-
Notifications
You must be signed in to change notification settings - Fork 3
/
app.js
270 lines (270 loc) · 10.5 KB
/
app.js
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
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
//app.js
var server = require('./utils/util.js');
App({
onLaunch: function () {
// console.log('App Launch')
var self = this;
var rd_session = wx.getStorageSync('rd_session');
if (!rd_session) {
self.login();
} else {
wx.checkSession({
success: function () {
// 登录态未过期
// console.log('登录态未过期')
self.rd_session = rd_session;
self.getUserInfo();
},
fail: function () {
//登录态过期
// console.log('过期');
self.login();
}
})
}
},
onShow: function () {
// console.log('App Show')
},
onHide: function () {
// console.log('App Hide')
},
globalData: {
hasLogin: false,
cartList: [],
userInfo: [],
shops: [
{
address:"银河购物中心",
city_id:"340400",
delivery_fee:4,
distance:"844958",
distanceFormat:844.96,
end_sell_time:null,
favorite:"0",
is_rest:"0",
latitude:"32.648893",
longitude:"117.018078",
min_price:"15",
notice:"进店买东西的最美",
overall:"5.0",
phone:"15345548787",
pic_hd:"http://manage.ipaotui.com/manage_uploadfile/seller/20170623/hd_1498207177149820717757072.jpg",
pic_url:"http://manage.ipaotui.com/manage_uploadfile/seller/20170623/1498207177149820717757072.jpg",
qrcode_url:"https://m.ipaotui.com/mini-program/shop?id=3892",
quality:"5.0",
reach_time:"30",
reserve_day:"0",
sales:"30",
sell_time:"10:00-21:00",
seller_id:"3892",
seller_name:"珍奶会所",
service:"5.0",
share_url:"https://m.ipaotui.com/mall/shop?id=3892",
start_sell_time:null,
state:"1",
goods_map:{
174388:{
detail:"",
goods_id:"174388",
goods_name:"焦糖红豆龙珠奶茶",
packing_fee:"0.00",
pic_hd1:"http://manage.ipaotui.com/manage_uploadfile/seller_goods/20170623/hd1_1498209225149820922541553.jpg",
pic_hd2:"http://manage.ipaotui.com/manage_uploadfile/seller_goods/20170623/hd2_1498209225149820922541553.jpg",
pic_url:"http://manage.ipaotui.com/manage_uploadfile/seller_goods/20170623/1498209225149820922541553.jpg",
praise:"0",
price:"10.00",
sales:"0",
seller_id:"3892",
stock:"100",
sub_goods:[
{
packing_fee:"0.00",
price:"10.00",
stock:"100",
sub_id:"19604",
sub_name:"M杯",
},{
packing_fee:"0.00",
price:"15.00",
stock:"100",
sub_id:"19605",
sub_name:"超大杯",
}
],
sub_goods_map:{
19604:{
packing_fee:"0.00",
price:"10.00",
stock:"100",
sub_id:"19604",
sub_name:"M杯",
},
19605:{
packing_fee:"0.00",
price:"15.00",
stock:"100",
sub_id:"19605",
sub_name:"超大杯",
}
}
},
174389:{
detail:"",
goods_id:"174389",
goods_name:"什么都有",
packing_fee:"0.00",
pic_hd1:"http://manage.ipaotui.com/manage_uploadfile/seller_goods/20170623/hd1_1498209436149820943656970.jpg",
pic_hd2:"http://manage.ipaotui.com/manage_uploadfile/seller_goods/20170623/hd2_1498209436149820943656970.jpg",
pic_url:"http://manage.ipaotui.com/manage_uploadfile/seller_goods/20170623/1498209436149820943656970.jpg",
praise:"0",
price:"15.00",
sales:"5",
seller_id:"3892",
stock:"97",
sub_goods:[],
sub_goods_map:{}
}
},
menus:[
{
goods:"174389,174390,174391,174392,174399,174403,174408",
is_use:"1",
menu_id:"19151",
menu_name:"热销产品",
seller_id:"3892",
sort:"6",
goods2:[
{
detail:"",
goods_id:"174389",
goods_name:"什么都有",
packing_fee:"0.00",
pic_hd1:"http://manage.ipaotui.com/manage_uploadfile/seller_goods/20170623/hd1_1498209436149820943656970.jpg",
pic_hd2:"http://manage.ipaotui.com/manage_uploadfile/seller_goods/20170623/hd2_1498209436149820943656970.jpg",
pic_url:"http://manage.ipaotui.com/manage_uploadfile/seller_goods/20170623/1498209436149820943656970.jpg",
praise:"0",
price:"15.00",
sales:"5",
seller_id:"3892",
stock:"97",
sub_goods:[]
}
]
},{
goods:"174421,174422,174423",
is_use:"1",
menu_id:"19158",
menu_name:"夏季限定",
seller_id:"3892",
sort:"5",
goods2:[
{
detail:"",
goods_id:"174388",
goods_name:"焦糖红豆龙珠奶茶",
packing_fee:"0.00",
pic_hd1:"http://manage.ipaotui.com/manage_uploadfile/seller_goods/20170623/hd1_1498210564149821056457795.jpg",
pic_hd2:"http://manage.ipaotui.com/manage_uploadfile/seller_goods/20170623/hd2_1498210564149821056457795.jpg",
pic_url:"http://manage.ipaotui.com/manage_uploadfile/seller_goods/20170623/1498210564149821056457795.jpg",
praise:"0",
price:"10.00",
sales:"1",
seller_id:"3892",
stock:"1000",
sub_goods:[
{
packing_fee:"0.00",
price:"10.00",
stock:"999",
sub_id:"19614",
sub_name:"L杯",
},{
packing_fee:"0.00",
price:"15.00",
stock:"999",
sub_id:"19614",
sub_name:"超大杯",
}
]
}
]
}
],
promotion:[
{
info:"在线支付满30减15,满60减30",
typeId:"1",
pic_url:"http://manage.ipaotui.com/Uploadfile/Img/seller_promotion/first_cut.png"
},{
info:"超值半价购@伊斯坦布尔",
typeId:"2",
pic_url:"http://manage.ipaotui.com/Uploadfile/Img/seller_promotion/first_cut.png"
},{
info:"超值半价购@初心精选沙拉",
typeId:"3",
pic_url:"http://manage.ipaotui.com/Uploadfile/Img/seller_promotion/first_cut.png"
},{
info:"满80元赠送迷你雪梨汁200ml1份",
typeId:"4",
pic_url:"http://manage.ipaotui.com/Uploadfile/Img/seller_promotion/first_cut.png"
},{
info:"下单返券",
typeId:"5",
pic_url:"http://manage.ipaotui.com/Uploadfile/Img/seller_promotion/first_cut.png"
},{
info:"点赞特价",
typeId:"6",
pic_url:"http://manage.ipaotui.com/Uploadfile/Img/seller_promotion/first_cut.png"
},{
info:"本店支持开发票,请在下单时填写",
typeId:"7",
pic_url:"http://manage.ipaotui.com/Uploadfile/Img/seller_promotion/first_cut.png"
}
]
}
],
activityIconMap: {
1: "../../images/shop/减.png",
2: "../../images/shop/准.png",
3: "../../images/shop/折.png",
4: "../../images/shop/赠.png",
5: "../../images/shop/返.png",
6: "../../images/shop/特.png",
7: "../../images/shop/票.png"
}
},
rd_session: null,
login: function () {
var self = this;
wx.login({
success: function (res) {
// console.log('wx.login', res)
// server.getJSON('dwq/WxAppApi/setUserSessionKey.php', { code: res.code }, function (res) {
// self.rd_session = res.data.rd_session;
// self.globalData.hasLogin = true;
// wx.setStorageSync('rd_session', self.rd_session);
// self.getUserInfo();
// });
}
});
},
getUserInfo: function () {
var self = this;
wx.getUserInfo({
success: function (res) {
self.globalData.userInfo = res.userInfo;
server.getJSON('dwq/WxAppApi/checkSignature.php', {
rd_session: self.rd_session,
signature: res.signature,
raw_data: res.rawData
}, function (res) {
if (!res.data.is_pass) {
// TODO:验证有误处理
self.login();
}
});
}
});
}
})