优化我的页面未登录状态下的逻辑,新增首页未登录效果

This commit is contained in:
weipengfei 2023-07-21 17:45:27 +08:00
parent 37a46e0e28
commit e5d2ea72ce
3 changed files with 45 additions and 12 deletions

View File

@ -9,10 +9,18 @@
<!-- #endif --> <!-- #endif -->
<view class="my_info flex_a_c"> <view class="my_info flex_a_c">
<view class=""> <view class="">
<u--image :showLoading="true" :src="myOaInfo.avatar||'../../static/img/public/man.png'" width="112.28rpx" height="112.28rpx" shape="circle"></u--image> <u--image :showLoading="true" :src="myOaInfo.avatar||'../../static/img/public/avatar.png'" width="112.28rpx" height="112.28rpx" shape="circle"></u--image>
</view> </view>
<view class="mesg_box"> <view v-if="!$store.state.app.token" @click="login" class="mesg_box">
<view class="name">{{ myOaInfo.nickname }} {{ myOaInfo.mobile }}</view> <view class="name">
<text class="nickname">立即登录</text>
</view>
<view class="duty">
登录后可查看更多
</view>
</view>
<view v-else class="mesg_box">
<view class="name"><text class="nickname">{{ myOaInfo.nickname }}</text> {{ myOaInfo.mobile }}</view>
<view class="duty">({{ myOaInfo.did_name }}){{myOaInfo.label_name}}</view> <view class="duty">({{ myOaInfo.did_name }}){{myOaInfo.label_name}}</view>
</view> </view>
</view> </view>
@ -101,7 +109,7 @@
<script> <script>
import { Toast } from '@/libs/uniApi.js' import { Toast } from '@/libs/uniApi.js'
import { oaHomeData } from '@/static/server/server.js' import { oaHomeData } from '@/static/server/server.js'
import {noticeList} from "@/api/notice.js" import { noticeList } from "@/api/notice.js"
// import tabbar from '../components/tabbar' // import tabbar from '../components/tabbar'
import { getIndexListAPI, getTaskListAPI, getMyTaskListAPI, getApproveListAPI, getUserIndexAPI } from '@/api/oaApi.js' import { getIndexListAPI, getTaskListAPI, getMyTaskListAPI, getApproveListAPI, getUserIndexAPI } from '@/api/oaApi.js'
export default { export default {
@ -157,6 +165,7 @@
// this.getIndexList() // this.getIndexList()
this.getApproveList() this.getApproveList()
this.initUserInfo() this.initUserInfo()
this.showToask()
}, },
computed: {}, computed: {},
methods: { methods: {
@ -173,7 +182,7 @@
// }) // })
// }, // },
initUserInfo(){ initUserInfo(){
this.$store.state.app.userInfo ? this.myOaInfo = this.$store.state.app.userInfo : null; this.$store.state.app.userInfo ? this.myOaInfo = this.$store.state.app.userInfo : this.myOaInfo.avatar = '';
}, },
async getApproveList() { async getApproveList() {
const res = await noticeList({ const res = await noticeList({
@ -216,9 +225,23 @@
}, },
// //
clickNotice(e){ clickNotice(e){
uni.navigateTo({ uni.navigateTo({
url: `/pages/oaNews/oaNews?id=${e}` url: `/pages/oaNews/oaNews?id=${e}`
}) })
},
// ,
showToask(){
if(!this.$store.state.app.token){
this.assessData = this.assessData.map(item=>{
item.num = '*';
return item;
})
}
},
login() {
uni.navigateTo({
url:'/pages/oaLogin/oaLogin'
})
}, },
async getUserIndex() { async getUserIndex() {
const res = await getUserIndexAPI() const res = await getUserIndexAPI()
@ -259,6 +282,11 @@
.mesg_box { .mesg_box {
color: #fff; color: #fff;
margin-left: 31.58rpx; margin-left: 31.58rpx;
.nickname{
font-size: 32rpx;
font-weight: 500;
margin-right: 30rpx;
}
.duty { .duty {
margin-top: 10.53rpx; margin-top: 10.53rpx;

View File

@ -96,7 +96,6 @@
return { return {
myOaData: myOaData, myOaData: myOaData,
src: 'https://cdn.uviewui.com/uview/album/1.jpg', src: 'https://cdn.uviewui.com/uview/album/1.jpg',
oaUserInfo: {}
} }
}, },
onReady() { onReady() {
@ -112,6 +111,9 @@
computed:{ computed:{
eyeType(){ eyeType(){
return this.$store.state.config.eyeType; return this.$store.state.config.eyeType;
},
oaUserInfo(){
return this.$store.state.app.userInfo||{avatar:''};
} }
}, },
methods: { methods: {
@ -127,6 +129,10 @@
content:'确定要退出登录吗', content:'确定要退出登录吗',
success: (e) => { success: (e) => {
if(e.confirm){ if(e.confirm){
that.$store.commit('SET_USERINFO',{
user: null,
token: null
})
that.$store.commit('LOGOUT'); that.$store.commit('LOGOUT');
uni.navigateTo({ uni.navigateTo({
url:'/pages/oaLogin/oaLogin' url:'/pages/oaLogin/oaLogin'
@ -137,8 +143,7 @@
}, },
async getOaUserInfo() { async getOaUserInfo() {
const res = await userInfo(); const res = await userInfo();
this.oaUserInfo = res.data; this.$store.commit('setUserInfo', res.data);
this.$store.commit('setUserInfo', this.oaUserInfo);
}, },
naviTo(url) { naviTo(url) {
url ? url ?

View File

@ -10,7 +10,7 @@ const state = {
const mutations = { const mutations = {
setUserInfo(state, data) { setUserInfo(state, data) {
state.userInfo = data state.userInfo = data
uni.setStorageSync("USER_INFO", data) Cache.set("USER_INFO", data)
}, },
LOGOUT(state) { LOGOUT(state) {
Cache.clear('USER_INFO') Cache.clear('USER_INFO')