商品团购分享处理

This commit is contained in:
2024-06-07 14:10:43 +08:00
parent 613c0df738
commit 4b4ee44242
10 changed files with 53 additions and 26 deletions

View File

@@ -1,6 +1,6 @@
<script lang='ts'>
import {
getCompanyId,
getCompanyId, getQueryParam,
getRegisterStoreId,
mpUpdate,
setCompanyId,
@@ -85,12 +85,6 @@ export default {
}
if(options?.query.scene) {
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')) {

View File

@@ -1,14 +1,16 @@
import { get } from '@/utils';
import { get, post } from '@/utils';
import { CategoryBean, GoodsBean } from '@/api/goods/types';
enum URL {
categoryList = '/ext/goods/category_list',
goodsList = '/ext/goods/query',
goodsDetail = '/ext/goods/info'
goodsDetail = '/ext/goods/info',
shareGoodsDetail = '/wechat/coupons/group/qrcode'
}
export const getCategoryList = () => get<CategoryBean[]>({ url: URL.categoryList });
export const getGoodsList = (params: any) => get<GoodsBean[]>({ url: URL.goodsList, data: params });
export const getGoodsDetail = (goodsId: string) => get<GoodsBean>({ url: URL.goodsDetail + `?goodsId=${goodsId}` });
export const getShareGoodsDetail = (shareId: string) => post<GoodsBean>({ url: URL.shareGoodsDetail + `/${shareId}` });

View File

@@ -2,8 +2,8 @@
"name": "SUKE-MP",
"appid": "",
"description": "",
"versionName": "3.0.2",
"versionCode": "302",
"versionName": "3.0.3",
"versionCode": "303",
"transformPx": false,
"app-plus": {
"usingComponents": true,

View File

@@ -144,7 +144,7 @@ import SkuDialog from '@/components/sku-dialog.vue';
import CouponItem from './components/coupon-item.vue';
import { getGroupBuyDetail, getGroupBuyRecordList, preOrder } from '@/api/groupbuy';
import { getGoodsList } from '@/api/goods';
import { getGoodsList, getShareGoodsDetail } from '@/api/goods';
import { GoodsBean } from '@/api/goods/types';
import { useUserStore } from '@/store';
import { GroupBuyBean, RecordBean } from '@/api/groupbuy/types';
@@ -173,7 +173,13 @@ const currentPageNum = ref(1);
onLoad(async (e: any) => {
if(isLogin()) {
await uni.showLoading();
groupBuyBean.value = await getGroupBuyDetail(e.id);
if(e.id != undefined) {
groupBuyBean.value = await getGroupBuyDetail(e.id);
}
if(e.shareId != undefined) {
const { group, share } = await getShareGoodsDetail(e.shareId);
groupBuyBean.value = group;
}
// setCompanyId('1512403904150138881');
// groupBuyBean.value = await getGroupBuyDetail('1740922051118063618');
if(groupBuyBean.value) {

View File

@@ -3,6 +3,8 @@
</template>
<script lang='ts' setup>
import { getQueryParam } from '@/utils';
onLoad((options) => {
getApp().logger?.info('ticketsBuy options: ', options);
let couponId = options?.couponsId;
@@ -17,11 +19,7 @@ onLoad((options) => {
}, 300);
});
function getQueryParam(queryParams: string, key: string) {
let regex = new RegExp('(?:[?&]|^)' + key + '=([^&]+)'),
match = queryParams.match(regex);
return match && match[1];
}
</script>
<style lang='scss' scoped>

View File

@@ -86,6 +86,7 @@ const submenuList = [
title: '注册有礼',
icon: assetsUrl('ic_register_gift2.png'),
path: '/pages/common/register/reward'
// path: '/pages/common/groupbuy/detail?shareId=1797548579864748033'
// path: '/pages/coupons/ticketsBuy/ticketsBuy?couponsId=1797773484774432769'
},
{

View File

@@ -3,10 +3,30 @@
</template>
<script lang='ts' setup>
onMounted(() => {
uni.reLaunch({
url: '/pages/home/index'
});
import { getQueryParam } from '@/utils';
onLoad((options) => {
if(options?.query) {
getApp().logger?.info('app goods share options: ', options);
const params = decodeURIComponent(options?.query);
const shareId = getQueryParam(params, 'shareId');
getApp().logger?.info('app goods share options: ', params, shareId);
if(shareId != undefined) {
setTimeout(() => {
uni.reLaunch({
url: `/pages/common/groupbuy/detail?shareId=${shareId}`
});
}, 300);
} else {
uni.reLaunch({
url: '/pages/home/index'
});
}
} else {
uni.reLaunch({
url: '/pages/home/index'
});
}
});
</script>

View File

@@ -80,7 +80,7 @@ const params = ref<{
nickName: userInfo.value.nickName,
telephone: userInfo.value.telephone,
gender: userInfo.value.gender,
birthday: userInfo.value.birthday|| dayjs().format('YYYY-MM-DD')
birthday: userInfo.value.birthday || dayjs().format('YYYY-MM-DD')
});
onLoad(() => {
@@ -135,7 +135,7 @@ const save = async () => {
const result = await updateProfile({
...params.value,
birthday: dayjs(birthday.value).isValid() ? dayjs(birthday.value).format('YYYY-MM-DD HH:mm:ss') : dayjs().format('YYYY-MM-DD HH:mm:ss'),
birthday: dayjs(params.value.birthday).isValid() ? dayjs(params.value.birthday).format('YYYY-MM-DD HH:mm:ss') : dayjs().format('YYYY-MM-DD HH:mm:ss'),
birthdayType: 0
});

View File

@@ -132,3 +132,9 @@ export function copy(content: string) {
}
});
}
export function getQueryParam(queryParams: string, key: string) {
let regex = new RegExp('(?:[?&]|^)' + key + '=([^&]+)'),
match = queryParams.match(regex);
return match && match[1];
}

View File

@@ -61,7 +61,7 @@ function responseInterceptors() {
}
// 登录状态失效,重新登录
if(data.code === 4011 || data?.retcode === 4011) {
if(data?.code === 401 || data?.code === 4011 || data?.retcode === 4011) {
// 是否在获取token中,防止重复获取
if(!isRefreshing) {
// 修改登录状态为true