补充分享未注册店铺的团购券的注册流程

This commit is contained in:
2024-06-12 23:01:53 +08:00
parent fe91157f6c
commit 6921c82ad3
9 changed files with 73 additions and 44 deletions

View File

@@ -101,15 +101,6 @@ export default {
}, 500);
}
}
//原先商品团购
if(options?.path?.includes('ticketsBuy/ticketsBuy') && options?.query.couponsId) {
setTimeout(() => {
uni.reLaunch({
url: 'pages/common/groupbuy/detail?couponId=' + options?.query.couponsId
});
}, 500);
}
}
logger.info(`App Launch options ${env}: { companyId: `, getCompanyId() + ', storeId: ' + getRegisterStoreId() + ' }');
@@ -128,7 +119,9 @@ export default {
globalData: {
logger: logger,
companyId: getCompanyId(),
storeId: getRegisterStoreId()
storeId: getRegisterStoreId(),
shareCompanyId: '',
shareStoreId: ''
}
};

View File

@@ -2,3 +2,5 @@ import { get } from '@/utils/request';
export const getCompanyList = (maOpenId: string) => get({ url: `/wc/wechat/company?maOpenId=${maOpenId}` });
export const getCompanyInfo = () => get({ url: `/ext/zconfig/company_find` });
export const getStoreId = (data: any) => get({ url: '/wc/wechat/get_store_id', data });

View File

@@ -157,6 +157,7 @@ import { getGoodsList } from '@/api/goods';
import { GoodsBean } from '@/api/goods/types';
import { useUserStore } from '@/store';
import { GroupBuyBean, RecordBean } from '@/api/groupbuy/types';
import { getStoreId } from '@/api/company';
const userStore = useUserStore();
const { userInfo } = storeToRefs(userStore);

View File

@@ -4,10 +4,26 @@
<script lang='ts' setup>
onLoad((options) => {
import { getStoreId } from '@/api/company';
onLoad(async (options) => {
getApp().globalData?.logger?.info('ticketsBuy share options: ', options);
let couponId = options?.couponsId;
if(couponId) {
if(options?.companyId && options?.creatorId) {
const storeId = await getStoreId({
companyid: options?.companyId,
deviceid: options?.creatorId
});
if(storeId) {
// setRegisterStoreId(storeId);
if(getApp()?.globalData) {
getApp().globalData!.shareCompanyId = options?.companyId;
getApp().globalData!.shareStoreId = storeId;
}
}
}
setTimeout(() => {
uni.reLaunch({
url: `/pages/common/groupbuy/detail?couponId=${couponId}`

View File

@@ -178,38 +178,50 @@ function avatarModifyRemind() {
const fetchCompanyList = (fn: any = undefined) => {
const maOpenId = getOpenId() || 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);
companyList.value = res.map((res: { company: any }) => res.company);
userList.value = res.map((res: { user: any }) => res.user);
if(companyList.value.length === 0) {
uni.showModal({
title: '提示',
content: '当前店铺还未注册,请先注册',
showCancel: true,
success: (res) => {
if(res.confirm) {
goPath('/pages/common/register/index');
}
}
});
return;
}
if(fn != undefined && fn instanceof Function) {
fn(companyList.value, userList.value);
} else {
let index = companyList.value.findIndex((res: { id: string }) => res.id === getApp().globalData?.companyId);
//未在当前公司下注册
if(index < 0) {
if(!getApp()?.globalData?.storeId) {
goPath('/pages/common/register/index');
if(companyList.value.length === 0) {
showRegisterModal();
return;
}
if(fn != undefined && fn instanceof Function) {
fn(companyList.value, userList.value);
} else {
let index = companyList.value.findIndex((res: { id: string }) => res.id === getApp()?.globalData?.companyId);
//未在当前公司下注册
if(index < 0) {
showRegisterModal();
return;
}
index = 0;
}
userStore.setUserInfo(userList.value[index]);
userStore.setCompanyInfo(companyList.value[index]);
avatarModifyRemind();
//分享过来的公司id和店铺id
if(getApp()?.globalData?.shareCompanyId && getApp()?.globalData?.shareStoreId) {
index = companyList.value.findIndex((res: { id: string }) => res.id === getApp().globalData?.shareCompanyId);
if(index < 0) {
showRegisterModal();
return;
}
}
userStore.setUserInfo(userList.value[index]);
userStore.setCompanyInfo(companyList.value[index]);
avatarModifyRemind();
}
}
)
;
};
const showRegisterModal = () => {
uni.showModal({
title: '提示',
content: '当前店铺还未注册,请先注册',
showCancel: true,
success: (res) => {
if(res.confirm) {
goPath('/pages/common/register/index');
}
}
});
};

View File

@@ -7,6 +7,11 @@
onLoad((options) => {
getApp().globalData?.logger?.info('app share index/index options: ', options);
if(options?.companyId && options?.storeId && getApp()?.globalData) {
getApp().globalData!.shareCompanyId = options?.companyId;
getApp().globalData!.shareStoreId = options?.storeId;
}
let goodsShareId = '';
if(options?.shareId) {
goodsShareId = options?.shareId;

View File

@@ -9,7 +9,7 @@
<view class='right-content accent-text-color' :class='{"right-content-disabled": item?.status!=0}'>
<text>{{ item?.name }}</text>
<text>有效期至{{ dayjs(item?.startTime).format('YYYY-MM-DD') }}</text>
<text>有效期至{{ dayjs(item?.endTime).format('YYYY-MM-DD') }}</text>
<text class='btn-text' :class='{"btn-text-disabled": item?.status!=0}' @click.stop='goPath("/pages/mall/index")'>
立即使用
</text>
@@ -80,7 +80,7 @@ defineProps({
position: relative;
flex: 1;
justify-content: center;
margin-left: 70rpx;
margin-left: 65rpx;
text:nth-of-type(1) {
font-size: 30rpx;

View File

@@ -130,9 +130,9 @@ const useUserStore = defineStore('user', {
unionId: this.userInfo.unionId,
openId: this.userInfo.openId,
maOpenId: this.userInfo.maOpenId,
companyId: getCompanyId(),
companyId: getApp()?.globalData?.shareCompanyId || getCompanyId(),
creatorId: this.userInfo.creatorId,
storeId: getRegisterStoreId()
storeId: getApp()?.globalData?.shareStoreId || getRegisterStoreId()
} as RegisterParams;
return new Promise(async (resolve, reject) => {
try {

View File

@@ -43,7 +43,7 @@ function setCompanyId(companyId: string) {
if(companyId) {
uni.setStorageSync(CompanyIdKey, companyId);
if(getApp()?.globalData) {
getApp().globalData.companyId = companyId;
getApp().globalData!.companyId = companyId;
}
}
}