feat: add mock-bind endpoint to bypass token flow for testing
The bind + confirm two-step flow has timezone issues between Node.js (UTC on SCF) and MySQL (timezone +08:00) that cause bind_token to fail validation. Add POST /api/v1/device/mock-bind that does bind + confirm in one atomic step, skipping the token entirely. Only available when NODE_ENV != production. Update ble-connect and index page mock buttons to use mock-bind.
这个提交包含在:
@@ -96,16 +96,13 @@ Page({
|
||||
this.startBleConnect()
|
||||
},
|
||||
|
||||
_mockConfirmBind: function () {
|
||||
onMockConnect: function () {
|
||||
var self = this
|
||||
clearTimeout(this._scanTimer)
|
||||
ble.stopScan()
|
||||
self.setData({ state: 'binding' })
|
||||
http.post('/api/v1/device/bind', {
|
||||
http.post('/api/v1/device/mock-bind', {
|
||||
device_id: self.data.deviceId
|
||||
}).then(function (data) {
|
||||
return http.post('/api/v1/device/bind/confirm', {
|
||||
device_id: data.device_id,
|
||||
bind_token: data.bind_token
|
||||
})
|
||||
}).then(function () {
|
||||
self.setData({ state: 'done' })
|
||||
wx.redirectTo({
|
||||
@@ -116,15 +113,7 @@ Page({
|
||||
})
|
||||
},
|
||||
|
||||
onMockConnect: function () {
|
||||
clearTimeout(this._scanTimer)
|
||||
ble.stopScan()
|
||||
this._mockConfirmBind()
|
||||
},
|
||||
|
||||
onMockBindSuccess: function () {
|
||||
clearTimeout(this._scanTimer)
|
||||
ble.stopScan()
|
||||
this._mockConfirmBind()
|
||||
this.onMockConnect()
|
||||
}
|
||||
})
|
||||
|
||||
在新工单中引用
屏蔽一个用户