yrjy_mini_sdk 1.0.10 → 1.0.11
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/dist/index.cjs.js +2 -2
- package/dist/index.esm.js +2 -2
- package/package.json +1 -1
- package/src/struct/trackCore.js +41 -28
package/dist/index.cjs.js
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
"use strict";function e(e,t){(null==t||t>e.length)&&(t=e.length);for(var r=0,n=Array(t);r<t;r++)n[r]=e[r];return n}function t(t,r){if(t){if("string"==typeof t)return e(t,r);var n={}.toString.call(t).slice(8,-1);return"Object"===n&&t.constructor&&(n=t.constructor.name),"Map"===n||"Set"===n?Array.from(t):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?e(t,r):void 0}}function r(e,r){return function(e){if(Array.isArray(e))return e}(e)||function(e,t){var r=null==e?null:"undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=r){var n,o,i,a,u=[],c=!0,s=!1;try{if(i=(r=r.call(e)).next,0===t){if(Object(r)!==r)return;c=!1}else for(;!(c=(n=i.call(r)).done)&&(u.push(n.value),u.length!==t);c=!0);}catch(e){s=!0,o=e}finally{try{if(!c&&null!=r.return&&(a=r.return(),Object(a)!==a))return}finally{if(s)throw o}}return u}}(e,r)||t(e,r)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function n(e){return n="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},n(e)}function o(r){return function(t){if(Array.isArray(t))return e(t)}(r)||function(e){if("undefined"!=typeof Symbol&&null!=e[Symbol.iterator]||null!=e["@@iterator"])return Array.from(e)}(r)||t(r)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function i(e,t,r,n,o,i,a){try{var u=e[i](a),c=u.value}catch(e){return void r(e)}u.done?t(c):Promise.resolve(c).then(n,o)}function a(e){return function(){var t=this,r=arguments;return new Promise(function(n,o){var a=e.apply(t,r);function u(e){i(a,n,o,u,c,"next",e)}function c(e){i(a,n,o,u,c,"throw",e)}u(void 0)})}}function u(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function c(e){var t=function(e,t){if("object"!=n(e)||!e)return e;var r=e[Symbol.toPrimitive];if(void 0!==r){var o=r.call(e,t||"default");if("object"!=n(o))return o;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===t?String:Number)(e)}(e,"string");return"symbol"==n(t)?t:t+""}function s(e,t){for(var r=0;r<t.length;r++){var n=t[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,c(n.key),n)}}function f(e,t,r){return t&&s(e.prototype,t),r&&s(e,r),Object.defineProperty(e,"prototype",{writable:!1}),e}function
|
|
1
|
+
"use strict";function e(e,t){(null==t||t>e.length)&&(t=e.length);for(var r=0,n=Array(t);r<t;r++)n[r]=e[r];return n}function t(t,r){if(t){if("string"==typeof t)return e(t,r);var n={}.toString.call(t).slice(8,-1);return"Object"===n&&t.constructor&&(n=t.constructor.name),"Map"===n||"Set"===n?Array.from(t):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?e(t,r):void 0}}function r(e,r){return function(e){if(Array.isArray(e))return e}(e)||function(e,t){var r=null==e?null:"undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=r){var n,o,i,a,u=[],c=!0,s=!1;try{if(i=(r=r.call(e)).next,0===t){if(Object(r)!==r)return;c=!1}else for(;!(c=(n=i.call(r)).done)&&(u.push(n.value),u.length!==t);c=!0);}catch(e){s=!0,o=e}finally{try{if(!c&&null!=r.return&&(a=r.return(),Object(a)!==a))return}finally{if(s)throw o}}return u}}(e,r)||t(e,r)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function n(e){return n="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},n(e)}function o(r){return function(t){if(Array.isArray(t))return e(t)}(r)||function(e){if("undefined"!=typeof Symbol&&null!=e[Symbol.iterator]||null!=e["@@iterator"])return Array.from(e)}(r)||t(r)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function i(e,t,r,n,o,i,a){try{var u=e[i](a),c=u.value}catch(e){return void r(e)}u.done?t(c):Promise.resolve(c).then(n,o)}function a(e){return function(){var t=this,r=arguments;return new Promise(function(n,o){var a=e.apply(t,r);function u(e){i(a,n,o,u,c,"next",e)}function c(e){i(a,n,o,u,c,"throw",e)}u(void 0)})}}function u(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function c(e){var t=function(e,t){if("object"!=n(e)||!e)return e;var r=e[Symbol.toPrimitive];if(void 0!==r){var o=r.call(e,t||"default");if("object"!=n(o))return o;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===t?String:Number)(e)}(e,"string");return"symbol"==n(t)?t:t+""}function s(e,t){for(var r=0;r<t.length;r++){var n=t[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,c(n.key),n)}}function f(e,t,r){return t&&s(e.prototype,t),r&&s(e,r),Object.defineProperty(e,"prototype",{writable:!1}),e}function l(e,t,r){return(t=c(t))in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}function p(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}Object.defineProperty(exports,"__esModule",{value:!0});var h,y={exports:{}},d={exports:{}};(h=d).exports=function(e,t){this.v=e,this.k=t},h.exports.__esModule=!0,h.exports.default=h.exports;var v=d.exports,g={exports:{}},m={exports:{}};!function(e){function t(r,n,o,i){var a=Object.defineProperty;try{a({},"",{})}catch(r){a=0}e.exports=t=function(e,r,n,o){function i(r,n){t(e,r,function(e){return this._invoke(r,n,e)})}r?a?a(e,r,{value:n,enumerable:!o,configurable:!o,writable:!o}):e[r]=n:(i("next",0),i("throw",1),i("return",2))},e.exports.__esModule=!0,e.exports.default=e.exports,t(r,n,o,i)}e.exports=t,e.exports.__esModule=!0,e.exports.default=e.exports}(m);var b=m.exports;!function(e){var t=b;function r(){
|
|
2
2
|
/*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/babel/babel/blob/main/packages/babel-helpers/LICENSE */
|
|
3
|
-
var n,o,i="function"==typeof Symbol?Symbol:{},a=i.iterator||"@@iterator",u=i.toStringTag||"@@toStringTag";function c(e,r,i,a){var u=r&&r.prototype instanceof f?r:f,c=Object.create(u.prototype);return t(c,"_invoke",function(e,t,r){var i,a,u,c=0,f=r||[],p=!1,l={p:0,n:0,v:n,a:y,f:y.bind(n,4),d:function(e,t){return i=e,a=0,u=n,l.n=t,s}};function y(e,t){for(a=e,u=t,o=0;!p&&c&&!r&&o<f.length;o++){var r,i=f[o],y=l.p,h=i[2];e>3?(r=h===t)&&(u=i[(a=i[4])?5:(a=3,3)],i[4]=i[5]=n):i[0]<=y&&((r=e<2&&y<i[1])?(a=0,l.v=t,l.n=i[1]):y<h&&(r=e<3||i[0]>t||t>h)&&(i[4]=e,i[5]=t,l.n=h,a=0))}if(r||e>1)return s;throw p=!0,t}return function(r,f,h){if(c>1)throw TypeError("Generator is already running");for(p&&1===f&&y(f,h),a=f,u=h;(o=a<2?n:u)||!p;){i||(a?a<3?(a>1&&(l.n=-1),y(a,u)):l.n=u:l.v=u);try{if(c=2,i){if(a||(r="next"),o=i[r]){if(!(o=o.call(i,u)))throw TypeError("iterator result is not an object");if(!o.done)return o;u=o.value,a<2&&(a=0)}else 1===a&&(o=i.return)&&o.call(i),a<2&&(u=TypeError("The iterator does not provide a '"+r+"' method"),a=1);i=n}else if((o=(p=l.n<0)?u:e.call(t,l))!==s)break}catch(e){i=n,a=1,u=e}finally{c=1}}return{value:o,done:p}}}(e,i,a),!0),c}var s={};function f(){}function p(){}function l(){}o=Object.getPrototypeOf;var y=[][a]?o(o([][a]())):(t(o={},a,function(){return this}),o),h=l.prototype=f.prototype=Object.create(y);function d(e){return Object.setPrototypeOf?Object.setPrototypeOf(e,l):(e.__proto__=l,t(e,u,"GeneratorFunction")),e.prototype=Object.create(h),e}return p.prototype=l,t(h,"constructor",l),t(l,"constructor",p),p.displayName="GeneratorFunction",t(l,u,"GeneratorFunction"),t(h),t(h,u,"Generator"),t(h,a,function(){return this}),t(h,"toString",function(){return"[object Generator]"}),(e.exports=r=function(){return{w:c,m:d}},e.exports.__esModule=!0,e.exports.default=e.exports)()}e.exports=r,e.exports.__esModule=!0,e.exports.default=e.exports}(g);var x=g.exports,_={exports:{}},P={exports:{}},k={exports:{}};!function(e){var t=v,r=b;e.exports=function e(n,o){function i(e,r,a,u){try{var c=n[e](r),s=c.value;return s instanceof t?o.resolve(s.v).then(function(e){i("next",e,a,u)},function(e){i("throw",e,a,u)}):o.resolve(s).then(function(e){c.value=e,a(c)},function(e){return i("throw",e,a,u)})}catch(e){u(e)}}var a;this.next||(r(e.prototype),r(e.prototype,"function"==typeof Symbol&&Symbol.asyncIterator||"@asyncIterator",function(){return this})),r(this,"_invoke",function(e,t,r){function n(){return new o(function(t,n){i(e,r,t,n)})}return a=a?a.then(n,n):n()},!0)},e.exports.__esModule=!0,e.exports.default=e.exports}(k);var w=k.exports;!function(e){var t=x,r=w;e.exports=function(e,n,o,i,a){return new r(t().w(e,n,o,i),a||Promise)},e.exports.__esModule=!0,e.exports.default=e.exports}(P);var O=P.exports;!function(e){var t=O;e.exports=function(e,r,n,o,i){var a=t(e,r,n,o,i);return a.next().then(function(e){return e.done?e.value:a.next()})},e.exports.__esModule=!0,e.exports.default=e.exports}(_);var T=_.exports,C={exports:{}};!function(e){e.exports=function(e){var t=Object(e),r=[];for(var n in t)r.unshift(n);return function e(){for(;r.length;)if((n=r.pop())in t)return e.value=n,e.done=!1,e;return e.done=!0,e}},e.exports.__esModule=!0,e.exports.default=e.exports}(C);var j=C.exports,S={exports:{}},I={exports:{}};!function(e){function t(r){return e.exports=t="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},e.exports.__esModule=!0,e.exports.default=e.exports,t(r)}e.exports=t,e.exports.__esModule=!0,e.exports.default=e.exports}(I);var M=I.exports;!function(e){var t=M.default;e.exports=function(e){if(null!=e){var r=e["function"==typeof Symbol&&Symbol.iterator||"@@iterator"],n=0;if(r)return r.call(e);if("function"==typeof e.next)return e;if(!isNaN(e.length))return{next:function(){return e&&n>=e.length&&(e=void 0),{value:e&&e[n++],done:!e}}}}throw new TypeError(t(e)+" is not iterable")},e.exports.__esModule=!0,e.exports.default=e.exports}(S);var $=S.exports;!function(e){var t=v,r=x,n=T,o=O,i=w,a=j,u=$;function c(){var s=r(),f=s.m(c),p=(Object.getPrototypeOf?Object.getPrototypeOf(f):f.__proto__).constructor;function l(e){var t="function"==typeof e&&e.constructor;return!!t&&(t===p||"GeneratorFunction"===(t.displayName||t.name))}var y={throw:1,return:2,break:3,continue:3};function h(e){var t,r;return function(n){t||(t={stop:function(){return r(n.a,2)},catch:function(){return n.v},abrupt:function(e,t){return r(n.a,y[e],t)},delegateYield:function(e,o,i){return t.resultName=o,r(n.d,u(e),i)},finish:function(e){return r(n.f,e)}},r=function(e,r,o){n.p=t.prev,n.n=t.next;try{return e(r,o)}finally{t.next=n.n}}),t.resultName&&(t[t.resultName]=n.v,t.resultName=void 0),t.sent=n.v,t.next=n.n;try{return e.call(this,t)}finally{n.p=t.prev,n.n=t.next}}}return(e.exports=c=function(){return{wrap:function(e,t,r,n){return s.w(h(e),t,r,n&&n.reverse())},isGeneratorFunction:l,mark:s.m,awrap:function(e,r){return new t(e,r)},AsyncIterator:i,async:function(e,t,r,i,a){return(l(t)?o:n)(h(e),t,r,i,a)},keys:a,values:u}},e.exports.__esModule=!0,e.exports.default=e.exports)()}e.exports=c,e.exports.__esModule=!0,e.exports.default=e.exports}(h);var E=(0,h.exports)(),L=E;try{regeneratorRuntime=E}catch(e){"object"==typeof globalThis?globalThis.regeneratorRuntime=E:Function("r","regeneratorRuntime = r")(E)}var U=l(L),A="",D="https://log.cdyrjygs.com/binlog",N="https://crbt.cdyrjygs.com/cms-vrbt";function R(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),r.push.apply(r,n)}return r}function q(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{};t%2?R(Object(r),!0).forEach(function(t){p(e,t,r[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):R(Object(r)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))})}return e}var B=function(){return f(function e(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};u(this,e),this.config={baseURL:t.baseURL||"",timeout:t.timeout||1e4,header:q({"Content-Type":"application/json"},t.header)}},[{key:"requestInterceptor",value:function(e){return e.url=this.config.baseURL+e.url,e.timeout=e.timeout||this.config.timeout,e.header=q(q({},this.config.header),e.header),e}},{key:"responseInterceptor",value:function(e){if(200===e.statusCode)return Promise.resolve(e.data);var t={code:e.statusCode,message:e.data.message||"请求失败"};return uni.showToast({title:t.message,icon:"none",duration:2e3}),Promise.reject(t)}},{key:"request",value:function(e){var t=this;return e=this.requestInterceptor(e),new Promise(function(r,n){uni.request(q(q({},e),{},{success:function(o){try{var i=t.responseInterceptor(o,e);r(i)}catch(e){n(e)}},fail:function(e){var t={code:e.errMsg?-1:-2,message:e.errMsg||"网络请求失败"};uni.showToast({title:t.message,icon:"none",duration:2e3}),n(t)}}))})}},{key:"get",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};return this.request(q({url:e,data:t,method:"GET"},r))}},{key:"post",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};return this.request(q({url:e,data:t,method:"POST"},r))}},{key:"put",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};return this.request(q({url:e,data:t,method:"PUT"},r))}},{key:"delete",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};return this.request(q({url:e,data:t,method:"DELETE"},r))}},{key:"setBaseURL",value:function(e){this.config.baseURL=e}},{key:"setHeader",value:function(e){this.config.header=q(q({},this.config.header),e)}}])}();new B;var F=new B({baseURL:A,timeout:1e4,header:{"Content-Type":"application/json"}}),G=function(e,t){return F.get(e,t)};function z(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),r.push.apply(r,n)}return r}function J(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{};t%2?z(Object(r),!0).forEach(function(t){p(e,t,r[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):z(Object(r)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))})}return e}var V=function(){return f(function e(){u(this,e)},null,[{key:"init",value:(r=a(U.mark(function e(t){var r=this;return U.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=1,this._updateNetworkType();case 1:return this.launchTime=Date.now(),this.config=J(J({},this.config),t),e.next=2,this.getBaseInf();case 2:return this.MiniProBaseInfo=e.sent,this.launchOptions=this.getLaunchOptionsSync(),this.cachedUserInfo=this.getUserInfo(),e.next=3,this._getOpenId();case 3:uni.onNetworkStatusChange(function(e){r.networkType=e.networkType||""}),this.initialized=!0,this.report({name:"initEvent",action:"埋点初始化"}),this._executeCachedApiCalls();case 4:case"end":return e.stop()}},e,this)})),function(e){return r.apply(this,arguments)})},{key:"getPrimaryCategory",value:function(){return this.primaryCategory}},{key:"setPrimaryCategory",value:function(e,t){this._setCategory(e,t,"primaryCategory","一级栏目")}},{key:"getSecondaryCategory",value:function(){return this.secondaryCategory}},{key:"setSecondaryCategory",value:function(e,t){this._setCategory(e,t,"secondaryCategory","二级栏目")}},{key:"_setCategory",value:function(e,t,r,n){if(Array.isArray(e)&&0!==e.length)if("number"!=typeof t||t<0||t>=e.length)this[r]="";else{var o=e[t];o&&"string"==typeof o.title&&""!==o.title.trim()?this[r]=o.title:this[r]=""}else this[r]=""}},{key:"resetCategory",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"secondary",t=arguments.length>1?arguments[1]:void 0;if(["primary","secondary","both"].includes(e))if(void 0!==t){if("both"===e){if("string"!=typeof t&&("object"!==n(t)||null===t))return;if("object"===n(t)){if(void 0!==t.primary&&"string"!=typeof t.primary)return;if(void 0!==t.secondary&&"string"!=typeof t.secondary)return}}else if("string"!=typeof t)return;switch(e){case"primary":this.primaryCategory=t;break;case"secondary":this.secondaryCategory=t;break;case"both":if("object"===n(t)&&null!==t){var r=void 0!==t.primary?t.primary:"",o=void 0!==t.secondary?t.secondary:"";this.primaryCategory=r,this.secondaryCategory=o}else this.primaryCategory=t,this.secondaryCategory=t}}else switch(e){case"primary":this.primaryCategory="";break;case"secondary":this.secondaryCategory="";break;case"both":this.primaryCategory="",this.secondaryCategory=""}}},{key:"_updateNetworkType",value:function(){var e=this;return new Promise(function(t){uni.getNetworkType({success:function(r){e.networkType=r.networkType||"",t()},fail:function(r){e.networkType="",t()}})})}},{key:"_executeCachedApiCalls",value:function(){var e=this;0!==this.apiCallCache.length&&(this.apiCallCache.forEach(function(t){var r=t.method,n=t.args;try{e[r].apply(e,o(n))}catch(e){}}),this.apiCallCache=[])}},{key:"_getOpenId",value:(t=a(U.mark(function e(){var t,r,n;return U.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:return e.prev=0,e.next=1,this._getLoginCode();case 1:if(t=e.sent){e.next=2;break}return e.abrupt("return");case 2:return r="".concat(N,"/api/aiqwxq/getOpenid"),e.next=3,G(r,{code:t});case 3:n=e.sent,this.openid=(null==n?void 0:n.result)||"",e.next=5;break;case 4:e.prev=4,e.catch(0);case 5:case"end":return e.stop()}},e,this,[[0,4]])})),function(){return t.apply(this,arguments)})},{key:"_getLoginCode",value:function(){return new Promise(function(e,t){uni.login({success:function(t){t.code?e(t.code):e("")},fail:function(t){e("")}})})}},{key:"getBaseInf",value:(e=a(U.mark(function e(){var t,r,o,i,a,u,c;return U.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:if(e.prev=0,o=null===(t=this.storageDataFromMiniPro)||void 0===t||null===(t=t.systemInfo)||void 0===t?void 0:t.data){e.next=2;break}if(i="track_system_info","object"===("undefined"==typeof uni?"undefined":n(uni))&&null!==uni&&"function"==typeof uni.getStorageSync&&(o=uni.getStorageSync(i)),o||"object"!==("undefined"==typeof uni?"undefined":n(uni))||null===uni||"function"!=typeof uni.getSystemInfo){e.next=2;break}return e.next=1,uni.getSystemInfo();case 1:a=e.sent,o={system:a.system||"",uniPlatform:a.uniPlatform||"",deviceBrand:a.deviceBrand||"",deviceType:a.deviceType||""},"function"==typeof uni.setStorageSync&&uni.setStorageSync(i,o);case 2:return u=this._getMiniProgramInfo(null===(r=o)||void 0===r?void 0:r.uniPlatform),c=J(J({},o),u),e.abrupt("return",c);case 3:return e.prev=3,e.catch(0),e.abrupt("return",{system:"",uniPlatform:"",deviceBrand:"",platform:"",appId:""});case 4:case"end":return e.stop()}},e,this,[[0,3]])})),function(){return e.apply(this,arguments)})},{key:"_getMiniProgramInfo",value:function(e){var t="",r="",n="";try{if("mp-weixin"===e){var o,i,a,u=wx.getAccountInfoSync();t=(null===(o=u.miniProgram)||void 0===o?void 0:o.appId)||"",r=(null===(i=u.miniProgram)||void 0===i?void 0:i.version)||"",n=(null===(a=u.miniProgram)||void 0===a?void 0:a.envVersion)||""}else if("mp-douyin"===e){var c,s,f,p=tt.getEnvInfoSync();t=(null===(c=p.microapp)||void 0===c?void 0:c.appId)||"",r=(null===(s=p.microapp)||void 0===s?void 0:s.mpVersion)||"",n=(null===(f=p.microapp)||void 0===f?void 0:f.envType)||""}}catch(e){}return{appId:t,version:r,envVersion:n}}},{key:"getUserInfo",value:function(){try{var e,t=null===(e=this.storageDataFromMiniPro)||void 0===e||null===(e=e.userInfoDeatil)||void 0===e?void 0:e.data;return t?{userId:t.id||"",userPhone:t.mobile||""}:{userId:"",userPhone:""}}catch(e){return{userId:"",userPhone:""}}}},{key:"setUserInfo",value:function(e){if(e&&e.id)try{this.cachedUserInfo={userId:e.id||"",userPhone:e.mobile||""}}catch(e){}}},{key:"clearUserInfo",value:function(){try{this.cachedUserInfo={}}catch(e){}}},{key:"enable",value:function(){this.config.enabled=!0}},{key:"disable",value:function(){this.config.enabled=!1}},{key:"getLaunchOptionsSync",value:function(){try{if("object"===("undefined"==typeof uni?"undefined":n(uni))&&null!==uni&&"function"==typeof uni.getLaunchOptionsSync){var e,t=uni.getLaunchOptionsSync()||{},r=t.path,o=t.scene,i=t.query;return{launchPath:null!=r?r:"",launchScene:null!=o?o:"",launchParams:Object.keys(i).length>0?JSON.stringify(i):"",subChannel:null!==(e=i.subChannel)&&void 0!==e?e:"",click_id:i.qz_gdt||i.gdt_vid||""}}return{}}catch(e){return{}}}},{key:"submitTrackLog",value:function(e){var t,r;(t=this.config.reportUrl,r=e,F.post(t,r)).then(function(){}).catch(function(e){})}},{key:"_adReport",value:function(e){var t=this.launchOptions,r={adId:t.click_id,subChannel:t.subChannel,adLink:t.launchPath,adType:e,mobile:this.cachedUserInfo.userPhone};(function(e,t){return F.get(e,t)})("".concat(N,"/api/aiqwxq/adReport"),r).then(function(e){}).catch(function(e){})}},{key:"report",value:function(e){if(this.initialized){var t=J(J(J(J({launchTime:this.launchTime,currentTime:Date.now()},this.launchOptions),this.MiniProBaseInfo),this.cachedUserInfo),{},{openid:this.openid,networkType:this.networkType},e);this.submitTrackLog(t)}else this.apiCallCache.push({method:"report",args:[e]})}},{key:"customReport",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:"clickEvent",n=!(arguments.length>3&&void 0!==arguments[3])||arguments[3];if(this.config.enabled&&e&&r){var o={action:e,name:r};if(n){var i=J(J({},this.primaryCategory&&{primaryCategory:this.primaryCategory}),this.secondaryCategory&&{secondaryCategory:this.secondaryCategory});Object.assign(o,i)}t&&Object.keys(t).length>0&&(o.data=JSON.stringify(t)),this.report(o)}}}]);var e,t,r}();p(V,"config",{reportUrl:D,enabled:!0}),p(V,"initialized",!1),p(V,"apiCallCache",[]),p(V,"storageDataFromMiniPro",function(){try{return function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};try{return e&&"string"==typeof e?JSON.parse(e):t}catch(e){return t}}(uni.getStorageSync("storageName"),{})}catch(e){return{}}}()),p(V,"launchTime",null),p(V,"cachedNetworkType",""),p(V,"MiniProBaseInfo",{}),p(V,"networkType",""),p(V,"launchOptions",{}),p(V,"openid",""),p(V,"primaryCategory",""),p(V,"secondaryCategory","");var H={onLoad:function(e){var t=function(){var e=[];try{if("harmonyos"===process.env.UNI_PLATFORM){var t=uni.getAppPageManager();t&&"function"==typeof t.getPages&&(e=t.getPages()||[])}else"object"===("undefined"==typeof uni?"undefined":n(uni))&&null!==uni&&"function"==typeof uni.getCurrentPages&&(e=uni.getCurrentPages()||[])}catch(e){}return e}(),r=function(e,t){var r="";return e&&(e.route?r=e.route:e.__route__?r=e.__route__:e.path?r=e.path:t&&"object"===n(t)&&null!==t&&(t.route?r=t.route:t.__route__?r=t.__route__:t.path&&(r=t.path))),r}(t[t.length-1]||{},this.$scope);V.currentPagePath=r||"";var o={trackType:"pageview",viewPagePath:r||"",viewPageLoadTime:Date.now(),viewPageParams:e||{}};this.$pageTrackCache=o},onUnload:function(){this._reportPageTrack()},onHide:function(){this._reportPageTrack()},onShow:function(){this.$pageTrackCache&&(this.$pageTrackCache.lastShowTime=Date.now()),this.$pageTrackCache&&this.$pageTrackCache.viewPagePath&&(V.currentPagePath=this.$pageTrackCache.viewPagePath)},methods:{_reportPageTrack:function(){if(this.$pageTrackCache){var e=this.$pageTrackCache.lastShowTime||this.$pageTrackCache.viewPageLoadTime,t=Date.now(),r=t-e,n={path:this.$pageTrackCache.viewPagePath||"",loadTime:this.$pageTrackCache.viewPageLoadTime||Date.now(),leaveTime:t,params:this.$pageTrackCache.viewPageParams||{},stayTime:r};V.customReport("页面曝光",n,"pageviewEvent",!1)}}}},Y=!1;function K(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};if(!Y&&(Y=!0,V.init(t),e.config.globalProperties.$Track=V,e.mixin(H),uni.$Track=V,"object"===("undefined"==typeof uni?"undefined":n(uni))&&null!==uni)){["navigateTo","redirectTo","reLaunch","switchTab","navigateBack"].forEach(function(e){if("function"==typeof uni[e]){var t=uni[e];uni[e]=function(o){try{var i="";if("function"==typeof uni.getCurrentPages){var a=uni.getCurrentPages()||[],u=a[a.length-1]||{};i=u.route||u.__route__||u.path||""}if(!i&&V.currentPagePath&&(i=V.currentPagePath),!i&&"function"==typeof getApp)try{var c=getApp();if(c&&c._pages&&c._pages.length>0){var s=c._pages[c._pages.length-1]||{};i=s.route||s.__route__||s.path||""}else if(c&&c.$vm&&c.$vm.$page){var f=c.$vm.$page;i=f.route||f.__route__||f.path||""}}catch(e){}if(!i)try{if(uni.$app&&uni.$app._pages&&uni.$app._pages.length>0){var p=uni.$app._pages[uni.$app._pages.length-1]||{};i=p.route||p.__route__||p.path||""}}catch(e){}var l="",y={};if("navigateBack"===e)l="back",y={delta:o||1};else if("object"===n(o)&&null!==o){if((l=o.url||"").includes("?")){var h=r(l.split("?"),2),d=h[0],v=h[1];l=d,y=v.split("&").reduce(function(e,t){var n=r(t.split("="),2),o=n[0],i=n[1];return o&&(e[o]=decodeURIComponent(i||"")),e},{})}Object.keys(o).forEach(function(e){"url"!==e&&"success"!==e&&"fail"!==e&&"complete"!==e&&(y[e]=o[e])})}var g={currentPagePath:i||"",targetPagePath:l||"",navigationParams:y||{}};V.customReport("页面跳转",g,"navigationEvent",!1)}catch(e){}return t.call(uni,o)}}})}}var Q={install:K,Track:V,trackPageMixin:H};exports.Track=V,exports.default=Q,exports.install=K,exports.trackPageMixin=H;
|
|
3
|
+
var n,o,i="function"==typeof Symbol?Symbol:{},a=i.iterator||"@@iterator",u=i.toStringTag||"@@toStringTag";function c(e,r,i,a){var u=r&&r.prototype instanceof f?r:f,c=Object.create(u.prototype);return t(c,"_invoke",function(e,t,r){var i,a,u,c=0,f=r||[],l=!1,p={p:0,n:0,v:n,a:h,f:h.bind(n,4),d:function(e,t){return i=e,a=0,u=n,p.n=t,s}};function h(e,t){for(a=e,u=t,o=0;!l&&c&&!r&&o<f.length;o++){var r,i=f[o],h=p.p,y=i[2];e>3?(r=y===t)&&(u=i[(a=i[4])?5:(a=3,3)],i[4]=i[5]=n):i[0]<=h&&((r=e<2&&h<i[1])?(a=0,p.v=t,p.n=i[1]):h<y&&(r=e<3||i[0]>t||t>y)&&(i[4]=e,i[5]=t,p.n=y,a=0))}if(r||e>1)return s;throw l=!0,t}return function(r,f,y){if(c>1)throw TypeError("Generator is already running");for(l&&1===f&&h(f,y),a=f,u=y;(o=a<2?n:u)||!l;){i||(a?a<3?(a>1&&(p.n=-1),h(a,u)):p.n=u:p.v=u);try{if(c=2,i){if(a||(r="next"),o=i[r]){if(!(o=o.call(i,u)))throw TypeError("iterator result is not an object");if(!o.done)return o;u=o.value,a<2&&(a=0)}else 1===a&&(o=i.return)&&o.call(i),a<2&&(u=TypeError("The iterator does not provide a '"+r+"' method"),a=1);i=n}else if((o=(l=p.n<0)?u:e.call(t,p))!==s)break}catch(e){i=n,a=1,u=e}finally{c=1}}return{value:o,done:l}}}(e,i,a),!0),c}var s={};function f(){}function l(){}function p(){}o=Object.getPrototypeOf;var h=[][a]?o(o([][a]())):(t(o={},a,function(){return this}),o),y=p.prototype=f.prototype=Object.create(h);function d(e){return Object.setPrototypeOf?Object.setPrototypeOf(e,p):(e.__proto__=p,t(e,u,"GeneratorFunction")),e.prototype=Object.create(y),e}return l.prototype=p,t(y,"constructor",p),t(p,"constructor",l),l.displayName="GeneratorFunction",t(p,u,"GeneratorFunction"),t(y),t(y,u,"Generator"),t(y,a,function(){return this}),t(y,"toString",function(){return"[object Generator]"}),(e.exports=r=function(){return{w:c,m:d}},e.exports.__esModule=!0,e.exports.default=e.exports)()}e.exports=r,e.exports.__esModule=!0,e.exports.default=e.exports}(g);var x=g.exports,P={exports:{}},_={exports:{}},k={exports:{}};!function(e){var t=v,r=b;e.exports=function e(n,o){function i(e,r,a,u){try{var c=n[e](r),s=c.value;return s instanceof t?o.resolve(s.v).then(function(e){i("next",e,a,u)},function(e){i("throw",e,a,u)}):o.resolve(s).then(function(e){c.value=e,a(c)},function(e){return i("throw",e,a,u)})}catch(e){u(e)}}var a;this.next||(r(e.prototype),r(e.prototype,"function"==typeof Symbol&&Symbol.asyncIterator||"@asyncIterator",function(){return this})),r(this,"_invoke",function(e,t,r){function n(){return new o(function(t,n){i(e,r,t,n)})}return a=a?a.then(n,n):n()},!0)},e.exports.__esModule=!0,e.exports.default=e.exports}(k);var w=k.exports;!function(e){var t=x,r=w;e.exports=function(e,n,o,i,a){return new r(t().w(e,n,o,i),a||Promise)},e.exports.__esModule=!0,e.exports.default=e.exports}(_);var O=_.exports;!function(e){var t=O;e.exports=function(e,r,n,o,i){var a=t(e,r,n,o,i);return a.next().then(function(e){return e.done?e.value:a.next()})},e.exports.__esModule=!0,e.exports.default=e.exports}(P);var C=P.exports,T={exports:{}};!function(e){e.exports=function(e){var t=Object(e),r=[];for(var n in t)r.unshift(n);return function e(){for(;r.length;)if((n=r.pop())in t)return e.value=n,e.done=!1,e;return e.done=!0,e}},e.exports.__esModule=!0,e.exports.default=e.exports}(T);var j=T.exports,S={exports:{}},I={exports:{}};!function(e){function t(r){return e.exports=t="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},e.exports.__esModule=!0,e.exports.default=e.exports,t(r)}e.exports=t,e.exports.__esModule=!0,e.exports.default=e.exports}(I);var M=I.exports;!function(e){var t=M.default;e.exports=function(e){if(null!=e){var r=e["function"==typeof Symbol&&Symbol.iterator||"@@iterator"],n=0;if(r)return r.call(e);if("function"==typeof e.next)return e;if(!isNaN(e.length))return{next:function(){return e&&n>=e.length&&(e=void 0),{value:e&&e[n++],done:!e}}}}throw new TypeError(t(e)+" is not iterable")},e.exports.__esModule=!0,e.exports.default=e.exports}(S);var $=S.exports;!function(e){var t=v,r=x,n=C,o=O,i=w,a=j,u=$;function c(){var s=r(),f=s.m(c),l=(Object.getPrototypeOf?Object.getPrototypeOf(f):f.__proto__).constructor;function p(e){var t="function"==typeof e&&e.constructor;return!!t&&(t===l||"GeneratorFunction"===(t.displayName||t.name))}var h={throw:1,return:2,break:3,continue:3};function y(e){var t,r;return function(n){t||(t={stop:function(){return r(n.a,2)},catch:function(){return n.v},abrupt:function(e,t){return r(n.a,h[e],t)},delegateYield:function(e,o,i){return t.resultName=o,r(n.d,u(e),i)},finish:function(e){return r(n.f,e)}},r=function(e,r,o){n.p=t.prev,n.n=t.next;try{return e(r,o)}finally{t.next=n.n}}),t.resultName&&(t[t.resultName]=n.v,t.resultName=void 0),t.sent=n.v,t.next=n.n;try{return e.call(this,t)}finally{n.p=t.prev,n.n=t.next}}}return(e.exports=c=function(){return{wrap:function(e,t,r,n){return s.w(y(e),t,r,n&&n.reverse())},isGeneratorFunction:p,mark:s.m,awrap:function(e,r){return new t(e,r)},AsyncIterator:i,async:function(e,t,r,i,a){return(p(t)?o:n)(y(e),t,r,i,a)},keys:a,values:u}},e.exports.__esModule=!0,e.exports.default=e.exports)()}e.exports=c,e.exports.__esModule=!0,e.exports.default=e.exports}(y);var E=(0,y.exports)(),L=E;try{regeneratorRuntime=E}catch(e){"object"==typeof globalThis?globalThis.regeneratorRuntime=E:Function("r","regeneratorRuntime = r")(E)}var U=p(L),D="",A="https://log.cdyrjygs.com/binlog",N="https://crbt.cdyrjygs.com/cms-vrbt";function R(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),r.push.apply(r,n)}return r}function q(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{};t%2?R(Object(r),!0).forEach(function(t){l(e,t,r[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):R(Object(r)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))})}return e}var B=function(){return f(function e(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};u(this,e),this.config={baseURL:t.baseURL||"",timeout:t.timeout||1e4,header:q({"Content-Type":"application/json"},t.header)}},[{key:"requestInterceptor",value:function(e){return e.url=this.config.baseURL+e.url,e.timeout=e.timeout||this.config.timeout,e.header=q(q({},this.config.header),e.header),e}},{key:"responseInterceptor",value:function(e){if(200===e.statusCode)return Promise.resolve(e.data);var t={code:e.statusCode,message:e.data.message||"请求失败"};return uni.showToast({title:t.message,icon:"none",duration:2e3}),Promise.reject(t)}},{key:"request",value:function(e){var t=this;return e=this.requestInterceptor(e),new Promise(function(r,n){uni.request(q(q({},e),{},{success:function(o){try{var i=t.responseInterceptor(o,e);r(i)}catch(e){n(e)}},fail:function(e){var t={code:e.errMsg?-1:-2,message:e.errMsg||"网络请求失败"};uni.showToast({title:t.message,icon:"none",duration:2e3}),n(t)}}))})}},{key:"get",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};return this.request(q({url:e,data:t,method:"GET"},r))}},{key:"post",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};return this.request(q({url:e,data:t,method:"POST"},r))}},{key:"put",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};return this.request(q({url:e,data:t,method:"PUT"},r))}},{key:"delete",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};return this.request(q({url:e,data:t,method:"DELETE"},r))}},{key:"setBaseURL",value:function(e){this.config.baseURL=e}},{key:"setHeader",value:function(e){this.config.header=q(q({},this.config.header),e)}}])}();new B;var F=new B({baseURL:D,timeout:1e4,header:{"Content-Type":"application/json"}}),G=function(e,t){return F.get(e,t)};function z(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),r.push.apply(r,n)}return r}function J(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{};t%2?z(Object(r),!0).forEach(function(t){l(e,t,r[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):z(Object(r)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))})}return e}var V=function(){return f(function e(){u(this,e)},null,[{key:"init",value:(r=a(U.mark(function e(t){var r=this;return U.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=1,this._updateNetworkType();case 1:return this.launchTime=Date.now(),this.config=J(J({},this.config),t),e.next=2,this.getBaseInf();case 2:return this.MiniProBaseInfo=e.sent,this.launchOptions=this.getLaunchOptionsSync(),this.cachedUserInfo=this.getUserInfo(),e.next=3,this._getOpenId();case 3:uni.onNetworkStatusChange(function(e){r.networkType=e.networkType||""}),this.initialized=!0,this.report({name:"initEvent",action:"埋点初始化"}),this._executeCachedApiCalls();case 4:case"end":return e.stop()}},e,this)})),function(e){return r.apply(this,arguments)})},{key:"getPrimaryCategory",value:function(){return this.primaryCategory}},{key:"setPrimaryCategory",value:function(e,t){this._setCategory(e,t,"primaryCategory","一级栏目")}},{key:"getSecondaryCategory",value:function(){return this.secondaryCategory}},{key:"setSecondaryCategory",value:function(e,t){this._setCategory(e,t,"secondaryCategory","二级栏目")}},{key:"_setCategory",value:function(e,t,r,n){if(Array.isArray(e)&&0!==e.length)if("number"!=typeof t||t<0||t>=e.length)this[r]="";else{var o=e[t];o&&"string"==typeof o.title&&""!==o.title.trim()?this[r]=o.title:this[r]=""}else this[r]=""}},{key:"resetCategory",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"secondary",t=arguments.length>1?arguments[1]:void 0;if(["primary","secondary","both"].includes(e))if(void 0!==t){if("both"===e){if("string"!=typeof t&&("object"!==n(t)||null===t))return;if("object"===n(t)){if(void 0!==t.primary&&"string"!=typeof t.primary)return;if(void 0!==t.secondary&&"string"!=typeof t.secondary)return}}else if("string"!=typeof t)return;switch(e){case"primary":this.primaryCategory=t;break;case"secondary":this.secondaryCategory=t;break;case"both":if("object"===n(t)&&null!==t){var r=void 0!==t.primary?t.primary:"",o=void 0!==t.secondary?t.secondary:"";this.primaryCategory=r,this.secondaryCategory=o}else this.primaryCategory=t,this.secondaryCategory=t}}else switch(e){case"primary":this.primaryCategory="";break;case"secondary":this.secondaryCategory="";break;case"both":this.primaryCategory="",this.secondaryCategory=""}}},{key:"_updateNetworkType",value:function(){var e=this;return new Promise(function(t){uni.getNetworkType({success:function(r){e.networkType=r.networkType||"",t()},fail:function(r){e.networkType="",t()}})})}},{key:"_executeCachedApiCalls",value:function(){var e=this;0!==this.apiCallCache.length&&(this.apiCallCache.forEach(function(t){var r=t.method,n=t.args;try{e[r].apply(e,o(n))}catch(e){}}),this.apiCallCache=[])}},{key:"_getOpenId",value:(t=a(U.mark(function e(){var t,r,n;return U.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:return e.prev=0,e.next=1,this._getLoginCode();case 1:if(t=e.sent){e.next=2;break}return e.abrupt("return");case 2:return r="".concat(N,"/api/aiqwxq/getOpenid"),e.next=3,G(r,{code:t});case 3:n=e.sent,this.openid=(null==n?void 0:n.result)||"",e.next=5;break;case 4:e.prev=4,e.catch(0);case 5:case"end":return e.stop()}},e,this,[[0,4]])})),function(){return t.apply(this,arguments)})},{key:"_getLoginCode",value:function(){return new Promise(function(e,t){uni.login({success:function(t){t.code?e(t.code):e("")},fail:function(t){e("")}})})}},{key:"getBaseInf",value:(e=a(U.mark(function e(){var t,r,o,i,a,u,c;return U.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:if(e.prev=0,o=null===(t=this.storageDataFromMiniPro)||void 0===t||null===(t=t.systemInfo)||void 0===t?void 0:t.data){e.next=2;break}if(i="track_system_info","object"===("undefined"==typeof uni?"undefined":n(uni))&&null!==uni&&"function"==typeof uni.getStorageSync&&(o=uni.getStorageSync(i)),o||"object"!==("undefined"==typeof uni?"undefined":n(uni))||null===uni||"function"!=typeof uni.getSystemInfo){e.next=2;break}return e.next=1,uni.getSystemInfo();case 1:a=e.sent,o={system:a.system||"",uniPlatform:a.uniPlatform||"",deviceBrand:a.deviceBrand||"",deviceType:a.deviceType||""},"function"==typeof uni.setStorageSync&&uni.setStorageSync(i,o);case 2:return u=this._getMiniProgramInfo(null===(r=o)||void 0===r?void 0:r.uniPlatform),c=J(J({},o),u),e.abrupt("return",c);case 3:return e.prev=3,e.catch(0),e.abrupt("return",{system:"",uniPlatform:"",deviceBrand:"",platform:"",appId:""});case 4:case"end":return e.stop()}},e,this,[[0,3]])})),function(){return e.apply(this,arguments)})},{key:"_getMiniProgramInfo",value:function(e){var t="",r="",n="";try{if("mp-weixin"===e){var o,i,a,u=wx.getAccountInfoSync();t=(null===(o=u.miniProgram)||void 0===o?void 0:o.appId)||"",r=(null===(i=u.miniProgram)||void 0===i?void 0:i.version)||"",n=(null===(a=u.miniProgram)||void 0===a?void 0:a.envVersion)||""}else if("mp-douyin"===e){var c,s,f,l=tt.getEnvInfoSync();t=(null===(c=l.microapp)||void 0===c?void 0:c.appId)||"",r=(null===(s=l.microapp)||void 0===s?void 0:s.mpVersion)||"",n=(null===(f=l.microapp)||void 0===f?void 0:f.envType)||""}}catch(e){}return{appId:t,version:r,envVersion:n}}},{key:"getUserInfo",value:function(){try{var e,t=null===(e=this.storageDataFromMiniPro)||void 0===e||null===(e=e.userInfoDeatil)||void 0===e?void 0:e.data;return t?{userId:t.id||"",userPhone:t.mobile||""}:{userId:"",userPhone:""}}catch(e){return{userId:"",userPhone:""}}}},{key:"setUserInfo",value:function(e){if(e&&e.id)try{this.cachedUserInfo={userId:e.id||"",userPhone:e.mobile||""}}catch(e){}}},{key:"clearUserInfo",value:function(){try{this.cachedUserInfo={}}catch(e){}}},{key:"enable",value:function(){this.config.enabled=!0}},{key:"disable",value:function(){this.config.enabled=!1}},{key:"getLaunchOptionsSync",value:function(){try{var e,t,r=null===(e=this.storageDataFromMiniPro)||void 0===e||null===(e=e.appLaunchOption)||void 0===e?void 0:e.data;if(!r){if("object"!==("undefined"==typeof uni?"undefined":n(uni))||null===uni||"function"!=typeof uni.getLaunchOptionsSync)return{launchPath:"",launchScene:"",launchParams:"",subChannel:"",click_id:""};r=uni.getLaunchOptionsSync()||{}}var o=r,i=o.path,a=void 0===i?"":i,u=o.scene,c=void 0===u?"":u,s=o.query,f=void 0===s?{}:s;return{launchPath:a,launchScene:c,launchParams:Object.keys(f).length>0?JSON.stringify(f):"",subChannel:null!==(t=f.subChannel)&&void 0!==t?t:"",click_id:f.qz_gdt||f.gdt_vid||""}}catch(e){return defaultResult}}},{key:"submitTrackLog",value:function(e){var t,r;(t=this.config.reportUrl,r=e,F.post(t,r)).then(function(){}).catch(function(e){})}},{key:"_adReport",value:function(e){var t=this.launchOptions,r={adId:t.click_id,subChannel:t.subChannel,adLink:t.launchPath,adType:e,mobile:this.cachedUserInfo.userPhone,sourceChannel:this.MiniProBaseInfo.uniPlatform};(function(e,t){return F.get(e,t)})("".concat(N,"/api/aiqwxq/adReport"),r).then(function(e){}).catch(function(e){})}},{key:"report",value:function(e){if(this.initialized){var t=J(J(J(J({launchTime:this.launchTime,currentTime:Date.now()},this.launchOptions),this.MiniProBaseInfo),this.cachedUserInfo),{},{openid:this.openid,networkType:this.networkType},e);this.submitTrackLog(t)}else this.apiCallCache.push({method:"report",args:[e]})}},{key:"customReport",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:"clickEvent",n=!(arguments.length>3&&void 0!==arguments[3])||arguments[3];if(this.config.enabled&&e&&r){var o={action:e,name:r};if(n){var i=J(J({},this.primaryCategory&&{primaryCategory:this.primaryCategory}),this.secondaryCategory&&{secondaryCategory:this.secondaryCategory});Object.assign(o,i)}t&&Object.keys(t).length>0&&(o.data=JSON.stringify(t)),this.report(o)}}}]);var e,t,r}();l(V,"config",{reportUrl:A,enabled:!0}),l(V,"initialized",!1),l(V,"apiCallCache",[]),l(V,"storageDataFromMiniPro",function(){try{return function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};try{return e&&"string"==typeof e?JSON.parse(e):t}catch(e){return t}}(uni.getStorageSync("storageName"),{})}catch(e){return{}}}()),l(V,"launchTime",null),l(V,"cachedNetworkType",""),l(V,"MiniProBaseInfo",{}),l(V,"networkType",""),l(V,"launchOptions",{}),l(V,"openid",""),l(V,"primaryCategory",""),l(V,"secondaryCategory","");var H={onLoad:function(e){var t=function(){var e=[];try{if("harmonyos"===process.env.UNI_PLATFORM){var t=uni.getAppPageManager();t&&"function"==typeof t.getPages&&(e=t.getPages()||[])}else"object"===("undefined"==typeof uni?"undefined":n(uni))&&null!==uni&&"function"==typeof uni.getCurrentPages&&(e=uni.getCurrentPages()||[])}catch(e){}return e}(),r=function(e,t){var r="";return e&&(e.route?r=e.route:e.__route__?r=e.__route__:e.path?r=e.path:t&&"object"===n(t)&&null!==t&&(t.route?r=t.route:t.__route__?r=t.__route__:t.path&&(r=t.path))),r}(t[t.length-1]||{},this.$scope);V.currentPagePath=r||"";var o={trackType:"pageview",viewPagePath:r||"",viewPageLoadTime:Date.now(),viewPageParams:e||{}};this.$pageTrackCache=o},onUnload:function(){this._reportPageTrack()},onHide:function(){this._reportPageTrack()},onShow:function(){this.$pageTrackCache&&(this.$pageTrackCache.lastShowTime=Date.now()),this.$pageTrackCache&&this.$pageTrackCache.viewPagePath&&(V.currentPagePath=this.$pageTrackCache.viewPagePath)},methods:{_reportPageTrack:function(){if(this.$pageTrackCache){var e=this.$pageTrackCache.lastShowTime||this.$pageTrackCache.viewPageLoadTime,t=Date.now(),r=t-e,n={path:this.$pageTrackCache.viewPagePath||"",loadTime:this.$pageTrackCache.viewPageLoadTime||Date.now(),leaveTime:t,params:this.$pageTrackCache.viewPageParams||{},stayTime:r};V.customReport("页面曝光",n,"pageviewEvent",!1)}}}},Y=!1;function K(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};if(!Y&&(Y=!0,V.init(t),e.config.globalProperties.$Track=V,e.mixin(H),uni.$Track=V,"object"===("undefined"==typeof uni?"undefined":n(uni))&&null!==uni)){["navigateTo","redirectTo","reLaunch","switchTab","navigateBack"].forEach(function(e){if("function"==typeof uni[e]){var t=uni[e];uni[e]=function(o){try{var i="";if("function"==typeof uni.getCurrentPages){var a=uni.getCurrentPages()||[],u=a[a.length-1]||{};i=u.route||u.__route__||u.path||""}if(!i&&V.currentPagePath&&(i=V.currentPagePath),!i&&"function"==typeof getApp)try{var c=getApp();if(c&&c._pages&&c._pages.length>0){var s=c._pages[c._pages.length-1]||{};i=s.route||s.__route__||s.path||""}else if(c&&c.$vm&&c.$vm.$page){var f=c.$vm.$page;i=f.route||f.__route__||f.path||""}}catch(e){}if(!i)try{if(uni.$app&&uni.$app._pages&&uni.$app._pages.length>0){var l=uni.$app._pages[uni.$app._pages.length-1]||{};i=l.route||l.__route__||l.path||""}}catch(e){}var p="",h={};if("navigateBack"===e)p="back",h={delta:o||1};else if("object"===n(o)&&null!==o){if((p=o.url||"").includes("?")){var y=r(p.split("?"),2),d=y[0],v=y[1];p=d,h=v.split("&").reduce(function(e,t){var n=r(t.split("="),2),o=n[0],i=n[1];return o&&(e[o]=decodeURIComponent(i||"")),e},{})}Object.keys(o).forEach(function(e){"url"!==e&&"success"!==e&&"fail"!==e&&"complete"!==e&&(h[e]=o[e])})}var g={currentPagePath:i||"",targetPagePath:p||"",navigationParams:h||{}};V.customReport("页面跳转",g,"navigationEvent",!1)}catch(e){}return t.call(uni,o)}}})}}var Q={install:K,Track:V,trackPageMixin:H};exports.Track=V,exports.default=Q,exports.install=K,exports.trackPageMixin=H;
|
package/dist/index.esm.js
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
function e(e,t){(null==t||t>e.length)&&(t=e.length);for(var r=0,n=Array(t);r<t;r++)n[r]=e[r];return n}function t(t,r){if(t){if("string"==typeof t)return e(t,r);var n={}.toString.call(t).slice(8,-1);return"Object"===n&&t.constructor&&(n=t.constructor.name),"Map"===n||"Set"===n?Array.from(t):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?e(t,r):void 0}}function r(e,r){return function(e){if(Array.isArray(e))return e}(e)||function(e,t){var r=null==e?null:"undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=r){var n,o,i,a,u=[],c=!0,s=!1;try{if(i=(r=r.call(e)).next,0===t){if(Object(r)!==r)return;c=!1}else for(;!(c=(n=i.call(r)).done)&&(u.push(n.value),u.length!==t);c=!0);}catch(e){s=!0,o=e}finally{try{if(!c&&null!=r.return&&(a=r.return(),Object(a)!==a))return}finally{if(s)throw o}}return u}}(e,r)||t(e,r)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function n(e){return n="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},n(e)}function o(r){return function(t){if(Array.isArray(t))return e(t)}(r)||function(e){if("undefined"!=typeof Symbol&&null!=e[Symbol.iterator]||null!=e["@@iterator"])return Array.from(e)}(r)||t(r)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function i(e,t,r,n,o,i,a){try{var u=e[i](a),c=u.value}catch(e){return void r(e)}u.done?t(c):Promise.resolve(c).then(n,o)}function a(e){return function(){var t=this,r=arguments;return new Promise(function(n,o){var a=e.apply(t,r);function u(e){i(a,n,o,u,c,"next",e)}function c(e){i(a,n,o,u,c,"throw",e)}u(void 0)})}}function u(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function c(e){var t=function(e,t){if("object"!=n(e)||!e)return e;var r=e[Symbol.toPrimitive];if(void 0!==r){var o=r.call(e,t||"default");if("object"!=n(o))return o;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===t?String:Number)(e)}(e,"string");return"symbol"==n(t)?t:t+""}function s(e,t){for(var r=0;r<t.length;r++){var n=t[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,c(n.key),n)}}function f(e,t,r){return t&&s(e.prototype,t),r&&s(e,r),Object.defineProperty(e,"prototype",{writable:!1}),e}function l(e,t,r){return(t=c(t))in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}function p(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}var y
|
|
1
|
+
function e(e,t){(null==t||t>e.length)&&(t=e.length);for(var r=0,n=Array(t);r<t;r++)n[r]=e[r];return n}function t(t,r){if(t){if("string"==typeof t)return e(t,r);var n={}.toString.call(t).slice(8,-1);return"Object"===n&&t.constructor&&(n=t.constructor.name),"Map"===n||"Set"===n?Array.from(t):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?e(t,r):void 0}}function r(e,r){return function(e){if(Array.isArray(e))return e}(e)||function(e,t){var r=null==e?null:"undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=r){var n,o,i,a,u=[],c=!0,s=!1;try{if(i=(r=r.call(e)).next,0===t){if(Object(r)!==r)return;c=!1}else for(;!(c=(n=i.call(r)).done)&&(u.push(n.value),u.length!==t);c=!0);}catch(e){s=!0,o=e}finally{try{if(!c&&null!=r.return&&(a=r.return(),Object(a)!==a))return}finally{if(s)throw o}}return u}}(e,r)||t(e,r)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function n(e){return n="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},n(e)}function o(r){return function(t){if(Array.isArray(t))return e(t)}(r)||function(e){if("undefined"!=typeof Symbol&&null!=e[Symbol.iterator]||null!=e["@@iterator"])return Array.from(e)}(r)||t(r)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function i(e,t,r,n,o,i,a){try{var u=e[i](a),c=u.value}catch(e){return void r(e)}u.done?t(c):Promise.resolve(c).then(n,o)}function a(e){return function(){var t=this,r=arguments;return new Promise(function(n,o){var a=e.apply(t,r);function u(e){i(a,n,o,u,c,"next",e)}function c(e){i(a,n,o,u,c,"throw",e)}u(void 0)})}}function u(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function c(e){var t=function(e,t){if("object"!=n(e)||!e)return e;var r=e[Symbol.toPrimitive];if(void 0!==r){var o=r.call(e,t||"default");if("object"!=n(o))return o;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===t?String:Number)(e)}(e,"string");return"symbol"==n(t)?t:t+""}function s(e,t){for(var r=0;r<t.length;r++){var n=t[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,c(n.key),n)}}function f(e,t,r){return t&&s(e.prototype,t),r&&s(e,r),Object.defineProperty(e,"prototype",{writable:!1}),e}function l(e,t,r){return(t=c(t))in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}function p(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}var h,y={exports:{}},d={exports:{}};(h=d).exports=function(e,t){this.v=e,this.k=t},h.exports.__esModule=!0,h.exports.default=h.exports;var v=d.exports,g={exports:{}},m={exports:{}};!function(e){function t(r,n,o,i){var a=Object.defineProperty;try{a({},"",{})}catch(r){a=0}e.exports=t=function(e,r,n,o){function i(r,n){t(e,r,function(e){return this._invoke(r,n,e)})}r?a?a(e,r,{value:n,enumerable:!o,configurable:!o,writable:!o}):e[r]=n:(i("next",0),i("throw",1),i("return",2))},e.exports.__esModule=!0,e.exports.default=e.exports,t(r,n,o,i)}e.exports=t,e.exports.__esModule=!0,e.exports.default=e.exports}(m);var b=m.exports;!function(e){var t=b;function r(){
|
|
2
2
|
/*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/babel/babel/blob/main/packages/babel-helpers/LICENSE */
|
|
3
|
-
var n,o,i="function"==typeof Symbol?Symbol:{},a=i.iterator||"@@iterator",u=i.toStringTag||"@@toStringTag";function c(e,r,i,a){var u=r&&r.prototype instanceof f?r:f,c=Object.create(u.prototype);return t(c,"_invoke",function(e,t,r){var i,a,u,c=0,f=r||[],l=!1,p={p:0,n:0,v:n,a:y,f:y.bind(n,4),d:function(e,t){return i=e,a=0,u=n,p.n=t,s}};function y(e,t){for(a=e,u=t,o=0;!l&&c&&!r&&o<f.length;o++){var r,i=f[o],y=p.p,h=i[2];e>3?(r=h===t)&&(u=i[(a=i[4])?5:(a=3,3)],i[4]=i[5]=n):i[0]<=y&&((r=e<2&&y<i[1])?(a=0,p.v=t,p.n=i[1]):y<h&&(r=e<3||i[0]>t||t>h)&&(i[4]=e,i[5]=t,p.n=h,a=0))}if(r||e>1)return s;throw l=!0,t}return function(r,f,h){if(c>1)throw TypeError("Generator is already running");for(l&&1===f&&y(f,h),a=f,u=h;(o=a<2?n:u)||!l;){i||(a?a<3?(a>1&&(p.n=-1),y(a,u)):p.n=u:p.v=u);try{if(c=2,i){if(a||(r="next"),o=i[r]){if(!(o=o.call(i,u)))throw TypeError("iterator result is not an object");if(!o.done)return o;u=o.value,a<2&&(a=0)}else 1===a&&(o=i.return)&&o.call(i),a<2&&(u=TypeError("The iterator does not provide a '"+r+"' method"),a=1);i=n}else if((o=(l=p.n<0)?u:e.call(t,p))!==s)break}catch(e){i=n,a=1,u=e}finally{c=1}}return{value:o,done:l}}}(e,i,a),!0),c}var s={};function f(){}function l(){}function p(){}o=Object.getPrototypeOf;var y=[][a]?o(o([][a]())):(t(o={},a,function(){return this}),o),h=p.prototype=f.prototype=Object.create(y);function d(e){return Object.setPrototypeOf?Object.setPrototypeOf(e,p):(e.__proto__=p,t(e,u,"GeneratorFunction")),e.prototype=Object.create(h),e}return l.prototype=p,t(h,"constructor",p),t(p,"constructor",l),l.displayName="GeneratorFunction",t(p,u,"GeneratorFunction"),t(h),t(h,u,"Generator"),t(h,a,function(){return this}),t(h,"toString",function(){return"[object Generator]"}),(e.exports=r=function(){return{w:c,m:d}},e.exports.__esModule=!0,e.exports.default=e.exports)()}e.exports=r,e.exports.__esModule=!0,e.exports.default=e.exports}(g);var x=g.exports,_={exports:{}},P={exports:{}},k={exports:{}};!function(e){var t=v,r=b;e.exports=function e(n,o){function i(e,r,a,u){try{var c=n[e](r),s=c.value;return s instanceof t?o.resolve(s.v).then(function(e){i("next",e,a,u)},function(e){i("throw",e,a,u)}):o.resolve(s).then(function(e){c.value=e,a(c)},function(e){return i("throw",e,a,u)})}catch(e){u(e)}}var a;this.next||(r(e.prototype),r(e.prototype,"function"==typeof Symbol&&Symbol.asyncIterator||"@asyncIterator",function(){return this})),r(this,"_invoke",function(e,t,r){function n(){return new o(function(t,n){i(e,r,t,n)})}return a=a?a.then(n,n):n()},!0)},e.exports.__esModule=!0,e.exports.default=e.exports}(k);var w=k.exports;!function(e){var t=x,r=w;e.exports=function(e,n,o,i,a){return new r(t().w(e,n,o,i),a||Promise)},e.exports.__esModule=!0,e.exports.default=e.exports}(P);var O=P.exports;!function(e){var t=O;e.exports=function(e,r,n,o,i){var a=t(e,r,n,o,i);return a.next().then(function(e){return e.done?e.value:a.next()})},e.exports.__esModule=!0,e.exports.default=e.exports}(_);var T=_.exports,C={exports:{}};!function(e){e.exports=function(e){var t=Object(e),r=[];for(var n in t)r.unshift(n);return function e(){for(;r.length;)if((n=r.pop())in t)return e.value=n,e.done=!1,e;return e.done=!0,e}},e.exports.__esModule=!0,e.exports.default=e.exports}(C);var j=C.exports,S={exports:{}},I={exports:{}};!function(e){function t(r){return e.exports=t="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},e.exports.__esModule=!0,e.exports.default=e.exports,t(r)}e.exports=t,e.exports.__esModule=!0,e.exports.default=e.exports}(I);var M=I.exports;!function(e){var t=M.default;e.exports=function(e){if(null!=e){var r=e["function"==typeof Symbol&&Symbol.iterator||"@@iterator"],n=0;if(r)return r.call(e);if("function"==typeof e.next)return e;if(!isNaN(e.length))return{next:function(){return e&&n>=e.length&&(e=void 0),{value:e&&e[n++],done:!e}}}}throw new TypeError(t(e)+" is not iterable")},e.exports.__esModule=!0,e.exports.default=e.exports}(S);var $=S.exports;!function(e){var t=v,r=x,n=T,o=O,i=w,a=j,u=$;function c(){var s=r(),f=s.m(c),l=(Object.getPrototypeOf?Object.getPrototypeOf(f):f.__proto__).constructor;function p(e){var t="function"==typeof e&&e.constructor;return!!t&&(t===l||"GeneratorFunction"===(t.displayName||t.name))}var y={throw:1,return:2,break:3,continue:3};function h(e){var t,r;return function(n){t||(t={stop:function(){return r(n.a,2)},catch:function(){return n.v},abrupt:function(e,t){return r(n.a,y[e],t)},delegateYield:function(e,o,i){return t.resultName=o,r(n.d,u(e),i)},finish:function(e){return r(n.f,e)}},r=function(e,r,o){n.p=t.prev,n.n=t.next;try{return e(r,o)}finally{t.next=n.n}}),t.resultName&&(t[t.resultName]=n.v,t.resultName=void 0),t.sent=n.v,t.next=n.n;try{return e.call(this,t)}finally{n.p=t.prev,n.n=t.next}}}return(e.exports=c=function(){return{wrap:function(e,t,r,n){return s.w(h(e),t,r,n&&n.reverse())},isGeneratorFunction:p,mark:s.m,awrap:function(e,r){return new t(e,r)},AsyncIterator:i,async:function(e,t,r,i,a){return(p(t)?o:n)(h(e),t,r,i,a)},keys:a,values:u}},e.exports.__esModule=!0,e.exports.default=e.exports)()}e.exports=c,e.exports.__esModule=!0,e.exports.default=e.exports}(h);var E=(0,h.exports)(),L=E;try{regeneratorRuntime=E}catch(e){"object"==typeof globalThis?globalThis.regeneratorRuntime=E:Function("r","regeneratorRuntime = r")(E)}var U=p(L),A="",D="https://log.cdyrjygs.com/binlog",N="https://crbt.cdyrjygs.com/cms-vrbt";function R(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),r.push.apply(r,n)}return r}function q(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{};t%2?R(Object(r),!0).forEach(function(t){l(e,t,r[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):R(Object(r)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))})}return e}var B=function(){return f(function e(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};u(this,e),this.config={baseURL:t.baseURL||"",timeout:t.timeout||1e4,header:q({"Content-Type":"application/json"},t.header)}},[{key:"requestInterceptor",value:function(e){return e.url=this.config.baseURL+e.url,e.timeout=e.timeout||this.config.timeout,e.header=q(q({},this.config.header),e.header),e}},{key:"responseInterceptor",value:function(e){if(200===e.statusCode)return Promise.resolve(e.data);var t={code:e.statusCode,message:e.data.message||"请求失败"};return uni.showToast({title:t.message,icon:"none",duration:2e3}),Promise.reject(t)}},{key:"request",value:function(e){var t=this;return e=this.requestInterceptor(e),new Promise(function(r,n){uni.request(q(q({},e),{},{success:function(o){try{var i=t.responseInterceptor(o,e);r(i)}catch(e){n(e)}},fail:function(e){var t={code:e.errMsg?-1:-2,message:e.errMsg||"网络请求失败"};uni.showToast({title:t.message,icon:"none",duration:2e3}),n(t)}}))})}},{key:"get",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};return this.request(q({url:e,data:t,method:"GET"},r))}},{key:"post",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};return this.request(q({url:e,data:t,method:"POST"},r))}},{key:"put",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};return this.request(q({url:e,data:t,method:"PUT"},r))}},{key:"delete",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};return this.request(q({url:e,data:t,method:"DELETE"},r))}},{key:"setBaseURL",value:function(e){this.config.baseURL=e}},{key:"setHeader",value:function(e){this.config.header=q(q({},this.config.header),e)}}])}();new B;var F=new B({baseURL:A,timeout:1e4,header:{"Content-Type":"application/json"}}),G=function(e,t){return F.get(e,t)};function z(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),r.push.apply(r,n)}return r}function J(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{};t%2?z(Object(r),!0).forEach(function(t){l(e,t,r[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):z(Object(r)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))})}return e}var V=function(){return f(function e(){u(this,e)},null,[{key:"init",value:(r=a(U.mark(function e(t){var r=this;return U.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=1,this._updateNetworkType();case 1:return this.launchTime=Date.now(),this.config=J(J({},this.config),t),e.next=2,this.getBaseInf();case 2:return this.MiniProBaseInfo=e.sent,this.launchOptions=this.getLaunchOptionsSync(),this.cachedUserInfo=this.getUserInfo(),e.next=3,this._getOpenId();case 3:uni.onNetworkStatusChange(function(e){r.networkType=e.networkType||""}),this.initialized=!0,this.report({name:"initEvent",action:"埋点初始化"}),this._executeCachedApiCalls();case 4:case"end":return e.stop()}},e,this)})),function(e){return r.apply(this,arguments)})},{key:"getPrimaryCategory",value:function(){return this.primaryCategory}},{key:"setPrimaryCategory",value:function(e,t){this._setCategory(e,t,"primaryCategory","一级栏目")}},{key:"getSecondaryCategory",value:function(){return this.secondaryCategory}},{key:"setSecondaryCategory",value:function(e,t){this._setCategory(e,t,"secondaryCategory","二级栏目")}},{key:"_setCategory",value:function(e,t,r,n){if(Array.isArray(e)&&0!==e.length)if("number"!=typeof t||t<0||t>=e.length)this[r]="";else{var o=e[t];o&&"string"==typeof o.title&&""!==o.title.trim()?this[r]=o.title:this[r]=""}else this[r]=""}},{key:"resetCategory",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"secondary",t=arguments.length>1?arguments[1]:void 0;if(["primary","secondary","both"].includes(e))if(void 0!==t){if("both"===e){if("string"!=typeof t&&("object"!==n(t)||null===t))return;if("object"===n(t)){if(void 0!==t.primary&&"string"!=typeof t.primary)return;if(void 0!==t.secondary&&"string"!=typeof t.secondary)return}}else if("string"!=typeof t)return;switch(e){case"primary":this.primaryCategory=t;break;case"secondary":this.secondaryCategory=t;break;case"both":if("object"===n(t)&&null!==t){var r=void 0!==t.primary?t.primary:"",o=void 0!==t.secondary?t.secondary:"";this.primaryCategory=r,this.secondaryCategory=o}else this.primaryCategory=t,this.secondaryCategory=t}}else switch(e){case"primary":this.primaryCategory="";break;case"secondary":this.secondaryCategory="";break;case"both":this.primaryCategory="",this.secondaryCategory=""}}},{key:"_updateNetworkType",value:function(){var e=this;return new Promise(function(t){uni.getNetworkType({success:function(r){e.networkType=r.networkType||"",t()},fail:function(r){e.networkType="",t()}})})}},{key:"_executeCachedApiCalls",value:function(){var e=this;0!==this.apiCallCache.length&&(this.apiCallCache.forEach(function(t){var r=t.method,n=t.args;try{e[r].apply(e,o(n))}catch(e){}}),this.apiCallCache=[])}},{key:"_getOpenId",value:(t=a(U.mark(function e(){var t,r,n;return U.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:return e.prev=0,e.next=1,this._getLoginCode();case 1:if(t=e.sent){e.next=2;break}return e.abrupt("return");case 2:return r="".concat(N,"/api/aiqwxq/getOpenid"),e.next=3,G(r,{code:t});case 3:n=e.sent,this.openid=(null==n?void 0:n.result)||"",e.next=5;break;case 4:e.prev=4,e.catch(0);case 5:case"end":return e.stop()}},e,this,[[0,4]])})),function(){return t.apply(this,arguments)})},{key:"_getLoginCode",value:function(){return new Promise(function(e,t){uni.login({success:function(t){t.code?e(t.code):e("")},fail:function(t){e("")}})})}},{key:"getBaseInf",value:(e=a(U.mark(function e(){var t,r,o,i,a,u,c;return U.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:if(e.prev=0,o=null===(t=this.storageDataFromMiniPro)||void 0===t||null===(t=t.systemInfo)||void 0===t?void 0:t.data){e.next=2;break}if(i="track_system_info","object"===("undefined"==typeof uni?"undefined":n(uni))&&null!==uni&&"function"==typeof uni.getStorageSync&&(o=uni.getStorageSync(i)),o||"object"!==("undefined"==typeof uni?"undefined":n(uni))||null===uni||"function"!=typeof uni.getSystemInfo){e.next=2;break}return e.next=1,uni.getSystemInfo();case 1:a=e.sent,o={system:a.system||"",uniPlatform:a.uniPlatform||"",deviceBrand:a.deviceBrand||"",deviceType:a.deviceType||""},"function"==typeof uni.setStorageSync&&uni.setStorageSync(i,o);case 2:return u=this._getMiniProgramInfo(null===(r=o)||void 0===r?void 0:r.uniPlatform),c=J(J({},o),u),e.abrupt("return",c);case 3:return e.prev=3,e.catch(0),e.abrupt("return",{system:"",uniPlatform:"",deviceBrand:"",platform:"",appId:""});case 4:case"end":return e.stop()}},e,this,[[0,3]])})),function(){return e.apply(this,arguments)})},{key:"_getMiniProgramInfo",value:function(e){var t="",r="",n="";try{if("mp-weixin"===e){var o,i,a,u=wx.getAccountInfoSync();t=(null===(o=u.miniProgram)||void 0===o?void 0:o.appId)||"",r=(null===(i=u.miniProgram)||void 0===i?void 0:i.version)||"",n=(null===(a=u.miniProgram)||void 0===a?void 0:a.envVersion)||""}else if("mp-douyin"===e){var c,s,f,l=tt.getEnvInfoSync();t=(null===(c=l.microapp)||void 0===c?void 0:c.appId)||"",r=(null===(s=l.microapp)||void 0===s?void 0:s.mpVersion)||"",n=(null===(f=l.microapp)||void 0===f?void 0:f.envType)||""}}catch(e){}return{appId:t,version:r,envVersion:n}}},{key:"getUserInfo",value:function(){try{var e,t=null===(e=this.storageDataFromMiniPro)||void 0===e||null===(e=e.userInfoDeatil)||void 0===e?void 0:e.data;return t?{userId:t.id||"",userPhone:t.mobile||""}:{userId:"",userPhone:""}}catch(e){return{userId:"",userPhone:""}}}},{key:"setUserInfo",value:function(e){if(e&&e.id)try{this.cachedUserInfo={userId:e.id||"",userPhone:e.mobile||""}}catch(e){}}},{key:"clearUserInfo",value:function(){try{this.cachedUserInfo={}}catch(e){}}},{key:"enable",value:function(){this.config.enabled=!0}},{key:"disable",value:function(){this.config.enabled=!1}},{key:"getLaunchOptionsSync",value:function(){try{if("object"===("undefined"==typeof uni?"undefined":n(uni))&&null!==uni&&"function"==typeof uni.getLaunchOptionsSync){var e,t=uni.getLaunchOptionsSync()||{},r=t.path,o=t.scene,i=t.query;return{launchPath:null!=r?r:"",launchScene:null!=o?o:"",launchParams:Object.keys(i).length>0?JSON.stringify(i):"",subChannel:null!==(e=i.subChannel)&&void 0!==e?e:"",click_id:i.qz_gdt||i.gdt_vid||""}}return{}}catch(e){return{}}}},{key:"submitTrackLog",value:function(e){var t,r;(t=this.config.reportUrl,r=e,F.post(t,r)).then(function(){}).catch(function(e){})}},{key:"_adReport",value:function(e){var t=this.launchOptions,r={adId:t.click_id,subChannel:t.subChannel,adLink:t.launchPath,adType:e,mobile:this.cachedUserInfo.userPhone};(function(e,t){return F.get(e,t)})("".concat(N,"/api/aiqwxq/adReport"),r).then(function(e){}).catch(function(e){})}},{key:"report",value:function(e){if(this.initialized){var t=J(J(J(J({launchTime:this.launchTime,currentTime:Date.now()},this.launchOptions),this.MiniProBaseInfo),this.cachedUserInfo),{},{openid:this.openid,networkType:this.networkType},e);this.submitTrackLog(t)}else this.apiCallCache.push({method:"report",args:[e]})}},{key:"customReport",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:"clickEvent",n=!(arguments.length>3&&void 0!==arguments[3])||arguments[3];if(this.config.enabled&&e&&r){var o={action:e,name:r};if(n){var i=J(J({},this.primaryCategory&&{primaryCategory:this.primaryCategory}),this.secondaryCategory&&{secondaryCategory:this.secondaryCategory});Object.assign(o,i)}t&&Object.keys(t).length>0&&(o.data=JSON.stringify(t)),this.report(o)}}}]);var e,t,r}();l(V,"config",{reportUrl:D,enabled:!0}),l(V,"initialized",!1),l(V,"apiCallCache",[]),l(V,"storageDataFromMiniPro",function(){try{return function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};try{return e&&"string"==typeof e?JSON.parse(e):t}catch(e){return t}}(uni.getStorageSync("storageName"),{})}catch(e){return{}}}()),l(V,"launchTime",null),l(V,"cachedNetworkType",""),l(V,"MiniProBaseInfo",{}),l(V,"networkType",""),l(V,"launchOptions",{}),l(V,"openid",""),l(V,"primaryCategory",""),l(V,"secondaryCategory","");var H={onLoad:function(e){var t=function(){var e=[];try{if("harmonyos"===process.env.UNI_PLATFORM){var t=uni.getAppPageManager();t&&"function"==typeof t.getPages&&(e=t.getPages()||[])}else"object"===("undefined"==typeof uni?"undefined":n(uni))&&null!==uni&&"function"==typeof uni.getCurrentPages&&(e=uni.getCurrentPages()||[])}catch(e){}return e}(),r=function(e,t){var r="";return e&&(e.route?r=e.route:e.__route__?r=e.__route__:e.path?r=e.path:t&&"object"===n(t)&&null!==t&&(t.route?r=t.route:t.__route__?r=t.__route__:t.path&&(r=t.path))),r}(t[t.length-1]||{},this.$scope);V.currentPagePath=r||"";var o={trackType:"pageview",viewPagePath:r||"",viewPageLoadTime:Date.now(),viewPageParams:e||{}};this.$pageTrackCache=o},onUnload:function(){this._reportPageTrack()},onHide:function(){this._reportPageTrack()},onShow:function(){this.$pageTrackCache&&(this.$pageTrackCache.lastShowTime=Date.now()),this.$pageTrackCache&&this.$pageTrackCache.viewPagePath&&(V.currentPagePath=this.$pageTrackCache.viewPagePath)},methods:{_reportPageTrack:function(){if(this.$pageTrackCache){var e=this.$pageTrackCache.lastShowTime||this.$pageTrackCache.viewPageLoadTime,t=Date.now(),r=t-e,n={path:this.$pageTrackCache.viewPagePath||"",loadTime:this.$pageTrackCache.viewPageLoadTime||Date.now(),leaveTime:t,params:this.$pageTrackCache.viewPageParams||{},stayTime:r};V.customReport("页面曝光",n,"pageviewEvent",!1)}}}},Y=!1;function K(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};if(!Y&&(Y=!0,V.init(t),e.config.globalProperties.$Track=V,e.mixin(H),uni.$Track=V,"object"===("undefined"==typeof uni?"undefined":n(uni))&&null!==uni)){["navigateTo","redirectTo","reLaunch","switchTab","navigateBack"].forEach(function(e){if("function"==typeof uni[e]){var t=uni[e];uni[e]=function(o){try{var i="";if("function"==typeof uni.getCurrentPages){var a=uni.getCurrentPages()||[],u=a[a.length-1]||{};i=u.route||u.__route__||u.path||""}if(!i&&V.currentPagePath&&(i=V.currentPagePath),!i&&"function"==typeof getApp)try{var c=getApp();if(c&&c._pages&&c._pages.length>0){var s=c._pages[c._pages.length-1]||{};i=s.route||s.__route__||s.path||""}else if(c&&c.$vm&&c.$vm.$page){var f=c.$vm.$page;i=f.route||f.__route__||f.path||""}}catch(e){}if(!i)try{if(uni.$app&&uni.$app._pages&&uni.$app._pages.length>0){var l=uni.$app._pages[uni.$app._pages.length-1]||{};i=l.route||l.__route__||l.path||""}}catch(e){}var p="",y={};if("navigateBack"===e)p="back",y={delta:o||1};else if("object"===n(o)&&null!==o){if((p=o.url||"").includes("?")){var h=r(p.split("?"),2),d=h[0],v=h[1];p=d,y=v.split("&").reduce(function(e,t){var n=r(t.split("="),2),o=n[0],i=n[1];return o&&(e[o]=decodeURIComponent(i||"")),e},{})}Object.keys(o).forEach(function(e){"url"!==e&&"success"!==e&&"fail"!==e&&"complete"!==e&&(y[e]=o[e])})}var g={currentPagePath:i||"",targetPagePath:p||"",navigationParams:y||{}};V.customReport("页面跳转",g,"navigationEvent",!1)}catch(e){}return t.call(uni,o)}}})}}var Q={install:K,Track:V,trackPageMixin:H};export{V as Track,Q as default,K as install,H as trackPageMixin};
|
|
3
|
+
var n,o,i="function"==typeof Symbol?Symbol:{},a=i.iterator||"@@iterator",u=i.toStringTag||"@@toStringTag";function c(e,r,i,a){var u=r&&r.prototype instanceof f?r:f,c=Object.create(u.prototype);return t(c,"_invoke",function(e,t,r){var i,a,u,c=0,f=r||[],l=!1,p={p:0,n:0,v:n,a:h,f:h.bind(n,4),d:function(e,t){return i=e,a=0,u=n,p.n=t,s}};function h(e,t){for(a=e,u=t,o=0;!l&&c&&!r&&o<f.length;o++){var r,i=f[o],h=p.p,y=i[2];e>3?(r=y===t)&&(u=i[(a=i[4])?5:(a=3,3)],i[4]=i[5]=n):i[0]<=h&&((r=e<2&&h<i[1])?(a=0,p.v=t,p.n=i[1]):h<y&&(r=e<3||i[0]>t||t>y)&&(i[4]=e,i[5]=t,p.n=y,a=0))}if(r||e>1)return s;throw l=!0,t}return function(r,f,y){if(c>1)throw TypeError("Generator is already running");for(l&&1===f&&h(f,y),a=f,u=y;(o=a<2?n:u)||!l;){i||(a?a<3?(a>1&&(p.n=-1),h(a,u)):p.n=u:p.v=u);try{if(c=2,i){if(a||(r="next"),o=i[r]){if(!(o=o.call(i,u)))throw TypeError("iterator result is not an object");if(!o.done)return o;u=o.value,a<2&&(a=0)}else 1===a&&(o=i.return)&&o.call(i),a<2&&(u=TypeError("The iterator does not provide a '"+r+"' method"),a=1);i=n}else if((o=(l=p.n<0)?u:e.call(t,p))!==s)break}catch(e){i=n,a=1,u=e}finally{c=1}}return{value:o,done:l}}}(e,i,a),!0),c}var s={};function f(){}function l(){}function p(){}o=Object.getPrototypeOf;var h=[][a]?o(o([][a]())):(t(o={},a,function(){return this}),o),y=p.prototype=f.prototype=Object.create(h);function d(e){return Object.setPrototypeOf?Object.setPrototypeOf(e,p):(e.__proto__=p,t(e,u,"GeneratorFunction")),e.prototype=Object.create(y),e}return l.prototype=p,t(y,"constructor",p),t(p,"constructor",l),l.displayName="GeneratorFunction",t(p,u,"GeneratorFunction"),t(y),t(y,u,"Generator"),t(y,a,function(){return this}),t(y,"toString",function(){return"[object Generator]"}),(e.exports=r=function(){return{w:c,m:d}},e.exports.__esModule=!0,e.exports.default=e.exports)()}e.exports=r,e.exports.__esModule=!0,e.exports.default=e.exports}(g);var x=g.exports,P={exports:{}},_={exports:{}},k={exports:{}};!function(e){var t=v,r=b;e.exports=function e(n,o){function i(e,r,a,u){try{var c=n[e](r),s=c.value;return s instanceof t?o.resolve(s.v).then(function(e){i("next",e,a,u)},function(e){i("throw",e,a,u)}):o.resolve(s).then(function(e){c.value=e,a(c)},function(e){return i("throw",e,a,u)})}catch(e){u(e)}}var a;this.next||(r(e.prototype),r(e.prototype,"function"==typeof Symbol&&Symbol.asyncIterator||"@asyncIterator",function(){return this})),r(this,"_invoke",function(e,t,r){function n(){return new o(function(t,n){i(e,r,t,n)})}return a=a?a.then(n,n):n()},!0)},e.exports.__esModule=!0,e.exports.default=e.exports}(k);var w=k.exports;!function(e){var t=x,r=w;e.exports=function(e,n,o,i,a){return new r(t().w(e,n,o,i),a||Promise)},e.exports.__esModule=!0,e.exports.default=e.exports}(_);var O=_.exports;!function(e){var t=O;e.exports=function(e,r,n,o,i){var a=t(e,r,n,o,i);return a.next().then(function(e){return e.done?e.value:a.next()})},e.exports.__esModule=!0,e.exports.default=e.exports}(P);var C=P.exports,T={exports:{}};!function(e){e.exports=function(e){var t=Object(e),r=[];for(var n in t)r.unshift(n);return function e(){for(;r.length;)if((n=r.pop())in t)return e.value=n,e.done=!1,e;return e.done=!0,e}},e.exports.__esModule=!0,e.exports.default=e.exports}(T);var j=T.exports,S={exports:{}},I={exports:{}};!function(e){function t(r){return e.exports=t="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},e.exports.__esModule=!0,e.exports.default=e.exports,t(r)}e.exports=t,e.exports.__esModule=!0,e.exports.default=e.exports}(I);var M=I.exports;!function(e){var t=M.default;e.exports=function(e){if(null!=e){var r=e["function"==typeof Symbol&&Symbol.iterator||"@@iterator"],n=0;if(r)return r.call(e);if("function"==typeof e.next)return e;if(!isNaN(e.length))return{next:function(){return e&&n>=e.length&&(e=void 0),{value:e&&e[n++],done:!e}}}}throw new TypeError(t(e)+" is not iterable")},e.exports.__esModule=!0,e.exports.default=e.exports}(S);var $=S.exports;!function(e){var t=v,r=x,n=C,o=O,i=w,a=j,u=$;function c(){var s=r(),f=s.m(c),l=(Object.getPrototypeOf?Object.getPrototypeOf(f):f.__proto__).constructor;function p(e){var t="function"==typeof e&&e.constructor;return!!t&&(t===l||"GeneratorFunction"===(t.displayName||t.name))}var h={throw:1,return:2,break:3,continue:3};function y(e){var t,r;return function(n){t||(t={stop:function(){return r(n.a,2)},catch:function(){return n.v},abrupt:function(e,t){return r(n.a,h[e],t)},delegateYield:function(e,o,i){return t.resultName=o,r(n.d,u(e),i)},finish:function(e){return r(n.f,e)}},r=function(e,r,o){n.p=t.prev,n.n=t.next;try{return e(r,o)}finally{t.next=n.n}}),t.resultName&&(t[t.resultName]=n.v,t.resultName=void 0),t.sent=n.v,t.next=n.n;try{return e.call(this,t)}finally{n.p=t.prev,n.n=t.next}}}return(e.exports=c=function(){return{wrap:function(e,t,r,n){return s.w(y(e),t,r,n&&n.reverse())},isGeneratorFunction:p,mark:s.m,awrap:function(e,r){return new t(e,r)},AsyncIterator:i,async:function(e,t,r,i,a){return(p(t)?o:n)(y(e),t,r,i,a)},keys:a,values:u}},e.exports.__esModule=!0,e.exports.default=e.exports)()}e.exports=c,e.exports.__esModule=!0,e.exports.default=e.exports}(y);var E=(0,y.exports)(),L=E;try{regeneratorRuntime=E}catch(e){"object"==typeof globalThis?globalThis.regeneratorRuntime=E:Function("r","regeneratorRuntime = r")(E)}var U=p(L),D="",A="https://log.cdyrjygs.com/binlog",N="https://crbt.cdyrjygs.com/cms-vrbt";function R(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),r.push.apply(r,n)}return r}function q(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{};t%2?R(Object(r),!0).forEach(function(t){l(e,t,r[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):R(Object(r)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))})}return e}var B=function(){return f(function e(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};u(this,e),this.config={baseURL:t.baseURL||"",timeout:t.timeout||1e4,header:q({"Content-Type":"application/json"},t.header)}},[{key:"requestInterceptor",value:function(e){return e.url=this.config.baseURL+e.url,e.timeout=e.timeout||this.config.timeout,e.header=q(q({},this.config.header),e.header),e}},{key:"responseInterceptor",value:function(e){if(200===e.statusCode)return Promise.resolve(e.data);var t={code:e.statusCode,message:e.data.message||"请求失败"};return uni.showToast({title:t.message,icon:"none",duration:2e3}),Promise.reject(t)}},{key:"request",value:function(e){var t=this;return e=this.requestInterceptor(e),new Promise(function(r,n){uni.request(q(q({},e),{},{success:function(o){try{var i=t.responseInterceptor(o,e);r(i)}catch(e){n(e)}},fail:function(e){var t={code:e.errMsg?-1:-2,message:e.errMsg||"网络请求失败"};uni.showToast({title:t.message,icon:"none",duration:2e3}),n(t)}}))})}},{key:"get",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};return this.request(q({url:e,data:t,method:"GET"},r))}},{key:"post",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};return this.request(q({url:e,data:t,method:"POST"},r))}},{key:"put",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};return this.request(q({url:e,data:t,method:"PUT"},r))}},{key:"delete",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};return this.request(q({url:e,data:t,method:"DELETE"},r))}},{key:"setBaseURL",value:function(e){this.config.baseURL=e}},{key:"setHeader",value:function(e){this.config.header=q(q({},this.config.header),e)}}])}();new B;var F=new B({baseURL:D,timeout:1e4,header:{"Content-Type":"application/json"}}),G=function(e,t){return F.get(e,t)};function z(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),r.push.apply(r,n)}return r}function J(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{};t%2?z(Object(r),!0).forEach(function(t){l(e,t,r[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):z(Object(r)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))})}return e}var V=function(){return f(function e(){u(this,e)},null,[{key:"init",value:(r=a(U.mark(function e(t){var r=this;return U.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=1,this._updateNetworkType();case 1:return this.launchTime=Date.now(),this.config=J(J({},this.config),t),e.next=2,this.getBaseInf();case 2:return this.MiniProBaseInfo=e.sent,this.launchOptions=this.getLaunchOptionsSync(),this.cachedUserInfo=this.getUserInfo(),e.next=3,this._getOpenId();case 3:uni.onNetworkStatusChange(function(e){r.networkType=e.networkType||""}),this.initialized=!0,this.report({name:"initEvent",action:"埋点初始化"}),this._executeCachedApiCalls();case 4:case"end":return e.stop()}},e,this)})),function(e){return r.apply(this,arguments)})},{key:"getPrimaryCategory",value:function(){return this.primaryCategory}},{key:"setPrimaryCategory",value:function(e,t){this._setCategory(e,t,"primaryCategory","一级栏目")}},{key:"getSecondaryCategory",value:function(){return this.secondaryCategory}},{key:"setSecondaryCategory",value:function(e,t){this._setCategory(e,t,"secondaryCategory","二级栏目")}},{key:"_setCategory",value:function(e,t,r,n){if(Array.isArray(e)&&0!==e.length)if("number"!=typeof t||t<0||t>=e.length)this[r]="";else{var o=e[t];o&&"string"==typeof o.title&&""!==o.title.trim()?this[r]=o.title:this[r]=""}else this[r]=""}},{key:"resetCategory",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"secondary",t=arguments.length>1?arguments[1]:void 0;if(["primary","secondary","both"].includes(e))if(void 0!==t){if("both"===e){if("string"!=typeof t&&("object"!==n(t)||null===t))return;if("object"===n(t)){if(void 0!==t.primary&&"string"!=typeof t.primary)return;if(void 0!==t.secondary&&"string"!=typeof t.secondary)return}}else if("string"!=typeof t)return;switch(e){case"primary":this.primaryCategory=t;break;case"secondary":this.secondaryCategory=t;break;case"both":if("object"===n(t)&&null!==t){var r=void 0!==t.primary?t.primary:"",o=void 0!==t.secondary?t.secondary:"";this.primaryCategory=r,this.secondaryCategory=o}else this.primaryCategory=t,this.secondaryCategory=t}}else switch(e){case"primary":this.primaryCategory="";break;case"secondary":this.secondaryCategory="";break;case"both":this.primaryCategory="",this.secondaryCategory=""}}},{key:"_updateNetworkType",value:function(){var e=this;return new Promise(function(t){uni.getNetworkType({success:function(r){e.networkType=r.networkType||"",t()},fail:function(r){e.networkType="",t()}})})}},{key:"_executeCachedApiCalls",value:function(){var e=this;0!==this.apiCallCache.length&&(this.apiCallCache.forEach(function(t){var r=t.method,n=t.args;try{e[r].apply(e,o(n))}catch(e){}}),this.apiCallCache=[])}},{key:"_getOpenId",value:(t=a(U.mark(function e(){var t,r,n;return U.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:return e.prev=0,e.next=1,this._getLoginCode();case 1:if(t=e.sent){e.next=2;break}return e.abrupt("return");case 2:return r="".concat(N,"/api/aiqwxq/getOpenid"),e.next=3,G(r,{code:t});case 3:n=e.sent,this.openid=(null==n?void 0:n.result)||"",e.next=5;break;case 4:e.prev=4,e.catch(0);case 5:case"end":return e.stop()}},e,this,[[0,4]])})),function(){return t.apply(this,arguments)})},{key:"_getLoginCode",value:function(){return new Promise(function(e,t){uni.login({success:function(t){t.code?e(t.code):e("")},fail:function(t){e("")}})})}},{key:"getBaseInf",value:(e=a(U.mark(function e(){var t,r,o,i,a,u,c;return U.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:if(e.prev=0,o=null===(t=this.storageDataFromMiniPro)||void 0===t||null===(t=t.systemInfo)||void 0===t?void 0:t.data){e.next=2;break}if(i="track_system_info","object"===("undefined"==typeof uni?"undefined":n(uni))&&null!==uni&&"function"==typeof uni.getStorageSync&&(o=uni.getStorageSync(i)),o||"object"!==("undefined"==typeof uni?"undefined":n(uni))||null===uni||"function"!=typeof uni.getSystemInfo){e.next=2;break}return e.next=1,uni.getSystemInfo();case 1:a=e.sent,o={system:a.system||"",uniPlatform:a.uniPlatform||"",deviceBrand:a.deviceBrand||"",deviceType:a.deviceType||""},"function"==typeof uni.setStorageSync&&uni.setStorageSync(i,o);case 2:return u=this._getMiniProgramInfo(null===(r=o)||void 0===r?void 0:r.uniPlatform),c=J(J({},o),u),e.abrupt("return",c);case 3:return e.prev=3,e.catch(0),e.abrupt("return",{system:"",uniPlatform:"",deviceBrand:"",platform:"",appId:""});case 4:case"end":return e.stop()}},e,this,[[0,3]])})),function(){return e.apply(this,arguments)})},{key:"_getMiniProgramInfo",value:function(e){var t="",r="",n="";try{if("mp-weixin"===e){var o,i,a,u=wx.getAccountInfoSync();t=(null===(o=u.miniProgram)||void 0===o?void 0:o.appId)||"",r=(null===(i=u.miniProgram)||void 0===i?void 0:i.version)||"",n=(null===(a=u.miniProgram)||void 0===a?void 0:a.envVersion)||""}else if("mp-douyin"===e){var c,s,f,l=tt.getEnvInfoSync();t=(null===(c=l.microapp)||void 0===c?void 0:c.appId)||"",r=(null===(s=l.microapp)||void 0===s?void 0:s.mpVersion)||"",n=(null===(f=l.microapp)||void 0===f?void 0:f.envType)||""}}catch(e){}return{appId:t,version:r,envVersion:n}}},{key:"getUserInfo",value:function(){try{var e,t=null===(e=this.storageDataFromMiniPro)||void 0===e||null===(e=e.userInfoDeatil)||void 0===e?void 0:e.data;return t?{userId:t.id||"",userPhone:t.mobile||""}:{userId:"",userPhone:""}}catch(e){return{userId:"",userPhone:""}}}},{key:"setUserInfo",value:function(e){if(e&&e.id)try{this.cachedUserInfo={userId:e.id||"",userPhone:e.mobile||""}}catch(e){}}},{key:"clearUserInfo",value:function(){try{this.cachedUserInfo={}}catch(e){}}},{key:"enable",value:function(){this.config.enabled=!0}},{key:"disable",value:function(){this.config.enabled=!1}},{key:"getLaunchOptionsSync",value:function(){try{var e,t,r=null===(e=this.storageDataFromMiniPro)||void 0===e||null===(e=e.appLaunchOption)||void 0===e?void 0:e.data;if(!r){if("object"!==("undefined"==typeof uni?"undefined":n(uni))||null===uni||"function"!=typeof uni.getLaunchOptionsSync)return{launchPath:"",launchScene:"",launchParams:"",subChannel:"",click_id:""};r=uni.getLaunchOptionsSync()||{}}var o=r,i=o.path,a=void 0===i?"":i,u=o.scene,c=void 0===u?"":u,s=o.query,f=void 0===s?{}:s;return{launchPath:a,launchScene:c,launchParams:Object.keys(f).length>0?JSON.stringify(f):"",subChannel:null!==(t=f.subChannel)&&void 0!==t?t:"",click_id:f.qz_gdt||f.gdt_vid||""}}catch(e){return defaultResult}}},{key:"submitTrackLog",value:function(e){var t,r;(t=this.config.reportUrl,r=e,F.post(t,r)).then(function(){}).catch(function(e){})}},{key:"_adReport",value:function(e){var t=this.launchOptions,r={adId:t.click_id,subChannel:t.subChannel,adLink:t.launchPath,adType:e,mobile:this.cachedUserInfo.userPhone,sourceChannel:this.MiniProBaseInfo.uniPlatform};(function(e,t){return F.get(e,t)})("".concat(N,"/api/aiqwxq/adReport"),r).then(function(e){}).catch(function(e){})}},{key:"report",value:function(e){if(this.initialized){var t=J(J(J(J({launchTime:this.launchTime,currentTime:Date.now()},this.launchOptions),this.MiniProBaseInfo),this.cachedUserInfo),{},{openid:this.openid,networkType:this.networkType},e);this.submitTrackLog(t)}else this.apiCallCache.push({method:"report",args:[e]})}},{key:"customReport",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:"clickEvent",n=!(arguments.length>3&&void 0!==arguments[3])||arguments[3];if(this.config.enabled&&e&&r){var o={action:e,name:r};if(n){var i=J(J({},this.primaryCategory&&{primaryCategory:this.primaryCategory}),this.secondaryCategory&&{secondaryCategory:this.secondaryCategory});Object.assign(o,i)}t&&Object.keys(t).length>0&&(o.data=JSON.stringify(t)),this.report(o)}}}]);var e,t,r}();l(V,"config",{reportUrl:A,enabled:!0}),l(V,"initialized",!1),l(V,"apiCallCache",[]),l(V,"storageDataFromMiniPro",function(){try{return function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};try{return e&&"string"==typeof e?JSON.parse(e):t}catch(e){return t}}(uni.getStorageSync("storageName"),{})}catch(e){return{}}}()),l(V,"launchTime",null),l(V,"cachedNetworkType",""),l(V,"MiniProBaseInfo",{}),l(V,"networkType",""),l(V,"launchOptions",{}),l(V,"openid",""),l(V,"primaryCategory",""),l(V,"secondaryCategory","");var H={onLoad:function(e){var t=function(){var e=[];try{if("harmonyos"===process.env.UNI_PLATFORM){var t=uni.getAppPageManager();t&&"function"==typeof t.getPages&&(e=t.getPages()||[])}else"object"===("undefined"==typeof uni?"undefined":n(uni))&&null!==uni&&"function"==typeof uni.getCurrentPages&&(e=uni.getCurrentPages()||[])}catch(e){}return e}(),r=function(e,t){var r="";return e&&(e.route?r=e.route:e.__route__?r=e.__route__:e.path?r=e.path:t&&"object"===n(t)&&null!==t&&(t.route?r=t.route:t.__route__?r=t.__route__:t.path&&(r=t.path))),r}(t[t.length-1]||{},this.$scope);V.currentPagePath=r||"";var o={trackType:"pageview",viewPagePath:r||"",viewPageLoadTime:Date.now(),viewPageParams:e||{}};this.$pageTrackCache=o},onUnload:function(){this._reportPageTrack()},onHide:function(){this._reportPageTrack()},onShow:function(){this.$pageTrackCache&&(this.$pageTrackCache.lastShowTime=Date.now()),this.$pageTrackCache&&this.$pageTrackCache.viewPagePath&&(V.currentPagePath=this.$pageTrackCache.viewPagePath)},methods:{_reportPageTrack:function(){if(this.$pageTrackCache){var e=this.$pageTrackCache.lastShowTime||this.$pageTrackCache.viewPageLoadTime,t=Date.now(),r=t-e,n={path:this.$pageTrackCache.viewPagePath||"",loadTime:this.$pageTrackCache.viewPageLoadTime||Date.now(),leaveTime:t,params:this.$pageTrackCache.viewPageParams||{},stayTime:r};V.customReport("页面曝光",n,"pageviewEvent",!1)}}}},Y=!1;function K(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};if(!Y&&(Y=!0,V.init(t),e.config.globalProperties.$Track=V,e.mixin(H),uni.$Track=V,"object"===("undefined"==typeof uni?"undefined":n(uni))&&null!==uni)){["navigateTo","redirectTo","reLaunch","switchTab","navigateBack"].forEach(function(e){if("function"==typeof uni[e]){var t=uni[e];uni[e]=function(o){try{var i="";if("function"==typeof uni.getCurrentPages){var a=uni.getCurrentPages()||[],u=a[a.length-1]||{};i=u.route||u.__route__||u.path||""}if(!i&&V.currentPagePath&&(i=V.currentPagePath),!i&&"function"==typeof getApp)try{var c=getApp();if(c&&c._pages&&c._pages.length>0){var s=c._pages[c._pages.length-1]||{};i=s.route||s.__route__||s.path||""}else if(c&&c.$vm&&c.$vm.$page){var f=c.$vm.$page;i=f.route||f.__route__||f.path||""}}catch(e){}if(!i)try{if(uni.$app&&uni.$app._pages&&uni.$app._pages.length>0){var l=uni.$app._pages[uni.$app._pages.length-1]||{};i=l.route||l.__route__||l.path||""}}catch(e){}var p="",h={};if("navigateBack"===e)p="back",h={delta:o||1};else if("object"===n(o)&&null!==o){if((p=o.url||"").includes("?")){var y=r(p.split("?"),2),d=y[0],v=y[1];p=d,h=v.split("&").reduce(function(e,t){var n=r(t.split("="),2),o=n[0],i=n[1];return o&&(e[o]=decodeURIComponent(i||"")),e},{})}Object.keys(o).forEach(function(e){"url"!==e&&"success"!==e&&"fail"!==e&&"complete"!==e&&(h[e]=o[e])})}var g={currentPagePath:i||"",targetPagePath:p||"",navigationParams:h||{}};V.customReport("页面跳转",g,"navigationEvent",!1)}catch(e){}return t.call(uni,o)}}})}}var Q={install:K,Track:V,trackPageMixin:H};export{V as Track,Q as default,K as install,H as trackPageMixin};
|
package/package.json
CHANGED
package/src/struct/trackCore.js
CHANGED
|
@@ -498,37 +498,49 @@ static resetCategory(type = "secondary", value) {
|
|
|
498
498
|
this.config.enabled = false;
|
|
499
499
|
console.log("✅ 埋点功能已关闭");
|
|
500
500
|
}
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
const click_id = query.qz_gdt || query.gdt_vid || "";
|
|
501
|
+
/**
|
|
502
|
+
* 获取小程序启动时的参数
|
|
503
|
+
* 核心逻辑:优先用缓存值 → 缓存无值调用API → 都无返回默认值
|
|
504
|
+
* @returns {Object} 标准化的启动参数对象
|
|
505
|
+
*/
|
|
506
|
+
static getLaunchOptionsSync() {
|
|
507
|
+
try {
|
|
508
|
+
const defaultResult = {
|
|
509
|
+
launchPath: "",
|
|
510
|
+
launchScene: "",
|
|
511
|
+
launchParams: "",
|
|
512
|
+
subChannel: "",
|
|
513
|
+
click_id: ""
|
|
514
|
+
};
|
|
516
515
|
|
|
517
|
-
|
|
518
|
-
|
|
519
|
-
|
|
520
|
-
|
|
521
|
-
|
|
522
|
-
|
|
523
|
-
|
|
524
|
-
|
|
525
|
-
|
|
516
|
+
let launchOptions = this.storageDataFromMiniPro?.appLaunchOption?.data;
|
|
517
|
+
|
|
518
|
+
if (!launchOptions) {
|
|
519
|
+
if (typeof uni === "object" && uni !== null && typeof uni.getLaunchOptionsSync === "function") {
|
|
520
|
+
launchOptions = uni.getLaunchOptionsSync() || {};
|
|
521
|
+
console.log("✅ 缓存无启动参数,调用API获取参数", launchOptions);
|
|
522
|
+
}
|
|
523
|
+
else {
|
|
524
|
+
console.warn("⚠️ 无法获取启动参数:缓存无数据且uni.getLaunchOptionsSync不可用");
|
|
525
|
+
return defaultResult;
|
|
526
526
|
}
|
|
527
|
-
} catch (err) {
|
|
528
|
-
console.error("❌ 获取启动参数失败:", err);
|
|
529
|
-
return {};
|
|
530
527
|
}
|
|
528
|
+
const { path = "", scene = "", query = {} } = launchOptions;
|
|
529
|
+
const launchParams = Object.keys(query).length > 0 ? JSON.stringify(query) : "";
|
|
530
|
+
const subChannel = query.subChannel ?? "";
|
|
531
|
+
const click_id = query.qz_gdt || query.gdt_vid || "";
|
|
532
|
+
return {
|
|
533
|
+
launchPath: path,
|
|
534
|
+
launchScene: scene,
|
|
535
|
+
launchParams,
|
|
536
|
+
subChannel,
|
|
537
|
+
click_id
|
|
538
|
+
};
|
|
539
|
+
} catch (err) {
|
|
540
|
+
console.error("❌ 获取启动参数失败:", err);
|
|
541
|
+
return defaultResult;
|
|
531
542
|
}
|
|
543
|
+
}
|
|
532
544
|
|
|
533
545
|
/**
|
|
534
546
|
* 单个埋点上报
|
|
@@ -559,7 +571,8 @@ static resetCategory(type = "secondary", value) {
|
|
|
559
571
|
subChannel,
|
|
560
572
|
adLink: launchPath,
|
|
561
573
|
adType,
|
|
562
|
-
mobile: this.cachedUserInfo.userPhone
|
|
574
|
+
mobile: this.cachedUserInfo.userPhone,
|
|
575
|
+
sourceChannel: this.MiniProBaseInfo.uniPlatform
|
|
563
576
|
}
|
|
564
577
|
const url = `${config.miniProURL}/api/aiqwxq/adReport`;
|
|
565
578
|
adReport(url, data)
|