优化:提升小程序全链路性能

This commit is contained in:
2026-10-11 16:53:02 +08:00
parent 0e7e60fefd
commit f00c753fd6
20 changed files with 403 additions and 113 deletions
@@ -1,6 +1,7 @@
const userApi = require('../../api/user')
const authApi = require('../../api/auth')
const auth = require('../../utils/auth')
const profileCache = require('../../utils/profile-cache')
Page({
data: {
@@ -16,10 +17,10 @@ Page({
onShow() { this.loadProfile() },
async loadProfile() {
async loadProfile(options = {}) {
this.setData({ loading: true })
try {
const profile = await userApi.info()
const profile = await profileCache.getProfile(options)
this.setData({ profile, 'smsForm.phone': profile.phone || '' })
const app = getApp()
const session = auth.getSession()
@@ -49,7 +50,8 @@ Page({
this.setData({ binding: true })
try {
await userApi.bindWechatPhone(phoneCode)
await this.loadProfile()
profileCache.invalidate()
await this.loadProfile({ force: true })
wx.showToast({ title: '手机号已绑定' })
} catch (error) {
wx.showToast({ title: error.message || '绑定失败', icon: 'none' })
@@ -95,7 +97,8 @@ Page({
this.setData({ binding: true })
try {
await userApi.bindPhone({ phone: form.phone, verificationCode: form.code })
await this.loadProfile()
profileCache.invalidate()
await this.loadProfile({ force: true })
wx.showToast({ title: '手机号已绑定' })
} catch (error) {
wx.showToast({ title: error.message || '绑定失败', icon: 'none' })