first commit

This commit is contained in:
chz
2026-01-15 15:05:29 +08:00
commit 0ec405e137
66 changed files with 8572 additions and 0 deletions
+116
View File
@@ -0,0 +1,116 @@
// pages/mine/index.js
const app = getApp();
const AuthUtil = require("../../utils/auth");
Page({
/**
* 页面的初始数据
*/
data: {
userInfo: {},
isLoggedIn: false,
},
/**
* 生命周期函数--监听页面加载
*/
onLoad(options) {},
/**
* 生命周期函数--监听页面初次渲染完成
*/
onReady() {},
/**
* 生命周期函数--监听页面显示
*/
onShow() {
// 每次页面显示时更新用户信息
this.updateUserInfo();
},
/**
* 生命周期函数--监听页面隐藏
*/
onHide() {},
/**
* 生命周期函数--监听页面卸载
*/
onUnload() {},
/**
* 页面相关事件处理函数--监听用户下拉动作
*/
onPullDownRefresh() {},
/**
* 页面上拉触底事件的处理函数
*/
onReachBottom() {},
/**
* 用户点击右上角分享
*/
onShareAppMessage() {},
/**
* 更新用户信息
*/
updateUserInfo() {
// 从认证工具获取用户信息
const userInfo = AuthUtil.getUserInfo();
const isLoggedIn = AuthUtil.hasToken() && app.globalData.isLoggedIn;
this.setData({
userInfo: userInfo || {},
isLoggedIn: isLoggedIn,
});
},
/**
* 跳转到编辑个人信息页面
*/
goToEditProfile() {
if (!this.data.isLoggedIn) {
wx.showToast({
title: '请先登录',
icon: 'none'
});
return;
}
wx.navigateTo({
url: '/pages/edit-profile/index'
});
},
/**
* 处理注销登录
*/
handleLogout() {
wx.showModal({
title: "确认注销",
content: "您确定要退出登录吗?",
success: (res) => {
if (res.confirm) {
// 使用认证工具清除登录状态
AuthUtil.clearAuth();
// 提示用户
wx.showToast({
title: "已注销登录",
icon: "success",
});
// 跳转到登录页
setTimeout(() => {
wx.reLaunch({
url: "/pages/login/index",
});
}, 1500);
}
},
});
},
});
+12
View File
@@ -0,0 +1,12 @@
{
"navigationBarBackgroundColor": "#0052d9",
"navigationBarTextStyle": "white",
"navigationBarTitleText": "我的",
"usingComponents": {
"t-avatar": "tdesign-miniprogram/avatar/avatar",
"t-button": "tdesign-miniprogram/button/button",
"t-cell": "tdesign-miniprogram/cell/cell",
"t-cell-group": "tdesign-miniprogram/cell-group/cell-group",
"t-message": "tdesign-miniprogram/message/message"
}
}
+29
View File
@@ -0,0 +1,29 @@
<!-- pages/mine/index.wxml -->
<view class="user-container">
<!-- 用户信息部分 -->
<view class="user-info" bindtap="goToEditProfile">
<t-avatar class="avatar" size="large" icon="user" image="{{userInfo.avatar || ''}}"></t-avatar>
<view class="user-detail">
<view class="username">{{userInfo.nickname || '未登录'}}</view>
<view class="user-id">@{{userInfo.username || ''}}</view>
<view class="user-role">{{userInfo.user_status === 1 ? '用户' : (userInfo.user_status === 2 ? '管理员' : '待审核')}}</view>
</view>
<view class="edit-icon" wx:if="{{isLoggedIn}}">
<t-icon name="edit" size="36rpx" color="#0052d9" />
</view>
</view>
<!-- 功能列表 -->
<view class="function-list">
<t-cell-group>
<t-cell title="个人信息" hover left-icon="user" bindtap="goToEditProfile" arrow />
<t-cell title="系统设置" hover left-icon="setting" url="" arrow />
<t-cell title="关于我们" hover left-icon="info-circle" url="" arrow />
</t-cell-group>
</view>
<!-- 注销按钮 -->
<view class="logout-container" wx:if="{{isLoggedIn}}">
<t-button theme="danger" block size="large" bind:tap="handleLogout">注销登录</t-button>
</view>
</view>
+60
View File
@@ -0,0 +1,60 @@
/* pages/mine/index.wxss */
.user-container {
display: flex;
flex-direction: column;
min-height: 100vh;
background-color: #f6f6f6;
}
.user-info {
display: flex;
align-items: center;
padding: 40rpx 30rpx;
background-color: #0052d9;
color: #fff;
position: relative;
cursor: pointer;
}
.avatar {
margin-right: 30rpx;
background-color: #fff;
}
.user-detail {
flex: 1;
}
.username {
font-size: 36rpx;
font-weight: bold;
margin-bottom: 5rpx;
}
.user-id {
font-size: 24rpx;
opacity: 0.7;
margin-bottom: 8rpx;
}
.user-role {
font-size: 28rpx;
opacity: 0.8;
}
.edit-icon {
padding: 10rpx;
background-color: rgba(255, 255, 255, 0.2);
border-radius: 50%;
display: flex;
align-items: center;
justify-content: center;
}
.function-list {
margin-top: 30rpx;
}
.logout-container {
margin: 60rpx 30rpx;
}