uniapp【修复】: 拼团订单分享按钮后续逻辑不通

This commit is contained in:
15093570141
2024-11-12 20:49:47 +08:00
parent ad20797147
commit 66e483f53f
7 changed files with 1126 additions and 952 deletions

View File

@@ -3,91 +3,91 @@ import type { Response } from '@/core/models';
/** 获取不同类型营销下单支持的配送方式 */
export const queryOrderDistributionModel = (data : any) : Promise<Response<any>> => {
return post('Api/Order/GetOrderDistributionModel', {
data,
}, true);
return post('Api/Order/GetOrderDistributionModel', {
data,
}, true);
}
/** 获取全部订单列表 */
export const queryOrderList = (data : any) : Promise<Response<any>> => {
return post('Api/Order/GetOrderList', {
data,
}, true);
return post('Api/Order/GetOrderList', {
data,
}, true);
}
/** 根据订单编号获取当前订单的支付信息 */
export const queryOrderPayInfo = (data : any) : Promise<Response<any>> => {
return post('Api/Order/GetOrderPayInfo', {
data,
}, true);
return post('Api/Order/GetOrderPayInfo', {
data,
}, true);
}
/** 确认收货 */
export const queryOrderConfirm = (data : any) : Promise<Response<any>> => {
return post('Api/Order/OrderConfirm', {
data,
}, true);
return post('Api/Order/OrderConfirm', {
data,
}, true);
}
/** 查询当前订单是否接入微信发货信息管理 */
export const queryOrderShippingList = (data : any) : Promise<Response<any>> => {
return post('Api/Order/OrderShippingList', {
data,
}, true);
return post('Api/Order/OrderShippingList', {
data,
}, true);
}
/** 获取订单详情 */
export const queryOrderDetails = (data : any) : Promise<Response<any>> => {
return post('Api/Order/OrderDetails', {
data,
}, true);
return post('Api/Order/OrderDetails', {
data,
}, true);
}
/** 取消订单 */
export const queryCancelOrder = (data : any) : Promise<Response<any>> => {
return post('Api/Order/CancelOrder', {
data,
}, true);
return post('Api/Order/CancelOrder', {
data,
}, true);
}
/** 订单评价接口 */
export const submitOrderEvaluate = (data : any) : Promise<Response<any>> => {
return post('Api/User/OrderEvaluate', {
data,
}, true);
return post('Api/User/OrderEvaluate', {
data,
}, true);
}
/** 判断用户下单可以使用多少积分 */
export const queryUserPoint = (data : any) : Promise<Response<any>> => {
return post('Api/User/GetUserPoint', {
data,
}, true);
return post('Api/User/GetUserPoint', {
data,
}, true);
}
/** 根据订单id取拼团信息用在订单详情页 */
export const queryOrderPinTuanTeamInfo = (data : any) : Promise<Response<any>> => {
return post('Api/PinTuan/GetPinTuanTeam', {
data,
}, true);
return post('Api/PinTuan/GetPinTuanTeam', {
data,
}, true);
}
/** 获取发票是否开具 */
export const queryCheckInvoice = (data : any) : Promise<Response<any>> => {
return post('Api/Order/CheckInvoice', {
data,
}, true);
return post('Api/Order/CheckInvoice', {
data,
}, true);
}
/** 提交发票申请 */
export const querySubmitInvoiceApply = (data : any) : Promise<Response<any>> => {
return post('Api/Order/SubmitInvoiceApply', {
data,
}, true);
return post('Api/Order/SubmitInvoiceApply', {
data,
}, true);
}
/** 物流信息接口 */
export const queryLogisticsByApi = (data : any) : Promise<Response<any>> => {
return post('Api/Order/LogisticsByApi', {
data,
}, true);
return post('Api/Order/LogisticsByApi', {
data,
}, true);
}

View File

@@ -26,7 +26,7 @@
</view>
<!-- 积分兑换价格 -->
<Point :flex="true" :data="props.goodsDetailData?.product" fontSize="24rpx"></Point>
<Point v-if="!props.isActivityGoods" :flex="true" :data="props.goodsDetailData?.product" fontSize="24rpx"></Point>
<view class="name-box" v-if="props.goodsDetailData?.name || props.goodsDetailData?.brief">
<view class="name">{{ props.goodsDetailData?.name }}</view>

View File

@@ -41,7 +41,7 @@
<lpainterText :text="'截止:' + state.shareData.endTime"
css="color: #212121; background: #ffb400; padding:8rpx 20rpx;border-radius:12rpx" />
</lpainterView>
<lpainterView css="margin-top: 30rpx; font-size: 26rpx; color: #8c5400">
<lpainterView css="width: 570rpx;margin-top: 30rpx; font-size: 26rpx; color: #8c5400">
<lpainterText :text="state.shareData.brief"
css=" background: #fff4d9; padding:8rpx 20rpx; border-radius:12rpx" />
</lpainterView>
@@ -130,7 +130,7 @@
if (state.shareType == ShareEnum.goods) {
/** 获取商品详情 */
getGoodsDetail(query)
} else if (state.shareType == ShareEnum.pinTuan || state.shareType === ShareEnum.addPinTuan) {
} else if (state.shareType == ShareEnum.pinTuan || state.shareType == ShareEnum.addPinTuan) {
/** 获取活动拼团详情 */
getActivityPinTuan(query);
} else if (state.shareType == ShareEnum.serviceGoods) {
@@ -196,7 +196,7 @@
state.shareData.mktprice = goodsDetail.data?.mktprice;
state.shareData.showPinTuanArguments = true;
state.shareData.endTime = goodsDetail.data?.groupEndTime;
state.shareData.endTime = goodsDetail.data?.pinTuanRule?.endTime;
state.shareData.peopleNumber = goodsDetail.data?.pinTuanRule?.peopleNumber;
} else {
handleShowToast(goodsDetail.msg, 'none', () => {

View File

@@ -86,3 +86,80 @@
background-color: #d33123;
}
}
.pinTuan-popup-box{
padding: 40rpx;
.time-title{
font-size: 27rpx;
text-align: center;
margin-bottom: 5rpx;
}
.time{
text-align: center;
}
.teams-box{
margin-top: 40rpx;
display: flex;
flex-wrap: wrap;
justify-content: center;
.img-box{
position: relative;
width: 80rpx;
height: 80rpx;
border-radius: 50%;
margin-right: 30rpx;
margin-bottom: 20rpx;
.tit{
position: absolute;
top: -5rpx;
left: -10rpx;
display: inline-block;
background-color: #d33123;
color: #fff;
font-size: 22rpx;
z-index: 98;
padding: 0 10rpx;
border-radius: 10rpx;
-webkit-transform: scale(0.8);
transform: scale(0.8);
}
.img{
display: block;
width: 80rpx;
height: 80rpx;
border: 1px solid #d33123;
border-radius: 50%;
}
}
.need-peo{
width: 80rpx;
height: 80rpx;
border-radius: 50%;
display: flex;
border: 1px dashed #e1e1e1;
margin-right: 30rpx;
margin-bottom: 20rpx;
.tit{
margin: auto;
color: #d1d1d1;
font-size: 27rpx;
}
}
}
.peo-box{
margin-top: 20rpx;
text-align: center;
.peo{
color: #d33123;
}
}
.btn-box{
margin: 40rpx auto 0;
background-color: #d33123;
font-size: 27rpx;
padding: 20rpx 0;
justify-content: center;
width: 400rpx;
color: #fff;
border-radius: 20px;
}
}

View File

@@ -1,310 +1,350 @@
<template>
<coreshop-page bgColor="rgba(0,0,0,0)" :isShowStatusBarHeight="false" :placeholder="false" showLoginModalDom
needLoadingPage :loadingPage="loadingPage">
<view class="goods-detail">
<!-- 商品详情 -->
<GoodsDetail :goodsId="state.goodsDetailData?.id" :goodsDetailData="state.goodsDetailData"
:swiperBanner="state.swiperBanner" :shareType="ShareEnum.pinTuan"
:goodsDetailContent="state.goodsDetailContent" :isActivityGoods="true">
<template #activityGoodsOtheService>
<view class="pinTuan-record" v-if="state.goodsDetailData?.pinTuanRecord?.length > 0">
<view class="title">
<view class="tit">开团信息</view>
<view class="desc">{{ state.goodsDetailData?.pinTuanRecordNums || '0' }}人在拼单可直接参与</view>
</view>
<view class="pinTuan-box">
<view class="item-box" v-for="item, index in state.goodsDetailData?.pinTuanRecord"
:key="index">
<view class="msg-box">
<view class="msg">还差 <text class="red">{{ item.teamNums || '' }}</text> 拼成</view>
<view class="time">
剩余
<uv-count-down :time="item.lastTime * 1000" format="HH:mm:ss"></uv-count-down>
</view>
</view>
<view class="peo-box">
<image class="peo" v-for="cell, cellIndex in item.teams" :key="cellIndex"
:src="cell.userAvatar"></image>
</view>
<view class="peo-share">
<uv-button v-if="item.isOverdue" type="success" :disabled="true" size="mini"
text="已结束"></uv-button>
<uv-button v-else type="success" size="mini" text="去拼单"
@click="handleSplicingOrders(item.teamId)"></uv-button>
</view>
</view>
</view>
</view>
</template>
</GoodsDetail>
<coreshop-page bgColor="rgba(0,0,0,0)" :isShowStatusBarHeight="false" :placeholder="false" showLoginModalDom
needLoadingPage :loadingPage="loadingPage">
<view class="goods-detail">
<!-- 商品详情 -->
<GoodsDetail :goodsId="state.goodsDetailData?.id" :goodsDetailData="state.goodsDetailData"
:swiperBanner="state.swiperBanner" :shareType="ShareEnum.pinTuan"
:goodsDetailContent="state.goodsDetailContent" :isActivityGoods="true">
<template #activityGoodsOtheService>
<view class="pinTuan-record" v-if="state.goodsDetailData?.pinTuanRecord?.length > 0">
<view class="title">
<view class="tit">开团信息</view>
<view class="desc">{{ state.goodsDetailData?.pinTuanRecordNums || '0' }}人在拼单可直接参与</view>
</view>
<view class="pinTuan-box">
<view class="item-box" v-for="item, index in state.goodsDetailData?.pinTuanRecord"
:key="index">
<view class="msg-box">
<view class="msg">还差 <text class="red">{{ item.teamNums || '' }}</text> 拼成</view>
<view class="time">
剩余
<uv-count-down :time="item.lastTime * 1000" format="HH:mm:ss"></uv-count-down>
</view>
</view>
<view class="peo-box">
<image class="peo" v-for="cell, cellIndex in item.teams" :key="cellIndex"
:src="cell.userAvatar"></image>
</view>
<view class="peo-share">
<uv-button v-if="item.isOverdue" type="success" :disabled="true" size="mini"
text="已结束"></uv-button>
<uv-button v-else type="success" size="mini" text="去拼单"
@click="handleSplicingOrders(item.teamId)"></uv-button>
</view>
</view>
</view>
</view>
</template>
</GoodsDetail>
<!-- 为您推荐 -->
<GoodsDetailRecommend></GoodsDetailRecommend>
<!-- 为您推荐 -->
<GoodsDetailRecommend></GoodsDetailRecommend>
<!-- 底部 购买 -->
<GoodsDetailBottomTabbar>
<template #bottomTabbar>
<view class="btn-box">
<view class="btn" @click="handleSingleBuy">
<view class="box">
<view class="num">{{ state.goodsDetailData.price }}</view>
<view class="tit">单独购买</view>
</view>
</view>
<view class="btn buy" @click="handleMultipleBuy">
<view class="box">
<view class="num">{{ state.goodsDetailData.pinTuanPrice }}</view>
<view class="tit">发起拼团</view>
</view>
</view>
</view>
</template>
</GoodsDetailBottomTabbar>
<!-- 底部 购买 -->
<GoodsDetailBottomTabbar>
<template #bottomTabbar>
<view class="btn-box">
<view class="btn" @click="handleSingleBuy">
<view class="box">
<view class="num">{{ state.goodsDetailData.price }}</view>
<view class="tit">单独购买</view>
</view>
</view>
<view class="btn buy" @click="handleMultipleBuy()">
<view class="box">
<view class="num">{{ state.goodsDetailData.pinTuanPrice }}</view>
<view class="tit">发起拼团</view>
</view>
</view>
</view>
</template>
</GoodsDetailBottomTabbar>
<!-- 商品sku弹框 -->
<GoodsDetailSkuPopup :showSku="state.showSku" :goodsDetailData="state.goodsDetailData"
:isShowAddCartBtn="false" :buyNowNowloading="loading" @handleChangePopup="handleChangePopup"
@handleBuyNow="handleBuyNow" :btnBuyTitlt="state.btnBuyTitlt">
</GoodsDetailSkuPopup>
</view>
</coreshop-page>
<!-- 商品sku弹框 -->
<GoodsDetailSkuPopup :showSku="state.showSku" :goodsDetailData="state.goodsDetailData"
:isShowAddCartBtn="false" :buyNowNowloading="loading" @handleChangePopup="handleChangePopup"
@handleBuyNow="handleBuyNow" :btnBuyTitlt="state.btnBuyTitlt">
</GoodsDetailSkuPopup>
<!-- 分享进来的参与拼团弹框 -->
<uv-popup ref="pinTuanPopup" mode="bottom" :closeable="true">
<view class="pinTuan-popup-box">
<view class="time-title">剩余时间</view>
<view class="time">
<uv-count-down :time="state.teamInfo.lastTime * 1000" :autoStart="true" :millisecond="true" format="DD天HH时mm分ss秒"></uv-count-down>
</view>
<view class="teams-box">
<view class="img-box" v-for="item,index in state.teamInfo.teams" :key="index">
<text class="tit" v-if="item.recordId == item.teamId">拼主</text>
<image class="img" :src="item.userAvatar"></image>
</view>
<view class="need-peo" v-if="state.teamInfo?.teamNums" v-for="item in state.teamInfo?.teamNums" :key="item">
<text class="tit">?</text>
</view>
</view>
<view class="peo-box">
还差 <text class="peo">{{ state.teamInfo?.teamNums || '' }}</text> 赶快拼单吧
</view>
<view class="btn-box" @click="handleJoinGroupBuy">
参与拼团
</view>
</view>
</uv-popup>
</view>
</coreshop-page>
</template>
<script setup lang="ts">
import { reactive, ref } from 'vue';
import { onLoad, onShareAppMessage, onShareTimeline, onPullDownRefresh } from '@dcloudio/uni-app';
import { queryPinTuanGoodsDetail, queryCartNum, queryAddCart, queryOrderPinTuanTeamInfo } from '@/core/api';
import type { Response } from '@/core/models';
import { UserToken, shareUrl } from '@/core/consts'
import { useCartStore, useLoginStore } from '@/core/store';
import { PaymentTypeEnum, ShareEnum, ShareClientEnum, ShareModelEnum } from '@/core/enum';
import { handleRouteNavigateTo, handleShowToast, getShareUrl } from '@/core/utils';
import { deepClone } from '@/uni_modules/uv-ui-tools/libs/function/index.js';
import { reactive, ref } from 'vue';
import { onLoad, onShareAppMessage, onShareTimeline, onPullDownRefresh } from '@dcloudio/uni-app';
import { queryPinTuanGoodsDetail, queryCartNum, queryAddCart, queryOrderPinTuanTeamInfo } from '@/core/api';
import type { Response } from '@/core/models';
import { UserToken, shareUrl } from '@/core/consts'
import { useCartStore, useLoginStore } from '@/core/store';
import { PaymentTypeEnum, ShareEnum, ShareClientEnum, ShareModelEnum } from '@/core/enum';
import { handleRouteNavigateTo, handleShowToast, getShareUrl } from '@/core/utils';
import { deepClone } from '@/uni_modules/uv-ui-tools/libs/function/index.js';
import GoodsDetail from '@/pages/components/goods-detail/index.vue';
import GoodsDetailRecommend from '@/pages/components/goods-detail/components/goods-detail-recommend/goods-detail-recommend.vue';
import GoodsDetailSkuPopup from '@/pages/components/goods-detail/components/goods-detail-sku/goods-detail-sku.vue';
import GoodsDetailBottomTabbar from '@/pages/components/goods-detail/components/goods-detail-bottom-tabbar/goods-detail-bottom-tabbar.vue';
import { useLoadingFn } from '@/core/hooks';
import GoodsDetail from '@/pages/components/goods-detail/index.vue';
import GoodsDetailRecommend from '@/pages/components/goods-detail/components/goods-detail-recommend/goods-detail-recommend.vue';
import GoodsDetailSkuPopup from '@/pages/components/goods-detail/components/goods-detail-sku/goods-detail-sku.vue';
import GoodsDetailBottomTabbar from '@/pages/components/goods-detail/components/goods-detail-bottom-tabbar/goods-detail-bottom-tabbar.vue';
import { useLoadingFn } from '@/core/hooks';
interface QueryParams {
id : number;
teamId ?: number;
}
interface QueryParams {
id : number;
teamId ?: number;
}
/** 登录store */
const _useLoginStore = useLoginStore();
/** 登录store */
const _useLoginStore = useLoginStore();
/** 获取购物车数据 */
const cartStore = useCartStore();
/** 获取购物车数据 */
const cartStore = useCartStore();
/** 分享进来的参与拼团弹框 */
const pinTuanPopup = ref();
const state = reactive<{
id : number;
goodsDetailData : any,
swiperBanner : Array<string>;
goodsDetailContent : string;
skuPrice : Number;
defaultSkuList : Array<any>;
activitySkuList : Array<any>;
showSku : boolean;
teamId : number;
isSingleBuy : boolean;
btnBuyTitlt : string;
teamInfo : any;
shareUrl : string;
}>({
id: 0,
goodsDetailData: {},
swiperBanner: [],
goodsDetailContent: "",
skuPrice: 0,
defaultSkuList: [],
activitySkuList: [],
showSku: false,
teamId: 0,
isSingleBuy: true,
btnBuyTitlt: "发起拼团",
teamInfo: {},
shareUrl: "",
});
const state = reactive<{
id : number;
goodsDetailData : any,
swiperBanner : Array<string>;
goodsDetailContent : string;
skuPrice : Number;
defaultSkuList : Array<any>;
activitySkuList : Array<any>;
showSku : boolean;
teamId : number;
isSingleBuy : boolean;
btnBuyTitlt : string;
teamInfo : any;
shareUrl : string;
}>({
id: 0,
goodsDetailData: {},
swiperBanner: [],
goodsDetailContent: "",
skuPrice: 0,
defaultSkuList: [],
activitySkuList: [],
showSku: false,
teamId: 0,
isSingleBuy: true,
btnBuyTitlt: "发起拼团",
teamInfo: {},
shareUrl: "",
});
const loading = ref(false);
const loadingPage = ref(true);
const handleBuyNow = useLoadingFn(onBuyNow, loading);
const handleGetGoodsDetail = useLoadingFn(getGoodsDetail, loadingPage);
const loading = ref(false);
const loadingPage = ref(true);
const handleBuyNow = useLoadingFn(onBuyNow, loading);
const handleGetGoodsDetail = useLoadingFn(getGoodsDetail, loadingPage);
onLoad((query : QueryParams) => {
if (query?.teamId) {
state.teamId = query?.teamId;
state.goodsDetailData = {
teamId: query?.teamId
};
getOrderPinTuanTeamInfo(query?.teamId);
}
/** 获取商品详情 */
state.id = Number(query.id);
handleGetGoodsDetail();
});
onLoad((query : QueryParams) => {
if (query?.teamId) {
state.teamId = query?.teamId;
state.goodsDetailData = {
teamId: query?.teamId
};
getOrderPinTuanTeamInfo(query?.teamId);
}
/** 获取商品详情 */
state.id = Number(query.id);
handleGetGoodsDetail();
});
onPullDownRefresh(async () => {
await handleGetGoodsDetail();
uni.stopPullDownRefresh();
});
onPullDownRefresh(async () => {
await handleGetGoodsDetail();
uni.stopPullDownRefresh();
});
async function getGoodsDetail() {
let data = {
id: state.id,
data: true,
}
if (uni.getStorageSync(UserToken)) {
data['token'] = uni.getStorageSync(UserToken)
}
const goodsDetail : Response<any> = await queryPinTuanGoodsDetail(data);
async function getGoodsDetail() {
let data = {
id: state.id,
data: true,
}
if (uni.getStorageSync(UserToken)) {
data['token'] = uni.getStorageSync(UserToken)
}
const goodsDetail : Response<any> = await queryPinTuanGoodsDetail(data);
/** 增加活动价格,并合并对象,可能会存在 teamId */
Object.assign(state.goodsDetailData, {
...goodsDetail.data,
activityPrice: goodsDetail.data.pinTuanPrice,
});
/** 增加活动价格,并合并对象,可能会存在 teamId */
Object.assign(state.goodsDetailData, {
...goodsDetail.data,
activityPrice: goodsDetail.data.pinTuanPrice,
});
/** 默认价格 */
state.skuPrice = goodsDetail?.data?.price;
/** 商品轮播图 */
state.swiperBanner = goodsDetail?.data?.images?.split(',');
/** 商品详情内容 */
state.goodsDetailContent = goodsDetail?.data?.intro;
/** 默认sku */
state.defaultSkuList = deepClone(goodsDetail?.data?.skuList?.sku_list);
/** 活动商品价格sku */
state.activitySkuList = deepClone(state.goodsDetailData?.skuList?.sku_list?.map((item : any) => {
item.price = (Number(item.price) - Number(state.goodsDetailData.pinTuanRule.discountAmount));
return item;
}));
/** 如果用户登录,获取购物车数量 */
if (uni.getStorageSync(UserToken)) {
getCartNum();
}
state.shareUrl = await getShareUrl({
client: ShareClientEnum.wxMiNiProgram,
url: shareUrl,
type: ShareModelEnum.url,
page: ShareEnum.pinTuan,
params: {
groupId: state.id,
goodsId: state.goodsDetailData.id,
teamId: state.teamId
}
})
}
/** 默认价格 */
state.skuPrice = goodsDetail?.data?.price;
/** 商品轮播图 */
state.swiperBanner = goodsDetail?.data?.images?.split(',');
/** 商品详情内容 */
state.goodsDetailContent = goodsDetail?.data?.intro;
/** 默认sku */
state.defaultSkuList = deepClone(goodsDetail?.data?.skuList?.sku_list);
/** 活动商品价格sku */
state.activitySkuList = deepClone(state.goodsDetailData?.skuList?.sku_list?.map((item : any) => {
item.price = (Number(item.price) - Number(state.goodsDetailData.pinTuanRule.discountAmount));
return item;
}));
/** 如果用户登录,获取购物车数量 */
if (uni.getStorageSync(UserToken)) {
getCartNum();
}
state.shareUrl = await getShareUrl({
client: ShareClientEnum.wxMiNiProgram,
url: shareUrl,
type: ShareModelEnum.url,
page: ShareEnum.pinTuan,
params: {
groupId: state.id,
goodsId: state.goodsDetailData.id,
teamId: state.teamId
}
})
}
/** 获取通过分享进来的拼团数据 */
const getOrderPinTuanTeamInfo = async (teamId : number) => {
const teamInfo : Response<any> = await queryOrderPinTuanTeamInfo({ teamId, });
if (teamInfo.status) {
state.teamInfo = teamInfo?.data;
pinTuanPopup.value.open();
} else {
handleShowToast(teamInfo.msg)
}
}
/** 获取购物车数量 */
const getCartNum = async () => {
const num : Response<number> = await queryCartNum();
cartStore.setCartNum(num?.data || 0);
}
/** 单独购买 */
const handleSingleBuy = () => {
_useLoginStore.checkLogin(() => {
state.teamId = 0;
state.showSku = true;
state.isSingleBuy = true;
state.btnBuyTitlt = '单独购买';
state.goodsDetailData.skuList.sku_list = state.defaultSkuList;
});
}
/** 拼团购买统一调用 */
const handlePinTuan = (title?:string)=>{
_useLoginStore.checkLogin(() => {
state.showSku = true;
state.isSingleBuy = false;
state.btnBuyTitlt = title || '发起拼团';
state.goodsDetailData.skuList.sku_list = state.activitySkuList;
});
}
/** 弹框中的按钮参与拼团购买 */
const handleJoinGroupBuy = ()=>{
pinTuanPopup.value.close();
handlePinTuan('参与拼团');
}
/** 拼团购买 */
const handleMultipleBuy = () => {
state.teamId = 0;
handlePinTuan()
}
/** 获取通过分享进来的拼团数据 */
const getOrderPinTuanTeamInfo = async (teamId : number) => {
const teamInfo : Response<any> = await queryOrderPinTuanTeamInfo({ teamId, });
if (teamInfo.status) {
state.teamInfo = teamInfo?.data;
} else {
handleShowToast(teamInfo.msg)
}
}
/** 获取购物车数量 */
const getCartNum = async () => {
const num : Response<number> = await queryCartNum();
cartStore.setCartNum(num?.data || 0);
}
/** 去拼单购买 */
const handleSplicingOrders = (teamId : number) => {
state.teamId = teamId;
handlePinTuan('去拼单');
}
/** 关闭sku弹框 */
const handleChangePopup = (show : boolean) => {
state.showSku = show;
}
/** 单独购买 */
const handleSingleBuy = () => {
_useLoginStore.checkLogin(() => {
state.teamId = 0;
state.showSku = true;
state.isSingleBuy = true;
state.btnBuyTitlt = '单独购买';
state.goodsDetailData.skuList.sku_list = state.defaultSkuList;
});
}
/** 立即购买购买 */
async function onBuyNow({ productId, nums } : any) {
if (state.isSingleBuy) {
await handleSingleQuery(productId, nums)
} else {
await handleMultipleQuery(productId, nums)
}
}
/** 拼团购买 */
const handleMultipleBuy = () => {
_useLoginStore.checkLogin(() => {
state.teamId = 0;
state.showSku = true;
state.isSingleBuy = false;
state.btnBuyTitlt = '发起拼团';
state.goodsDetailData.skuList.sku_list = state.activitySkuList;
});
}
/** 处理单个购买请求 */
const handleSingleQuery = async (productId : number, nums : number) => {
const addCart : Response<number> = await queryAddCart({
ProductId: productId,
Nums: nums,
type: PaymentTypeEnum.pinTuan,
cartType: PaymentTypeEnum.common,
});
if (addCart.status) {
handleRouteNavigateTo(`/pages/order/submit/submit?cartIds=${addCart.data}`)
/** 关闭sku弹框 */
handleChangePopup(false);
} else {
handleShowToast(addCart.msg);
}
}
/** 去拼单 */
const handleSplicingOrders = (teamId : number) => {
state.teamId = teamId;
handleMultipleBuy();
}
/** 处理拼团购买请求 */
const handleMultipleQuery = async (productId : number, nums : number) => {
const addCart : Response<number> = await queryAddCart({
ProductId: productId,
Nums: nums,
type: PaymentTypeEnum.pinTuan,
cartType: PaymentTypeEnum.pinTuan,
objectId: state.id,
teamId: state.teamId
});
if (addCart.status) {
handleRouteNavigateTo(`/pages/order/submit/submit?cartIds=${addCart.data}&orderType=${PaymentTypeEnum.pinTuan}&objectId=${state.id}${state.teamId != 0 ? `&teamId=${state.teamId}` : ''}`)
/** 关闭sku弹框 */
handleChangePopup(false);
} else {
handleShowToast(addCart.msg);
}
}
/** 关闭sku弹框 */
const handleChangePopup = (show : boolean) => {
state.showSku = show;
}
/** 立即购买购买 */
async function onBuyNow({ productId, nums } : any) {
if (state.isSingleBuy) {
await handleSingleQuery(productId, nums)
} else {
await handleMultipleQuery(productId, nums)
}
}
/** 处理单个购买请求 */
const handleSingleQuery = async (productId : number, nums : number) => {
const addCart : Response<number> = await queryAddCart({
ProductId: productId,
Nums: nums,
type: PaymentTypeEnum.pinTuan,
cartType: PaymentTypeEnum.common,
});
if (addCart.status) {
handleRouteNavigateTo(`/pages/order/submit/submit?cartIds=${addCart.data}`)
/** 关闭sku弹框 */
handleChangePopup(false);
} else {
handleShowToast(addCart.msg);
}
}
/** 处理拼团购买请求 */
const handleMultipleQuery = async (productId : number, nums : number) => {
const addCart : Response<number> = await queryAddCart({
ProductId: productId,
Nums: nums,
type: PaymentTypeEnum.pinTuan,
cartType: PaymentTypeEnum.pinTuan,
objectId: state.id,
teamId: state.teamId
});
if (addCart.status) {
handleRouteNavigateTo(`/pages/order/submit/submit?cartIds=${addCart.data}&orderType=${PaymentTypeEnum.pinTuan}&objectId=${state.id}${state.teamId != 0 ? `&teamId=${state.teamId}` : ''}`)
/** 关闭sku弹框 */
handleChangePopup(false);
} else {
handleShowToast(addCart.msg);
}
}
/** 分享 */
onShareAppMessage(() => {
return {
title: state.goodsDetailData.name,
imageUrl: state.goodsDetailData.image,
path: state.shareUrl
}
});
onShareTimeline(() => {
return {
title: state.goodsDetailData.name,
imageUrl: state.goodsDetailData.image,
path: state.shareUrl
}
});
/** 分享 */
onShareAppMessage(() => {
return {
title: state.goodsDetailData.name,
imageUrl: state.goodsDetailData.image,
path: state.shareUrl
}
});
onShareTimeline(() => {
return {
title: state.goodsDetailData.name,
imageUrl: state.goodsDetailData.image,
path: state.shareUrl
}
});
</script>
<style lang="scss" scoped>
@import './detail.scss';
@import './detail.scss';
</style>

View File

@@ -99,10 +99,10 @@
<script setup lang="ts">
import { reactive, ref } from 'vue';
import { onLoad, onShareAppMessage, onShareTimeline, onPullDownRefresh } from '@dcloudio/uni-app';
import { querySolitaireDetail, queryShare, queryAddCart, queryRemoveCart } from '@/core/api';
import { querySolitaireDetail, queryAddCart, queryRemoveCart } from '@/core/api';
import { ShareClientEnum, ShareModelEnum, ShareEnum, EmptyEnum, PaymentTypeEnum, AddCartEnum } from '@/core/enum';
import type { Response } from '@/core/models';
import { UserToken, shareUrl } from '@/core/consts'
import { shareUrl } from '@/core/consts'
import { useShopConfigStore, useLoginStore } from '@/core/store';
import { handleShowToast, handleRouteNavigateTo, getShareUrl } from '@/core/utils';
import { timeFormat } from '@/uni_modules/uv-ui-tools/libs/function/index.js';