From 0f9633b8f0ae2cccfe71beacf32a35518a533b67 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E4=B9=98=E9=A3=8E?= Date: Fri, 13 Feb 2026 09:59:08 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BC=98=E5=8C=96=E5=B0=8F=E7=A8=8B=E5=BA=8F?= =?UTF-8?q?=E7=89=88=E6=9C=AC=E6=9B=B4=E6=96=B0=E6=A3=80=E6=B5=8B=E9=80=BB?= =?UTF-8?q?=E8=BE=91=EF=BC=8C=E5=A2=9E=E5=BC=BA=E7=94=A8=E6=88=B7=E4=BD=93?= =?UTF-8?q?=E9=AA=8C=E3=80=82=E6=96=B0=E5=A2=9E=E6=89=AB=E7=A0=81=E5=8A=9F?= =?UTF-8?q?=E8=83=BD=EF=BC=8C=E6=94=AF=E6=8C=81=E7=94=A8=E6=88=B7=E9=80=9A?= =?UTF-8?q?=E8=BF=87=E6=89=AB=E4=B8=80=E6=89=AB=E8=8E=B7=E5=8F=96=E4=BF=A1?= =?UTF-8?q?=E6=81=AF=E5=B9=B6=E5=B1=95=E7=A4=BA=E8=A7=A3=E6=9E=90=E7=BB=93?= =?UTF-8?q?=E6=9E=9C=EF=BC=8C=E6=8F=90=E5=8D=87=E4=BA=A4=E4=BA=92=E6=80=A7?= =?UTF-8?q?=E3=80=82=E6=9B=B4=E6=96=B0=E6=A0=B7=E5=BC=8F=E4=BB=A5=E9=80=82?= =?UTF-8?q?=E5=BA=94=E6=96=B0=E5=8A=9F=E8=83=BD=EF=BC=8C=E7=A1=AE=E4=BF=9D?= =?UTF-8?q?=E7=95=8C=E9=9D=A2=E5=8F=8B=E5=A5=BD=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- miniprogram/app.js | 56 +++++++++++++------------ miniprogram/pages/my/my.js | 53 +++++++++++++++++++++-- miniprogram/pages/my/my.wxml | 15 +++++++ miniprogram/pages/my/my.wxss | 25 +++++++++++ miniprogram/project.private.config.json | 46 +------------------- 5 files changed, 121 insertions(+), 74 deletions(-) diff --git a/miniprogram/app.js b/miniprogram/app.js index e02ba9fc..b903ce7b 100644 --- a/miniprogram/app.js +++ b/miniprogram/app.js @@ -240,36 +240,40 @@ App({ } }, - // 检查更新 + // 版本更新检测:发现新版本时提示用户立即更新 checkUpdate() { - if (wx.canIUse('getUpdateManager')) { - const updateManager = wx.getUpdateManager() - - updateManager.onCheckForUpdate((res) => { - if (res.hasUpdate) { - console.log('发现新版本') + if (!wx.canIUse('getUpdateManager')) return + const updateManager = wx.getUpdateManager() + + updateManager.onCheckForUpdate((res) => { + if (res.hasUpdate) { + console.log('[App] 发现新版本,正在后台下载') + wx.showToast({ title: '发现新版本,正在准备…', icon: 'none', duration: 2000 }) + } + }) + + updateManager.onUpdateReady(() => { + wx.showModal({ + title: '发现新版本', + content: '小程序已更新,请立即重启以使用最新版本。', + confirmText: '立即更新', + cancelText: '稍后', + showCancel: true, + success: (res) => { + if (res.confirm) { + updateManager.applyUpdate() + } } }) - - updateManager.onUpdateReady(() => { - wx.showModal({ - title: '更新提示', - content: '新版本已准备好,是否重启应用?', - success: (res) => { - if (res.confirm) { - updateManager.applyUpdate() - } - } - }) + }) + + updateManager.onUpdateFailed(() => { + wx.showModal({ + title: '更新失败', + content: '新版本下载失败,请稍后重新打开小程序或删除后重新搜索打开。', + showCancel: false }) - - updateManager.onUpdateFailed(() => { - wx.showToast({ - title: '更新失败,请稍后重试', - icon: 'none' - }) - }) - } + }) }, /** diff --git a/miniprogram/pages/my/my.js b/miniprogram/pages/my/my.js index a9d5916f..40ef6e66 100644 --- a/miniprogram/pages/my/my.js +++ b/miniprogram/pages/my/my.js @@ -40,6 +40,7 @@ Page({ // 菜单列表 menuList: [ + { id: 'scan', title: '扫一扫', icon: '📷', iconBg: 'gray' }, { id: 'orders', title: '我的订单', icon: '📦', count: 0 }, { id: 'referral', title: '推广中心', icon: '🎁', iconBg: 'gold', badge: '90%佣金' }, { id: 'withdrawRecords', title: '提现记录', icon: '📋', iconBg: 'gray' }, @@ -64,7 +65,11 @@ Page({ // 修改昵称弹窗 showNicknameModal: false, - editingNickname: '' + editingNickname: '', + + // 扫一扫结果弹窗 + showScanResultModal: false, + scanResult: '' }, onLoad() { @@ -608,12 +613,17 @@ Page({ // 点击菜单 handleMenuTap(e) { const id = e.currentTarget.dataset.id - + + if (id === 'scan') { + this.doScanCode() + return + } + if (!this.data.isLoggedIn && id !== 'about') { this.showLogin() return } - + const routes = { orders: '/pages/purchases/purchases', referral: '/pages/referral/referral', @@ -621,12 +631,47 @@ Page({ about: '/pages/about/about', settings: '/pages/settings/settings' } - + if (routes[id]) { wx.navigateTo({ url: routes[id] }) } }, + // 扫一扫:调起扫码,展示解析值 + doScanCode() { + wx.scanCode({ + onlyFromCamera: false, + scanType: ['qrCode', 'barCode'], + success: (res) => { + const result = res.result || '' + this.setData({ + showScanResultModal: true, + scanResult: result + }) + }, + fail: (err) => { + if (err.errMsg && !err.errMsg.includes('cancel')) { + wx.showToast({ title: '扫码失败', icon: 'none' }) + } + } + }) + }, + + // 关闭扫码结果弹窗 + closeScanResultModal() { + this.setData({ showScanResultModal: false, scanResult: '' }) + }, + + // 复制扫码结果 + copyScanResult() { + const text = this.data.scanResult || '' + if (!text) return + wx.setClipboardData({ + data: text, + success: () => wx.showToast({ title: '已复制', icon: 'success' }) + }) + }, + goToRead(e) { const id = e.currentTarget.dataset.id const mid = e.currentTarget.dataset.mid diff --git a/miniprogram/pages/my/my.wxml b/miniprogram/pages/my/my.wxml index d14323d8..9eb42a78 100644 --- a/miniprogram/pages/my/my.wxml +++ b/miniprogram/pages/my/my.wxml @@ -281,6 +281,21 @@ + + + + + + 扫码解析结果 + + {{scanResult}} + + 复制 + 关闭 + + + + diff --git a/miniprogram/pages/my/my.wxss b/miniprogram/pages/my/my.wxss index 2fe68b6d..611fbb78 100644 --- a/miniprogram/pages/my/my.wxss +++ b/miniprogram/pages/my/my.wxss @@ -1236,3 +1236,28 @@ background: linear-gradient(135deg, #4CAF50 0%, #388E3C 100%); color: #fff; font-size: 26rpx; font-weight: 500; border-radius: 20rpx; } + +/* ===== 扫一扫结果弹窗 ===== */ +.scan-result-modal .modal-close { top: 24rpx; right: 24rpx; } +.scan-result-header { margin-bottom: 24rpx; } +.scan-result-title { font-size: 32rpx; font-weight: 600; color: #fff; } +.scan-result-body { + max-height: 320rpx; + padding: 24rpx; + background: rgba(255,255,255,0.06); + border-radius: 16rpx; + margin-bottom: 24rpx; + word-break: break-all; +} +.scan-result-text { font-size: 26rpx; color: rgba(255,255,255,0.9); line-height: 1.5; } +.scan-result-actions { display: flex; gap: 24rpx; } +.scan-result-btn { + flex: 1; + padding: 24rpx; + text-align: center; + font-size: 28rpx; + color: rgba(255,255,255,0.9); + background: rgba(255,255,255,0.1); + border-radius: 24rpx; +} +.scan-result-btn.primary { background: #00CED1; color: #000; } diff --git a/miniprogram/project.private.config.json b/miniprogram/project.private.config.json index 072fabb7..20414ec5 100644 --- a/miniprogram/project.private.config.json +++ b/miniprogram/project.private.config.json @@ -24,51 +24,9 @@ "miniprogram": { "list": [ { - "name": "pages/addresses/addresses", - "pathName": "pages/addresses/addresses", + "name": "我的", + "pathName": "pages/my/my", "query": "", - "scene": null, - "launchMode": "default" - }, - { - "name": "pages/referral/referral", - "pathName": "pages/referral/referral", - "query": "", - "launchMode": "default", - "scene": null - }, - { - "name": "pages/read/read", - "pathName": "pages/read/read", - "query": "mid=11", - "launchMode": "default", - "scene": null - }, - { - "name": "pages/referral/referral", - "pathName": "pages/referral/referral", - "query": "", - "launchMode": "default", - "scene": null - }, - { - "name": "ces", - "pathName": "pages/read/read", - "query": "scene=mid%3D3&ref%3DogpTW5a9ex", - "launchMode": "default", - "scene": null - }, - { - "name": "pages/chapters/chapters", - "pathName": "pages/chapters/chapters", - "query": "", - "launchMode": "default", - "scene": null - }, - { - "name": "pages/read/read", - "pathName": "pages/read/read", - "query": "id=1.2", "launchMode": "default", "scene": null }