处理未登录情况
This commit is contained in:
@@ -14,16 +14,16 @@
|
||||
</view>
|
||||
</view>
|
||||
|
||||
<view class='user-info-card'>
|
||||
<image class='user-avatar' :src='userInfo.image' mode='aspectFill' />
|
||||
<text class='user-name primary-text-color'>{{ userInfo?.nickName }}</text>
|
||||
<view class='user-info-card' @click.stop='goPath("/pages/mine/index")'>
|
||||
<image class='user-avatar' :src='userInfo.image||defaultAvatar' mode='aspectFill' />
|
||||
<text class='user-name primary-text-color'>{{ userInfo?.nickName || '未登录' }}</text>
|
||||
<view class='integral-view primary-text-color' @click.stop='goPath("/pages/mine/subs/integral/index")'>
|
||||
<text>{{ userInfo?.integration }}</text>
|
||||
<text>{{ userInfo?.integration || 0 }}</text>
|
||||
<text>积分</text>
|
||||
</view>
|
||||
<view class='divider' style='height: 83rpx' />
|
||||
<view class='balance-view' @click.stop='goPath("/pages/mine/subs/recharge/index")'>
|
||||
<text class='accent-text-color'>{{ userInfo?.balance }}</text>
|
||||
<text class='accent-text-color'>{{ userInfo?.balance || 0 }}</text>
|
||||
<text>余额(元)</text>
|
||||
</view>
|
||||
</view>
|
||||
@@ -65,12 +65,12 @@
|
||||
<script setup lang='ts'>
|
||||
import { getCompanyInfo, getCompanyList } from '@/api/company';
|
||||
import { useUserStore } from '@/store';
|
||||
import { assetsUrl } from '@/utils/assets';
|
||||
import { assetsUrl, defaultAvatar } from '@/utils/assets';
|
||||
import { getCompanyId, goPath, isLogin, setCompanyId } from '@/utils';
|
||||
import { storeToRefs } from 'pinia';
|
||||
|
||||
const store = useUserStore();
|
||||
const { userInfo } = storeToRefs(store);
|
||||
const userStore = useUserStore();
|
||||
const { userInfo } = storeToRefs(userStore);
|
||||
const bannerList = ref<string[]>([]);
|
||||
const currentBannerIndex = ref(0);
|
||||
const recommendBannerList = ref<string[]>([]);
|
||||
@@ -103,19 +103,24 @@ onShow(async () => {
|
||||
bannerList.value = data.bannerinx?.map((res: { src: string }) => res.src);
|
||||
recommendBannerList.value = data.bannerhot?.map((res: { src: string }) => res.src);
|
||||
|
||||
getCompanyList(userInfo.value.maOpenId).then(res => {
|
||||
const companyList = res.map((res: { company: any }) => res.company);
|
||||
const userList = res.map((res: { user: any }) => res.user);
|
||||
// if(!getCompanyId()) {
|
||||
uni.showActionSheet({
|
||||
itemList: companyList.map((res: { companyName: string }) => res.companyName),
|
||||
success: (res) => {
|
||||
setCompanyId(companyList[res.tapIndex].id);
|
||||
store.setUserInfo(userList[res.tapIndex]);
|
||||
}
|
||||
});
|
||||
// }
|
||||
});
|
||||
if(userInfo.value.maOpenId) {
|
||||
getCompanyList(userInfo.value.maOpenId).then(res => {
|
||||
const companyList = res.map((res: { company: any }) => res.company);
|
||||
const userList = res.map((res: { user: any }) => res.user);
|
||||
if(!getCompanyId()) {
|
||||
uni.showActionSheet({
|
||||
itemList: companyList.map((res: { companyName: string }) => res.companyName),
|
||||
success: (res) => {
|
||||
setCompanyId(companyList[res.tapIndex].id);
|
||||
userStore.setUserInfo(userList[res.tapIndex]);
|
||||
userStore.fetchTerminal();
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
} else {
|
||||
await userStore.getProfile();
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
|
Reference in New Issue
Block a user