4Sstore.js
13.1 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
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
import {
request
} from "../../request/index.js"
const a = getApp()
Page({
data: {
baseUrl: a.globalData.baseUrl,
statusTop: a.globalData.statusHeight,
imagesUrl: a.globalData.imagesUrl,
four: 4,
msg: '',
time: 30 * 60 * 60 * 1000,
timeData: {},
storeList: 4,
groomList: [],
decorations: '', // 精品
stores_id: '',
kefu: [],
hotActivity: [],
hotModels: [],
products: [],
goodDetal: {},
page: 1,
total: 0,
S4Spage: false,
it_cloose: false,
showItem: false,
s4_id: '',
hotModel: [],
},
// 同 VehicleList 是一个页面
onLoad: function (options) {
console.log(options);
},
onChange(e) {
this.setData({
timeData: e.detail,
});
},
onShow: function () {
let that = this
console.log(that.data.s4_id, "s4_id");
let s4_id = a.globalData.stores_id
console.log(s4_id, "s4_id");
a.globalData.stores_id = ''
if (s4_id == '') {
that.setData({
S4Spage: false,
// it_cloose: true,
})
} else {
that.setData({
S4Spage: true,
it_cloose: false,
})
}
that.setData({
s4_id,
products: [],
kefu: [],
hotActivity: [],
groomList: [],
hotModels: [],
page: 1
})
setTimeout(() => {
that.getDecorations()
that.getHotActivity()
that.getHotModels()
that.getgood3List()
that.getProducts()
that.getNewcar()
}, 100);
},
goback() {
wx.navigateBack()
},
noBinding4S() {
wx.navigateTo({
url: '/pages/my4S/my4S'
})
},
async clickAttention() { // 点击关注
let that = this
let decorations = that.data.decorations
try {
const {
data
} = await request({
url: 'api/index2/guan',
data: {
id: decorations.id
}
})
console.log(data);
if (data.code == 1) {
that.setData({
msg: data.msg
})
that.getDecorations()
}
} catch (err) {
console.log(err, "出错了");
a.popTest(err.msg)
}
},
async getDecorations() { // 获取 s4店页面[头部数据
let that = this
try {
const {
data: {
data
}
} = await request({
url: 'api/shop4s2/index',
data: {
s4_id: that.data.s4_id
}
})
console.log(data);
if (data != null) {
console.log(1111);
that.setData({
kefu: data.kefu,
S4Spage: true,
it_cloose: false,
s4_id: data.id
})
} else {
that.setData({
S4Spage: false,
it_cloose: true,
})
}
that.setData({
decorations: data,
})
console.log(that.data.S4Spage);
} catch (err) {
console.log(err, "出错了");
a.popTest(err.msg)
that.setData({
S4Spage: false,
it_cloose: true,
})
}
},
async getHotActivity() { // 获取热门活动
let that = this
try {
const {
data: {
data
}
} = await request({
url: 'api/shop4s2/hotActive',
data: {
s4_id: that.data.s4_id
}
})
console.log(data);
that.setData({
hotActivity: data,
})
} catch (err) {
console.log(err, "出错了");
a.popTest(err.msg)
}
},
async getNewcar() { // 获取热销车型
let that = this
try {
const {
data: {
data
}
} = await request({
url: 'api/shop4s2/cheGood',
data: {
s4_id: that.data.s4_id
}
})
console.log(data);
that.setData({
hotModel: data,
})
} catch (err) {
console.log(err, "出错了");
a.popTest(err.msg)
}
},
async getProducts() { // 获取配件商品
let that = this
try {
const {
data: {
data
}
} = await request({
url: 'api/shop4s2/peiGoods',
data: {
s4_id: that.data.s4_id,
page: that.data.page
}
})
console.log(data);
that.setData({
last_page: data.last_page,
total: data.total,
page: data.current_page,
products: that.data.products.concat(data.data),
})
} catch (err) {
console.log(err, "出错了");
a.popTest(err.msg)
}
},
async getHotModels() { // 获取
let that = this
try {
const {
data: {
data
}
} = await request({
url: 'api/shop4s2/hotChe',
data: {
s4_id: that.data.s4_id
}
})
console.log(data);
that.setData({
hotModels: data,
})
} catch (err) {
console.log(err, "出错了");
a.popTest(err.msg)
}
},
async getgood3List() { // 获取跳3个商品详情
let that = this
try {
const {
data: {
data
}
} = await request({
url: 'api/shop4s2/newImg3',
data: {
s4_id: that.data.s4_id
}
})
console.log(data, "新接口");
that.setData({
goodDetal: data
})
} catch (err) {
console.log(err, "出错了");
a.popTest(err.msg)
}
},
freeTell(e) {
console.log(e);
let phone = e.currentTarget.dataset.phone
wx.makePhoneCall({
phoneNumber: phone,
})
},
changeBarn() {
wx.navigateTo({
url: '/pages/Vmore4SList/Vmore4SList'
})
},
goCarDetails(e) {
let id = e.currentTarget.dataset.id
wx.navigateTo({
url: '/pages/carDetails/carDetails?id=' + id
})
},
goSearch() {
wx.navigateTo({
url: '/pages/Vmore4SList/Vmore4SList?home=1'
})
},
goVnewslist() {
let decorations = this.data.decorations
let s4_id = decorations.id
wx.navigateTo({
url: '/pages/Vnewslist/Vnewslist?s4_id=' + s4_id
})
},
allche() {
let that = this
let token = wx.getStorageSync("token")
let decorations = that.data.decorations
let s4_id = decorations.id
console.log(s4_id);
if (token) {
wx.navigateTo({
url: '/pages/VehicleList/VehicleList?id=' + s4_id
})
} else {
a.popTest('请登录后操作')
}
},
goReservation() {
let that = this
let token = wx.getStorageSync("token")
let decorations = that.data.decorations
let s4_id = decorations.id
if (token) {
wx.navigateTo({
url: '/pages/upkeepImg/upkeepImg?type=2' + '&id=' + s4_id || that.data.s4_id
})
} else {
a.popTest('请登录后操作')
}
},
goAccessories() { // 精品配件
let token = wx.getStorageSync("token")
let decorations = this.data.decorations
let s4_id = decorations.id
if (token) {
wx.navigateTo({
url: '/pages/goAccessories/goAccessories?id=' + s4_id
})
} else {
a.popTest('请登录后操作')
}
},
toRecommendCar() { // 去推荐购车页面
let token = wx.getStorageSync("token")
let that = this
let decorations = that.data.decorations
let s4_id = decorations.id
if (token) {
wx.navigateTo({
url: '/pages/RecommendCar/RecommendCar?s4_id=' + s4_id
})
} else {
a.popTest('请登录后操作')
}
},
lookMorePartsList() {
let id = this.data.s4_id
console.log(id);
wx.navigateTo({
url: '/pages/goAccessories/goAccessories?id=' + id
})
},
bindMakePhone(e) {
console.log(e);
let phone = e.currentTarget.dataset.phone
wx.makePhoneCall({
phoneNumber: phone
})
},
goToPay(e) {
let id = e.currentTarget.dataset.id
wx.navigateTo({
url: '/pages/confirmStoreOrder/confirmStoreOrder?id=' + id
})
},
onReachBottom: function () {
let that = this
let newpageNum = that.data.page;
let products = that.data.products
newpageNum++;
that.setData({
page: newpageNum
})
if (products.length != that.data.total) {
that.getProducts()
console.log(123333333333);
} else {
that.setData({
showItem: true,
})
}
},
ToActivityDetails(e) {
let id = e.currentTarget.dataset.id
let type = e.currentTarget.dataset.type
if (type == 1) {
wx.navigateTo({
url: '/pages/activityDetails/activityDetails?id=' + id + '&type=' + type + '&tap=0'
})
} else if (type == 2) {
wx.navigateTo({
url: '/pages/details/details?id=' + id + '&type=' + type
})
} else if (type == 3) {
wx.navigateTo({
url: '/pages/detail/detail?id=' + id
})
}
},
goDetail(e) {
let id = e.currentTarget.dataset.id
wx.navigateTo({
url: '/pages/goAccessoriesDetailIMG/goAccessoriesDetailIMG?id=' + id
})
},
goToAccessoriesDetailIMG(e) { //进入配件详情
let that = this
let token = wx.getStorageSync('token')
let goodDetal = that.data.goodDetal
let tir = e.currentTarget.dataset.tir
if (token) {
if (tir == 1) {
wx.navigateTo({
url: '/pages/productdetailsImg/productdetailsImg?id=' + goodDetal.good1_id
})
} else if (tir == 2) {
wx.navigateTo({
url: '/pages/productdetailsImg/productdetailsImg?id=' + goodDetal.good2_id
})
} else {
wx.navigateTo({
url: '/pages/productdetailsImg/productdetailsImg?id=' + goodDetal.good3_id
})
}
} else {
that.goLogin()
}
},
toGoPromotion() {
wx.navigateTo({
url: '/pages/goPromotion/goPromotion'
})
},
toUpkeep() {
wx.navigateTo({
url: '/pages/upkeepImg/upkeepImg'
})
},
carList() {
let that = this
let stores_id = that.data.s4_id
wx.navigateTo({
url: '/pages/upkeepImg/upkeepImg?stores_id=' + stores_id
})
},
onShareAppMessage(options) {
var that = this;
var shareObj = {
title: that.data.decorations.name || "车唛分享", // 默认是小程序的名称(可以写slogan等)
path: '/pages/4Sstore/4Sstore', // 默认是当前页面,必须是以‘/’开头的完整路径
imageUrl: '', //自定义图片路径,可以是本地文件路径、代码包文件路径或者网络图片路径,支持PNG及JPG,不传入 imageUrl 则使用默认截图。显示图片长宽比是 5:4
};
// 返回shareObj
return shareObj;
},
toGoDetailA(e) {
let that = this
let good_type = Number(e.currentTarget.dataset.good_type)
let type = e.currentTarget.dataset.type
that.publicDetails(type, good_type)
},
publicDetails(type, good_type) {
let that = this
console.log(type, good_type, "珊瑚");
let decorations = that.data.decorations
let s4_id = decorations.id
if (type == 1) { //可以跳转
switch (good_type) {
case 1: // 人气好物
wx.navigateTo({
url: '/pages/VSpikeMall/VSpikeMall?id_name=' + '人气好物' + '&id=' + s4_id
})
break;
case 2: // 精选推荐
wx.navigateTo({
url: '/pages/VSpikeMall/VSpikeMall?id_name=' + '精选推荐' + '&id=' + s4_id
})
break;
case 3: // 团购热卖
wx.navigateTo({
url: '/pages/VSpikeMall/VSpikeMall?id_name=' + '团购热卖' + '&id=' + s4_id
})
break;
case 4: //限时抢购
wx.navigateTo({
url: '/pages/VSpikeMall/VSpikeMall?id_name=' + '限时抢购' + '&id=' + s4_id
})
break;
case 5: //车型商品
wx.navigateTo({
url: '/pages/VSpikeMall/VSpikeMall?id_name=' + '车型商品' + '&id=' + s4_id
})
break;
case -1: //活动列表
wx.navigateTo({
url: '/pages/goPromotion/goPromotion?id=' + s4_id
})
break;
case -2: //活动列表
wx.navigateTo({
url: '/pages/goPromotion/goPromotion?id=' + s4_id
})
break;
default:
break;
}
} else {
a.popTest('该4s店暂未运营')
}
},
async public() {
let that = this
try {
const {
data: {
data
}
} = await request({
url: '',
data: {
goods_id: that.data.goods_id
}
})
console.log(data);
that.setData({
public: data
})
} catch (err) {
console.log(err);
that.setData({
msg: err.msg
})
that.popTest()
}
},
goLogin() {
wx.showModal({
title: '提示',
content: '您尚未登录,前往登录',
success: function (res) {
if (res.confirm) {
wx.navigateTo({
// url: '/pages/authorization/authorization'
})
} else {
wx.switchTab({
url: '/pages/home/home'
})
}
}
})
},
popTest() {
wx.showToast({
title: this.data.msg,
icon: 'none', //如果要纯文本,不要icon,将值设为'none'
duration: 1300
})
},
popSuccessTest() {
wx.showToast({
title: this.data.msg,
icon: '', //默认值是success,就算没有icon这个值,就算有其他值最终也显示success
duration: 1300, //停留时间
})
},
})