index.js
4.67 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
import { env } from '~/api/env/index'
import { goodsList } from '../constant/lifeConstant'
Page({
/**
* 页面的初始数据
*/
data: {
tripMenu: [],
goodsList,
utilList: []
},
/**
* 生命周期函数--监听页面加载
*/
onLoad(options) {
const {
merchantId
} = wx.p.storage.get('merchant_info')
this.getHomeConfig(merchantId)
this.getAllMerchantList()
},
getHomeConfig(merchantId) {
wx.p.api.homeApi.getHomeConfig({ merchantId }).then(data => {
wx.hideLoading();
let utilList = []
if (data.clueList && data.clueList.length) {
data.clueList.map(e => {
if (e.clueId == 1) {
let rescueTypeList = [
{
confId: 5,
name: '事故救援',
iconUrl: 'accident_rescue_icon',
sign: '免费'
},
{
confId: 3,
name: '送油',
iconUrl: 'send_oil_icon'
},
{
confId: 4,
name: '搭电',
iconUrl: 'pick_up_power_icon'
},
{
confId: 2,
name: '换胎',
iconUrl: 'trie_change_icon'
},
{
confId: 0,
name: '紧急脱困',
iconUrl: 'emergency_relief_icon',
},
{
confId: 1,
name: '拖车',
iconUrl: 'trailer_icon'
},
// {
// confId: 6,
// name: '找车位',
// iconUrl: 'parking_icon',
// url: '/packageEquity/pages/parking/index/index'
// },
]
rescueTypeList.forEach(v => {
utilList.push({
...v,
url: v.url ? v.url : '/packageEquity/pages/road/index/index'
})
})
}
})
}
this.setData({
utilList
})
})
},
getAllMerchantList() {
const {
merchantId
} = wx.p.storage.get('merchant_info')
let para = {
merchantId
}
wx.p.api.equityApi.getAllEquity(para).then(res => {
const carList = res.carServiceList
const equityList = res.goodsServiceList
let tripMenu = []
const needShowEquity = ['高德打车', '曹操出行']
if (env == 'production') {
equityList.forEach(el => {
if (el.goodsCategory == '交通出行') {
if (el.equityGoodsGroupDescDtos) {
el.equityGoodsGroupDescDtos.forEach(item => {
if (needShowEquity.includes(item.equityName))
tripMenu.push({
name: item.equityName,
icon: item.equityIcon,
...item,
sign: item.equityName == '高德打车' ? '10元券' : ''
})
})
}
}
})
} else if (env == 'test' || env == 'beta') {
equityList.forEach(el => {
if (el.equityGoodsGroupDescDtos) {
el.equityGoodsGroupDescDtos.forEach(item => {
tripMenu.push({
name: item.equityName,
icon: item.equityIcon,
...item
})
})
}
})
}
this.setData({
tripMenu
})
})
},
})