Browse Source

feat(用户中心): 添加未登录状态显示和登录检查功能

- 在用户中心页面添加未登录状态显示,包括登录提示和按钮
- 实现登录状态检查逻辑,根据token判断是否登录
- 调整页面内容显示逻辑,未登录时隐藏敏感信息
- 移除getGoodsList接口的auth配置
- 更新manifest.json中的appid
master
前端-胡立永 4 days ago
parent
commit
41f0eeebc8
3 changed files with 195 additions and 96 deletions
  1. +0
    -1
      api/api.js
  2. +1
    -1
      manifest.json
  3. +194
    -94
      pages/index/center.vue

+ 0
- 1
api/api.js View File

@ -362,7 +362,6 @@ const config = {
getGoodsList : {
url: '/token/getGoodsList',
method: 'GET',
auth : true,
},
// 查询我的店铺


+ 1
- 1
manifest.json View File

@ -1,6 +1,6 @@
{
"name" : "瑶都万能强",
"appid" : "__UNI__6A04410",
"appid" : "__UNI__197A38F",
"description" : "",
"versionName" : "1.0.0",
"versionCode" : "100",


+ 194
- 94
pages/index/center.vue View File

@ -2,113 +2,129 @@
<view class="page">
<view class="beijin">
<view class="profile">
<view class="o">
<view class="headImage">
<image
:src="userInfo.headImage"
mode="aspectFill"></image>
<!-- 未登录状态 -->
<view v-if="!isLogin" class="login-section">
<view class="avatar-placeholder">
<uv-icon name="account" size="80rpx" color="#ccc"></uv-icon>
</view>
<view class="login-info">
<view class="welcome-text">欢迎来到墙友社区</view>
<view class="login-desc">登录后享受更多功能</view>
<button class="login-btn" @click="$utils.toLogin">立即登录</button>
</view>
</view>
<!-- 已登录状态 -->
<view v-else>
<view class="o">
<view class="headImage">
<image
:src="userInfo.headImage"
mode="aspectFill"></image>
<view class="vip_info"
v-if="userInfo.isPay">
<view class="title">
{{ headInfo[vipList[userInfo.isPay - 1]].keyName }}
</view>
<!-- <view class="time">
2024-6-6到期
</view> -->
</view>
</view>
<view class="vip_info"
v-if="userInfo.isPay">
<!-- <view class="vip_info">
<view class="title">
{{ headInfo[vipList[userInfo.isPay - 1]].keyName }}
普通会员
</view>
<!-- <view class="time">
<view class="time">
2024-6-6到期
</view> -->
</view>
</view> -->
<view class="setUp"
@click="$utils.navigateTo('/pages_order/mine/setting')">
设置
</view>
</view>
<!-- <view class="vip_info">
<view class="title">
普通会员
<view class="account">
<view class="number">
{{ userInfo.nickName || '墙友1712378974678376' }}
</view>
<view class="time">
2024-6-6到期
<view class="gender">
<uv-icon
:name="sex[userInfo.sex].name"
size="34rpx"
:color="sex[userInfo.sex].color"></uv-icon>
</view>
</view> -->
<view class="setUp"
@click="$utils.navigateTo('/pages_order/mine/setting')">
设置
</view>
</view>
<view class="account">
<view class="number">
{{ userInfo.nickName || '墙友1712378974678376' }}
</view>
<view class="gender">
<uv-icon
:name="sex[userInfo.sex].name"
size="34rpx"
:color="sex[userInfo.sex].color"></uv-icon>
<view class="authentication">
{{ auth[userInfo.idCardOpen] || '未认证' }}
</view>
</view>
<view class="authentication">
{{ auth[userInfo.idCardOpen] || '未认证' }}
<view class="Days">
<!-- 你已经成为狐友133天啦~ -->
</view>
</view>
<view class="Days">
<!-- 你已经成为狐友133天啦~ -->
</view>
<view class="box">
<view class="fenst"
@click="$utils.navigateTo('/pages_order/mine/promotion')">
<view class="digit">
<uv-icon
size="40rpx"
color="#black"
name="grid"></uv-icon>
</view>
<view class="fans">
二维码
<view class="box">
<view class="fenst"
@click="$utils.navigateTo('/pages_order/mine/promotion')">
<view class="digit">
<uv-icon
size="40rpx"
color="#black"
name="grid"></uv-icon>
</view>
<view class="fans">
二维码
</view>
</view>
</view>
<view class="shut">
|
</view>
<view class="fenst"
@click="$utils.navigateTo('/pages_order/mine/fans')">
<view class="digit">
{{ userInfo.intentionNum }}
<view class="shut">
|
</view>
<view class="fans">
粉丝
<view class="fenst"
@click="$utils.navigateTo('/pages_order/mine/fans')">
<view class="digit">
{{ userInfo.intentionNum }}
</view>
<view class="fans">
粉丝
</view>
</view>
</view>
<view class="shut">
|
</view>
<view class="fenst"
@click="$utils.navigateTo('/pages_order/mine/runningWater?status=0')">
<view class="digit">
{{ userInfo.price }}
<view class="shut">
|
</view>
<view class="fans">
余额
<view class="fenst"
@click="$utils.navigateTo('/pages_order/mine/runningWater?status=0')">
<view class="digit">
{{ userInfo.price }}
</view>
<view class="fans">
余额
</view>
</view>
</view>
<view class="shut">
|
</view>
<view class="fenst"
@click="$utils.navigateTo('/pages_order/mine/runningWater?status=1')">
<view class="digit">
{{ userInfo.integerPrice }}
<view class="shut">
|
</view>
<view class="fans">
积分
<view class="fenst"
@click="$utils.navigateTo('/pages_order/mine/runningWater?status=1')">
<view class="digit">
{{ userInfo.integerPrice }}
</view>
<view class="fans">
积分
</view>
</view>
</view>
</view>
@ -116,7 +132,8 @@
</view>
</view>
<view class="Content">
<!-- 只有登录后才显示内容标签页 -->
<view v-if="isLogin" class="Content">
<uv-tabs :list="tabs" @click="click"
:activeStyle="{color : '#000', fontWeight : 900}"
lineColor="#5baaff"
@ -125,7 +142,7 @@
</view>
<!-- 我的帖子 -->
<view v-if="type == 0">
<view v-if="isLogin && type == 0">
<dynamicItemEdit
:key="index"
@click="$utils.navigateTo('/pages_order/post/addPost?id=' + item.id)"
@ -137,18 +154,28 @@
</view>
<!-- 我的店铺 -->
<view v-if="type == 3">
<view v-if="isLogin && type == 3">
<gourmetItem :key="index" v-for="(item, index) in list" :item="item"
@click="$utils.navigateTo('/pages_order/gourmet/gourmetDetail?id=' + item.id)" />
</view>
<!-- 未登录提示 -->
<view v-if="!isLogin" class="login-prompt">
<uv-empty
text="请先登录查看更多内容"
textSize="30rpx"
iconSize="200rpx"
icon="account">
</uv-empty>
</view>
<view class="no-data"
v-if="!tabs[type].show">
v-if="isLogin && !tabs[type].show">
暂未开放
</view>
<uv-empty
v-else-if="list.length == 0"
v-else-if="isLogin && list.length == 0"
text="空空如也"
textSize="30rpx"
iconSize="200rpx"
@ -194,7 +221,7 @@
},
],
vipList : ['vip', 'vipBig'],
mixinsListApi : 'getMyPostPage',
mixinsListApi : '',
apiList : [
'getMyPostPage',//
'',
@ -203,18 +230,42 @@
],
auth : ['审核中', '个人认证', '店铺认证'],
type : 0,
isLogin: false,
}
},
onShow() {
this.$store.commit('getUserInfo')
this.checkLoginStatus()
},
methods: {
//
checkLoginStatus() {
// token
const token = uni.getStorageSync('token')
if (token) {
this.mixinsListApi = 'getMyPostPage'
this.isLogin = true
this.$store.commit('getUserInfo')
} else {
this.isLogin = false
}
},
click({index}) {
if (!this.isLogin) {
this.showLoginTip()
return
}
this.type = index
this.mixinsListApi = this.apiList[index]
this.list = []
this.getData()
},
//
showLoginTip() {
uni.showToast({
title: '请先登录',
icon: 'none'
})
},
//
delDynamic(postId){
let self = this
@ -250,6 +301,51 @@
.profile {
padding: 40rpx;
padding-top: 160rpx;
//
.login-section {
display: flex;
flex-direction: column;
align-items: center;
padding: 40rpx 0;
.avatar-placeholder {
width: 100px;
height: 100px;
border-radius: 50%;
background: #f5f5f5;
display: flex;
align-items: center;
justify-content: center;
margin-bottom: 30rpx;
}
.login-info {
text-align: center;
.welcome-text {
font-size: 32rpx;
font-weight: bold;
margin-bottom: 10rpx;
}
.login-desc {
font-size: 24rpx;
color: #666;
margin-bottom: 40rpx;
}
.login-btn {
background: linear-gradient(45deg, #5baaff, #4a90e2);
color: white;
border: none;
border-radius: 50rpx;
padding: 20rpx 60rpx;
font-size: 28rpx;
font-weight: bold;
}
}
}
.box {
padding: 0rpx 10rpx;
@ -372,6 +468,10 @@
.Content {}
.login-prompt {
padding: 100rpx 0;
}
.no-data{
display: flex;
justify-content: center;


Loading…
Cancel
Save