优化我的页面未登录状态下的逻辑,新增首页未登录效果
This commit is contained in:
parent
37a46e0e28
commit
e5d2ea72ce
@ -9,10 +9,18 @@
|
||||
<!-- #endif -->
|
||||
<view class="my_info flex_a_c">
|
||||
<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 class="mesg_box">
|
||||
<view class="name">{{ myOaInfo.nickname }} {{ myOaInfo.mobile }}</view>
|
||||
<view v-if="!$store.state.app.token" @click="login" class="mesg_box">
|
||||
<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>
|
||||
</view>
|
||||
@ -101,7 +109,7 @@
|
||||
<script>
|
||||
import { Toast } from '@/libs/uniApi.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 { getIndexListAPI, getTaskListAPI, getMyTaskListAPI, getApproveListAPI, getUserIndexAPI } from '@/api/oaApi.js'
|
||||
export default {
|
||||
@ -157,6 +165,7 @@
|
||||
// this.getIndexList()
|
||||
this.getApproveList()
|
||||
this.initUserInfo()
|
||||
this.showToask()
|
||||
},
|
||||
computed: {},
|
||||
methods: {
|
||||
@ -173,7 +182,7 @@
|
||||
// })
|
||||
// },
|
||||
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() {
|
||||
const res = await noticeList({
|
||||
@ -216,9 +225,23 @@
|
||||
},
|
||||
// 点击公告
|
||||
clickNotice(e){
|
||||
uni.navigateTo({
|
||||
url: `/pages/oaNews/oaNews?id=${e}`
|
||||
})
|
||||
uni.navigateTo({
|
||||
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() {
|
||||
const res = await getUserIndexAPI()
|
||||
@ -259,6 +282,11 @@
|
||||
.mesg_box {
|
||||
color: #fff;
|
||||
margin-left: 31.58rpx;
|
||||
.nickname{
|
||||
font-size: 32rpx;
|
||||
font-weight: 500;
|
||||
margin-right: 30rpx;
|
||||
}
|
||||
|
||||
.duty {
|
||||
margin-top: 10.53rpx;
|
||||
|
@ -96,7 +96,6 @@
|
||||
return {
|
||||
myOaData: myOaData,
|
||||
src: 'https://cdn.uviewui.com/uview/album/1.jpg',
|
||||
oaUserInfo: {}
|
||||
}
|
||||
},
|
||||
onReady() {
|
||||
@ -112,6 +111,9 @@
|
||||
computed:{
|
||||
eyeType(){
|
||||
return this.$store.state.config.eyeType;
|
||||
},
|
||||
oaUserInfo(){
|
||||
return this.$store.state.app.userInfo||{avatar:''};
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
@ -127,6 +129,10 @@
|
||||
content:'确定要退出登录吗',
|
||||
success: (e) => {
|
||||
if(e.confirm){
|
||||
that.$store.commit('SET_USERINFO',{
|
||||
user: null,
|
||||
token: null
|
||||
})
|
||||
that.$store.commit('LOGOUT');
|
||||
uni.navigateTo({
|
||||
url:'/pages/oaLogin/oaLogin'
|
||||
@ -137,8 +143,7 @@
|
||||
},
|
||||
async getOaUserInfo() {
|
||||
const res = await userInfo();
|
||||
this.oaUserInfo = res.data;
|
||||
this.$store.commit('setUserInfo', this.oaUserInfo);
|
||||
this.$store.commit('setUserInfo', res.data);
|
||||
},
|
||||
naviTo(url) {
|
||||
url ?
|
||||
|
@ -10,7 +10,7 @@ const state = {
|
||||
const mutations = {
|
||||
setUserInfo(state, data) {
|
||||
state.userInfo = data
|
||||
uni.setStorageSync("USER_INFO", data)
|
||||
Cache.set("USER_INFO", data)
|
||||
},
|
||||
LOGOUT(state) {
|
||||
Cache.clear('USER_INFO')
|
||||
|
Loading…
x
Reference in New Issue
Block a user