mirror of
https://gitee.com/qingqing-coconut-tea/RcKtFezyRAZX
synced 2026-07-21 10:32:32 +08:00
init
This commit is contained in:
106
wechat/pages/user/user.js
Normal file
106
wechat/pages/user/user.js
Normal file
@@ -0,0 +1,106 @@
|
||||
// pages/user/user.js
|
||||
// 用户中心逻辑处理
|
||||
|
||||
const app = getApp()
|
||||
|
||||
Page({
|
||||
data: {
|
||||
userInfo: null,
|
||||
hasLogin: false,
|
||||
menuList: [
|
||||
{ id: 1, name: '我的文章', icon: 'icon-article', url: '/pages/my-article/my-article' },
|
||||
{ id: 2, name: '我的收藏', icon: 'icon-favorite', url: '/pages/my-favorite/my-favorite' },
|
||||
{ id: 3, name: '我的评论', icon: 'icon-comment', url: '/pages/my-comment/my-comment' },
|
||||
{ id: 4, name: '浏览历史', icon: 'icon-history', url: '/pages/history/history' },
|
||||
{ id: 5, name: '消息通知', icon: 'icon-notification', url: '/pages/notification/notification' },
|
||||
{ id: 6, name: '意见反馈', icon: 'icon-feedback', url: '/pages/feedback/feedback' },
|
||||
{ id: 7, name: '系统设置', icon: 'icon-settings', url: '/pages/settings/settings' }
|
||||
],
|
||||
stats: {
|
||||
articleCount: 12,
|
||||
favoriteCount: 45,
|
||||
commentCount: 128
|
||||
}
|
||||
},
|
||||
|
||||
onLoad() {
|
||||
this.checkLoginStatus()
|
||||
},
|
||||
|
||||
onShow() {
|
||||
this.checkLoginStatus()
|
||||
},
|
||||
|
||||
// 检查登录状态
|
||||
checkLoginStatus() {
|
||||
const userInfo = wx.getStorageSync('userInfo')
|
||||
this.setData({
|
||||
userInfo: userInfo,
|
||||
hasLogin: !!userInfo
|
||||
})
|
||||
},
|
||||
|
||||
// 跳转到登录页面
|
||||
goToLogin() {
|
||||
wx.navigateTo({
|
||||
url: '/pages/login/login'
|
||||
})
|
||||
},
|
||||
|
||||
// 跳转到用户信息编辑页面
|
||||
goToProfile() {
|
||||
if (!this.data.hasLogin) {
|
||||
this.goToLogin()
|
||||
return
|
||||
}
|
||||
wx.navigateTo({
|
||||
url: '/pages/profile/profile'
|
||||
})
|
||||
},
|
||||
|
||||
// 跳转到菜单页面
|
||||
goToMenu(e) {
|
||||
const url = e.currentTarget.dataset.url
|
||||
if (!this.data.hasLogin && url !== '/pages/settings/settings') {
|
||||
this.goToLogin()
|
||||
return
|
||||
}
|
||||
wx.navigateTo({ url })
|
||||
},
|
||||
|
||||
// 退出登录
|
||||
handleLogout() {
|
||||
wx.showModal({
|
||||
title: '提示',
|
||||
content: '确定要退出登录吗?',
|
||||
success: (res) => {
|
||||
if (res.confirm) {
|
||||
wx.removeStorageSync('userInfo')
|
||||
wx.removeStorageSync('token')
|
||||
this.setData({
|
||||
userInfo: null,
|
||||
hasLogin: false
|
||||
})
|
||||
wx.showToast({
|
||||
title: '已退出登录',
|
||||
icon: 'success'
|
||||
})
|
||||
}
|
||||
}
|
||||
})
|
||||
},
|
||||
|
||||
// 预览图片
|
||||
previewAvatar() {
|
||||
if (!this.data.userInfo || !this.data.userInfo.avatar) return
|
||||
wx.previewImage({
|
||||
urls: [this.data.userInfo.avatar]
|
||||
})
|
||||
}
|
||||
})
|
||||
|
||||
/**
|
||||
* @联系作者:16768118056
|
||||
* @描述:(此项目非免费分享)源码百分百可用,搞定毕设不发愁,支持远程调试安装、二次开发、定制、讲解、文档类。
|
||||
* @访问:https://www.notmaker.com/detail/8326a897119d4542896c863a69d7bbe7/gtt20260415,查看完整运行演示。
|
||||
*/
|
||||
10
wechat/pages/user/user.json
Normal file
10
wechat/pages/user/user.json
Normal file
@@ -0,0 +1,10 @@
|
||||
{
|
||||
"usingComponents": {},
|
||||
"navigationBarTitleText": "我的"
|
||||
}
|
||||
|
||||
/**
|
||||
* @联系作者:16768118056
|
||||
* @描述:(此项目非免费分享)源码百分百可用,搞定毕设不发愁,支持远程调试安装、二次开发、定制、讲解、文档类。
|
||||
* @访问:https://www.notmaker.com/detail/8326a897119d4542896c863a69d7bbe7/gtt20260415,查看完整运行演示。
|
||||
*/
|
||||
52
wechat/pages/user/user.wxml
Normal file
52
wechat/pages/user/user.wxml
Normal file
@@ -0,0 +1,52 @@
|
||||
<!-- pages/user/user.wxml -->
|
||||
<!-- 用户中心视图 -->
|
||||
|
||||
<view class="user-container">
|
||||
<!-- 用户信息卡片 -->
|
||||
<view class="user-card">
|
||||
<view class="user-info" bindtap="goToProfile">
|
||||
<image class="avatar" src="{{userInfo ? userInfo.avatar : '/static/images/default-avatar.png'}}" bindtap="previewAvatar" />
|
||||
<view class="info-text">
|
||||
<text class="nickname">{{hasLogin ? userInfo.nickname : '点击登录'}}</text>
|
||||
<text class="user-id" wx:if="{{hasLogin}}">ID: {{userInfo.id}}</text>
|
||||
</view>
|
||||
<text class="arrow">></text>
|
||||
</view>
|
||||
<view class="user-stats" wx:if="{{hasLogin}}">
|
||||
<view class="stat-item">
|
||||
<text class="stat-value">{{stats.articleCount}}</text>
|
||||
<text class="stat-label">文章</text>
|
||||
</view>
|
||||
<view class="stat-item">
|
||||
<text class="stat-value">{{stats.favoriteCount}}</text>
|
||||
<text class="stat-label">收藏</text>
|
||||
</view>
|
||||
<view class="stat-item">
|
||||
<text class="stat-value">{{stats.commentCount}}</text>
|
||||
<text class="stat-label">评论</text>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
|
||||
<!-- 菜单列表 -->
|
||||
<view class="menu-list">
|
||||
<block wx:for="{{menuList}}" wx:key="id">
|
||||
<view class="menu-item" bindtap="goToMenu" data-url="{{item.url}}">
|
||||
<view class="menu-left">
|
||||
<text class="iconfont {{item.icon}} menu-icon"></text>
|
||||
<text class="menu-name">{{item.name}}</text>
|
||||
</view>
|
||||
<text class="arrow">></text>
|
||||
</view>
|
||||
</block>
|
||||
</view>
|
||||
|
||||
<!-- 退出登录按钮 -->
|
||||
<button class="logout-btn" wx:if="{{hasLogin}}" bindtap="handleLogout">退出登录</button>
|
||||
</view>
|
||||
|
||||
/**
|
||||
* @联系作者:16768118056
|
||||
* @描述:(此项目非免费分享)源码百分百可用,搞定毕设不发愁,支持远程调试安装、二次开发、定制、讲解、文档类。
|
||||
* @访问:https://www.notmaker.com/detail/8326a897119d4542896c863a69d7bbe7/gtt20260415,查看完整运行演示。
|
||||
*/
|
||||
118
wechat/pages/user/user.wxss
Normal file
118
wechat/pages/user/user.wxss
Normal file
@@ -0,0 +1,118 @@
|
||||
/* pages/user/user.wxss */
|
||||
/* 用户中心样式 */
|
||||
|
||||
.user-container {
|
||||
min-height: 100vh;
|
||||
background-color: #f5f5f5;
|
||||
}
|
||||
|
||||
.user-card {
|
||||
background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
|
||||
padding: 60rpx 30rpx 40rpx;
|
||||
color: #fff;
|
||||
}
|
||||
|
||||
.user-info {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
}
|
||||
|
||||
.avatar {
|
||||
width: 120rpx;
|
||||
height: 120rpx;
|
||||
border-radius: 60rpx;
|
||||
border: 4rpx solid rgba(255, 255, 255, 0.3);
|
||||
margin-right: 30rpx;
|
||||
}
|
||||
|
||||
.info-text {
|
||||
flex: 1;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
}
|
||||
|
||||
.nickname {
|
||||
font-size: 36rpx;
|
||||
font-weight: bold;
|
||||
margin-bottom: 10rpx;
|
||||
}
|
||||
|
||||
.user-id {
|
||||
font-size: 24rpx;
|
||||
opacity: 0.8;
|
||||
}
|
||||
|
||||
.arrow {
|
||||
font-size: 32rpx;
|
||||
opacity: 0.6;
|
||||
}
|
||||
|
||||
.user-stats {
|
||||
display: flex;
|
||||
margin-top: 50rpx;
|
||||
}
|
||||
|
||||
.stat-item {
|
||||
flex: 1;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
align-items: center;
|
||||
}
|
||||
|
||||
.stat-value {
|
||||
font-size: 36rpx;
|
||||
font-weight: bold;
|
||||
margin-bottom: 10rpx;
|
||||
}
|
||||
|
||||
.stat-label {
|
||||
font-size: 24rpx;
|
||||
opacity: 0.8;
|
||||
}
|
||||
|
||||
.menu-list {
|
||||
background-color: #fff;
|
||||
margin-top: 20rpx;
|
||||
}
|
||||
|
||||
.menu-item {
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
align-items: center;
|
||||
padding: 30rpx;
|
||||
border-bottom: 1rpx solid #f0f0f0;
|
||||
}
|
||||
|
||||
.menu-item:last-child {
|
||||
border-bottom: none;
|
||||
}
|
||||
|
||||
.menu-left {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
}
|
||||
|
||||
.menu-icon {
|
||||
font-size: 40rpx;
|
||||
color: #409EFF;
|
||||
margin-right: 20rpx;
|
||||
}
|
||||
|
||||
.menu-name {
|
||||
font-size: 28rpx;
|
||||
color: #303133;
|
||||
}
|
||||
|
||||
.logout-btn {
|
||||
margin: 60rpx 30rpx;
|
||||
background-color: #fff;
|
||||
color: #F56C6C;
|
||||
border-radius: 8rpx;
|
||||
font-size: 28rpx;
|
||||
}
|
||||
|
||||
/**
|
||||
* @联系作者:16768118056
|
||||
* @描述:(此项目非免费分享)源码百分百可用,搞定毕设不发愁,支持远程调试安装、二次开发、定制、讲解、文档类。
|
||||
* @访问:https://www.notmaker.com/detail/8326a897119d4542896c863a69d7bbe7/gtt20260415,查看完整运行演示。
|
||||
*/
|
||||
Reference in New Issue
Block a user