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

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); }, 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() + ' }'); logger.info(`App Launch options ${env}: { companyId: `, getCompanyId() + ', storeId: ' + getRegisterStoreId() + ' }');
@@ -128,7 +119,9 @@ export default {
globalData: { globalData: {
logger: logger, logger: logger,
companyId: getCompanyId(), 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 getCompanyList = (maOpenId: string) => get({ url: `/wc/wechat/company?maOpenId=${maOpenId}` });
export const getCompanyInfo = () => get({ url: `/ext/zconfig/company_find` }); 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 { GoodsBean } from '@/api/goods/types';
import { useUserStore } from '@/store'; import { useUserStore } from '@/store';
import { GroupBuyBean, RecordBean } from '@/api/groupbuy/types'; import { GroupBuyBean, RecordBean } from '@/api/groupbuy/types';
import { getStoreId } from '@/api/company';
const userStore = useUserStore(); const userStore = useUserStore();
const { userInfo } = storeToRefs(userStore); const { userInfo } = storeToRefs(userStore);

View File

@@ -4,10 +4,26 @@
<script lang='ts' setup> <script lang='ts' setup>
onLoad((options) => { import { getStoreId } from '@/api/company';
onLoad(async (options) => {
getApp().globalData?.logger?.info('ticketsBuy share options: ', options); getApp().globalData?.logger?.info('ticketsBuy share options: ', options);
let couponId = options?.couponsId; let couponId = options?.couponsId;
if(couponId) { 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(() => { setTimeout(() => {
uni.reLaunch({ uni.reLaunch({
url: `/pages/common/groupbuy/detail?couponId=${couponId}` url: `/pages/common/groupbuy/detail?couponId=${couponId}`

View File

@@ -178,38 +178,50 @@ function avatarModifyRemind() {
const fetchCompanyList = (fn: any = undefined) => { const fetchCompanyList = (fn: any = undefined) => {
const maOpenId = getOpenId() || userInfo.value?.maOpenId || (userList.value.filter((res: UserBean) => res?.maOpenId !== '')[0]?.maOpenId); const maOpenId = getOpenId() || userInfo.value?.maOpenId || (userList.value.filter((res: UserBean) => res?.maOpenId !== '')[0]?.maOpenId);
getCompanyList(maOpenId).then(res => { getCompanyList(maOpenId).then(res => {
companyList.value = res.map((res: { company: any }) => res.company); companyList.value = res.map((res: { company: any }) => res.company);
userList.value = res.map((res: { user: any }) => res.user); userList.value = res.map((res: { user: any }) => res.user);
if(companyList.value.length === 0) { if(companyList.value.length === 0) {
uni.showModal({ showRegisterModal();
title: '提示', return;
content: '当前店铺还未注册,请先注册', }
showCancel: true, if(fn != undefined && fn instanceof Function) {
success: (res) => { fn(companyList.value, userList.value);
if(res.confirm) { } else {
goPath('/pages/common/register/index'); let index = companyList.value.findIndex((res: { id: string }) => res.id === getApp()?.globalData?.companyId);
} //未在当前公司下注册
} if(index < 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) {
if(!getApp()?.globalData?.storeId) {
goPath('/pages/common/register/index');
return; return;
} }
index = 0;
}
userStore.setUserInfo(userList.value[index]); //分享过来的公司id和店铺id
userStore.setCompanyInfo(companyList.value[index]); if(getApp()?.globalData?.shareCompanyId && getApp()?.globalData?.shareStoreId) {
avatarModifyRemind(); 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) => { onLoad((options) => {
getApp().globalData?.logger?.info('app share index/index options: ', 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 = ''; let goodsShareId = '';
if(options?.shareId) { if(options?.shareId) {
goodsShareId = 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}'> <view class='right-content accent-text-color' :class='{"right-content-disabled": item?.status!=0}'>
<text>{{ item?.name }}</text> <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 class='btn-text' :class='{"btn-text-disabled": item?.status!=0}' @click.stop='goPath("/pages/mall/index")'>
立即使用 立即使用
</text> </text>
@@ -80,7 +80,7 @@ defineProps({
position: relative; position: relative;
flex: 1; flex: 1;
justify-content: center; justify-content: center;
margin-left: 70rpx; margin-left: 65rpx;
text:nth-of-type(1) { text:nth-of-type(1) {
font-size: 30rpx; font-size: 30rpx;

View File

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

View File

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