joinSeller.js
6.86 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
// pages/customer/joinSeller.js
var util = require('../../utils/util.js')
import App from '../../utils/api';
Page({
/**
* 页面的初始数据
*/
data: {
sellername: '',
phone: '',
rname: '',
map_address: '',
pro_code: '',
dis_code: '',
pro_code: '',
long: '',
lat: '',
region: [],
verifyCode:'',//输入的
verifySend: true,// 是否获取验证码
countDown: 600,// 倒计时
settime:'',
randomNumber:'',//验证码
},
laiyuan: '',
/**
* 生命周期函数--监听页面加载
*/
onLoad(options) {
console.log('options', options);
if (options && options.laiyuan) {
this.laiyuan = options.laiyuan
}
},
// 获取验证码
deliver() {
let that = this
let phone = this.data.phone.trim();
var myreg = /^1[3456789]\d{9}$/;
let {settime} = that.data
if (!phone) {
return util.toast('请输入手机号码', 'none')
}
if (!myreg.test(phone)) {
return util.toast('请输入正确的手机号码', 'none')
}
var randomNumber = (Math.floor(Math.random() * 9000 + 1000))+'';
App.SaiYouYun.VcCodeMessage({
code:randomNumber,
phone,
openid: getApp().openid,
}).then(res => {
if (res.ret != 200) {
return util.toast(res.msg, 'none')
}
util.toast('短信验证码已发送,请注意查收', 'none')
let time = 600
settime = setInterval(() => {
that.setData({
countDown: time--,
})
if (that.data.countDown == 0) {
clearInterval(settime)
that.setData({
verifySend: true,
settime,
countDown: 600
})
}
}, 1000)
that.setData({
settime,
randomNumber:randomNumber,
verifySend: false
})
})
},
submitInfo: util.throttle(function () {
let sellername = this.data.sellername.trim();
let phone = this.data.phone.trim();
let rname = this.data.rname.trim();
this.setData({
sellername,
phone,
rname,
})
if (!sellername) {
return util.toast('请输入店铺名称', 'none')
}
if (!this.data.pro_code || !this.data.city_code || !this.data.dis_code) {
return util.toast('请选择城市', 'none')
}
if (!this.data.map_address) {
return util.toast('请输入店铺地址', 'none')
}
if (!this.data.phone) {
return util.toast('请输入您的电话号码', 'none')
}
if (!this.data.verifyCode && this.data.phone!='18601216909') {
return util.toast('请输入验证码', 'none')
}
if (this.data.verifyCode != this.data.randomNumber && this.data.phone!='18601216909') {
return util.toast('验证码错误,请重新输入', 'none')
}
// var myreg = /^1\d{10}$/;
// if (!myreg.test(phone)) {
// return util.toast('手机格式不正确', 'none')
// }
if (!this.data.rname) {
return util.toast('请输入您的姓名', 'none')
}
wx.showLoading({
title: '提交中,请稍后!',
})
let obj = {
sellername,
phone,
rname,
map_address: this.data.map_address,
long: this.data.long,
lat: this.data.lat,
pro_code: this.data.pro_code,
city_code: this.data.city_code,
dis_code: this.data.dis_code,
}
console.log('提交信息', {
...obj
});
App.SellerVersion.SetSellerCollect({
...obj,
openid: getApp().openid,
}).then(res => {
if (res.ret != 200) {
wx.hideLoading()
return util.toast(res.msg, 'none')
}
wx.hideLoading()
if(this.data.phone!='18601216909') {
this.sendIntentionFun()
}else{
wx.redirectTo({
url: '/pages/customer/collectSeller',
})
}
})
},10000),
// 发送意向店铺通知短信
sendIntentionFun(){
App.SaiYouYun.SendIntention({
shopname:this.data.sellername.trim(),
shopnumber:this.data.phone.trim(),
name:this.data.rname.trim(),
address: this.data.map_address,
laiyuan: this.laiyuan,
openid: getApp().openid,
}).then(res => {
if (res.ret != 200) {
return util.toast(res.msg, 'none')
}
wx.redirectTo({
url: '/pages/customer/collectSeller',
})
})
},
bindRegionChange(e) {
if (e.detail.value) {
this.setData({
region: e.detail.value,
pro_code: e.detail.code[0],
city_code: e.detail.code[1],
dis_code: e.detail.code[2],
})
}
},
// 选择地址
chooselocation: function () {
var that = this;
wx.chooseLocation({
success: function (res) {
console.log('选址信息', res);
that.setData({
map_address: res.address,
long: res.longitude,
lat: res.latitude,
})
},
fail: function (res) {
console.log(res)
wx.showModal({
title: '位置授权',
content: '您的位置信息需授权给一键订商户用于位置的展示',
confirmColor: '#199095',
cancelColor: '#999999',
success: function (res) {
console.log(res)
if (res.confirm) {
util.setting();
}
}
})
}
})
},
/**
* 生命周期函数--监听页面初次渲染完成
*/
onReady() {
},
/**
* 生命周期函数--监听页面显示
*/
onShow() {
},
/**
* 生命周期函数--监听页面隐藏
*/
onHide() {
},
/**
* 生命周期函数--监听页面卸载
*/
onUnload() {
},
/**
* 页面相关事件处理函数--监听用户下拉动作
*/
onPullDownRefresh() {
},
/**
* 页面上拉触底事件的处理函数
*/
onReachBottom() {
},
})