app.js
4.18 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
//app.js
var util = require('utils/util.js')
var uri = require('utils/uri.js')
const socket = require('utils/socket.js');
var mta= require('utils/mta_analysis.js')
App({
scence:0,
onLaunch: function (opt) {
mta.App.init({
"appID":"500667278",
});
this.getSystemInfo(uri.CACHE__SYSTEM_INFO);
console.log(socket)
// socket.initSocket();
},
onShow:function(){
socket.resiverMessage();
this.scence=0;
// if(util.cache('identity')){
// this.getstaff();
// }
if (wx.canIUse('getUpdateManager')) {
const updateManager = wx.getUpdateManager();
updateManager.onCheckForUpdate(function (res) {
// 请求完新版本信息的回调
console.log('onCheckForUpdate',res)
})
updateManager.onUpdateReady(function (res) {
console.log('onUpdateReady',res)
updateManager.applyUpdate();
wx.showToast({
title:'版本已更新',
duration:2000,
mask:true,
success:function(){
}
})
})
updateManager.onUpdateFailed(function (res) {
// 新的版本下载失败
console.log('onUpdateFailed',res)
})
}
},
getstaff:function(){
var that=this;
wx.request({
url: "https://dcapi.colorcun.com/?service=App.Seller.GetAuthUserLists",
data: {sellerid:util.cache('sellerid')},
header: {
'content-type': 'application/json'
},
success: function(res) {
if(res.data.ret==200){
var list=res.data.data;
var temp={};
for(var key in list){
list[key].forEach(function(v,i){
if(v.openid && v.openid!=''){
temp[v.openid]=true
}
})
}
if(!temp[util.cache('openid')]){
that.getsellerlist();
}
}
},
complete:function (res) {
}
})
},
getsellerlist:function(){
var that=this;
wx.request({
url: "https://dcapi.colorcun.com/?service=App.Seller.GetSystemByOpenid",
data: {openid: util.cache('openid')},
header: {
'content-type': 'application/json'
},
success: function (res) {
if (that.scence == 0) {
if (res.data.ret == 200 && res.data.data[0].auth == 0) { //无商家
if (util.cache('manage')) {
wx.reLaunch({
url: '/pages/currency/c_store'
})
} else {
wx.reLaunch({
url: '/pages/login/l_login'
})
}
} else if (res.data.ret == 200 && res.data.data[0].length > 1) { //有多个商家
wx.reLaunch({
url: '/pages/currency/c_store'
})
} else if (res.data.ret == 200 && res.data.data[0].length == 1) { //有1个商家
wx.reLaunch({
url: '/pages/me/s_index?sellerid=' + res.data.data[0][0].id
})
}
}
}
})
},
onHide:function(){
},
getSystemInfo:function(cb){
var systemInfo=util.cache(uri.CACHE__SYSTEM_INFO);
if(systemInfo){
typeof cb == "function" && cb(systemInfo)
}else{
//调用设备信息接口
wx.getSystemInfo({
success:function(res){
util.cache(uri.CACHE__SYSTEM_INFO,res);
typeof cb == "function" && cb(res);
}
});
}
},
"networkTimeout":{
"request": 20000,
"connectSocket": 20000,
"uploadFile": 20000,
"downloadFile": 20000
},
})