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.
这个提交包含在:
Guoguo
2026-04-29 05:10:12 -07:00
父节点 3e8cd8764a
当前提交 775112130d
修改 3 个文件,包含 35 行新增25 行删除
+5 -16
查看文件
@@ -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()
}
})