index.js
17.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
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
const navStyle = 'background-color: transparent;'
import { IMG_URL } from '~/utils/constantData.js'
// import Util from '~/utils/util.js'
import { deleteSecond } from '~/utils/format'
// import { senceData } from './constant/data'
import { scenceList } from './constant/data'
// import { senceData, productData } from './constant/senceData'
import { subscriptionBannerUrl, subscriptionSystemData } from './constant/systemData'
import { getMockData } from '~/api/api'
const IMAGES = Object.freeze({
arrow: `${IMG_URL}/index/point.png`,
actArrow: `${IMG_URL}/index/actArrow.png`
})
// `${IMG_URL}index/car2.png`,
//本地图片路径
let IMG_URLLocal = '../../../images/'
import { productBysceneApi, pageApi, tagApi, battleMessageApi, getActivityRecordApi } from '~/api/index.js'
let leftMenuIndex = 0
Page({
// behaviors: [kfMixin],
/**
* 页面的初始数据
*/
data: {
IMAGES,
navStyle,
IMG_URL,
IMG_URLLocal,
actClass: 'right',
guideSrcIndex: 1,
guideShow: false,
dataArr: [],
apiData: [],
actNum: 3, //car 场景选择
tabIndx: 0,
// navList: ['看线索', '看产品'],
navList: ['看产品', '客户数字化'],
isShowService: false,
// 固定按钮
btnList: [{
imgSrc: 'contact',
name: '在线客服',
bindtap: 'goConsult'
}, {
imgSrc: 'bus-pro',
name: '申请业务',
bindtap: 'openBus'
},
// {
// imgSrc: 'bus-pro',
// name: '申请产品',
// bindtap: 'openPro',
// isHide: false
// },
{
imgSrc: 'valuation',
name: '预估产值',
bindtap: 'showCalculate',
isHide: false
}],
// 预估弹框
// visible: false,
isReset: false,
formData: {
sales: 100,
flow: 10000
},
lastFormData: {
sales: 100,
flow: 10000
},
isFirst: true,
// tabList: pageData.tabList,
// 定义数据
scenceList,
// senceData,
isShow: false,
// productData,
activityList: [],
// 视频播放地址
videoSrc: '',
videoTitle: '',
headerHeight: 0,
unreadClueCount: 0,
img_version: '0.1.1',
subscriptionBannerUrl: Object.freeze(subscriptionBannerUrl),
subscriptionSystemData: Object.freeze(subscriptionSystemData)
},
proClick(e) {
let { detail } = e
//登录的用户手机号
let userInfo = wx.$storage.get("userInfo");
let obj = {
actNum: isNaN(detail.scenIndex) ? 99 : detail.scenIndex, //选中的场景 没有就是订阅系统的
sceneid99: detail.sceneid,
activeNavIdx: detail.id, //选中的产品,
phone: userInfo.phone
}
wx.$router.go('/packagesList/pages/productDetail/productDetail', obj)
},
// 跳转视频详情
videoClick(e) {
const { name } = e.target.dataset
const {
index,
info: { videoUrl },
scenIndex,
list
} = e.detail
const videoList = list
let userInfo = wx.$storage.get("userInfo")
const obj = {
index,
videoList,
scenIndex: isNaN(scenIndex) ? 99 : scenIndex,
videoUrl: videoUrl,
phone: userInfo.phone
}
if (name == '客户数字化') {
obj.leftMenuIndex = leftMenuIndex
}
wx.$router.go('/packagesList/pages/videoDetal/videoDetal', obj)
},
// 跳转众筹活动页
activityClick(e) {
const id = e.detail
wx.$router.go('/packagesList/activityDetail/activityDetail', { id })
},
// 场景跳转
senceClick(e) {
// let { scenIndex } = this.data;
// let userInfo = wx.$storage.get("userInfo");
// let obj = {
// actNum: scenIndex, //选中的场景
// activeNavIdx: 0, //选中的产品
// phone: userInfo.phone,
// };
// wx.$router.go("/pages/viewProdBanner/index", obj);
const { scenIndex } = e.detail
let userInfo = wx.$storage.get("userInfo");
wx.$router.go('/packagesList/pages/scenarioDetail/scenarioDetail', {
actNum: scenIndex,
phone: userInfo.phone
})
},
// 获取全部活动列表
getActivityRecord() {
getActivityRecordApi({}).then(({ data, code, message }) => {
if (code == -1) {
wx.showToast({
title: message,
icon: 'none',
duration: 2000
})
}
this.setData({
activityList: data
})
})
},
//引导图
guideFn() {
if (this.data.guideSrcIndex === 4) {
this.setData({
guideShow: false
})
//显示tabar
wx.pro.showTabBar()
return
}
this.setData({
guideSrcIndex: ++this.data.guideSrcIndex
})
// console.log('guideSrcIndex',this.data.guideSrcIndex)
},
// navbar高度设置
navbarReady(e) {
let { height, statusBarHeight } = e.detail
this.setData({
headerHeight: height / 2 + statusBarHeight,
// headerHeight: height / 2 + statusBarHeight + 88 * 2
})
},
selectCar(e) {
let actNum = e.detail
this.setData({
actNum
})
},
// 头部看线索,产品切换
changeTabIndx(e) {
// console.log('e.detail: ', e.detail)
let { sessionId } = wx.$storage.get()
// console.log("sessionId: ", sessionId);
let param = {
sessionId
}
let first = true
this.setData({
tabIndx: e.detail
})
this.btnIsHide()
},
//看产品下拉刷新
refresherrefresh() {
let { tabIndx } = this.data
if (tabIndx == 0) {
// 看产品
this.getProductByscene()
// // 看线索
// this.getClueInit()
wx.pro.showToast({
title: '刷新成功',
icon: 'loading',
duration: 1500
})
}
},
// 跳转咨询页面
goConsult() {
// console.log('跳转到咨询页面')
wx.pro.openCustomerServiceChat({
extInfo: { url: 'https://work.weixin.qq.com/kfid/kfcf7b721472201345e' },
corpId: 'ww047bdc0f1e76cc13',
complete: r => {
// console.log(r)
}
})
},
// 申请业务、
openBus() {
wx.$router.go("/packagesList/apply/pages/apply");
},
// 开通产品
// openPro() {
// let obj = {
// scene:3
// }
// wx.$router.go("/packagesList/applyProd/pages/apply",obj);
// },
// 预估产值
showCalculate() {
wx.$router.go("measure");
// this.setData({
// visible: !this.data.visible,
// isReset: false
// })
},
// clickDialog(e) {
// // console.log(e.changedTouches[0].clientY)
// if (e.changedTouches[0].clientY < 352) {
// this.setData({
// visible: false,
// isReset: false,
// formData: this.data.lastFormData
// })
// }
// },
// 提交测算
// submit(e) {
// let sales = e ? +e.detail.value.sales : this.data.formData.sales
// let flow = e ? +e.detail.value.flow : this.data.formData.flow
// // console.log('flow', sales, flow)
// const reg = /^[1-9]\d*$/
// // console.log(reg.test(sales), flow, '---')
// if (!reg.test(sales)) {
// wx.showToast({
// title: '门店月平均新车销量应为正整数',
// icon: 'none',
// duration: 2000
// })
// return
// }
// if (!reg.test(flow)) {
// wx.showToast({
// title: '3年内售后存量用户应为正整数',
// icon: 'none',
// duration: 2000
// })
// return
// }
// this.setData({
// 'lastFormData.sales': sales,
// 'lastFormData.flow': flow
// })
// const _this = this
// this.data.senceData.forEach((item, index) => {
// item.productList.forEach((i, lastIndex) => {
// if (i.profit) {
// let sale = `senceData[${index}].productList[${lastIndex}].sale`
// let name = `senceData[${index}].productList[${lastIndex}].profit`
// let flowKey = `senceData[${index}].productList[${lastIndex}].flow`
// let profit = _this.formula(i.productType, sales, flow)
// // console.log(name, profit)
// this.setData({
// [name]: profit,
// [sale]: sales,
// [flowKey]: flow
// })
// }
// })
// })
// // 触发自定义事件 利润 数量
// // this.triggerEvent('countProfit', profit, sales)
// // let type = this.getProductType(sceneIndex, tabIndex);
// // let profit = this.formula(type, sales, flow);
// // console.log('profit: ', profit);
// this.setData({
// visible: false
// })
// // this.showCase();
// // if (!this.data.isFirst) {
// wx.showToast({
// title: '测算结果已在页面内同步展示',
// icon: 'none',
// duration: 2000
// })
// // } else {
// // this.setData({
// // isFirst: false
// // })
// // }
// },
// // 获取场景下的产品类型
// getProductType(sceneIndex, tabIndex) {
// let typeArray = [
// ["benefitCard"], //数字无忧权益卡
// ["sunMembrane"], //汽车太阳膜
// ["protectMembrane", "colorMembrane"], //'漆面保护膜','改色膜'
// ["digitBeauty", "chair", "ar", "lamp", "navigation"], //'数字化美容','座椅通风','AR导航','氛围灯','360全景导航'
// ];
// return typeArray[sceneIndex][tabIndex];
// },
// 计算公式,参数:productType
// formula(productType, sales, flow) {
// let profit = 0
// switch (productType) {
// case 'benefitCard':
// // 数字无忧权益卡
// profit = (sales * 0.5 * 2000 * 12).toFixed(0)
// break
// case 'sunMembrane':
// // 汽车太阳膜
// profit = (sales * 0.8 * 0.7 * 1500 * 12).toFixed(0)
// break
// case 'protectMembrane':
// // 漆面保护膜
// profit = (sales * 0.05 * 3000 * 12).toFixed(0)
// break
// case 'colorMembrane':
// // 改色膜
// profit = (sales * 0.05 * 5000 * 12).toFixed(0)
// break
// case 'digitBeauty':
// // 数字化美容
// profit = (sales * 0.2 * 300 * 12).toFixed(0)
// break
// case 'chair':
// // 座椅通风
// profit = (flow * 2580 * 0.9 * 0.01).toFixed(0)
// break
// case 'ar':
// // AR导航
// profit = (flow * 1680 * 0.9 * 0.015).toFixed(0)
// break
// case 'lamp':
// // 氛围灯
// profit = (flow * 2680 * 0.9 * 0.015).toFixed(0)
// break
// case 'navigation':
// // 360全景导航
// profit = (flow * 2880 * 0.9 * 0.015).toFixed(0)
// break
// }
// // console.log(profit.length)
// // console.log(productType, sales, flow, profit)
// if (profit.length > 9) {
// return (profit / 10000).toFixed(0) + '万'
// } else {
// return profit
// }
// },
// reset() {
// this.setData({
// isReset: false,
// formData: {
// sales: 100,
// flow: 10000
// }
// })
// },
focus() {
this.setData({
isReset: true
})
return false
},
// 固定按钮
btnIsHide() {
this.setData({
['btnList[2].isHide']: this.data.tabIndx != 0
})
},
/**
* 生命周期函数--监听页面加载
*/
onLoad: function (options) {
// console.log('options: ', options);
let { sessionId } = wx.$storage.get()
// console.log("sessionId: ", sessionId);
let param = {
sessionId
}
// 看产品
this.getProductByscene()
// // 看线索
// this.getClueInit()
this.setData({
productData: this.addAll(this.data.productData)
})
this.getActivityRecord()
// //第一次进来储缓存,以后不再用引导图
let firstLogin = wx.$storage.get('firstLogin')
if (!firstLogin) {
//第一次隐藏tabar
wx.pro.hideTabBar()
this.setData({
guideShow: true
})
wx.$storage.set('firstLogin', 'firstLogin')
}
if (this.data.guideShow) {
wx.$storage.set('disLikeRecordFlag', true)
let disLikeRecordFlag = wx.$storage.get('disLikeRecordFlag')
this.setData({
disLikeRecordFlag
})
}
//视频弹窗
wx.$eventbus.on('getvideo', e => {
// console.log('getvideo event bus: ', e);
let url = wx.$util.getCurrentPageUrl()
if (url == '/pages/tab/index/index') {
let obj = {
videoTitle: e.title,
videoSrc: e.src
}
this.getVideoUrl(obj)
wx.nextTick(() => {
this.videocomp.play()
})
}
})
},
addAll(data) {
for (let i in data) {
let arr = [],
m = [],
n = []
data[i].map(item => {
arr = arr.concat(item.productList)
m = item.videoList
n = item.posterList
})
const allData = {
name: '全部',
productList: arr,
videoList: m,
posterList: n
}
data[i].unshift(allData)
}
return data
},
//接口数据,本地数据对接
compositionData(localData, apiData) {
localData.forEach((item, index) => {
apiData.forEach((inner, idx) => {
if (item.name == inner.stage) {
item.sceneStatus = inner.sceneStatus
item.productList.forEach((outChild, outIndex) => {
inner.productList.forEach((innerChild, innerIndex) => {
if (outChild.proName == innerChild.productName) {
outChild.productStatus = innerChild.productStatus
}
})
})
}
})
})
// console.log('localData, apiData: ', localData);
// this.setData({
// senceData: localData
// })
},
getFirstSenceIndex(param) {
let actTndex = this.data.apiData.findIndex(item => item.sceneStatus == 1)
// console.log('actTndex: ', actTndex);
this.setData({
actNum: actTndex
})
},
// 看产品接口
getProductByscene() {
productBysceneApi().then(res => {
let { code, data } = res
if (code == 0) {
this.setData({
apiData: data
})
// this.compositionData(senceData, this.data.apiData)
// this.getFirstSenceIndex();
}
})
},
// 看线索相关
/**
* 生命周期函数--监听页面初次渲染完成
*/
onReady: function () {
this.prompt = this.selectComponent('#toast')
this.videocomp = this.selectComponent('#videocomp')
},
// //点击收藏提示框
showToggleToast(e) {
let tipObj = e.detail
this.prompt.showToast({
type: tipObj.type,
title: tipObj.title,
duration: 1000,
compelete: function () {
// console.log("toast框隐藏之后,会调用该函数");
//例如:跳转页面wx.navigateTo({ url: 'xxx' });
}
})
},
onReachBottom() {
console.log('滑到底部了')
},
// 展示海报
getSharePost(merchantId) {
battleMessageApi({ serviceMerchantId: merchantId })
.then(result => {
console.log(result)
let posterId = wx.$storage.get('posterId')
console.log(posterId)
if (posterId == result.valueUrl) return
// 为2是已经展示过了
wx.$storage.set('posterId', result.valueUrl)
let updatedTime = deleteSecond(result.createdTime)
console.log(updatedTime)
this.setData({
posterItem: {
activityName: result.activityName,
// posterUrl: 'https://wx.glsx.com.cn/upload/biz/598888808108396544.png',
posterUrl: result.valueUrl,
// crowdFundActivityId: item.valueUrl,
updatedTime,
type: 'warReport'
}
})
// if (result.status && result.status != 2) {
// }
// debugger
})
.catch(err => { })
},
/**
* 生命周期函数--监听页面显示
*/
onShow: async function () {
let { userInfo } = wx.$storage.get()
!userInfo.isSuper && this.getSharePost(userInfo.subLoginUser.merchantId)
let { serviceMerchatList } = await getMockData() || { serviceMerchatList: [] }
this.setData({
isShowService: serviceMerchatList.includes(userInfo.merchantId + '')
})
},
// 节流函数
throttle(fn, gaptime) {
if (gaptime == null || gaptime == undefined) {
gaptime = 200
}
let _lastTime = null
return function () {
let _nowTime = +new Date()
if (_nowTime - _lastTime > gaptime || !_lastTime) {
fn.apply(this, arguments)
_lastTime = _nowTime
}
}
},
onPageScroll: (function () {
let timer = null
return function (e) {
// console.log("在滚动");
// 监听页面的滚动开始和结束
clearTimeout(timer)
timer = setTimeout(() => {
// console.log("滚动结束");
wx.$eventbus.emit('evt_page_scroll', { scrollTop: e.scrollTop })
}, 300)
}
})(),
//设置视频url
getVideoUrl(params) {
this.setData(params)
},
//申请活动
gotoApply() {
wx.$router.go('/packagesList/apply/pages/apply')
},
/** 客户数字化 */
sysMenuClick(e) {
console.log(e)
const { id } = e.detail
leftMenuIndex = id
},
/**
* 生命周期函数--监听页面隐藏
*/
onHide: function () { },
/**
* 生命周期函数--监听页面卸载
*/
onUnload: function () { },
/**
* 页面相关事件处理函数--监听用户下拉动作
*/
onPullDownRefresh: function () { },
/**
* 用户点击右上角分享
*/
onShareAppMessage: function () { },
onShareTimeline: function () { }
})