文件
jw-beauty/miniprogram/pages/profile/profile.js
T
Guoguo 71e4a487a5 fix: resolve subscription UX issues and add placeholder pages
- Profile: show "未订阅" card when subscription inactive/0 days
- Profile: subscription management navigates to page instead of modal
- Subscribe-plans: data-driven plan cards with mock payment flow
- Subscribe-plans: show current subscription status at top
- Subscribe-prompt: "先使用普通模式" goes to wear-check directly
- Add help and contact placeholder pages
- Fix unbindDevice to work without explicit deviceId
2026-04-29 07:00:36 -07:00

91 行
2.2 KiB
JavaScript

var api = require('../../utils/api')
var app = getApp()
Page({
data: {
userInfo: null,
subscription: null,
deviceCount: 0,
subRemaining: 0
},
onShow: function () {
this.loadProfile()
},
loadProfile: function () {
var self = this
api.getProfile().then(function (profile) {
self.setData({
userInfo: profile,
deviceCount: profile.device_count || 0
})
}).catch(function () {})
api.getSubscription().then(function (sub) {
self.setData({
subscription: sub,
subRemaining: sub.remaining_days || 0
})
}).catch(function () {})
},
onManageDevice: function () {
var self = this
if (this.data.deviceCount > 0) {
wx.showActionSheet({
itemList: ['解绑当前设备'],
success: function (res) {
if (res.tapIndex === 0) {
wx.showModal({
title: '确认解绑',
content: '解绑后将无法使用该设备,确定要解绑吗?',
success: function (modalRes) {
if (modalRes.confirm) {
api.unbindDevice().then(function () {
wx.showToast({ title: '已解绑', icon: 'success' })
self.loadProfile()
}).catch(function (err) {
wx.showToast({ title: err.message || '解绑失败', icon: 'none' })
})
}
}
})
}
}
})
} else {
wx.navigateTo({ url: '/pages/scan/scan' })
}
},
onViewSubscription: function () {
wx.navigateTo({ url: '/pages/subscribe-plans/subscribe-plans' })
},
onViewHistory: function () {
wx.switchTab({ url: '/pages/history/history' })
},
onHelp: function () {
wx.navigateTo({ url: '/pages/help/help' })
},
onContact: function () {
wx.navigateTo({ url: '/pages/contact/contact' })
},
onLogout: function () {
wx.showModal({
title: '退出登录',
content: '确定要退出登录吗?',
success: function (res) {
if (res.confirm) {
wx.removeStorageSync('token')
wx.reLaunch({ url: '/pages/login/login' })
}
}
})
}
})