RecommendCar.js
5.9 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
import {
request
} from "../../request/index.js"
const a = getApp()
var timer = ''
Page({
data: {
imagesUrl: a.globalData.baseUrl,
msg: '',
name: '', //姓名
phone: '', //手机号
code: '', //验证码
yv_pay: '', // 购买预算
pin1: '', // 意向品牌1[品牌至少一个]
pin2: '', // 意向品牌2
pin3: '', // 意向品牌3
s4_id: '', //推荐4s店的id
bei: '', //
intention: [], // 意向品牌
city_id: '', // 城市id
arr4S: [],
intention: [],
SugImage: '',
ajxtrue: false,
brand: false,
downBrand: true,
pin_id: '',
CarBrandName1: '',
CarBrandName2: '',
CarBrandName3: '',
pinP1: 1,
pinP2: 2,
pinP3: 3,
time: 60,
countDownNum: 60,
sendNum: 0,
s4_id: '',
},
onLoad: function (options) {
// console.log(options);
let that = this
that.setData({
s4_id: options.s4_id || '',
CarBrandName1: options.CarBrandName1 || '',
CarBrandName2: options.CarBrandName2 || '',
CarBrandName3: options.CarBrandName3 || '',
pin_id: options.id || '',
})
let token = wx.getStorageSync("token")
if (token) {
that.getSugImage()
} else {
that.popConfirm()
}
},
onReady: function () {},
onShow: function () {},
popConfirm: function () {
wx.showModal({
title: '提示',
content: '您尚未登录,请登录后操作',
success: function (res) {
if (res.confirm) {
wx.navigateTo({
url: '/pages/authorization/authorization'
})
} else {
wx.switchTab({
url: '/pages/home/home'
})
}
}
})
},
async formSubmit(e) {
let that = this
let nn = e.detail.value
try {
const {
data
} = await request({
url: 'api/shop4s/sugCar',
data: {
name: nn.nickename,
phone: nn.phone,
code: nn.pass,
yv_pay: nn.yv_pay,
pin1: nn.pin1,
pin2: nn.pin2,
pin3: nn.pin3,
s4_id: that.data.s4_id,
bei: nn.bei,
}
})
// console.log(data);
a.popSuccessTest(data.msg)
setTimeout(() => {
wx.navigateBack()
}, 1200);
} catch (err) {
// console.log(err);
a.popTest(err.msg)
}
},
sendmima() { // 获取code
let that = this,
phone = a.setPhone(that.data.phone);
if (phone) {
that.countown()
// console.log(phone);
// return
setTimeout(async () => {
try {
const {
data: {
data
}
} = await request({
url: 'api/shop4s/faCode',
data: {
phone: phone
}
})
// console.log(data);
that.setData({
code: data.code
})
} catch (err) {
clearInterval(that.data.timer);
that.setData({
sendNum: 0
})
// console.log(err);
a.popTest(err.msg)
}
}, 1000);
}
},
countown() {
let that = this;
let countDownNum = that.data.countDownNum; //获取倒计时初始值
that.setData({
sendNum: 1,
timer: setInterval(function () {
countDownNum--;
that.setData({
countDownNum: countDownNum
})
if (that.data.countDownNum == 0) {
clearInterval(timer);
that.setData({
countDownNum: 60,
sendNum: 0
})
}
}, 1000)
})
},
async getSugImage() { // 获取
let that = this;
try {
const {
data: {
data
}
} = await
request({
url: 'api/common/img',
})
that.setData({
SugImage: data
})
} catch (err) {
// console.log(err);
a.popTest(err.msg)
}
},
goRuleBook() {
let that = this
let s4_id = that.data.s4_id
wx.navigateTo({
url: '/pages/ruleBook/ruleBook?s4_id=' + s4_id
})
},
async getPinChe() { // 获取车辆品牌
let that = this
try {
const {
data: {
data
}
} = await request({
url: 'api/index/pin',
method: 'GET'
})
let obj = []
data.forEach((value) => {
obj.push(value.name)
})
that.setData({
intention: obj,
arrayChe: data
})
} catch (err) {
// console.log(err);
a.popTest(err.msg)
}
},
blurPhone(e) {
let phone = e.detail.value;
let that = this
that.setData({
phone
})
},
downBrand() {
this.setData({
brand: true,
downBrand: false
})
},
goCarBrand() {
wx.navigateTo({
url: '/pages/CarBrand/CarBrand?pinP=' + this.data.pinP1
})
},
goCarBrand2() {
wx.navigateTo({
url: '/pages/CarBrand/CarBrand?pinP=' + this.data.pinP2
})
},
goCarBrand3() {
wx.navigateTo({
url: '/pages/CarBrand/CarBrand?pinP=' + this.data.pinP3
})
},
go4Ssearch() {
let that = this
if (that.data.CarBrandName3 || that.data.CarBrandName2 || that.data.CarBrandName1) {
wx.navigateTo({
url: '/pages/4Ssearch/4Ssearch?pin_id=' + this.data.pin_id + '&city_id=' + this.data.city_id
})
} else {
a.popTest('尚未选择意向品牌,请先选择意向品牌')
}
},
onShareAppMessage(options) {
var that = this;
var shareObj = {
title: "同放分享", // 默认是小程序的名称(可以写slogan等)
path: '/pages/RecommendCar/RecommendCar', // 默认是当前页面,必须是以‘/’开头的完整路径
imageUrl: '', //自定义图片路径,可以是本地文件路径、代码包文件路径或者网络图片路径,支持PNG及JPG,不传入 imageUrl 则使用默认截图。显示图片长宽比是 5:4
};
// 返回shareObj
return shareObj;
},
})