更新小程序开发文档,新增2026-03-03的最佳实践记录,优化个人中心类页面的卡片区边距规范,确保一致性与可用性。调整相关页面以反映最新设计稿,提升用户体验与功能一致性。

This commit is contained in:
Alex-larget
2026-03-04 19:06:06 +08:00
parent 7064f82126
commit 5a5f0087d2
66 changed files with 2555 additions and 1059 deletions

View File

@@ -8,7 +8,7 @@ const { parseScene } = require('./utils/scene.js')
App({
globalData: {
// API基础地址 - 连接真实后端
baseUrl: 'https://soulapi.quwanzhi.com',
baseUrl: 'https://soulapi.quwanzhi.com',
// baseUrl: 'https://souldev.quwanzhi.com',
// baseUrl: 'http://localhost:8080',
@@ -56,7 +56,10 @@ App({
navBarHeight: 88,
// TabBar相关
currentTab: 0
currentTab: 0,
// 更新检测:上次检测时间戳,避免频繁请求
lastUpdateCheck: 0
},
onLaunch(options) {
@@ -77,9 +80,10 @@ App({
this.handleReferralCode(options)
},
// 小程序显示时也检查分享参数
// 小程序显示时:处理分享参数、检测更新(从后台切回时)
onShow(options) {
this.handleReferralCode(options)
this.checkUpdate()
},
// 处理推荐码绑定:官方以 options.scene 接收扫码参数(可同时带 mid/id + ref与 utils/scene 解析闭环
@@ -238,21 +242,30 @@ App({
}
},
// 检查更新
/**
* 小程序更新检测(基于 wx.getUpdateManager
* - 启动时检测;从后台切回前台时也检测(间隔至少 5 分钟,避免频繁请求)
*/
checkUpdate() {
if (wx.canIUse('getUpdateManager')) {
try {
if (!wx.canIUse('getUpdateManager')) return
const now = Date.now()
const lastCheck = this.globalData.lastUpdateCheck || 0
if (lastCheck && now - lastCheck < 5 * 60 * 1000) return // 5 分钟内不重复检测
this.globalData.lastUpdateCheck = now
const updateManager = wx.getUpdateManager()
updateManager.onCheckForUpdate((res) => {
if (res.hasUpdate) {
console.log('发现新版本')
console.log('[App] 发现新版本,正在下载...')
}
})
updateManager.onUpdateReady(() => {
wx.showModal({
title: '更新提示',
content: '新版本已准备好,是否重启应用?',
content: '新版本已准备好,重启后即可使用',
confirmText: '立即重启',
cancelText: '稍后',
success: (res) => {
if (res.confirm) {
updateManager.applyUpdate()
@@ -260,13 +273,15 @@ App({
}
})
})
updateManager.onUpdateFailed(() => {
wx.showToast({
title: '更新失败,请稍后重试',
icon: 'none'
icon: 'none',
duration: 2500
})
})
} catch (e) {
console.warn('[App] checkUpdate failed:', e)
}
},