|
@@ -2,28 +2,13 @@ |
|
@@ -2,28 +2,13 @@ |
2
|
import wx from './utils/wx';
|
2
|
import wx from './utils/wx';
|
3
|
import udid from './common/udid';
|
3
|
import udid from './common/udid';
|
4
|
import event from './common/event';
|
4
|
import event from './common/event';
|
5
|
-import promisify from './common/promisify';
|
|
|
6
|
import objectAssign from './vendors/object-assign';
|
5
|
import objectAssign from './vendors/object-assign';
|
7
|
import {WeToast} from './vendors/toast/wetoast';
|
6
|
import {WeToast} from './vendors/toast/wetoast';
|
8
|
import config from './common/config';
|
7
|
import config from './common/config';
|
9
|
import {GET, POST} from './common/request';
|
8
|
import {GET, POST} from './common/request';
|
10
|
-import {Encrypt,Decrypt} from './common/aes.js';
|
|
|
11
|
-let crypto = require('./common/cryptojs/cryptojs.js').Crypto
|
|
|
12
|
import md5 from './vendors/md5';
|
9
|
import md5 from './vendors/md5';
|
13
|
-var mta = require('./vendors/mta_analysis.js')
|
|
|
14
|
-import { wechatLoginAction } from './utils/login';
|
|
|
15
|
-import { isStringEmpty } from './utils/util';
|
|
|
16
|
-
|
|
|
17
|
-import { logEvent,
|
|
|
18
|
- YB_LAUNCH_APP,
|
|
|
19
|
- YB_EXIT_APP,
|
|
|
20
|
- YB_ENTER_FOREGROUND,
|
|
|
21
|
- YB_ENTER_BACKGROUND,
|
|
|
22
|
- YB_PAGE_OPEN_L,
|
|
|
23
|
- YB_AWAKE_MP
|
|
|
24
|
- } from './common/analytics.js';
|
|
|
25
|
-
|
|
|
26
|
-import { appReport } from './common/appReport.js';
|
10
|
+import {wechatLoginAction} from './utils/login';
|
|
|
11
|
+import {isStringEmpty} from './utils/util';
|
27
|
|
12
|
|
28
|
App({
|
13
|
App({
|
29
|
onLaunch: function (options) {
|
14
|
onLaunch: function (options) {
|
|
@@ -39,14 +24,14 @@ App({ |
|
@@ -39,14 +24,14 @@ App({ |
39
|
this.globalData.systemInfo = res;
|
24
|
this.globalData.systemInfo = res;
|
40
|
this.checkUDID();
|
25
|
this.checkUDID();
|
41
|
|
26
|
|
42
|
- that.getSimplePise()
|
|
|
43
|
- this.checkNetworkType()
|
27
|
+ that.getSimplePise();
|
|
|
28
|
+ this.checkNetworkType();
|
44
|
|
29
|
|
45
|
- if (options && options.scene){
|
30
|
+ if (options && options.scene) {
|
46
|
this.globalData.ch = options.scene
|
31
|
this.globalData.ch = options.scene
|
47
|
}
|
32
|
}
|
48
|
|
33
|
|
49
|
- if (options && options.query && options.query.union_type){
|
34
|
+ if (options && options.query && options.query.union_type) {
|
50
|
this.globalData.union_type = options.query.union_type
|
35
|
this.globalData.union_type = options.query.union_type
|
51
|
}
|
36
|
}
|
52
|
|
37
|
|
|
@@ -73,60 +58,27 @@ App({ |
|
@@ -73,60 +58,27 @@ App({ |
73
|
data: ""
|
58
|
data: ""
|
74
|
});
|
59
|
});
|
75
|
}
|
60
|
}
|
76
|
- })
|
61
|
+ });
|
|
|
62
|
+
|
77
|
this.getSessionkey();
|
63
|
this.getSessionkey();
|
78
|
- let timestamp = new Date().getTime() + ''
|
64
|
+ let timestamp = new Date().getTime() + '';
|
79
|
this.globalData.sid = md5(timestamp);
|
65
|
this.globalData.sid = md5(timestamp);
|
80
|
|
66
|
|
81
|
- if (options){
|
67
|
+ if (options) {
|
82
|
let channel = options.query.channel;
|
68
|
let channel = options.query.channel;
|
83
|
let channelType = options.query.type;
|
69
|
let channelType = options.query.type;
|
84
|
- let params = { 'CHANNEL': channel, 'TYPE': channelType };
|
|
|
85
|
- logEvent(YB_LAUNCH_APP, params, this);
|
70
|
+ let params = {'CHANNEL': channel, 'TYPE': channelType};
|
86
|
}
|
71
|
}
|
87
|
setTimeout(function () {
|
72
|
setTimeout(function () {
|
88
|
- wechatLoginAction(function (response) {});}, 1000);
|
73
|
+ wechatLoginAction(() => '');
|
|
|
74
|
+ }, 1000);
|
89
|
|
75
|
|
90
|
this.mtainit(options);
|
76
|
this.mtainit(options);
|
91
|
},
|
77
|
},
|
92
|
|
78
|
|
93
|
- //当应用程序进入前台显示状态时触发
|
|
|
94
|
- onShow(options) {
|
|
|
95
|
- let that = this
|
|
|
96
|
- let params = {};
|
|
|
97
|
- logEvent(YB_ENTER_FOREGROUND, params, this)
|
|
|
98
|
- if (that.globalData.hasReportAwakeAction==='false'){
|
|
|
99
|
- let pathParam = ""
|
|
|
100
|
- if(options && options.query) {
|
|
|
101
|
- for (var Key in options.query) {
|
|
|
102
|
- if (pathParam.length == 0) {
|
|
|
103
|
- pathParam = Key + '=' + options.query[Key] + '';
|
|
|
104
|
- } else {
|
|
|
105
|
- pathParam = pathParam + '&' + '' + Key + '=' + options.query[Key] + '';
|
|
|
106
|
- }
|
|
|
107
|
- }
|
|
|
108
|
- }
|
|
|
109
|
- let path
|
|
|
110
|
- if(pathParam!==""){
|
|
|
111
|
- path = options.path + "?" + pathParam
|
|
|
112
|
- }else{
|
|
|
113
|
- path = options.path
|
|
|
114
|
- }
|
|
|
115
|
- params = {
|
|
|
116
|
- PAGE_PATH: path
|
|
|
117
|
- };
|
|
|
118
|
- logEvent(YB_AWAKE_MP, params, this);
|
|
|
119
|
- that.globalData.hasReportAwakeAction = 'true'
|
|
|
120
|
- }
|
|
|
121
|
- appReport('start', "LIFECYCLE", "RESUME", {},this)
|
|
|
122
|
- },
|
79
|
+ onShow() {},
|
123
|
|
80
|
|
124
|
- //当应用程序进入后台状态时触发
|
|
|
125
|
- onHide () {
|
|
|
126
|
- let params = {};
|
|
|
127
|
- logEvent(YB_ENTER_BACKGROUND,params)
|
|
|
128
|
- appReport('start', "LIFECYCLE", "STOP", {},this)
|
|
|
129
|
- },
|
81
|
+ onHide () {},
|
130
|
|
82
|
|
131
|
getUserInfo: function () {
|
83
|
getUserInfo: function () {
|
132
|
try {
|
84
|
try {
|
|
@@ -156,7 +108,7 @@ App({ |
|
@@ -156,7 +108,7 @@ App({ |
156
|
var value = this.globalData.WXThird_session
|
108
|
var value = this.globalData.WXThird_session
|
157
|
if (!isStringEmpty(value)) {
|
109
|
if (!isStringEmpty(value)) {
|
158
|
that.globalData.WXThird_session = value;
|
110
|
that.globalData.WXThird_session = value;
|
159
|
- }else{
|
111
|
+ } else {
|
160
|
value = wx.getStorageSync('WXThird_session')
|
112
|
value = wx.getStorageSync('WXThird_session')
|
161
|
}
|
113
|
}
|
162
|
return value
|
114
|
return value
|
|
@@ -197,9 +149,9 @@ App({ |
|
@@ -197,9 +149,9 @@ App({ |
197
|
})
|
149
|
})
|
198
|
},
|
150
|
},
|
199
|
|
151
|
|
200
|
- setOpenID:function(openID){
|
152
|
+ setOpenID: function (openID) {
|
201
|
|
153
|
|
202
|
- if(openID=='') return
|
154
|
+ if (openID == '') return
|
203
|
this.globalData.openID = openID;
|
155
|
this.globalData.openID = openID;
|
204
|
wx.setStorage({
|
156
|
wx.setStorage({
|
205
|
key: "openID",
|
157
|
key: "openID",
|
|
@@ -209,9 +161,9 @@ App({ |
|
@@ -209,9 +161,9 @@ App({ |
209
|
|
161
|
|
210
|
getOpenID: function () {
|
162
|
getOpenID: function () {
|
211
|
let openid = ''
|
163
|
let openid = ''
|
212
|
- if (!isStringEmpty(this.globalData.openID)){
|
164
|
+ if (!isStringEmpty(this.globalData.openID)) {
|
213
|
openid = this.globalData.openID
|
165
|
openid = this.globalData.openID
|
214
|
- }else{
|
166
|
+ } else {
|
215
|
openid = wx.getStorageSync('openID')
|
167
|
openid = wx.getStorageSync('openID')
|
216
|
this.globalData.openID = openid
|
168
|
this.globalData.openID = openid
|
217
|
}
|
169
|
}
|
|
@@ -233,27 +185,24 @@ App({ |
|
@@ -233,27 +185,24 @@ App({ |
233
|
systemInfo: null,
|
185
|
systemInfo: null,
|
234
|
WXThird_session: '',
|
186
|
WXThird_session: '',
|
235
|
WXUnion_ID: '',
|
187
|
WXUnion_ID: '',
|
236
|
- openID:'',
|
188
|
+ openID: '',
|
237
|
p2SecretKey: '',
|
189
|
p2SecretKey: '',
|
238
|
sessionkey: '',
|
190
|
sessionkey: '',
|
239
|
sid: '',
|
191
|
sid: '',
|
240
|
- udid:'',
|
|
|
241
|
- cid:'1',
|
|
|
242
|
- mobileRegisterState:'',
|
192
|
+ udid: '',
|
|
|
193
|
+ cid: '1',
|
|
|
194
|
+ mobileRegisterState: '',
|
243
|
hasReportAwakeAction: 'false',
|
195
|
hasReportAwakeAction: 'false',
|
244
|
- defraudurl:'https://activity.yoho.cn/feature/45.html?title=防诈骗提醒',
|
196
|
+ defraudurl: 'https://activity.yoho.cn/feature/45.html?title=防诈骗提醒',
|
245
|
miniapp_type: config.constants.MINI_APP_TYPE,
|
197
|
miniapp_type: config.constants.MINI_APP_TYPE,
|
246
|
- union_type:'',
|
|
|
247
|
- ch:'',
|
|
|
248
|
- networkType:'0',
|
|
|
249
|
- deviceInfo:{},
|
198
|
+ union_type: '',
|
|
|
199
|
+ ch: '',
|
|
|
200
|
+ networkType: '0',
|
|
|
201
|
+ deviceInfo: {}
|
250
|
},
|
202
|
},
|
251
|
|
203
|
|
252
|
isLogin: function () {
|
204
|
isLogin: function () {
|
253
|
return this.globalData.userInfo != null &&
|
205
|
return this.globalData.userInfo != null &&
|
254
|
- // this.globalData.userInfo.uid != undefined &&
|
|
|
255
|
- // this.globalData.userInfo.uid != null &&
|
|
|
256
|
- // this.globalData.userInfo.uid != '' &&
|
|
|
257
|
this.globalData.WXThird_session != '' &&
|
206
|
this.globalData.WXThird_session != '' &&
|
258
|
this.globalData.WXThird_session != null &&
|
207
|
this.globalData.WXThird_session != null &&
|
259
|
this.globalData.WXThird_session != undefined;
|
208
|
this.globalData.WXThird_session != undefined;
|
|
@@ -261,14 +210,14 @@ App({ |
|
@@ -261,14 +210,14 @@ App({ |
261
|
|
210
|
|
262
|
getUid: function () {
|
211
|
getUid: function () {
|
263
|
let uid = this.globalData.userInfo.uid
|
212
|
let uid = this.globalData.userInfo.uid
|
264
|
- if(!uid||uid===0){
|
213
|
+ if (!uid || uid === 0) {
|
265
|
this.getUserInfo();
|
214
|
this.getUserInfo();
|
266
|
uid = this.globalData.userInfo.uid
|
215
|
uid = this.globalData.userInfo.uid
|
267
|
}
|
216
|
}
|
268
|
return uid;
|
217
|
return uid;
|
269
|
},
|
218
|
},
|
270
|
|
219
|
|
271
|
- getMiniappType:function(){
|
220
|
+ getMiniappType: function () {
|
272
|
return config.constants.MINI_APP_TYPE
|
221
|
return config.constants.MINI_APP_TYPE
|
273
|
},
|
222
|
},
|
274
|
|
223
|
|
|
@@ -277,20 +226,20 @@ App({ |
|
@@ -277,20 +226,20 @@ App({ |
277
|
let that = this
|
226
|
let that = this
|
278
|
let data = {
|
227
|
let data = {
|
279
|
"udid": that.globalData.udid,
|
228
|
"udid": that.globalData.udid,
|
280
|
- "method": 'resources.simple.pice'}
|
229
|
+ "method": 'resources.simple.pice'
|
|
|
230
|
+ }
|
281
|
let method = "GET"
|
231
|
let method = "GET"
|
282
|
let header = {
|
232
|
let header = {
|
283
|
'Content-Type': 'application/x-www-form-urlencoded'
|
233
|
'Content-Type': 'application/x-www-form-urlencoded'
|
284
|
}
|
234
|
}
|
285
|
|
235
|
|
286
|
wx.request({
|
236
|
wx.request({
|
287
|
- url:config.constants.API_HOST,
|
237
|
+ url: config.constants.API_HOST,
|
288
|
data,
|
238
|
data,
|
289
|
method,
|
239
|
method,
|
290
|
header: header,
|
240
|
header: header,
|
291
|
success: function (res) {
|
241
|
success: function (res) {
|
292
|
- // console.log("res:", res)
|
|
|
293
|
- if (res && res.data && res.data.data && res.data.data.sk){
|
242
|
+ if (res && res.data && res.data.data && res.data.data.sk) {
|
294
|
that.globalData.p2SecretKey = res.data.data.sk;
|
243
|
that.globalData.p2SecretKey = res.data.data.sk;
|
295
|
wx.setStorage({
|
244
|
wx.setStorage({
|
296
|
key: "p2SecretKey",
|
245
|
key: "p2SecretKey",
|
|
@@ -299,7 +248,6 @@ App({ |
|
@@ -299,7 +248,6 @@ App({ |
299
|
}
|
248
|
}
|
300
|
},
|
249
|
},
|
301
|
fail: function (err) {
|
250
|
fail: function (err) {
|
302
|
- // console.log("err:",err)
|
|
|
303
|
}
|
251
|
}
|
304
|
});
|
252
|
});
|
305
|
},
|
253
|
},
|
|
@@ -307,34 +255,23 @@ App({ |
|
@@ -307,34 +255,23 @@ App({ |
307
|
fastloginSwitch: function () {
|
255
|
fastloginSwitch: function () {
|
308
|
let that = this
|
256
|
let that = this
|
309
|
let param = {
|
257
|
let param = {
|
310
|
- method: 'app.passport.fastloginSwitch',
|
258
|
+ method: 'app.passport.fastloginSwitch'
|
311
|
};
|
259
|
};
|
312
|
GET(config.constants.API_HOST, param)
|
260
|
GET(config.constants.API_HOST, param)
|
313
|
.then(json => {
|
261
|
.then(json => {
|
314
|
- // if (!json || !json.code || json.code != 200 || !json.data) return;
|
|
|
315
|
- // if (!json.data || !json.data.sk) return;
|
|
|
316
|
-
|
|
|
317
|
- // let p2SecretKey = json.data.sk;
|
|
|
318
|
- // if (!p2SecretKey) return;
|
|
|
319
|
- // that.globalData.p2SecretKey = p2SecretKey;
|
|
|
320
|
-
|
|
|
321
|
- // wx.setStorage({
|
|
|
322
|
- // key: "p2SecretKey",
|
|
|
323
|
- // data: p2SecretKey
|
|
|
324
|
- // });
|
|
|
325
|
})
|
262
|
})
|
326
|
|
263
|
|
327
|
.catch(error => {
|
264
|
.catch(error => {
|
328
|
});
|
265
|
});
|
329
|
},
|
266
|
},
|
330
|
|
267
|
|
331
|
- checkUDID:function(){
|
268
|
+ checkUDID: function () {
|
332
|
let that = this
|
269
|
let that = this
|
333
|
try {
|
270
|
try {
|
334
|
var value = wx.getStorageSync('udid')
|
271
|
var value = wx.getStorageSync('udid')
|
335
|
if (value) {
|
272
|
if (value) {
|
336
|
that.globalData.udid = value;
|
273
|
that.globalData.udid = value;
|
337
|
- }else{
|
274
|
+ } else {
|
338
|
let udidValue = md5(that.getUUID());
|
275
|
let udidValue = md5(that.getUUID());
|
339
|
that.globalData.udid = udidValue;
|
276
|
that.globalData.udid = udidValue;
|
340
|
try {
|
277
|
try {
|
|
@@ -344,12 +281,10 @@ App({ |
|
@@ -344,12 +281,10 @@ App({ |
344
|
}
|
281
|
}
|
345
|
//获取签名秘钥
|
282
|
//获取签名秘钥
|
346
|
} catch (e) {
|
283
|
} catch (e) {
|
347
|
- // Do something when catch error
|
|
|
348
|
- // console.log("checkUDID error: " + e)
|
|
|
349
|
}
|
284
|
}
|
350
|
},
|
285
|
},
|
351
|
|
286
|
|
352
|
- checkNetworkType:function(){
|
287
|
+ checkNetworkType: function () {
|
353
|
let that = this;
|
288
|
let that = this;
|
354
|
let net = '';
|
289
|
let net = '';
|
355
|
|
290
|
|
|
@@ -371,8 +306,7 @@ App({ |
|
@@ -371,8 +306,7 @@ App({ |
371
|
}
|
306
|
}
|
372
|
// console.log("network:",net)
|
307
|
// console.log("network:",net)
|
373
|
},
|
308
|
},
|
374
|
- complete:function(res){
|
|
|
375
|
- appReport('start', "LIFECYCLE", "START", {}, that)
|
309
|
+ complete: function (res) {
|
376
|
}
|
310
|
}
|
377
|
})
|
311
|
})
|
378
|
that.globalData.networkType = net;
|
312
|
that.globalData.networkType = net;
|
|
@@ -384,10 +318,6 @@ App({ |
|
@@ -384,10 +318,6 @@ App({ |
384
|
},
|
318
|
},
|
385
|
|
319
|
|
386
|
loginCallBack: function (response) {
|
320
|
loginCallBack: function (response) {
|
387
|
- // console.log(response)
|
|
|
388
|
- // if (response.code === 10001) {
|
|
|
389
|
- // this.showRelaunchModal();
|
|
|
390
|
- // }
|
|
|
391
|
},
|
321
|
},
|
392
|
|
322
|
|
393
|
showRelaunchModal: function () {
|
323
|
showRelaunchModal: function () {
|
|
@@ -411,23 +341,15 @@ App({ |
|
@@ -411,23 +341,15 @@ App({ |
411
|
try {
|
341
|
try {
|
412
|
var value = wx.getStorageSync('sessionkey')
|
342
|
var value = wx.getStorageSync('sessionkey')
|
413
|
if (value) {
|
343
|
if (value) {
|
414
|
- // console.log(value)
|
|
|
415
|
this.globalData.sessionkey = value;
|
344
|
this.globalData.sessionkey = value;
|
416
|
}
|
345
|
}
|
417
|
} catch (e) {
|
346
|
} catch (e) {
|
418
|
- // console.log(e)
|
|
|
419
|
}
|
347
|
}
|
420
|
}
|
348
|
}
|
421
|
return undefined;
|
349
|
return undefined;
|
422
|
},
|
350
|
},
|
423
|
|
351
|
|
424
|
- mtainit(e) {
|
|
|
425
|
- mta.App.init({
|
|
|
426
|
- "appID": "500570715",
|
|
|
427
|
- "eventID": "500570797",
|
|
|
428
|
- });
|
|
|
429
|
- // console.log("init mta");
|
|
|
430
|
- },
|
352
|
+ mtainit(e) {},
|
431
|
WeToast
|
353
|
WeToast
|
432
|
})
|
354
|
})
|
433
|
|
355
|
|