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 -9
查看文件
@@ -150,18 +150,14 @@ Page({
onMockBind: function () {
var self = this
var mockDeviceId = 'MOCK_' + Date.now().toString(36).toUpperCase()
wx.showModal({
title: '模拟绑定',
content: '将创建一个模拟设备 ' + mockDeviceId + ' 并绑定到当前账号',
editable: true,
placeholderText: '输入设备编号(需先在后台创建)',
success: function (res) {
if (res.confirm) {
http.post('/api/v1/device/bind', { device_id: mockDeviceId }).then(function (data) {
return http.post('/api/v1/device/bind/confirm', {
device_id: data.device_id,
bind_token: data.bind_token
})
}).then(function () {
if (res.confirm && res.content) {
var deviceId = res.content.trim()
http.post('/api/v1/device/mock-bind', { device_id: deviceId }).then(function () {
wx.showToast({ title: '模拟绑定成功', icon: 'success' })
self.checkState()
}).catch(function (err) {