提交 d18939e7 编写于 作者: Q qiang

chore: build

上级 7c8bb0cb
...@@ -1412,7 +1412,7 @@ var serviceContext = (function (vue) { ...@@ -1412,7 +1412,7 @@ var serviceContext = (function (vue) {
} }
this.formater = formater || defaultFormatter; this.formater = formater || defaultFormatter;
this.messages = messages || {}; this.messages = messages || {};
this.setLocale(locale); this.setLocale(locale || LOCALE_EN);
if (watcher) { if (watcher) {
this.watchLocale(watcher); this.watchLocale(watcher);
} }
......
因为 它太大了无法显示 source diff 。你可以改为 查看blob
...@@ -246,18 +246,14 @@ const getRoute = () => { ...@@ -246,18 +246,14 @@ const getRoute = () => {
if (getPlatformName() === 'bd') { if (getPlatformName() === 'bd') {
return _self.$mp && _self.$mp.page.is return _self.$mp && _self.$mp.page.is
} else { } else {
return _self.route || (_self.$mp && _self.$mp.page.route) return _self.route || (_self.$scope && _self.$scope.route)
} }
}; };
const getPageRoute = (self) => { const getPageRoute = (_this) => {
let route = getRoute(); let pageVm = _this.self;
let query = self._query; let page = pageVm.$page || pageVm.$scope.$page;
let str = return page.fullPath === '/' ? page.route : page.fullPath
query && JSON.stringify(query) !== '{}' ? '?' + JSON.stringify(query) : '';
// clear
self._query = '';
return route + str
}; };
const getPageTypes = (self) => { const getPageTypes = (self) => {
...@@ -389,7 +385,18 @@ const requestData = (done) => { ...@@ -389,7 +385,18 @@ const requestData = (done) => {
}); });
}; };
const titleJsons = process.env.UNI_STAT_TITLE_JSON; let titleJsons = {};
// #ifdef MP
let pagesTitle = require('uni-pages?{"type":"style"}').default;
pagesTitle = pagesTitle.pages;
for (let i in pagesTitle) {
titleJsons[i] = pagesTitle[i].navigationBarTitleText || '';
}
// #endif
// #ifndef MP
titleJsons = process.env.UNI_STAT_TITLE_JSON;
// #endif
const statConfig = { const statConfig = {
appid: process.env.UNI_APP_ID, appid: process.env.UNI_APP_ID,
}; };
...@@ -443,6 +450,62 @@ class Util { ...@@ -443,6 +450,62 @@ class Util {
sw: resultOptions.screenWidth, sw: resultOptions.screenWidth,
sh: resultOptions.screenHeight, sh: resultOptions.screenHeight,
}; };
// 注册拦截器
let registerInterceptor =
typeof uni.addInterceptor === 'function' &&
process.env.NODE_ENV !== 'development';
if (registerInterceptor) {
this.addInterceptorInit();
this.interceptLogin();
this.interceptShare(true);
this.interceptRequestPayment();
}
}
addInterceptorInit() {
let self = this;
uni.addInterceptor('setNavigationBarTitle', {
invoke(args) {
self._navigationBarTitle.page = args.title;
},
});
}
interceptLogin() {
let self = this;
uni.addInterceptor('login', {
complete() {
self._login();
},
});
}
interceptShare(type) {
let self = this;
if (!type) {
self._share();
return
}
uni.addInterceptor('share', {
success() {
self._share();
},
fail() {
self._share();
},
});
}
interceptRequestPayment() {
let self = this;
uni.addInterceptor('requestPayment', {
success() {
self._payment('pay_success');
},
fail() {
self._payment('pay_fail');
},
});
} }
getIsReportData() { getIsReportData() {
...@@ -482,12 +545,11 @@ class Util { ...@@ -482,12 +545,11 @@ class Util {
_pageShow() { _pageShow() {
const route = getPageRoute(this); const route = getPageRoute(this);
const routepath = getRoute(); const routepath = getRoute();
this._navigationBarTitle.config = titleJsons[routepath] || ''; this._navigationBarTitle.config =
(titleJsons && titleJsons[routepath]) || '';
if (this.__licationShow) { if (this.__licationShow) {
getFirstTime(); getFirstTime();
this.__licationShow = false; this.__licationShow = false;
// console.log('这是 onLauch 之后执行的第一次 pageShow ,为下次记录时间做准备');
this._lastPageRoute = route; this._lastPageRoute = route;
return return
} }
...@@ -509,7 +571,10 @@ class Util { ...@@ -509,7 +571,10 @@ class Util {
if (!this.__licationHide) { if (!this.__licationHide) {
getLastTime(); getLastTime();
const time = getResidenceTime('page'); const time = getResidenceTime('page');
const route = getPageRoute(this); let route = getPageRoute(this);
if (!this._lastPageRoute) {
this._lastPageRoute = route;
}
this._sendPageRequest({ this._sendPageRequest({
url: route, url: route,
urlref: this._lastPageRoute, urlref: this._lastPageRoute,
...@@ -553,6 +618,8 @@ class Util { ...@@ -553,6 +618,8 @@ class Util {
} }
_sendReportRequest(options) { _sendReportRequest(options) {
this._navigationBarTitle.lt = '1'; this._navigationBarTitle.lt = '1';
this._navigationBarTitle.config =
(titleJsons && titleJsons[options.path]) || '';
let query = let query =
options.query && JSON.stringify(options.query) !== '{}' options.query && JSON.stringify(options.query) !== '{}'
? '?' + JSON.stringify(options.query) ? '?' + JSON.stringify(options.query)
...@@ -663,7 +730,6 @@ class Util { ...@@ -663,7 +730,6 @@ class Util {
requestData[data.lt] = []; requestData[data.lt] = [];
} }
requestData[data.lt].push(data); requestData[data.lt].push(data);
if (getPlatformName() === 'n') { if (getPlatformName() === 'n') {
uni.setStorageSync('__UNI__STAT__DATA', requestData); uni.setStorageSync('__UNI__STAT__DATA', requestData);
} }
...@@ -725,11 +791,7 @@ class Util { ...@@ -725,11 +791,7 @@ class Util {
url: STAT_URL, url: STAT_URL,
method: 'POST', method: 'POST',
data: optionsData, data: optionsData,
success: () => { success: () => {},
// if (process.env.NODE_ENV === 'development') {
// console.log('stat request success');
// }
},
fail: (e) => { fail: (e) => {
if (++this._retry < 3) { if (++this._retry < 3) {
setTimeout(() => { setTimeout(() => {
...@@ -779,77 +841,16 @@ class Stat extends Util { ...@@ -779,77 +841,16 @@ class Stat extends Util {
constructor() { constructor() {
super(); super();
this.instance = null; this.instance = null;
// 注册拦截器
if (
typeof uni.addInterceptor === 'function' &&
process.env.NODE_ENV !== 'development'
) {
this.addInterceptorInit();
this.interceptLogin();
this.interceptShare(true);
this.interceptRequestPayment();
}
}
addInterceptorInit() {
let self = this;
uni.addInterceptor('setNavigationBarTitle', {
invoke(args) {
self._navigationBarTitle.page = args.title;
},
});
}
interceptLogin() {
let self = this;
uni.addInterceptor('login', {
complete() {
self._login();
},
});
}
interceptShare(type) {
let self = this;
if (!type) {
self._share();
return
}
uni.addInterceptor('share', {
success() {
self._share();
},
fail() {
self._share();
},
});
}
interceptRequestPayment() {
let self = this;
uni.addInterceptor('requestPayment', {
success() {
self._payment('pay_success');
},
fail() {
self._payment('pay_fail');
},
});
} }
report(options, self) { report(options, self) {
this.self = self; // TODO 需要确认如果不用 $vm ,其他平台会不会出错
setPageResidenceTime(); setPageResidenceTime();
this.__licationShow = true; this.__licationShow = true;
this._sendReportRequest(options, true); this._sendReportRequest(options, true);
} }
load(options, self) { load(options, self) {
// if (!self.$scope && !self.$mp) {
// const page = getCurrentPages()
// console.log();
// self.$scope = page[page.length - 1]
// }
this.self = self; this.self = self;
this._query = options; this._query = options;
} }
...@@ -862,13 +863,7 @@ class Stat extends Util { ...@@ -862,13 +863,7 @@ class Stat extends Util {
this._applicationShow(self); this._applicationShow(self);
} }
} }
ready(self) {}
ready(self) {
// this.self = self;
// if (getPageTypes(self)) {
// this._pageShow(self);
// }
}
hide(self) { hide(self) {
this.self = self; this.self = self;
if (getPageTypes(self)) { if (getPageTypes(self)) {
...@@ -882,7 +877,6 @@ class Stat extends Util { ...@@ -882,7 +877,6 @@ class Stat extends Util {
if (process.env.NODE_ENV === 'development') { if (process.env.NODE_ENV === 'development') {
console.info('当前运行环境为开发者工具,不上报数据。'); console.info('当前运行环境为开发者工具,不上报数据。');
} }
// return;
} }
let emVal = ''; let emVal = '';
if (!em.message) { if (!em.message) {
...@@ -913,15 +907,12 @@ const stat = Stat$1.getInstance(); ...@@ -913,15 +907,12 @@ const stat = Stat$1.getInstance();
let isHide = false; let isHide = false;
const lifecycle = { const lifecycle = {
onLaunch(options) { onLaunch(options) {
console.log('report onLaunch init');
stat.report(options, this); stat.report(options, this);
}, },
onReady() { onReady() {
console.log('report onReady init');
stat.ready(this); stat.ready(this);
}, },
onLoad(options) { onLoad(options) {
console.log('report onLoad init');
stat.load(options, this); stat.load(options, this);
// 重写分享,获取分享上报事件 // 重写分享,获取分享上报事件
if (this.$scope && this.$scope.onShareAppMessage) { if (this.$scope && this.$scope.onShareAppMessage) {
...@@ -933,17 +924,14 @@ const lifecycle = { ...@@ -933,17 +924,14 @@ const lifecycle = {
} }
}, },
onShow() { onShow() {
console.log('report onShow init');
isHide = false; isHide = false;
stat.show(this); stat.show(this);
}, },
onHide() { onHide() {
console.log('report onHide init');
isHide = true; isHide = true;
stat.hide(this); stat.hide(this);
}, },
onUnload() { onUnload() {
console.log('report onUnload init');
if (isHide) { if (isHide) {
isHide = false; isHide = false;
return return
...@@ -951,29 +939,23 @@ const lifecycle = { ...@@ -951,29 +939,23 @@ const lifecycle = {
stat.hide(this); stat.hide(this);
}, },
onError(e) { onError(e) {
console.log('report onError init');
stat.error(e); stat.error(e);
}, },
}; };
function main() { function main() {
console.log('stat onload ----'); if (process.env.NODE_ENV === 'development') {
uni.onAppLaunch((options) => { uni.report = function (type, options) {};
// 小程序平台此时也无法获取getApp,统一在options中传递一个app对象 } else {
options.app.$vm.$.appContext.app.mixin(lifecycle); uni.onAppLaunch((options) => {
uni.report = function (type, options) { stat.report(options);
stat.sendEvent(type, options); // 小程序平台此时也无法获取getApp,统一在options中传递一个app对象
}; options.app.$vm.$.appContext.app.mixin(lifecycle);
}); uni.report = function (type, options) {
// if (process.env.NODE_ENV === 'development') { stat.sendEvent(type, options);
// uni.report = function (type, options) {} };
// } else { });
// const Vue = require('vue') }
// ;(Vue.default || Vue).mixin(lifecycle)
// uni.report = function (type, options) {
// stat.sendEvent(type, options)
// }
// }
} }
main(); main();
...@@ -244,18 +244,14 @@ const getRoute = () => { ...@@ -244,18 +244,14 @@ const getRoute = () => {
if (getPlatformName() === 'bd') { if (getPlatformName() === 'bd') {
return _self.$mp && _self.$mp.page.is return _self.$mp && _self.$mp.page.is
} else { } else {
return _self.route || (_self.$mp && _self.$mp.page.route) return _self.route || (_self.$scope && _self.$scope.route)
} }
}; };
const getPageRoute = (self) => { const getPageRoute = (_this) => {
let route = getRoute(); let pageVm = _this.self;
let query = self._query; let page = pageVm.$page || pageVm.$scope.$page;
let str = return page.fullPath === '/' ? page.route : page.fullPath
query && JSON.stringify(query) !== '{}' ? '?' + JSON.stringify(query) : '';
// clear
self._query = '';
return route + str
}; };
const getPageTypes = (self) => { const getPageTypes = (self) => {
...@@ -387,7 +383,18 @@ const requestData = (done) => { ...@@ -387,7 +383,18 @@ const requestData = (done) => {
}); });
}; };
const titleJsons = process.env.UNI_STAT_TITLE_JSON; let titleJsons = {};
// #ifdef MP
let pagesTitle = require('uni-pages?{"type":"style"}').default;
pagesTitle = pagesTitle.pages;
for (let i in pagesTitle) {
titleJsons[i] = pagesTitle[i].navigationBarTitleText || '';
}
// #endif
// #ifndef MP
titleJsons = process.env.UNI_STAT_TITLE_JSON;
// #endif
const statConfig = { const statConfig = {
appid: process.env.UNI_APP_ID, appid: process.env.UNI_APP_ID,
}; };
...@@ -441,6 +448,62 @@ class Util { ...@@ -441,6 +448,62 @@ class Util {
sw: resultOptions.screenWidth, sw: resultOptions.screenWidth,
sh: resultOptions.screenHeight, sh: resultOptions.screenHeight,
}; };
// 注册拦截器
let registerInterceptor =
typeof uni.addInterceptor === 'function' &&
process.env.NODE_ENV !== 'development';
if (registerInterceptor) {
this.addInterceptorInit();
this.interceptLogin();
this.interceptShare(true);
this.interceptRequestPayment();
}
}
addInterceptorInit() {
let self = this;
uni.addInterceptor('setNavigationBarTitle', {
invoke(args) {
self._navigationBarTitle.page = args.title;
},
});
}
interceptLogin() {
let self = this;
uni.addInterceptor('login', {
complete() {
self._login();
},
});
}
interceptShare(type) {
let self = this;
if (!type) {
self._share();
return
}
uni.addInterceptor('share', {
success() {
self._share();
},
fail() {
self._share();
},
});
}
interceptRequestPayment() {
let self = this;
uni.addInterceptor('requestPayment', {
success() {
self._payment('pay_success');
},
fail() {
self._payment('pay_fail');
},
});
} }
getIsReportData() { getIsReportData() {
...@@ -480,12 +543,11 @@ class Util { ...@@ -480,12 +543,11 @@ class Util {
_pageShow() { _pageShow() {
const route = getPageRoute(this); const route = getPageRoute(this);
const routepath = getRoute(); const routepath = getRoute();
this._navigationBarTitle.config = titleJsons[routepath] || ''; this._navigationBarTitle.config =
(titleJsons && titleJsons[routepath]) || '';
if (this.__licationShow) { if (this.__licationShow) {
getFirstTime(); getFirstTime();
this.__licationShow = false; this.__licationShow = false;
// console.log('这是 onLauch 之后执行的第一次 pageShow ,为下次记录时间做准备');
this._lastPageRoute = route; this._lastPageRoute = route;
return return
} }
...@@ -507,7 +569,10 @@ class Util { ...@@ -507,7 +569,10 @@ class Util {
if (!this.__licationHide) { if (!this.__licationHide) {
getLastTime(); getLastTime();
const time = getResidenceTime('page'); const time = getResidenceTime('page');
const route = getPageRoute(this); let route = getPageRoute(this);
if (!this._lastPageRoute) {
this._lastPageRoute = route;
}
this._sendPageRequest({ this._sendPageRequest({
url: route, url: route,
urlref: this._lastPageRoute, urlref: this._lastPageRoute,
...@@ -551,6 +616,8 @@ class Util { ...@@ -551,6 +616,8 @@ class Util {
} }
_sendReportRequest(options) { _sendReportRequest(options) {
this._navigationBarTitle.lt = '1'; this._navigationBarTitle.lt = '1';
this._navigationBarTitle.config =
(titleJsons && titleJsons[options.path]) || '';
let query = let query =
options.query && JSON.stringify(options.query) !== '{}' options.query && JSON.stringify(options.query) !== '{}'
? '?' + JSON.stringify(options.query) ? '?' + JSON.stringify(options.query)
...@@ -661,7 +728,6 @@ class Util { ...@@ -661,7 +728,6 @@ class Util {
requestData[data.lt] = []; requestData[data.lt] = [];
} }
requestData[data.lt].push(data); requestData[data.lt].push(data);
if (getPlatformName() === 'n') { if (getPlatformName() === 'n') {
uni.setStorageSync('__UNI__STAT__DATA', requestData); uni.setStorageSync('__UNI__STAT__DATA', requestData);
} }
...@@ -723,11 +789,7 @@ class Util { ...@@ -723,11 +789,7 @@ class Util {
url: STAT_URL, url: STAT_URL,
method: 'POST', method: 'POST',
data: optionsData, data: optionsData,
success: () => { success: () => {},
// if (process.env.NODE_ENV === 'development') {
// console.log('stat request success');
// }
},
fail: (e) => { fail: (e) => {
if (++this._retry < 3) { if (++this._retry < 3) {
setTimeout(() => { setTimeout(() => {
...@@ -777,77 +839,16 @@ class Stat extends Util { ...@@ -777,77 +839,16 @@ class Stat extends Util {
constructor() { constructor() {
super(); super();
this.instance = null; this.instance = null;
// 注册拦截器
if (
typeof uni.addInterceptor === 'function' &&
process.env.NODE_ENV !== 'development'
) {
this.addInterceptorInit();
this.interceptLogin();
this.interceptShare(true);
this.interceptRequestPayment();
}
}
addInterceptorInit() {
let self = this;
uni.addInterceptor('setNavigationBarTitle', {
invoke(args) {
self._navigationBarTitle.page = args.title;
},
});
}
interceptLogin() {
let self = this;
uni.addInterceptor('login', {
complete() {
self._login();
},
});
}
interceptShare(type) {
let self = this;
if (!type) {
self._share();
return
}
uni.addInterceptor('share', {
success() {
self._share();
},
fail() {
self._share();
},
});
}
interceptRequestPayment() {
let self = this;
uni.addInterceptor('requestPayment', {
success() {
self._payment('pay_success');
},
fail() {
self._payment('pay_fail');
},
});
} }
report(options, self) { report(options, self) {
this.self = self; // TODO 需要确认如果不用 $vm ,其他平台会不会出错
setPageResidenceTime(); setPageResidenceTime();
this.__licationShow = true; this.__licationShow = true;
this._sendReportRequest(options, true); this._sendReportRequest(options, true);
} }
load(options, self) { load(options, self) {
// if (!self.$scope && !self.$mp) {
// const page = getCurrentPages()
// console.log();
// self.$scope = page[page.length - 1]
// }
this.self = self; this.self = self;
this._query = options; this._query = options;
} }
...@@ -860,13 +861,7 @@ class Stat extends Util { ...@@ -860,13 +861,7 @@ class Stat extends Util {
this._applicationShow(self); this._applicationShow(self);
} }
} }
ready(self) {}
ready(self) {
// this.self = self;
// if (getPageTypes(self)) {
// this._pageShow(self);
// }
}
hide(self) { hide(self) {
this.self = self; this.self = self;
if (getPageTypes(self)) { if (getPageTypes(self)) {
...@@ -880,7 +875,6 @@ class Stat extends Util { ...@@ -880,7 +875,6 @@ class Stat extends Util {
if (process.env.NODE_ENV === 'development') { if (process.env.NODE_ENV === 'development') {
console.info('当前运行环境为开发者工具,不上报数据。'); console.info('当前运行环境为开发者工具,不上报数据。');
} }
// return;
} }
let emVal = ''; let emVal = '';
if (!em.message) { if (!em.message) {
...@@ -911,15 +905,12 @@ const stat = Stat$1.getInstance(); ...@@ -911,15 +905,12 @@ const stat = Stat$1.getInstance();
let isHide = false; let isHide = false;
const lifecycle = { const lifecycle = {
onLaunch(options) { onLaunch(options) {
console.log('report onLaunch init');
stat.report(options, this); stat.report(options, this);
}, },
onReady() { onReady() {
console.log('report onReady init');
stat.ready(this); stat.ready(this);
}, },
onLoad(options) { onLoad(options) {
console.log('report onLoad init');
stat.load(options, this); stat.load(options, this);
// 重写分享,获取分享上报事件 // 重写分享,获取分享上报事件
if (this.$scope && this.$scope.onShareAppMessage) { if (this.$scope && this.$scope.onShareAppMessage) {
...@@ -931,17 +922,14 @@ const lifecycle = { ...@@ -931,17 +922,14 @@ const lifecycle = {
} }
}, },
onShow() { onShow() {
console.log('report onShow init');
isHide = false; isHide = false;
stat.show(this); stat.show(this);
}, },
onHide() { onHide() {
console.log('report onHide init');
isHide = true; isHide = true;
stat.hide(this); stat.hide(this);
}, },
onUnload() { onUnload() {
console.log('report onUnload init');
if (isHide) { if (isHide) {
isHide = false; isHide = false;
return return
...@@ -949,29 +937,23 @@ const lifecycle = { ...@@ -949,29 +937,23 @@ const lifecycle = {
stat.hide(this); stat.hide(this);
}, },
onError(e) { onError(e) {
console.log('report onError init');
stat.error(e); stat.error(e);
}, },
}; };
function main() { function main() {
console.log('stat onload ----'); if (process.env.NODE_ENV === 'development') {
uni.onAppLaunch((options) => { uni.report = function (type, options) {};
// 小程序平台此时也无法获取getApp,统一在options中传递一个app对象 } else {
options.app.$vm.$.appContext.app.mixin(lifecycle); uni.onAppLaunch((options) => {
uni.report = function (type, options) { stat.report(options);
stat.sendEvent(type, options); // 小程序平台此时也无法获取getApp,统一在options中传递一个app对象
}; options.app.$vm.$.appContext.app.mixin(lifecycle);
}); uni.report = function (type, options) {
// if (process.env.NODE_ENV === 'development') { stat.sendEvent(type, options);
// uni.report = function (type, options) {} };
// } else { });
// const Vue = require('vue') }
// ;(Vue.default || Vue).mixin(lifecycle)
// uni.report = function (type, options) {
// stat.sendEvent(type, options)
// }
// }
} }
main(); main();
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册