...
|
...
|
@@ -2,433 +2,355 @@ |
|
|
import wx from './utils/wx';
|
|
|
import udid from './common/udid';
|
|
|
import event from './common/event';
|
|
|
import promisify from './common/promisify';
|
|
|
import objectAssign from './vendors/object-assign';
|
|
|
import {WeToast} from './vendors/toast/wetoast';
|
|
|
import config from './common/config';
|
|
|
import {GET, POST} from './common/request';
|
|
|
import {Encrypt,Decrypt} from './common/aes.js';
|
|
|
let crypto = require('./common/cryptojs/cryptojs.js').Crypto
|
|
|
import md5 from './vendors/md5';
|
|
|
var mta = require('./vendors/mta_analysis.js')
|
|
|
import { wechatLoginAction } from './utils/login';
|
|
|
import { isStringEmpty } from './utils/util';
|
|
|
|
|
|
import { logEvent,
|
|
|
YB_LAUNCH_APP,
|
|
|
YB_EXIT_APP,
|
|
|
YB_ENTER_FOREGROUND,
|
|
|
YB_ENTER_BACKGROUND,
|
|
|
YB_PAGE_OPEN_L,
|
|
|
YB_AWAKE_MP
|
|
|
} from './common/analytics.js';
|
|
|
|
|
|
import { appReport } from './common/appReport.js';
|
|
|
|
|
|
import {wechatLoginAction} from './utils/login';
|
|
|
import {isStringEmpty} from './utils/util';
|
|
|
|
|
|
App({
|
|
|
onLaunch: function (options) {
|
|
|
let that = this;
|
|
|
let res = wx.getSystemInfoSync();
|
|
|
if (!res.screenHeight) {
|
|
|
res.screenHeight = res.windowHeight;
|
|
|
}
|
|
|
if (!res.screenWidth) {
|
|
|
res.screenWidth = res.windowWidth;
|
|
|
}
|
|
|
|
|
|
this.globalData.systemInfo = res;
|
|
|
this.checkUDID();
|
|
|
|
|
|
that.getSimplePise()
|
|
|
this.checkNetworkType()
|
|
|
|
|
|
if (options && options.scene){
|
|
|
this.globalData.ch = options.scene
|
|
|
}
|
|
|
|
|
|
if (options && options.query && options.query.union_type){
|
|
|
this.globalData.union_type = options.query.union_type
|
|
|
}
|
|
|
|
|
|
wx.checkSession({
|
|
|
success: function () {
|
|
|
//登录态未过期
|
|
|
that.getWechatThirdSession();
|
|
|
that.getUserInfo();
|
|
|
that.getUnionID();
|
|
|
},
|
|
|
fail: function () {
|
|
|
//登录态过期
|
|
|
wx.setStorage({
|
|
|
key: "WXThird_session",
|
|
|
data: ''
|
|
|
});
|
|
|
wx.setStorage({
|
|
|
key: "userInfo",
|
|
|
data: {}
|
|
|
});
|
|
|
onLaunch: function (options) {
|
|
|
let that = this;
|
|
|
let res = wx.getSystemInfoSync();
|
|
|
if (!res.screenHeight) {
|
|
|
res.screenHeight = res.windowHeight;
|
|
|
}
|
|
|
if (!res.screenWidth) {
|
|
|
res.screenWidth = res.windowWidth;
|
|
|
}
|
|
|
|
|
|
wx.setStorage({
|
|
|
key: "unionID",
|
|
|
data: ""
|
|
|
this.globalData.systemInfo = res;
|
|
|
this.checkUDID();
|
|
|
|
|
|
that.getSimplePise();
|
|
|
this.checkNetworkType();
|
|
|
|
|
|
if (options && options.scene) {
|
|
|
this.globalData.ch = options.scene
|
|
|
}
|
|
|
|
|
|
if (options && options.query && options.query.union_type) {
|
|
|
this.globalData.union_type = options.query.union_type
|
|
|
}
|
|
|
|
|
|
wx.checkSession({
|
|
|
success: function () {
|
|
|
//登录态未过期
|
|
|
that.getWechatThirdSession();
|
|
|
that.getUserInfo();
|
|
|
that.getUnionID();
|
|
|
},
|
|
|
fail: function () {
|
|
|
//登录态过期
|
|
|
wx.setStorage({
|
|
|
key: "WXThird_session",
|
|
|
data: ''
|
|
|
});
|
|
|
wx.setStorage({
|
|
|
key: "userInfo",
|
|
|
data: {}
|
|
|
});
|
|
|
|
|
|
wx.setStorage({
|
|
|
key: "unionID",
|
|
|
data: ""
|
|
|
});
|
|
|
}
|
|
|
});
|
|
|
}
|
|
|
})
|
|
|
this.getSessionkey();
|
|
|
let timestamp = new Date().getTime() + ''
|
|
|
this.globalData.sid = md5(timestamp);
|
|
|
|
|
|
if (options){
|
|
|
let channel = options.query.channel;
|
|
|
let channelType = options.query.type;
|
|
|
let params = { 'CHANNEL': channel, 'TYPE': channelType };
|
|
|
logEvent(YB_LAUNCH_APP, params, this);
|
|
|
}
|
|
|
setTimeout(function () {
|
|
|
wechatLoginAction(function (response) {});}, 1000);
|
|
|
|
|
|
this.mtainit(options);
|
|
|
},
|
|
|
|
|
|
//当应用程序进入前台显示状态时触发
|
|
|
onShow(options) {
|
|
|
let that = this
|
|
|
let params = {};
|
|
|
logEvent(YB_ENTER_FOREGROUND, params, this)
|
|
|
if (that.globalData.hasReportAwakeAction==='false'){
|
|
|
let pathParam = ""
|
|
|
if(options && options.query) {
|
|
|
for (var Key in options.query) {
|
|
|
if (pathParam.length == 0) {
|
|
|
pathParam = Key + '=' + options.query[Key] + '';
|
|
|
} else {
|
|
|
pathParam = pathParam + '&' + '' + Key + '=' + options.query[Key] + '';
|
|
|
}
|
|
|
|
|
|
this.getSessionkey();
|
|
|
let timestamp = new Date().getTime() + '';
|
|
|
this.globalData.sid = md5(timestamp);
|
|
|
|
|
|
if (options) {
|
|
|
let channel = options.query.channel;
|
|
|
let channelType = options.query.type;
|
|
|
let params = {'CHANNEL': channel, 'TYPE': channelType};
|
|
|
}
|
|
|
setTimeout(function () {
|
|
|
wechatLoginAction(() => '');
|
|
|
}, 1000);
|
|
|
|
|
|
this.mtainit(options);
|
|
|
},
|
|
|
|
|
|
onShow() {},
|
|
|
|
|
|
onHide () {},
|
|
|
|
|
|
getUserInfo: function () {
|
|
|
try {
|
|
|
var value = wx.getStorageSync('userInfo')
|
|
|
if (value) {
|
|
|
this.globalData.userInfo = value;
|
|
|
}
|
|
|
} catch (e) {
|
|
|
// console.log(e)
|
|
|
}
|
|
|
}
|
|
|
let path
|
|
|
if(pathParam!==""){
|
|
|
path = options.path + "?" + pathParam
|
|
|
}else{
|
|
|
path = options.path
|
|
|
}
|
|
|
params = {
|
|
|
PAGE_PATH: path
|
|
|
};
|
|
|
logEvent(YB_AWAKE_MP, params, this);
|
|
|
that.globalData.hasReportAwakeAction = 'true'
|
|
|
}
|
|
|
appReport('start', "LIFECYCLE", "RESUME", {},this)
|
|
|
},
|
|
|
|
|
|
//当应用程序进入后台状态时触发
|
|
|
onHide () {
|
|
|
let params = {};
|
|
|
logEvent(YB_ENTER_BACKGROUND,params)
|
|
|
appReport('start', "LIFECYCLE", "STOP", {},this)
|
|
|
},
|
|
|
|
|
|
getUserInfo: function () {
|
|
|
try {
|
|
|
var value = wx.getStorageSync('userInfo')
|
|
|
if (value) {
|
|
|
this.globalData.userInfo = value;
|
|
|
}
|
|
|
} catch (e) {
|
|
|
// console.log(e)
|
|
|
}
|
|
|
},
|
|
|
|
|
|
getUnionID: function () {
|
|
|
try {
|
|
|
var value = wx.getStorageSync('unionID')
|
|
|
if (value) {
|
|
|
this.globalData.WXUnion_ID = value;
|
|
|
}
|
|
|
} catch (e) {
|
|
|
// console.log(e)
|
|
|
}
|
|
|
},
|
|
|
|
|
|
getWechatThirdSession: function () {
|
|
|
try {
|
|
|
var that = this
|
|
|
var value = this.globalData.WXThird_session
|
|
|
if (!isStringEmpty(value)) {
|
|
|
that.globalData.WXThird_session = value;
|
|
|
}else{
|
|
|
value = wx.getStorageSync('WXThird_session')
|
|
|
}
|
|
|
return value
|
|
|
} catch (e) {
|
|
|
// console.log(e)
|
|
|
}
|
|
|
},
|
|
|
|
|
|
setUserInfo: function (cb) {
|
|
|
this.globalData.userInfo = objectAssign(this.globalData.userInfo, cb);
|
|
|
wx.setStorage({
|
|
|
key: "userInfo",
|
|
|
data: this.globalData.userInfo
|
|
|
})
|
|
|
},
|
|
|
|
|
|
setSessionkey: function (sessionkey) {
|
|
|
this.globalData.sessionkey = sessionkey;
|
|
|
wx.setStorage({
|
|
|
key: "sessionkey",
|
|
|
data: this.globalData.sessionkey
|
|
|
})
|
|
|
},
|
|
|
|
|
|
setWechatThirdSession: function (session) {
|
|
|
this.globalData.WXThird_session = session;
|
|
|
wx.setStorage({
|
|
|
key: "WXThird_session",
|
|
|
data: this.globalData.WXThird_session
|
|
|
})
|
|
|
},
|
|
|
|
|
|
setWXUnionID: function (unionID) {
|
|
|
this.globalData.WXUnion_ID = unionID;
|
|
|
wx.setStorage({
|
|
|
key: "unionID",
|
|
|
data: unionID
|
|
|
})
|
|
|
},
|
|
|
|
|
|
setOpenID:function(openID){
|
|
|
|
|
|
if(openID=='') return
|
|
|
this.globalData.openID = openID;
|
|
|
wx.setStorage({
|
|
|
key: "openID",
|
|
|
data: openID
|
|
|
})
|
|
|
},
|
|
|
|
|
|
getOpenID: function () {
|
|
|
let openid = ''
|
|
|
if (!isStringEmpty(this.globalData.openID)){
|
|
|
openid = this.globalData.openID
|
|
|
}else{
|
|
|
openid = wx.getStorageSync('openID')
|
|
|
this.globalData.openID = openid
|
|
|
}
|
|
|
return openid
|
|
|
},
|
|
|
|
|
|
updateUid: function (uid) {
|
|
|
this.getUserInfo();
|
|
|
this.globalData.userInfo.uid = uid;
|
|
|
wx.setStorage({
|
|
|
key: "userInfo",
|
|
|
data: this.globalData.userInfo
|
|
|
})
|
|
|
},
|
|
|
|
|
|
globalData: {
|
|
|
selectedChannel: 'boy',
|
|
|
userInfo: {},
|
|
|
systemInfo: null,
|
|
|
WXThird_session: '',
|
|
|
WXUnion_ID: '',
|
|
|
openID:'',
|
|
|
p2SecretKey: '',
|
|
|
sessionkey: '',
|
|
|
sid: '',
|
|
|
udid:'',
|
|
|
cid:'1',
|
|
|
mobileRegisterState:'',
|
|
|
hasReportAwakeAction: 'false',
|
|
|
defraudurl:'https://activity.yoho.cn/feature/45.html?title=防诈骗提醒',
|
|
|
miniapp_type: config.constants.MINI_APP_TYPE,
|
|
|
union_type:'',
|
|
|
ch:'',
|
|
|
networkType:'0',
|
|
|
deviceInfo:{},
|
|
|
},
|
|
|
|
|
|
isLogin: function () {
|
|
|
return this.globalData.userInfo != null &&
|
|
|
// this.globalData.userInfo.uid != undefined &&
|
|
|
// this.globalData.userInfo.uid != null &&
|
|
|
// this.globalData.userInfo.uid != '' &&
|
|
|
this.globalData.WXThird_session != '' &&
|
|
|
this.globalData.WXThird_session != null &&
|
|
|
this.globalData.WXThird_session != undefined;
|
|
|
},
|
|
|
|
|
|
getUid: function () {
|
|
|
let uid = this.globalData.userInfo.uid
|
|
|
if(!uid||uid===0){
|
|
|
this.getUserInfo();
|
|
|
uid = this.globalData.userInfo.uid
|
|
|
}
|
|
|
return uid;
|
|
|
},
|
|
|
|
|
|
getMiniappType:function(){
|
|
|
return config.constants.MINI_APP_TYPE
|
|
|
},
|
|
|
|
|
|
//获取加签的秘钥
|
|
|
getSimplePise: function () {
|
|
|
let that = this
|
|
|
let data = {
|
|
|
"udid": that.globalData.udid,
|
|
|
"method": 'resources.simple.pice'}
|
|
|
let method = "GET"
|
|
|
let header = {
|
|
|
'Content-Type': 'application/x-www-form-urlencoded'
|
|
|
}
|
|
|
|
|
|
wx.request({
|
|
|
url:config.constants.API_HOST,
|
|
|
data,
|
|
|
method,
|
|
|
header: header,
|
|
|
success: function (res) {
|
|
|
// console.log("res:", res)
|
|
|
if (res && res.data && res.data.data && res.data.data.sk){
|
|
|
that.globalData.p2SecretKey = res.data.data.sk;
|
|
|
wx.setStorage({
|
|
|
key: "p2SecretKey",
|
|
|
data: res.data.data.sk
|
|
|
});
|
|
|
},
|
|
|
|
|
|
getUnionID: function () {
|
|
|
try {
|
|
|
var value = wx.getStorageSync('unionID')
|
|
|
if (value) {
|
|
|
this.globalData.WXUnion_ID = value;
|
|
|
}
|
|
|
} catch (e) {
|
|
|
// console.log(e)
|
|
|
}
|
|
|
},
|
|
|
fail: function (err) {
|
|
|
// console.log("err:",err)
|
|
|
}
|
|
|
});
|
|
|
},
|
|
|
|
|
|
fastloginSwitch: function () {
|
|
|
let that = this
|
|
|
let param = {
|
|
|
method: 'app.passport.fastloginSwitch',
|
|
|
};
|
|
|
GET(config.constants.API_HOST, param)
|
|
|
.then(json => {
|
|
|
// if (!json || !json.code || json.code != 200 || !json.data) return;
|
|
|
// if (!json.data || !json.data.sk) return;
|
|
|
|
|
|
// let p2SecretKey = json.data.sk;
|
|
|
// if (!p2SecretKey) return;
|
|
|
// that.globalData.p2SecretKey = p2SecretKey;
|
|
|
|
|
|
// wx.setStorage({
|
|
|
// key: "p2SecretKey",
|
|
|
// data: p2SecretKey
|
|
|
// });
|
|
|
})
|
|
|
|
|
|
.catch(error => {
|
|
|
});
|
|
|
},
|
|
|
|
|
|
checkUDID:function(){
|
|
|
let that = this
|
|
|
try {
|
|
|
var value = wx.getStorageSync('udid')
|
|
|
if (value) {
|
|
|
that.globalData.udid = value;
|
|
|
}else{
|
|
|
let udidValue = md5(that.getUUID());
|
|
|
that.globalData.udid = udidValue;
|
|
|
},
|
|
|
|
|
|
getWechatThirdSession: function () {
|
|
|
try {
|
|
|
wx.setStorageSync('udid', udidValue)
|
|
|
var that = this
|
|
|
var value = this.globalData.WXThird_session
|
|
|
if (!isStringEmpty(value)) {
|
|
|
that.globalData.WXThird_session = value;
|
|
|
} else {
|
|
|
value = wx.getStorageSync('WXThird_session')
|
|
|
}
|
|
|
return value
|
|
|
} catch (e) {
|
|
|
// console.log(e)
|
|
|
}
|
|
|
}
|
|
|
//获取签名秘钥
|
|
|
} catch (e) {
|
|
|
// Do something when catch error
|
|
|
// console.log("checkUDID error: " + e)
|
|
|
}
|
|
|
},
|
|
|
|
|
|
checkNetworkType:function(){
|
|
|
let that = this;
|
|
|
let net = '';
|
|
|
|
|
|
wx.getNetworkType({
|
|
|
success: function (res) {
|
|
|
// 返回网络类型, 有效值:
|
|
|
// wifi/2g/3g/4g/unknown(Android下不常见的网络类型)/none(无网络)
|
|
|
var networkType = res.networkType
|
|
|
if (networkType === 'wifi') {
|
|
|
net = '1';
|
|
|
} else if (networkType === '2g') {
|
|
|
net = '2';
|
|
|
} else if (networkType === '3g') {
|
|
|
net = '3';
|
|
|
} else if (networkType === '4g') {
|
|
|
net = '4';
|
|
|
},
|
|
|
|
|
|
setUserInfo: function (cb) {
|
|
|
this.globalData.userInfo = objectAssign(this.globalData.userInfo, cb);
|
|
|
wx.setStorage({
|
|
|
key: "userInfo",
|
|
|
data: this.globalData.userInfo
|
|
|
})
|
|
|
},
|
|
|
|
|
|
setSessionkey: function (sessionkey) {
|
|
|
this.globalData.sessionkey = sessionkey;
|
|
|
wx.setStorage({
|
|
|
key: "sessionkey",
|
|
|
data: this.globalData.sessionkey
|
|
|
})
|
|
|
},
|
|
|
|
|
|
setWechatThirdSession: function (session) {
|
|
|
this.globalData.WXThird_session = session;
|
|
|
wx.setStorage({
|
|
|
key: "WXThird_session",
|
|
|
data: this.globalData.WXThird_session
|
|
|
})
|
|
|
},
|
|
|
|
|
|
setWXUnionID: function (unionID) {
|
|
|
this.globalData.WXUnion_ID = unionID;
|
|
|
wx.setStorage({
|
|
|
key: "unionID",
|
|
|
data: unionID
|
|
|
})
|
|
|
},
|
|
|
|
|
|
setOpenID: function (openID) {
|
|
|
|
|
|
if (openID == '') return
|
|
|
this.globalData.openID = openID;
|
|
|
wx.setStorage({
|
|
|
key: "openID",
|
|
|
data: openID
|
|
|
})
|
|
|
},
|
|
|
|
|
|
getOpenID: function () {
|
|
|
let openid = ''
|
|
|
if (!isStringEmpty(this.globalData.openID)) {
|
|
|
openid = this.globalData.openID
|
|
|
} else {
|
|
|
net = '0';
|
|
|
openid = wx.getStorageSync('openID')
|
|
|
this.globalData.openID = openid
|
|
|
}
|
|
|
return openid
|
|
|
},
|
|
|
|
|
|
updateUid: function (uid) {
|
|
|
this.getUserInfo();
|
|
|
this.globalData.userInfo.uid = uid;
|
|
|
wx.setStorage({
|
|
|
key: "userInfo",
|
|
|
data: this.globalData.userInfo
|
|
|
})
|
|
|
},
|
|
|
|
|
|
globalData: {
|
|
|
selectedChannel: 'boy',
|
|
|
userInfo: {},
|
|
|
systemInfo: null,
|
|
|
WXThird_session: '',
|
|
|
WXUnion_ID: '',
|
|
|
openID: '',
|
|
|
p2SecretKey: '',
|
|
|
sessionkey: '',
|
|
|
sid: '',
|
|
|
udid: '',
|
|
|
cid: '1',
|
|
|
mobileRegisterState: '',
|
|
|
hasReportAwakeAction: 'false',
|
|
|
defraudurl: 'https://activity.yoho.cn/feature/45.html?title=防诈骗提醒',
|
|
|
miniapp_type: config.constants.MINI_APP_TYPE,
|
|
|
union_type: '',
|
|
|
ch: '',
|
|
|
networkType: '0',
|
|
|
deviceInfo: {}
|
|
|
},
|
|
|
|
|
|
isLogin: function () {
|
|
|
return this.globalData.userInfo != null &&
|
|
|
this.globalData.WXThird_session != '' &&
|
|
|
this.globalData.WXThird_session != null &&
|
|
|
this.globalData.WXThird_session != undefined;
|
|
|
},
|
|
|
|
|
|
getUid: function () {
|
|
|
let uid = this.globalData.userInfo.uid
|
|
|
if (!uid || uid === 0) {
|
|
|
this.getUserInfo();
|
|
|
uid = this.globalData.userInfo.uid
|
|
|
}
|
|
|
return uid;
|
|
|
},
|
|
|
|
|
|
getMiniappType: function () {
|
|
|
return config.constants.MINI_APP_TYPE
|
|
|
},
|
|
|
|
|
|
//获取加签的秘钥
|
|
|
getSimplePise: function () {
|
|
|
let that = this
|
|
|
let data = {
|
|
|
"udid": that.globalData.udid,
|
|
|
"method": 'resources.simple.pice'
|
|
|
}
|
|
|
// console.log("network:",net)
|
|
|
},
|
|
|
complete:function(res){
|
|
|
appReport('start', "LIFECYCLE", "START", {}, that)
|
|
|
}
|
|
|
})
|
|
|
that.globalData.networkType = net;
|
|
|
},
|
|
|
|
|
|
getUUID: function () {
|
|
|
let value = "" + Date.now() + '-' + Math.floor(1e7 * Math.random()) + '-' + Math.random().toString(16).replace('.', '') + '-' + String(Math.random() * 31242).replace('.', '').slice(0, 8);
|
|
|
return value;
|
|
|
},
|
|
|
|
|
|
loginCallBack: function (response) {
|
|
|
// console.log(response)
|
|
|
// if (response.code === 10001) {
|
|
|
// this.showRelaunchModal();
|
|
|
// }
|
|
|
},
|
|
|
|
|
|
showRelaunchModal: function () {
|
|
|
wx.showModal({
|
|
|
title: '提示',
|
|
|
content: '使用微信小程序需要微信授权,您已经拒绝了该请求,请删除小程序重新进入。',
|
|
|
showCancel: false,
|
|
|
success: function (res) {
|
|
|
if (res.confirm) {
|
|
|
wx.navigateBack({
|
|
|
delta: 1
|
|
|
})
|
|
|
let method = "GET"
|
|
|
let header = {
|
|
|
'Content-Type': 'application/x-www-form-urlencoded'
|
|
|
}
|
|
|
}
|
|
|
})
|
|
|
},
|
|
|
|
|
|
getSessionkey: function () {
|
|
|
if (this.isLogin) {
|
|
|
|
|
|
try {
|
|
|
var value = wx.getStorageSync('sessionkey')
|
|
|
if (value) {
|
|
|
// console.log(value)
|
|
|
this.globalData.sessionkey = value;
|
|
|
|
|
|
wx.request({
|
|
|
url: config.constants.API_HOST,
|
|
|
data,
|
|
|
method,
|
|
|
header: header,
|
|
|
success: function (res) {
|
|
|
if (res && res.data && res.data.data && res.data.data.sk) {
|
|
|
that.globalData.p2SecretKey = res.data.data.sk;
|
|
|
wx.setStorage({
|
|
|
key: "p2SecretKey",
|
|
|
data: res.data.data.sk
|
|
|
});
|
|
|
}
|
|
|
},
|
|
|
fail: function (err) {
|
|
|
}
|
|
|
});
|
|
|
},
|
|
|
|
|
|
fastloginSwitch: function () {
|
|
|
let that = this
|
|
|
let param = {
|
|
|
method: 'app.passport.fastloginSwitch'
|
|
|
};
|
|
|
GET(config.constants.API_HOST, param)
|
|
|
.then(json => {
|
|
|
})
|
|
|
|
|
|
.catch(error => {
|
|
|
});
|
|
|
},
|
|
|
|
|
|
checkUDID: function () {
|
|
|
let that = this
|
|
|
try {
|
|
|
var value = wx.getStorageSync('udid')
|
|
|
if (value) {
|
|
|
that.globalData.udid = value;
|
|
|
} else {
|
|
|
let udidValue = md5(that.getUUID());
|
|
|
that.globalData.udid = udidValue;
|
|
|
try {
|
|
|
wx.setStorageSync('udid', udidValue)
|
|
|
} catch (e) {
|
|
|
}
|
|
|
}
|
|
|
//获取签名秘钥
|
|
|
} catch (e) {
|
|
|
}
|
|
|
},
|
|
|
|
|
|
checkNetworkType: function () {
|
|
|
let that = this;
|
|
|
let net = '';
|
|
|
|
|
|
wx.getNetworkType({
|
|
|
success: function (res) {
|
|
|
// 返回网络类型, 有效值:
|
|
|
// wifi/2g/3g/4g/unknown(Android下不常见的网络类型)/none(无网络)
|
|
|
var networkType = res.networkType
|
|
|
if (networkType === 'wifi') {
|
|
|
net = '1';
|
|
|
} else if (networkType === '2g') {
|
|
|
net = '2';
|
|
|
} else if (networkType === '3g') {
|
|
|
net = '3';
|
|
|
} else if (networkType === '4g') {
|
|
|
net = '4';
|
|
|
} else {
|
|
|
net = '0';
|
|
|
}
|
|
|
// console.log("network:",net)
|
|
|
},
|
|
|
complete: function (res) {
|
|
|
}
|
|
|
})
|
|
|
that.globalData.networkType = net;
|
|
|
},
|
|
|
|
|
|
getUUID: function () {
|
|
|
let value = "" + Date.now() + '-' + Math.floor(1e7 * Math.random()) + '-' + Math.random().toString(16).replace('.', '') + '-' + String(Math.random() * 31242).replace('.', '').slice(0, 8);
|
|
|
return value;
|
|
|
},
|
|
|
|
|
|
loginCallBack: function (response) {
|
|
|
},
|
|
|
|
|
|
showRelaunchModal: function () {
|
|
|
wx.showModal({
|
|
|
title: '提示',
|
|
|
content: '使用微信小程序需要微信授权,您已经拒绝了该请求,请删除小程序重新进入。',
|
|
|
showCancel: false,
|
|
|
success: function (res) {
|
|
|
if (res.confirm) {
|
|
|
wx.navigateBack({
|
|
|
delta: 1
|
|
|
})
|
|
|
}
|
|
|
}
|
|
|
})
|
|
|
},
|
|
|
|
|
|
getSessionkey: function () {
|
|
|
if (this.isLogin) {
|
|
|
|
|
|
try {
|
|
|
var value = wx.getStorageSync('sessionkey')
|
|
|
if (value) {
|
|
|
this.globalData.sessionkey = value;
|
|
|
}
|
|
|
} catch (e) {
|
|
|
}
|
|
|
}
|
|
|
} catch (e) {
|
|
|
// console.log(e)
|
|
|
}
|
|
|
}
|
|
|
return undefined;
|
|
|
},
|
|
|
|
|
|
mtainit(e) {
|
|
|
mta.App.init({
|
|
|
"appID": "500570715",
|
|
|
"eventID": "500570797",
|
|
|
});
|
|
|
// console.log("init mta");
|
|
|
},
|
|
|
WeToast
|
|
|
return undefined;
|
|
|
},
|
|
|
|
|
|
mtainit(e) {},
|
|
|
WeToast
|
|
|
})
|
|
|
|
|
|
|
...
|
...
|
|