bug修复
This commit is contained in:
@@ -15,7 +15,7 @@
|
||||
</view>
|
||||
|
||||
<view class='user-info-card' @click.stop='goPath("/pages/mine/index")'>
|
||||
<image class='user-avatar' :src='userInfo.image||defaultAvatar' mode='aspectFill' />
|
||||
<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 || 0 }}</text>
|
||||
@@ -64,15 +64,19 @@
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
<CompanyDialog ref='companyDialogRef' :companyList='companyList' />
|
||||
</template>
|
||||
|
||||
<script setup lang='ts'>
|
||||
import CompanyDialog from '@/components/company-dialog.vue';
|
||||
import { getCompanyList } from '@/api/company';
|
||||
import { useUserStore } from '@/store';
|
||||
import { assetsUrl, defaultAvatar, defaultImage } from '@/utils/assets';
|
||||
import { getCompanyId, goPath, isLogin } from '@/utils';
|
||||
import { storeToRefs } from 'pinia';
|
||||
import { UserBean } from '@/store/modules/user/types';
|
||||
|
||||
const companyDialogRef = ref();
|
||||
const userStore = useUserStore();
|
||||
const { userInfo, companyConfigInfo } = storeToRefs(userStore);
|
||||
const currentBannerIndex = ref(0);
|
||||
@@ -94,6 +98,8 @@ const submenuList = [
|
||||
path: '/pages/home/subs/group/join'
|
||||
}
|
||||
];
|
||||
const companyList = ref([]);
|
||||
const userList = ref<UserBean[]>([]);
|
||||
|
||||
onMounted(() => {
|
||||
wx.getPrivacySetting({
|
||||
@@ -132,42 +138,30 @@ onShow(async () => {
|
||||
});
|
||||
|
||||
const switchCompany = () => {
|
||||
// getCompanyList(userInfo.value.maOpenId).then(res => {
|
||||
// const companyList = res.map((res: { company: any }) => res.company);
|
||||
// const userList = res.map((res: { user: any }) => res.user);
|
||||
// uni.showActionSheet({
|
||||
// itemList: companyList.map((res: { companyName: string }) => res.companyName),
|
||||
// success: (res) => {
|
||||
// userStore.setUserInfo(userList[res.tapIndex]);
|
||||
// userStore.setCompanyInfo(companyList[res.tapIndex]);
|
||||
// }
|
||||
// });
|
||||
// });
|
||||
fetchCompanyList((companyList: any[], userList: any[]) => {
|
||||
uni.showActionSheet({
|
||||
itemList: companyList.map((res: { companyName: string }) => res.companyName),
|
||||
success: (res) => {
|
||||
userStore.setUserInfo(userList[res.tapIndex]);
|
||||
userStore.setCompanyInfo(companyList[res.tapIndex]);
|
||||
}
|
||||
companyDialogRef.value.show((index: number) => {
|
||||
userStore.setUserInfo(userList[index]);
|
||||
userStore.setCompanyInfo(companyList[index]);
|
||||
});
|
||||
});
|
||||
};
|
||||
|
||||
const fetchCompanyList = (fn: any = undefined) => {
|
||||
getCompanyList(userInfo.value.maOpenId).then(res => {
|
||||
const companyList = res.map((res: { company: any }) => res.company);
|
||||
const userList = res.map((res: { user: any }) => res.user);
|
||||
const maOpenId = userInfo.value?.maOpenId || (userList.value.filter((res: UserBean) => res?.maOpenId !== '')[0]?.maOpenId);
|
||||
getCompanyList(maOpenId).then(res => {
|
||||
companyList.value = res.map((res: { company: any }) => res.company);
|
||||
userList.value = res.map((res: { user: any }) => res.user);
|
||||
if(fn != undefined && fn instanceof Function) {
|
||||
fn(companyList, userList);
|
||||
fn(companyList.value, userList.value);
|
||||
} else {
|
||||
let index = companyList.findIndex((res: { id: string }) => res.id === getCompanyId());
|
||||
let index = companyList.value.findIndex((res: { id: string }) => res.id === getCompanyId());
|
||||
if(index < 0) {
|
||||
index = 0;
|
||||
}
|
||||
userStore.setUserInfo(userList[index]);
|
||||
userStore.setCompanyInfo(companyList[index]);
|
||||
userStore.setUserInfo(userList.value[index]);
|
||||
userStore.setCompanyInfo(companyList.value[index]);
|
||||
}
|
||||
|
||||
// uni.showActionSheet({
|
||||
// itemList: companyList.map((res: { companyName: string }) => res.companyName),
|
||||
// success: (res) => {
|
||||
|
Reference in New Issue
Block a user