优化小程序版本更新检测逻辑,增强用户体验。新增扫码功能,支持用户通过扫一扫获取信息并展示解析结果,提升交互性。更新样式以适应新功能,确保界面友好。
This commit is contained in:
@@ -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
|
||||
|
||||
@@ -281,6 +281,21 @@
|
||||
</view>
|
||||
</view>
|
||||
|
||||
<!-- 扫一扫结果弹窗 -->
|
||||
<view class="modal-overlay" wx:if="{{showScanResultModal}}" bindtap="closeScanResultModal">
|
||||
<view class="modal-content scan-result-modal" catchtap="stopPropagation">
|
||||
<view class="modal-close" bindtap="closeScanResultModal">✕</view>
|
||||
<view class="scan-result-header">
|
||||
<text class="scan-result-title">扫码解析结果</text>
|
||||
</view>
|
||||
<scroll-view class="scan-result-body" scroll-y><text class="scan-result-text">{{scanResult}}</text></scroll-view>
|
||||
<view class="scan-result-actions">
|
||||
<view class="scan-result-btn" bindtap="copyScanResult">复制</view>
|
||||
<view class="scan-result-btn primary" bindtap="closeScanResultModal">关闭</view>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
|
||||
<!-- 底部留白 -->
|
||||
<view class="bottom-space"></view>
|
||||
</view>
|
||||
|
||||
@@ -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; }
|
||||
|
||||
Reference in New Issue
Block a user