indexMixin.js
5.98 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
import { equity } from '@r/api.js'
import shopList from './list'
export default {
data() {
return {
ServiceList: {},
goodsServiceList: {},
goodsServiceKey: [],
carServiceList: [],
merchantId: sessionStorage.getItem('GL_WX_MERCHANTID'),
notice: '',
phone_range: ['134', '135', '136', '137', '138', '139', '147', '150', '151', '152', '157', '158', '159', '182', '183', '184', '187', '188', '130', '131', '132', '145', '155', '156', '185', '186', '133', '153', '180', '181', '189', '170', '176', '177', '178'],
travelList: [{
name: '优惠加油',
icon: 'tuanyou',
description: '7折起',
id: 54
},
{
name: '道路救援',
icon: 'jiuyuan',
description: '非事故免费',
route: 'road'
},
],
hotelList: [{
name: '今日特惠',
icon: 'today',
description: '超性价比'
},
{
name: '景区门票',
icon: 'tickets',
description: '全国3000+景点'
}
],
cateringList2: [{
name: '肯德基',
icon: 'kfc',
description: '最高省81元',
typeId: 23
},
{
name: '麦当劳',
icon: 'm',
description: '最高省44元',
typeId: 64
},
{
name: '星巴克',
icon: 'xbk',
description: '最高省17元',
typeId: 21
},
{
name: '瑞幸咖啡',
icon: 'ruixing',
description: '最高省10元',
typeId: 148
}
],
gasList: [{
name: '覆盖城市',
icon: 'city',
subIcon: '400'
},
{
name: '加油站',
icon: 'gas',
subIcon: '10000'
}
],
...shopList
}
},
mounted() {
this.setNoticeInfo();
this.getMerchantid();
if (this.isMiniprogram) wx.miniProgram.postMessage({})
},
methods: {
setNoticeInfo() {
let { phone_range } = this
let start = this.setRandom(0, phone_range.length, 'floor')
let end = `${this.setRandom(0, 9, 'floor')}${this.setRandom(0, 9, 'floor')}${this.setRandom(0, 9, 'floor')}${this.setRandom(0, 9, 'floor')}`
let phone = `${phone_range[start]}***${end}`
let price = this.setRandom(25.99, 45.99).toFixed(2)
this.notice = `距离您当前位置的油站有优惠,点击加油,用户${phone}刚通过加油优惠${price}元。`
},
setRandom(start, end, type) {
if (type == 'floor') {
return Math.floor(Math.random() * (end - start)) + start
}
return Math.random() * (end - start) + start
},
updataNotice() {
this.setNoticeInfo()
},
CarLink(e) {
let supplier = e.supplier;
switch(supplier) {
case 'GL_OIL':
window.vm.$router.push({ path: '/oilStation/index'});
break;
case 'GL_ROAD_RESCUE':
window.vm.$router.push({ path: '/equity/road'});
break;
case 'GL_TIRE_PROTECTION':
window.vm.$router.push({ path: '/equity/tyre'});
break;
case 'GL_ROBBERY_PROTECTION':
window.vm.$router.push({ path: '/equity/compensate'});
break;
case 'GL_COLLISION_REPAIR':
window.vm.$router.push({ path: '/equity/collision'});
break;
case 'GL_CAR_TOTAL_LOSS':
window.vm.$router.push({ path: '/equity/loss'});
break;
case 'EDJ':
this.jumpDEJ();
break;
default:
this.showToast('即将上线,敬请期待')
}
},
jumpDEJ() {
let {sessionId} = JSON.parse(sessionStorage.getItem('GL_EQUITY_USER_INFO'));
let para = {
sessionId
}
equity.getEdjUrl(para).then(res => {
let {code, data, message} = res
if (code == 0){
this.openWindows(data)
} else {
this.showToast(message)
}
})
},
jumpLink(e) {
if(e.appearance == 1) {
window.vm.$router.push({ path: '/commodity/business/',query:{
brandId: e.brandId,
supplier: e.supplier
}
});
}else {
window.vm.$router.push({
path: '/commodity/recharge/', query: {
brandId: e.brandId,
supplier: e.supplier
}
})
}
},
// jumpLink(e) {
// let params = {
// ...e
// }
// delete params.name
// delete params.icon
// delete params.description
// console.log(params)
// if (params.route) {
// let [href] = window.location.href.split('/#/')
// let url = `${href}/#/equity/${params.route}`
// this.openWindows(url, `equity.${params.route}`)
// return
// }
// equity.getCouponList({
// requestSource: this.getChannel(), //1.小程序,2.APP,3.公众号
// ...params
// }).then(res => {
// console.log(res)
// let { code, data, message } = res
// if (code == 0) {
// this.openWindows(data)
// } else {
// this.showToast(message)
// }
//
// })
// }
getMerchantid() {
this.carServiceList = []
let para = {
merchantId: this.merchantId
}
equity.getMerchantid(para).then(res => {
let {code, data, message} = res
if (code == 0){
this.goodsServiceKey = Object.keys(data.goodsServiceList)
this.carServiceList = data.carServiceList
this.goodsServiceList = data.goodsServiceList;
} else {
this.showToast(message)
}
})
},
jumpMore() {
equity.getCouponList({
requestSource: this.getChannel() //1.小程序,2.APP,3.公众号
}).then(res => {
let { code, data, message } = res
if (code == 0) {
this.openWindows(data)
} else {
this.showToast(message)
}
})
}
},
}