- Add expire_time > NOW() filter to findActive() preventing stale subscriptions - Add express-rate-limit on login endpoints (user: 10/15min, admin: 5/15min) - Add production guard for default admin credentials - Fix BLE bindDevice userId encoding (uint32 instead of hexToBytes on numeric) - Wrap adminCreate in transaction to prevent race condition - Add settings cache invalidation after admin saves - Read trial_days from settings instead of hardcoding 7 - Fix double JSON.stringify in commandDao.finish call - Cancel stale pending bindings before creating new ones - Reduce token refresh grace period from 3 days to 1 day - Fix subscribe-success to fetch expiry from server (correct for renewals) - Add keep-alive name property to DashboardView and SettingsView - Fix BLE disconnect() to preserve listener registrations across reconnects
56 行
1.6 KiB
JavaScript
56 行
1.6 KiB
JavaScript
var api = require('../../utils/api')
|
|
|
|
Page({
|
|
data: {
|
|
statusBarHeight: 44,
|
|
planName: '年卡会员',
|
|
expiryDate: ''
|
|
},
|
|
|
|
onBack: function () {
|
|
wx.navigateBack({
|
|
fail: function () {
|
|
wx.reLaunch({ url: '/pages/index/index' })
|
|
}
|
|
})
|
|
},
|
|
|
|
onLoad: function (options) {
|
|
var self = this
|
|
var app = getApp()
|
|
self.setData({ statusBarHeight: app.globalData.statusBarHeight })
|
|
|
|
var planMap = { yearly: '年卡会员', monthly: '月卡会员', trial: '试用会员' }
|
|
var plan = options.plan || 'yearly'
|
|
self.setData({ planName: planMap[plan] || '会员' })
|
|
|
|
// Fetch actual subscription expiry from server instead of computing client-side
|
|
api.getSubscription().then(function (res) {
|
|
if (res && res.expire_time) {
|
|
var date = new Date(res.expire_time)
|
|
var y = date.getFullYear()
|
|
var m = ('0' + (date.getMonth() + 1)).slice(-2)
|
|
var d = ('0' + date.getDate()).slice(-2)
|
|
self.setData({ expiryDate: y + '年' + m + '月' + d + '日' })
|
|
}
|
|
}).catch(function () {
|
|
// Fallback: compute from current date if server call fails
|
|
var durationMap = { yearly: 365, monthly: 30, trial: 7 }
|
|
var now = new Date()
|
|
now.setDate(now.getDate() + (durationMap[plan] || 365))
|
|
var y = now.getFullYear()
|
|
var m = ('0' + (now.getMonth() + 1)).slice(-2)
|
|
var d = ('0' + now.getDate()).slice(-2)
|
|
self.setData({ expiryDate: y + '年' + m + '月' + d + '日' })
|
|
})
|
|
},
|
|
|
|
onStartSmart: function () {
|
|
wx.navigateTo({ url: '/pages/wear-check/wear-check' })
|
|
},
|
|
|
|
onBackHome: function () {
|
|
wx.switchTab({ url: '/pages/index/index' })
|
|
}
|
|
})
|