text: var _={},sa={para:{name:"sensors",server_url:"",send_timeout:1e3,use_client_time:!1,show_log:!0,allow_amend_share_path:!0,max_string_length:300,datasend_timeout:3e3,source_channel:[],autoTrack:{appLaunch:!0,appShow:!0,appHide:!0,pageShow:!0,pageShare:!0},is_persistent_save:!1}},logger="object"==typeof logger?logger:{};logger.info=function(){if(sa.para.show_log&&"object"==typeof console&&console.log)try{return console.log.apply(console,arguments)}catch(t){console.log(arguments[0])}},sa.setPara=function(t){sa.para=_.extend2Lev(sa.para,t);var e=[];if(_.isArray(sa.para.source_channel))for(var r=sa.para.source_channel.length,a=0;a<r;a++)-1===" utm_source utm_medium utm_campaign utm_content utm_term sa_utm ".indexOf(" "+sa.para.source_channel[a]+" ")&&e.push(sa.para.source_channel[a]);sa.para.source_channel=e,_.isObject(sa.para.register)&&_.extend(_.info.properties,sa.para.register),sa.para.openid_url||(sa.para.openid_url=sa.para.server_url.replace(/([^\/])\/(sa)(\.gif){0,1}/,"$1/mp_login")),"number"!=typeof sa.para.send_timeout&&(sa.para.send_timeout=1e3);var s={send_timeout:6e3,max_length:6};!0===sa.para.batch_send?(sa.para.batch_send=_.extend({},s),sa.para.use_client_time=!0):"object"==typeof sa.para.batch_send&&(sa.para.use_client_time=!0,sa.para.batch_send=_.extend({},s,sa.para.batch_send)),sa.para.server_url||logger.info("\u8bf7\u4f7f\u7528 setPara() \u65b9\u6cd5\u8bbe\u7f6e server_url \u6570\u636e\u63a5\u6536\u5730\u5740,\u8be6\u60c5\u53ef\u67e5\u770bhttps://www.sensorsdata.cn/manual/mp_sdk_new.html#112-%E5%BC%95%E5%85%A5%E5%B9%B6%E9%85%8D%E7%BD%AE%E5%8F%82%E6%95%B0")},sa.status={};var ArrayProto=Array.prototype,FuncProto=Function.prototype,ObjProto=Object.prototype,slice=ArrayProto.slice,toString=ObjProto.toString,hasOwnProperty=ObjProto.hasOwnProperty,LIB_VERSION="1.13.14",LIB_NAME="MiniProgram",source_channel_standard="utm_source utm_medium utm_campaign utm_content utm_term",latest_source_channel=["$latest_utm_source","$latest_utm_medium","$latest_utm_campaign","$latest_utm_content","$latest_utm_term","latest_sa_utm"],mp_scene={1001:"\u53d1\u73b0\u680f\u5c0f\u7a0b\u5e8f\u4e3b\u5165\u53e3\uff0c“\u6700\u8fd1\u4f7f\u7528”\u5217\u8868",1005:"\u9876\u90e8\u641c\u7d22\u6846\u7684\u641c\u7d22\u7ed3\u679c\u9875",1006:"\u53d1\u73b0\u680f\u5c0f\u7a0b\u5e8f\u4e3b\u5165\u53e3\u641c\u7d22\u6846\u7684\u641c\u7d22\u7ed3\u679c\u9875",1007:"\u5355\u4eba\u804a\u5929\u4f1a\u8bdd\u4e2d\u7684\u5c0f\u7a0b\u5e8f\u6d88\u606f\u5361\u7247",1008:"\u7fa4\u804a\u4f1a\u8bdd\u4e2d\u7684\u5c0f\u7a0b\u5e8f\u6d88\u606f\u5361\u7247",1011:"\u626b\u63cf\u4e8c\u7ef4\u7801",1012:"\u957f\u6309\u56fe\u7247\u8bc6\u522b\u4e8c\u7ef4\u7801",1013:"\u624b\u673a\u76f8\u518c\u9009\u53d6\u4e8c\u7ef4\u7801",1014:"\u5c0f\u7a0b\u5e8f\u6a21\u7248\u6d88\u606f",1017:"\u524d\u5f80\u4f53\u9a8c\u7248\u7684\u5165\u53e3\u9875",1019:"\u5fae\u4fe1\u94b1\u5305",1020:"\u516c\u4f17\u53f7 profile \u9875\u76f8\u5173\u5c0f\u7a0b\u5e8f\u5217\u8868",1022:"\u804a\u5929\u9876\u90e8\u7f6e\u9876\u5c0f\u7a0b\u5e8f\u5165\u53e3",1023:"\u5b89\u5353\u7cfb\u7edf\u684c\u9762\u56fe\u6807",1024:"\u5c0f\u7a0b\u5e8f profile \u9875",1025:"\u626b\u63cf\u4e00\u7ef4\u7801",1026:"\u9644\u8fd1\u5c0f\u7a0b\u5e8f\u5217\u8868",1027:"\u9876\u90e8\u641c\u7d22\u6846\u641c\u7d22\u7ed3\u679c\u9875“\u4f7f\u7528\u8fc7\u7684\u5c0f\u7a0b\u5e8f”\u5217\u8868",1028:"\u6211\u7684\u5361\u5305",1029:"\u5361\u5238\u8be6\u60c5\u9875",1030:"\u81ea\u52a8\u5316\u6d4b\u8bd5\u4e0b\u6253\u5f00\u5c0f\u7a0b\u5e8f",1031:"\u957f\u6309\u56fe\u7247\u8bc6\u522b\u4e00\u7ef4\u7801",1032:"\u624b\u673a\u76f8\u518c\u9009\u53d6\u4e00\u7ef4\u7801",1034:"\u5fae\u4fe1\u652f\u4ed8\u5b8c\u6210\u9875",1035:"\u516c\u4f17\u53f7\u81ea\u5b9a\u4e49\u83dc\u5355",1036:"App \u5206\u4eab\u6d88\u606f\u5361\u7247",1037:"\u5c0f\u7a0b\u5e8f\u6253\u5f00\u5c0f\u7a0b\u5e8f",1038:"\u4ece\u53e6\u4e00\u4e2a\u5c0f\u7a0b\u5e8f\u8fd4\u56de",1039:"\u6447\u7535\u89c6",1042:"\u6dfb\u52a0\u597d\u53cb\u641c\u7d22\u6846\u7684\u641c\u7d22\u7ed3\u679c\u9875",1043:"\u516c\u4f17\u53f7\u6a21\u677f\u6d88\u606f",1044:"\u5e26 shareTicket \u7684\u5c0f\u7a0b\u5e8f\u6d88\u606f\u5361\u7247\uff08\u8be6\u60c5)",1045:"\u670b\u53cb\u5708\u5e7f\u544a",1046:"\u670b\u53cb\u5708\u5e7f\u544a\u8be6\u60c5\u9875",1047:"\u626b\u63cf\u5c0f\u7a0b\u5e8f\u7801",1048:"\u957f\u6309\u56fe\u7247\u8bc6\u522b\u5c0f\u7a0b\u5e8f\u7801",1049:"\u624b\u673a\u76f8\u518c\u9009\u53d6\u5c0f\u7a0b\u5e8f\u7801",1052:"\u5361\u5238\u7684\u9002\u7528\u95e8\u5e97\u5217\u8868",1053:"\u641c\u4e00\u641c\u7684\u7ed3\u679c\u9875",1054:"\u9876\u90e8\u641c\u7d22\u6846\u5c0f\u7a0b\u5e8f\u5feb\u6377\u5165\u53e3",1056:"\u97f3\u4e50\u64ad\u653e\u5668\u83dc\u5355",1057:"\u94b1\u5305\u4e2d\u7684\u94f6\u884c\u5361\u8be6\u60c5\u9875",1058:"\u516c\u4f17\u53f7\u6587\u7ae0",1059:"\u4f53\u9a8c\u7248\u5c0f\u7a0b\u5e8f\u7ed1\u5b9a\u9080\u8bf7\u9875",1064:"\u5fae\u4fe1\u8fdeWi-Fi\u72b6\u6001\u680f",1067:"\u516c\u4f17\u53f7\u6587\u7ae0\u5e7f\u544a",1068:"\u9644\u8fd1\u5c0f\u7a0b\u5e8f\u5217\u8868\u5e7f\u544a",1069:"\u79fb\u52a8\u5e94\u7528",1071:"\u94b1\u5305\u4e2d\u7684\u94f6\u884c\u5361\u5217\u8868\u9875",1072:"\u4e8c\u7ef4\u7801\u6536\u6b3e\u9875\u9762",1073:"\u5ba2\u670d\u6d88\u606f\u5217\u8868\u4e0b\u53d1\u7684\u5c0f\u7a0b\u5e8f\u6d88\u606f\u5361\u7247",1074:"\u516c\u4f17\u53f7\u4f1a\u8bdd\u4e0b\u53d1\u7684\u5c0f\u7a0b\u5e8f\u6d88\u606f\u5361\u7247",1077:"\u6447\u5468\u8fb9",1078:"\u8fdeWi-Fi\u6210\u529f\u9875",1079:"\u5fae\u4fe1\u6e38\u620f\u4e2d\u5fc3",1081:"\u5ba2\u670d\u6d88\u606f\u4e0b\u53d1\u7684\u6587\u5b57\u94fe",1082:"\u516c\u4f17\u53f7\u4f1a\u8bdd\u4e0b\u53d1\u7684\u6587\u5b57\u94fe",1084:"\u670b\u53cb\u5708\u5e7f\u544a\u539f\u751f\u9875",1089:"\u5fae\u4fe1\u804a\u5929\u4e3b\u754c\u9762\u4e0b\u62c9",1090:"\u957f\u6309\u5c0f\u7a0b\u5e8f\u53f3\u4e0a\u89d2\u83dc\u5355\u5524\u51fa\u6700\u8fd1\u4f7f\u7528\u5386\u53f2",1091:"\u516c\u4f17\u53f7\u6587\u7ae0\u5546\u54c1\u5361\u7247",1092:"\u57ce\u5e02\u670d\u52a1\u5165\u53e3",1095:"\u5c0f\u7a0b\u5e8f\u5e7f\u544a\u7ec4\u4ef6",1096:"\u804a\u5929\u8bb0\u5f55",1097:"\u5fae\u4fe1\u652f\u4ed8\u7b7e\u7ea6\u9875",1099:"\u9875\u9762\u5185\u5d4c\u63d2\u4ef6",1102:"\u516c\u4f17\u53f7 profile \u9875\u670d\u52a1\u9884\u89c8",1103:"\u53d1\u73b0\u680f\u5c0f\u7a0b\u5e8f\u4e3b\u5165\u53e3\uff0c“\u6211\u7684\u5c0f\u7a0b\u5e8f”\u5217\u8868",1104:"\u5fae\u4fe1\u804a\u5929\u4e3b\u754c\u9762\u4e0b\u62c9\uff0c“\u6211\u7684\u5c0f\u7a0b\u5e8f”\u680f",1106:"\u804a\u5929\u4e3b\u754c\u9762\u4e0b\u62c9\uff0c\u4ece\u9876\u90e8\u641c\u7d22\u7ed3\u679c\u9875\uff0c\u6253\u5f00\u5c0f\u7a0b\u5e8f",1124:"\u626b“\u4e00\u7269\u4e00\u7801”\u6253\u5f00\u5c0f\u7a0b\u5e8f",1125:"\u957f\u6309\u56fe\u7247\u8bc6\u522b“\u4e00\u7269\u4e00\u7801”",1126:"\u626b\u63cf\u624b\u673a\u76f8\u518c\u4e2d\u9009\u53d6\u7684“\u4e00\u7269\u4e00\u7801”",1129:"\u5fae\u4fe1\u722c\u866b\u8bbf\u95ee",1131:"\u6d6e\u7a97\u6253\u5f00\u5c0f\u7a0b\u5e8f"},sa_referrer="\u76f4\u63a5\u6253\u5f00";sa.status.referrer="\u76f4\u63a5\u6253\u5f00";var mpshow_time=null,share_depth=0,share_distinct_id="",is_first_launch=!1;function mp_proxy(t,e,r){var a=sa.autoTrackCustom[r];if(t[e]){var s=t[e];t[e]=function(){"onLaunch"===e&&(this[sa.para.name]=sa),!sa.para.autoTrackIsFirst||_.isObject(sa.para.autoTrackIsFirst)&&!sa.para.autoTrackIsFirst[r]?(s.apply(this,arguments),a.apply(this,arguments)):(!0===sa.para.autoTrackIsFirst||_.isObject(sa.para.autoTrackIsFirst)&&sa.para.autoTrackIsFirst[r])&&(a.apply(this,arguments),s.apply(this,arguments))}}else t[e]=function(){"onLaunch"===e&&(this[sa.para.name]=sa),a.apply(this,arguments)}}sa.lib_version=LIB_VERSION,function(){FuncProto.bind;var t=ArrayProto.forEach,e=ArrayProto.indexOf,r=Array.isArray,a={},s=_.each=function(e,r,s){if(null==e)return!1;if(t&&e.forEach===t)e.forEach(r,s);else if(e.length===+e.length){for(var n=0,i=e.length;n<i;n++)if(n in e&&r.call(s,e[n],n,e)===a)return!1}else for(var o in e)if(hasOwnProperty.call(e,o)&&r.call(s,e[o],o,e)===a)return!1};_.logger=logger,_.extend=function(t){return s(slice.call(arguments,1),function(e){for(var r in e)void 0!==e[r]&&(t[r]=e[r])}),t},_.extend2Lev=function(t){return s(slice.call(arguments,1),function(e){for(var r in e)void 0!==e[r]&&(_.isObject(e[r])&&_.isObject(t[r])?_.extend(t[r],e[r]):t[r]=e[r])}),t},_.coverExtend=function(t){return s(slice.call(arguments,1),function(e){for(var r in e)void 0!==e[r]&&void 0===t[r]&&(t[r]=e[r])}),t},_.isArray=r||function(t){return"[object Array]"===toString.call(t)},_.isFunction=function(t){try{return/^\s*\bfunction\b/.test(t)}catch(t){return!1}},_.isArguments=function(t){return!(!t||!hasOwnProperty.call(t,"callee"))},_.toArray=function(t){return t?t.toArray?t.toArray():_.isArray(t)?slice.call(t):_.isArguments(t)?slice.call(t):_.values(t):[]},_.values=function(t){var e=[];return null==t?e:(s(t,function(t){e[e.length]=t}),e)},_.include=function(t,r){var n=!1;return null==t?n:e&&t.indexOf===e?-1!=t.indexOf(r):(s(t,function(t){if(n||(n=t===r))return a}),n)}}(),_.trim=function(t){return t.replace(/^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g,"")},_.isObject=function(t){return null!=t&&"[object Object]"==toString.call(t)},_.isEmptyObject=function(t){if(_.isObject(t)){for(var e in t)if(hasOwnProperty.call(t,e))return!1;return!0}return!1},_.isUndefined=function(t){return void 0===t},_.isString=function(t){return"[object String]"==toString.call(t)},_.isDate=function(t){return"[object Date]"==toString.call(t)},_.isBoolean=function(t){return"[object Boolean]"==toString.call(t)},_.isNumber=function(t){return"[object Number]"==toString.call(t)&&/[\d\.]+/.test(String(t))},_.isJSONString=function(t){try{JSON.parse(t)}catch(t){return!1}return!0},_.decodeURIComponent=function(t){var e="";try{e=decodeURIComponent(t)}catch(r){e=t}return e},_.encodeDates=function(t){return _.each(t,function(e,r){_.isDate(e)?t[r]=_.formatDate(e):_.isObject(e)&&(t[r]=_.encodeDates(e))}),t},_.formatDate=function(t){function e(t){return t<10?"0"+t:t}return t.getFullYear()+"-"+e(t.getMonth()+1)+"-"+e(t.getDate())+" "+e(t.getHours())+":"+e(t.getMinutes())+":"+e(t.getSeconds())+"."+e(t.getMilliseconds())},_.searchObjDate=function(t){_.isObject(t)&&_.each(t,function(e,r){_.isObject(e)?_.searchObjDate(t[r]):_.isDate(e)&&(t[r]=_.formatDate(e))})},_.formatString=function(t){return t.length>sa.para.max_string_length?(logger.info("\u5b57\u7b26\u4e32\u957f\u5ea6\u8d85\u8fc7\u9650\u5236\uff0c\u5df2\u7ecf\u505a\u622a\u53d6--"+t),t.slice(0,sa.para.max_string_length)):t},_.searchObjString=function(t){_.isObject(t)&&_.each(t,function(e,r){_.isObject(e)?_.searchObjString(t[r]):_.isString(e)&&(t[r]=_.formatString(e))})},_.unique=function(t){for(var e,r=[],a={},s=0;s<t.length;s++)(e=t[s])in a||(a[e]=!0,r.push(e));return r},_.strip_sa_properties=function(t){return _.isObject(t)?(_.each(t,function(e,r){if(_.isArray(e)){var a=[];_.each(e,function(t){_.isString(t)?a.push(t):logger.info("\u60a8\u7684\u6570\u636e-",e,"\u7684\u6570\u7ec4\u91cc\u7684\u503c\u5fc5\u987b\u662f\u5b57\u7b26\u4e32,\u5df2\u7ecf\u5c06\u5176\u5220\u9664")}),0!==a.length?t[r]=a:(delete t[r],logger.info("\u5df2\u7ecf\u5220\u9664\u7a7a\u7684\u6570\u7ec4"))}_.isString(e)||_.isNumber(e)||_.isDate(e)||_.isBoolean(e)||_.isArray(e)||(logger.info("\u60a8\u7684\u6570\u636e-",e,"-\u683c\u5f0f\u4e0d\u6ee1\u8db3\u8981\u6c42\uff0c\u6211\u4eec\u5df2\u7ecf\u5c06\u5176\u5220\u9664"),delete t[r])}),t):t},_.strip_empty_properties=function(t){var e={};return _.each(t,function(t,r){null!=t&&(e[r]=t)}),e},_.utf8Encode=function(t){var e,r,a,s,n="";for(e=r=0,a=(t=(t+"").replace(/\r\n/g,"\n").replace(/\r/g,"\n")).length,s=0;s<a;s++){var i=t.charCodeAt(s),o=null;i<128?r++:o=i>127&&i<2048?String.fromCharCode(i>>6|192,63&i|128):String.fromCharCode(i>>12|224,i>>6&63|128,63&i|128),null!==o&&(r>e&&(n+=t.substring(e,r)),n+=o,e=r=s+1)}return r>e&&(n+=t.substring(e,t.length)),n},_.base64Encode=function(t){var e,r,a,s,n,i="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",o=0,c=0,u="",p=[];if(!t)return t;t=_.utf8Encode(t);do{e=(n=t.charCodeAt(o++)<<16|t.charCodeAt(o++)<<8|t.charCodeAt(o++))>>18&63,r=n>>12&63,a=n>>6&63,s=63&n,p[c++]=i.charAt(e)+i.charAt(r)+i.charAt(a)+i.charAt(s)}while(o<t.length);switch(u=p.join(""),t.length%3){case 1:u=u.slice(0,-2)+"==";break;case 2:u=u.slice(0,-1)+"="}return u},_.getCurrentPath=function(){var t="\u672a\u53d6\u5230";try{var e=getCurrentPages();t=e[e.length-1].route}catch(t){logger.info(t)}return t},_.getCurrentUrl=function(t){var e=_.getCurrentPath(),r="";return _.isObject(t)&&t.sensors_mp_encode_url_query&&(r=t.sensors_mp_encode_url_query),e?r?e+"?"+r:e:"\u672a\u53d6\u5230"},_.getPath=function(t){return t="string"==typeof t?t.replace(/^\//,""):"\u53d6\u503c\u5f02\u5e38"},sa.initialState={queue:[],isComplete:!1,systemIsComplete:!1,storeIsComplete:!1,checkIsComplete:function(){this.systemIsComplete&&this.storeIsComplete&&(this.isComplete=!0,this.queue.length>0&&(_.each(this.queue,function(t){sa[t[0]].apply(sa,slice.call(t[1]))}),this.queue=[]))}},_.getCustomUtmFromQuery=function(t,e,r,a){if(!_.isObject(t))return{};var s={};if(t.sa_utm)for(var n in t)"sa_utm"!==n?_.include(sa.para.source_channel,n)&&(s[r+n]=t[n]):s[a+n]=t[n];else for(var n in t)-1===(" "+source_channel_standard+" ").indexOf(" "+n+" ")?_.include(sa.para.source_channel,n)&&(s[r+n]=t[n]):s[e+n]=t[n];return s},_.getObjFromQuery=function(t){var e=t.split("?"),r={};return e&&e[1]?(_.each(e[1].split("&"),function(t){var e=t.split("=");e[0]&&e[1]&&(r[e[0]]=e[1])}),r):{}},_.setStorageSync=function(t,e){var r=function(){wx.setStorageSync(t,e)};try{r()}catch(t){logger.info("set Storage fail --",t);try{r()}catch(t){logger.info("set Storage fail again --",t)}}},_.getStorageSync=function(t){var e="";try{e=wx.getStorageSync(t)}catch(r){try{e=wx.getStorageSync(t)}catch(t){logger.info("getStorage fail")}}return e},_.getMPScene=function(t){return"number"==typeof t||"string"==typeof t&&""!==t?(t=String(t),mp_scene[t]||t):"\u672a\u53d6\u5230\u503c"},_.getShareDepth=function(){if("number"==typeof share_depth&&0!==share_depth){var t=sa.store.getDistinctId(),e=sa.store.getFirstId();return!share_distinct_id||share_distinct_id!==t&&share_distinct_id!==e?share_depth+1:share_depth}return 1},_.setShareInfo=function(t,e){var r={};if(!(t&&_.isObject(t.query)&&t.query.sampshare))return{};if(r=_.decodeURIComponent(t.query.sampshare),!_.isJSONString(r))return{};var a=(r=JSON.parse(r)).d,s=r.p,n=r.i;"string"==typeof n?(e.$share_distinct_id=n,share_distinct_id=n):e.$share_distinct_id="\u53d6\u503c\u5f02\u5e38","number"==typeof a?(e.$share_depth=a,share_depth=a):e.$share_depth="-1",e.$share_url_path="string"==typeof s?s:"\u53d6\u503c\u5f02\u5e38"},_.getShareInfo=function(){return JSON.stringify({i:sa.store.getDistinctId()||"\u53d6\u503c\u5f02\u5e38",p:_.getCurrentPath(),d:_.getShareDepth()})},_.detectOptionQuery=function(t){if(!t||!_.isObject(t.query))return{};var e,r,a,s,n={};return n.query=_.extend({},t.query),"string"==typeof n.query.scene&&(e=n.query,r=["utm_source","utm_content","utm_medium","utm_campaign","utm_term","sa_utm"].concat(sa.para.source_channel),a=new RegExp("("+r.join("|")+")%3D","i"),1===(s=Object.keys(e)).length&&"scene"===s[0]&&a.test(e.scene))&&(n.scene=n.query.scene,delete n.query.scene),t.query.q&&t.query.scancode_time&&"101"===String(t.scene).slice(0,3)&&(n.q=String(n.query.q),delete n.query.q,delete n.query.scancode_time),n},_.getMixedQuery=function(t){var e=_.detectOptionQuery(t),r=e.scene,a=e.q,s=e.query;for(var n in s)s[n]=_.decodeURIComponent(s[n]);return r&&(r=-1!==(r=_.decodeURIComponent(r)).indexOf("?")?"?"+r.replace(/\?/g,""):"?"+r,_.extend(s,_.getObjFromQuery(r))),a&&_.extend(s,_.getObjFromQuery(_.decodeURIComponent(a))),s},_.setUtm=function(t,e){var r={},a=_.getMixedQuery(t),s=_.getCustomUtmFromQuery(a,"$","_","$"),n=_.getCustomUtmFromQuery(a,"$latest_","_latest_","$latest_");return r.pre1=s,r.pre2=n,_.extend(e,s),r},_.wxrequest=function(t){var e=wx.request(t);setTimeout(function(){_.isObject(e)&&_.isFunction(e.abort)&&e.abort()},sa.para.datasend_timeout)},_.info={currentProps:{},properties:{$lib:LIB_NAME,$lib_version:String(LIB_VERSION)},getSystem:function(){var t=this.properties;function e(){wx.getSystemInfo({success:function(e){var r,a;t.$manufacturer=e.brand,t.$model=e.model,t.$screen_width=Number(e.screenWidth),t.$screen_height=Number(e.screenHeight),t.$os=(r=e.platform,"ios"===(a=r.toLowerCase())?"iOS":"android"===a?"Android":r),t.$os_version=e.system.indexOf(" ")>-1?e.system.split(" ")[1]:e.system},complete:function(){sa.initialState.systemIsComplete=!0,sa.initialState.checkIsComplete()}})}wx.getNetworkType({success:function(e){t.$network_type=e.networkType},complete:e})}},sa._=_,sa.prepareData=function(t,e){var r={distinct_id:this.store.getDistinctId(),lib:{$lib:LIB_NAME,$lib_method:"code",$lib_version:String(LIB_VERSION)},properties:{}};_.extend(r,this.store.getUnionId(),t),_.isObject(t.properties)&&!_.isEmptyObject(t.properties)&&_.extend(r.properties,t.properties),t.type&&"profile"===t.type.slice(0,7)||(sa.para.batch_send&&(r._track_id=Number(String(Math.random()).slice(2,5)+String(Math.random()).slice(2,4)+String(Date.now()).slice(-4))),r.properties=_.extend({},_.info.properties,sa.store.getProps(),_.info.currentProps,r.properties),"object"==typeof sa.store._state&&"number"==typeof sa.store._state.first_visit_day_time&&sa.store._state.first_visit_day_time>(new Date).getTime()?r.properties.$is_first_day=!0:r.properties.$is_first_day=!1),r.properties.$time&&_.isDate(r.properties.$time)?(r.time=1*r.properties.$time,delete r.properties.$time):sa.para.use_client_time&&(r.time=1*new Date),_.searchObjDate(r),_.searchObjString(r),logger.info(r),sa.sendStrategy.send(r)},sa.store={verifyDistinctId:function(t){return"number"==typeof t&&(t=String(t),/^\d+$/.test(t)||(t="unexpected_id")),"string"==typeof t&&""!==t||(t="unexpected_id"),t},storageInfo:null,getUUID:function(){return Date.now()+"-"+Math.floor(1e7*Math.random())+"-"+Math.random().toString(16).replace(".","")+"-"+String(31242*Math.random()).replace(".","").slice(0,8)},getStorage:function(){return this.storageInfo?this.storageInfo:(this.storageInfo=sa._.getStorageSync("sensorsdata2015_wechat")||"",this.storageInfo)},_state:{},mem:{mdata:[],getLength:function(){return this.mdata.length},add:function(t){this.mdata.push(t)},clear:function(t){this.mdata.splice(0,t)}},toState:function(t){var e=null;_.isJSONString(t)?(e=JSON.parse(t)).distinct_id?this._state=e:this.set("distinct_id",this.getUUID()):_.isObject(t)&&(e=t).distinct_id?this._state=e:this.set("distinct_id",this.getUUID())},getFirstId:function(){return this._state.first_id},getDistinctId:function(){return this._state.distinct_id},getUnionId:function(){var t={};return this._state.first_id&&this._state.distinct_id?(t.login_id=this._state.distinct_id,t.anonymous_id=this._state.first_id):t.anonymous_id=this._state.distinct_id,t},getProps:function(){return this._state.props||{}},setProps:function(t,e){var r=this._state.props||{};e?this.set("props",t):(_.extend(r,t),this.set("props",r))},set:function(t,e){var r={};for(var a in"string"==typeof t?r[t]=e:"object"==typeof t&&(r=t),this._state=this._state||{},r)this._state[a]=r[a];this.save()},change:function(t,e){this._state[t]=e},save:function(){sa._.setStorageSync("sensorsdata2015_wechat",this._state)},init:function(){var t=this.getStorage();if(t)this.toState(t);else{is_first_launch=!0;var e=new Date,r=e.getTime();e.setHours(23),e.setMinutes(59),e.setSeconds(60),sa.setOnceProfile({$first_visit_time:new Date}),this.set({distinct_id:this.getUUID(),first_visit_time:r,first_visit_day_time:e.getTime()})}}},sa.setProfile=function(t,e){sa.prepareData({type:"profile_set",properties:t},e)},sa.setOnceProfile=function(t,e){sa.prepareData({type:"profile_set_once",properties:t},e)},sa.appendProfile=function(t,e){if(!_.isObject(t))return!1;_.each(t,function(e,r){_.isString(e)?t[r]=[e]:_.isArray(e)||(delete t[r],logger.info("appendProfile\u5c5e\u6027\u7684\u503c\u5fc5\u987b\u662f\u5b57\u7b26\u4e32\u6216\u8005\u6570\u7ec4"))}),sa.prepareData({type:"profile_append",properties:t},e)},sa.incrementProfile=function(t,e){if(!_.isObject(t))return!1;var r=t;_.isString(t)&&((t={})[r]=1),sa.prepareData({type:"profile_increment",properties:t},e)},sa.track=function(t,e,r){this.prepareData({type:"track",event:t,properties:e},r)},sa.identify=function(t,e){if("string"!=typeof t&&"number"!=typeof t)return!1;t=sa.store.verifyDistinctId(t);var r=sa.store.getFirstId();!0===e?r?sa.store.set("first_id",t):sa.store.set("distinct_id",t):r?sa.store.change("first_id",t):sa.store.change("distinct_id",t)},sa.trackSignup=function(t,e,r,a){var s=sa.store.getFirstId()||sa.store.getDistinctId();sa.store.set("distinct_id",t),sa.prepareData({original_id:s,distinct_id:t,type:"track_signup",event:e,properties:r},a)},sa.registerApp=function(t){_.isObject(t)&&!_.isEmptyObject(t)&&(_.info.currentProps=_.extend(_.info.currentProps,t))},sa.register=function(t){_.isObject(t)&&!_.isEmptyObject(t)&&sa.store.setProps(t)},sa.clearAllRegister=function(){sa.store.setProps({},!0)},sa.clearAllProps=function(t){var e=sa.store.getProps(),r={};_.isArray(t)&&(_.each(e,function(e,a){_.include(t,a)||(r[a]=e)}),sa.store.setProps(r,!0))},sa.clearAppRegister=function(t){_.isArray(t)&&_.each(_.info.currentProps,function(e,r){_.include(t,r)&&delete _.info.currentProps[r]})},sa.setLatestChannel=function(t){_.isEmptyObject(t)||(function(t,e){var r=!1;for(var a in e)t[e[a]]&&(r=!0);return r}(t,latest_source_channel)&&(sa.clearAppRegister(latest_source_channel),sa.clearAllProps(latest_source_channel)),sa.para.is_persistent_save?sa.register(t):sa.registerApp(t))},sa.login=function(t){if("string"!=typeof t&&"number"!=typeof t)return!1;t=sa.store.verifyDistinctId(t);var e=sa.store.getFirstId(),r=sa.store.getDistinctId();t!==r&&(e?sa.trackSignup(t,"$SignUp"):(sa.store.set("first_id",r),sa.trackSignup(t,"$SignUp")))},sa.openid={getRequest:function(t){wx.login({success:function(e){e.code&&sa.para.appid&&sa.para.openid_url?_.wxrequest({url:sa.para.openid_url+"&code="+e.code+"&appid="+sa.para.appid,method:"GET",complete:function(e){_.isObject(e)&&_.isObject(e.data)&&e.data.openid?t(e.data.openid):t()}}):t()}})},getWXStorage:function(){var t=sa.store.getStorage();if(t&&_.isObject(t))return t.openid},getOpenid:function(t){if(!sa.para.appid)return t(),!1;var e=this.getWXStorage();e?t(e):this.getRequest(t)}},sa.initial=function(){this._.info.getSystem(),this.store.init()},sa.init=function(t){if(!0===this.hasInit)return!1;this.hasInit=!0,sa.setPara(t),sa.para.batch_send&&sa.sendStrategy.batchInterval(),sa.initialState.storeIsComplete=!0,sa.initialState.checkIsComplete()},sa.getPresetProperties=function(){if(_.info&&_.info.properties&&_.info.properties.$lib){var t={};_.each(_.info.currentProps,function(e,r){0===r.indexOf("$")&&(t[r]=e)});var e=_.extend(t,{$url_path:_.getCurrentPath()},_.info.properties,sa.store.getProps());return delete e.$lib,e}return{}},_.autoExeQueue=function(){return{items:[],enqueue:function(t){this.items.push(t),this.start()},dequeue:function(){return this.items.shift()},getCurrentItem:function(){return this.items[0]},isRun:!1,start:function(){this.items.length>0&&!this.isRun&&(this.isRun=!0,this.getCurrentItem().start())},close:function(){this.dequeue(),this.isRun=!1,this.start()}}},sa.requestQueue=function(t){this.url=t.url},sa.requestQueue.prototype.isEnd=function(){this.received||(this.received=!0,this.close())},sa.requestQueue.prototype.start=function(){var t=this;setTimeout(function(){t.isEnd()},sa.para.send_timeout),_.wxrequest({url:this.url,method:"GET",complete:function(){t.isEnd()}})},sa.dataQueue=_.autoExeQueue(),sa.sendStrategy={dataHasSend:!0,dataHasChange:!1,onAppHide:function(){sa.para.batch_send&&this.batchSend()},send:function(t){if(!sa.para.server_url)return!1;if(sa.para.batch_send){if(this.dataHasChange=!0,sa.store.mem.getLength()>=300)return logger.info("\u6570\u636e\u91cf\u5b58\u50a8\u8fc7\u5927\uff0c\u6709\u5f02\u5e38"),!1;sa.store.mem.add(t),sa.store.mem.getLength()>=sa.para.batch_send.max_length&&this.batchSend()}else this.queueSend(t)},queueSend:function(t){t=JSON.stringify(t),t=-1!==sa.para.server_url.indexOf("?")?sa.para.server_url+"&data="+encodeURIComponent(_.base64Encode(t)):sa.para.server_url+"?data="+encodeURIComponent(_.base64Encode(t));var e=new sa.requestQueue({url:t});e.close=function(){sa.dataQueue.close()},sa.dataQueue.enqueue(e)},wxrequest:function(t){if(_.isArray(t.data)&&t.data.length>0){var e=Date.now();t.data.forEach(function(t){t._flush_time=e}),t.data=JSON.stringify(t.data),_.wxrequest({url:sa.para.server_url,method:"POST",dataType:"text",data:"data_list="+encodeURIComponent(_.base64Encode(t.data)),success:function(){t.success(t.len)}})}else t.success(t.len)},batchSend:function(){if(this.dataHasSend){var t=sa.store.mem.mdata,e=t.length;e>0&&(this.dataHasSend=!1,this.wxrequest({data:t,len:e,success:this.batchRemove.bind(this)}))}},batchRemove:function(t){sa.store.mem.clear(t),this.dataHasSend=!0,this.dataHasChange=!0,this.batchWrite()},is_first_batch_write:!0,batchWrite:function(){var t=this;this.dataHasChange&&(this.is_first_batch_write&&(this.is_first_batch_write=!1,setTimeout(function(){t.batchSend()},1e3)),this.dataHasChange=!1,sa._.setStorageSync("sensors_mp_prepare_data",sa.store.mem.mdata))},batchInterval:function(){var t=this;!function e(){setTimeout(function(){t.batchWrite(),e()},500)}(),function e(){setTimeout(function(){t.batchSend(),e()},sa.para.batch_send.send_timeout)}()}},sa.setOpenid=function(t,e){sa.store.set("openid",t),e?sa.store.set("distinct_id",t):sa.identify(t,!0)},sa.initWithOpenid=function(t,e){(t=t||{}).appid&&(sa.para.appid=t.appid),sa.openid.getOpenid(function(r){r&&sa.setOpenid(r,t.isCoverLogin),e&&_.isFunction(e)&&e(r),sa.init(t)})},_.each(["setProfile","setOnceProfile","track","quick","incrementProfile","appendProfile"],function(t){var e=sa[t];sa[t]=function(){sa.initialState.isComplete?e.apply(sa,arguments):sa.initialState.queue.push([t,arguments])}}),_.setQuery=function(t,e){if(t&&_.isObject(t)&&!_.isEmptyObject(t)){var r=[];return _.each(t,function(t,a){"q"===a&&_.isString(t)&&0===t.indexOf("http")||"scene"===a||(e?r.push(a+"="+t):r.push(a+"="+_.decodeURIComponent(t)))}),r.join("&")}return""},_.getUtmFromPage=function(){var t={};try{var e=getCurrentPages(),r=e[e.length-1].options;t=_.getCustomUtmFromQuery(r,"$","_","$")}catch(t){logger.info(t)}return t},sa.autoTrackCustom={trackCustom:function(t,e,r){var a=sa.para.autoTrack[t],s="";sa.para.autoTrack&&a&&("function"==typeof a?(s=a(),_.isObject(s)&&_.extend(e,s)):_.isObject(a)&&(_.extend(e,a),sa.para.autoTrack[t]=!0),sa.track(r,e))},appLaunch:function(t,e){"object"!=typeof this||this.trackCustom||(this[sa.para.name]=sa);var r={};t&&t.path&&(r.$url_path=_.getPath(t.path)),_.setShareInfo(t,r);var a=_.setUtm(t,r);is_first_launch?(r.$is_first_time=!0,_.isEmptyObject(a.pre1)||sa.setOnceProfile(a.pre1)):r.$is_first_time=!1,sa.setLatestChannel(a.pre2),t.scene=t.scene||"\u672a\u53d6\u5230\u503c",r.$scene=_.getMPScene(t.scene),sa.registerApp({$latest_scene:r.$scene}),r.$url_query=_.setQuery(t.query),e?(r=_.extend(r,e),sa.track("$MPLaunch",r)):sa.para.autoTrack&&sa.para.autoTrack.appLaunch&&sa.autoTrackCustom.trackCustom("appLaunch",r,"$MPLaunch")},appShow:function(t,e){var r={};mpshow_time=(new Date).getTime(),t&&t.path&&(r.$url_path=_.getPath(t.path)),_.setShareInfo(t,r);var a=_.setUtm(t,r);sa.setLatestChannel(a.pre2),t.scene=t.scene||"\u672a\u53d6\u5230\u503c",r.$scene=_.getMPScene(t.scene),sa.registerApp({$latest_scene:r.$scene}),r.$url_query=_.setQuery(t.query),e?(r=_.extend(r,e),sa.track("$MPShow",r)):sa.para.autoTrack&&sa.para.autoTrack.appShow&&sa.autoTrackCustom.trackCustom("appShow",r,"$MPShow")},appHide:function(t){var e=(new Date).getTime(),r={};r.$url_path=_.getCurrentPath(),mpshow_time&&e-mpshow_time>0&&(e-mpshow_time)/36e5<24&&(r.event_duration=(e-mpshow_time)/1e3),t?(r=_.extend(r,t),sa.track("$MPHide",r)):sa.para.autoTrack&&sa.para.autoTrack.appHide&&sa.autoTrackCustom.trackCustom("appHide",r,"$MPHide"),sa.sendStrategy.onAppHide()},pageLoad:function(t){t&&_.isObject(t)&&(this.sensors_mp_url_query=_.setQuery(t),this.sensors_mp_encode_url_query=_.setQuery(t,!0))},pageShow:function(){var t={},e=_.getCurrentPath();t.$referrer=sa_referrer,t.$url_path=e,sa.status.last_referrer=sa_referrer,t.$url_query=this.sensors_mp_url_query?this.sensors_mp_url_query:"",t=_.extend(t,_.getUtmFromPage()),sa.para.onshow?sa.para.onshow(sa,e,this):sa.para.autoTrack&&sa.para.autoTrack.pageShow&&sa.autoTrackCustom.trackCustom("pageShow",t,"$MPViewScreen"),sa_referrer=e,sa.status.referrer=e},pageShare:function(t,e){var r=t.onShareAppMessage;t.onShareAppMessage=function(){var t=r.apply(this,arguments);return sa.para.autoTrack&&sa.para.autoTrack.pageShare&&sa.autoTrackCustom.trackCustom("pageShare",{$url_path:_.getCurrentPath(),$share_depth:_.getShareDepth()},"$MPShare"),sa.para.allow_amend_share_path&&("object"!=typeof t&&((t={}).path=_.getCurrentUrl(this)),"object"!=typeof t||void 0!==t.path&&""!==t.path||(t.path=_.getCurrentUrl(this)),"object"==typeof t&&"string"==typeof t.path&&(-1===t.path.indexOf("?")?t.path=t.path+"?":"&"!==t.path.slice(-1)&&(t.path=t.path+"&")),t.path=t.path+"sampshare="+encodeURIComponent(_.getShareInfo())),t}}},sa.quick=function(){var t=arguments[0],e=arguments[1],r=arguments[2],a=_.isObject(r)?r:{};if("getAnonymousID"===t){if(!_.isEmptyObject(sa.store._state))return sa.store._state.first_id?sa.store._state.first_id:sa.store._state.distinct_id;logger.info("\u8bf7\u5148\u521d\u59cb\u5316SDK")}else"appLaunch"===t||"appShow"===t?e?sa.autoTrackCustom[t](e,a):logger.info("App\u7684launch\u548cshow\uff0c\u5728sensors.quick\u7b2c\u4e8c\u4e2a\u53c2\u6570\u5fc5\u987b\u4f20\u5165App\u7684options\u53c2\u6570"):"appHide"===t&&(a=_.isObject(e)?e:{},sa.autoTrackCustom[t](a))},sa.App=function(t){mp_proxy(t=t||{},"onLaunch","appLaunch"),mp_proxy(t,"onShow","appShow"),mp_proxy(t,"onHide","appHide"),App.apply(this,arguments)},sa.Page=function(t){mp_proxy(t,"onLoad","pageLoad"),mp_proxy(t,"onShow","pageShow"),"function"==typeof t.onShareAppMessage&&sa.autoTrackCustom.pageShare(t),Page.apply(this,arguments)},sa.initial(),module.exports=sa;