add.js
3.15 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
Component({
/**
* 组件的属性列表
*/
options: {
styleIsolation: 'apply-shared' // apply-shared 或 shared
},
properties: {
codeId: {
type: String,
value: ''
},
userPhone: {
type: Number,
value: ''
}
},
observers: {
'codeId': function (data) { }
},
/**
* 组件的初始数据
*/
data: {
list_fill: [{
label: '手机号',
value: 'ownerPhone',
type: 'input'
},
{
label: '车牌号',
value: 'carNumber'
},
{
label: '留言',
value: 'ownerRemark',
type: 'textarea'
}
],
form: {
ownerPhone: '',
carNumber: '',
ownerRemark: '临时停靠,马上回来',
userPhone: ''
}
},
/**
* 组件的方法列表
*/
methods: {
inputHandle(e) {
let {
detail: {
value
},
currentTarget: {
dataset: {
index
}
}
} = e
const list = ['form.ownerPhone', '', 'form.ownerRemark']
this.setData({
[list[index]]: value
})
},
clickRow(e) {
let {
index
} = e.currentTarget.dataset
if (index == 1) {
wx.chooseLicensePlate().then(res => {
console
this.setData({
'form.carNumber': res.plateNumber
})
})
}
},
//绑定
bindHandle() {
const phoneRex = /^[1]([3-9])[0-9]{9}$/
let index;
let {
form: {
ownerPhone,
carNumber,
ownerRemark,
id
},
codeId,
userPhone
} = this.data
try {
if (!ownerPhone) throw '请输入手机号'
if (!phoneRex.test(ownerPhone)) throw '请输入正确的手机号'
} catch (error) {
wx.p.wxApi.showToast(error)
return
}
index = codeId ? 1 : 0
let userInfo = wx.p.cache.userInfo.getUserInfo()
const Api = ['getUpdateRescueinfo', 'bindMovecode']
let params = {
ownerPhone,
carNumber,
ownerRemark,
unionId:userInfo.unionId
}
if (codeId) {
params.userPhone = userInfo.phone
params.codeId = codeId
} else {
params.id = id
}
wx.p.api.rescueApi[Api[index]](params).then(res => {
if (res) {
wx.p.wxApi.showToast('绑定成功')
//数据上报
// this.trackHttp()
wx.p.router.redirectTo('/packageMine/pages/move/success/success')
} else {
wx.p.wxApi.showToast(res.message)
}
})
},
trackHttp() {
const {
merchantId
} = wx.p.storage.get('merchant_info')
let {
form: {
ownerPhone,
carNumber,
}
} = this.data,
userInfo = wx.p.cache.userInfo.getUserInfo() || {},
data = {
unionId: userInfo.unionId || null,
car_number: carNumber,
customer_phone: ownerPhone || null,
add_way: 110,
merchant_id: merchantId
}
const jsonList = [JSON.stringify(data)]
wx.p.api.shopmallApi.trackHttp({
jsonList
})
}
}
})