fix: back button alignment, mock bind flow, and timezone bug
- nav-back: add text-align:left to override page-header's center - ble-connect mock: call bind API first to get fresh token before confirm, instead of relying on potentially stale URL params - utils.js: use local time instead of UTC for toMysqlDate, fixing timezone mismatch with MySQL NOW() that caused bind tokens to appear immediately expired
这个提交包含在:
@@ -244,6 +244,7 @@ page {
|
|||||||
color: rgba(255, 255, 255, 0.85);
|
color: rgba(255, 255, 255, 0.85);
|
||||||
padding: 8rpx 0;
|
padding: 8rpx 0;
|
||||||
margin-bottom: 8rpx;
|
margin-bottom: 8rpx;
|
||||||
|
text-align: left;
|
||||||
}
|
}
|
||||||
|
|
||||||
.nav-back-light {
|
.nav-back-light {
|
||||||
|
|||||||
@@ -96,38 +96,35 @@ Page({
|
|||||||
this.startBleConnect()
|
this.startBleConnect()
|
||||||
},
|
},
|
||||||
|
|
||||||
onMockConnect: function () {
|
_mockConfirmBind: function () {
|
||||||
var self = this
|
var self = this
|
||||||
clearTimeout(this._scanTimer)
|
|
||||||
ble.stopScan()
|
|
||||||
self.setData({ state: 'binding' })
|
self.setData({ state: 'binding' })
|
||||||
// Skip BLE bind, confirm directly with server
|
http.post('/api/v1/device/bind', {
|
||||||
http.post('/api/v1/device/bind/confirm', {
|
device_id: self.data.deviceId
|
||||||
device_id: self.data.deviceId,
|
}).then(function (data) {
|
||||||
bind_token: self.data.bindToken
|
return http.post('/api/v1/device/bind/confirm', {
|
||||||
|
device_id: data.device_id,
|
||||||
|
bind_token: data.bind_token
|
||||||
|
})
|
||||||
}).then(function () {
|
}).then(function () {
|
||||||
self.setData({ state: 'done' })
|
self.setData({ state: 'done' })
|
||||||
wx.redirectTo({
|
wx.redirectTo({
|
||||||
url: '/pages/bind-success/bind-success?device_id=' + self.data.deviceId
|
url: '/pages/bind-success/bind-success?device_id=' + self.data.deviceId
|
||||||
})
|
})
|
||||||
}).catch(function (err) {
|
}).catch(function (err) {
|
||||||
self.setData({ state: 'error', error: err.message || '模拟确认失败' })
|
self.setData({ state: 'error', error: err.message || '模拟绑定失败' })
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
|
|
||||||
onMockBindSuccess: function () {
|
onMockConnect: function () {
|
||||||
var self = this
|
|
||||||
clearTimeout(this._scanTimer)
|
clearTimeout(this._scanTimer)
|
||||||
ble.stopScan()
|
ble.stopScan()
|
||||||
http.post('/api/v1/device/bind/confirm', {
|
this._mockConfirmBind()
|
||||||
device_id: self.data.deviceId,
|
},
|
||||||
bind_token: self.data.bindToken
|
|
||||||
}).then(function () {
|
onMockBindSuccess: function () {
|
||||||
wx.redirectTo({
|
clearTimeout(this._scanTimer)
|
||||||
url: '/pages/bind-success/bind-success?device_id=' + self.data.deviceId
|
ble.stopScan()
|
||||||
})
|
this._mockConfirmBind()
|
||||||
}).catch(function (err) {
|
|
||||||
self.setData({ state: 'error', error: err.message || '模拟确认失败' })
|
|
||||||
})
|
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|||||||
+2
-1
@@ -2,7 +2,8 @@ function toMysqlDate(value) {
|
|||||||
if (!value) return null
|
if (!value) return null
|
||||||
const d = new Date(value)
|
const d = new Date(value)
|
||||||
if (Number.isNaN(d.getTime())) return null
|
if (Number.isNaN(d.getTime())) return null
|
||||||
return d.toISOString().slice(0, 19).replace('T', ' ')
|
const pad = n => String(n).padStart(2, '0')
|
||||||
|
return d.getFullYear() + '-' + pad(d.getMonth() + 1) + '-' + pad(d.getDate()) + ' ' + pad(d.getHours()) + ':' + pad(d.getMinutes()) + ':' + pad(d.getSeconds())
|
||||||
}
|
}
|
||||||
|
|
||||||
function formatDate(date) {
|
function formatDate(date) {
|
||||||
|
|||||||
在新工单中引用
屏蔽一个用户