zg-sdk-wechart 2.0.3 → 2.0.4
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/README.md +5 -1
- package/dist/zhuge.es.min.js +1 -1
- package/dist/zhuge.min.js +1 -1
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -84,6 +84,7 @@ sdk配置信息。不需要自定义的参数可忽略
|
|
|
84
84
|
superProperty: { // 全局事件属性,设置后除会话、环境及identify事件外,所有事件都会自动加上该配置所有属性
|
|
85
85
|
propA: 'hello'
|
|
86
86
|
},
|
|
87
|
+
requestTimeout: 60000, // 请求超时时间,单位毫秒。微信基础库最低版本要求为2.10.0。默认与最大值为60秒
|
|
87
88
|
sendLimit: 1, // 批量上传限制,默认为1。即事件即时上传。当该配置大于1时,事件会累计达到limit限制再批量上传,也可调用flush方法手动清空
|
|
88
89
|
shareToUtm: { // 打开分享页面时,分享属性到utm信息的映射配置。当设置该映射后,映射的分享属性会当做对应的utm信息就行setUtm操作
|
|
89
90
|
商品名称: 'utm_content' // 分享打开的「商品名称」属性,映射为utm_content属性
|
|
@@ -309,4 +310,7 @@ class Index extends Component {
|
|
|
309
310
|
|
|
310
311
|
export default Index;
|
|
311
312
|
|
|
312
|
-
```
|
|
313
|
+
```
|
|
314
|
+
|
|
315
|
+
#### 6. sendLimit批量上传时,上传时机是什么时候?
|
|
316
|
+
当设置了sendLimit时,触发的所有埋点请求,会达到limit指定数量时,将所有埋点数据合并为一个请求进行上传。另外为避免数据丢失的可能性,当页面触发Page的onHide、onUnload生命周期时,不管请求数量是否达到limit限制,都会将已缓存数据进行上传。
|
package/dist/zhuge.es.min.js
CHANGED
|
@@ -13,4 +13,4 @@ LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
|
|
|
13
13
|
OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
|
|
14
14
|
PERFORMANCE OF THIS SOFTWARE.
|
|
15
15
|
***************************************************************************** */
|
|
16
|
-
function d(t,e,r,n){var i,o=arguments.length,u=o<3?e:null===n?n=Object.getOwnPropertyDescriptor(e,r):n;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)u=Reflect.decorate(t,e,r,n);else for(var a=t.length-1;a>=0;a--)(i=t[a])&&(u=(o<3?i(u):o>3?i(e,r,u):i(e,r))||u);return o>3&&u&&Object.defineProperty(e,r,u),u}function v(t,e,r,n){return new(r||(r=Promise))((function(i,o){function u(t){try{s(n.next(t))}catch(t){o(t)}}function a(t){try{s(n.throw(t))}catch(t){o(t)}}function s(t){var e;t.done?i(t.value):(e=t.value,e instanceof r?e:new r((function(t){t(e)}))).then(u,a)}s((n=n.apply(t,e||[])).next())}))}var g,y,_,w={utmKeys:["utm_source","utm_medium","utm_campaign","utm_content","utm_term"],isValid:function(t){return null==t},type:function(t){return Object.prototype.toString.call(t)},isObject:function(t){return"[object Object]"===this.type(t)},isArray:function(t){return"[object Array]"===this.type(t)},isString:function(t){return"[object String]"===this.type(t)},isNumber:function(t){return"[object Number]"===this.type(t)},isDate:function(t){return"[object Date]"===this.type(t)},isFunction:function(t){return"[object Function]"===this.type(t)},isEmpty:function(t){return Array.isArray(t)||"string"==typeof t||t instanceof String?0===t.length:t instanceof Map||t instanceof Set?0===t.size:"[object Object]"===Object.prototype.toString.call(t)&&0===Object.keys(t).length},merge:function(){for(var t=this,e=arguments.length,r=new Array(e),n=0;n<e;n++)r[n]=arguments[n];return r.reduce((function(e,r){return Object.keys(r).forEach((function(n){Array.isArray(e[n])&&Array.isArray(r[n])?e[n]=Array.from(new Set(e[n].concat(r[n]))):t.isObject(e[n])&&t.isObject(r[n])?e[n]=t.merge(e[n],r[n]):e[n]=r[n]})),e}),{})},UUID:function(){var t=function(){return Math.floor(65536*(1+Math.random())).toString(16).substring(1)};return t()+t()+"-"+t()+"-"+t()+"-"+t()+"-"+t()+t()+t()},clone:function(t){var r=function(t){var e=t.constructor;switch(n(t)){case"Boolean":case"Number":case"String":case"Error":case"Date":return new e(t);case"RegExp":return o(t);case"Symbol":return i(t);case"Function":return t;default:return null}},n=function(t){return Object.prototype.toString.call(t).slice(8,-1)},i=function(t){return Object(Symbol.prototype.valueOf.call(t))},o=function(t){var e=new t.constructor(t.source,/\w*$/.exec(t));return e.lastIndex=t.lastIndex,e},u=function(t,e){for(var r=-1,n=t.length;++r<n;)e(t[r],r);return t},a=function t(i){var o=arguments.length>1&&void 0!==arguments[1]?arguments[1]:new WeakMap;if("object"!==e(i)||null===i)return i;var a=n(i),s=null;return o.get(i)?o.get(i):(o.set(i,s),"Set"!==a&&"Map"!==a&&"Array"!==a&&"Object"!==a?r(i):"Set"===a?(s=new Set,i.forEach((function(e){s.add(t(e,o))})),s):"Map"===a?(s=new Map,i.forEach((function(e,r){s.set(r,t(e,o))})),s):("Array"===a&&(s=new Array,u(i,(function(e,r){s[r]=t(e,o)}))),"Object"===a&&(s=new Object,u(Object.keys(i),(function(e){s[e]=t(i[e],o)}))),s))};return a(t)},parseQuery:function(t){if(this.isEmpty(t))return"";var e=[];for(var r in t)e.push("".concat(r,"=").concat(t[r]));return e.join("&")},getTimezone:function(t){return 6e4*-t.getTimezoneOffset()},encode:function(t){var e={};for(var r in t)e["_"+r]=t[r];return e},isEqual:function(t,e){if(this.type(t)!==this.type(e))return!1;var r=!0;for(var n in t)t[n]!==e[n]&&(r=!1);return r},getUtmByQuery:function(t){var e={};for(var r in t)this.utmKeys.includes(r)&&(e[r]=t[r]);return e},filterUtm:function(t){var e=["utm_source","utm_medium","utm_campaign","utm_content","utm_term"],r=!1,n={};for(var i in t)e.indexOf(i)>-1&&(r=!0,n[i]=t[i]);return r?n:null},deleteQueryParams:function(t,e){var r=t.split("&"),n=[];return r.forEach((function(t){var r=new RegExp(e+"=.*"),i="";r.test(t)?(i=t.replace(r,""))&&n.push(i):n.push(t)})),n.join("&")},addUrlParam:function(t,e){var r=t,n="";for(var i in e)n&&(n+="&"),r=this.deleteQueryParams(r,i),n+=i+"="+e[i];var o=r.split("?");return o.length>1?o[1]?o[1]=n+"&"+o[1]:o[1]=n:1===o.length&&o.push(n),o.join("?")},getCurrentPage:function(){var t=getCurrentPages();return t[t.length-1]},wxGetTitle:function(t){var e="";t.data&&t.data.title&&t.data.title.length>0&&(e=Array.isArray(t.data.title)?t.data.title.join(" "):t.data.title);try{if(!e.length&&__wxConfig&&(__wxConfig.tabBar&&__wxConfig.tabBar.list.forEach((function(r){r.pagePath==="".concat(t.route,".html")&&r.text&&(e=r.text)})),!e.length)){var r=__wxConfig.page[t.route]||__wxConfig.page["".concat(t.route,".html")];e=r?r.window.navigationBarTitleText:__wxConfig.global.window.navigationBarTitleText}}catch(t){console.error("解析title错误",t)}return e||t.route}},b=function(){function t(e,n){r(this,t),this.timeout=500,this.catch=[],this.clearCatchTimer=null,this.url="".concat(n.config.serverUrl.normal,"/apipool"),this.timeout=n.config.timeout||this.timeout,this.debug=n.config.debug?1:0,this.appKey=n.appKey,this.did=n.storage.allData.did,this.sendLimit=n.config.sendLimit,this.requestFunction=e}return i(t,[{key:"generateRequestData",value:function(){var t=new Date,e={method:"web_event_sr.upload",event:JSON.stringify({sln:"itn",pl:"js",sdk:"sys",sdkv:"2.0",owner:"zg",ut:"".concat(t.getFullYear(),"-").concat(t.getMonth()+1,"-").concat(t.getDate()," ").concat(t.getHours(),":").concat(t.getMinutes(),":").concat(t.getSeconds()),tz:w.getTimezone(t),debug:this.debug?1:0,ak:this.appKey,usr:{did:this.did},data:h(this.catch)}),_:t.getTime()+""};return this.catch=[],e}},{key:"clear",value:function(){var t=this.generateRequestData();this.requestFunction(this.url,t)}},{key:"send",value:function(t){var e=this;if(this.catch.push(t),this.clearCatchTimer&&clearTimeout(this.clearCatchTimer),this.clearCatchTimer=setTimeout((function(){e.clear()}),3e4),!(this.catch.length<this.sendLimit)){this.clearCatchTimer&&clearTimeout(this.clearCatchTimer);var r=this.generateRequestData();return new Promise((function(t,n){var i,o=!1;i=setTimeout((function(){o=!0,t(null)}),e.timeout),e.requestFunction(e.url,r).then((function(e){o||(clearTimeout(i),t(e))})).catch((function(t){n(t)}))}))}}}]),t}(),x=function(){function e(t,n,i){r(this,e),this.storageFunction=t,this.allData=i||{},this.allData.did||this.set("did",n.config.did||w.UUID()),this.allData.cuid||this.set("cuid",void 0),w.isEmpty(n.config.utm)||this.set("utm",n.config.utm)}return i(e,[{key:"get",value:function(t){return this.allData[t]}},{key:"set",value:function(e,r){return v(this,void 0,void 0,t.mark((function n(){return t.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return this.allData[e]=r,t.next=3,this.storageFunction.set("zg",this.allData);case 3:case"end":return t.stop()}}),n,this)})))}}]),e}();function k(t,e,r){var n=r.value;return r.value=function(){for(var t=arguments.length,r=new Array(t),i=0;i<t;i++)r[i]=arguments[i];if(this.pageReady&&this.loadReady)return n.apply(this,r);this.buffer.push({fnName:e,args:r})},r}var S=function(){function e(t,n,i){r(this,e),this.buffer=[],this.currentPage={queryObj:{},query:"",route:"",time:0,url:"",title:""},this.prevPage={queryObj:{},query:"",route:"",time:0,url:"",title:""},this.cn="",this.previousCountEvent={name:"",props:{}},this.count=0,this.countTimer=null,this.pageReady=!1,this.loadReady=!1,y=t,g=n,_=i,this.referrerDomain="miniprogram",this.appKey="",this.config={serverUrl:{normal:"https://u.zhugeapi.net",bac:"https://ubak.zhugeio.com"},debug:!1,pv:!1,click:!1,timeout:18e5,requestTimeout:500,did:"",duration:!1,vn:"1.0",appId:"",sendLimit:1,superProperty:{},forwardShare:!1,beforeDuration:function(){},afterDuration:function(){},countDuration:3e3,parseScene:!0,utm:{},utmMode:"session",shareToUtm:{},exposure:!1}}return i(e,[{key:"load",value:function(e,r){return v(this,void 0,void 0,t.mark((function n(){var i;return t.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return this.appKey=e,this.config=w.merge(this.config,r),t.prev=2,t.next=5,g.get();case 5:if((i=t.sent).did){t.next=10;break}return t.next=9,g.getDid();case 9:i.did=t.sent;case 10:this.storage=new x(g,this,i),this.request=new b(y,this),this.loadReady=!0,this.updateSession("load"),this.freeBuffer(),t.next=20;break;case 17:t.prev=17,t.t0=t.catch(2),console.error("sdk初始化失败,缓存读取失败",t.t0);case 20:case"end":return t.stop()}}),n,this,[[2,17]])})))}},{key:"freeBuffer",value:function(){if(this.loadReady&&this.pageReady)for(;this.buffer.length;){var t=this.buffer.shift();if(t)(e.prototype[t.fnName]||this[t.fnName]).apply(this,t.args)}}},{key:"send",value:function(t){var e=this.storage.allData.utm;if(e)for(var r in e)e[r]&&(t.pr["$".concat(r)]=e[r]);return this.request.send(t)}},{key:"trackBaseData",value:function(e){return v(this,void 0,void 0,t.mark((function r(){var n,i;return t.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return n=new Date,t.t0=e,t.t1=n.getTime(),t.t2=this.storage.allData.sid,t.t3=this.storage.allData.cuid,t.t4=this.cn,t.t5=w.getTimezone(n),t.t6=this.currentPage.url,t.t7=this.prevPage.url,t.t8=_.os(),t.t9=_.ov(),t.t10=_.version(),t.next=14,_.mnet();case 14:return t.t11=t.sent,t.next=17,_.net();case 17:return t.t12=t.sent,t.t13=this.config.vn,t.t14=this.referrerDomain,t.t15=this.config.appId,t.t16={$eid:t.t0,$ct:t.t1,$sid:t.t2,$cuid:t.t3,$cn:t.t4,$tz:t.t5,$url:t.t6,$ref:t.t7,$os:t.t8,$ov:t.t9,$wv:t.t10,$mnet:t.t11,$net:t.t12,$vn:t.t13,$referrer_domain:t.t14,$wxeid:t.t15},(i={dt:"evt",pr:t.t16}).pr=w.merge(i.pr,w.encode(this.config.superProperty)),t.abrupt("return",i);case 25:case"end":return t.stop()}}),r,this)})))}},{key:"environmentInfo",value:function(){var t=new Date,e={dt:"pl",pr:{$rs:"".concat(_.windowWidth(),"x").concat(_.windowHeight()),$tz:w.getTimezone(t),$ct:t.getTime(),$cuid:this.storage.allData.cuid,$sid:this.storage.allData.sid}};this.send(e)}},{key:"sessionEnd",value:function(t){var e=new Date,r=t.update-t.sid,n={dt:"se",pr:{$ct:t.update,$cn:this.cn,$tz:w.getTimezone(e),$dru:r,$sid:t.sid,$cuid:t.cuid,$referrer_domain:this.referrerDomain}};this.send(n)}},{key:"sessionStart",value:function(){return v(this,void 0,void 0,t.mark((function e(){var r,n,i,o,u;return t.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return r=new Date,n=this.storage.allData,i=n.sid,o=n.cuid,t.t0=i,t.t1=i,t.t2=o,t.t3=this.cn,t.t4=w.getTimezone(r),t.t5=this.currentPage.url,t.t6=this.prevPage.url,t.t7=_.os(),t.t8=_.ov(),t.t9=_.version(),t.next=14,_.mnet();case 14:return t.t10=t.sent,t.next=17,_.net();case 17:t.t11=t.sent,t.t12=this.config.vn,t.t13=this.referrerDomain,t.t14=this.config.appId,t.t15={$ct:t.t0,$sid:t.t1,$cuid:t.t2,$cn:t.t3,$tz:t.t4,$url:t.t5,$ref:t.t6,$os:t.t7,$ov:t.t8,$wv:t.t9,$mnet:t.t10,$net:t.t11,$vn:t.t12,$referrer_domain:t.t13,$wxeid:t.t14},u={dt:"ss",pr:t.t15},this.send(u),this.environmentInfo();case 25:case"end":return t.stop()}}),e,this)})))}},{key:"updateSession",value:function(t){var e=this.storage.allData,r=Date.now();if(e.sid&&e.update)if(r-e.update>this.config.timeout){var n=w.clone(e);this.storage.set("sid",r),this.storage.set("update",r),this.sessionEnd(n),this.sessionStart()}else this.storage.set("update",r);else this.storage.set("sid",r),this.storage.set("update",r),this.sessionStart()}},{key:"click",value:function(e){var r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{$element_content:"",$element_selector:"",$element_style:[]};return v(this,void 0,void 0,t.mark((function e(){var n;return t.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(this.config.click){t.next=2;break}return t.abrupt("return");case 2:return this.updateSession("click"),t.next=5,this.trackBaseData("click");case 5:return(n=t.sent).dt="abp",n.pr=w.merge(n.pr,{$page_url:this.currentPage.url,$page_title:this.currentPage.title},r),t.next=10,this.send(n);case 10:case"end":return t.stop()}}),e,this)})))}},{key:"pv",value:function(e){return v(this,void 0,void 0,t.mark((function r(){var n,i;return t.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(this.config.pv){t.next=2;break}return t.abrupt("return");case 2:return this.updateSession("pv"),t.next=5,this.trackBaseData("pv");case 5:return(n=t.sent).dt="abp",i={$page_title:this.currentPage.title},n.pr=w.merge(n.pr,i,e||{}),t.next=11,this.send(n);case 11:case"end":return t.stop()}}),r,this)})))}},{key:"duration",value:function(){return v(this,void 0,void 0,t.mark((function e(){var r,n;return t.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(this.config.duration){t.next=2;break}return t.abrupt("return");case 2:return this.updateSession("duration"),w.isFunction(this.config.beforeDuration)&&this.config.beforeDuration(),r=this.currentPage.time-this.prevPage.time,t.next=7,this.trackBaseData("dr");case 7:return(n=t.sent).dt="abp",n.pr=w.merge(n.pr,{$dr:r,$url:this.prevPage.url,$title:this.prevPage.title}),t.next=12,this.send(n);case 12:w.isFunction(this.config.afterDuration)&&this.config.afterDuration();case 13:case"end":return t.stop()}}),e,this)})))}},{key:"track",value:function(e,r){return v(this,void 0,void 0,t.mark((function n(){var i;return t.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return this.updateSession("track"),t.next=3,this.trackBaseData(e);case 3:return(i=t.sent).pr=w.merge(i.pr,w.encode(r)),t.next=7,this.send(i);case 7:case"end":return t.stop()}}),n,this)})))}},{key:"identify",value:function(e,r){return v(this,void 0,void 0,t.mark((function n(){var i,o;return t.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return this.storage.set("cuid",e),this.updateSession("identify"),i=new Date,(o={dt:"usr",pr:{$ct:i.getTime(),$tz:w.getTimezone(i),$cuid:e,$sid:this.storage.allData.sid,$url:this.currentPage.url}}).pr=w.merge(o.pr,w.encode(r)),t.next=7,this.trackBaseData("usr");case 7:return t.next=9,this.send(o);case 9:case"end":return t.stop()}}),n,this)})))}},{key:"trackCount",value:function(t,e){var r=this;0===this.count&&(this.countStartTime=Date.now(),this.previousCountEvent.name=t,this.previousCountEvent.props=w.clone(e)),this.previousCountEvent.name===t&&w.isEqual(this.previousCountEvent.props,e)||(this.sendCountEvent(this.previousCountEvent.name,this.previousCountEvent.props,!1),this.previousCountEvent.name=t,this.previousCountEvent.props=w.clone(e),this.countStartTime=Date.now(),this.count=0),this.count+=1,this.countTimer&&clearTimeout(this.countTimer),this.countTimer=setTimeout((function(){r.sendCountEvent(t,e,!0)}),this.config.countDuration)}},{key:"sendCountEvent",value:function(e,r,n){return v(this,void 0,void 0,t.mark((function i(){var o,u,a,s;return t.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return this.updateSession("track count"),o=Date.now()-this.countStartTime,n&&(o-=this.config.countDuration),u=this.count,this.count=n?0:1,t.next=7,this.trackBaseData(e);case 7:return a=t.sent,s={},w.isObject(r)&&(s=w.clone(r)),a.pr=w.merge(a.pr,w.encode(s),w.encode({count:u,countTime:o})),t.next=13,this.send(a);case 13:case"end":return t.stop()}}),i,this)})))}},{key:"trackRevenue",value:function(e){return v(this,void 0,void 0,t.mark((function r(){var n,i,o,u,a,s,c,f;return t.wrap((function(r){for(;;)switch(r.prev=r.next){case 0:return o=function(t,e){var r=0;try{t.toString().split(".")[1]&&(r+=t.toString().split(".")[1].length)}catch(t){console.error(t)}try{e.toString().split(".")[1]&&(r+=e.toString().split(".")[1].length)}catch(t){console.error(t)}return Number(t.toString().replace(".",""))*Number(e.toString().replace(".",""))/Math.pow(10,r)},this.updateSession("track revenue"),r.next=4,this.trackBaseData("revenue");case 4:(n=r.sent).dt="abp",(i=w.merge({price:0,total:0,productID:null,productQuantity:0,revenueType:null},e)).total=o(i.price,i.productQuantity),u=["productID","revenueType"],a=["price","total","productQuantity"],s={},r.t0=t.keys(i);case 12:if((r.t1=r.t0()).done){r.next=21;break}if(c=r.t1.value,-1!==u.indexOf(c)||-1!==a.indexOf(c)){r.next=16;break}return r.abrupt("continue",12);case 16:f=i[c],a.indexOf(c)>-1&&((f=Number(f))||(f=0)),s["$"+c]=f,r.next=12;break;case 21:return n.pr=w.merge(n.pr,s),r.next=24,this.send(n);case 24:case"end":return r.stop()}}),r,this)})))}},{key:"setUtm",value:function(e){return v(this,void 0,void 0,t.mark((function r(){var n;return t.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:null!==(n=w.filterUtm(e))&&(this.storage.set("utm",n),this.updateSession("setUtm"));case 2:case"end":return t.stop()}}),r,this)})))}},{key:"setSuperProperty",value:function(t){w.isObject(t)&&(this.config.superProperty=t)}},{key:"extendSuperPropertys",value:function(t){w.isObject(t)&&(this.config.superProperty=w.merge(this.config.superProperty,t))}},{key:"removeSuperProperty",value:function(t){var e,r=function(t,e){var r;if("undefined"==typeof Symbol||null==t[Symbol.iterator]){if(Array.isArray(t)||(r=p(t))||e&&t&&"number"==typeof t.length){r&&(t=r);var n=0,i=function(){};return{s:i,n:function(){return n>=t.length?{done:!0}:{done:!1,value:t[n++]}},e:function(t){throw t},f:i}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var o,u=!0,a=!1;return{s:function(){r=t[Symbol.iterator]()},n:function(){var t=r.next();return u=t.done,t},e:function(t){a=!0,o=t},f:function(){try{u||null==r.return||r.return()}finally{if(a)throw o}}}}(t);try{for(r.s();!(e=r.n()).done;){var n=e.value;delete this.config.superProperty[n]}}catch(t){r.e(t)}finally{r.f()}}},{key:"getSuperProperty",value:function(){return this.config.superProperty}}]),e}();d([k],S.prototype,"environmentInfo",null),d([k],S.prototype,"sessionEnd",null),d([k],S.prototype,"sessionStart",null),d([k],S.prototype,"updateSession",null),d([k],S.prototype,"click",null),d([k],S.prototype,"pv",null),d([k],S.prototype,"duration",null),d([k],S.prototype,"track",null),d([k],S.prototype,"identify",null),d([k],S.prototype,"trackCount",null),d([k],S.prototype,"trackRevenue",null),d([k],S.prototype,"setUtm",null);var P=["onLaunch","onShow","onHide","onError","onPageNotFound","onUnhandledRejection","onThemeChange","onShareAppMessage","onLogin"],O=["onLoad","onShow","onReady","onHide","onUnload","onShareAppMessage","onReachBottom","onPageScroll","onPullDownRefresh","onTabItemTap","onInit","onShareTimeline","onAddToFavorites","onResize","onTitleClick","onOptionMenuClick","onPullIntercept","onURLQueryChange"],D=function(t){return w.wxGetTitle(t)},T=function(t,e){return new Promise((function(r,n){var i;wx.request((o(i={url:t,data:e,method:"POST"},"header",{"content-type":"application/x-www-form-urlencoded"}),o(i,"dataType","json"),o(i,"responseType","arraybuffer"),o(i,"success",(function(t){r(t)})),o(i,"fail",(function(t){n(t)})),i))}))},$=["getStorage:fail data not found","getStorage:fail:data not found"],j={getDid:function(){return new Promise((function(t,e){wx.getStorage({key:"zg-did",success:function(e){t(e.data),wx.removeStorage({key:"zg-did"})},fail:function(r){$.includes(r.errMsg)?t(""):e(r)}})}))},get:function(){return new Promise((function(t,e){wx.getStorage({key:"zg",success:function(e){t(e.data)},fail:function(r){$.includes(r.errMsg)?t({}):e(r)}})}))},set:function(t,e){return new Promise((function(r,n){wx.setStorage({key:t,data:e,success:r,fail:n})}))}},E=!1,z=wx.getSystemInfoSync(),A=z.system.split(/\s/),C={os:A[0],ov:A[1],version:z.version,windowHeight:z.windowHeight,windowWidth:z.windowWidth,net:0,mnet:0};function I(t){var e=t.toLowerCase();"wifi"===e?(C.net=1,C.mnet=0):(C.net=0,C.mnet={"2g":1,"3g":3,"4g":13}[e]||0)}function L(t){return new Promise((function(e,r){if(E)return e(C[t]);wx.getNetworkType({success:function(r){E=!0,I(r.networkType),e(C[t])}})}))}wx.onNetworkStatusChange((function(t){I(t.networkType)}));var R,q,U={os:function(){return C.os},ov:function(){return C.ov},version:function(){return C.version},net:function(){return L("net")},mnet:function(){return L("mnet")},windowWidth:function(){return C.windowWidth},windowHeight:function(){return C.windowHeight}},N=App,F=Page,M=Component,B=["eid","ct","tz","cuid","cn","sid","url","os","ov","wv","mnet","referrer_domain","net","vn","wxeid","uid","share_id","share_title","share_level","title","path"];function K(t,e,r){if(t[r]&&w.isFunction(t[r])){var n=t[r];t[r]=function(){n.apply(this,arguments),e[r].apply(this,arguments)}}else t[r]=function(){e[r].apply(this,arguments)}}function G(t,e,r){var n=t[e];t[e]=function(){var t=arguments[0];if(R===t||t&&R&&R.timeStamp===t.timeStamp)return n.apply(this,arguments);if(R=t,t){var e=t.type;"tap"===e&&r.click(t)}return n.apply(this,arguments)}}var W=function(e){u(o,S);var n=f(o);function o(t){var e;return r(this,o),(e=n.call(this,T,j,U)).openData={path:"",props:{}},e.shared=!1,e.semiAutoTrackEventCatch={},e.isShareOperation=!1,q=t,e}return i(o,[{key:"load",value:function(t,e){var r,n=l(a(o.prototype),"load",this).call(this,t,e),i=this,u=(r=i,{App:{onShow:function(t){r.sceneToUtm(t),r.openOptions=t,r.updateSession("appOnShow")},onHide:function(){r.config.duration&&!r.isShareOperation&&(r.pageReady=!0,r.currentPage.time=Date.now(),r.duration().then((function(){r.pageReady=!1,r.prevPage={queryObj:{},query:"",route:"",time:0,url:"",title:""}})))}},Page:{onLoad:function(t){r.currentPage.query=w.parseQuery(t),r.currentPage.queryObj=t},onShow:function(){var t=getCurrentPages(),e=t[t.length-1];r.currentPage.route=e.__route__||e.route,r.currentPage.time=Date.now(),r.currentPage.url="".concat(r.currentPage.route);var n=D;if(r.currentPage.title="function"==typeof n?n(e):"",r.currentPage.query&&(r.currentPage.url+="?".concat(r.currentPage.query)),r.pageReady=!0,r.freeBuffer(),r.currentPage.url!==r.prevPage.url){""!==r.prevPage.url&&r.duration();try{r.trackOpenShare(r.openOptions)}catch(t){console.warn(t,"".concat(r.referrerDomain," ","zhuge"," sdk trackOpenShare error"))}r.pv()}r.startObserveMarkElement(e),r.openOptions=null,r.isShareOperation=!1},onHide:function(){r.semiAutoTrackEventCatch={},r.prevPage=w.clone(r.currentPage),r.pageReady=!1},onUnload:function(){r.semiAutoTrackEventCatch={},r.prevPage=w.clone(r.currentPage),r.pageReady=!1}}});return this.lifecycle=u,App=function(t){for(var e in u.App)K(t,u.App,e);for(var r in t)!P.includes(r)&&w.isFunction(t[r])&&G(t,r,i);return N(t)},Page=function(t){for(var e in u.Page)K(t,u.Page,e);for(var r in t)!O.includes(r)&&w.isFunction(t[r])&&"onShareAppMessage"!==r&&G(t,r,i);var n=t.onShareAppMessage;return w.isFunction(n)&&(t.onShareAppMessage=i.onShareAppMessage(n)),F(t)},Component=function(t){if(void 0!==t.methods)for(var e in t.methods)G(t.methods,e,i);return M(t)},global.mpvue&&(global.App=App,global.Page=Page,global.Component=Component),App.zhuge=i,n}},{key:"pv",value:function(e){var r=this,n=Object.create(null,{pv:{get:function(){return l(a(o.prototype),"pv",r)}}});return v(this,void 0,void 0,t.mark((function e(){var r,i;return t.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return r={},i=w.getCurrentPage(),this.config.forwardShare&&this.openOptions&&(r.$share_open_type=1008===this.openOptions.scene?"群聊":"聊天",this.openOptions.query&&this.openOptions.query.zg_share_level&&(r.$share_level=Number(this.openOptions.query.zg_share_level)),i.data&&i.data.zg_share_data&&(r=w.merge(r,w.encode(i.data.zg_share_data)))),t.next=5,n.pv.call(this,r);case 5:case"end":return t.stop()}}),e,this)})))}},{key:"click",value:function(e,r){var n=this,i=Object.create(null,{click:{get:function(){return l(a(o.prototype),"click",n)}}});return v(this,void 0,void 0,t.mark((function n(){var o,u,a,s;return t.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return o=e.target,u=o.dataset.title,a=o.dataset.index,s=[],s="alipay-miniprogram"===this.referrerDomain?["","",e.detail.pageX,e.detail.pageY]:["","",e.detail.x,e.detail.y],t.next=7,i.click.call(this,e,w.merge({$element_content:u||"",$element_selector:a||"",$element_style:s},r||{}));case 7:case"end":return t.stop()}}),n,this)})))}},{key:"sceneToUtm",value:function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},e=w.getUtmByQuery(t.query);if(this.config.parseScene&&t.scene&&q){var r=t.scene;this.cn=r+"";var n=q[r],i={},o=null,u=q.isShare(r);if(u&&t.referrerInfo&&(o=t.referrerInfo.appId),n){i={utm_source:n.utm_source,utm_medium:n.utm_medium,utm_campaign:o};var a=t.query||{};q.isCartShare(r)&&a.zg_uid&&a.zg_share_id&&(i.utm_term=a.zg_uid,i.utm_content=a.zg_share_id)}e=w.merge(i,e)}"fresh"===this.config.utmMode&&w.isEmpty(this.config.utm)&&this.storage.set("utm",e)}},{key:"trackOpenShare",value:function(e){return v(this,void 0,void 0,t.mark((function r(){var n,i,o,u,a,s,c,f,l,h,p;return t.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(e&&this.config.forwardShare){t.next=2;break}return t.abrupt("return");case 2:if(!this.shared){t.next=5;break}return this.shared=!1,t.abrupt("return");case 5:if(n=e.query||{},i=this.currentPage.route,!(q.isCartShare(e.scene)&&n.zg_uid&&n.zg_share_id)){t.next=24;break}for(a in o={$uid:n.zg_uid,$share_id:n.zg_share_id,$title:this.currentPage.title,$path:i,$share_open_type:1008===e.scene?"群聊":"聊天",$share_level:Number(n.zg_share_level)},this.shareId=n.zg_share_id,this.shareLevel=Number(n.zg_share_level),u={},n)s=a.replace(/^zg_/,""),-1===B.indexOf(s)&&/^zg_/.test(a)&&(u[s]=n[a]);if(c=this.config.shareToUtm,w.isObject(c)&&!w.isEmpty(c)){for(l in f={},c)null!==u[l]&&void 0!==u[l]&&(h=c[l],f[h]=u[l]);w.isEmpty(w)||(f.utm_campaign||(f.utm_campaign="分享打开"),this.setUtm(f))}return this.openData={path:i,props:u},o=w.merge(o,w.encode(u)),t.next=19,this.trackBaseData("wxsopen");case 19:return(p=t.sent).dt="abp",p.pr=w.merge(p.pr,o),t.next=24,this.request.send(p);case 24:case"end":return t.stop()}}),r,this)})))}},{key:"onShareAppMessage",value:function(t){var e=this;return function(){e.isShareOperation=!0;var r=t.apply(this,arguments)||{};if(!e.config.forwardShare)return r;r.path=r.path||e.currentPage.url;var n=r.title||e.currentPage.title,i=r.path.split("?")[0],o=this.data.zg_share_data,u=(new Date).getTime(),a=1;!this.data.newShare&&e.openData&&e.openData.path===i&&w.isEqual(o||{},e.openData.props)&&(u=e.shareId,a=e.shareLevel+1);var s={share_id:u,uid:e.storage.allData.cuid||e.storage.allData.did,share_level:a},c={$share_title:n,$title:e.currentPage.title||"",$path:i},f={};for(var l in s)c["$".concat(l)]=f["zg_".concat(l)]=s[l];for(var h in o)-1===B.indexOf(h)&&(c["_".concat(h)]=f["zg_".concat(h)]=o[h]);return r.path=w.addUrlParam(r.path,f),e.trackBaseData("wxshare").then((function(t){t.dt="abp",t.pr=w.merge(t.pr,c),e.request.send(t)})),e.shared=!0,r}}},{key:"startObserveMarkElement",value:function(t){var e=this;this.config.exposure&&(this.elementObserver&&this.elementObserver.disconnect(),t.isComponent?this.elementObserver=t.createIntersectionObserver({observeAll:!0}):this.elementObserver=wx.createIntersectionObserver(t,{observeAll:!0}),this.elementObserver.relativeToViewport().observe(".zhuge-expo-track",(function(t){if(t.intersectionRatio>0){var r,n=e.getEventDataFromDataset(t.dataset);(r=l(a(o.prototype),"track",e)).call.apply(r,[e].concat(h(n)))}})))}},{key:"getEventDataFromDataset",value:function(t){var e={},r="";for(var n in t){if(n.startsWith("expo"))if("expoName"===n)r=t[n];else e[n.replace(/^expo(.*)/,(function(t,e,r,n){return e.replace(e[0],e[0].toLocaleLowerCase())}))]=t[n]}return[r,e]}}]),o}();d([k],W.prototype,"sceneToUtm",null),d([k],W.prototype,"trackOpenShare",null);var H={1001:{utm_source:"微信主程序",utm_medium:"发现栏小程序主入口"},1005:{utm_source:"搜索",utm_medium:"顶部搜索框的搜索结果页"},1006:{utm_source:"搜索",utm_medium:"发现栏小程序主入口搜索框的搜索结果页"},1007:{utm_source:"分享",utm_medium:"单人聊天会话中的小程序消息卡片"},1008:{utm_source:"分享",utm_medium:"群聊会话中的小程序消息卡片"},1011:{utm_source:"扫码",utm_medium:"扫描二维码"},1012:{utm_source:"扫码",utm_medium:"长按图片识别二维码"},1013:{utm_source:"扫码",utm_medium:"手机相册选取二维码"},1014:{utm_source:"小程序模板消息",utm_medium:"小程序模板消息"},1017:{utm_source:"体验版",utm_medium:"前往体验版的入口页"},1019:{utm_source:"微信支付",utm_medium:"微信钱包"},1020:{utm_source:"公众号",utm_medium:"公众号profile页相关小程序列表"},1022:{utm_source:"微信主程序",utm_medium:"聊天顶部置顶小程序入口"},1023:{utm_source:"桌面图标",utm_medium:"安卓系统桌面图标"},1024:{utm_source:"微信主程序",utm_medium:"小程序 profile 页"},1025:{utm_source:"扫码",utm_medium:"扫描一维码"},1026:{utm_source:"微信主程序",utm_medium:"附近小程序列表"},1027:{utm_source:"搜索",utm_medium:"顶部搜索框搜索结果页“使用过的小程序”列表"},1028:{utm_source:"微信卡券",utm_medium:"我的卡包"},1029:{utm_source:"微信卡券",utm_medium:"卡券详情页"},1030:{utm_source:"测试",utm_medium:"自动化测试下打开小程序"},1031:{utm_source:"扫码",utm_medium:"长按图片识别一维码"},1032:{utm_source:"扫码",utm_medium:"手机相册选取一维码"},1034:{utm_source:"微信支付",utm_medium:"微信支付完成页"},1035:{utm_source:"公众号",utm_medium:"公众号自定义菜单"},1036:{utm_source:"分享",utm_medium:"App分享消息卡片"},1037:{utm_source:"小程序",utm_medium:"小程序打开小程序"},1038:{utm_source:"小程序",utm_medium:"从另一个小程序返回"},1039:{utm_source:"摇电视",utm_medium:"摇电视"},1042:{utm_source:"搜索",utm_medium:"添加好友搜索框的搜索结果页"},1043:{utm_source:"公众号",utm_medium:"公众号模板消息"},1044:{utm_source:"分享",utm_medium:"带shareTicket的小程序消息卡片(详情)"},1045:{utm_source:"广告",utm_medium:"朋友圈广告"},1046:{utm_source:"广告",utm_medium:"朋友圈广告详情页"},1047:{utm_source:"扫码",utm_medium:"扫描小程序码"},1048:{utm_source:"扫码",utm_medium:"长按图片识别小程序码"},1049:{utm_source:"扫码",utm_medium:"手机相册选取小程序码"},1052:{utm_source:"微信卡券",utm_medium:"卡券的适用门店列表"},1053:{utm_source:"搜索",utm_medium:"搜一搜的结果页"},1054:{utm_source:"搜索",utm_medium:"顶部搜索框小程序快捷入口"},1056:{utm_source:"音乐播放器菜单",utm_medium:"音乐播放器菜单"},1057:{utm_source:"微信支付",utm_medium:"钱包中的银行卡详情页"},1058:{utm_source:"公众号",utm_medium:"公众号文章"},1059:{utm_source:"体验版",utm_medium:"体验版小程序绑定邀请页"},1064:{utm_source:"微信WIFI",utm_medium:"微信连Wi-Fi状态栏"},1067:{utm_source:"广告",utm_medium:"公众号文章广告"},1068:{utm_source:"广告",utm_medium:"附近小程序列表广告"},1069:{utm_source:"移动应用",utm_medium:"移动应用"},1071:{utm_source:"微信支付",utm_medium:"钱包中的银行卡列表页"},1072:{utm_source:"微信支付",utm_medium:"二维码收款页面"},1073:{utm_source:"客服消息",utm_medium:"客服消息列表下发的小程序消息卡片"},1074:{utm_source:"公众号会话",utm_medium:"公众号会话下发的小程序消息卡片"},1077:{utm_source:"摇周边",utm_medium:"摇周边"},1078:{utm_source:"微信WIFI",utm_medium:"连Wi-Fi成功页"},1079:{utm_source:"微信游戏中心",utm_medium:"微信游戏中心"},1081:{utm_source:"客服消息",utm_medium:"客服消息下发的文字链"},1082:{utm_source:"公众号",utm_medium:"公众号会话下发的文字链"},1084:{utm_source:"广告",utm_medium:"朋友圈广告原生页"},1089:{utm_source:"微信主程序",utm_medium:"微信聊天主界面下拉"},1090:{utm_source:"小程序",utm_medium:"长按小程序右上角菜单唤出最近使用历史"},1091:{utm_source:"公众号",utm_medium:"公众号文章商品卡片"},1092:{utm_source:"微信城市服务",utm_medium:"城市服务入口"},1095:{utm_source:"广告",utm_medium:"小程序广告组件"},1096:{utm_source:"分享",utm_medium:"聊天记录"},1097:{utm_source:"微信支付",utm_medium:"微信支付签约页"},1099:{utm_source:"小程序",utm_medium:"页面内嵌插件"},1102:{utm_source:"公众号",utm_medium:"公众号profile页服务预览"},1129:{utm_source:"爬虫",utm_medium:"微信爬虫"},isShare:function(t){return[1020,1035,1036,1037,1038,1043].includes(t)},isCartShare:function(t){return[1044,1007,1008,1036].includes(t)}},Q=new(function(t){u(n,W);var e=f(n);function n(){return r(this,n),e.call(this,H)}return i(n,[{key:"load",value:function(t,e){if(wx.getAccountInfoSync){var r=wx.getAccountInfoSync();r&&r.miniProgram&&r.miniProgram.appId&&(e.appId=r.miniProgram.appId)}return l(a(n.prototype),"load",this).call(this,t,e)}},{key:"weixinIdentify",value:function(){var t=this,e=this.config.appId;arguments[0]&&"string"==typeof arguments[0]&&(e=arguments[0]);var r,n=this.config.serverUrl.normal,i="",o="",u="",a="",s="",c="";function f(t,e,r){if(!(r&&t.length<=r)){var n=r||0;t[n].call(e,(function(){f(t,e,n+1)}))}}function l(t){wx.login({success:function(e){i=e.code,t&&t()},fail:function(t){console.error("诸葛SDK提示:","登录失败",t)}})}var h=function(r){var s=t,c={url:n+"/zgwx/user/code2session",method:"GET",data:{code:i,appId:e},success:function(t){o=t.data.openid,u=t.data.unionid,a=t.data.session_key,r&&r()},fail:function(t){n!==s.config.serverUrl.bac?(c.url=s.config.serverUrl.bac+"/zgwx/user/code2session",wx.request(c)):console.error("诸葛SDK提示:","获取codeSession失败",t)}};wx.request(c)};function p(t){wx.getSetting({success:function(e){e.authSetting["scope.userInfo"]?wx.getUserInfo({lang:"zh_CN",success:function(e){r=e.userInfo,s=e.iv,c=e.encryptedData,t&&t()}}):console.error("诸葛SDK提示:","未授权",e)}})}function m(t){wx.getUserProfile?wx.getUserProfile({desc:arguments[0]||"用于完善会员资料",lang:"zh_CN",success:function(e){r=e.userInfo,t&&t()},fail:function(e){console.error("userProfile错误",e),t&&t()}}):t&&t()}var d=function(e){var r=t,i={url:n+"/zgwx/data/decrypt",method:"POST",data:{sessionKey:a,iv:s,encryptData:c},success:function(t){u=t.data.unionId,e&&e(t.data||{})},fail:function(t){n!==r.config.serverUrl.bac?(i.url=r.config.serverUrl.bac+"/zgwx/data/decrypt",wx.request(i)):console.error("诸葛SDK提示:","获取codeSession失败",t)}};wx.request(i)},v=function(e){var n="";switch(r.gender){case 1:n="男";break;case 2:n="女"}t.identify(u||o,{name:r.nickName,avatar:r.avatarUrl,"微信-昵称":r.nickName,"微信-性别":n,"微信-城市":r.city,"微信-省":r.province,"微信-国家":r.country}),e&&e()},g=[m,l,p,h,d,v],y=Array.prototype.pop.call(arguments);"function"==typeof y&&g.push((function(){y({userInfo:r,unionid:u,openid:o,sessionKey:a})})),f(g,this)}}]),n}());App.zhuge=Q;export default Q;
|
|
16
|
+
function d(t,e,r,n){var i,o=arguments.length,u=o<3?e:null===n?n=Object.getOwnPropertyDescriptor(e,r):n;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)u=Reflect.decorate(t,e,r,n);else for(var a=t.length-1;a>=0;a--)(i=t[a])&&(u=(o<3?i(u):o>3?i(e,r,u):i(e,r))||u);return o>3&&u&&Object.defineProperty(e,r,u),u}function v(t,e,r,n){return new(r||(r=Promise))((function(i,o){function u(t){try{s(n.next(t))}catch(t){o(t)}}function a(t){try{s(n.throw(t))}catch(t){o(t)}}function s(t){var e;t.done?i(t.value):(e=t.value,e instanceof r?e:new r((function(t){t(e)}))).then(u,a)}s((n=n.apply(t,e||[])).next())}))}var g,y,_,w={utmKeys:["utm_source","utm_medium","utm_campaign","utm_content","utm_term"],isValid:function(t){return null==t},type:function(t){return Object.prototype.toString.call(t)},isObject:function(t){return"[object Object]"===this.type(t)},isArray:function(t){return"[object Array]"===this.type(t)},isString:function(t){return"[object String]"===this.type(t)},isNumber:function(t){return"[object Number]"===this.type(t)},isDate:function(t){return"[object Date]"===this.type(t)},isFunction:function(t){return"[object Function]"===this.type(t)},isEmpty:function(t){return Array.isArray(t)||"string"==typeof t||t instanceof String?0===t.length:t instanceof Map||t instanceof Set?0===t.size:"[object Object]"===Object.prototype.toString.call(t)&&0===Object.keys(t).length},merge:function(){for(var t=this,e=arguments.length,r=new Array(e),n=0;n<e;n++)r[n]=arguments[n];return r.reduce((function(e,r){return Object.keys(r).forEach((function(n){Array.isArray(e[n])&&Array.isArray(r[n])?e[n]=Array.from(new Set(e[n].concat(r[n]))):t.isObject(e[n])&&t.isObject(r[n])?e[n]=t.merge(e[n],r[n]):e[n]=r[n]})),e}),{})},UUID:function(){var t=function(){return Math.floor(65536*(1+Math.random())).toString(16).substring(1)};return t()+t()+"-"+t()+"-"+t()+"-"+t()+"-"+t()+t()+t()},clone:function(t){var r=function(t){var e=t.constructor;switch(n(t)){case"Boolean":case"Number":case"String":case"Error":case"Date":return new e(t);case"RegExp":return o(t);case"Symbol":return i(t);case"Function":return t;default:return null}},n=function(t){return Object.prototype.toString.call(t).slice(8,-1)},i=function(t){return Object(Symbol.prototype.valueOf.call(t))},o=function(t){var e=new t.constructor(t.source,/\w*$/.exec(t));return e.lastIndex=t.lastIndex,e},u=function(t,e){for(var r=-1,n=t.length;++r<n;)e(t[r],r);return t},a=function t(i){var o=arguments.length>1&&void 0!==arguments[1]?arguments[1]:new WeakMap;if("object"!==e(i)||null===i)return i;var a=n(i),s=null;return o.get(i)?o.get(i):(o.set(i,s),"Set"!==a&&"Map"!==a&&"Array"!==a&&"Object"!==a?r(i):"Set"===a?(s=new Set,i.forEach((function(e){s.add(t(e,o))})),s):"Map"===a?(s=new Map,i.forEach((function(e,r){s.set(r,t(e,o))})),s):("Array"===a&&(s=new Array,u(i,(function(e,r){s[r]=t(e,o)}))),"Object"===a&&(s=new Object,u(Object.keys(i),(function(e){s[e]=t(i[e],o)}))),s))};return a(t)},parseQuery:function(t){if(this.isEmpty(t))return"";var e=[];for(var r in t)e.push("".concat(r,"=").concat(t[r]));return e.join("&")},getTimezone:function(t){return 6e4*-t.getTimezoneOffset()},encode:function(t){var e={};for(var r in t)e["_"+r]=t[r];return e},isEqual:function(t,e){if(this.type(t)!==this.type(e))return!1;var r=!0;for(var n in t)t[n]!==e[n]&&(r=!1);return r},getUtmByQuery:function(t){var e={};for(var r in t)this.utmKeys.includes(r)&&(e[r]=t[r]);return e},filterUtm:function(t){var e=["utm_source","utm_medium","utm_campaign","utm_content","utm_term"],r=!1,n={};for(var i in t)e.indexOf(i)>-1&&(r=!0,n[i]=t[i]);return r?n:null},deleteQueryParams:function(t,e){var r=t.split("&"),n=[];return r.forEach((function(t){var r=new RegExp(e+"=.*"),i="";r.test(t)?(i=t.replace(r,""))&&n.push(i):n.push(t)})),n.join("&")},addUrlParam:function(t,e){var r=t,n="";for(var i in e)n&&(n+="&"),r=this.deleteQueryParams(r,i),n+=i+"="+e[i];var o=r.split("?");return o.length>1?o[1]?o[1]=n+"&"+o[1]:o[1]=n:1===o.length&&o.push(n),o.join("?")},getCurrentPage:function(){var t=getCurrentPages();return t[t.length-1]},wxGetTitle:function(t){var e="";t.data&&t.data.title&&t.data.title.length>0&&(e=Array.isArray(t.data.title)?t.data.title.join(" "):t.data.title);try{if(!e.length&&__wxConfig&&(__wxConfig.tabBar&&__wxConfig.tabBar.list.forEach((function(r){r.pagePath==="".concat(t.route,".html")&&r.text&&(e=r.text)})),!e.length)){var r=__wxConfig.page[t.route]||__wxConfig.page["".concat(t.route,".html")];e=r?r.window.navigationBarTitleText:__wxConfig.global.window.navigationBarTitleText}}catch(t){console.error("解析title错误",t)}return e||t.route}},b=function(){function t(e,n){r(this,t),this.timeout=500,this.catch=[],this.clearCatchTimer=null,this.url="".concat(n.config.serverUrl.normal,"/apipool"),this.timeout=n.config.timeout||this.timeout,this.requestTimeout=n.config.requestTimeout,this.debug=n.config.debug?1:0,this.appKey=n.appKey,this.did=n.storage.allData.did,this.sendLimit=n.config.sendLimit,this.requestFunction=e}return i(t,[{key:"generateRequestData",value:function(){var t=new Date,e={method:"web_event_sr.upload",event:JSON.stringify({sln:"itn",pl:"js",sdk:"sys",sdkv:"2.0.4",owner:"zg",ut:"".concat(t.getFullYear(),"-").concat(t.getMonth()+1,"-").concat(t.getDate()," ").concat(t.getHours(),":").concat(t.getMinutes(),":").concat(t.getSeconds()),tz:w.getTimezone(t),debug:this.debug?1:0,ak:this.appKey,usr:{did:this.did},data:h(this.catch)}),_:t.getTime()+""};return this.catch=[],e}},{key:"clear",value:function(){var t=this.generateRequestData();this.requestFunction(this.url,t,{timeout:this.requestTimeout})}},{key:"send",value:function(t){var e=this;if(this.catch.push(t),this.clearCatchTimer&&clearTimeout(this.clearCatchTimer),this.clearCatchTimer=setTimeout((function(){e.clear()}),3e4),!(this.catch.length<this.sendLimit)){this.clearCatchTimer&&clearTimeout(this.clearCatchTimer);var r=this.generateRequestData();return new Promise((function(t,n){var i,o=!1;i=setTimeout((function(){o=!0,t(null)}),e.timeout),e.requestFunction(e.url,r,{timeout:e.requestTimeout}).then((function(e){o||(clearTimeout(i),t(e))})).catch((function(t){n(t)}))}))}}}]),t}(),x=function(){function e(t,n,i){r(this,e),this.storageFunction=t,this.allData=i||{},this.allData.did||this.set("did",n.config.did||w.UUID()),this.allData.cuid||this.set("cuid",void 0),w.isEmpty(n.config.utm)||this.set("utm",n.config.utm)}return i(e,[{key:"get",value:function(t){return this.allData[t]}},{key:"set",value:function(e,r){return v(this,void 0,void 0,t.mark((function n(){return t.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return this.allData[e]=r,t.next=3,this.storageFunction.set("zg",this.allData);case 3:case"end":return t.stop()}}),n,this)})))}}]),e}();function k(t,e,r){var n=r.value;return r.value=function(){for(var t=arguments.length,r=new Array(t),i=0;i<t;i++)r[i]=arguments[i];if(this.pageReady&&this.loadReady)return n.apply(this,r);this.buffer.push({fnName:e,args:r})},r}var S=function(){function e(t,n,i){r(this,e),this.buffer=[],this.currentPage={queryObj:{},query:"",route:"",time:0,url:"",title:""},this.prevPage={queryObj:{},query:"",route:"",time:0,url:"",title:""},this.cn="",this.previousCountEvent={name:"",props:{}},this.count=0,this.countTimer=null,this.pageReady=!1,this.loadReady=!1,y=t,g=n,_=i,this.referrerDomain="miniprogram",this.appKey="",this.config={serverUrl:{normal:"https://u.zhugeapi.net",bac:"https://ubak.zhugeio.com"},debug:!1,pv:!1,click:!1,timeout:18e5,requestTimeout:6e4,did:"",duration:!1,vn:"1.0",appId:"",sendLimit:1,superProperty:{},forwardShare:!1,beforeDuration:function(){},afterDuration:function(){},countDuration:3e3,parseScene:!0,utm:{},utmMode:"session",shareToUtm:{},exposure:!1}}return i(e,[{key:"load",value:function(e,r){return v(this,void 0,void 0,t.mark((function n(){var i;return t.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return this.appKey=e,this.config=w.merge(this.config,r),t.prev=2,t.next=5,g.get();case 5:if((i=t.sent).did){t.next=10;break}return t.next=9,g.getDid();case 9:i.did=t.sent;case 10:this.storage=new x(g,this,i),this.request=new b(y,this),this.loadReady=!0,this.updateSession("load"),this.freeBuffer(),t.next=20;break;case 17:t.prev=17,t.t0=t.catch(2),console.error("sdk初始化失败,缓存读取失败",t.t0);case 20:case"end":return t.stop()}}),n,this,[[2,17]])})))}},{key:"freeBuffer",value:function(){if(this.loadReady&&this.pageReady)for(;this.buffer.length;){var t=this.buffer.shift();if(t)(e.prototype[t.fnName]||this[t.fnName]).apply(this,t.args)}}},{key:"send",value:function(t){var e=this.storage.allData.utm;if(e)for(var r in e)e[r]&&(t.pr["$".concat(r)]=e[r]);return this.request.send(t)}},{key:"trackBaseData",value:function(e){return v(this,void 0,void 0,t.mark((function r(){var n,i;return t.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return n=new Date,t.t0=e,t.t1=n.getTime(),t.t2=this.storage.allData.sid,t.t3=this.storage.allData.cuid,t.t4=this.cn,t.t5=w.getTimezone(n),t.t6=this.currentPage.url,t.t7=this.prevPage.url,t.t8=_.os(),t.t9=_.ov(),t.t10=_.version(),t.next=14,_.mnet();case 14:return t.t11=t.sent,t.next=17,_.net();case 17:return t.t12=t.sent,t.t13=this.config.vn,t.t14=this.referrerDomain,t.t15=this.config.appId,t.t16={$eid:t.t0,$ct:t.t1,$sid:t.t2,$cuid:t.t3,$cn:t.t4,$tz:t.t5,$url:t.t6,$ref:t.t7,$os:t.t8,$ov:t.t9,$wv:t.t10,$mnet:t.t11,$net:t.t12,$vn:t.t13,$referrer_domain:t.t14,$wxeid:t.t15},(i={dt:"evt",pr:t.t16}).pr=w.merge(i.pr,w.encode(this.config.superProperty)),t.abrupt("return",i);case 25:case"end":return t.stop()}}),r,this)})))}},{key:"environmentInfo",value:function(){var t=new Date,e={dt:"pl",pr:{$rs:"".concat(_.windowWidth(),"x").concat(_.windowHeight()),$tz:w.getTimezone(t),$ct:t.getTime(),$cuid:this.storage.allData.cuid,$sid:this.storage.allData.sid}};this.send(e)}},{key:"sessionEnd",value:function(t){var e=new Date,r=t.update-t.sid,n={dt:"se",pr:{$ct:t.update,$cn:this.cn,$tz:w.getTimezone(e),$dru:r,$sid:t.sid,$cuid:t.cuid,$referrer_domain:this.referrerDomain}};this.send(n)}},{key:"sessionStart",value:function(){return v(this,void 0,void 0,t.mark((function e(){var r,n,i,o,u;return t.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return r=new Date,n=this.storage.allData,i=n.sid,o=n.cuid,t.t0=i,t.t1=i,t.t2=o,t.t3=this.cn,t.t4=w.getTimezone(r),t.t5=this.currentPage.url,t.t6=this.prevPage.url,t.t7=_.os(),t.t8=_.ov(),t.t9=_.version(),t.next=14,_.mnet();case 14:return t.t10=t.sent,t.next=17,_.net();case 17:t.t11=t.sent,t.t12=this.config.vn,t.t13=this.referrerDomain,t.t14=this.config.appId,t.t15={$ct:t.t0,$sid:t.t1,$cuid:t.t2,$cn:t.t3,$tz:t.t4,$url:t.t5,$ref:t.t6,$os:t.t7,$ov:t.t8,$wv:t.t9,$mnet:t.t10,$net:t.t11,$vn:t.t12,$referrer_domain:t.t13,$wxeid:t.t14},u={dt:"ss",pr:t.t15},this.send(u),this.environmentInfo();case 25:case"end":return t.stop()}}),e,this)})))}},{key:"updateSession",value:function(t){var e=this.storage.allData,r=Date.now();if(e.sid&&e.update)if(r-e.update>this.config.timeout){var n=w.clone(e);this.storage.set("sid",r),this.storage.set("update",r),this.sessionEnd(n),this.sessionStart()}else this.storage.set("update",r);else this.storage.set("sid",r),this.storage.set("update",r),this.sessionStart()}},{key:"click",value:function(e){var r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{$element_content:"",$element_selector:"",$element_style:[]};return v(this,void 0,void 0,t.mark((function e(){var n;return t.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(this.config.click){t.next=2;break}return t.abrupt("return");case 2:return this.updateSession("click"),t.next=5,this.trackBaseData("click");case 5:return(n=t.sent).dt="abp",n.pr=w.merge(n.pr,{$page_url:this.currentPage.url,$page_title:this.currentPage.title},r),t.next=10,this.send(n);case 10:case"end":return t.stop()}}),e,this)})))}},{key:"pv",value:function(e){return v(this,void 0,void 0,t.mark((function r(){var n,i;return t.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(this.config.pv){t.next=2;break}return t.abrupt("return");case 2:return this.updateSession("pv"),t.next=5,this.trackBaseData("pv");case 5:return(n=t.sent).dt="abp",i={$page_title:this.currentPage.title},n.pr=w.merge(n.pr,i,e||{}),t.next=11,this.send(n);case 11:case"end":return t.stop()}}),r,this)})))}},{key:"duration",value:function(){return v(this,void 0,void 0,t.mark((function e(){var r,n;return t.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(this.config.duration){t.next=2;break}return t.abrupt("return");case 2:return this.updateSession("duration"),w.isFunction(this.config.beforeDuration)&&this.config.beforeDuration(),r=this.currentPage.time-this.prevPage.time,t.next=7,this.trackBaseData("dr");case 7:return(n=t.sent).dt="abp",n.pr=w.merge(n.pr,{$dr:r,$url:this.prevPage.url,$title:this.prevPage.title}),t.next=12,this.send(n);case 12:w.isFunction(this.config.afterDuration)&&this.config.afterDuration();case 13:case"end":return t.stop()}}),e,this)})))}},{key:"track",value:function(e,r){return v(this,void 0,void 0,t.mark((function n(){var i;return t.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return this.updateSession("track"),t.next=3,this.trackBaseData(e);case 3:return(i=t.sent).pr=w.merge(i.pr,w.encode(r)),t.next=7,this.send(i);case 7:case"end":return t.stop()}}),n,this)})))}},{key:"identify",value:function(e,r){return v(this,void 0,void 0,t.mark((function n(){var i,o;return t.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return this.storage.set("cuid",e),this.updateSession("identify"),i=new Date,(o={dt:"usr",pr:{$ct:i.getTime(),$tz:w.getTimezone(i),$cuid:e,$sid:this.storage.allData.sid,$url:this.currentPage.url}}).pr=w.merge(o.pr,w.encode(r)),t.next=7,this.trackBaseData("usr");case 7:return t.next=9,this.send(o);case 9:case"end":return t.stop()}}),n,this)})))}},{key:"trackCount",value:function(t,e){var r=this;0===this.count&&(this.countStartTime=Date.now(),this.previousCountEvent.name=t,this.previousCountEvent.props=w.clone(e)),this.previousCountEvent.name===t&&w.isEqual(this.previousCountEvent.props,e)||(this.sendCountEvent(this.previousCountEvent.name,this.previousCountEvent.props,!1),this.previousCountEvent.name=t,this.previousCountEvent.props=w.clone(e),this.countStartTime=Date.now(),this.count=0),this.count+=1,this.countTimer&&clearTimeout(this.countTimer),this.countTimer=setTimeout((function(){r.sendCountEvent(t,e,!0)}),this.config.countDuration)}},{key:"sendCountEvent",value:function(e,r,n){return v(this,void 0,void 0,t.mark((function i(){var o,u,a,s;return t.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return this.updateSession("track count"),o=Date.now()-this.countStartTime,n&&(o-=this.config.countDuration),u=this.count,this.count=n?0:1,t.next=7,this.trackBaseData(e);case 7:return a=t.sent,s={},w.isObject(r)&&(s=w.clone(r)),a.pr=w.merge(a.pr,w.encode(s),w.encode({count:u,countTime:o})),t.next=13,this.send(a);case 13:case"end":return t.stop()}}),i,this)})))}},{key:"trackRevenue",value:function(e){return v(this,void 0,void 0,t.mark((function r(){var n,i,o,u,a,s,c,f;return t.wrap((function(r){for(;;)switch(r.prev=r.next){case 0:return o=function(t,e){var r=0;try{t.toString().split(".")[1]&&(r+=t.toString().split(".")[1].length)}catch(t){console.error(t)}try{e.toString().split(".")[1]&&(r+=e.toString().split(".")[1].length)}catch(t){console.error(t)}return Number(t.toString().replace(".",""))*Number(e.toString().replace(".",""))/Math.pow(10,r)},this.updateSession("track revenue"),r.next=4,this.trackBaseData("revenue");case 4:(n=r.sent).dt="abp",(i=w.merge({price:0,total:0,productID:null,productQuantity:0,revenueType:null},e)).total=o(i.price,i.productQuantity),u=["productID","revenueType"],a=["price","total","productQuantity"],s={},r.t0=t.keys(i);case 12:if((r.t1=r.t0()).done){r.next=21;break}if(c=r.t1.value,-1!==u.indexOf(c)||-1!==a.indexOf(c)){r.next=16;break}return r.abrupt("continue",12);case 16:f=i[c],a.indexOf(c)>-1&&((f=Number(f))||(f=0)),s["$"+c]=f,r.next=12;break;case 21:return n.pr=w.merge(n.pr,s),r.next=24,this.send(n);case 24:case"end":return r.stop()}}),r,this)})))}},{key:"setUtm",value:function(e){return v(this,void 0,void 0,t.mark((function r(){var n;return t.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:null!==(n=w.filterUtm(e))&&(this.storage.set("utm",n),this.updateSession("setUtm"));case 2:case"end":return t.stop()}}),r,this)})))}},{key:"setSuperProperty",value:function(t){w.isObject(t)&&(this.config.superProperty=t)}},{key:"extendSuperPropertys",value:function(t){w.isObject(t)&&(this.config.superProperty=w.merge(this.config.superProperty,t))}},{key:"removeSuperProperty",value:function(t){var e,r=function(t,e){var r;if("undefined"==typeof Symbol||null==t[Symbol.iterator]){if(Array.isArray(t)||(r=p(t))||e&&t&&"number"==typeof t.length){r&&(t=r);var n=0,i=function(){};return{s:i,n:function(){return n>=t.length?{done:!0}:{done:!1,value:t[n++]}},e:function(t){throw t},f:i}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var o,u=!0,a=!1;return{s:function(){r=t[Symbol.iterator]()},n:function(){var t=r.next();return u=t.done,t},e:function(t){a=!0,o=t},f:function(){try{u||null==r.return||r.return()}finally{if(a)throw o}}}}(t);try{for(r.s();!(e=r.n()).done;){var n=e.value;delete this.config.superProperty[n]}}catch(t){r.e(t)}finally{r.f()}}},{key:"getSuperProperty",value:function(){return this.config.superProperty}},{key:"flush",value:function(){this.request.clear()}}]),e}();d([k],S.prototype,"environmentInfo",null),d([k],S.prototype,"sessionEnd",null),d([k],S.prototype,"sessionStart",null),d([k],S.prototype,"updateSession",null),d([k],S.prototype,"click",null),d([k],S.prototype,"pv",null),d([k],S.prototype,"duration",null),d([k],S.prototype,"track",null),d([k],S.prototype,"identify",null),d([k],S.prototype,"trackCount",null),d([k],S.prototype,"trackRevenue",null),d([k],S.prototype,"setUtm",null);var P=["onLaunch","onShow","onHide","onError","onPageNotFound","onUnhandledRejection","onThemeChange","onShareAppMessage","onLogin"],O=["onLoad","onShow","onReady","onHide","onUnload","onShareAppMessage","onReachBottom","onPageScroll","onPullDownRefresh","onTabItemTap","onInit","onShareTimeline","onAddToFavorites","onResize","onTitleClick","onOptionMenuClick","onPullIntercept","onURLQueryChange"],D=function(t){return w.wxGetTitle(t)},T=function(t,e,r){return new Promise((function(n,i){var u;wx.request((o(u={url:t,data:e,method:"POST",timeout:null==r?void 0:r.timeout},"header",{"content-type":"application/x-www-form-urlencoded"}),o(u,"dataType","json"),o(u,"responseType","arraybuffer"),o(u,"success",(function(t){n(t)})),o(u,"fail",(function(t){i(t)})),u))}))},$={getDid:function(){return new Promise((function(t,e){wx.getStorage({key:"zg-did",success:function(e){t(e.data),wx.removeStorage({key:"zg-did"})},fail:function(e){t("")}})}))},get:function(){return new Promise((function(t,e){wx.getStorage({key:"zg",success:function(e){t(e.data)},fail:function(e){t({})}})}))},set:function(t,e){return new Promise((function(r,n){wx.setStorage({key:t,data:e,success:r,fail:n})}))}},j=!1,E=wx.getSystemInfoSync(),z=E.system.split(/\s/),A={os:z[0],ov:z[1],version:E.version,windowHeight:E.windowHeight,windowWidth:E.windowWidth,net:0,mnet:0};function C(t){var e=t.toLowerCase();"wifi"===e?(A.net=1,A.mnet=0):(A.net=0,A.mnet={"2g":1,"3g":3,"4g":13}[e]||0)}function I(t){return new Promise((function(e,r){if(j)return e(A[t]);wx.getNetworkType({success:function(r){j=!0,C(r.networkType),e(A[t])}})}))}wx.onNetworkStatusChange((function(t){C(t.networkType)}));var L,q,R={os:function(){return A.os},ov:function(){return A.ov},version:function(){return A.version},net:function(){return I("net")},mnet:function(){return I("mnet")},windowWidth:function(){return A.windowWidth},windowHeight:function(){return A.windowHeight}},U=App,N=Page,F=Component,M=["eid","ct","tz","cuid","cn","sid","url","os","ov","wv","mnet","referrer_domain","net","vn","wxeid","uid","share_id","share_title","share_level","title","path"];function B(t,e,r){if(t[r]&&w.isFunction(t[r])){var n=t[r];t[r]=function(){n.apply(this,arguments),e[r].apply(this,arguments)}}else t[r]=function(){e[r].apply(this,arguments)}}function K(t,e,r){var n=t[e];t[e]=function(){var t=arguments[0];if(L===t||t&&L&&L.timeStamp===t.timeStamp)return n.apply(this,arguments);if(L=t,t){var e=t.type;"tap"===e&&r.click(t)}return n.apply(this,arguments)}}var G=function(e){u(o,S);var n=f(o);function o(t){var e;return r(this,o),(e=n.call(this,T,$,R)).openData={path:"",props:{}},e.shared=!1,e.semiAutoTrackEventCatch={},e.isShareOperation=!1,q=t,e}return i(o,[{key:"load",value:function(t,e){var r,n=l(a(o.prototype),"load",this).call(this,t,e),i=this,u=(r=i,{App:{onShow:function(t){r.sceneToUtm(t),r.openOptions=t,r.updateSession("appOnShow")},onHide:function(){r.flush(),r.config.duration&&!r.isShareOperation&&(r.pageReady=!0,r.currentPage.time=Date.now(),r.duration().then((function(){r.pageReady=!1,r.prevPage={queryObj:{},query:"",route:"",time:0,url:"",title:""}})))}},Page:{onLoad:function(t){r.currentPage.query=w.parseQuery(t),r.currentPage.queryObj=t},onShow:function(){var t=getCurrentPages(),e=t[t.length-1];r.currentPage.route=e.__route__||e.route,r.currentPage.time=Date.now(),r.currentPage.url="".concat(r.currentPage.route);var n=D;if(r.currentPage.title="function"==typeof n?n(e):"",r.currentPage.query&&(r.currentPage.url+="?".concat(r.currentPage.query)),r.pageReady=!0,r.freeBuffer(),r.currentPage.url!==r.prevPage.url){""!==r.prevPage.url&&r.duration();try{r.trackOpenShare(r.openOptions)}catch(t){console.warn(t,"".concat(r.referrerDomain," ","zhuge"," sdk trackOpenShare error"))}r.pv()}r.startObserveMarkElement(e),r.openOptions=null,r.isShareOperation=!1},onHide:function(){r.semiAutoTrackEventCatch={},r.prevPage=w.clone(r.currentPage),r.pageReady=!1,r.flush()},onUnload:function(){r.semiAutoTrackEventCatch={},r.prevPage=w.clone(r.currentPage),r.pageReady=!1,r.flush()}}});return this.lifecycle=u,App=function(t){for(var e in u.App)B(t,u.App,e);for(var r in t)!P.includes(r)&&w.isFunction(t[r])&&K(t,r,i);return U(t)},Page=function(t){for(var e in u.Page)B(t,u.Page,e);for(var r in t)!O.includes(r)&&w.isFunction(t[r])&&"onShareAppMessage"!==r&&K(t,r,i);var n=t.onShareAppMessage;return w.isFunction(n)&&(t.onShareAppMessage=i.onShareAppMessage(n)),N(t)},Component=function(t){if(void 0!==t.methods)for(var e in t.methods)K(t.methods,e,i);return F(t)},global.mpvue&&(global.App=App,global.Page=Page,global.Component=Component),App.zhuge=i,n}},{key:"pv",value:function(e){var r=this,n=Object.create(null,{pv:{get:function(){return l(a(o.prototype),"pv",r)}}});return v(this,void 0,void 0,t.mark((function e(){var r,i;return t.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return r={},i=w.getCurrentPage(),this.config.forwardShare&&this.openOptions&&(r.$share_open_type=1008===this.openOptions.scene?"群聊":"聊天",this.openOptions.query&&this.openOptions.query.zg_share_level&&(r.$share_level=Number(this.openOptions.query.zg_share_level)),i.data&&i.data.zg_share_data&&(r=w.merge(r,w.encode(i.data.zg_share_data)))),t.next=5,n.pv.call(this,r);case 5:case"end":return t.stop()}}),e,this)})))}},{key:"click",value:function(e,r){var n=this,i=Object.create(null,{click:{get:function(){return l(a(o.prototype),"click",n)}}});return v(this,void 0,void 0,t.mark((function n(){var o,u,a,s;return t.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return o=e.target,u=o.dataset.title,a=o.dataset.index,s=[],s="alipay-miniprogram"===this.referrerDomain?["","",e.detail.pageX,e.detail.pageY]:["","",e.detail.x,e.detail.y],t.next=7,i.click.call(this,e,w.merge({$element_content:u||"",$element_selector:a||"",$element_style:s},r||{}));case 7:case"end":return t.stop()}}),n,this)})))}},{key:"sceneToUtm",value:function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},e=w.getUtmByQuery(t.query);if(this.config.parseScene&&t.scene&&q){var r=t.scene;this.cn=r+"";var n=q[r],i={},o=null,u=q.isShare(r);if(u&&t.referrerInfo&&(o=t.referrerInfo.appId),n){i={utm_source:n.utm_source,utm_medium:n.utm_medium,utm_campaign:o};var a=t.query||{};q.isCartShare(r)&&a.zg_uid&&a.zg_share_id&&(i.utm_term=a.zg_uid,i.utm_content=a.zg_share_id)}e=w.merge(i,e)}"fresh"===this.config.utmMode&&w.isEmpty(this.config.utm)&&this.storage.set("utm",e)}},{key:"trackOpenShare",value:function(e){return v(this,void 0,void 0,t.mark((function r(){var n,i,o,u,a,s,c,f,l,h,p;return t.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(e&&this.config.forwardShare){t.next=2;break}return t.abrupt("return");case 2:if(!this.shared){t.next=5;break}return this.shared=!1,t.abrupt("return");case 5:if(n=e.query||{},i=this.currentPage.route,!(q.isCartShare(e.scene)&&n.zg_uid&&n.zg_share_id)){t.next=24;break}for(a in o={$uid:n.zg_uid,$share_id:n.zg_share_id,$title:this.currentPage.title,$path:i,$share_open_type:1008===e.scene?"群聊":"聊天",$share_level:Number(n.zg_share_level)},this.shareId=n.zg_share_id,this.shareLevel=Number(n.zg_share_level),u={},n)s=a.replace(/^zg_/,""),-1===M.indexOf(s)&&/^zg_/.test(a)&&(u[s]=n[a]);if(c=this.config.shareToUtm,w.isObject(c)&&!w.isEmpty(c)){for(l in f={},c)null!==u[l]&&void 0!==u[l]&&(h=c[l],f[h]=u[l]);w.isEmpty(w)||(f.utm_campaign||(f.utm_campaign="分享打开"),this.setUtm(f))}return this.openData={path:i,props:u},o=w.merge(o,w.encode(u)),t.next=19,this.trackBaseData("wxsopen");case 19:return(p=t.sent).dt="abp",p.pr=w.merge(p.pr,o),t.next=24,this.request.send(p);case 24:case"end":return t.stop()}}),r,this)})))}},{key:"onShareAppMessage",value:function(t){var e=this;return function(){e.isShareOperation=!0;var r=t.apply(this,arguments)||{};if(!e.config.forwardShare)return r;r.path=r.path||e.currentPage.url;var n=r.title||e.currentPage.title,i=r.path.split("?")[0],o=this.data.zg_share_data,u=(new Date).getTime(),a=1;!this.data.newShare&&e.openData&&e.openData.path===i&&w.isEqual(o||{},e.openData.props)&&(u=e.shareId,a=e.shareLevel+1);var s={share_id:u,uid:e.storage.allData.cuid||e.storage.allData.did,share_level:a},c={$share_title:n,$title:e.currentPage.title||"",$path:i},f={};for(var l in s)c["$".concat(l)]=f["zg_".concat(l)]=s[l];for(var h in o)-1===M.indexOf(h)&&(c["_".concat(h)]=f["zg_".concat(h)]=o[h]);return r.path=w.addUrlParam(r.path,f),e.trackBaseData("wxshare").then((function(t){t.dt="abp",t.pr=w.merge(t.pr,c),e.request.send(t)})),e.shared=!0,r}}},{key:"startObserveMarkElement",value:function(t){var e=this;this.config.exposure&&(this.elementObserver&&this.elementObserver.disconnect(),t.isComponent?this.elementObserver=t.createIntersectionObserver({observeAll:!0}):this.elementObserver=wx.createIntersectionObserver(t,{observeAll:!0}),this.elementObserver.relativeToViewport().observe(".zhuge-expo-track",(function(t){if(t.intersectionRatio>0){var r,n=e.getEventDataFromDataset(t.dataset);(r=l(a(o.prototype),"track",e)).call.apply(r,[e].concat(h(n)))}})))}},{key:"getEventDataFromDataset",value:function(t){var e={},r="";for(var n in t){if(n.startsWith("expo"))if("expoName"===n)r=t[n];else e[n.replace(/^expo(.*)/,(function(t,e,r,n){return e.replace(e[0],e[0].toLocaleLowerCase())}))]=t[n]}return[r,e]}}]),o}();d([k],G.prototype,"sceneToUtm",null),d([k],G.prototype,"trackOpenShare",null);var W={1001:{utm_source:"微信主程序",utm_medium:"发现栏小程序主入口"},1005:{utm_source:"搜索",utm_medium:"顶部搜索框的搜索结果页"},1006:{utm_source:"搜索",utm_medium:"发现栏小程序主入口搜索框的搜索结果页"},1007:{utm_source:"分享",utm_medium:"单人聊天会话中的小程序消息卡片"},1008:{utm_source:"分享",utm_medium:"群聊会话中的小程序消息卡片"},1011:{utm_source:"扫码",utm_medium:"扫描二维码"},1012:{utm_source:"扫码",utm_medium:"长按图片识别二维码"},1013:{utm_source:"扫码",utm_medium:"手机相册选取二维码"},1014:{utm_source:"小程序模板消息",utm_medium:"小程序模板消息"},1017:{utm_source:"体验版",utm_medium:"前往体验版的入口页"},1019:{utm_source:"微信支付",utm_medium:"微信钱包"},1020:{utm_source:"公众号",utm_medium:"公众号profile页相关小程序列表"},1022:{utm_source:"微信主程序",utm_medium:"聊天顶部置顶小程序入口"},1023:{utm_source:"桌面图标",utm_medium:"安卓系统桌面图标"},1024:{utm_source:"微信主程序",utm_medium:"小程序 profile 页"},1025:{utm_source:"扫码",utm_medium:"扫描一维码"},1026:{utm_source:"微信主程序",utm_medium:"附近小程序列表"},1027:{utm_source:"搜索",utm_medium:"顶部搜索框搜索结果页“使用过的小程序”列表"},1028:{utm_source:"微信卡券",utm_medium:"我的卡包"},1029:{utm_source:"微信卡券",utm_medium:"卡券详情页"},1030:{utm_source:"测试",utm_medium:"自动化测试下打开小程序"},1031:{utm_source:"扫码",utm_medium:"长按图片识别一维码"},1032:{utm_source:"扫码",utm_medium:"手机相册选取一维码"},1034:{utm_source:"微信支付",utm_medium:"微信支付完成页"},1035:{utm_source:"公众号",utm_medium:"公众号自定义菜单"},1036:{utm_source:"分享",utm_medium:"App分享消息卡片"},1037:{utm_source:"小程序",utm_medium:"小程序打开小程序"},1038:{utm_source:"小程序",utm_medium:"从另一个小程序返回"},1039:{utm_source:"摇电视",utm_medium:"摇电视"},1042:{utm_source:"搜索",utm_medium:"添加好友搜索框的搜索结果页"},1043:{utm_source:"公众号",utm_medium:"公众号模板消息"},1044:{utm_source:"分享",utm_medium:"带shareTicket的小程序消息卡片(详情)"},1045:{utm_source:"广告",utm_medium:"朋友圈广告"},1046:{utm_source:"广告",utm_medium:"朋友圈广告详情页"},1047:{utm_source:"扫码",utm_medium:"扫描小程序码"},1048:{utm_source:"扫码",utm_medium:"长按图片识别小程序码"},1049:{utm_source:"扫码",utm_medium:"手机相册选取小程序码"},1052:{utm_source:"微信卡券",utm_medium:"卡券的适用门店列表"},1053:{utm_source:"搜索",utm_medium:"搜一搜的结果页"},1054:{utm_source:"搜索",utm_medium:"顶部搜索框小程序快捷入口"},1056:{utm_source:"音乐播放器菜单",utm_medium:"音乐播放器菜单"},1057:{utm_source:"微信支付",utm_medium:"钱包中的银行卡详情页"},1058:{utm_source:"公众号",utm_medium:"公众号文章"},1059:{utm_source:"体验版",utm_medium:"体验版小程序绑定邀请页"},1064:{utm_source:"微信WIFI",utm_medium:"微信连Wi-Fi状态栏"},1067:{utm_source:"广告",utm_medium:"公众号文章广告"},1068:{utm_source:"广告",utm_medium:"附近小程序列表广告"},1069:{utm_source:"移动应用",utm_medium:"移动应用"},1071:{utm_source:"微信支付",utm_medium:"钱包中的银行卡列表页"},1072:{utm_source:"微信支付",utm_medium:"二维码收款页面"},1073:{utm_source:"客服消息",utm_medium:"客服消息列表下发的小程序消息卡片"},1074:{utm_source:"公众号会话",utm_medium:"公众号会话下发的小程序消息卡片"},1077:{utm_source:"摇周边",utm_medium:"摇周边"},1078:{utm_source:"微信WIFI",utm_medium:"连Wi-Fi成功页"},1079:{utm_source:"微信游戏中心",utm_medium:"微信游戏中心"},1081:{utm_source:"客服消息",utm_medium:"客服消息下发的文字链"},1082:{utm_source:"公众号",utm_medium:"公众号会话下发的文字链"},1084:{utm_source:"广告",utm_medium:"朋友圈广告原生页"},1089:{utm_source:"微信主程序",utm_medium:"微信聊天主界面下拉"},1090:{utm_source:"小程序",utm_medium:"长按小程序右上角菜单唤出最近使用历史"},1091:{utm_source:"公众号",utm_medium:"公众号文章商品卡片"},1092:{utm_source:"微信城市服务",utm_medium:"城市服务入口"},1095:{utm_source:"广告",utm_medium:"小程序广告组件"},1096:{utm_source:"分享",utm_medium:"聊天记录"},1097:{utm_source:"微信支付",utm_medium:"微信支付签约页"},1099:{utm_source:"小程序",utm_medium:"页面内嵌插件"},1102:{utm_source:"公众号",utm_medium:"公众号profile页服务预览"},1129:{utm_source:"爬虫",utm_medium:"微信爬虫"},isShare:function(t){return[1020,1035,1036,1037,1038,1043].includes(t)},isCartShare:function(t){return[1044,1007,1008,1036].includes(t)}},H=new(function(t){u(n,G);var e=f(n);function n(){return r(this,n),e.call(this,W)}return i(n,[{key:"load",value:function(t,e){var r=e||{};if(wx.getAccountInfoSync){var i=wx.getAccountInfoSync();i&&i.miniProgram&&i.miniProgram.appId&&(r.appId=i.miniProgram.appId)}return l(a(n.prototype),"load",this).call(this,t,r)}},{key:"weixinIdentify",value:function(){var t=this,e=this.config.appId;arguments[0]&&"string"==typeof arguments[0]&&(e=arguments[0]);var r,n=this.config.serverUrl.normal,i="",o="",u="",a="",s="",c="";function f(t,e,r){if(!(r&&t.length<=r)){var n=r||0;t[n].call(e,(function(){f(t,e,n+1)}))}}function l(t){wx.login({success:function(e){i=e.code,t&&t()},fail:function(t){console.error("诸葛SDK提示:","登录失败",t)}})}var h=function(r){var s=t,c={url:n+"/zgwx/user/code2session",method:"GET",data:{code:i,appId:e},success:function(t){o=t.data.openid,u=t.data.unionid,a=t.data.session_key,r&&r()},fail:function(t){n!==s.config.serverUrl.bac?(c.url=s.config.serverUrl.bac+"/zgwx/user/code2session",wx.request(c)):console.error("诸葛SDK提示:","获取codeSession失败",t)}};wx.request(c)};function p(t){wx.getSetting({success:function(e){e.authSetting["scope.userInfo"]?wx.getUserInfo({lang:"zh_CN",success:function(e){r=e.userInfo,s=e.iv,c=e.encryptedData,t&&t()}}):console.error("诸葛SDK提示:","未授权",e)}})}function m(t){wx.getUserProfile?wx.getUserProfile({desc:arguments[0]||"用于完善会员资料",lang:"zh_CN",success:function(e){r=e.userInfo,t&&t()},fail:function(e){console.error("userProfile错误",e),t&&t()}}):t&&t()}var d=function(e){var r=t,i={url:n+"/zgwx/data/decrypt",method:"POST",data:{sessionKey:a,iv:s,encryptData:c},success:function(t){u=t.data.unionId,e&&e(t.data||{})},fail:function(t){n!==r.config.serverUrl.bac?(i.url=r.config.serverUrl.bac+"/zgwx/data/decrypt",wx.request(i)):console.error("诸葛SDK提示:","获取codeSession失败",t)}};wx.request(i)},v=function(e){var n="";switch(r.gender){case 1:n="男";break;case 2:n="女"}t.identify(u||o,{name:r.nickName,avatar:r.avatarUrl,"微信-昵称":r.nickName,"微信-性别":n,"微信-城市":r.city,"微信-省":r.province,"微信-国家":r.country}),e&&e()},g=[m,l,p,h,d,v],y=Array.prototype.pop.call(arguments);"function"==typeof y&&g.push((function(){y({userInfo:r,unionid:u,openid:o,sessionKey:a})})),f(g,this)}}]),n}());App.zhuge=H;export default H;
|
package/dist/zhuge.min.js
CHANGED
|
@@ -13,4 +13,4 @@ var regeneratorRuntime=function(t){"use strict";var e,r=Object.prototype,n=r.has
|
|
|
13
13
|
OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
|
|
14
14
|
PERFORMANCE OF THIS SOFTWARE.
|
|
15
15
|
***************************************************************************** */
|
|
16
|
-
function p(t,e,r,n){var i,o=arguments.length,u=o<3?e:null===n?n=Object.getOwnPropertyDescriptor(e,r):n;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)u=Reflect.decorate(t,e,r,n);else for(var a=t.length-1;a>=0;a--)(i=t[a])&&(u=(o<3?i(u):o>3?i(e,r,u):i(e,r))||u);return o>3&&u&&Object.defineProperty(e,r,u),u}function d(t,e,r,n){return new(r||(r=Promise))((function(i,o){function u(t){try{s(n.next(t))}catch(t){o(t)}}function a(t){try{s(n.throw(t))}catch(t){o(t)}}function s(t){var e;t.done?i(t.value):(e=t.value,e instanceof r?e:new r((function(t){t(e)}))).then(u,a)}s((n=n.apply(t,e||[])).next())}))}var g,v,y,_={utmKeys:["utm_source","utm_medium","utm_campaign","utm_content","utm_term"],isValid:function(t){return null==t},type:function(t){return Object.prototype.toString.call(t)},isObject:function(t){return"[object Object]"===this.type(t)},isArray:function(t){return"[object Array]"===this.type(t)},isString:function(t){return"[object String]"===this.type(t)},isNumber:function(t){return"[object Number]"===this.type(t)},isDate:function(t){return"[object Date]"===this.type(t)},isFunction:function(t){return"[object Function]"===this.type(t)},isEmpty:function(t){return Array.isArray(t)||"string"==typeof t||t instanceof String?0===t.length:t instanceof Map||t instanceof Set?0===t.size:"[object Object]"===Object.prototype.toString.call(t)&&0===Object.keys(t).length},merge:function(){for(var t=this,e=arguments.length,r=new Array(e),n=0;n<e;n++)r[n]=arguments[n];return r.reduce((function(e,r){return Object.keys(r).forEach((function(n){Array.isArray(e[n])&&Array.isArray(r[n])?e[n]=Array.from(new Set(e[n].concat(r[n]))):t.isObject(e[n])&&t.isObject(r[n])?e[n]=t.merge(e[n],r[n]):e[n]=r[n]})),e}),{})},UUID:function(){var t=function(){return Math.floor(65536*(1+Math.random())).toString(16).substring(1)};return t()+t()+"-"+t()+"-"+t()+"-"+t()+"-"+t()+t()+t()},clone:function(e){var r=function(t){var e=t.constructor;switch(n(t)){case"Boolean":case"Number":case"String":case"Error":case"Date":return new e(t);case"RegExp":return o(t);case"Symbol":return i(t);case"Function":return t;default:return null}},n=function(t){return Object.prototype.toString.call(t).slice(8,-1)},i=function(t){return Object(Symbol.prototype.valueOf.call(t))},o=function(t){var e=new t.constructor(t.source,/\w*$/.exec(t));return e.lastIndex=t.lastIndex,e},u=function(t,e){for(var r=-1,n=t.length;++r<n;)e(t[r],r);return t},a=function e(i){var o=arguments.length>1&&void 0!==arguments[1]?arguments[1]:new WeakMap;if("object"!==t(i)||null===i)return i;var a=n(i),s=null;return o.get(i)?o.get(i):(o.set(i,s),"Set"!==a&&"Map"!==a&&"Array"!==a&&"Object"!==a?r(i):"Set"===a?(s=new Set,i.forEach((function(t){s.add(e(t,o))})),s):"Map"===a?(s=new Map,i.forEach((function(t,r){s.set(r,e(t,o))})),s):("Array"===a&&(s=new Array,u(i,(function(t,r){s[r]=e(t,o)}))),"Object"===a&&(s=new Object,u(Object.keys(i),(function(t){s[t]=e(i[t],o)}))),s))};return a(e)},parseQuery:function(t){if(this.isEmpty(t))return"";var e=[];for(var r in t)e.push("".concat(r,"=").concat(t[r]));return e.join("&")},getTimezone:function(t){return 6e4*-t.getTimezoneOffset()},encode:function(t){var e={};for(var r in t)e["_"+r]=t[r];return e},isEqual:function(t,e){if(this.type(t)!==this.type(e))return!1;var r=!0;for(var n in t)t[n]!==e[n]&&(r=!1);return r},getUtmByQuery:function(t){var e={};for(var r in t)this.utmKeys.includes(r)&&(e[r]=t[r]);return e},filterUtm:function(t){var e=["utm_source","utm_medium","utm_campaign","utm_content","utm_term"],r=!1,n={};for(var i in t)e.indexOf(i)>-1&&(r=!0,n[i]=t[i]);return r?n:null},deleteQueryParams:function(t,e){var r=t.split("&"),n=[];return r.forEach((function(t){var r=new RegExp(e+"=.*"),i="";r.test(t)?(i=t.replace(r,""))&&n.push(i):n.push(t)})),n.join("&")},addUrlParam:function(t,e){var r=t,n="";for(var i in e)n&&(n+="&"),r=this.deleteQueryParams(r,i),n+=i+"="+e[i];var o=r.split("?");return o.length>1?o[1]?o[1]=n+"&"+o[1]:o[1]=n:1===o.length&&o.push(n),o.join("?")},getCurrentPage:function(){var t=getCurrentPages();return t[t.length-1]},wxGetTitle:function(t){var e="";t.data&&t.data.title&&t.data.title.length>0&&(e=Array.isArray(t.data.title)?t.data.title.join(" "):t.data.title);try{if(!e.length&&__wxConfig&&(__wxConfig.tabBar&&__wxConfig.tabBar.list.forEach((function(r){r.pagePath==="".concat(t.route,".html")&&r.text&&(e=r.text)})),!e.length)){var r=__wxConfig.page[t.route]||__wxConfig.page["".concat(t.route,".html")];e=r?r.window.navigationBarTitleText:__wxConfig.global.window.navigationBarTitleText}}catch(t){console.error("解析title错误",t)}return e||t.route}},w=function(){function t(r,n){e(this,t),this.timeout=500,this.catch=[],this.clearCatchTimer=null,this.url="".concat(n.config.serverUrl.normal,"/apipool"),this.timeout=n.config.timeout||this.timeout,this.debug=n.config.debug?1:0,this.appKey=n.appKey,this.did=n.storage.allData.did,this.sendLimit=n.config.sendLimit,this.requestFunction=r}return n(t,[{key:"generateRequestData",value:function(){var t=new Date,e={method:"web_event_sr.upload",event:JSON.stringify({sln:"itn",pl:"js",sdk:"sys",sdkv:"2.0",owner:"zg",ut:"".concat(t.getFullYear(),"-").concat(t.getMonth()+1,"-").concat(t.getDate()," ").concat(t.getHours(),":").concat(t.getMinutes(),":").concat(t.getSeconds()),tz:_.getTimezone(t),debug:this.debug?1:0,ak:this.appKey,usr:{did:this.did},data:l(this.catch)}),_:t.getTime()+""};return this.catch=[],e}},{key:"clear",value:function(){var t=this.generateRequestData();this.requestFunction(this.url,t)}},{key:"send",value:function(t){var e=this;if(this.catch.push(t),this.clearCatchTimer&&clearTimeout(this.clearCatchTimer),this.clearCatchTimer=setTimeout((function(){e.clear()}),3e4),!(this.catch.length<this.sendLimit)){this.clearCatchTimer&&clearTimeout(this.clearCatchTimer);var r=this.generateRequestData();return new Promise((function(t,n){var i,o=!1;i=setTimeout((function(){o=!0,t(null)}),e.timeout),e.requestFunction(e.url,r).then((function(e){o||(clearTimeout(i),t(e))})).catch((function(t){n(t)}))}))}}}]),t}(),b=function(){function t(r,n,i){e(this,t),this.storageFunction=r,this.allData=i||{},this.allData.did||this.set("did",n.config.did||_.UUID()),this.allData.cuid||this.set("cuid",void 0),_.isEmpty(n.config.utm)||this.set("utm",n.config.utm)}return n(t,[{key:"get",value:function(t){return this.allData[t]}},{key:"set",value:function(t,e){return d(this,void 0,void 0,regeneratorRuntime.mark((function r(){return regeneratorRuntime.wrap((function(r){for(;;)switch(r.prev=r.next){case 0:return this.allData[t]=e,r.next=3,this.storageFunction.set("zg",this.allData);case 3:case"end":return r.stop()}}),r,this)})))}}]),t}();function x(t,e,r){var n=r.value;return r.value=function(){for(var t=arguments.length,r=new Array(t),i=0;i<t;i++)r[i]=arguments[i];if(this.pageReady&&this.loadReady)return n.apply(this,r);this.buffer.push({fnName:e,args:r})},r}var k=function(){function t(r,n,i){e(this,t),this.buffer=[],this.currentPage={queryObj:{},query:"",route:"",time:0,url:"",title:""},this.prevPage={queryObj:{},query:"",route:"",time:0,url:"",title:""},this.cn="",this.previousCountEvent={name:"",props:{}},this.count=0,this.countTimer=null,this.pageReady=!1,this.loadReady=!1,v=r,g=n,y=i,this.referrerDomain="miniprogram",this.appKey="",this.config={serverUrl:{normal:"https://u.zhugeapi.net",bac:"https://ubak.zhugeio.com"},debug:!1,pv:!1,click:!1,timeout:18e5,requestTimeout:500,did:"",duration:!1,vn:"1.0",appId:"",sendLimit:1,superProperty:{},forwardShare:!1,beforeDuration:function(){},afterDuration:function(){},countDuration:3e3,parseScene:!0,utm:{},utmMode:"session",shareToUtm:{},exposure:!1}}return n(t,[{key:"load",value:function(t,e){return d(this,void 0,void 0,regeneratorRuntime.mark((function r(){var n;return regeneratorRuntime.wrap((function(r){for(;;)switch(r.prev=r.next){case 0:return this.appKey=t,this.config=_.merge(this.config,e),r.prev=2,r.next=5,g.get();case 5:if((n=r.sent).did){r.next=10;break}return r.next=9,g.getDid();case 9:n.did=r.sent;case 10:this.storage=new b(g,this,n),this.request=new w(v,this),this.loadReady=!0,this.updateSession("load"),this.freeBuffer(),r.next=20;break;case 17:r.prev=17,r.t0=r.catch(2),console.error("sdk初始化失败,缓存读取失败",r.t0);case 20:case"end":return r.stop()}}),r,this,[[2,17]])})))}},{key:"freeBuffer",value:function(){if(this.loadReady&&this.pageReady)for(;this.buffer.length;){var e=this.buffer.shift();if(e)(t.prototype[e.fnName]||this[e.fnName]).apply(this,e.args)}}},{key:"send",value:function(t){var e=this.storage.allData.utm;if(e)for(var r in e)e[r]&&(t.pr["$".concat(r)]=e[r]);return this.request.send(t)}},{key:"trackBaseData",value:function(t){return d(this,void 0,void 0,regeneratorRuntime.mark((function e(){var r,n;return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return r=new Date,e.t0=t,e.t1=r.getTime(),e.t2=this.storage.allData.sid,e.t3=this.storage.allData.cuid,e.t4=this.cn,e.t5=_.getTimezone(r),e.t6=this.currentPage.url,e.t7=this.prevPage.url,e.t8=y.os(),e.t9=y.ov(),e.t10=y.version(),e.next=14,y.mnet();case 14:return e.t11=e.sent,e.next=17,y.net();case 17:return e.t12=e.sent,e.t13=this.config.vn,e.t14=this.referrerDomain,e.t15=this.config.appId,e.t16={$eid:e.t0,$ct:e.t1,$sid:e.t2,$cuid:e.t3,$cn:e.t4,$tz:e.t5,$url:e.t6,$ref:e.t7,$os:e.t8,$ov:e.t9,$wv:e.t10,$mnet:e.t11,$net:e.t12,$vn:e.t13,$referrer_domain:e.t14,$wxeid:e.t15},(n={dt:"evt",pr:e.t16}).pr=_.merge(n.pr,_.encode(this.config.superProperty)),e.abrupt("return",n);case 25:case"end":return e.stop()}}),e,this)})))}},{key:"environmentInfo",value:function(){var t=new Date,e={dt:"pl",pr:{$rs:"".concat(y.windowWidth(),"x").concat(y.windowHeight()),$tz:_.getTimezone(t),$ct:t.getTime(),$cuid:this.storage.allData.cuid,$sid:this.storage.allData.sid}};this.send(e)}},{key:"sessionEnd",value:function(t){var e=new Date,r=t.update-t.sid,n={dt:"se",pr:{$ct:t.update,$cn:this.cn,$tz:_.getTimezone(e),$dru:r,$sid:t.sid,$cuid:t.cuid,$referrer_domain:this.referrerDomain}};this.send(n)}},{key:"sessionStart",value:function(){return d(this,void 0,void 0,regeneratorRuntime.mark((function t(){var e,r,n,i,o;return regeneratorRuntime.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return e=new Date,r=this.storage.allData,n=r.sid,i=r.cuid,t.t0=n,t.t1=n,t.t2=i,t.t3=this.cn,t.t4=_.getTimezone(e),t.t5=this.currentPage.url,t.t6=this.prevPage.url,t.t7=y.os(),t.t8=y.ov(),t.t9=y.version(),t.next=14,y.mnet();case 14:return t.t10=t.sent,t.next=17,y.net();case 17:t.t11=t.sent,t.t12=this.config.vn,t.t13=this.referrerDomain,t.t14=this.config.appId,t.t15={$ct:t.t0,$sid:t.t1,$cuid:t.t2,$cn:t.t3,$tz:t.t4,$url:t.t5,$ref:t.t6,$os:t.t7,$ov:t.t8,$wv:t.t9,$mnet:t.t10,$net:t.t11,$vn:t.t12,$referrer_domain:t.t13,$wxeid:t.t14},o={dt:"ss",pr:t.t15},this.send(o),this.environmentInfo();case 25:case"end":return t.stop()}}),t,this)})))}},{key:"updateSession",value:function(t){var e=this.storage.allData,r=Date.now();if(e.sid&&e.update)if(r-e.update>this.config.timeout){var n=_.clone(e);this.storage.set("sid",r),this.storage.set("update",r),this.sessionEnd(n),this.sessionStart()}else this.storage.set("update",r);else this.storage.set("sid",r),this.storage.set("update",r),this.sessionStart()}},{key:"click",value:function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{$element_content:"",$element_selector:"",$element_style:[]};return d(this,void 0,void 0,regeneratorRuntime.mark((function t(){var r;return regeneratorRuntime.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(this.config.click){t.next=2;break}return t.abrupt("return");case 2:return this.updateSession("click"),t.next=5,this.trackBaseData("click");case 5:return(r=t.sent).dt="abp",r.pr=_.merge(r.pr,{$page_url:this.currentPage.url,$page_title:this.currentPage.title},e),t.next=10,this.send(r);case 10:case"end":return t.stop()}}),t,this)})))}},{key:"pv",value:function(t){return d(this,void 0,void 0,regeneratorRuntime.mark((function e(){var r,n;return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(this.config.pv){e.next=2;break}return e.abrupt("return");case 2:return this.updateSession("pv"),e.next=5,this.trackBaseData("pv");case 5:return(r=e.sent).dt="abp",n={$page_title:this.currentPage.title},r.pr=_.merge(r.pr,n,t||{}),e.next=11,this.send(r);case 11:case"end":return e.stop()}}),e,this)})))}},{key:"duration",value:function(){return d(this,void 0,void 0,regeneratorRuntime.mark((function t(){var e,r;return regeneratorRuntime.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(this.config.duration){t.next=2;break}return t.abrupt("return");case 2:return this.updateSession("duration"),_.isFunction(this.config.beforeDuration)&&this.config.beforeDuration(),e=this.currentPage.time-this.prevPage.time,t.next=7,this.trackBaseData("dr");case 7:return(r=t.sent).dt="abp",r.pr=_.merge(r.pr,{$dr:e,$url:this.prevPage.url,$title:this.prevPage.title}),t.next=12,this.send(r);case 12:_.isFunction(this.config.afterDuration)&&this.config.afterDuration();case 13:case"end":return t.stop()}}),t,this)})))}},{key:"track",value:function(t,e){return d(this,void 0,void 0,regeneratorRuntime.mark((function r(){var n;return regeneratorRuntime.wrap((function(r){for(;;)switch(r.prev=r.next){case 0:return this.updateSession("track"),r.next=3,this.trackBaseData(t);case 3:return(n=r.sent).pr=_.merge(n.pr,_.encode(e)),r.next=7,this.send(n);case 7:case"end":return r.stop()}}),r,this)})))}},{key:"identify",value:function(t,e){return d(this,void 0,void 0,regeneratorRuntime.mark((function r(){var n,i;return regeneratorRuntime.wrap((function(r){for(;;)switch(r.prev=r.next){case 0:return this.storage.set("cuid",t),this.updateSession("identify"),n=new Date,(i={dt:"usr",pr:{$ct:n.getTime(),$tz:_.getTimezone(n),$cuid:t,$sid:this.storage.allData.sid,$url:this.currentPage.url}}).pr=_.merge(i.pr,_.encode(e)),r.next=7,this.trackBaseData("usr");case 7:return r.next=9,this.send(i);case 9:case"end":return r.stop()}}),r,this)})))}},{key:"trackCount",value:function(t,e){var r=this;0===this.count&&(this.countStartTime=Date.now(),this.previousCountEvent.name=t,this.previousCountEvent.props=_.clone(e)),this.previousCountEvent.name===t&&_.isEqual(this.previousCountEvent.props,e)||(this.sendCountEvent(this.previousCountEvent.name,this.previousCountEvent.props,!1),this.previousCountEvent.name=t,this.previousCountEvent.props=_.clone(e),this.countStartTime=Date.now(),this.count=0),this.count+=1,this.countTimer&&clearTimeout(this.countTimer),this.countTimer=setTimeout((function(){r.sendCountEvent(t,e,!0)}),this.config.countDuration)}},{key:"sendCountEvent",value:function(t,e,r){return d(this,void 0,void 0,regeneratorRuntime.mark((function n(){var i,o,u,a;return regeneratorRuntime.wrap((function(n){for(;;)switch(n.prev=n.next){case 0:return this.updateSession("track count"),i=Date.now()-this.countStartTime,r&&(i-=this.config.countDuration),o=this.count,this.count=r?0:1,n.next=7,this.trackBaseData(t);case 7:return u=n.sent,a={},_.isObject(e)&&(a=_.clone(e)),u.pr=_.merge(u.pr,_.encode(a),_.encode({count:o,countTime:i})),n.next=13,this.send(u);case 13:case"end":return n.stop()}}),n,this)})))}},{key:"trackRevenue",value:function(t){return d(this,void 0,void 0,regeneratorRuntime.mark((function e(){var r,n,i,o,u,a,s,c;return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return i=function(t,e){var r=0;try{t.toString().split(".")[1]&&(r+=t.toString().split(".")[1].length)}catch(t){console.error(t)}try{e.toString().split(".")[1]&&(r+=e.toString().split(".")[1].length)}catch(t){console.error(t)}return Number(t.toString().replace(".",""))*Number(e.toString().replace(".",""))/Math.pow(10,r)},this.updateSession("track revenue"),e.next=4,this.trackBaseData("revenue");case 4:(r=e.sent).dt="abp",(n=_.merge({price:0,total:0,productID:null,productQuantity:0,revenueType:null},t)).total=i(n.price,n.productQuantity),o=["productID","revenueType"],u=["price","total","productQuantity"],a={},e.t0=regeneratorRuntime.keys(n);case 12:if((e.t1=e.t0()).done){e.next=21;break}if(s=e.t1.value,-1!==o.indexOf(s)||-1!==u.indexOf(s)){e.next=16;break}return e.abrupt("continue",12);case 16:c=n[s],u.indexOf(s)>-1&&((c=Number(c))||(c=0)),a["$"+s]=c,e.next=12;break;case 21:return r.pr=_.merge(r.pr,a),e.next=24,this.send(r);case 24:case"end":return e.stop()}}),e,this)})))}},{key:"setUtm",value:function(t){return d(this,void 0,void 0,regeneratorRuntime.mark((function e(){var r;return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:null!==(r=_.filterUtm(t))&&(this.storage.set("utm",r),this.updateSession("setUtm"));case 2:case"end":return e.stop()}}),e,this)})))}},{key:"setSuperProperty",value:function(t){_.isObject(t)&&(this.config.superProperty=t)}},{key:"extendSuperPropertys",value:function(t){_.isObject(t)&&(this.config.superProperty=_.merge(this.config.superProperty,t))}},{key:"removeSuperProperty",value:function(t){var e,r=function(t,e){var r;if("undefined"==typeof Symbol||null==t[Symbol.iterator]){if(Array.isArray(t)||(r=m(t))||e&&t&&"number"==typeof t.length){r&&(t=r);var n=0,i=function(){};return{s:i,n:function(){return n>=t.length?{done:!0}:{done:!1,value:t[n++]}},e:function(t){throw t},f:i}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var o,u=!0,a=!1;return{s:function(){r=t[Symbol.iterator]()},n:function(){var t=r.next();return u=t.done,t},e:function(t){a=!0,o=t},f:function(){try{u||null==r.return||r.return()}finally{if(a)throw o}}}}(t);try{for(r.s();!(e=r.n()).done;){var n=e.value;delete this.config.superProperty[n]}}catch(t){r.e(t)}finally{r.f()}}},{key:"getSuperProperty",value:function(){return this.config.superProperty}}]),t}();p([x],k.prototype,"environmentInfo",null),p([x],k.prototype,"sessionEnd",null),p([x],k.prototype,"sessionStart",null),p([x],k.prototype,"updateSession",null),p([x],k.prototype,"click",null),p([x],k.prototype,"pv",null),p([x],k.prototype,"duration",null),p([x],k.prototype,"track",null),p([x],k.prototype,"identify",null),p([x],k.prototype,"trackCount",null),p([x],k.prototype,"trackRevenue",null),p([x],k.prototype,"setUtm",null);var S=["onLaunch","onShow","onHide","onError","onPageNotFound","onUnhandledRejection","onThemeChange","onShareAppMessage","onLogin"],P=["onLoad","onShow","onReady","onHide","onUnload","onShareAppMessage","onReachBottom","onPageScroll","onPullDownRefresh","onTabItemTap","onInit","onShareTimeline","onAddToFavorites","onResize","onTitleClick","onOptionMenuClick","onPullIntercept","onURLQueryChange"],O=function(t){return _.wxGetTitle(t)},D=function(t,e){return new Promise((function(r,n){var o;wx.request((i(o={url:t,data:e,method:"POST"},"header",{"content-type":"application/x-www-form-urlencoded"}),i(o,"dataType","json"),i(o,"responseType","arraybuffer"),i(o,"success",(function(t){r(t)})),i(o,"fail",(function(t){n(t)})),o))}))},T=["getStorage:fail data not found","getStorage:fail:data not found"],$={getDid:function(){return new Promise((function(t,e){wx.getStorage({key:"zg-did",success:function(e){t(e.data),wx.removeStorage({key:"zg-did"})},fail:function(r){T.includes(r.errMsg)?t(""):e(r)}})}))},get:function(){return new Promise((function(t,e){wx.getStorage({key:"zg",success:function(e){t(e.data)},fail:function(r){T.includes(r.errMsg)?t({}):e(r)}})}))},set:function(t,e){return new Promise((function(r,n){wx.setStorage({key:t,data:e,success:r,fail:n})}))}},j=!1,R=wx.getSystemInfoSync(),E=R.system.split(/\s/),z={os:E[0],ov:E[1],version:R.version,windowHeight:R.windowHeight,windowWidth:R.windowWidth,net:0,mnet:0};function A(t){var e=t.toLowerCase();"wifi"===e?(z.net=1,z.mnet=0):(z.net=0,z.mnet={"2g":1,"3g":3,"4g":13}[e]||0)}function C(t){return new Promise((function(e,r){if(j)return e(z[t]);wx.getNetworkType({success:function(r){j=!0,A(r.networkType),e(z[t])}})}))}wx.onNetworkStatusChange((function(t){A(t.networkType)}));var I,L,q={os:function(){return z.os},ov:function(){return z.ov},version:function(){return z.version},net:function(){return C("net")},mnet:function(){return C("mnet")},windowWidth:function(){return z.windowWidth},windowHeight:function(){return z.windowHeight}},U=App,N=Page,F=Component,M=["eid","ct","tz","cuid","cn","sid","url","os","ov","wv","mnet","referrer_domain","net","vn","wxeid","uid","share_id","share_title","share_level","title","path"];function B(t,e,r){if(t[r]&&_.isFunction(t[r])){var n=t[r];t[r]=function(){n.apply(this,arguments),e[r].apply(this,arguments)}}else t[r]=function(){e[r].apply(this,arguments)}}function K(t,e,r){var n=t[e];t[e]=function(){var t=arguments[0];if(I===t||t&&I&&I.timeStamp===t.timeStamp)return n.apply(this,arguments);if(I=t,t){var e=t.type;"tap"===e&&r.click(t)}return n.apply(this,arguments)}}var G=function(t){o(i,t);var r=c(i);function i(t){var n;return e(this,i),(n=r.call(this,D,$,q)).openData={path:"",props:{}},n.shared=!1,n.semiAutoTrackEventCatch={},n.isShareOperation=!1,L=t,n}return n(i,[{key:"load",value:function(t,e){var r,n=f(u(i.prototype),"load",this).call(this,t,e),o=this,a=(r=o,{App:{onShow:function(t){r.sceneToUtm(t),r.openOptions=t,r.updateSession("appOnShow")},onHide:function(){r.config.duration&&!r.isShareOperation&&(r.pageReady=!0,r.currentPage.time=Date.now(),r.duration().then((function(){r.pageReady=!1,r.prevPage={queryObj:{},query:"",route:"",time:0,url:"",title:""}})))}},Page:{onLoad:function(t){r.currentPage.query=_.parseQuery(t),r.currentPage.queryObj=t},onShow:function(){var t=getCurrentPages(),e=t[t.length-1];r.currentPage.route=e.__route__||e.route,r.currentPage.time=Date.now(),r.currentPage.url="".concat(r.currentPage.route);var n=O;if(r.currentPage.title="function"==typeof n?n(e):"",r.currentPage.query&&(r.currentPage.url+="?".concat(r.currentPage.query)),r.pageReady=!0,r.freeBuffer(),r.currentPage.url!==r.prevPage.url){""!==r.prevPage.url&&r.duration();try{r.trackOpenShare(r.openOptions)}catch(t){console.warn(t,"".concat(r.referrerDomain," ","zhuge"," sdk trackOpenShare error"))}r.pv()}r.startObserveMarkElement(e),r.openOptions=null,r.isShareOperation=!1},onHide:function(){r.semiAutoTrackEventCatch={},r.prevPage=_.clone(r.currentPage),r.pageReady=!1},onUnload:function(){r.semiAutoTrackEventCatch={},r.prevPage=_.clone(r.currentPage),r.pageReady=!1}}});return this.lifecycle=a,App=function(t){for(var e in a.App)B(t,a.App,e);for(var r in t)!S.includes(r)&&_.isFunction(t[r])&&K(t,r,o);return U(t)},Page=function(t){for(var e in a.Page)B(t,a.Page,e);for(var r in t)!P.includes(r)&&_.isFunction(t[r])&&"onShareAppMessage"!==r&&K(t,r,o);var n=t.onShareAppMessage;return _.isFunction(n)&&(t.onShareAppMessage=o.onShareAppMessage(n)),N(t)},Component=function(t){if(void 0!==t.methods)for(var e in t.methods)K(t.methods,e,o);return F(t)},global.mpvue&&(global.App=App,global.Page=Page,global.Component=Component),App.zhuge=o,n}},{key:"pv",value:function(t){var e=this,r=Object.create(null,{pv:{get:function(){return f(u(i.prototype),"pv",e)}}});return d(this,void 0,void 0,regeneratorRuntime.mark((function t(){var e,n;return regeneratorRuntime.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return e={},n=_.getCurrentPage(),this.config.forwardShare&&this.openOptions&&(e.$share_open_type=1008===this.openOptions.scene?"群聊":"聊天",this.openOptions.query&&this.openOptions.query.zg_share_level&&(e.$share_level=Number(this.openOptions.query.zg_share_level)),n.data&&n.data.zg_share_data&&(e=_.merge(e,_.encode(n.data.zg_share_data)))),t.next=5,r.pv.call(this,e);case 5:case"end":return t.stop()}}),t,this)})))}},{key:"click",value:function(t,e){var r=this,n=Object.create(null,{click:{get:function(){return f(u(i.prototype),"click",r)}}});return d(this,void 0,void 0,regeneratorRuntime.mark((function r(){var i,o,u,a;return regeneratorRuntime.wrap((function(r){for(;;)switch(r.prev=r.next){case 0:return i=t.target,o=i.dataset.title,u=i.dataset.index,a=[],a="alipay-miniprogram"===this.referrerDomain?["","",t.detail.pageX,t.detail.pageY]:["","",t.detail.x,t.detail.y],r.next=7,n.click.call(this,t,_.merge({$element_content:o||"",$element_selector:u||"",$element_style:a},e||{}));case 7:case"end":return r.stop()}}),r,this)})))}},{key:"sceneToUtm",value:function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},e=_.getUtmByQuery(t.query);if(this.config.parseScene&&t.scene&&L){var r=t.scene;this.cn=r+"";var n=L[r],i={},o=null,u=L.isShare(r);if(u&&t.referrerInfo&&(o=t.referrerInfo.appId),n){i={utm_source:n.utm_source,utm_medium:n.utm_medium,utm_campaign:o};var a=t.query||{};L.isCartShare(r)&&a.zg_uid&&a.zg_share_id&&(i.utm_term=a.zg_uid,i.utm_content=a.zg_share_id)}e=_.merge(i,e)}"fresh"===this.config.utmMode&&_.isEmpty(this.config.utm)&&this.storage.set("utm",e)}},{key:"trackOpenShare",value:function(t){return d(this,void 0,void 0,regeneratorRuntime.mark((function e(){var r,n,i,o,u,a,s,c,f,l,m;return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(t&&this.config.forwardShare){e.next=2;break}return e.abrupt("return");case 2:if(!this.shared){e.next=5;break}return this.shared=!1,e.abrupt("return");case 5:if(r=t.query||{},n=this.currentPage.route,!(L.isCartShare(t.scene)&&r.zg_uid&&r.zg_share_id)){e.next=24;break}for(u in i={$uid:r.zg_uid,$share_id:r.zg_share_id,$title:this.currentPage.title,$path:n,$share_open_type:1008===t.scene?"群聊":"聊天",$share_level:Number(r.zg_share_level)},this.shareId=r.zg_share_id,this.shareLevel=Number(r.zg_share_level),o={},r)a=u.replace(/^zg_/,""),-1===M.indexOf(a)&&/^zg_/.test(u)&&(o[a]=r[u]);if(s=this.config.shareToUtm,_.isObject(s)&&!_.isEmpty(s)){for(f in c={},s)null!==o[f]&&void 0!==o[f]&&(l=s[f],c[l]=o[f]);_.isEmpty(_)||(c.utm_campaign||(c.utm_campaign="分享打开"),this.setUtm(c))}return this.openData={path:n,props:o},i=_.merge(i,_.encode(o)),e.next=19,this.trackBaseData("wxsopen");case 19:return(m=e.sent).dt="abp",m.pr=_.merge(m.pr,i),e.next=24,this.request.send(m);case 24:case"end":return e.stop()}}),e,this)})))}},{key:"onShareAppMessage",value:function(t){var e=this;return function(){e.isShareOperation=!0;var r=t.apply(this,arguments)||{};if(!e.config.forwardShare)return r;r.path=r.path||e.currentPage.url;var n=r.title||e.currentPage.title,i=r.path.split("?")[0],o=this.data.zg_share_data,u=(new Date).getTime(),a=1;!this.data.newShare&&e.openData&&e.openData.path===i&&_.isEqual(o||{},e.openData.props)&&(u=e.shareId,a=e.shareLevel+1);var s={share_id:u,uid:e.storage.allData.cuid||e.storage.allData.did,share_level:a},c={$share_title:n,$title:e.currentPage.title||"",$path:i},f={};for(var l in s)c["$".concat(l)]=f["zg_".concat(l)]=s[l];for(var m in o)-1===M.indexOf(m)&&(c["_".concat(m)]=f["zg_".concat(m)]=o[m]);return r.path=_.addUrlParam(r.path,f),e.trackBaseData("wxshare").then((function(t){t.dt="abp",t.pr=_.merge(t.pr,c),e.request.send(t)})),e.shared=!0,r}}},{key:"startObserveMarkElement",value:function(t){var e=this;this.config.exposure&&(this.elementObserver&&this.elementObserver.disconnect(),t.isComponent?this.elementObserver=t.createIntersectionObserver({observeAll:!0}):this.elementObserver=wx.createIntersectionObserver(t,{observeAll:!0}),this.elementObserver.relativeToViewport().observe(".zhuge-expo-track",(function(t){if(t.intersectionRatio>0){var r,n=e.getEventDataFromDataset(t.dataset);(r=f(u(i.prototype),"track",e)).call.apply(r,[e].concat(l(n)))}})))}},{key:"getEventDataFromDataset",value:function(t){var e={},r="";for(var n in t){if(n.startsWith("expo"))if("expoName"===n)r=t[n];else e[n.replace(/^expo(.*)/,(function(t,e,r,n){return e.replace(e[0],e[0].toLocaleLowerCase())}))]=t[n]}return[r,e]}}]),i}(k);p([x],G.prototype,"sceneToUtm",null),p([x],G.prototype,"trackOpenShare",null);var W={1001:{utm_source:"微信主程序",utm_medium:"发现栏小程序主入口"},1005:{utm_source:"搜索",utm_medium:"顶部搜索框的搜索结果页"},1006:{utm_source:"搜索",utm_medium:"发现栏小程序主入口搜索框的搜索结果页"},1007:{utm_source:"分享",utm_medium:"单人聊天会话中的小程序消息卡片"},1008:{utm_source:"分享",utm_medium:"群聊会话中的小程序消息卡片"},1011:{utm_source:"扫码",utm_medium:"扫描二维码"},1012:{utm_source:"扫码",utm_medium:"长按图片识别二维码"},1013:{utm_source:"扫码",utm_medium:"手机相册选取二维码"},1014:{utm_source:"小程序模板消息",utm_medium:"小程序模板消息"},1017:{utm_source:"体验版",utm_medium:"前往体验版的入口页"},1019:{utm_source:"微信支付",utm_medium:"微信钱包"},1020:{utm_source:"公众号",utm_medium:"公众号profile页相关小程序列表"},1022:{utm_source:"微信主程序",utm_medium:"聊天顶部置顶小程序入口"},1023:{utm_source:"桌面图标",utm_medium:"安卓系统桌面图标"},1024:{utm_source:"微信主程序",utm_medium:"小程序 profile 页"},1025:{utm_source:"扫码",utm_medium:"扫描一维码"},1026:{utm_source:"微信主程序",utm_medium:"附近小程序列表"},1027:{utm_source:"搜索",utm_medium:"顶部搜索框搜索结果页“使用过的小程序”列表"},1028:{utm_source:"微信卡券",utm_medium:"我的卡包"},1029:{utm_source:"微信卡券",utm_medium:"卡券详情页"},1030:{utm_source:"测试",utm_medium:"自动化测试下打开小程序"},1031:{utm_source:"扫码",utm_medium:"长按图片识别一维码"},1032:{utm_source:"扫码",utm_medium:"手机相册选取一维码"},1034:{utm_source:"微信支付",utm_medium:"微信支付完成页"},1035:{utm_source:"公众号",utm_medium:"公众号自定义菜单"},1036:{utm_source:"分享",utm_medium:"App分享消息卡片"},1037:{utm_source:"小程序",utm_medium:"小程序打开小程序"},1038:{utm_source:"小程序",utm_medium:"从另一个小程序返回"},1039:{utm_source:"摇电视",utm_medium:"摇电视"},1042:{utm_source:"搜索",utm_medium:"添加好友搜索框的搜索结果页"},1043:{utm_source:"公众号",utm_medium:"公众号模板消息"},1044:{utm_source:"分享",utm_medium:"带shareTicket的小程序消息卡片(详情)"},1045:{utm_source:"广告",utm_medium:"朋友圈广告"},1046:{utm_source:"广告",utm_medium:"朋友圈广告详情页"},1047:{utm_source:"扫码",utm_medium:"扫描小程序码"},1048:{utm_source:"扫码",utm_medium:"长按图片识别小程序码"},1049:{utm_source:"扫码",utm_medium:"手机相册选取小程序码"},1052:{utm_source:"微信卡券",utm_medium:"卡券的适用门店列表"},1053:{utm_source:"搜索",utm_medium:"搜一搜的结果页"},1054:{utm_source:"搜索",utm_medium:"顶部搜索框小程序快捷入口"},1056:{utm_source:"音乐播放器菜单",utm_medium:"音乐播放器菜单"},1057:{utm_source:"微信支付",utm_medium:"钱包中的银行卡详情页"},1058:{utm_source:"公众号",utm_medium:"公众号文章"},1059:{utm_source:"体验版",utm_medium:"体验版小程序绑定邀请页"},1064:{utm_source:"微信WIFI",utm_medium:"微信连Wi-Fi状态栏"},1067:{utm_source:"广告",utm_medium:"公众号文章广告"},1068:{utm_source:"广告",utm_medium:"附近小程序列表广告"},1069:{utm_source:"移动应用",utm_medium:"移动应用"},1071:{utm_source:"微信支付",utm_medium:"钱包中的银行卡列表页"},1072:{utm_source:"微信支付",utm_medium:"二维码收款页面"},1073:{utm_source:"客服消息",utm_medium:"客服消息列表下发的小程序消息卡片"},1074:{utm_source:"公众号会话",utm_medium:"公众号会话下发的小程序消息卡片"},1077:{utm_source:"摇周边",utm_medium:"摇周边"},1078:{utm_source:"微信WIFI",utm_medium:"连Wi-Fi成功页"},1079:{utm_source:"微信游戏中心",utm_medium:"微信游戏中心"},1081:{utm_source:"客服消息",utm_medium:"客服消息下发的文字链"},1082:{utm_source:"公众号",utm_medium:"公众号会话下发的文字链"},1084:{utm_source:"广告",utm_medium:"朋友圈广告原生页"},1089:{utm_source:"微信主程序",utm_medium:"微信聊天主界面下拉"},1090:{utm_source:"小程序",utm_medium:"长按小程序右上角菜单唤出最近使用历史"},1091:{utm_source:"公众号",utm_medium:"公众号文章商品卡片"},1092:{utm_source:"微信城市服务",utm_medium:"城市服务入口"},1095:{utm_source:"广告",utm_medium:"小程序广告组件"},1096:{utm_source:"分享",utm_medium:"聊天记录"},1097:{utm_source:"微信支付",utm_medium:"微信支付签约页"},1099:{utm_source:"小程序",utm_medium:"页面内嵌插件"},1102:{utm_source:"公众号",utm_medium:"公众号profile页服务预览"},1129:{utm_source:"爬虫",utm_medium:"微信爬虫"},isShare:function(t){return[1020,1035,1036,1037,1038,1043].includes(t)},isCartShare:function(t){return[1044,1007,1008,1036].includes(t)}},H=new(function(t){o(i,t);var r=c(i);function i(){return e(this,i),r.call(this,W)}return n(i,[{key:"load",value:function(t,e){if(wx.getAccountInfoSync){var r=wx.getAccountInfoSync();r&&r.miniProgram&&r.miniProgram.appId&&(e.appId=r.miniProgram.appId)}return f(u(i.prototype),"load",this).call(this,t,e)}},{key:"weixinIdentify",value:function(){var t=this,e=this.config.appId;arguments[0]&&"string"==typeof arguments[0]&&(e=arguments[0]);var r,n=this.config.serverUrl.normal,i="",o="",u="",a="",s="",c="";function f(t,e,r){if(!(r&&t.length<=r)){var n=r||0;t[n].call(e,(function(){f(t,e,n+1)}))}}function l(t){wx.login({success:function(e){i=e.code,t&&t()},fail:function(t){console.error("诸葛SDK提示:","登录失败",t)}})}var m=function(r){var s=t,c={url:n+"/zgwx/user/code2session",method:"GET",data:{code:i,appId:e},success:function(t){o=t.data.openid,u=t.data.unionid,a=t.data.session_key,r&&r()},fail:function(t){n!==s.config.serverUrl.bac?(c.url=s.config.serverUrl.bac+"/zgwx/user/code2session",wx.request(c)):console.error("诸葛SDK提示:","获取codeSession失败",t)}};wx.request(c)};function h(t){wx.getSetting({success:function(e){e.authSetting["scope.userInfo"]?wx.getUserInfo({lang:"zh_CN",success:function(e){r=e.userInfo,s=e.iv,c=e.encryptedData,t&&t()}}):console.error("诸葛SDK提示:","未授权",e)}})}function p(t){wx.getUserProfile?wx.getUserProfile({desc:arguments[0]||"用于完善会员资料",lang:"zh_CN",success:function(e){r=e.userInfo,t&&t()},fail:function(e){console.error("userProfile错误",e),t&&t()}}):t&&t()}var d=function(e){var r=t,i={url:n+"/zgwx/data/decrypt",method:"POST",data:{sessionKey:a,iv:s,encryptData:c},success:function(t){u=t.data.unionId,e&&e(t.data||{})},fail:function(t){n!==r.config.serverUrl.bac?(i.url=r.config.serverUrl.bac+"/zgwx/data/decrypt",wx.request(i)):console.error("诸葛SDK提示:","获取codeSession失败",t)}};wx.request(i)},g=function(e){var n="";switch(r.gender){case 1:n="男";break;case 2:n="女"}t.identify(u||o,{name:r.nickName,avatar:r.avatarUrl,"微信-昵称":r.nickName,"微信-性别":n,"微信-城市":r.city,"微信-省":r.province,"微信-国家":r.country}),e&&e()},v=[p,l,h,m,d,g],y=Array.prototype.pop.call(arguments);"function"==typeof y&&v.push((function(){y({userInfo:r,unionid:u,openid:o,sessionKey:a})})),f(v,this)}}]),i}(G));return App.zhuge=H,H}));
|
|
16
|
+
function p(t,e,r,n){var i,o=arguments.length,u=o<3?e:null===n?n=Object.getOwnPropertyDescriptor(e,r):n;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)u=Reflect.decorate(t,e,r,n);else for(var a=t.length-1;a>=0;a--)(i=t[a])&&(u=(o<3?i(u):o>3?i(e,r,u):i(e,r))||u);return o>3&&u&&Object.defineProperty(e,r,u),u}function d(t,e,r,n){return new(r||(r=Promise))((function(i,o){function u(t){try{s(n.next(t))}catch(t){o(t)}}function a(t){try{s(n.throw(t))}catch(t){o(t)}}function s(t){var e;t.done?i(t.value):(e=t.value,e instanceof r?e:new r((function(t){t(e)}))).then(u,a)}s((n=n.apply(t,e||[])).next())}))}var g,v,y,_={utmKeys:["utm_source","utm_medium","utm_campaign","utm_content","utm_term"],isValid:function(t){return null==t},type:function(t){return Object.prototype.toString.call(t)},isObject:function(t){return"[object Object]"===this.type(t)},isArray:function(t){return"[object Array]"===this.type(t)},isString:function(t){return"[object String]"===this.type(t)},isNumber:function(t){return"[object Number]"===this.type(t)},isDate:function(t){return"[object Date]"===this.type(t)},isFunction:function(t){return"[object Function]"===this.type(t)},isEmpty:function(t){return Array.isArray(t)||"string"==typeof t||t instanceof String?0===t.length:t instanceof Map||t instanceof Set?0===t.size:"[object Object]"===Object.prototype.toString.call(t)&&0===Object.keys(t).length},merge:function(){for(var t=this,e=arguments.length,r=new Array(e),n=0;n<e;n++)r[n]=arguments[n];return r.reduce((function(e,r){return Object.keys(r).forEach((function(n){Array.isArray(e[n])&&Array.isArray(r[n])?e[n]=Array.from(new Set(e[n].concat(r[n]))):t.isObject(e[n])&&t.isObject(r[n])?e[n]=t.merge(e[n],r[n]):e[n]=r[n]})),e}),{})},UUID:function(){var t=function(){return Math.floor(65536*(1+Math.random())).toString(16).substring(1)};return t()+t()+"-"+t()+"-"+t()+"-"+t()+"-"+t()+t()+t()},clone:function(e){var r=function(t){var e=t.constructor;switch(n(t)){case"Boolean":case"Number":case"String":case"Error":case"Date":return new e(t);case"RegExp":return o(t);case"Symbol":return i(t);case"Function":return t;default:return null}},n=function(t){return Object.prototype.toString.call(t).slice(8,-1)},i=function(t){return Object(Symbol.prototype.valueOf.call(t))},o=function(t){var e=new t.constructor(t.source,/\w*$/.exec(t));return e.lastIndex=t.lastIndex,e},u=function(t,e){for(var r=-1,n=t.length;++r<n;)e(t[r],r);return t},a=function e(i){var o=arguments.length>1&&void 0!==arguments[1]?arguments[1]:new WeakMap;if("object"!==t(i)||null===i)return i;var a=n(i),s=null;return o.get(i)?o.get(i):(o.set(i,s),"Set"!==a&&"Map"!==a&&"Array"!==a&&"Object"!==a?r(i):"Set"===a?(s=new Set,i.forEach((function(t){s.add(e(t,o))})),s):"Map"===a?(s=new Map,i.forEach((function(t,r){s.set(r,e(t,o))})),s):("Array"===a&&(s=new Array,u(i,(function(t,r){s[r]=e(t,o)}))),"Object"===a&&(s=new Object,u(Object.keys(i),(function(t){s[t]=e(i[t],o)}))),s))};return a(e)},parseQuery:function(t){if(this.isEmpty(t))return"";var e=[];for(var r in t)e.push("".concat(r,"=").concat(t[r]));return e.join("&")},getTimezone:function(t){return 6e4*-t.getTimezoneOffset()},encode:function(t){var e={};for(var r in t)e["_"+r]=t[r];return e},isEqual:function(t,e){if(this.type(t)!==this.type(e))return!1;var r=!0;for(var n in t)t[n]!==e[n]&&(r=!1);return r},getUtmByQuery:function(t){var e={};for(var r in t)this.utmKeys.includes(r)&&(e[r]=t[r]);return e},filterUtm:function(t){var e=["utm_source","utm_medium","utm_campaign","utm_content","utm_term"],r=!1,n={};for(var i in t)e.indexOf(i)>-1&&(r=!0,n[i]=t[i]);return r?n:null},deleteQueryParams:function(t,e){var r=t.split("&"),n=[];return r.forEach((function(t){var r=new RegExp(e+"=.*"),i="";r.test(t)?(i=t.replace(r,""))&&n.push(i):n.push(t)})),n.join("&")},addUrlParam:function(t,e){var r=t,n="";for(var i in e)n&&(n+="&"),r=this.deleteQueryParams(r,i),n+=i+"="+e[i];var o=r.split("?");return o.length>1?o[1]?o[1]=n+"&"+o[1]:o[1]=n:1===o.length&&o.push(n),o.join("?")},getCurrentPage:function(){var t=getCurrentPages();return t[t.length-1]},wxGetTitle:function(t){var e="";t.data&&t.data.title&&t.data.title.length>0&&(e=Array.isArray(t.data.title)?t.data.title.join(" "):t.data.title);try{if(!e.length&&__wxConfig&&(__wxConfig.tabBar&&__wxConfig.tabBar.list.forEach((function(r){r.pagePath==="".concat(t.route,".html")&&r.text&&(e=r.text)})),!e.length)){var r=__wxConfig.page[t.route]||__wxConfig.page["".concat(t.route,".html")];e=r?r.window.navigationBarTitleText:__wxConfig.global.window.navigationBarTitleText}}catch(t){console.error("解析title错误",t)}return e||t.route}},w=function(){function t(r,n){e(this,t),this.timeout=500,this.catch=[],this.clearCatchTimer=null,this.url="".concat(n.config.serverUrl.normal,"/apipool"),this.timeout=n.config.timeout||this.timeout,this.requestTimeout=n.config.requestTimeout,this.debug=n.config.debug?1:0,this.appKey=n.appKey,this.did=n.storage.allData.did,this.sendLimit=n.config.sendLimit,this.requestFunction=r}return n(t,[{key:"generateRequestData",value:function(){var t=new Date,e={method:"web_event_sr.upload",event:JSON.stringify({sln:"itn",pl:"js",sdk:"sys",sdkv:"2.0.4",owner:"zg",ut:"".concat(t.getFullYear(),"-").concat(t.getMonth()+1,"-").concat(t.getDate()," ").concat(t.getHours(),":").concat(t.getMinutes(),":").concat(t.getSeconds()),tz:_.getTimezone(t),debug:this.debug?1:0,ak:this.appKey,usr:{did:this.did},data:l(this.catch)}),_:t.getTime()+""};return this.catch=[],e}},{key:"clear",value:function(){var t=this.generateRequestData();this.requestFunction(this.url,t,{timeout:this.requestTimeout})}},{key:"send",value:function(t){var e=this;if(this.catch.push(t),this.clearCatchTimer&&clearTimeout(this.clearCatchTimer),this.clearCatchTimer=setTimeout((function(){e.clear()}),3e4),!(this.catch.length<this.sendLimit)){this.clearCatchTimer&&clearTimeout(this.clearCatchTimer);var r=this.generateRequestData();return new Promise((function(t,n){var i,o=!1;i=setTimeout((function(){o=!0,t(null)}),e.timeout),e.requestFunction(e.url,r,{timeout:e.requestTimeout}).then((function(e){o||(clearTimeout(i),t(e))})).catch((function(t){n(t)}))}))}}}]),t}(),b=function(){function t(r,n,i){e(this,t),this.storageFunction=r,this.allData=i||{},this.allData.did||this.set("did",n.config.did||_.UUID()),this.allData.cuid||this.set("cuid",void 0),_.isEmpty(n.config.utm)||this.set("utm",n.config.utm)}return n(t,[{key:"get",value:function(t){return this.allData[t]}},{key:"set",value:function(t,e){return d(this,void 0,void 0,regeneratorRuntime.mark((function r(){return regeneratorRuntime.wrap((function(r){for(;;)switch(r.prev=r.next){case 0:return this.allData[t]=e,r.next=3,this.storageFunction.set("zg",this.allData);case 3:case"end":return r.stop()}}),r,this)})))}}]),t}();function x(t,e,r){var n=r.value;return r.value=function(){for(var t=arguments.length,r=new Array(t),i=0;i<t;i++)r[i]=arguments[i];if(this.pageReady&&this.loadReady)return n.apply(this,r);this.buffer.push({fnName:e,args:r})},r}var k=function(){function t(r,n,i){e(this,t),this.buffer=[],this.currentPage={queryObj:{},query:"",route:"",time:0,url:"",title:""},this.prevPage={queryObj:{},query:"",route:"",time:0,url:"",title:""},this.cn="",this.previousCountEvent={name:"",props:{}},this.count=0,this.countTimer=null,this.pageReady=!1,this.loadReady=!1,v=r,g=n,y=i,this.referrerDomain="miniprogram",this.appKey="",this.config={serverUrl:{normal:"https://u.zhugeapi.net",bac:"https://ubak.zhugeio.com"},debug:!1,pv:!1,click:!1,timeout:18e5,requestTimeout:6e4,did:"",duration:!1,vn:"1.0",appId:"",sendLimit:1,superProperty:{},forwardShare:!1,beforeDuration:function(){},afterDuration:function(){},countDuration:3e3,parseScene:!0,utm:{},utmMode:"session",shareToUtm:{},exposure:!1}}return n(t,[{key:"load",value:function(t,e){return d(this,void 0,void 0,regeneratorRuntime.mark((function r(){var n;return regeneratorRuntime.wrap((function(r){for(;;)switch(r.prev=r.next){case 0:return this.appKey=t,this.config=_.merge(this.config,e),r.prev=2,r.next=5,g.get();case 5:if((n=r.sent).did){r.next=10;break}return r.next=9,g.getDid();case 9:n.did=r.sent;case 10:this.storage=new b(g,this,n),this.request=new w(v,this),this.loadReady=!0,this.updateSession("load"),this.freeBuffer(),r.next=20;break;case 17:r.prev=17,r.t0=r.catch(2),console.error("sdk初始化失败,缓存读取失败",r.t0);case 20:case"end":return r.stop()}}),r,this,[[2,17]])})))}},{key:"freeBuffer",value:function(){if(this.loadReady&&this.pageReady)for(;this.buffer.length;){var e=this.buffer.shift();if(e)(t.prototype[e.fnName]||this[e.fnName]).apply(this,e.args)}}},{key:"send",value:function(t){var e=this.storage.allData.utm;if(e)for(var r in e)e[r]&&(t.pr["$".concat(r)]=e[r]);return this.request.send(t)}},{key:"trackBaseData",value:function(t){return d(this,void 0,void 0,regeneratorRuntime.mark((function e(){var r,n;return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return r=new Date,e.t0=t,e.t1=r.getTime(),e.t2=this.storage.allData.sid,e.t3=this.storage.allData.cuid,e.t4=this.cn,e.t5=_.getTimezone(r),e.t6=this.currentPage.url,e.t7=this.prevPage.url,e.t8=y.os(),e.t9=y.ov(),e.t10=y.version(),e.next=14,y.mnet();case 14:return e.t11=e.sent,e.next=17,y.net();case 17:return e.t12=e.sent,e.t13=this.config.vn,e.t14=this.referrerDomain,e.t15=this.config.appId,e.t16={$eid:e.t0,$ct:e.t1,$sid:e.t2,$cuid:e.t3,$cn:e.t4,$tz:e.t5,$url:e.t6,$ref:e.t7,$os:e.t8,$ov:e.t9,$wv:e.t10,$mnet:e.t11,$net:e.t12,$vn:e.t13,$referrer_domain:e.t14,$wxeid:e.t15},(n={dt:"evt",pr:e.t16}).pr=_.merge(n.pr,_.encode(this.config.superProperty)),e.abrupt("return",n);case 25:case"end":return e.stop()}}),e,this)})))}},{key:"environmentInfo",value:function(){var t=new Date,e={dt:"pl",pr:{$rs:"".concat(y.windowWidth(),"x").concat(y.windowHeight()),$tz:_.getTimezone(t),$ct:t.getTime(),$cuid:this.storage.allData.cuid,$sid:this.storage.allData.sid}};this.send(e)}},{key:"sessionEnd",value:function(t){var e=new Date,r=t.update-t.sid,n={dt:"se",pr:{$ct:t.update,$cn:this.cn,$tz:_.getTimezone(e),$dru:r,$sid:t.sid,$cuid:t.cuid,$referrer_domain:this.referrerDomain}};this.send(n)}},{key:"sessionStart",value:function(){return d(this,void 0,void 0,regeneratorRuntime.mark((function t(){var e,r,n,i,o;return regeneratorRuntime.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return e=new Date,r=this.storage.allData,n=r.sid,i=r.cuid,t.t0=n,t.t1=n,t.t2=i,t.t3=this.cn,t.t4=_.getTimezone(e),t.t5=this.currentPage.url,t.t6=this.prevPage.url,t.t7=y.os(),t.t8=y.ov(),t.t9=y.version(),t.next=14,y.mnet();case 14:return t.t10=t.sent,t.next=17,y.net();case 17:t.t11=t.sent,t.t12=this.config.vn,t.t13=this.referrerDomain,t.t14=this.config.appId,t.t15={$ct:t.t0,$sid:t.t1,$cuid:t.t2,$cn:t.t3,$tz:t.t4,$url:t.t5,$ref:t.t6,$os:t.t7,$ov:t.t8,$wv:t.t9,$mnet:t.t10,$net:t.t11,$vn:t.t12,$referrer_domain:t.t13,$wxeid:t.t14},o={dt:"ss",pr:t.t15},this.send(o),this.environmentInfo();case 25:case"end":return t.stop()}}),t,this)})))}},{key:"updateSession",value:function(t){var e=this.storage.allData,r=Date.now();if(e.sid&&e.update)if(r-e.update>this.config.timeout){var n=_.clone(e);this.storage.set("sid",r),this.storage.set("update",r),this.sessionEnd(n),this.sessionStart()}else this.storage.set("update",r);else this.storage.set("sid",r),this.storage.set("update",r),this.sessionStart()}},{key:"click",value:function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{$element_content:"",$element_selector:"",$element_style:[]};return d(this,void 0,void 0,regeneratorRuntime.mark((function t(){var r;return regeneratorRuntime.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(this.config.click){t.next=2;break}return t.abrupt("return");case 2:return this.updateSession("click"),t.next=5,this.trackBaseData("click");case 5:return(r=t.sent).dt="abp",r.pr=_.merge(r.pr,{$page_url:this.currentPage.url,$page_title:this.currentPage.title},e),t.next=10,this.send(r);case 10:case"end":return t.stop()}}),t,this)})))}},{key:"pv",value:function(t){return d(this,void 0,void 0,regeneratorRuntime.mark((function e(){var r,n;return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(this.config.pv){e.next=2;break}return e.abrupt("return");case 2:return this.updateSession("pv"),e.next=5,this.trackBaseData("pv");case 5:return(r=e.sent).dt="abp",n={$page_title:this.currentPage.title},r.pr=_.merge(r.pr,n,t||{}),e.next=11,this.send(r);case 11:case"end":return e.stop()}}),e,this)})))}},{key:"duration",value:function(){return d(this,void 0,void 0,regeneratorRuntime.mark((function t(){var e,r;return regeneratorRuntime.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(this.config.duration){t.next=2;break}return t.abrupt("return");case 2:return this.updateSession("duration"),_.isFunction(this.config.beforeDuration)&&this.config.beforeDuration(),e=this.currentPage.time-this.prevPage.time,t.next=7,this.trackBaseData("dr");case 7:return(r=t.sent).dt="abp",r.pr=_.merge(r.pr,{$dr:e,$url:this.prevPage.url,$title:this.prevPage.title}),t.next=12,this.send(r);case 12:_.isFunction(this.config.afterDuration)&&this.config.afterDuration();case 13:case"end":return t.stop()}}),t,this)})))}},{key:"track",value:function(t,e){return d(this,void 0,void 0,regeneratorRuntime.mark((function r(){var n;return regeneratorRuntime.wrap((function(r){for(;;)switch(r.prev=r.next){case 0:return this.updateSession("track"),r.next=3,this.trackBaseData(t);case 3:return(n=r.sent).pr=_.merge(n.pr,_.encode(e)),r.next=7,this.send(n);case 7:case"end":return r.stop()}}),r,this)})))}},{key:"identify",value:function(t,e){return d(this,void 0,void 0,regeneratorRuntime.mark((function r(){var n,i;return regeneratorRuntime.wrap((function(r){for(;;)switch(r.prev=r.next){case 0:return this.storage.set("cuid",t),this.updateSession("identify"),n=new Date,(i={dt:"usr",pr:{$ct:n.getTime(),$tz:_.getTimezone(n),$cuid:t,$sid:this.storage.allData.sid,$url:this.currentPage.url}}).pr=_.merge(i.pr,_.encode(e)),r.next=7,this.trackBaseData("usr");case 7:return r.next=9,this.send(i);case 9:case"end":return r.stop()}}),r,this)})))}},{key:"trackCount",value:function(t,e){var r=this;0===this.count&&(this.countStartTime=Date.now(),this.previousCountEvent.name=t,this.previousCountEvent.props=_.clone(e)),this.previousCountEvent.name===t&&_.isEqual(this.previousCountEvent.props,e)||(this.sendCountEvent(this.previousCountEvent.name,this.previousCountEvent.props,!1),this.previousCountEvent.name=t,this.previousCountEvent.props=_.clone(e),this.countStartTime=Date.now(),this.count=0),this.count+=1,this.countTimer&&clearTimeout(this.countTimer),this.countTimer=setTimeout((function(){r.sendCountEvent(t,e,!0)}),this.config.countDuration)}},{key:"sendCountEvent",value:function(t,e,r){return d(this,void 0,void 0,regeneratorRuntime.mark((function n(){var i,o,u,a;return regeneratorRuntime.wrap((function(n){for(;;)switch(n.prev=n.next){case 0:return this.updateSession("track count"),i=Date.now()-this.countStartTime,r&&(i-=this.config.countDuration),o=this.count,this.count=r?0:1,n.next=7,this.trackBaseData(t);case 7:return u=n.sent,a={},_.isObject(e)&&(a=_.clone(e)),u.pr=_.merge(u.pr,_.encode(a),_.encode({count:o,countTime:i})),n.next=13,this.send(u);case 13:case"end":return n.stop()}}),n,this)})))}},{key:"trackRevenue",value:function(t){return d(this,void 0,void 0,regeneratorRuntime.mark((function e(){var r,n,i,o,u,a,s,c;return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return i=function(t,e){var r=0;try{t.toString().split(".")[1]&&(r+=t.toString().split(".")[1].length)}catch(t){console.error(t)}try{e.toString().split(".")[1]&&(r+=e.toString().split(".")[1].length)}catch(t){console.error(t)}return Number(t.toString().replace(".",""))*Number(e.toString().replace(".",""))/Math.pow(10,r)},this.updateSession("track revenue"),e.next=4,this.trackBaseData("revenue");case 4:(r=e.sent).dt="abp",(n=_.merge({price:0,total:0,productID:null,productQuantity:0,revenueType:null},t)).total=i(n.price,n.productQuantity),o=["productID","revenueType"],u=["price","total","productQuantity"],a={},e.t0=regeneratorRuntime.keys(n);case 12:if((e.t1=e.t0()).done){e.next=21;break}if(s=e.t1.value,-1!==o.indexOf(s)||-1!==u.indexOf(s)){e.next=16;break}return e.abrupt("continue",12);case 16:c=n[s],u.indexOf(s)>-1&&((c=Number(c))||(c=0)),a["$"+s]=c,e.next=12;break;case 21:return r.pr=_.merge(r.pr,a),e.next=24,this.send(r);case 24:case"end":return e.stop()}}),e,this)})))}},{key:"setUtm",value:function(t){return d(this,void 0,void 0,regeneratorRuntime.mark((function e(){var r;return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:null!==(r=_.filterUtm(t))&&(this.storage.set("utm",r),this.updateSession("setUtm"));case 2:case"end":return e.stop()}}),e,this)})))}},{key:"setSuperProperty",value:function(t){_.isObject(t)&&(this.config.superProperty=t)}},{key:"extendSuperPropertys",value:function(t){_.isObject(t)&&(this.config.superProperty=_.merge(this.config.superProperty,t))}},{key:"removeSuperProperty",value:function(t){var e,r=function(t,e){var r;if("undefined"==typeof Symbol||null==t[Symbol.iterator]){if(Array.isArray(t)||(r=m(t))||e&&t&&"number"==typeof t.length){r&&(t=r);var n=0,i=function(){};return{s:i,n:function(){return n>=t.length?{done:!0}:{done:!1,value:t[n++]}},e:function(t){throw t},f:i}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var o,u=!0,a=!1;return{s:function(){r=t[Symbol.iterator]()},n:function(){var t=r.next();return u=t.done,t},e:function(t){a=!0,o=t},f:function(){try{u||null==r.return||r.return()}finally{if(a)throw o}}}}(t);try{for(r.s();!(e=r.n()).done;){var n=e.value;delete this.config.superProperty[n]}}catch(t){r.e(t)}finally{r.f()}}},{key:"getSuperProperty",value:function(){return this.config.superProperty}},{key:"flush",value:function(){this.request.clear()}}]),t}();p([x],k.prototype,"environmentInfo",null),p([x],k.prototype,"sessionEnd",null),p([x],k.prototype,"sessionStart",null),p([x],k.prototype,"updateSession",null),p([x],k.prototype,"click",null),p([x],k.prototype,"pv",null),p([x],k.prototype,"duration",null),p([x],k.prototype,"track",null),p([x],k.prototype,"identify",null),p([x],k.prototype,"trackCount",null),p([x],k.prototype,"trackRevenue",null),p([x],k.prototype,"setUtm",null);var S=["onLaunch","onShow","onHide","onError","onPageNotFound","onUnhandledRejection","onThemeChange","onShareAppMessage","onLogin"],P=["onLoad","onShow","onReady","onHide","onUnload","onShareAppMessage","onReachBottom","onPageScroll","onPullDownRefresh","onTabItemTap","onInit","onShareTimeline","onAddToFavorites","onResize","onTitleClick","onOptionMenuClick","onPullIntercept","onURLQueryChange"],O=function(t){return _.wxGetTitle(t)},D=function(t,e,r){return new Promise((function(n,o){var u;wx.request((i(u={url:t,data:e,method:"POST",timeout:null==r?void 0:r.timeout},"header",{"content-type":"application/x-www-form-urlencoded"}),i(u,"dataType","json"),i(u,"responseType","arraybuffer"),i(u,"success",(function(t){n(t)})),i(u,"fail",(function(t){o(t)})),u))}))},T={getDid:function(){return new Promise((function(t,e){wx.getStorage({key:"zg-did",success:function(e){t(e.data),wx.removeStorage({key:"zg-did"})},fail:function(e){t("")}})}))},get:function(){return new Promise((function(t,e){wx.getStorage({key:"zg",success:function(e){t(e.data)},fail:function(e){t({})}})}))},set:function(t,e){return new Promise((function(r,n){wx.setStorage({key:t,data:e,success:r,fail:n})}))}},$=!1,j=wx.getSystemInfoSync(),R=j.system.split(/\s/),E={os:R[0],ov:R[1],version:j.version,windowHeight:j.windowHeight,windowWidth:j.windowWidth,net:0,mnet:0};function z(t){var e=t.toLowerCase();"wifi"===e?(E.net=1,E.mnet=0):(E.net=0,E.mnet={"2g":1,"3g":3,"4g":13}[e]||0)}function A(t){return new Promise((function(e,r){if($)return e(E[t]);wx.getNetworkType({success:function(r){$=!0,z(r.networkType),e(E[t])}})}))}wx.onNetworkStatusChange((function(t){z(t.networkType)}));var C,I,L={os:function(){return E.os},ov:function(){return E.ov},version:function(){return E.version},net:function(){return A("net")},mnet:function(){return A("mnet")},windowWidth:function(){return E.windowWidth},windowHeight:function(){return E.windowHeight}},q=App,U=Page,N=Component,F=["eid","ct","tz","cuid","cn","sid","url","os","ov","wv","mnet","referrer_domain","net","vn","wxeid","uid","share_id","share_title","share_level","title","path"];function M(t,e,r){if(t[r]&&_.isFunction(t[r])){var n=t[r];t[r]=function(){n.apply(this,arguments),e[r].apply(this,arguments)}}else t[r]=function(){e[r].apply(this,arguments)}}function B(t,e,r){var n=t[e];t[e]=function(){var t=arguments[0];if(C===t||t&&C&&C.timeStamp===t.timeStamp)return n.apply(this,arguments);if(C=t,t){var e=t.type;"tap"===e&&r.click(t)}return n.apply(this,arguments)}}var K=function(t){o(i,t);var r=c(i);function i(t){var n;return e(this,i),(n=r.call(this,D,T,L)).openData={path:"",props:{}},n.shared=!1,n.semiAutoTrackEventCatch={},n.isShareOperation=!1,I=t,n}return n(i,[{key:"load",value:function(t,e){var r,n=f(u(i.prototype),"load",this).call(this,t,e),o=this,a=(r=o,{App:{onShow:function(t){r.sceneToUtm(t),r.openOptions=t,r.updateSession("appOnShow")},onHide:function(){r.flush(),r.config.duration&&!r.isShareOperation&&(r.pageReady=!0,r.currentPage.time=Date.now(),r.duration().then((function(){r.pageReady=!1,r.prevPage={queryObj:{},query:"",route:"",time:0,url:"",title:""}})))}},Page:{onLoad:function(t){r.currentPage.query=_.parseQuery(t),r.currentPage.queryObj=t},onShow:function(){var t=getCurrentPages(),e=t[t.length-1];r.currentPage.route=e.__route__||e.route,r.currentPage.time=Date.now(),r.currentPage.url="".concat(r.currentPage.route);var n=O;if(r.currentPage.title="function"==typeof n?n(e):"",r.currentPage.query&&(r.currentPage.url+="?".concat(r.currentPage.query)),r.pageReady=!0,r.freeBuffer(),r.currentPage.url!==r.prevPage.url){""!==r.prevPage.url&&r.duration();try{r.trackOpenShare(r.openOptions)}catch(t){console.warn(t,"".concat(r.referrerDomain," ","zhuge"," sdk trackOpenShare error"))}r.pv()}r.startObserveMarkElement(e),r.openOptions=null,r.isShareOperation=!1},onHide:function(){r.semiAutoTrackEventCatch={},r.prevPage=_.clone(r.currentPage),r.pageReady=!1,r.flush()},onUnload:function(){r.semiAutoTrackEventCatch={},r.prevPage=_.clone(r.currentPage),r.pageReady=!1,r.flush()}}});return this.lifecycle=a,App=function(t){for(var e in a.App)M(t,a.App,e);for(var r in t)!S.includes(r)&&_.isFunction(t[r])&&B(t,r,o);return q(t)},Page=function(t){for(var e in a.Page)M(t,a.Page,e);for(var r in t)!P.includes(r)&&_.isFunction(t[r])&&"onShareAppMessage"!==r&&B(t,r,o);var n=t.onShareAppMessage;return _.isFunction(n)&&(t.onShareAppMessage=o.onShareAppMessage(n)),U(t)},Component=function(t){if(void 0!==t.methods)for(var e in t.methods)B(t.methods,e,o);return N(t)},global.mpvue&&(global.App=App,global.Page=Page,global.Component=Component),App.zhuge=o,n}},{key:"pv",value:function(t){var e=this,r=Object.create(null,{pv:{get:function(){return f(u(i.prototype),"pv",e)}}});return d(this,void 0,void 0,regeneratorRuntime.mark((function t(){var e,n;return regeneratorRuntime.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return e={},n=_.getCurrentPage(),this.config.forwardShare&&this.openOptions&&(e.$share_open_type=1008===this.openOptions.scene?"群聊":"聊天",this.openOptions.query&&this.openOptions.query.zg_share_level&&(e.$share_level=Number(this.openOptions.query.zg_share_level)),n.data&&n.data.zg_share_data&&(e=_.merge(e,_.encode(n.data.zg_share_data)))),t.next=5,r.pv.call(this,e);case 5:case"end":return t.stop()}}),t,this)})))}},{key:"click",value:function(t,e){var r=this,n=Object.create(null,{click:{get:function(){return f(u(i.prototype),"click",r)}}});return d(this,void 0,void 0,regeneratorRuntime.mark((function r(){var i,o,u,a;return regeneratorRuntime.wrap((function(r){for(;;)switch(r.prev=r.next){case 0:return i=t.target,o=i.dataset.title,u=i.dataset.index,a=[],a="alipay-miniprogram"===this.referrerDomain?["","",t.detail.pageX,t.detail.pageY]:["","",t.detail.x,t.detail.y],r.next=7,n.click.call(this,t,_.merge({$element_content:o||"",$element_selector:u||"",$element_style:a},e||{}));case 7:case"end":return r.stop()}}),r,this)})))}},{key:"sceneToUtm",value:function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},e=_.getUtmByQuery(t.query);if(this.config.parseScene&&t.scene&&I){var r=t.scene;this.cn=r+"";var n=I[r],i={},o=null,u=I.isShare(r);if(u&&t.referrerInfo&&(o=t.referrerInfo.appId),n){i={utm_source:n.utm_source,utm_medium:n.utm_medium,utm_campaign:o};var a=t.query||{};I.isCartShare(r)&&a.zg_uid&&a.zg_share_id&&(i.utm_term=a.zg_uid,i.utm_content=a.zg_share_id)}e=_.merge(i,e)}"fresh"===this.config.utmMode&&_.isEmpty(this.config.utm)&&this.storage.set("utm",e)}},{key:"trackOpenShare",value:function(t){return d(this,void 0,void 0,regeneratorRuntime.mark((function e(){var r,n,i,o,u,a,s,c,f,l,m;return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(t&&this.config.forwardShare){e.next=2;break}return e.abrupt("return");case 2:if(!this.shared){e.next=5;break}return this.shared=!1,e.abrupt("return");case 5:if(r=t.query||{},n=this.currentPage.route,!(I.isCartShare(t.scene)&&r.zg_uid&&r.zg_share_id)){e.next=24;break}for(u in i={$uid:r.zg_uid,$share_id:r.zg_share_id,$title:this.currentPage.title,$path:n,$share_open_type:1008===t.scene?"群聊":"聊天",$share_level:Number(r.zg_share_level)},this.shareId=r.zg_share_id,this.shareLevel=Number(r.zg_share_level),o={},r)a=u.replace(/^zg_/,""),-1===F.indexOf(a)&&/^zg_/.test(u)&&(o[a]=r[u]);if(s=this.config.shareToUtm,_.isObject(s)&&!_.isEmpty(s)){for(f in c={},s)null!==o[f]&&void 0!==o[f]&&(l=s[f],c[l]=o[f]);_.isEmpty(_)||(c.utm_campaign||(c.utm_campaign="分享打开"),this.setUtm(c))}return this.openData={path:n,props:o},i=_.merge(i,_.encode(o)),e.next=19,this.trackBaseData("wxsopen");case 19:return(m=e.sent).dt="abp",m.pr=_.merge(m.pr,i),e.next=24,this.request.send(m);case 24:case"end":return e.stop()}}),e,this)})))}},{key:"onShareAppMessage",value:function(t){var e=this;return function(){e.isShareOperation=!0;var r=t.apply(this,arguments)||{};if(!e.config.forwardShare)return r;r.path=r.path||e.currentPage.url;var n=r.title||e.currentPage.title,i=r.path.split("?")[0],o=this.data.zg_share_data,u=(new Date).getTime(),a=1;!this.data.newShare&&e.openData&&e.openData.path===i&&_.isEqual(o||{},e.openData.props)&&(u=e.shareId,a=e.shareLevel+1);var s={share_id:u,uid:e.storage.allData.cuid||e.storage.allData.did,share_level:a},c={$share_title:n,$title:e.currentPage.title||"",$path:i},f={};for(var l in s)c["$".concat(l)]=f["zg_".concat(l)]=s[l];for(var m in o)-1===F.indexOf(m)&&(c["_".concat(m)]=f["zg_".concat(m)]=o[m]);return r.path=_.addUrlParam(r.path,f),e.trackBaseData("wxshare").then((function(t){t.dt="abp",t.pr=_.merge(t.pr,c),e.request.send(t)})),e.shared=!0,r}}},{key:"startObserveMarkElement",value:function(t){var e=this;this.config.exposure&&(this.elementObserver&&this.elementObserver.disconnect(),t.isComponent?this.elementObserver=t.createIntersectionObserver({observeAll:!0}):this.elementObserver=wx.createIntersectionObserver(t,{observeAll:!0}),this.elementObserver.relativeToViewport().observe(".zhuge-expo-track",(function(t){if(t.intersectionRatio>0){var r,n=e.getEventDataFromDataset(t.dataset);(r=f(u(i.prototype),"track",e)).call.apply(r,[e].concat(l(n)))}})))}},{key:"getEventDataFromDataset",value:function(t){var e={},r="";for(var n in t){if(n.startsWith("expo"))if("expoName"===n)r=t[n];else e[n.replace(/^expo(.*)/,(function(t,e,r,n){return e.replace(e[0],e[0].toLocaleLowerCase())}))]=t[n]}return[r,e]}}]),i}(k);p([x],K.prototype,"sceneToUtm",null),p([x],K.prototype,"trackOpenShare",null);var G={1001:{utm_source:"微信主程序",utm_medium:"发现栏小程序主入口"},1005:{utm_source:"搜索",utm_medium:"顶部搜索框的搜索结果页"},1006:{utm_source:"搜索",utm_medium:"发现栏小程序主入口搜索框的搜索结果页"},1007:{utm_source:"分享",utm_medium:"单人聊天会话中的小程序消息卡片"},1008:{utm_source:"分享",utm_medium:"群聊会话中的小程序消息卡片"},1011:{utm_source:"扫码",utm_medium:"扫描二维码"},1012:{utm_source:"扫码",utm_medium:"长按图片识别二维码"},1013:{utm_source:"扫码",utm_medium:"手机相册选取二维码"},1014:{utm_source:"小程序模板消息",utm_medium:"小程序模板消息"},1017:{utm_source:"体验版",utm_medium:"前往体验版的入口页"},1019:{utm_source:"微信支付",utm_medium:"微信钱包"},1020:{utm_source:"公众号",utm_medium:"公众号profile页相关小程序列表"},1022:{utm_source:"微信主程序",utm_medium:"聊天顶部置顶小程序入口"},1023:{utm_source:"桌面图标",utm_medium:"安卓系统桌面图标"},1024:{utm_source:"微信主程序",utm_medium:"小程序 profile 页"},1025:{utm_source:"扫码",utm_medium:"扫描一维码"},1026:{utm_source:"微信主程序",utm_medium:"附近小程序列表"},1027:{utm_source:"搜索",utm_medium:"顶部搜索框搜索结果页“使用过的小程序”列表"},1028:{utm_source:"微信卡券",utm_medium:"我的卡包"},1029:{utm_source:"微信卡券",utm_medium:"卡券详情页"},1030:{utm_source:"测试",utm_medium:"自动化测试下打开小程序"},1031:{utm_source:"扫码",utm_medium:"长按图片识别一维码"},1032:{utm_source:"扫码",utm_medium:"手机相册选取一维码"},1034:{utm_source:"微信支付",utm_medium:"微信支付完成页"},1035:{utm_source:"公众号",utm_medium:"公众号自定义菜单"},1036:{utm_source:"分享",utm_medium:"App分享消息卡片"},1037:{utm_source:"小程序",utm_medium:"小程序打开小程序"},1038:{utm_source:"小程序",utm_medium:"从另一个小程序返回"},1039:{utm_source:"摇电视",utm_medium:"摇电视"},1042:{utm_source:"搜索",utm_medium:"添加好友搜索框的搜索结果页"},1043:{utm_source:"公众号",utm_medium:"公众号模板消息"},1044:{utm_source:"分享",utm_medium:"带shareTicket的小程序消息卡片(详情)"},1045:{utm_source:"广告",utm_medium:"朋友圈广告"},1046:{utm_source:"广告",utm_medium:"朋友圈广告详情页"},1047:{utm_source:"扫码",utm_medium:"扫描小程序码"},1048:{utm_source:"扫码",utm_medium:"长按图片识别小程序码"},1049:{utm_source:"扫码",utm_medium:"手机相册选取小程序码"},1052:{utm_source:"微信卡券",utm_medium:"卡券的适用门店列表"},1053:{utm_source:"搜索",utm_medium:"搜一搜的结果页"},1054:{utm_source:"搜索",utm_medium:"顶部搜索框小程序快捷入口"},1056:{utm_source:"音乐播放器菜单",utm_medium:"音乐播放器菜单"},1057:{utm_source:"微信支付",utm_medium:"钱包中的银行卡详情页"},1058:{utm_source:"公众号",utm_medium:"公众号文章"},1059:{utm_source:"体验版",utm_medium:"体验版小程序绑定邀请页"},1064:{utm_source:"微信WIFI",utm_medium:"微信连Wi-Fi状态栏"},1067:{utm_source:"广告",utm_medium:"公众号文章广告"},1068:{utm_source:"广告",utm_medium:"附近小程序列表广告"},1069:{utm_source:"移动应用",utm_medium:"移动应用"},1071:{utm_source:"微信支付",utm_medium:"钱包中的银行卡列表页"},1072:{utm_source:"微信支付",utm_medium:"二维码收款页面"},1073:{utm_source:"客服消息",utm_medium:"客服消息列表下发的小程序消息卡片"},1074:{utm_source:"公众号会话",utm_medium:"公众号会话下发的小程序消息卡片"},1077:{utm_source:"摇周边",utm_medium:"摇周边"},1078:{utm_source:"微信WIFI",utm_medium:"连Wi-Fi成功页"},1079:{utm_source:"微信游戏中心",utm_medium:"微信游戏中心"},1081:{utm_source:"客服消息",utm_medium:"客服消息下发的文字链"},1082:{utm_source:"公众号",utm_medium:"公众号会话下发的文字链"},1084:{utm_source:"广告",utm_medium:"朋友圈广告原生页"},1089:{utm_source:"微信主程序",utm_medium:"微信聊天主界面下拉"},1090:{utm_source:"小程序",utm_medium:"长按小程序右上角菜单唤出最近使用历史"},1091:{utm_source:"公众号",utm_medium:"公众号文章商品卡片"},1092:{utm_source:"微信城市服务",utm_medium:"城市服务入口"},1095:{utm_source:"广告",utm_medium:"小程序广告组件"},1096:{utm_source:"分享",utm_medium:"聊天记录"},1097:{utm_source:"微信支付",utm_medium:"微信支付签约页"},1099:{utm_source:"小程序",utm_medium:"页面内嵌插件"},1102:{utm_source:"公众号",utm_medium:"公众号profile页服务预览"},1129:{utm_source:"爬虫",utm_medium:"微信爬虫"},isShare:function(t){return[1020,1035,1036,1037,1038,1043].includes(t)},isCartShare:function(t){return[1044,1007,1008,1036].includes(t)}},W=new(function(t){o(i,t);var r=c(i);function i(){return e(this,i),r.call(this,G)}return n(i,[{key:"load",value:function(t,e){var r=e||{};if(wx.getAccountInfoSync){var n=wx.getAccountInfoSync();n&&n.miniProgram&&n.miniProgram.appId&&(r.appId=n.miniProgram.appId)}return f(u(i.prototype),"load",this).call(this,t,r)}},{key:"weixinIdentify",value:function(){var t=this,e=this.config.appId;arguments[0]&&"string"==typeof arguments[0]&&(e=arguments[0]);var r,n=this.config.serverUrl.normal,i="",o="",u="",a="",s="",c="";function f(t,e,r){if(!(r&&t.length<=r)){var n=r||0;t[n].call(e,(function(){f(t,e,n+1)}))}}function l(t){wx.login({success:function(e){i=e.code,t&&t()},fail:function(t){console.error("诸葛SDK提示:","登录失败",t)}})}var m=function(r){var s=t,c={url:n+"/zgwx/user/code2session",method:"GET",data:{code:i,appId:e},success:function(t){o=t.data.openid,u=t.data.unionid,a=t.data.session_key,r&&r()},fail:function(t){n!==s.config.serverUrl.bac?(c.url=s.config.serverUrl.bac+"/zgwx/user/code2session",wx.request(c)):console.error("诸葛SDK提示:","获取codeSession失败",t)}};wx.request(c)};function h(t){wx.getSetting({success:function(e){e.authSetting["scope.userInfo"]?wx.getUserInfo({lang:"zh_CN",success:function(e){r=e.userInfo,s=e.iv,c=e.encryptedData,t&&t()}}):console.error("诸葛SDK提示:","未授权",e)}})}function p(t){wx.getUserProfile?wx.getUserProfile({desc:arguments[0]||"用于完善会员资料",lang:"zh_CN",success:function(e){r=e.userInfo,t&&t()},fail:function(e){console.error("userProfile错误",e),t&&t()}}):t&&t()}var d=function(e){var r=t,i={url:n+"/zgwx/data/decrypt",method:"POST",data:{sessionKey:a,iv:s,encryptData:c},success:function(t){u=t.data.unionId,e&&e(t.data||{})},fail:function(t){n!==r.config.serverUrl.bac?(i.url=r.config.serverUrl.bac+"/zgwx/data/decrypt",wx.request(i)):console.error("诸葛SDK提示:","获取codeSession失败",t)}};wx.request(i)},g=function(e){var n="";switch(r.gender){case 1:n="男";break;case 2:n="女"}t.identify(u||o,{name:r.nickName,avatar:r.avatarUrl,"微信-昵称":r.nickName,"微信-性别":n,"微信-城市":r.city,"微信-省":r.province,"微信-国家":r.country}),e&&e()},v=[p,l,h,m,d,g],y=Array.prototype.pop.call(arguments);"function"==typeof y&&v.push((function(){y({userInfo:r,unionid:u,openid:o,sessionKey:a})})),f(v,this)}}]),i}(K));return App.zhuge=W,W}));
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "zg-sdk-wechart",
|
|
3
|
-
"version": "2.0.
|
|
3
|
+
"version": "2.0.4",
|
|
4
4
|
"description": "诸葛智能微信小程序sdk",
|
|
5
5
|
"main": "./dist/zhuge.min.js",
|
|
6
6
|
"module": "./dist/zhuge.es.min.js",
|
|
@@ -13,5 +13,5 @@
|
|
|
13
13
|
"keywords": [],
|
|
14
14
|
"author": "",
|
|
15
15
|
"license": "ISC",
|
|
16
|
-
"gitHead": "
|
|
16
|
+
"gitHead": "948c8e8681c3ad6f81cd8e7f758b0044138a2ec4"
|
|
17
17
|
}
|