bind.js
4.4 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
const restapi = require('../restapi.js');
const filter = require('../../../../utils/filter.js');
const util = require('../../../../utils/util.js');
const app = getApp();
Page(filter.identityFilter({
/**
* 页面的初始数据
*/
data: {
authToast: false, // 是否显示授权提示框
authType: true, // 授权类型(true:授权用户信息;false:授权手机号)
marginTop: 0,
flag: false,
typeid:null,
type:null,
imei:null,
list: true,
buttonClicked: true,
oncar: null,//是否已上牌,1:未上牌,2:已上牌
},
/**
* 获取导航栏高度
*/
getNavHeight(e) {
console.log(e)
this.setData({
marginTop: e.detail
})
console.log(this.data.marginTop)
},
radioChange: function (e) {
console.log('radio发生change事件,携带value值为:', e.detail.value);
this.setData({
oncar: e.detail.value
})
},
richScan() {
let _this = this
wx.scanCode({
success(res) {
console.log(res)
_this.setData({
imei: res.result
})
}
})
},
bindinput(e) {
let target = e.currentTarget.dataset.name
let value = e.detail.value
this.setData({
[target]: value,
flag: true
})
},
bindBtn(e){
let self = this;
let merchantId = app.globalData.extConfig.merchantId;
if (!merchantId || merchantId == 'undefined') {
merchantId = 0;
}
let imei = self.data.imei;
if(!imei){
wx.showToast({
title: '请输入设备序列号',
icon: 'none',
duration: 2000
})
setTimeout(() => {
wx.hideToast()
}, 4000)
return;
}
let validateCode = '';
let typeId = self.data.typeid;
let oncar = self.data.oncar;
let obj = {
imei: imei,
validateCode:'',
typeId: typeId,
merchantId: merchantId
}
let promise = new Promise((resolve, reject) => {
restapi.bindDevice(obj, function (response) {
console.log("bindDevice", response);
if (response.returnCode == '0' && response.data) {
let result = response.data;
if (result || result == 'true') {
//绑定成功
wx.showToast({
title: '绑定成功',
icon: 'success',
duration: 5000
})
wx.switchTab({
url: '../../../../pages/tab/smartplus/smartplus'
})
resolve(result);
} else {
util.showLoading(response.message);
}
} else {
util.showLoading(response.message);
}
}, function (response) {
})
})
promise.then((data) => {
if (!oncar){
return;
}
// if (oncar == 1) {
// restapi.newCarBind(imei, validateCode, typeId, function (response) {
// console.log("newCarBind", response)
// if (response.returnCode == '0' && response.data == 1) {
// wx.navigateTo({
// url: '/packageIndex/pages/bindingDevice/index/index'
// })
// }
// }, function (response) {
// })
// } else {
// restapi.isNoVehicle(typeId, function (response) {
// console.log("isNoVehicle", response)
// if (response.returnCode == '0' && response.data) {
// let errId = response.errId;
// if (errId) {
// wx.navigateTo({
// url: 'packageIndex/pages/vehicle/vehicle'
// })
// }
// }
// }, function (response) {})
// }
});
setTimeout(() => {
wx.hideLoading()
}, 4000)
},
/**
* 生命周期函数--监听页面加载
*/
onLoad: function (options) {
var self = this;
console.log("onLoad", options)
let type = options.type;
let typeid = options.typeid;
self.setData({
type:type,
typeid: typeid
})
},
/**
* 生命周期函数--监听页面初次渲染完成
*/
onReady: function () {
},
/**
* 生命周期函数--监听页面显示
*/
onShow: function () {
},
/**
* 监听登录成功--页面onShow时触发
*/
onLogin: function () {
}
}))