vhall-mini-sdk 0.2.1 → 0.3.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +44 -0
- package/lib/components/announcement/announ-banner/index.js +40 -0
- package/lib/components/announcement/announ-banner/index.json +4 -0
- package/lib/components/announcement/announ-banner/index.wxml +13 -0
- package/lib/components/announcement/announ-banner/index.wxss +1 -0
- package/lib/components/announcement/announ-icon/index.js +69 -0
- package/lib/components/announcement/announ-icon/index.json +3 -0
- package/lib/components/announcement/announ-icon/index.wxml +10 -0
- package/lib/components/announcement/announ-icon/index.wxss +1 -0
- package/lib/components/announcement/announ-popup/index.js +44 -0
- package/lib/components/announcement/announ-popup/index.json +7 -0
- package/lib/components/announcement/announ-popup/index.wxml +39 -0
- package/lib/components/announcement/announ-popup/index.wxss +1 -0
- package/lib/components/announcement/index.js +223 -0
- package/lib/components/announcement/index.json +9 -0
- package/lib/components/announcement/index.wxml +6 -0
- package/lib/components/announcement/index.wxss +0 -0
- package/lib/components/live-landscape/live-landscape.js +7 -1
- package/lib/components/live-landscape/live-landscape.json +2 -0
- package/lib/components/live-landscape/live-landscape.wxml +7 -4
- package/lib/components/live-portrait/live-portrait.js +10 -2
- package/lib/components/live-portrait/live-portrait.json +3 -1
- package/lib/components/live-portrait/live-portrait.wxml +8 -4
- package/lib/components/mall-reward/index.js +47 -29
- package/lib/components/product/product-card/product-card.js +5 -6
- package/lib/components/product/product-detail/product-detail.js +6 -6
- package/lib/components/product/product-list/product-list.js +2 -3
- package/lib/sdk/main/index.js +2 -2
- package/lib/sdk/plugins/MallRewardServer.js +1 -1
- package/package.json +8 -11
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";function _callSuper(t,o,e){return o=_getPrototypeOf(o),function _possibleConstructorReturn(t,e){if(e&&("object"==typeof e||"function"==typeof e))return e;if(void 0!==e)throw new TypeError("Derived constructors may only return object or undefined");return function _assertThisInitialized(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}(t)}(t,_isNativeReflectConstruct()?Reflect.construct(o,[],_getPrototypeOf(t).constructor):o.apply(t,e))}function _createClass(e,r,t){return r&&function _defineProperties(e,r){for(var t=0;t<r.length;t++){var o=r[t];o.enumerable=o.enumerable||!1,o.configurable=!0,"value"in o&&(o.writable=!0),Object.defineProperty(e,_toPropertyKey(o.key),o)}}(e.prototype,r),Object.defineProperty(e,"prototype",{writable:!1}),e}function _getPrototypeOf(t){return _getPrototypeOf=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(t){return t.__proto__||Object.getPrototypeOf(t)},_getPrototypeOf(t)}function _isNativeReflectConstruct(){try{var t=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}))}catch(t){}return(_isNativeReflectConstruct=function(){return!!t})()}function _setPrototypeOf(t,e){return _setPrototypeOf=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(t,e){return t.__proto__=e,t},_setPrototypeOf(t,e)}function _toPropertyKey(t){var i=function _toPrimitive(t,r){if("object"!=typeof t||!t)return t;var e=t[Symbol.toPrimitive];if(void 0!==e){var i=e.call(t,r);if("object"!=typeof i)return i;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===r?String:Number)(t)}(t,"string");return"symbol"==typeof i?i:i+""}class BaseServer{constructor(){this.handlers=Object.create(null)}on=(type,handler)=>{const bindings=[];if("object"==typeof type&&null!==type)Object.entries(type).forEach(([eventName,eventHandler])=>{this._validateParams(eventName,eventHandler),this._addHandler(eventName,eventHandler),bindings.push({type:eventName,handler:eventHandler})});else{if("string"!=typeof type||"function"!=typeof handler)throw new Error("参数格式错误,支持:$on(事件名, 处理函数) 或 $on({事件名: 处理函数, ...})");this._validateParams(type,handler),this._addHandler(type,handler),bindings.push({type:type,handler:handler})}return()=>{bindings.forEach(({type:eventName,handler:eventHandler})=>{if(!this.handlers[eventName])return;const index=this.handlers[eventName].findIndex(handler=>handler===eventHandler);-1!==index&&(this.handlers[eventName].splice(index,1),0===this.handlers[eventName].length&&delete this.handlers[eventName])})}};emit=(type,...params)=>{this.handlers[type]&&[...this.handlers[type]].forEach(handler=>{handler(...params)})};off=(type,handler)=>{if(!this.handlers[type])throw new Error(`不存在事件: ${type}`);if(handler){const index=this.handlers[type].findIndex(ele=>ele===handler);this.handlers[type].splice(index,1),0===this.handlers[type].length&&delete this.handlers[type]}else delete this.handlers[type]};_validateParams(type,handler){if("string"!=typeof type)throw new Error("事件名必须为字符串");if("function"!=typeof handler)throw new Error("事件处理函数必须为函数")}_addHandler(type,handler){this.handlers[type]||(this.handlers[type]=[]),this.handlers[type].includes(handler)||this.handlers[type].push(handler)}}const LOG_LEVEL_trace=0,LOG_LEVEL_debug=1,LOG_LEVEL_info=2,LOG_LEVEL_log=2,LOG_LEVEL_warn=3,LOG_LEVEL_error=4;let _logLevel=LOG_LEVEL_info;function formatTime(){const date=new Date,pad=(n,len=2)=>String(n).padStart(len,"0");return`${pad(date.getHours())}:${pad(date.getMinutes())}:${pad(date.getSeconds())}:${pad(date.getMilliseconds(),3)}`}const logger=function createLogger(module=""){const prefix=module?`[${module}]`:"",appPrefix="VhallMiniSDK",enabled=level=>level>=_logLevel;return{trace:function trace(...args){enabled(LOG_LEVEL_trace)&&console.trace(`${appPrefix} [${formatTime()}] <TRACE> ${prefix} `,...args)},debug:function debug(...args){enabled(LOG_LEVEL_debug)&&console.debug(`${appPrefix} [${formatTime()}] <DEBUG> ${prefix} `,...args)},info:function info(...args){enabled(LOG_LEVEL_info)&&console.info(`${appPrefix} [${formatTime()}] <INFO> ${prefix}`,...args)},log:function log(...args){enabled(LOG_LEVEL_log)&&console.log(`${appPrefix} [${formatTime()}] <LOG> ${prefix}`,...args)},warn:function warn(...args){enabled(LOG_LEVEL_warn)&&console.warn(`${appPrefix} [${formatTime()}] <WARN> ${prefix}`,...args)},error:function error(...args){enabled(LOG_LEVEL_error)&&console.error(`${appPrefix} [${formatTime()}] <ERROR> ${prefix}`,...args)}}}("MallRewardServer");let MallRewardServer=function(){function MallRewardServer(sdkInstance){var _this;return function _classCallCheck(a,n){if(!(a instanceof n))throw new TypeError("Cannot call a class as a function")}(this,MallRewardServer),(_this=_callSuper(this,MallRewardServer)).sdkInstance=sdkInstance,_this.wxApi=sdkInstance.wxApi,_this}return function _inherits(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function");t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,writable:!0,configurable:!0}}),Object.defineProperty(t,"prototype",{writable:!1}),e&&_setPrototypeOf(t,e)}(MallRewardServer,BaseServer),_createClass(MallRewardServer,[{key:"getValidList",value:async function getValidList(){
|
|
1
|
+
"use strict";function _callSuper(t,o,e){return o=_getPrototypeOf(o),function _possibleConstructorReturn(t,e){if(e&&("object"==typeof e||"function"==typeof e))return e;if(void 0!==e)throw new TypeError("Derived constructors may only return object or undefined");return function _assertThisInitialized(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}(t)}(t,_isNativeReflectConstruct()?Reflect.construct(o,[],_getPrototypeOf(t).constructor):o.apply(t,e))}function _createClass(e,r,t){return r&&function _defineProperties(e,r){for(var t=0;t<r.length;t++){var o=r[t];o.enumerable=o.enumerable||!1,o.configurable=!0,"value"in o&&(o.writable=!0),Object.defineProperty(e,_toPropertyKey(o.key),o)}}(e.prototype,r),Object.defineProperty(e,"prototype",{writable:!1}),e}function _getPrototypeOf(t){return _getPrototypeOf=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(t){return t.__proto__||Object.getPrototypeOf(t)},_getPrototypeOf(t)}function _isNativeReflectConstruct(){try{var t=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}))}catch(t){}return(_isNativeReflectConstruct=function(){return!!t})()}function _setPrototypeOf(t,e){return _setPrototypeOf=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(t,e){return t.__proto__=e,t},_setPrototypeOf(t,e)}function _toPropertyKey(t){var i=function _toPrimitive(t,r){if("object"!=typeof t||!t)return t;var e=t[Symbol.toPrimitive];if(void 0!==e){var i=e.call(t,r);if("object"!=typeof i)return i;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===r?String:Number)(t)}(t,"string");return"symbol"==typeof i?i:i+""}class BaseServer{constructor(){this.handlers=Object.create(null)}on=(type,handler)=>{const bindings=[];if("object"==typeof type&&null!==type)Object.entries(type).forEach(([eventName,eventHandler])=>{this._validateParams(eventName,eventHandler),this._addHandler(eventName,eventHandler),bindings.push({type:eventName,handler:eventHandler})});else{if("string"!=typeof type||"function"!=typeof handler)throw new Error("参数格式错误,支持:$on(事件名, 处理函数) 或 $on({事件名: 处理函数, ...})");this._validateParams(type,handler),this._addHandler(type,handler),bindings.push({type:type,handler:handler})}return()=>{bindings.forEach(({type:eventName,handler:eventHandler})=>{if(!this.handlers[eventName])return;const index=this.handlers[eventName].findIndex(handler=>handler===eventHandler);-1!==index&&(this.handlers[eventName].splice(index,1),0===this.handlers[eventName].length&&delete this.handlers[eventName])})}};emit=(type,...params)=>{this.handlers[type]&&[...this.handlers[type]].forEach(handler=>{handler(...params)})};off=(type,handler)=>{if(!this.handlers[type])throw new Error(`不存在事件: ${type}`);if(handler){const index=this.handlers[type].findIndex(ele=>ele===handler);this.handlers[type].splice(index,1),0===this.handlers[type].length&&delete this.handlers[type]}else delete this.handlers[type]};_validateParams(type,handler){if("string"!=typeof type)throw new Error("事件名必须为字符串");if("function"!=typeof handler)throw new Error("事件处理函数必须为函数")}_addHandler(type,handler){this.handlers[type]||(this.handlers[type]=[]),this.handlers[type].includes(handler)||this.handlers[type].push(handler)}}const LOG_LEVEL_trace=0,LOG_LEVEL_debug=1,LOG_LEVEL_info=2,LOG_LEVEL_log=2,LOG_LEVEL_warn=3,LOG_LEVEL_error=4;let _logLevel=LOG_LEVEL_info;function formatTime(){const date=new Date,pad=(n,len=2)=>String(n).padStart(len,"0");return`${pad(date.getHours())}:${pad(date.getMinutes())}:${pad(date.getSeconds())}:${pad(date.getMilliseconds(),3)}`}const logger=function createLogger(module=""){const prefix=module?`[${module}]`:"",appPrefix="VhallMiniSDK",enabled=level=>level>=_logLevel;return{trace:function trace(...args){enabled(LOG_LEVEL_trace)&&console.trace(`${appPrefix} [${formatTime()}] <TRACE> ${prefix} `,...args)},debug:function debug(...args){enabled(LOG_LEVEL_debug)&&console.debug(`${appPrefix} [${formatTime()}] <DEBUG> ${prefix} `,...args)},info:function info(...args){enabled(LOG_LEVEL_info)&&console.info(`${appPrefix} [${formatTime()}] <INFO> ${prefix}`,...args)},log:function log(...args){enabled(LOG_LEVEL_log)&&console.log(`${appPrefix} [${formatTime()}] <LOG> ${prefix}`,...args)},warn:function warn(...args){enabled(LOG_LEVEL_warn)&&console.warn(`${appPrefix} [${formatTime()}] <WARN> ${prefix}`,...args)},error:function error(...args){enabled(LOG_LEVEL_error)&&console.error(`${appPrefix} [${formatTime()}] <ERROR> ${prefix}`,...args)}}}("MallRewardServer");let MallRewardServer=function(){function MallRewardServer(sdkInstance){var _this;return function _classCallCheck(a,n){if(!(a instanceof n))throw new TypeError("Cannot call a class as a function")}(this,MallRewardServer),(_this=_callSuper(this,MallRewardServer)).sdkInstance=sdkInstance,_this.wxApi=sdkInstance.wxApi,_this}return function _inherits(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function");t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,writable:!0,configurable:!0}}),Object.defineProperty(t,"prototype",{writable:!1}),e&&_setPrototypeOf(t,e)}(MallRewardServer,BaseServer),_createClass(MallRewardServer,[{key:"getValidList",value:async function getValidList(){const watchInitData=this.sdkInstance.store.get("watchInitData"),params={webinar_id:this.sdkInstance.webinarId,sence_type:5==watchInitData?.webinar?.type?1:0,switch_id:watchInitData?.switch?.switch_id};try{const res=await this.wxApi.sendPost("/v3/vss/mall-reward/get-valid-list",params,{headers:{"Content-Type":"application/x-www-form-urlencoded"}});return res&&200===res.code&&res.data&&(Array.isArray(res.data.list)&&res.data.list.forEach(item=>{item.tip_setting=function(val){const type=Object.prototype.toString.call(val);if(["[object Array]","[object Object]","[object Null]"].includes(type))return val;try{return JSON.parse(val)}catch(ex){return null}}(item.tip_setting)}),this.sdkInstance.store.set("mallRewardInfo",res?.data||null),this.updateActiveMallReward()),res?.data||null}catch(error){return logger.error("获取商城奖励列表出现异常,error:",error),null}}},{key:"updateActiveMallReward",value:function updateActiveMallReward(){const mallRewardInfo=this.sdkInstance.store.get("mallRewardInfo");if(!mallRewardInfo||!mallRewardInfo.list||0===mallRewardInfo.list.length)return null;let minViewingMinutes,idx=-1;for(let i=0;i<mallRewardInfo.list.length;i++){let item=mallRewardInfo.list[i];if(0===item.claim_status&&0===item.viewing_minutes&&1===item.status&&item.remaining_quota>0){idx=i;break}0===item.claim_status&&item.viewing_minutes>0&&0===item.status&&item.remaining_quota>0&&(void 0===minViewingMinutes||item.watch_minute<minViewingMinutes)&&(minViewingMinutes=item.viewing_minutes,idx=i)}return idx>-1?mallRewardInfo.list[idx]:null}},{key:"claimMallReward",value:async function claimMallReward(rewardId){const watchInitData=this.sdkInstance.store.get("watchInitData"),params={reward_id:rewardId,webinar_id:this.sdkInstance.webinarId,sence_type:5==watchInitData?.webinar?.type?1:0,switch_id:watchInitData?.switch?.switch_id};try{return await this.wxApi.sendPost("/v3/vss/mall-reward/receive",params,{headers:{"Content-Type":"application/x-www-form-urlencoded"}})}catch(error){return logger.error("领取商城奖励出现异常,error:",error),error}}}])}();!function _defineProperty(e,r,t){return(r=_toPropertyKey(r))in e?Object.defineProperty(e,r,{value:t,enumerable:!0,configurable:!0,writable:!0}):e[r]=t,e}(MallRewardServer,"name","MallRewardServer"),module.exports=MallRewardServer;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "vhall-mini-sdk",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.3.1",
|
|
4
4
|
"author": "vhall",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"miniprogram": "lib",
|
|
@@ -18,7 +18,8 @@
|
|
|
18
18
|
"files": [
|
|
19
19
|
"dist",
|
|
20
20
|
"lib",
|
|
21
|
-
"postinstall.js"
|
|
21
|
+
"postinstall.js",
|
|
22
|
+
"CHANGELOG.md"
|
|
22
23
|
],
|
|
23
24
|
"lint-staged": {
|
|
24
25
|
"*.{ts,js}": [
|
|
@@ -40,10 +41,11 @@
|
|
|
40
41
|
"@babel/plugin-transform-modules-commonjs": "^7.16.0",
|
|
41
42
|
"@babel/preset-env": "^7.21.4",
|
|
42
43
|
"@babel/preset-typescript": "^7.16.0",
|
|
43
|
-
"@rollup/plugin-babel": "^
|
|
44
|
-
"@rollup/plugin-commonjs": "^
|
|
45
|
-
"@rollup/plugin-node-resolve": "^16.0.
|
|
46
|
-
"@rollup/plugin-
|
|
44
|
+
"@rollup/plugin-babel": "^6.0.4",
|
|
45
|
+
"@rollup/plugin-commonjs": "^28.0.0",
|
|
46
|
+
"@rollup/plugin-node-resolve": "^16.0.0",
|
|
47
|
+
"@rollup/plugin-replace": "^6.0.3",
|
|
48
|
+
"@rollup/plugin-terser": "^0.4.4",
|
|
47
49
|
"@types/jest": "^27.0.2",
|
|
48
50
|
"@types/wechat-miniprogram": "^3.4.8",
|
|
49
51
|
"gulp": "^4.0.2",
|
|
@@ -57,12 +59,7 @@
|
|
|
57
59
|
"gulp-typescript": "^6.0.0-alpha.1",
|
|
58
60
|
"husky": "^9.1.7",
|
|
59
61
|
"jest": "^27.3.1",
|
|
60
|
-
"@rollup/plugin-babel": "^6.0.4",
|
|
61
|
-
"@rollup/plugin-commonjs": "^28.0.0",
|
|
62
|
-
"@rollup/plugin-node-resolve": "^16.0.0",
|
|
63
|
-
"@rollup/plugin-terser": "^0.4.4",
|
|
64
62
|
"lint-staged": "^13.0.3",
|
|
65
|
-
"rollup": "^4.24.0",
|
|
66
63
|
"merge2": "^1.4.1",
|
|
67
64
|
"miniprogram-api-typings": "^3.1.6",
|
|
68
65
|
"miniprogram-ci": "^1.6.1",
|