Server: - Add settings-cache with 60s TTL for feature toggle checks - Enforce maintenance_mode on login, enable_binding on device bind Admin console: - Remove dead "发送通知" button from user detail - Firmware check calls real API and compares versions Miniprogram: - Wear-check: dynamic battery/connected from BLE state - Login: hide non-functional phone auth button - Treating: show actual selected regions instead of hardcoded "全脸" - Index: display subscription status with tap to manage - Auto-scan: show "待检测" instead of "--" for PD data - Agreements: tap shows "内容建设中" modal
90 行
2.4 KiB
JavaScript
90 行
2.4 KiB
JavaScript
var app = getApp()
|
|
var http = require('../../utils/request')
|
|
|
|
Page({
|
|
data: {
|
|
statusBarHeight: 44,
|
|
loading: false,
|
|
userProfile: null
|
|
},
|
|
|
|
onLoad: function () {
|
|
var app = getApp()
|
|
this.setData({ statusBarHeight: app.globalData.statusBarHeight })
|
|
},
|
|
|
|
onLogin: function () {
|
|
var self = this
|
|
self.setData({ loading: true })
|
|
|
|
self.getWechatProfile().then(function (profile) {
|
|
self.setData({ userProfile: profile })
|
|
return app.doLogin()
|
|
}).then(function () {
|
|
return self.saveProfile()
|
|
}).then(function () {
|
|
self.setData({ loading: false })
|
|
wx.switchTab({ url: '/pages/index/index' })
|
|
}).catch(function (err) {
|
|
self.setData({ loading: false })
|
|
wx.showToast({ title: err.message || '登录失败', icon: 'none' })
|
|
})
|
|
},
|
|
|
|
getWechatProfile: function () {
|
|
return new Promise(function (resolve) {
|
|
if (!wx.getUserProfile) {
|
|
resolve(null)
|
|
return
|
|
}
|
|
wx.getUserProfile({
|
|
desc: '用于完善会员资料',
|
|
success: function (res) {
|
|
resolve(res.userInfo || null)
|
|
},
|
|
fail: function () {
|
|
resolve(null)
|
|
}
|
|
})
|
|
})
|
|
},
|
|
|
|
saveProfile: function () {
|
|
var profile = this.data.userProfile || {}
|
|
if (!profile.nickName && !profile.avatarUrl) return Promise.resolve()
|
|
return this.updateProfile({
|
|
nickname: profile.nickName || '',
|
|
avatar: profile.avatarUrl || '',
|
|
gender: profile.gender || 0
|
|
})
|
|
},
|
|
|
|
updateProfile: function (payload) {
|
|
return http.put('/api/v1/user/profile', payload).then(function () {
|
|
return app.loadProfile()
|
|
})
|
|
},
|
|
|
|
onAgreement: function () {
|
|
wx.showModal({ title: '提示', content: '用户协议和隐私政策内容建设中', showCancel: false })
|
|
},
|
|
|
|
onGetPhoneNumber: function (e) {
|
|
var self = this
|
|
if (!e.detail || !e.detail.code) {
|
|
wx.showToast({ title: '已跳过手机号授权', icon: 'none' })
|
|
return
|
|
}
|
|
self.setData({ loading: true })
|
|
app.doLogin().then(function () {
|
|
return http.post('/api/v1/user/phone', { code: e.detail.code })
|
|
}).then(function () {
|
|
self.setData({ loading: false })
|
|
wx.switchTab({ url: '/pages/index/index' })
|
|
}).catch(function (err) {
|
|
self.setData({ loading: false })
|
|
wx.showToast({ title: err.message || '手机号授权失败', icon: 'none' })
|
|
})
|
|
}
|
|
})
|