my.js
12.6 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
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
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
const app = getApp()
Page({
data: {
is_mobile:false,
ordoerState1:false,
order1:0,
oneone:[],
twotwo:[],
threethree:[],
fourfour:[],
ninenine:[],
ordoerState2: false,
order2: 0,
ordoerState3: false,
order3: 0,
ordoerState4: false,
order4: 0,
ordoerState9: false,
order9: 0,
imgUrl: app.globalData.imgUrl,
popup_state: false,
arr: [1, 2, 3],
user: [],
orderList: [],
stateArr: [{
id: 1,
name: '待付款',
icon: 'aicon44__1.png'
}, {
id: 2,
name: '待发货',
icon: 'aicon44__2.png'
}, {
id: 3,
name: '已发货',
icon: 'aicon44__3.png'
}, {
id: 4,
name: '待评价',
icon: 'aicon44__4.png'
}],
},
//点击查看积分
look_jifen(){
wx.navigateTo({
url: './personal_center/personal_center',
})
},
//获取购物车数量
fetchCartNum() {
let url = '/wxapp/cart/index'
app.post(url).then(r => {
if (r.code == 1) {
if (r.data.cartNum > 0) {
wx.showTabBarRedDot({
index: 1,
success: function (red) {
wx.setTabBarBadge({
index: 1,
text: r.data.cartNum.toString(),
})
}
})
} else {
wx.hideTabBarRedDot({
index: 1
})
}
}
})
},
//查看我的积分
jump_jifen(){
wx.navigateTo({
url: './personal_center/personal_center',
})
},
//跳转至会员中心
jump_vip() {
wx.navigateTo({
url: '../vip/vip_index/vip_index',
})
},
//获取个人信息
fetchPersonal() {
let url = '/wxapp/user/index';
app.post(url).then(r => {
console.log(r);
if(r.code==1){
if(r.data.user.mobile!=''){
this.setData({
is_mobile:false
})
}else{
this.setData({
is_mobile:true
})
}
this.setData({
user: r.data
});
}
});
},
//绑定手机
go_bangding_mobile(){
wx.navigateTo({
url: './modifyPhone/modifyPhone',
})
// this.setData({
// is_mobile:true
// })
},
//跳转售后
jump_afterMarket() {
wx.navigateTo({
url: './afterMarketList/afterMarketList',
})
},
//签到
signIn() {
this.setData({
popup_state: true
})
},
//签到成功
back_person() {
let url = '/wxapp/user/sign';
app.post(url).then(r => {
if (r.code == 1) {
wx.showToast({
title: '签到成功',
icon: 'none'
})
this.fetchPersonal();
}else{
wx.showToast({
title: '您今天已经签到过',
icon:'none'
})
}
});
this.setData({
popup_state: false
});
},
cancleMask() {
this.setData({
popup_state: false
})
},
onLoad: function() {
this.fetchOrderlist();
this.fetchPersonal();
console.log(this.data)
},
/**
* 生命周期函数--监听页面显示
*/
onShow: function () {
this.fetchPersonal();
this.fetchCartNum();
},
// 消息中心
get_message() {
wx.navigateTo({
url: '../my/activityInformation/activityInformation',
})
},
//渲染订单列表
fetchOrderlist() {
let url = '/wxapp/order/index'
let that=this
let oneone=[]
let twotwo=[]
let threethree=[]
let fourfour=[]
let ninenine=[]
let orderState1=that.data.ordoerState1
let orderState2 = that.data.orderState2
let orderState3 = that.data.orderState3
let orderState4 = that.data.orderState4
let orderState9 = that.data.orderState9
app.post(url).then(r => {
if (r.code == 1) {
r.data.forEach(function(ele,index){
if(ele.status==1){
oneone.push(ele)
}else if(ele.status==2){
twotwo.push(ele)
} else if (ele.status == 3) {
threethree.push(ele)
} else if (ele.status == 4) {
fourfour.push(ele)
} else if (ele.status == 9) {
ninenine.push(ele)
}
})
console.log(oneone, twotwo, threethree, fourfour, ninenine)
if (oneone.length > 0) {
orderState1 = true
} else {
orderState1 = false
}
if (twotwo.length > 0) {
orderState2 = true
} else {
orderState2 = false
}
if (threethree.length > 0) {
orderState3 = true
} else {
orderState3 = false
}
if (fourfour.length > 0) {
orderState4 = true
} else {
orderState4 = false
}
if (ninenine.length > 0) {
orderState9 = true
} else {
orderState9 = false
}
that.setData({
order1: oneone.length,
order2: twotwo.length,
order3: threethree.length,
order4: fourfour.length,
order9: ninenine.length,
orderState1: orderState1,
orderState2: orderState2,
orderState3: orderState3,
orderState4: orderState4,
orderState9: orderState9
})
}
})
},
// 修改个人信息
getamend_person() {
wx.navigateTo({
url: '../my/modifyPersonInformation/modifyPersonInformation',
})
},
// 兑换码充值
get_activity() {
wx.navigateTo({
url: '../my/charger_code/charger_code',
})
},
//点击积分抵现
integral() {
wx.navigateTo({
url: '../my/personal_center/personal_center'
})
},
// 待付款
get_obligation1(e) {
let index = e.currentTarget.dataset.index * 1 + 2
let status = e.currentTarget.dataset.id
let that=this
wx.navigateTo({
url: '../my/myOrder/myOrder?index=' + 3 + '&status=' + 1
})
},
// 待发货
get_obligation2(e) {
let index = e.currentTarget.dataset.index * 1 + 2
let status = e.currentTarget.dataset.id
let that = this
wx.navigateTo({
url: '../my/myOrder/myOrder?index=' + 4 + '&status=' + 2
})
},
// 待收货
get_obligation3(e) {
let index = e.currentTarget.dataset.index * 1 + 3
let status = e.currentTarget.dataset.id
let that = this
wx.navigateTo({
url: '../my/myOrder/myOrder?index=' + 5 + '&status=' +3
})
},
// 待评价
get_obligation4(e) {
let index = e.currentTarget.dataset.index * 1 + 2
let status = e.currentTarget.dataset.id
let that = this
wx.navigateTo({
url: '../my/myOrder/myOrder?index=' + 6 + '&status=' + 4
})
},
// 售后
get_sale() {
wx.navigateTo({
url: '../my/orderDetail/orderDetail',
})
},
//优惠券
coupons() {
wx.navigateTo({
url: '../my/coupons/coupons',
})
},
// 储值有礼
get_recharge(e) {
wx.navigateTo({
url: '../my/balance _center2/balance _center2?id=' + e.currentTarget.dataset.id,
})
},
// 分享有礼
get_share() {
wx.navigateTo({
url: 'invitationPolite/invitationPolite',
})
},
// 我的收藏
get_collection() {
wx.navigateTo({
url: '../my/myCollection/myCollection',
})
},
// 地址管理
get_address() {
wx.navigateTo({
url: '../my/myAddress/myAddress',
})
},
// 常见问题
get_issue() {
wx.navigateTo({
url: '../my/editAddress2/editAddress2',
})
},
//用户指南
suggestion() {
wx.navigateTo({
url: '../my/suggestion/suggestion',
})
}
})