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
}