bug修复
This commit is contained in:
parent
6cd0361f33
commit
448ee810de
44
src/App.vue
44
src/App.vue
@ -1,7 +1,7 @@
|
||||
<script setup lang='ts'>
|
||||
import { mpUpdate, setCompanyId, setReferrerUserId, setRegisterStoreId } from '@/utils';
|
||||
|
||||
onLaunch((options) => {
|
||||
onLaunch(async (options) => {
|
||||
console.log('App Launch options ', options);
|
||||
|
||||
const miniProgram = uni.getAccountInfoSync().miniProgram;
|
||||
@ -9,19 +9,31 @@ onLaunch((options) => {
|
||||
|
||||
//生产
|
||||
if(env === 'release' || env === 'trial') {
|
||||
uni.request({
|
||||
url: 'https://api.lakeapp.cn/wechat/version_info',
|
||||
success(res) {
|
||||
console.log(res);
|
||||
async function getVersionStatus() {
|
||||
return new Promise((resolve, reject) => {
|
||||
uni.request({
|
||||
url: 'https://api.lakeapp.cn/wechat/version_info',
|
||||
success(res) {
|
||||
console.log(res);
|
||||
resolve(res);
|
||||
},
|
||||
fail(exception) {
|
||||
reject(exception);
|
||||
}
|
||||
});
|
||||
}).then((res) => {
|
||||
const { version, audit } = res.data;
|
||||
// if(miniProgram.version === version && audit == 1) {
|
||||
if(audit == 1) {
|
||||
setCompanyId('1150930317231112193');
|
||||
setRegisterStoreId('1150930317436633090');
|
||||
}
|
||||
}
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
await getVersionStatus();
|
||||
}
|
||||
|
||||
//测试、开发 trial,develop
|
||||
else {
|
||||
setCompanyId('1150930317231112193');
|
||||
@ -30,6 +42,8 @@ onLaunch((options) => {
|
||||
|
||||
if(options?.query) {
|
||||
|
||||
// options.query.scene = 'companyId%3D1150930317231112193%26wxOpenId%3D111%26ticketId%3D123456%26storeId%3D1150930317436633090'
|
||||
|
||||
//保存登录邀请员工id
|
||||
if(options.query.referrerUserId) {
|
||||
setReferrerUserId(options.query.referrerUserId);
|
||||
@ -46,12 +60,20 @@ onLaunch((options) => {
|
||||
}
|
||||
|
||||
if(options?.query.scene) {
|
||||
//保存注册门店id
|
||||
const params = decodeURIComponent(options?.query.scene);
|
||||
if(params.split('=')[0] === 'storeId') {
|
||||
setRegisterStoreId(params.split('=')[1]);
|
||||
function getQueryParam(queryParams: string, key: string) {
|
||||
let regex = new RegExp('(?:[?&]|^)' + key + '=([^&]+)'),
|
||||
match = queryParams.match(regex);
|
||||
return match && match[1];
|
||||
}
|
||||
|
||||
//保存注册门店id
|
||||
const params = decodeURIComponent(options?.query.scene);
|
||||
if(params.includes('companyId')) {
|
||||
setCompanyId(getQueryParam(params, 'companyId') || '');
|
||||
}
|
||||
if(params.includes('storeId')) {
|
||||
setRegisterStoreId(getQueryParam(params, 'storeId') || '');
|
||||
}
|
||||
if(options?.query.scene === 'edit_avatar_nickname') {
|
||||
setTimeout(() => {
|
||||
uni.reLaunch({
|
||||
|
86
src/components/company-dialog.vue
Normal file
86
src/components/company-dialog.vue
Normal file
@ -0,0 +1,86 @@
|
||||
<template>
|
||||
<uni-popup ref='popupRef' type='bottom' :mask-click='false' @touchmove.stop.prevent=''>
|
||||
<view class='content'>
|
||||
<text class='title'>切换门店</text>
|
||||
<scroll-view scroll-y style='max-height: 600rpx;padding: 15rpx'>
|
||||
<view class='store-item' v-for='(item, index) in companyList' :key='index' @click='() => {
|
||||
handleClick(index)
|
||||
}'>
|
||||
<text>{{ item?.companyName || '' }}</text>
|
||||
</view>
|
||||
</scroll-view>
|
||||
<view class='close-btn primary-button' @click='close'>
|
||||
<text>取消</text>
|
||||
</view>
|
||||
</view>
|
||||
</uni-popup>
|
||||
</template>
|
||||
|
||||
<script lang='ts' setup>
|
||||
defineProps({
|
||||
companyList: {
|
||||
type: Array,
|
||||
default: () => []
|
||||
}
|
||||
});
|
||||
|
||||
const popupRef = ref();
|
||||
let callback: Function;
|
||||
|
||||
const show = (fn: Function) => {
|
||||
callback = fn;
|
||||
popupRef.value.open();
|
||||
};
|
||||
|
||||
const handleClick = (index: number) => {
|
||||
callback(index);
|
||||
close();
|
||||
};
|
||||
|
||||
const close = () => {
|
||||
popupRef.value.close();
|
||||
};
|
||||
|
||||
defineExpose({
|
||||
show, close
|
||||
});
|
||||
</script>
|
||||
|
||||
<style lang='scss' scoped>
|
||||
.content {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
background: #FFFFFF;
|
||||
border-radius: 20rpx 20rpx 0 0;
|
||||
padding: 20rpx 30rpx 30rpx 30rpx;
|
||||
|
||||
.title {
|
||||
display: flex;
|
||||
align-self: center;
|
||||
font-size: 30rpx;
|
||||
font-weight: bold;
|
||||
padding: 20rpx;
|
||||
}
|
||||
|
||||
.store-item {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
font-size: 35rpx;
|
||||
color: #333333;
|
||||
//padding: 20rpx 20rpx;
|
||||
}
|
||||
|
||||
.store-item:after {
|
||||
content: '';
|
||||
background: #F5F5F5;
|
||||
height: 0.5rpx;
|
||||
width: 100%;
|
||||
margin: 25rpx 0;
|
||||
}
|
||||
|
||||
.close-btn {
|
||||
background: #F5F5F5;
|
||||
color: #333333;
|
||||
}
|
||||
}
|
||||
</style>
|
@ -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) => {
|
||||
|
@ -52,16 +52,16 @@ const useUserStore = defineStore('user', {
|
||||
// }
|
||||
|
||||
getUserDiscount(): number {
|
||||
if(this.userInfo.levelEntity?.discount > 0 && this.userInfo.levelEntity?.discount < 10) {
|
||||
return this.userInfo.levelEntity?.discount / 10;
|
||||
} else if(this.userInfo.levelEntity?.discount >= 10 && this.userInfo.levelEntity?.discount <= 100) {
|
||||
return this.userInfo.levelEntity?.discount / 100;
|
||||
if(this.userInfo?.levelEntity?.discount > 0 && this.userInfo?.levelEntity?.discount < 10) {
|
||||
return this.userInfo?.levelEntity?.discount / 10;
|
||||
} else if(this.userInfo?.levelEntity?.discount >= 10 && this.userInfo?.levelEntity?.discount <= 100) {
|
||||
return this.userInfo?.levelEntity?.discount / 100;
|
||||
}
|
||||
return 1;
|
||||
},
|
||||
|
||||
getRealGoodsPrice: (state) => (price: number, priceExt: number) => {
|
||||
return state.userInfo.salePrice == 'price_ext' ? priceExt||0 : price;
|
||||
return state.userInfo.salePrice == 'price_ext' ? priceExt || 0 : price;
|
||||
}
|
||||
},
|
||||
|
||||
@ -71,8 +71,12 @@ const useUserStore = defineStore('user', {
|
||||
this.userInfo = partial as UserBean;
|
||||
// this.userInfo.levelEntity?.discount = 79;
|
||||
// this.userInfo.salePrice = 'price_ext';
|
||||
this.userInfo.userDiscount = this.getUserDiscount;
|
||||
await setCompanyId(this.userInfo.companyId);
|
||||
if(this.userInfo) {
|
||||
this.userInfo.userDiscount = this.getUserDiscount;
|
||||
await setCompanyId(this.userInfo.companyId);
|
||||
} else {
|
||||
await clearToken();
|
||||
}
|
||||
await this.fetchTerminal();
|
||||
await this.fetchCompanyInfo();
|
||||
},
|
||||
@ -178,7 +182,7 @@ const useUserStore = defineStore('user', {
|
||||
},
|
||||
|
||||
async fetchTerminal() {
|
||||
this.terminalInfo = await getTerminal(this.userInfo.companyId);
|
||||
this.terminalInfo = await getTerminal(this.userInfo?.companyId);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
1
types/components.d.ts
vendored
1
types/components.d.ts
vendored
@ -7,6 +7,7 @@ export {}
|
||||
|
||||
declare module 'vue' {
|
||||
export interface GlobalComponents {
|
||||
CompanyDialog: typeof import('./../src/components/company-dialog.vue')['default']
|
||||
OfficialAccountDialog: typeof import('./../src/components/official-account-dialog.vue')['default']
|
||||
PageNav: typeof import('./../src/components/page-nav/page-nav.vue')['default']
|
||||
PaymentButton: typeof import('./../src/components/payment-button.vue')['default']
|
||||
|
Loading…
Reference in New Issue
Block a user