Files
ruo-shan-cloud-pharmacy/miniprogram/package-live/volc-mini-sdk/utils/singleLogin.js
T
陈誉午 994b267f5c feat: 电子药箱小程序 - 4Tab药品管理
- 电子药箱: 药品库存管理 + 手动录入 + 今日用药打卡
- 药品百科: 搜索 + 分类筛选 + 20种药品静态数据
- 惠教中心: 4条药品使用指南课程
- 我的: 家庭成员信息管理
- 自定义TabBar + navigation-bar组件
- SVG药品分类插图
2026-07-29 11:20:52 +08:00

1 line
14 KiB
JavaScript

"use strict";function _typeof(e){return _typeof="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},_typeof(e)}Object.defineProperty(exports,"__esModule",{value:!0}),exports.updatePlayerInstance=exports.updateBanStatus=exports.resumePlayer=exports.playerInstance=exports.pausePlayer=exports.isRepeatConsume=exports.handleForceExitMessage=exports.handleBanStatusChange=exports.handleBanContinue=exports.getBanTypeByErrorCode=exports.getBanTipsText=exports.clearExitTimeList=exports.clearCacheUserInfo=void 0;var _constant=require("./constant"),_times=require("./times"),_loop=require("./loop"),_utils=require("./utils");function ownKeys(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),r.push.apply(r,n)}return r}function _objectSpread(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{};t%2?ownKeys(Object(r),!0).forEach(function(t){_defineProperty(e,t,r[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):ownKeys(Object(r)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))})}return e}function _defineProperty(e,t,r){return(t=_toPropertyKey(t))in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}function _toPropertyKey(e){var t=_toPrimitive(e,"string");return"symbol"===_typeof(t)?t:String(t)}function _toPrimitive(e,t){if("object"!==_typeof(e)||null===e)return e;var r=e[Symbol.toPrimitive];if(void 0!==r){var n=r.call(e,t||"default");if("object"!==_typeof(n))return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===t?String:Number)(e)}function _regeneratorRuntime(){_regeneratorRuntime=function(){return e};var e={},t=Object.prototype,r=t.hasOwnProperty,n=Object.defineProperty||function(e,t,r){e[t]=r.value},o="function"==typeof Symbol?Symbol:{},a=o.iterator||"@@iterator",i=o.asyncIterator||"@@asyncIterator",s=o.toStringTag||"@@toStringTag";function c(e,t,r){return Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}),e[t]}try{c({},"")}catch(e){c=function(e,t,r){return e[t]=r}}function u(e,t,r,o){var a=t&&t.prototype instanceof f?t:f,i=Object.create(a.prototype),s=new w(o||[]);return n(i,"_invoke",{value:P(e,r,s)}),i}function l(e,t,r){try{return{type:"normal",arg:e.call(t,r)}}catch(e){return{type:"throw",arg:e}}}e.wrap=u;var p={};function f(){}function y(){}function h(){}var d={};c(d,a,function(){return this});var v=Object.getPrototypeOf,_=v&&v(v(S([])));_&&_!==t&&r.call(_,a)&&(d=_);var g=h.prototype=f.prototype=Object.create(d);function m(e){["next","throw","return"].forEach(function(t){c(e,t,function(e){return this._invoke(t,e)})})}function E(e,t){function o(n,a,i,s){var c=l(e[n],e,a);if("throw"!==c.type){var u=c.arg,p=u.value;return p&&"object"==_typeof(p)&&r.call(p,"__await")?t.resolve(p.__await).then(function(e){o("next",e,i,s)},function(e){o("throw",e,i,s)}):t.resolve(p).then(function(e){u.value=e,i(u)},function(e){return o("throw",e,i,s)})}s(c.arg)}var a;n(this,"_invoke",{value:function(e,r){function n(){return new t(function(t,n){o(e,r,t,n)})}return a=a?a.then(n,n):n()}})}function P(e,t,r){var n="suspendedStart";return function(o,a){if("executing"===n)throw new Error("Generator is already running");if("completed"===n){if("throw"===o)throw a;return{value:void 0,done:!0}}for(r.method=o,r.arg=a;;){var i=r.delegate;if(i){var s=x(i,r);if(s){if(s===p)continue;return s}}if("next"===r.method)r.sent=r._sent=r.arg;else if("throw"===r.method){if("suspendedStart"===n)throw n="completed",r.arg;r.dispatchException(r.arg)}else"return"===r.method&&r.abrupt("return",r.arg);n="executing";var c=l(e,t,r);if("normal"===c.type){if(n=r.done?"completed":"suspendedYield",c.arg===p)continue;return{value:c.arg,done:r.done}}"throw"===c.type&&(n="completed",r.method="throw",r.arg=c.arg)}}}function x(e,t){var r=t.method,n=e.iterator[r];if(void 0===n)return t.delegate=null,"throw"===r&&e.iterator.return&&(t.method="return",t.arg=void 0,x(e,t),"throw"===t.method)||"return"!==r&&(t.method="throw",t.arg=new TypeError("The iterator does not provide a '"+r+"' method")),p;var o=l(n,e.iterator,t.arg);if("throw"===o.type)return t.method="throw",t.arg=o.arg,t.delegate=null,p;var a=o.arg;return a?a.done?(t[e.resultName]=a.value,t.next=e.nextLoc,"return"!==t.method&&(t.method="next",t.arg=void 0),t.delegate=null,p):a:(t.method="throw",t.arg=new TypeError("iterator result is not an object"),t.delegate=null,p)}function b(e){var t={tryLoc:e[0]};1 in e&&(t.catchLoc=e[1]),2 in e&&(t.finallyLoc=e[2],t.afterLoc=e[3]),this.tryEntries.push(t)}function T(e){var t=e.completion||{};t.type="normal",delete t.arg,e.completion=t}function w(e){this.tryEntries=[{tryLoc:"root"}],e.forEach(b,this),this.reset(!0)}function S(e){if(e){var t=e[a];if(t)return t.call(e);if("function"==typeof e.next)return e;if(!isNaN(e.length)){var n=-1,o=function t(){for(;++n<e.length;)if(r.call(e,n))return t.value=e[n],t.done=!1,t;return t.value=void 0,t.done=!0,t};return o.next=o}}return{next:O}}function O(){return{value:void 0,done:!0}}return y.prototype=h,n(g,"constructor",{value:h,configurable:!0}),n(h,"constructor",{value:y,configurable:!0}),y.displayName=c(h,s,"GeneratorFunction"),e.isGeneratorFunction=function(e){var t="function"==typeof e&&e.constructor;return!!t&&(t===y||"GeneratorFunction"===(t.displayName||t.name))},e.mark=function(e){return Object.setPrototypeOf?Object.setPrototypeOf(e,h):(e.__proto__=h,c(e,s,"GeneratorFunction")),e.prototype=Object.create(g),e},e.awrap=function(e){return{__await:e}},m(E.prototype),c(E.prototype,i,function(){return this}),e.AsyncIterator=E,e.async=function(t,r,n,o,a){void 0===a&&(a=Promise);var i=new E(u(t,r,n,o),a);return e.isGeneratorFunction(r)?i:i.next().then(function(e){return e.done?e.value:i.next()})},m(g),c(g,s,"Generator"),c(g,a,function(){return this}),c(g,"toString",function(){return"[object Generator]"}),e.keys=function(e){var t=Object(e),r=[];for(var n in t)r.push(n);return r.reverse(),function e(){for(;r.length;){var n=r.pop();if(n in t)return e.value=n,e.done=!1,e}return e.done=!0,e}},e.values=S,w.prototype={constructor:w,reset:function(e){if(this.prev=0,this.next=0,this.sent=this._sent=void 0,this.done=!1,this.delegate=null,this.method="next",this.arg=void 0,this.tryEntries.forEach(T),!e)for(var t in this)"t"===t.charAt(0)&&r.call(this,t)&&!isNaN(+t.slice(1))&&(this[t]=void 0)},stop:function(){this.done=!0;var e=this.tryEntries[0].completion;if("throw"===e.type)throw e.arg;return this.rval},dispatchException:function(e){if(this.done)throw e;var t=this;function n(r,n){return i.type="throw",i.arg=e,t.next=r,n&&(t.method="next",t.arg=void 0),!!n}for(var o=this.tryEntries.length-1;o>=0;--o){var a=this.tryEntries[o],i=a.completion;if("root"===a.tryLoc)return n("end");if(a.tryLoc<=this.prev){var s=r.call(a,"catchLoc"),c=r.call(a,"finallyLoc");if(s&&c){if(this.prev<a.catchLoc)return n(a.catchLoc,!0);if(this.prev<a.finallyLoc)return n(a.finallyLoc)}else if(s){if(this.prev<a.catchLoc)return n(a.catchLoc,!0)}else{if(!c)throw new Error("try statement without catch or finally");if(this.prev<a.finallyLoc)return n(a.finallyLoc)}}}},abrupt:function(e,t){for(var n=this.tryEntries.length-1;n>=0;--n){var o=this.tryEntries[n];if(o.tryLoc<=this.prev&&r.call(o,"finallyLoc")&&this.prev<o.finallyLoc){var a=o;break}}a&&("break"===e||"continue"===e)&&a.tryLoc<=t&&t<=a.finallyLoc&&(a=null);var i=a?a.completion:{};return i.type=e,i.arg=t,a?(this.method="next",this.next=a.finallyLoc,p):this.complete(i)},complete:function(e,t){if("throw"===e.type)throw e.arg;return"break"===e.type||"continue"===e.type?this.next=e.arg:"return"===e.type?(this.rval=this.arg=e.arg,this.method="return",this.next="end"):"normal"===e.type&&t&&(this.next=t),p},finish:function(e){for(var t=this.tryEntries.length-1;t>=0;--t){var r=this.tryEntries[t];if(r.finallyLoc===e)return this.complete(r.completion,r.afterLoc),T(r),p}},catch:function(e){for(var t=this.tryEntries.length-1;t>=0;--t){var r=this.tryEntries[t];if(r.tryLoc===e){var n=r.completion;if("throw"===n.type){var o=n.arg;T(r)}return o}}throw new Error("illegal catch attempt")},delegateYield:function(e,t,r){return this.delegate={iterator:S(e),resultName:t,nextLoc:r},"next"===this.method&&(this.arg=void 0),p}},e}function asyncGeneratorStep(e,t,r,n,o,a,i){try{var s=e[a](i),c=s.value}catch(e){return void r(e)}s.done?t(c):Promise.resolve(c).then(n,o)}function _asyncToGenerator(e){return function(){var t=this,r=arguments;return new Promise(function(n,o){var a=e.apply(t,r);function i(e){asyncGeneratorStep(a,n,o,i,s,"next",e)}function s(e){asyncGeneratorStep(a,n,o,i,s,"throw",e)}i(void 0)})}}var playerInstance=null;exports.playerInstance=playerInstance;var clearCacheUserInfo=function(){var e=_asyncToGenerator(_regeneratorRuntime().mark(function e(t){return _regeneratorRuntime().wrap(function(e){for(;;)switch(e.prev=e.next){case 0:return console.log("clearCacheUserInfo called with errorCode:",null==t?void 0:t.errorCode),e.abrupt("return",!0);case 2:case"end":return e.stop()}},e)}));return function(t){return e.apply(this,arguments)}}();exports.clearCacheUserInfo=clearCacheUserInfo;var updateBanStatus=function(e,t){if(e){var r=e.get("banStatus")||{},n=r.isBanned,o=t.isBanned,a=t.isSoftBan;!0===n&&n===o&&a||e.set("banStatus",_objectSpread(_objectSpread({},r),t))}};exports.updateBanStatus=updateBanStatus;var getBanTypeByErrorCode=function(e){return e===_constant.ErrorCodeEnum.MULTI_DEVICE_LOGIN?_constant.BAN_TYPE.TOPPED:[_constant.ErrorCodeEnum.NOT_PASS_REVIEW,_constant.ErrorCodeEnum.KICK_OUT,_constant.ErrorCodeEnum.IP_BANNED,_constant.ErrorCodeEnum.NOT_IN_AUDIENCE_GROUP].includes(e)?_constant.BAN_TYPE.KICK_OUT:_constant.BAN_TYPE.NONE};exports.getBanTypeByErrorCode=getBanTypeByErrorCode;var getBanTipsText=function(e){var t;return(_defineProperty(t={},_constant.BAN_TYPE.TOPPED,"当前账号已在其他设备登录"),_defineProperty(t,_constant.BAN_TYPE.KICK_OUT,"因扰乱直播间秩序,已暂停观看"),_defineProperty(t,_constant.BAN_TYPE.CHECK_IN,"因长时间未签到,已暂停观看"),_defineProperty(t,_constant.BAN_TYPE.NONE,"因扰乱直播间秩序,已暂停观看"),t)[e]||""};exports.getBanTipsText=getBanTipsText;var isRepeatConsume=function(e){try{var t=wx.getStorageSync("exitTimeList"),r=t?JSON.parse(t):[];if(Array.isArray(r)){if(r.includes(e))return console.log("重复消费",r,e),!0;r.push(e),wx.setStorageSync("exitTimeList",JSON.stringify(r))}else console.warn("exitTimeList in storage is not an array, resetting to empty array"),wx.setStorageSync("exitTimeList",JSON.stringify([]))}catch(t){console.error("Failed to parse or update exitTimeList in storage:",t),wx.setStorageSync("exitTimeList",JSON.stringify([e]))}return!1};exports.isRepeatConsume=isRepeatConsume;var clearExitTimeList=function(){try{wx.removeStorageSync("exitTimeList"),console.log("exitTimeList cleared")}catch(e){console.error("Failed to clear exitTimeList:",e)}};exports.clearExitTimeList=clearExitTimeList;var handleForceExitMessage=function(e,t){var r;if(!e||!t)return!1;var n,o=e.ExitStatus,a=e.ExitTime,i=e.ExitTip;if(o===_constant.BanStatus.SOFT_BAN)return!!(a&&_times.firstEntryTime&&a>_times.firstEntryTime)&&!isRepeatConsume(a)&&(updateBanStatus(t.store,{isBanned:!0,banType:_constant.BAN_TYPE.KICK_OUT,banTips:i,isSoftBan:!0}),null===(n=t.pausePollingForBan)||void 0===n||n.call(t,"soft_ban"),!0);var s=(t.store.get("mainInfo")||{}).disableOfflineModal||!1,c=(_defineProperty(r={},_constant.BanStatus.FORCE_BAN,{banType:_constant.BAN_TYPE.KICK_OUT,errorEvent:_constant.SDKErrorEvent.LIVE_KICK_OUT}),_defineProperty(r,_constant.BanStatus.IP_BAN,{banType:_constant.BAN_TYPE.KICK_OUT,errorEvent:_constant.SDKErrorEvent.LIVE_IP_BANNED}),_defineProperty(r,_constant.BanStatus.MULTI_DEVICE_LOGIN,{banType:_constant.BAN_TYPE.TOPPED,errorEvent:_constant.SDKErrorEvent.LIVE_DUPLICATE_LOGIN}),r)[o];return!!c&&(s||updateBanStatus(t.store,{isBanned:!0,banType:c.banType,banTips:i||c.defaultTips}),"function"==typeof t.pausePollingForBan?t.pausePollingForBan("force_exit"):((0,_loop.clearLoop)(_loop.LOOP_KEY.Activity),(0,_loop.clearLoop)(_loop.LOOP_KEY.Chat),(0,_loop.clearLoop)(_loop.LOOP_KEY.Report)),t.emit(_constant.EVENTS.PUBLIC.error,{code:_constant.SDKErrorCode[c.errorEvent],message:_constant.SDKErrorMessage[c.errorEvent]}),!0)};exports.handleForceExitMessage=handleForceExitMessage;var updatePlayerInstance=function(e){exports.playerInstance=playerInstance=e,console.log("[PlayerInstance] Player instance updated:",playerInstance?"Success":"Cleared")};exports.updatePlayerInstance=updatePlayerInstance;var pausePlayer=function(){playerInstance&&"function"==typeof playerInstance.pause?(console.log("[PlayerControl] Pausing player via global instance"),playerInstance.pause()):console.warn("[PlayerControl] Global player instance not available or pause method unavailable")};exports.pausePlayer=pausePlayer;var resumePlayer=function(){playerInstance&&"function"==typeof playerInstance.play?(console.log("[PlayerControl] Resuming player via global instance"),playerInstance.play()):console.warn("[PlayerControl] Global player instance not available or play method unavailable")};exports.resumePlayer=resumePlayer;var handleBanStatusChange=function(e,t){if(t&&e){var r=t.isBanned,n=t.banType,o=t.isSoftBan,a=n!==_constant.BAN_TYPE.CHECK_IN&&!o;r?(pausePlayer(),a&&(0,_utils.setDataIfChanged)(e,{showPlayer:!1})):(0,_utils.setDataIfChanged)(e,{showPlayer:!0})}};exports.handleBanStatusChange=handleBanStatusChange;var handleBanContinue=function(e,t,r){var n,o;if(e){console.log("[BanControl] User clicked continue watch");var a,i=t||(null===(n=e.data)||void 0===n?void 0:n.sdkInstance)||(null===(o=e.properties)||void 0===o?void 0:o.sdkInstance);r&&!0!==r.isSoftBan||null==i||null===(a=i.resumePollingAfterBan)||void 0===a||a.call(i),(0,_utils.setDataIfChanged)(e,{showPlayer:!0},function(){resumePlayer()})||resumePlayer()}else console.error("[BanControl] Invalid context provided for continue watch")};exports.handleBanContinue=handleBanContinue;