This commit is contained in:
2025-12-05 15:41:32 +08:00
commit 7339c71fc0
1433 changed files with 37574 additions and 0 deletions

97
pages/mine/mine.js Normal file
View File

@@ -0,0 +1,97 @@
// pages/mine/mine.js
const app = getApp();
Page({
data: {
userInfo: null,
isLogin: false,
menuList: [
{ id: 'favorite', icon: 'star-o', title: '我的收藏', url: '/pages/favorite/favorite' },
{ id: 'history', icon: 'underway-o', title: '浏览历史', url: '/pages/history/history' },
{ id: 'feedback', icon: 'comment-o', title: '意见反馈', url: '/pages/feedback/feedback' },
{ id: 'about', icon: 'info-o', title: '关于我们', url: '/pages/about/about' },
{ id: 'setting', icon: 'setting-o', title: '设置', url: '/pages/setting/setting' }
]
},
onLoad() {
this.checkLoginStatus();
},
onShow() {
this.checkLoginStatus();
// 初始化 TabBar 选中状态
if (typeof this.getTabBar === 'function' && this.getTabBar()) {
this.getTabBar().init();
}
},
// 检查登录状态
checkLoginStatus() {
const isLogin = app.checkLogin();
const userInfo = app.globalData.userInfo;
this.setData({ isLogin, userInfo });
},
// 获取用户信息(微信登录)
onGetUserInfo() {
wx.getUserProfile({
desc: '用于完善用户资料',
success: (res) => {
const userInfo = res.userInfo;
app.globalData.userInfo = userInfo;
this.setData({ userInfo, isLogin: true });
// 模拟设置token
app.setToken('mock_token_' + Date.now());
wx.showToast({
title: '登录成功',
icon: 'success'
});
},
fail: () => {
wx.showToast({
title: '已取消授权',
icon: 'none'
});
}
});
},
// 点击菜单项
onMenuTap(e) {
const { url, id } = e.currentTarget.dataset;
// 某些功能需要登录
if (['favorite', 'history'].includes(id) && !this.data.isLogin) {
wx.showToast({
title: '请先登录',
icon: 'none'
});
return;
}
wx.navigateTo({ url });
},
// 退出登录
onLogout() {
wx.showModal({
title: '提示',
content: '确定要退出登录吗?',
success: (res) => {
if (res.confirm) {
app.clearToken();
app.globalData.userInfo = null;
this.setData({ isLogin: false, userInfo: null });
wx.showToast({
title: '已退出登录',
icon: 'success'
});
}
}
});
}
});

4
pages/mine/mine.json Normal file
View File

@@ -0,0 +1,4 @@
{
"navigationBarTitleText": "我的",
"usingComponents": {}
}

74
pages/mine/mine.wxml Normal file
View File

@@ -0,0 +1,74 @@
<!--pages/mine/mine.wxml-->
<view class="container">
<!-- 用户信息区域 -->
<view class="user-section">
<view class="user-info" wx:if="{{ isLogin && userInfo }}">
<van-image
class="user-avatar"
round
width="120rpx"
height="120rpx"
src="{{ userInfo.avatarUrl }}"
/>
<view class="user-detail">
<text class="user-name">{{ userInfo.nickName }}</text>
<text class="user-desc">欢迎使用信息服务</text>
</view>
</view>
<view class="login-section" wx:else>
<van-image
class="default-avatar"
round
width="120rpx"
height="120rpx"
src="/assets/images/default-avatar.png"
/>
<view class="login-info">
<text class="login-hint">登录后享受更多服务</text>
<van-button
type="primary"
size="small"
round
bindtap="onGetUserInfo"
>
立即登录
</van-button>
</view>
</view>
</view>
<!-- 功能菜单 -->
<view class="menu-section">
<van-cell-group>
<van-cell
wx:for="{{ menuList }}"
wx:key="id"
title="{{ item.title }}"
is-link
data-id="{{ item.id }}"
data-url="{{ item.url }}"
bindtap="onMenuTap"
>
<van-icon slot="icon" name="{{ item.icon }}" size="40rpx" color="#1890ff" style="margin-right: 20rpx;" />
</van-cell>
</van-cell-group>
</view>
<!-- 退出登录 -->
<view class="logout-section" wx:if="{{ isLogin }}">
<van-button
type="default"
block
round
bindtap="onLogout"
>
退出登录
</van-button>
</view>
<!-- 版本信息 -->
<view class="version-info">
<text>版本 1.0.0</text>
</view>
</view>

83
pages/mine/mine.wxss Normal file
View File

@@ -0,0 +1,83 @@
/* pages/mine/mine.wxss */
.container {
min-height: 100vh;
background-color: #f5f5f5;
}
/* 用户信息区域 */
.user-section {
background: linear-gradient(135deg, #1890ff 0%, #36cfc9 100%);
padding: 60rpx 30rpx;
margin-bottom: 20rpx;
}
.user-info {
display: flex;
align-items: center;
}
.user-avatar {
margin-right: 30rpx;
}
.user-detail {
display: flex;
flex-direction: column;
}
.user-name {
font-size: 36rpx;
font-weight: bold;
color: #fff;
margin-bottom: 10rpx;
}
.user-desc {
font-size: 26rpx;
color: rgba(255, 255, 255, 0.8);
}
/* 未登录状态 */
.login-section {
display: flex;
align-items: center;
}
.default-avatar {
margin-right: 30rpx;
background-color: rgba(255, 255, 255, 0.3);
border-radius: 50%;
}
.login-info {
display: flex;
flex-direction: column;
align-items: flex-start;
}
.login-hint {
font-size: 28rpx;
color: rgba(255, 255, 255, 0.9);
margin-bottom: 16rpx;
}
/* 菜单区域 */
.menu-section {
margin: 20rpx;
border-radius: 16rpx;
overflow: hidden;
}
/* 退出登录 */
.logout-section {
margin: 40rpx 30rpx;
}
/* 版本信息 */
.version-info {
text-align: center;
padding: 40rpx;
color: #999;
font-size: 24rpx;
}