initial commit

This commit is contained in:
Rajuahamedkst 2025-09-12 23:39:00 +08:00
parent 1d71a02738
commit a6f83a1317
2 changed files with 59 additions and 11 deletions

View file

@ -207,8 +207,17 @@ Page({
// Show menu // Show menu
showMenu: function() { showMenu: function() {
// Different menu options based on whether user is logged in or using test data
const menuItems = ['Save Image', 'Share QR Code', 'Refresh Data'];
if (this.data.isTestData) {
menuItems.push('Go to Login');
}
menuItems.push('Settings');
wx.showActionSheet({ wx.showActionSheet({
itemList: ['Save Image', 'Share QR Code', 'Refresh Data', 'Use Test Data', 'Settings'], itemList: menuItems,
success: (res) => { success: (res) => {
switch (res.tapIndex) { switch (res.tapIndex) {
case 0: case 0:
@ -221,20 +230,50 @@ Page({
this.refreshUserInfo(); this.refreshUserInfo();
break; break;
case 3: case 3:
this.forceTestData(); if (this.data.isTestData) {
this.goToLogin();
} else {
this.goToSettings();
}
break; break;
case 4: case 4:
wx.navigateTo({ if (!this.data.isTestData) {
url: '/pages/settings/settings' this.goToSettings();
}); }
break; break;
} }
} }
}); });
}, },
// Force test data (for debugging) // Navigate to login page
goToLogin: function() {
wx.navigateTo({
url: '/pages/login/login'
});
},
// Navigate to settings page
goToSettings: function() {
wx.navigateTo({
url: '/pages/settings/settings'
});
},
// Force test data (for debugging) - only works when not logged in
forceTestData: function() { forceTestData: function() {
// Check if user is actually logged in
const userInfo = wx.getStorageSync('userInfo');
if (userInfo && userInfo.user && userInfo.token) {
wx.showModal({
title: 'Cannot Use Test Data',
content: 'You are currently logged in. Please log out first to use test data.',
showCancel: false,
confirmText: 'OK'
});
return;
}
console.log('Forcing test data...'); console.log('Forcing test data...');
const testUserData = this.getTestUserData(); const testUserData = this.getTestUserData();
@ -264,7 +303,7 @@ Page({
qrCodeUrl: '' qrCodeUrl: ''
}); });
// Always start with test data, then try real data // Try to reload user info (will use real data if available, test data if not)
this.loadUserInfo(); this.loadUserInfo();
}, },

View file

@ -66,12 +66,14 @@
<view class="user-meta"> <view class="user-meta">
<text class="user-nickname">{{userInfo.user.nickname || 'No nickname'}}</text> <text class="user-nickname">{{userInfo.user.nickname || 'No nickname'}}</text>
<text class="user-custom-id">{{userInfo.user.customId || 'No custom ID'}}</text> <text class="user-custom-id">{{userInfo.user.customId || 'No custom ID'}}</text>
<!-- Test data indicator --> <!-- Test data indicator - only show when using test data -->
<text wx:if="{{isTestData}}" class="test-indicator">🧪 Test Data</text> <view wx:if="{{isTestData}}" class="test-data-warning">
<text class="test-indicator">🧪 Demo Mode - Please Log In</text>
<button class="login-btn" bindtap="goToLogin">Log In</button>
</view>
</view> </view>
</view> </view>
</view> </view>
<view class="action-buttons"> <view class="action-buttons">
<!-- 保存二维码按钮 --> <!-- 保存二维码按钮 -->
<view class="action-btn" bindtap="saveQRCode"> <view class="action-btn" bindtap="saveQRCode">
@ -89,4 +91,11 @@
<image class="action-icon" src="/images/share.svg" mode="aspectFit"></image> <image class="action-icon" src="/images/share.svg" mode="aspectFit"></image>
</view> </view>
</view> </view>
</view>
</view>