@dcloudio/vue-cli-plugin-uni 2.0.0 → 2.0.1-32920211122002
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/commands/build.js +64 -33
- package/commands/serve.js +12 -17
- package/generator.js +6 -2
- package/index.js +5 -3
- package/lib/chain-webpack.js +8 -1
- package/lib/check-update.js +56 -0
- package/lib/commands/custom.js +7 -4
- package/lib/commands/invoke.js +5 -4
- package/lib/configure-webpack.js +35 -5
- package/lib/copy-webpack-options.js +60 -20
- package/lib/env.js +99 -51
- package/lib/error-reporting.js +9 -3
- package/lib/mp/index.js +31 -16
- package/lib/options.js +6 -3
- package/lib/util.js +5 -6
- package/package.json +3 -3
- package/packages/@vue/component-compiler-utils/MODIFY.md +5 -0
- package/packages/@vue/component-compiler-utils/dist/compileStyle.js +11 -0
- package/packages/@vue/component-compiler-utils/node_modules/postcss-selector-parser/API.md +873 -0
- package/packages/@vue/component-compiler-utils/node_modules/postcss-selector-parser/CHANGELOG.md +466 -0
- package/packages/@vue/component-compiler-utils/node_modules/postcss-selector-parser/LICENSE-MIT +22 -0
- package/packages/@vue/component-compiler-utils/node_modules/postcss-selector-parser/README.md +49 -0
- package/packages/@vue/component-compiler-utils/node_modules/postcss-selector-parser/dist/index.js +26 -0
- package/packages/@vue/component-compiler-utils/node_modules/postcss-selector-parser/dist/parser.js +1088 -0
- package/packages/@vue/component-compiler-utils/node_modules/postcss-selector-parser/dist/processor.js +185 -0
- package/packages/@vue/component-compiler-utils/node_modules/postcss-selector-parser/dist/selectors/attribute.js +468 -0
- package/packages/@vue/component-compiler-utils/node_modules/postcss-selector-parser/dist/selectors/className.js +67 -0
- package/packages/@vue/component-compiler-utils/node_modules/postcss-selector-parser/dist/selectors/combinator.js +35 -0
- package/packages/@vue/component-compiler-utils/node_modules/postcss-selector-parser/dist/selectors/comment.js +35 -0
- package/packages/@vue/component-compiler-utils/node_modules/postcss-selector-parser/dist/selectors/constructors.js +91 -0
- package/packages/@vue/component-compiler-utils/node_modules/postcss-selector-parser/dist/selectors/container.js +392 -0
- package/packages/@vue/component-compiler-utils/node_modules/postcss-selector-parser/dist/selectors/guards.js +54 -0
- package/packages/@vue/component-compiler-utils/node_modules/postcss-selector-parser/dist/selectors/id.js +39 -0
- package/packages/@vue/component-compiler-utils/node_modules/postcss-selector-parser/dist/selectors/index.js +39 -0
- package/packages/@vue/component-compiler-utils/node_modules/postcss-selector-parser/dist/selectors/namespace.js +98 -0
- package/packages/@vue/component-compiler-utils/node_modules/postcss-selector-parser/dist/selectors/nesting.js +36 -0
- package/packages/@vue/component-compiler-utils/node_modules/postcss-selector-parser/dist/selectors/node.js +216 -0
- package/packages/@vue/component-compiler-utils/node_modules/postcss-selector-parser/dist/selectors/pseudo.js +40 -0
- package/packages/@vue/component-compiler-utils/node_modules/postcss-selector-parser/dist/selectors/root.js +60 -0
- package/packages/@vue/component-compiler-utils/node_modules/postcss-selector-parser/dist/selectors/selector.js +35 -0
- package/packages/@vue/component-compiler-utils/node_modules/postcss-selector-parser/dist/selectors/string.js +35 -0
- package/packages/@vue/component-compiler-utils/node_modules/postcss-selector-parser/dist/selectors/tag.js +35 -0
- package/packages/@vue/component-compiler-utils/node_modules/postcss-selector-parser/dist/selectors/types.js +15 -0
- package/packages/@vue/component-compiler-utils/node_modules/postcss-selector-parser/dist/selectors/universal.js +36 -0
- package/packages/@vue/component-compiler-utils/node_modules/postcss-selector-parser/dist/sortAscending.js +10 -0
- package/packages/@vue/component-compiler-utils/node_modules/postcss-selector-parser/dist/tokenTypes.js +39 -0
- package/packages/@vue/component-compiler-utils/node_modules/postcss-selector-parser/dist/tokenize.js +271 -0
- package/packages/@vue/component-compiler-utils/node_modules/postcss-selector-parser/dist/util/ensureObject.js +20 -0
- package/packages/@vue/component-compiler-utils/node_modules/postcss-selector-parser/dist/util/getProp.js +22 -0
- package/packages/@vue/component-compiler-utils/node_modules/postcss-selector-parser/dist/util/index.js +41 -0
- package/packages/@vue/component-compiler-utils/node_modules/postcss-selector-parser/dist/util/stripComments.js +21 -0
- package/packages/@vue/component-compiler-utils/node_modules/postcss-selector-parser/dist/util/unesc.js +18 -0
- package/packages/@vue/component-compiler-utils/node_modules/postcss-selector-parser/package.json +76 -0
- package/packages/@vue/component-compiler-utils/node_modules/postcss-selector-parser/postcss-selector-parser.d.ts +499 -0
- package/packages/@vue/devtools-api/lib/cjs/api/api.d.ts +90 -0
- package/packages/@vue/devtools-api/lib/cjs/api/api.js +2 -0
- package/packages/@vue/devtools-api/lib/cjs/api/app.d.ts +1 -0
- package/packages/@vue/devtools-api/lib/cjs/api/app.js +2 -0
- package/packages/@vue/devtools-api/lib/cjs/api/component.d.ts +76 -0
- package/packages/@vue/devtools-api/lib/cjs/api/component.js +2 -0
- package/packages/@vue/devtools-api/lib/cjs/api/context.d.ts +5 -0
- package/packages/@vue/devtools-api/lib/cjs/api/context.js +2 -0
- package/packages/@vue/devtools-api/lib/cjs/api/hooks.d.ts +169 -0
- package/packages/@vue/devtools-api/lib/cjs/api/hooks.js +2 -0
- package/packages/@vue/devtools-api/lib/cjs/api/index.d.ts +6 -0
- package/packages/@vue/devtools-api/lib/cjs/api/index.js +18 -0
- package/packages/@vue/devtools-api/lib/cjs/api/util.d.ts +4 -0
- package/packages/@vue/devtools-api/lib/cjs/api/util.js +2 -0
- package/packages/@vue/devtools-api/lib/cjs/const.d.ts +1 -0
- package/packages/@vue/devtools-api/lib/cjs/const.js +4 -0
- package/packages/@vue/devtools-api/lib/cjs/env.d.ts +10 -0
- package/packages/@vue/devtools-api/lib/cjs/env.js +16 -0
- package/packages/@vue/devtools-api/lib/cjs/index.d.ts +14 -0
- package/packages/@vue/devtools-api/lib/cjs/index.js +31 -0
- package/packages/@vue/devtools-api/lib/esm/api/api.js +0 -0
- package/packages/@vue/devtools-api/lib/esm/api/app.js +0 -0
- package/packages/@vue/devtools-api/lib/esm/api/component.js +0 -0
- package/packages/@vue/devtools-api/lib/esm/api/context.js +0 -0
- package/packages/@vue/devtools-api/lib/esm/api/hooks.js +0 -0
- package/packages/@vue/devtools-api/lib/esm/api/index.js +6 -0
- package/packages/@vue/devtools-api/lib/esm/api/util.js +0 -0
- package/packages/@vue/devtools-api/lib/esm/const.js +1 -0
- package/packages/@vue/devtools-api/lib/esm/env.js +11 -0
- package/packages/@vue/devtools-api/lib/esm/index.js +17 -0
- package/packages/@vue/devtools-api/package.json +38 -0
- package/packages/app-vue-style-loader/lib/addStylesClient.js +1 -1
- package/packages/h5-vue-style-loader/lib/addStylesClient.js +1 -1
- package/packages/mp-vue/dist/mp.runtime.esm.js +3 -2
- package/packages/mp-vue/package.json +1 -0
- package/packages/uni-app/LICENSE +202 -0
- package/packages/uni-app/dist/uni-app.cjs.js +165 -0
- package/packages/uni-app/dist/uni-app.d.ts +61 -0
- package/packages/uni-app/dist/uni-app.es.js +108 -0
- package/packages/uni-app/package.json +22 -0
- package/packages/uni-cloud/dist/index.js +1 -1
- package/packages/uni-stat/dist/uni-stat.cjs.js +961 -0
- package/packages/uni-stat/dist/uni-stat.es.js +959 -0
- package/packages/uni-stat/lib/uni.plugin.js +68 -0
- package/packages/uni-stat/package.json +25 -0
- package/packages/vue3/node_modules/.yarn-integrity +27 -0
- package/packages/vue3/node_modules/@intlify/core-base/LICENSE +20 -0
- package/packages/vue3/node_modules/@intlify/core-base/README.md +7 -0
- package/packages/vue3/node_modules/@intlify/core-base/dist/core-base.cjs.js +989 -0
- package/packages/vue3/node_modules/@intlify/core-base/dist/core-base.cjs.prod.js +735 -0
- package/packages/vue3/node_modules/@intlify/core-base/dist/core-base.d.ts +576 -0
- package/packages/vue3/node_modules/@intlify/core-base/dist/core-base.esm-browser.js +2771 -0
- package/packages/vue3/node_modules/@intlify/core-base/dist/core-base.esm-browser.prod.js +6 -0
- package/packages/vue3/node_modules/@intlify/core-base/dist/core-base.esm-bundler.js +965 -0
- package/packages/vue3/node_modules/@intlify/core-base/dist/core-base.global.js +2814 -0
- package/packages/vue3/node_modules/@intlify/core-base/dist/core-base.global.prod.js +6 -0
- package/packages/vue3/node_modules/@intlify/core-base/index.js +7 -0
- package/packages/vue3/node_modules/@intlify/core-base/package.json +59 -0
- package/packages/vue3/node_modules/@intlify/devtools-if/LICENSE +20 -0
- package/packages/vue3/node_modules/@intlify/devtools-if/README.md +13 -0
- package/packages/vue3/node_modules/@intlify/devtools-if/dist/devtools-if.cjs.js +15 -0
- package/packages/vue3/node_modules/@intlify/devtools-if/dist/devtools-if.cjs.prod.js +15 -0
- package/packages/vue3/node_modules/@intlify/devtools-if/dist/devtools-if.d.ts +43 -0
- package/packages/vue3/node_modules/@intlify/devtools-if/dist/devtools-if.esm-bundler.js +11 -0
- package/packages/vue3/node_modules/@intlify/devtools-if/index.js +7 -0
- package/packages/vue3/node_modules/@intlify/devtools-if/package.json +49 -0
- package/packages/vue3/node_modules/@intlify/message-compiler/LICENSE +20 -0
- package/packages/vue3/node_modules/@intlify/message-compiler/README.md +7 -0
- package/packages/vue3/node_modules/@intlify/message-compiler/dist/message-compiler.cjs.js +1400 -0
- package/packages/vue3/node_modules/@intlify/message-compiler/dist/message-compiler.cjs.prod.js +1395 -0
- package/packages/vue3/node_modules/@intlify/message-compiler/dist/message-compiler.d.ts +197 -0
- package/packages/vue3/node_modules/@intlify/message-compiler/dist/message-compiler.esm-browser.js +1348 -0
- package/packages/vue3/node_modules/@intlify/message-compiler/dist/message-compiler.esm-browser.prod.js +6 -0
- package/packages/vue3/node_modules/@intlify/message-compiler/dist/message-compiler.esm-bundler.js +1329 -0
- package/packages/vue3/node_modules/@intlify/message-compiler/dist/message-compiler.global.js +1365 -0
- package/packages/vue3/node_modules/@intlify/message-compiler/dist/message-compiler.global.prod.js +6 -0
- package/packages/vue3/node_modules/@intlify/message-compiler/index.js +7 -0
- package/packages/vue3/node_modules/@intlify/message-compiler/package.json +56 -0
- package/packages/vue3/node_modules/@intlify/message-resolver/LICENSE +20 -0
- package/packages/vue3/node_modules/@intlify/message-resolver/README.md +7 -0
- package/packages/vue3/node_modules/@intlify/message-resolver/dist/message-resolver.cjs.js +302 -0
- package/packages/vue3/node_modules/@intlify/message-resolver/dist/message-resolver.cjs.prod.js +302 -0
- package/packages/vue3/node_modules/@intlify/message-resolver/dist/message-resolver.d.ts +21 -0
- package/packages/vue3/node_modules/@intlify/message-resolver/dist/message-resolver.esm-bundler.js +297 -0
- package/packages/vue3/node_modules/@intlify/message-resolver/index.js +7 -0
- package/packages/vue3/node_modules/@intlify/message-resolver/package.json +46 -0
- package/packages/vue3/node_modules/@intlify/runtime/LICENSE +20 -0
- package/packages/vue3/node_modules/@intlify/runtime/README.md +7 -0
- package/packages/vue3/node_modules/@intlify/runtime/dist/runtime.cjs.js +116 -0
- package/packages/vue3/node_modules/@intlify/runtime/dist/runtime.cjs.prod.js +116 -0
- package/packages/vue3/node_modules/@intlify/runtime/dist/runtime.d.ts +95 -0
- package/packages/vue3/node_modules/@intlify/runtime/dist/runtime.esm-bundler.js +111 -0
- package/packages/vue3/node_modules/@intlify/runtime/index.js +7 -0
- package/packages/vue3/node_modules/@intlify/runtime/package.json +51 -0
- package/packages/vue3/node_modules/@intlify/shared/LICENSE +20 -0
- package/packages/vue3/node_modules/@intlify/shared/README.md +18 -0
- package/packages/vue3/node_modules/@intlify/shared/dist/shared.cjs.js +222 -0
- package/packages/vue3/node_modules/@intlify/shared/dist/shared.cjs.prod.js +209 -0
- package/packages/vue3/node_modules/@intlify/shared/dist/shared.d.ts +145 -0
- package/packages/vue3/node_modules/@intlify/shared/dist/shared.esm-bundler.js +192 -0
- package/packages/vue3/node_modules/@intlify/shared/index.js +7 -0
- package/packages/vue3/node_modules/@intlify/shared/package.json +46 -0
- package/packages/vue3/node_modules/@intlify/vue-devtools/LICENSE +20 -0
- package/packages/vue3/node_modules/@intlify/vue-devtools/README.md +7 -0
- package/packages/vue3/node_modules/@intlify/vue-devtools/dist/vue-devtools.cjs.js +24 -0
- package/packages/vue3/node_modules/@intlify/vue-devtools/dist/vue-devtools.cjs.prod.js +24 -0
- package/packages/vue3/node_modules/@intlify/vue-devtools/dist/vue-devtools.d.ts +81 -0
- package/packages/vue3/node_modules/@intlify/vue-devtools/dist/vue-devtools.esm-bundler.js +18 -0
- package/packages/vue3/node_modules/@intlify/vue-devtools/index.js +7 -0
- package/packages/vue3/node_modules/@intlify/vue-devtools/package.json +51 -0
- package/packages/vue3/node_modules/@vue/devtools-api/lib/cjs/api/api.d.ts +90 -0
- package/packages/vue3/node_modules/@vue/devtools-api/lib/cjs/api/api.js +2 -0
- package/packages/vue3/node_modules/@vue/devtools-api/lib/cjs/api/app.d.ts +1 -0
- package/packages/vue3/node_modules/@vue/devtools-api/lib/cjs/api/app.js +2 -0
- package/packages/vue3/node_modules/@vue/devtools-api/lib/cjs/api/component.d.ts +76 -0
- package/packages/vue3/node_modules/@vue/devtools-api/lib/cjs/api/component.js +2 -0
- package/packages/vue3/node_modules/@vue/devtools-api/lib/cjs/api/context.d.ts +5 -0
- package/packages/vue3/node_modules/@vue/devtools-api/lib/cjs/api/context.js +2 -0
- package/packages/vue3/node_modules/@vue/devtools-api/lib/cjs/api/hooks.d.ts +169 -0
- package/packages/vue3/node_modules/@vue/devtools-api/lib/cjs/api/hooks.js +2 -0
- package/packages/vue3/node_modules/@vue/devtools-api/lib/cjs/api/index.d.ts +6 -0
- package/packages/vue3/node_modules/@vue/devtools-api/lib/cjs/api/index.js +18 -0
- package/packages/vue3/node_modules/@vue/devtools-api/lib/cjs/api/util.d.ts +4 -0
- package/packages/vue3/node_modules/@vue/devtools-api/lib/cjs/api/util.js +2 -0
- package/packages/vue3/node_modules/@vue/devtools-api/lib/cjs/const.d.ts +1 -0
- package/packages/vue3/node_modules/@vue/devtools-api/lib/cjs/const.js +4 -0
- package/packages/vue3/node_modules/@vue/devtools-api/lib/cjs/env.d.ts +10 -0
- package/packages/vue3/node_modules/@vue/devtools-api/lib/cjs/env.js +16 -0
- package/packages/vue3/node_modules/@vue/devtools-api/lib/cjs/index.d.ts +14 -0
- package/packages/vue3/node_modules/@vue/devtools-api/lib/cjs/index.js +31 -0
- package/packages/vue3/node_modules/@vue/devtools-api/lib/esm/api/api.js +0 -0
- package/packages/vue3/node_modules/@vue/devtools-api/lib/esm/api/app.js +0 -0
- package/packages/vue3/node_modules/@vue/devtools-api/lib/esm/api/component.js +0 -0
- package/packages/vue3/node_modules/@vue/devtools-api/lib/esm/api/context.js +0 -0
- package/packages/vue3/node_modules/@vue/devtools-api/lib/esm/api/hooks.js +0 -0
- package/packages/vue3/node_modules/@vue/devtools-api/lib/esm/api/index.js +6 -0
- package/packages/vue3/node_modules/@vue/devtools-api/lib/esm/api/util.js +0 -0
- package/packages/vue3/node_modules/@vue/devtools-api/lib/esm/const.js +1 -0
- package/packages/vue3/node_modules/@vue/devtools-api/lib/esm/env.js +11 -0
- package/packages/vue3/node_modules/@vue/devtools-api/lib/esm/index.js +17 -0
- package/packages/vue3/node_modules/@vue/devtools-api/package.json +38 -0
- package/packages/vue3/node_modules/source-map/CHANGELOG.md +301 -0
- package/packages/vue3/node_modules/source-map/LICENSE +28 -0
- package/packages/vue3/node_modules/source-map/README.md +742 -0
- package/packages/vue3/node_modules/source-map/dist/source-map.debug.js +3234 -0
- package/packages/vue3/node_modules/source-map/dist/source-map.js +3233 -0
- package/packages/vue3/node_modules/source-map/dist/source-map.min.js +2 -0
- package/packages/vue3/node_modules/source-map/dist/source-map.min.js.map +1 -0
- package/packages/vue3/node_modules/source-map/lib/array-set.js +121 -0
- package/packages/vue3/node_modules/source-map/lib/base64-vlq.js +140 -0
- package/packages/vue3/node_modules/source-map/lib/base64.js +67 -0
- package/packages/vue3/node_modules/source-map/lib/binary-search.js +111 -0
- package/packages/vue3/node_modules/source-map/lib/mapping-list.js +79 -0
- package/packages/vue3/node_modules/source-map/lib/quick-sort.js +114 -0
- package/packages/vue3/node_modules/source-map/lib/source-map-consumer.js +1145 -0
- package/packages/vue3/node_modules/source-map/lib/source-map-generator.js +425 -0
- package/packages/vue3/node_modules/source-map/lib/source-node.js +413 -0
- package/packages/vue3/node_modules/source-map/lib/util.js +488 -0
- package/packages/vue3/node_modules/source-map/package.json +73 -0
- package/packages/vue3/node_modules/source-map/source-map.d.ts +98 -0
- package/packages/vue3/node_modules/source-map/source-map.js +8 -0
- package/packages/vue3/node_modules/vue-i18n/LICENSE +20 -0
- package/packages/vue3/node_modules/vue-i18n/README.md +74 -0
- package/packages/vue3/node_modules/vue-i18n/dist/vue-i18n.cjs.js +1801 -0
- package/packages/vue3/node_modules/vue-i18n/dist/vue-i18n.cjs.prod.js +1685 -0
- package/packages/vue3/node_modules/vue-i18n/dist/vue-i18n.d.ts +3302 -0
- package/packages/vue3/node_modules/vue-i18n/dist/vue-i18n.esm-browser.js +5052 -0
- package/packages/vue3/node_modules/vue-i18n/dist/vue-i18n.esm-browser.prod.js +6 -0
- package/packages/vue3/node_modules/vue-i18n/dist/vue-i18n.esm-bundler.js +2226 -0
- package/packages/vue3/node_modules/vue-i18n/dist/vue-i18n.global.js +5065 -0
- package/packages/vue3/node_modules/vue-i18n/dist/vue-i18n.global.prod.js +6 -0
- package/packages/vue3/node_modules/vue-i18n/dist/vue-i18n.runtime.esm-browser.js +3724 -0
- package/packages/vue3/node_modules/vue-i18n/dist/vue-i18n.runtime.esm-browser.prod.js +6 -0
- package/packages/vue3/node_modules/vue-i18n/dist/vue-i18n.runtime.esm-bundler.js +2224 -0
- package/packages/vue3/node_modules/vue-i18n/dist/vue-i18n.runtime.global.js +3737 -0
- package/packages/vue3/node_modules/vue-i18n/dist/vue-i18n.runtime.global.prod.js +6 -0
- package/packages/vue3/node_modules/vue-i18n/index.js +7 -0
- package/packages/vue3/node_modules/vue-i18n/package.json +69 -0
- package/packages/vue3/node_modules/vue-i18n/vetur/attributes.json +62 -0
- package/packages/vue3/node_modules/vue-i18n/vetur/tags.json +14 -0
- package/packages/vue3/package.json +15 -0
- package/packages/vue3/yarn.lock +79 -0
- package/packages/vuex/CHANGELOG.md +604 -0
- package/packages/vuex/LICENSE +21 -0
- package/packages/vuex/README.md +55 -0
- package/packages/vuex/dist/vuex.cjs.js +1474 -0
- package/packages/vuex/dist/vuex.esm-browser.js +1472 -0
- package/packages/vuex/dist/vuex.esm-browser.prod.js +1307 -0
- package/packages/vuex/dist/vuex.esm-bundler.js +1473 -0
- package/packages/vuex/dist/vuex.global.js +1499 -0
- package/packages/vuex/dist/vuex.global.prod.js +6 -0
- package/packages/vuex/dist/vuex.mjs +32 -0
- package/packages/vuex/package.json +99 -0
- package/packages/vuex/types/helpers.d.ts +86 -0
- package/packages/vuex/types/index.d.ts +167 -0
- package/packages/vuex/types/logger.d.ts +20 -0
- package/packages/vuex/types/vue.d.ts +12 -0
- package/packages/vuex3/CHANGELOG.md +356 -0
- package/packages/vuex3/LICENSE +21 -0
- package/packages/vuex3/README.md +59 -0
- package/packages/vuex3/dist/logger.js +155 -0
- package/packages/vuex3/dist/vuex.common.js +1244 -0
- package/packages/vuex3/dist/vuex.esm.browser.js +1200 -0
- package/packages/vuex3/dist/vuex.esm.browser.min.js +6 -0
- package/packages/vuex3/dist/vuex.esm.js +1243 -0
- package/packages/vuex3/dist/vuex.js +1250 -0
- package/packages/vuex3/dist/vuex.min.js +6 -0
- package/packages/vuex3/dist/vuex.mjs +26 -0
- package/packages/vuex3/package.json +96 -0
- package/packages/vuex3/types/helpers.d.ts +86 -0
- package/packages/vuex3/types/index.d.ts +164 -0
- package/packages/vuex3/types/logger.d.ts +20 -0
- package/packages/vuex3/types/vue.d.ts +18 -0
- package/packages/webpack-uni-app-loader/plugin/index.js +8 -2
- package/packages/webpack-uni-app-loader/view/main.js +12 -0
|
@@ -0,0 +1,959 @@
|
|
|
1
|
+
var version = "3.0.0-alpha-3000020210813002";
|
|
2
|
+
|
|
3
|
+
const STAT_VERSION = version;
|
|
4
|
+
const STAT_URL = 'https://tongji.dcloud.io/uni/stat';
|
|
5
|
+
const STAT_H5_URL = 'https://tongji.dcloud.io/uni/stat.gif';
|
|
6
|
+
const PAGE_PVER_TIME = 1800;
|
|
7
|
+
const APP_PVER_TIME = 300;
|
|
8
|
+
const OPERATING_TIME = 10;
|
|
9
|
+
const DIFF_TIME = 60 * 1000 * 60 * 24;
|
|
10
|
+
|
|
11
|
+
const statConfig$1 = {
|
|
12
|
+
appid: process.env.UNI_APP_ID,
|
|
13
|
+
};
|
|
14
|
+
const UUID_KEY = '__DC_STAT_UUID';
|
|
15
|
+
const UUID_VALUE = '__DC_UUID_VALUE';
|
|
16
|
+
|
|
17
|
+
function getUuid() {
|
|
18
|
+
let uuid = '';
|
|
19
|
+
if (getPlatformName() === 'n') {
|
|
20
|
+
try {
|
|
21
|
+
uuid = plus.runtime.getDCloudId();
|
|
22
|
+
} catch (e) {
|
|
23
|
+
uuid = '';
|
|
24
|
+
}
|
|
25
|
+
return uuid
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
try {
|
|
29
|
+
uuid = uni.getStorageSync(UUID_KEY);
|
|
30
|
+
} catch (e) {
|
|
31
|
+
uuid = UUID_VALUE;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
if (!uuid) {
|
|
35
|
+
uuid = Date.now() + '' + Math.floor(Math.random() * 1e7);
|
|
36
|
+
try {
|
|
37
|
+
uni.setStorageSync(UUID_KEY, uuid);
|
|
38
|
+
} catch (e) {
|
|
39
|
+
uni.setStorageSync(UUID_KEY, UUID_VALUE);
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
return uuid
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
const getSgin = (statData) => {
|
|
46
|
+
let arr = Object.keys(statData);
|
|
47
|
+
let sortArr = arr.sort();
|
|
48
|
+
let sgin = {};
|
|
49
|
+
let sginStr = '';
|
|
50
|
+
for (var i in sortArr) {
|
|
51
|
+
sgin[sortArr[i]] = statData[sortArr[i]];
|
|
52
|
+
sginStr += sortArr[i] + '=' + statData[sortArr[i]] + '&';
|
|
53
|
+
}
|
|
54
|
+
// const options = sginStr.substr(0, sginStr.length - 1)
|
|
55
|
+
// sginStr = sginStr.substr(0, sginStr.length - 1) + '&key=' + STAT_KEY;
|
|
56
|
+
// const si = crypto.createHash('md5').update(sginStr).digest('hex');
|
|
57
|
+
return {
|
|
58
|
+
sign: '',
|
|
59
|
+
options: sginStr.substr(0, sginStr.length - 1),
|
|
60
|
+
}
|
|
61
|
+
};
|
|
62
|
+
|
|
63
|
+
const getSplicing = (data) => {
|
|
64
|
+
let str = '';
|
|
65
|
+
for (var i in data) {
|
|
66
|
+
str += i + '=' + data[i] + '&';
|
|
67
|
+
}
|
|
68
|
+
return str.substr(0, str.length - 1)
|
|
69
|
+
};
|
|
70
|
+
|
|
71
|
+
const getTime = () => {
|
|
72
|
+
return parseInt(new Date().getTime() / 1000)
|
|
73
|
+
};
|
|
74
|
+
|
|
75
|
+
const getPlatformName = () => {
|
|
76
|
+
const aliArr = ['y', 'a', 'p', 'mp-ali'];
|
|
77
|
+
const platformList = {
|
|
78
|
+
'app-plus': 'n',
|
|
79
|
+
h5: 'h5',
|
|
80
|
+
'mp-weixin': 'wx',
|
|
81
|
+
[aliArr.reverse().join('')]: 'ali',
|
|
82
|
+
'mp-baidu': 'bd',
|
|
83
|
+
'mp-toutiao': 'tt',
|
|
84
|
+
'mp-qq': 'qq',
|
|
85
|
+
'quickapp-native': 'qn',
|
|
86
|
+
'mp-kuaishou': 'ks',
|
|
87
|
+
};
|
|
88
|
+
return platformList[process.env.VUE_APP_PLATFORM]
|
|
89
|
+
};
|
|
90
|
+
|
|
91
|
+
const getPackName = () => {
|
|
92
|
+
let packName = '';
|
|
93
|
+
if (getPlatformName() === 'wx' || getPlatformName() === 'qq') {
|
|
94
|
+
// 兼容微信小程序低版本基础库
|
|
95
|
+
if (uni.canIUse('getAccountInfoSync')) {
|
|
96
|
+
packName = uni.getAccountInfoSync().miniProgram.appId || '';
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
return packName
|
|
100
|
+
};
|
|
101
|
+
|
|
102
|
+
const getVersion = () => {
|
|
103
|
+
return getPlatformName() === 'n' ? plus.runtime.version : ''
|
|
104
|
+
};
|
|
105
|
+
|
|
106
|
+
const getChannel = () => {
|
|
107
|
+
const platformName = getPlatformName();
|
|
108
|
+
let channel = '';
|
|
109
|
+
if (platformName === 'n') {
|
|
110
|
+
channel = plus.runtime.channel;
|
|
111
|
+
}
|
|
112
|
+
return channel
|
|
113
|
+
};
|
|
114
|
+
|
|
115
|
+
const getScene = (options) => {
|
|
116
|
+
const platformName = getPlatformName();
|
|
117
|
+
let scene = '';
|
|
118
|
+
if (options) {
|
|
119
|
+
return options
|
|
120
|
+
}
|
|
121
|
+
if (platformName === 'wx') {
|
|
122
|
+
scene = uni.getLaunchOptionsSync().scene;
|
|
123
|
+
}
|
|
124
|
+
return scene
|
|
125
|
+
};
|
|
126
|
+
const First__Visit__Time__KEY = 'First__Visit__Time';
|
|
127
|
+
const Last__Visit__Time__KEY = 'Last__Visit__Time';
|
|
128
|
+
|
|
129
|
+
const getFirstVisitTime = () => {
|
|
130
|
+
const timeStorge = uni.getStorageSync(First__Visit__Time__KEY);
|
|
131
|
+
let time = 0;
|
|
132
|
+
if (timeStorge) {
|
|
133
|
+
time = timeStorge;
|
|
134
|
+
} else {
|
|
135
|
+
time = getTime();
|
|
136
|
+
uni.setStorageSync(First__Visit__Time__KEY, time);
|
|
137
|
+
uni.removeStorageSync(Last__Visit__Time__KEY);
|
|
138
|
+
}
|
|
139
|
+
return time
|
|
140
|
+
};
|
|
141
|
+
|
|
142
|
+
const getLastVisitTime = () => {
|
|
143
|
+
const timeStorge = uni.getStorageSync(Last__Visit__Time__KEY);
|
|
144
|
+
let time = 0;
|
|
145
|
+
if (timeStorge) {
|
|
146
|
+
time = timeStorge;
|
|
147
|
+
} else {
|
|
148
|
+
time = '';
|
|
149
|
+
}
|
|
150
|
+
uni.setStorageSync(Last__Visit__Time__KEY, getTime());
|
|
151
|
+
return time
|
|
152
|
+
};
|
|
153
|
+
|
|
154
|
+
const PAGE_RESIDENCE_TIME = '__page__residence__time';
|
|
155
|
+
let First_Page_residence_time = 0;
|
|
156
|
+
let Last_Page_residence_time = 0;
|
|
157
|
+
|
|
158
|
+
const setPageResidenceTime = () => {
|
|
159
|
+
First_Page_residence_time = getTime();
|
|
160
|
+
if (getPlatformName() === 'n') {
|
|
161
|
+
uni.setStorageSync(PAGE_RESIDENCE_TIME, getTime());
|
|
162
|
+
}
|
|
163
|
+
return First_Page_residence_time
|
|
164
|
+
};
|
|
165
|
+
|
|
166
|
+
const getPageResidenceTime = () => {
|
|
167
|
+
Last_Page_residence_time = getTime();
|
|
168
|
+
if (getPlatformName() === 'n') {
|
|
169
|
+
First_Page_residence_time = uni.getStorageSync(PAGE_RESIDENCE_TIME);
|
|
170
|
+
}
|
|
171
|
+
return Last_Page_residence_time - First_Page_residence_time
|
|
172
|
+
};
|
|
173
|
+
const TOTAL__VISIT__COUNT = 'Total__Visit__Count';
|
|
174
|
+
const getTotalVisitCount = () => {
|
|
175
|
+
const timeStorge = uni.getStorageSync(TOTAL__VISIT__COUNT);
|
|
176
|
+
let count = 1;
|
|
177
|
+
if (timeStorge) {
|
|
178
|
+
count = timeStorge;
|
|
179
|
+
count++;
|
|
180
|
+
}
|
|
181
|
+
uni.setStorageSync(TOTAL__VISIT__COUNT, count);
|
|
182
|
+
return count
|
|
183
|
+
};
|
|
184
|
+
|
|
185
|
+
const GetEncodeURIComponentOptions = (statData) => {
|
|
186
|
+
let data = {};
|
|
187
|
+
for (let prop in statData) {
|
|
188
|
+
data[prop] = encodeURIComponent(statData[prop]);
|
|
189
|
+
}
|
|
190
|
+
return data
|
|
191
|
+
};
|
|
192
|
+
|
|
193
|
+
let Set__First__Time = 0;
|
|
194
|
+
let Set__Last__Time = 0;
|
|
195
|
+
|
|
196
|
+
const getFirstTime = () => {
|
|
197
|
+
let time = new Date().getTime();
|
|
198
|
+
Set__First__Time = time;
|
|
199
|
+
Set__Last__Time = 0;
|
|
200
|
+
return time
|
|
201
|
+
};
|
|
202
|
+
|
|
203
|
+
const getLastTime = () => {
|
|
204
|
+
let time = new Date().getTime();
|
|
205
|
+
Set__Last__Time = time;
|
|
206
|
+
return time
|
|
207
|
+
};
|
|
208
|
+
|
|
209
|
+
const getResidenceTime = (type) => {
|
|
210
|
+
let residenceTime = 0;
|
|
211
|
+
if (Set__First__Time !== 0) {
|
|
212
|
+
residenceTime = Set__Last__Time - Set__First__Time;
|
|
213
|
+
}
|
|
214
|
+
|
|
215
|
+
residenceTime = parseInt(residenceTime / 1000);
|
|
216
|
+
residenceTime = residenceTime < 1 ? 1 : residenceTime;
|
|
217
|
+
if (type === 'app') {
|
|
218
|
+
let overtime = residenceTime > APP_PVER_TIME ? true : false;
|
|
219
|
+
return {
|
|
220
|
+
residenceTime,
|
|
221
|
+
overtime,
|
|
222
|
+
}
|
|
223
|
+
}
|
|
224
|
+
if (type === 'page') {
|
|
225
|
+
let overtime = residenceTime > PAGE_PVER_TIME ? true : false;
|
|
226
|
+
return {
|
|
227
|
+
residenceTime,
|
|
228
|
+
overtime,
|
|
229
|
+
}
|
|
230
|
+
}
|
|
231
|
+
|
|
232
|
+
return {
|
|
233
|
+
residenceTime,
|
|
234
|
+
}
|
|
235
|
+
};
|
|
236
|
+
|
|
237
|
+
const getRoute = () => {
|
|
238
|
+
var pages = getCurrentPages();
|
|
239
|
+
var page = pages[pages.length - 1];
|
|
240
|
+
if (!page) return ''
|
|
241
|
+
// TODO 需要确认如果不用 $vm ,其他平台会不会出错
|
|
242
|
+
let _self = page.$vm;
|
|
243
|
+
|
|
244
|
+
if (getPlatformName() === 'bd') {
|
|
245
|
+
return _self.$mp && _self.$mp.page.is
|
|
246
|
+
} else {
|
|
247
|
+
return _self.route || (_self.$scope && _self.$scope.route)
|
|
248
|
+
}
|
|
249
|
+
};
|
|
250
|
+
|
|
251
|
+
const getPageRoute = (_this) => {
|
|
252
|
+
let pageVm = _this.self;
|
|
253
|
+
let page = pageVm.$page || pageVm.$scope.$page;
|
|
254
|
+
return page.fullPath === '/' ? page.route : page.fullPath
|
|
255
|
+
};
|
|
256
|
+
|
|
257
|
+
const getPageTypes = (self) => {
|
|
258
|
+
if (
|
|
259
|
+
self.$mpType === 'page' ||
|
|
260
|
+
(self.$mp && self.$mp.mpType === 'page') ||
|
|
261
|
+
self.$options.mpType === 'page'
|
|
262
|
+
) {
|
|
263
|
+
return true
|
|
264
|
+
}
|
|
265
|
+
return false
|
|
266
|
+
};
|
|
267
|
+
|
|
268
|
+
const calibration = (eventName, options) => {
|
|
269
|
+
// login 、 share 、pay_success 、pay_fail 、register 、title
|
|
270
|
+
if (!eventName) {
|
|
271
|
+
console.error(`uni.report 缺少 [eventName] 参数`);
|
|
272
|
+
return true
|
|
273
|
+
}
|
|
274
|
+
if (typeof eventName !== 'string') {
|
|
275
|
+
console.error(`uni.report [eventName] 参数类型错误,只能为 String 类型`);
|
|
276
|
+
return true
|
|
277
|
+
}
|
|
278
|
+
if (eventName.length > 255) {
|
|
279
|
+
console.error(`uni.report [eventName] 参数长度不能大于 255`);
|
|
280
|
+
return true
|
|
281
|
+
}
|
|
282
|
+
|
|
283
|
+
if (typeof options !== 'string' && typeof options !== 'object') {
|
|
284
|
+
console.error(
|
|
285
|
+
`uni.report [options] 参数类型错误,只能为 String 或 Object 类型`
|
|
286
|
+
);
|
|
287
|
+
return true
|
|
288
|
+
}
|
|
289
|
+
|
|
290
|
+
if (typeof options === 'string' && options.length > 255) {
|
|
291
|
+
console.error(`uni.report [options] 参数长度不能大于 255`);
|
|
292
|
+
return true
|
|
293
|
+
}
|
|
294
|
+
|
|
295
|
+
if (eventName === 'title' && typeof options !== 'string') {
|
|
296
|
+
console.error(
|
|
297
|
+
'uni.report [eventName] 参数为 title 时,[options] 参数只能为 String 类型'
|
|
298
|
+
);
|
|
299
|
+
return true
|
|
300
|
+
}
|
|
301
|
+
};
|
|
302
|
+
|
|
303
|
+
const Report_Data_Time = 'Report_Data_Time';
|
|
304
|
+
const Report_Status = 'Report_Status';
|
|
305
|
+
const isReportData = () => {
|
|
306
|
+
return new Promise((resolve, reject) => {
|
|
307
|
+
let start_time = '';
|
|
308
|
+
let end_time = new Date().getTime();
|
|
309
|
+
let diff_time = DIFF_TIME;
|
|
310
|
+
let report_status = 1;
|
|
311
|
+
try {
|
|
312
|
+
start_time = uni.getStorageSync(Report_Data_Time);
|
|
313
|
+
report_status = uni.getStorageSync(Report_Status);
|
|
314
|
+
} catch (e) {
|
|
315
|
+
start_time = '';
|
|
316
|
+
report_status = 1;
|
|
317
|
+
}
|
|
318
|
+
|
|
319
|
+
if (report_status === '') {
|
|
320
|
+
requestData(({ enable }) => {
|
|
321
|
+
uni.setStorageSync(Report_Data_Time, end_time);
|
|
322
|
+
uni.setStorageSync(Report_Status, enable);
|
|
323
|
+
if (enable === 1) {
|
|
324
|
+
resolve();
|
|
325
|
+
}
|
|
326
|
+
});
|
|
327
|
+
return
|
|
328
|
+
}
|
|
329
|
+
|
|
330
|
+
if (report_status === 1) {
|
|
331
|
+
resolve();
|
|
332
|
+
}
|
|
333
|
+
|
|
334
|
+
if (!start_time) {
|
|
335
|
+
uni.setStorageSync(Report_Data_Time, end_time);
|
|
336
|
+
start_time = end_time;
|
|
337
|
+
}
|
|
338
|
+
|
|
339
|
+
if (end_time - start_time > diff_time) {
|
|
340
|
+
requestData(({ enable }) => {
|
|
341
|
+
uni.setStorageSync(Report_Data_Time, end_time);
|
|
342
|
+
uni.setStorageSync(Report_Status, enable);
|
|
343
|
+
});
|
|
344
|
+
}
|
|
345
|
+
})
|
|
346
|
+
};
|
|
347
|
+
|
|
348
|
+
const requestData = (done) => {
|
|
349
|
+
let formData = {
|
|
350
|
+
usv: STAT_VERSION,
|
|
351
|
+
conf: JSON.stringify({
|
|
352
|
+
ak: statConfig$1.appid,
|
|
353
|
+
}),
|
|
354
|
+
};
|
|
355
|
+
uni.request({
|
|
356
|
+
url: STAT_URL,
|
|
357
|
+
method: 'GET',
|
|
358
|
+
data: formData,
|
|
359
|
+
success: (res) => {
|
|
360
|
+
const { data } = res;
|
|
361
|
+
if (data.ret === 0) {
|
|
362
|
+
typeof done === 'function' &&
|
|
363
|
+
done({
|
|
364
|
+
enable: data.enable,
|
|
365
|
+
});
|
|
366
|
+
}
|
|
367
|
+
},
|
|
368
|
+
fail: (e) => {
|
|
369
|
+
let report_status_code = 1;
|
|
370
|
+
try {
|
|
371
|
+
report_status_code = uni.getStorageSync(Report_Status);
|
|
372
|
+
} catch (e) {
|
|
373
|
+
report_status_code = 1;
|
|
374
|
+
}
|
|
375
|
+
if (report_status_code === '') {
|
|
376
|
+
report_status_code = 1;
|
|
377
|
+
}
|
|
378
|
+
typeof done === 'function' &&
|
|
379
|
+
done({
|
|
380
|
+
enable: report_status_code,
|
|
381
|
+
});
|
|
382
|
+
},
|
|
383
|
+
});
|
|
384
|
+
};
|
|
385
|
+
|
|
386
|
+
let titleJsons = {};
|
|
387
|
+
// #ifdef MP
|
|
388
|
+
let pagesTitle = require('uni-pages?{"type":"style"}').default;
|
|
389
|
+
pagesTitle = pagesTitle.pages;
|
|
390
|
+
for (let i in pagesTitle) {
|
|
391
|
+
titleJsons[i] = pagesTitle[i].navigationBarTitleText || '';
|
|
392
|
+
}
|
|
393
|
+
// #endif
|
|
394
|
+
// #ifndef MP
|
|
395
|
+
titleJsons = process.env.UNI_STAT_TITLE_JSON;
|
|
396
|
+
// #endif
|
|
397
|
+
|
|
398
|
+
const statConfig = {
|
|
399
|
+
appid: process.env.UNI_APP_ID,
|
|
400
|
+
};
|
|
401
|
+
const resultOptions = uni.getSystemInfoSync();
|
|
402
|
+
|
|
403
|
+
class Util {
|
|
404
|
+
constructor() {
|
|
405
|
+
this.self = '';
|
|
406
|
+
this._retry = 0;
|
|
407
|
+
this._platform = '';
|
|
408
|
+
this._query = {};
|
|
409
|
+
this._navigationBarTitle = {
|
|
410
|
+
config: '',
|
|
411
|
+
page: '',
|
|
412
|
+
report: '',
|
|
413
|
+
lt: '',
|
|
414
|
+
};
|
|
415
|
+
this._operatingTime = 0;
|
|
416
|
+
this._reportingRequestData = {
|
|
417
|
+
1: [],
|
|
418
|
+
11: [],
|
|
419
|
+
};
|
|
420
|
+
this.__prevent_triggering = false;
|
|
421
|
+
|
|
422
|
+
this.__licationHide = false;
|
|
423
|
+
this.__licationShow = false;
|
|
424
|
+
this._lastPageRoute = '';
|
|
425
|
+
this.statData = {
|
|
426
|
+
uuid: getUuid(),
|
|
427
|
+
ut: getPlatformName(),
|
|
428
|
+
mpn: getPackName(),
|
|
429
|
+
ak: statConfig.appid,
|
|
430
|
+
usv: STAT_VERSION,
|
|
431
|
+
v: getVersion(),
|
|
432
|
+
ch: getChannel(),
|
|
433
|
+
cn: '',
|
|
434
|
+
pn: '',
|
|
435
|
+
ct: '',
|
|
436
|
+
t: getTime(),
|
|
437
|
+
tt: '',
|
|
438
|
+
p: resultOptions.platform === 'android' ? 'a' : 'i',
|
|
439
|
+
brand: resultOptions.brand || '',
|
|
440
|
+
md: resultOptions.model,
|
|
441
|
+
sv: resultOptions.system.replace(/(Android|iOS)\s/, ''),
|
|
442
|
+
mpsdk: resultOptions.SDKVersion || '',
|
|
443
|
+
mpv: resultOptions.version || '',
|
|
444
|
+
lang: resultOptions.language,
|
|
445
|
+
pr: resultOptions.pixelRatio,
|
|
446
|
+
ww: resultOptions.windowWidth,
|
|
447
|
+
wh: resultOptions.windowHeight,
|
|
448
|
+
sw: resultOptions.screenWidth,
|
|
449
|
+
sh: resultOptions.screenHeight,
|
|
450
|
+
};
|
|
451
|
+
// 注册拦截器
|
|
452
|
+
let registerInterceptor =
|
|
453
|
+
typeof uni.addInterceptor === 'function' &&
|
|
454
|
+
process.env.NODE_ENV !== 'development';
|
|
455
|
+
if (registerInterceptor) {
|
|
456
|
+
this.addInterceptorInit();
|
|
457
|
+
this.interceptLogin();
|
|
458
|
+
this.interceptShare(true);
|
|
459
|
+
this.interceptRequestPayment();
|
|
460
|
+
}
|
|
461
|
+
}
|
|
462
|
+
|
|
463
|
+
addInterceptorInit() {
|
|
464
|
+
let self = this;
|
|
465
|
+
uni.addInterceptor('setNavigationBarTitle', {
|
|
466
|
+
invoke(args) {
|
|
467
|
+
self._navigationBarTitle.page = args.title;
|
|
468
|
+
},
|
|
469
|
+
});
|
|
470
|
+
}
|
|
471
|
+
|
|
472
|
+
interceptLogin() {
|
|
473
|
+
let self = this;
|
|
474
|
+
uni.addInterceptor('login', {
|
|
475
|
+
complete() {
|
|
476
|
+
self._login();
|
|
477
|
+
},
|
|
478
|
+
});
|
|
479
|
+
}
|
|
480
|
+
|
|
481
|
+
interceptShare(type) {
|
|
482
|
+
let self = this;
|
|
483
|
+
if (!type) {
|
|
484
|
+
self._share();
|
|
485
|
+
return
|
|
486
|
+
}
|
|
487
|
+
uni.addInterceptor('share', {
|
|
488
|
+
success() {
|
|
489
|
+
self._share();
|
|
490
|
+
},
|
|
491
|
+
fail() {
|
|
492
|
+
self._share();
|
|
493
|
+
},
|
|
494
|
+
});
|
|
495
|
+
}
|
|
496
|
+
|
|
497
|
+
interceptRequestPayment() {
|
|
498
|
+
let self = this;
|
|
499
|
+
uni.addInterceptor('requestPayment', {
|
|
500
|
+
success() {
|
|
501
|
+
self._payment('pay_success');
|
|
502
|
+
},
|
|
503
|
+
fail() {
|
|
504
|
+
self._payment('pay_fail');
|
|
505
|
+
},
|
|
506
|
+
});
|
|
507
|
+
}
|
|
508
|
+
|
|
509
|
+
getIsReportData() {
|
|
510
|
+
return isReportData()
|
|
511
|
+
}
|
|
512
|
+
|
|
513
|
+
_applicationShow() {
|
|
514
|
+
if (this.__licationHide) {
|
|
515
|
+
getLastTime();
|
|
516
|
+
const time = getResidenceTime('app');
|
|
517
|
+
if (time.overtime) {
|
|
518
|
+
let options = {
|
|
519
|
+
path: this._lastPageRoute,
|
|
520
|
+
scene: this.statData.sc,
|
|
521
|
+
};
|
|
522
|
+
this._sendReportRequest(options);
|
|
523
|
+
}
|
|
524
|
+
this.__licationHide = false;
|
|
525
|
+
}
|
|
526
|
+
}
|
|
527
|
+
|
|
528
|
+
_applicationHide(self, type) {
|
|
529
|
+
this.__licationHide = true;
|
|
530
|
+
getLastTime();
|
|
531
|
+
const time = getResidenceTime();
|
|
532
|
+
getFirstTime();
|
|
533
|
+
const route = getPageRoute(this);
|
|
534
|
+
this._sendHideRequest(
|
|
535
|
+
{
|
|
536
|
+
urlref: route,
|
|
537
|
+
urlref_ts: time.residenceTime,
|
|
538
|
+
},
|
|
539
|
+
type
|
|
540
|
+
);
|
|
541
|
+
}
|
|
542
|
+
|
|
543
|
+
_pageShow() {
|
|
544
|
+
const route = getPageRoute(this);
|
|
545
|
+
const routepath = getRoute();
|
|
546
|
+
this._navigationBarTitle.config =
|
|
547
|
+
(titleJsons && titleJsons[routepath]) || '';
|
|
548
|
+
if (this.__licationShow) {
|
|
549
|
+
getFirstTime();
|
|
550
|
+
this.__licationShow = false;
|
|
551
|
+
this._lastPageRoute = route;
|
|
552
|
+
return
|
|
553
|
+
}
|
|
554
|
+
|
|
555
|
+
getLastTime();
|
|
556
|
+
const time = getResidenceTime('page');
|
|
557
|
+
// 停留时间
|
|
558
|
+
if (time.overtime) {
|
|
559
|
+
let options = {
|
|
560
|
+
path: route,
|
|
561
|
+
scene: this.statData.sc,
|
|
562
|
+
};
|
|
563
|
+
this._sendReportRequest(options);
|
|
564
|
+
}
|
|
565
|
+
getFirstTime();
|
|
566
|
+
}
|
|
567
|
+
|
|
568
|
+
_pageHide() {
|
|
569
|
+
if (!this.__licationHide) {
|
|
570
|
+
getLastTime();
|
|
571
|
+
const time = getResidenceTime('page');
|
|
572
|
+
let route = getPageRoute(this);
|
|
573
|
+
if (!this._lastPageRoute) {
|
|
574
|
+
this._lastPageRoute = route;
|
|
575
|
+
}
|
|
576
|
+
this._sendPageRequest({
|
|
577
|
+
url: route,
|
|
578
|
+
urlref: this._lastPageRoute,
|
|
579
|
+
urlref_ts: time.residenceTime,
|
|
580
|
+
});
|
|
581
|
+
this._lastPageRoute = route;
|
|
582
|
+
this._navigationBarTitle = {
|
|
583
|
+
config: '',
|
|
584
|
+
page: '',
|
|
585
|
+
report: '',
|
|
586
|
+
lt: '',
|
|
587
|
+
};
|
|
588
|
+
return
|
|
589
|
+
}
|
|
590
|
+
}
|
|
591
|
+
|
|
592
|
+
_login() {
|
|
593
|
+
this._sendEventRequest(
|
|
594
|
+
{
|
|
595
|
+
key: 'login',
|
|
596
|
+
},
|
|
597
|
+
0
|
|
598
|
+
);
|
|
599
|
+
}
|
|
600
|
+
|
|
601
|
+
_share() {
|
|
602
|
+
this._sendEventRequest(
|
|
603
|
+
{
|
|
604
|
+
key: 'share',
|
|
605
|
+
},
|
|
606
|
+
0
|
|
607
|
+
);
|
|
608
|
+
}
|
|
609
|
+
_payment(key) {
|
|
610
|
+
this._sendEventRequest(
|
|
611
|
+
{
|
|
612
|
+
key,
|
|
613
|
+
},
|
|
614
|
+
0
|
|
615
|
+
);
|
|
616
|
+
}
|
|
617
|
+
_sendReportRequest(options) {
|
|
618
|
+
this._navigationBarTitle.lt = '1';
|
|
619
|
+
this._navigationBarTitle.config =
|
|
620
|
+
(titleJsons && titleJsons[options.path]) || '';
|
|
621
|
+
let query =
|
|
622
|
+
options.query && JSON.stringify(options.query) !== '{}'
|
|
623
|
+
? '?' + JSON.stringify(options.query)
|
|
624
|
+
: '';
|
|
625
|
+
this.statData.lt = '1';
|
|
626
|
+
this.statData.url = options.path + query || '';
|
|
627
|
+
this.statData.t = getTime();
|
|
628
|
+
this.statData.sc = getScene(options.scene);
|
|
629
|
+
this.statData.fvts = getFirstVisitTime();
|
|
630
|
+
this.statData.lvts = getLastVisitTime();
|
|
631
|
+
this.statData.tvc = getTotalVisitCount();
|
|
632
|
+
if (getPlatformName() === 'n') {
|
|
633
|
+
this.getProperty();
|
|
634
|
+
} else {
|
|
635
|
+
this.getNetworkInfo();
|
|
636
|
+
}
|
|
637
|
+
}
|
|
638
|
+
|
|
639
|
+
_sendPageRequest(opt) {
|
|
640
|
+
let { url, urlref, urlref_ts } = opt;
|
|
641
|
+
this._navigationBarTitle.lt = '11';
|
|
642
|
+
let options = {
|
|
643
|
+
ak: this.statData.ak,
|
|
644
|
+
uuid: this.statData.uuid,
|
|
645
|
+
lt: '11',
|
|
646
|
+
ut: this.statData.ut,
|
|
647
|
+
url,
|
|
648
|
+
tt: this.statData.tt,
|
|
649
|
+
urlref,
|
|
650
|
+
urlref_ts,
|
|
651
|
+
ch: this.statData.ch,
|
|
652
|
+
usv: this.statData.usv,
|
|
653
|
+
t: getTime(),
|
|
654
|
+
p: this.statData.p,
|
|
655
|
+
};
|
|
656
|
+
this.request(options);
|
|
657
|
+
}
|
|
658
|
+
|
|
659
|
+
_sendHideRequest(opt, type) {
|
|
660
|
+
let { urlref, urlref_ts } = opt;
|
|
661
|
+
let options = {
|
|
662
|
+
ak: this.statData.ak,
|
|
663
|
+
uuid: this.statData.uuid,
|
|
664
|
+
lt: '3',
|
|
665
|
+
ut: this.statData.ut,
|
|
666
|
+
urlref,
|
|
667
|
+
urlref_ts,
|
|
668
|
+
ch: this.statData.ch,
|
|
669
|
+
usv: this.statData.usv,
|
|
670
|
+
t: getTime(),
|
|
671
|
+
p: this.statData.p,
|
|
672
|
+
};
|
|
673
|
+
this.request(options, type);
|
|
674
|
+
}
|
|
675
|
+
_sendEventRequest({ key = '', value = '' } = {}) {
|
|
676
|
+
const route = this._lastPageRoute;
|
|
677
|
+
let options = {
|
|
678
|
+
ak: this.statData.ak,
|
|
679
|
+
uuid: this.statData.uuid,
|
|
680
|
+
lt: '21',
|
|
681
|
+
ut: this.statData.ut,
|
|
682
|
+
url: route,
|
|
683
|
+
ch: this.statData.ch,
|
|
684
|
+
e_n: key,
|
|
685
|
+
e_v: typeof value === 'object' ? JSON.stringify(value) : value.toString(),
|
|
686
|
+
usv: this.statData.usv,
|
|
687
|
+
t: getTime(),
|
|
688
|
+
p: this.statData.p,
|
|
689
|
+
};
|
|
690
|
+
this.request(options);
|
|
691
|
+
}
|
|
692
|
+
|
|
693
|
+
getNetworkInfo() {
|
|
694
|
+
uni.getNetworkType({
|
|
695
|
+
success: (result) => {
|
|
696
|
+
this.statData.net = result.networkType;
|
|
697
|
+
this.getLocation();
|
|
698
|
+
},
|
|
699
|
+
});
|
|
700
|
+
}
|
|
701
|
+
|
|
702
|
+
getProperty() {
|
|
703
|
+
plus.runtime.getProperty(plus.runtime.appid, (wgtinfo) => {
|
|
704
|
+
this.statData.v = wgtinfo.version || '';
|
|
705
|
+
this.getNetworkInfo();
|
|
706
|
+
});
|
|
707
|
+
}
|
|
708
|
+
|
|
709
|
+
getLocation() {
|
|
710
|
+
{
|
|
711
|
+
this.statData.lat = 0;
|
|
712
|
+
this.statData.lng = 0;
|
|
713
|
+
this.request(this.statData);
|
|
714
|
+
}
|
|
715
|
+
}
|
|
716
|
+
|
|
717
|
+
request(data, type) {
|
|
718
|
+
let time = getTime();
|
|
719
|
+
const title = this._navigationBarTitle;
|
|
720
|
+
data.ttn = title.page;
|
|
721
|
+
data.ttpj = title.config;
|
|
722
|
+
data.ttc = title.report;
|
|
723
|
+
let requestData = this._reportingRequestData;
|
|
724
|
+
if (getPlatformName() === 'n') {
|
|
725
|
+
requestData = uni.getStorageSync('__UNI__STAT__DATA') || {};
|
|
726
|
+
}
|
|
727
|
+
if (!requestData[data.lt]) {
|
|
728
|
+
requestData[data.lt] = [];
|
|
729
|
+
}
|
|
730
|
+
requestData[data.lt].push(data);
|
|
731
|
+
if (getPlatformName() === 'n') {
|
|
732
|
+
uni.setStorageSync('__UNI__STAT__DATA', requestData);
|
|
733
|
+
}
|
|
734
|
+
if (getPageResidenceTime() < OPERATING_TIME && !type) {
|
|
735
|
+
return
|
|
736
|
+
}
|
|
737
|
+
let uniStatData = this._reportingRequestData;
|
|
738
|
+
if (getPlatformName() === 'n') {
|
|
739
|
+
uniStatData = uni.getStorageSync('__UNI__STAT__DATA');
|
|
740
|
+
}
|
|
741
|
+
// 时间超过,重新获取时间戳
|
|
742
|
+
setPageResidenceTime();
|
|
743
|
+
let firstArr = [];
|
|
744
|
+
let contentArr = [];
|
|
745
|
+
let lastArr = [];
|
|
746
|
+
|
|
747
|
+
for (let i in uniStatData) {
|
|
748
|
+
const rd = uniStatData[i];
|
|
749
|
+
rd.forEach((elm) => {
|
|
750
|
+
const newData = getSplicing(elm);
|
|
751
|
+
if (i === 0) {
|
|
752
|
+
firstArr.push(newData);
|
|
753
|
+
} else if (i === 3) {
|
|
754
|
+
lastArr.push(newData);
|
|
755
|
+
} else {
|
|
756
|
+
contentArr.push(newData);
|
|
757
|
+
}
|
|
758
|
+
});
|
|
759
|
+
}
|
|
760
|
+
|
|
761
|
+
firstArr.push(...contentArr, ...lastArr);
|
|
762
|
+
let optionsData = {
|
|
763
|
+
usv: STAT_VERSION, //统计 SDK 版本号
|
|
764
|
+
t: time, //发送请求时的时间戮
|
|
765
|
+
requests: JSON.stringify(firstArr),
|
|
766
|
+
};
|
|
767
|
+
|
|
768
|
+
this._reportingRequestData = {};
|
|
769
|
+
if (getPlatformName() === 'n') {
|
|
770
|
+
uni.removeStorageSync('__UNI__STAT__DATA');
|
|
771
|
+
}
|
|
772
|
+
|
|
773
|
+
if (data.ut === 'h5') {
|
|
774
|
+
this.imageRequest(optionsData);
|
|
775
|
+
return
|
|
776
|
+
}
|
|
777
|
+
|
|
778
|
+
if (getPlatformName() === 'n' && this.statData.p === 'a') {
|
|
779
|
+
setTimeout(() => {
|
|
780
|
+
this._sendRequest(optionsData);
|
|
781
|
+
}, 200);
|
|
782
|
+
return
|
|
783
|
+
}
|
|
784
|
+
this._sendRequest(optionsData);
|
|
785
|
+
}
|
|
786
|
+
_sendRequest(optionsData) {
|
|
787
|
+
this.getIsReportData().then(() => {
|
|
788
|
+
uni.request({
|
|
789
|
+
url: STAT_URL,
|
|
790
|
+
method: 'POST',
|
|
791
|
+
data: optionsData,
|
|
792
|
+
success: () => {},
|
|
793
|
+
fail: (e) => {
|
|
794
|
+
if (++this._retry < 3) {
|
|
795
|
+
setTimeout(() => {
|
|
796
|
+
this._sendRequest(optionsData);
|
|
797
|
+
}, 1000);
|
|
798
|
+
}
|
|
799
|
+
},
|
|
800
|
+
});
|
|
801
|
+
});
|
|
802
|
+
}
|
|
803
|
+
/**
|
|
804
|
+
* h5 请求
|
|
805
|
+
*/
|
|
806
|
+
imageRequest(data) {
|
|
807
|
+
this.getIsReportData().then(() => {
|
|
808
|
+
let image = new Image();
|
|
809
|
+
let options = getSgin(GetEncodeURIComponentOptions(data)).options;
|
|
810
|
+
image.src = STAT_H5_URL + '?' + options;
|
|
811
|
+
});
|
|
812
|
+
}
|
|
813
|
+
|
|
814
|
+
sendEvent(key, value) {
|
|
815
|
+
// 校验 type 参数
|
|
816
|
+
if (calibration(key, value)) return
|
|
817
|
+
|
|
818
|
+
if (key === 'title') {
|
|
819
|
+
this._navigationBarTitle.report = value;
|
|
820
|
+
return
|
|
821
|
+
}
|
|
822
|
+
this._sendEventRequest(
|
|
823
|
+
{
|
|
824
|
+
key,
|
|
825
|
+
value: typeof value === 'object' ? JSON.stringify(value) : value,
|
|
826
|
+
},
|
|
827
|
+
1
|
|
828
|
+
);
|
|
829
|
+
}
|
|
830
|
+
}
|
|
831
|
+
|
|
832
|
+
class Stat extends Util {
|
|
833
|
+
static getInstance() {
|
|
834
|
+
if (!this.instance) {
|
|
835
|
+
this.instance = new Stat();
|
|
836
|
+
}
|
|
837
|
+
return this.instance
|
|
838
|
+
}
|
|
839
|
+
constructor() {
|
|
840
|
+
super();
|
|
841
|
+
this.instance = null;
|
|
842
|
+
}
|
|
843
|
+
|
|
844
|
+
report(options, self) {
|
|
845
|
+
// TODO 需要确认如果不用 $vm ,其他平台会不会出错
|
|
846
|
+
setPageResidenceTime();
|
|
847
|
+
this.__licationShow = true;
|
|
848
|
+
this._sendReportRequest(options, true);
|
|
849
|
+
}
|
|
850
|
+
|
|
851
|
+
load(options, self) {
|
|
852
|
+
this.self = self;
|
|
853
|
+
this._query = options;
|
|
854
|
+
}
|
|
855
|
+
|
|
856
|
+
show(self) {
|
|
857
|
+
this.self = self;
|
|
858
|
+
if (getPageTypes(self)) {
|
|
859
|
+
this._pageShow(self);
|
|
860
|
+
} else {
|
|
861
|
+
this._applicationShow(self);
|
|
862
|
+
}
|
|
863
|
+
}
|
|
864
|
+
ready(self) {}
|
|
865
|
+
hide(self) {
|
|
866
|
+
this.self = self;
|
|
867
|
+
if (getPageTypes(self)) {
|
|
868
|
+
this._pageHide(self);
|
|
869
|
+
} else {
|
|
870
|
+
this._applicationHide(self, true);
|
|
871
|
+
}
|
|
872
|
+
}
|
|
873
|
+
error(em) {
|
|
874
|
+
if (this._platform === 'devtools') {
|
|
875
|
+
if (process.env.NODE_ENV === 'development') {
|
|
876
|
+
console.info('当前运行环境为开发者工具,不上报数据。');
|
|
877
|
+
}
|
|
878
|
+
}
|
|
879
|
+
let emVal = '';
|
|
880
|
+
if (!em.message) {
|
|
881
|
+
emVal = JSON.stringify(em);
|
|
882
|
+
} else {
|
|
883
|
+
emVal = em.stack;
|
|
884
|
+
}
|
|
885
|
+
let options = {
|
|
886
|
+
ak: this.statData.ak,
|
|
887
|
+
uuid: this.statData.uuid,
|
|
888
|
+
lt: '31',
|
|
889
|
+
ut: this.statData.ut,
|
|
890
|
+
ch: this.statData.ch,
|
|
891
|
+
mpsdk: this.statData.mpsdk,
|
|
892
|
+
mpv: this.statData.mpv,
|
|
893
|
+
v: this.statData.v,
|
|
894
|
+
em: emVal,
|
|
895
|
+
usv: this.statData.usv,
|
|
896
|
+
t: getTime(),
|
|
897
|
+
p: this.statData.p,
|
|
898
|
+
};
|
|
899
|
+
this.request(options);
|
|
900
|
+
}
|
|
901
|
+
}
|
|
902
|
+
var Stat$1 = Stat;
|
|
903
|
+
|
|
904
|
+
const stat = Stat$1.getInstance();
|
|
905
|
+
let isHide = false;
|
|
906
|
+
const lifecycle = {
|
|
907
|
+
onLaunch(options) {
|
|
908
|
+
stat.report(options, this);
|
|
909
|
+
},
|
|
910
|
+
onReady() {
|
|
911
|
+
stat.ready(this);
|
|
912
|
+
},
|
|
913
|
+
onLoad(options) {
|
|
914
|
+
stat.load(options, this);
|
|
915
|
+
// 重写分享,获取分享上报事件
|
|
916
|
+
if (this.$scope && this.$scope.onShareAppMessage) {
|
|
917
|
+
let oldShareAppMessage = this.$scope.onShareAppMessage;
|
|
918
|
+
this.$scope.onShareAppMessage = function (options) {
|
|
919
|
+
stat.interceptShare(false);
|
|
920
|
+
return oldShareAppMessage.call(this, options)
|
|
921
|
+
};
|
|
922
|
+
}
|
|
923
|
+
},
|
|
924
|
+
onShow() {
|
|
925
|
+
isHide = false;
|
|
926
|
+
stat.show(this);
|
|
927
|
+
},
|
|
928
|
+
onHide() {
|
|
929
|
+
isHide = true;
|
|
930
|
+
stat.hide(this);
|
|
931
|
+
},
|
|
932
|
+
onUnload() {
|
|
933
|
+
if (isHide) {
|
|
934
|
+
isHide = false;
|
|
935
|
+
return
|
|
936
|
+
}
|
|
937
|
+
stat.hide(this);
|
|
938
|
+
},
|
|
939
|
+
onError(e) {
|
|
940
|
+
stat.error(e);
|
|
941
|
+
},
|
|
942
|
+
};
|
|
943
|
+
|
|
944
|
+
function main() {
|
|
945
|
+
if (process.env.NODE_ENV === 'development') {
|
|
946
|
+
uni.report = function (type, options) {};
|
|
947
|
+
} else {
|
|
948
|
+
uni.onAppLaunch((options) => {
|
|
949
|
+
stat.report(options);
|
|
950
|
+
// 小程序平台此时也无法获取getApp,统一在options中传递一个app对象
|
|
951
|
+
options.app.$vm.$.appContext.app.mixin(lifecycle);
|
|
952
|
+
uni.report = function (type, options) {
|
|
953
|
+
stat.sendEvent(type, options);
|
|
954
|
+
};
|
|
955
|
+
});
|
|
956
|
+
}
|
|
957
|
+
}
|
|
958
|
+
|
|
959
|
+
main();
|