uniapp【新增】: 新增添加购物车,提交订单,立即购买,代理,分销店铺设置,订单支付,秒杀详情立即购买,团购详情立即购买,团购详情购买操作,收货地址提交,订单售后提交 添加loading 禁用多次点击状态

This commit is contained in:
bob bob
2024-10-20 03:47:37 +00:00
parent d03c10df8b
commit 18f06d0d47
16 changed files with 213 additions and 106 deletions

View File

@@ -1,7 +1,7 @@
<template> <template>
<view class="btn" :style="{'border-radius':radiusComp,'background-color':props.backgroundColor,'color':props.color}" @click="onClick()"> <uv-button :text="props.title" :loading="props.loading"
{{props.title}} :custom-style="{'border-radius':radiusComp,'height':'100%','width':'100%','background-color':props.backgroundColor,'color':props.color,...customStyleComp}"
</view> @click="onClick()"></uv-button>
</template> </template>
<script setup lang="ts"> <script setup lang="ts">
@@ -14,26 +14,31 @@
radius ?: number; radius ?: number;
backgroundColor ?: string; backgroundColor ?: string;
color ?: string; color ?: string;
loading : boolean;
customStyle ?: { [key : string] : any }
}>(), { }>(), {
title: '保存', title: '保存',
radius: 44, radius: 44,
backgroundColor: '#D33123', backgroundColor: '#D33123',
color: '#FFFFFF' color: '#FFFFFF',
loading: false,
}) })
const radiusComp = computed(() => `${props.radius}px`); const radiusComp = computed(() => `${props.radius}px`);
const customStyleComp = computed(() => {
return props.customStyle || { 'height': '88rpx' };
});
const onClick = () => { const onClick = () => {
emits('onClick'); emits('onClick');
} }
</script> </script>
<style lang="scss" scoped> <style lang="scss" scoped>
.btn { // .base-btn {
display: flex; // display: flex;
align-items: center; // align-items: center;
justify-content: center; // justify-content: center;
height: 88rpx; // height: 88rpx;
font-size: 32rpx; // font-size: 32rpx;
} // }
</style> </style>

View File

@@ -101,9 +101,6 @@
</view> </view>
</view> </view>
</view> </view>
<!-- 登录提示 -->
<!-- <coreshop-login-modal></coreshop-login-modal> -->
</view> </view>
</template> </template>
@@ -313,12 +310,8 @@
/** 去购买 */ /** 去购买 */
const handleGoToBuy = () => { const handleGoToBuy = () => {
let ids : Array<number> = []; const ids : Array<number>= state.cartList.filter(x=>x.select).map(x=>x.id);
state.cartList.forEach((item : CartListType) => {
if (item.select) {
ids.push(item.id)
}
})
if (ids.length > 0) { if (ids.length > 0) {
handleRouteNavigateTo(`/pages/order/submit/submit?cartIds=${ids.join(',')}`) handleRouteNavigateTo(`/pages/order/submit/submit?cartIds=${ids.join(',')}`)
} else { } else {

View File

@@ -96,8 +96,8 @@
<!-- 商品sku弹框 --> <!-- 商品sku弹框 -->
<GoodsDetailSkuPopup :showSku="state.showSku" :goodsDetailData="state.goodsDetailData" <GoodsDetailSkuPopup :showSku="state.showSku" :goodsDetailData="state.goodsDetailData"
:safeAreaInsetBottom="false" @handleChangePopup="handleChangePopup" @handleAddCart="handleAddCart" :safeAreaInsetBottom="false" :buyNowNowloading="buyNowLoading" :addCartloading="addCartLoading"
@handleBuyNow="handleBuyNow"> @handleChangePopup="handleChangePopup" @handleAddCart="handleAddCart" @handleBuyNow="handleBuyNow">
</GoodsDetailSkuPopup> </GoodsDetailSkuPopup>
<!-- 头部大分类的弹框 --> <!-- 头部大分类的弹框 -->
@@ -131,6 +131,7 @@
import { getDomInfo, handleStaticResources, handleRouteNavigateTo, handleShowToast, handleRouteSwitchTab } from '@/core/utils'; import { getDomInfo, handleStaticResources, handleRouteNavigateTo, handleShowToast, handleRouteSwitchTab } from '@/core/utils';
import { AddCartEnum, PaymentTypeEnum, RouteSwitchTabEnum } from '@/core/enum'; import { AddCartEnum, PaymentTypeEnum, RouteSwitchTabEnum } from '@/core/enum';
import GoodsDetailSkuPopup from '@/pages/components/goods-detail/components/goods-detail-sku/goods-detail-sku.vue'; import GoodsDetailSkuPopup from '@/pages/components/goods-detail/components/goods-detail-sku/goods-detail-sku.vue';
import { useLoadingFn } from '@/core/hooks';
const instance = getCurrentInstance(); const instance = getCurrentInstance();
@@ -185,6 +186,13 @@
goodsDetailData: {}, goodsDetailData: {},
}); });
const buyNowLoading = ref(false);
const addCartLoading = ref(false);
const handleBuyNow = useLoadingFn(onBuyNow, buyNowLoading);
const handleAddCart = useLoadingFn(onAddCart, addCartLoading)
watch(() => props.data, (newVal : Array<CategoriesType>) => { watch(() => props.data, (newVal : Array<CategoriesType>) => {
if (newVal) { if (newVal) {
state.classifyData = newVal.map((item : CategoriesType) => { state.classifyData = newVal.map((item : CategoriesType) => {
@@ -277,7 +285,7 @@
} }
/** 添加购物车 */ /** 添加购物车 */
const handleAddCart = async ({ productId, nums } : any) => { async function onAddCart({ productId, nums } : any) {
const addCart : Response<number> = await queryAddCart({ const addCart : Response<number> = await queryAddCart({
productId, productId,
nums, nums,
@@ -295,7 +303,7 @@
} }
/** 立即购买 */ /** 立即购买 */
const handleBuyNow = async ({ productId, nums } : any) => { async function onBuyNow({ productId, nums } : any) {
const addCart : Response<number> = await queryAddCart({ const addCart : Response<number> = await queryAddCart({
productId, productId,
nums, nums,

View File

@@ -67,15 +67,15 @@
<!-- 商品sku弹框 --> <!-- 商品sku弹框 -->
<GoodsDetailSkuPopup :showSku="state.showSku" :goodsDetailData="state.goodsDetailData" <GoodsDetailSkuPopup :showSku="state.showSku" :goodsDetailData="state.goodsDetailData"
:safeAreaInsetBottom="false" @handleChangePopup="handleChangePopup" @handleAddCart="handleAddCart" :safeAreaInsetBottom="false" :buyNowNowloading="buyNowLoading" :addCartloading="addCartLoading"
@handleBuyNow="handleBuyNow"> @handleChangePopup="handleChangePopup" @handleAddCart="handleAddCart" @handleBuyNow="handleBuyNow">
</GoodsDetailSkuPopup> </GoodsDetailSkuPopup>
</view> </view>
</template> </template>
<script setup lang="ts"> <script setup lang="ts">
import { reactive, watch } from 'vue'; import { reactive, ref, watch } from 'vue';
import { onShow } from '@dcloudio/uni-app'; import { onShow } from '@dcloudio/uni-app';
import { UserToken, advertPosition, onClassifyPageHide } from '@/core/consts'; import { UserToken, advertPosition, onClassifyPageHide } from '@/core/consts';
import { queryGoodsPageList, queryCartNumAndMoney, queryGoodsDetailByToken, queryGoodsDetail, queryAddCart } from '@/core/api'; import { queryGoodsPageList, queryCartNumAndMoney, queryGoodsDetailByToken, queryGoodsDetail, queryAddCart } from '@/core/api';
@@ -84,6 +84,7 @@
import { useLoginStore } from '@/core/store' import { useLoginStore } from '@/core/store'
import { AddCartEnum, PaymentTypeEnum, RouteSwitchTabEnum } from '@/core/enum'; import { AddCartEnum, PaymentTypeEnum, RouteSwitchTabEnum } from '@/core/enum';
import GoodsDetailSkuPopup from '@/pages/components/goods-detail/components/goods-detail-sku/goods-detail-sku.vue'; import GoodsDetailSkuPopup from '@/pages/components/goods-detail/components/goods-detail-sku/goods-detail-sku.vue';
import { useLoadingFn } from '@/core/hooks';
/** 登录store */ /** 登录store */
const _useLoginStore = useLoginStore(); const _useLoginStore = useLoginStore();
@@ -122,6 +123,12 @@
goodsDetailData: {}, goodsDetailData: {},
}); });
const buyNowLoading = ref(false);
const addCartLoading = ref(false);
const handleBuyNow = useLoadingFn(onBuyNow, buyNowLoading);
const handleAddCart = useLoadingFn(onAddCart, addCartLoading)
watch(() => props.data, (newVal : Array<CategoriesType>) => { watch(() => props.data, (newVal : Array<CategoriesType>) => {
if (newVal) { if (newVal) {
state.classifyData = newVal.map((item : CategoriesType) => { state.classifyData = newVal.map((item : CategoriesType) => {
@@ -202,7 +209,7 @@
} }
/** 添加购物车 */ /** 添加购物车 */
const handleAddCart = async ({ productId, nums } : any) => { async function onAddCart({ productId, nums } : any) {
const addCart : Response<number> = await queryAddCart({ const addCart : Response<number> = await queryAddCart({
productId, productId,
nums, nums,
@@ -211,7 +218,7 @@
if (addCart.status) { if (addCart.status) {
handleShowToast(addCart.msg, 'success'); handleShowToast(addCart.msg, 'success');
/** 添加成功后,重新获取购物车数量和价格 */ /** 添加成功后,重新获取购物车数量和价格 */
getCartNumAndMoney(); await getCartNumAndMoney();
/** 关闭sku弹框 */ /** 关闭sku弹框 */
handleChangePopup(false); handleChangePopup(false);
} else { } else {
@@ -220,7 +227,7 @@
} }
/** 立即购买 */ /** 立即购买 */
const handleBuyNow = async ({ productId, nums } : any) => { async function onBuyNow({ productId, nums } : any) {
const addCart : Response<number> = await queryAddCart({ const addCart : Response<number> = await queryAddCart({
productId, productId,
nums, nums,

View File

@@ -108,4 +108,15 @@
.buy-now { .buy-now {
background-color: #d33123; background-color: #d33123;
} }
.core-button-confirm{
flex: 1;
font-size: 27rpx;
text-align: center;
color: #fff;
height: 90rpx;
}
coreshop-button{
display: block;
height: 90rpx;
}
} }

View File

@@ -30,8 +30,16 @@
@change="handleChangeNumberVal"></uv-number-box> @change="handleChangeNumberVal"></uv-number-box>
</view> </view>
<view class="btn-box"> <view class="btn-box">
<view v-if="props.isShowAddCartBtn" class="btn add-cart" @click="handleAddCart">加入购物车</view> <!-- <view v-if="props.isShowAddCartBtn" class="btn add-cart" @click="handleAddCart">加入购物车</view> -->
<view class="btn buy-now" @click="handleBuyNow">{{ props.btnBuyTitlt }}</view> <view v-if="props.isShowAddCartBtn" class="core-button-confirm add-cart">
<coreshop-button :loading="props.addCartloading" class="core-button-confirm_" :radius="0" title="加入购物车"
:customStyle="addCartCustomStyle" @onClick="handleAddCart()"></coreshop-button>
</view>
<!-- <view class="btn buy-now" @click="handleBuyNow">{{ props.btnBuyTitlt }}</view> -->
<view class="core-button-confirm">
<coreshop-button :loading="props.buyNowNowloading" class="core-button-confirm_" :radius="0"
:title="props.btnBuyTitlt" :customStyle="buyNowCustomStyle" @onClick="handleBuyNow()"></coreshop-button>
</view>
</view> </view>
</view> </view>
</uv-popup> </uv-popup>
@@ -43,18 +51,50 @@
import { handleStaticResources, handleShowToast } from '@/core/utils'; import { handleStaticResources, handleShowToast } from '@/core/utils';
import { deepClone } from '@/uni_modules/uv-ui-tools/libs/function/index.js'; import { deepClone } from '@/uni_modules/uv-ui-tools/libs/function/index.js';
const buyNowCustomStyle = {
'border': 'none',
'background-color': '#d33123',
'flex': 1,
'padding': '32rpx 0',
'font-size': '27rpx',
'text-align': 'center',
'color': '#fff',
'height': '90rpx'
}
const addCartCustomStyle = {
...buyNowCustomStyle,
'background-color': '#000',
}
const props = withDefaults(defineProps<{ const props = withDefaults(defineProps<{
showSku : boolean, showSku : boolean,
goodsDetailData : any, goodsDetailData : any,
isShowAddCartBtn : boolean, isShowAddCartBtn : boolean,
btnBuyTitlt : string, btnBuyTitlt : string,
safeAreaInsetBottom : boolean; safeAreaInsetBottom : boolean;
buyNowCustomStyle : { [key : string] : any },
buyNowNowloading : boolean,
addCartloading : boolean
}>(), { }>(), {
showSku: false, showSku: false,
goodsDetailData: {}, goodsDetailData: {},
isShowAddCartBtn: true, isShowAddCartBtn: true,
btnBuyTitlt: '立即购买', btnBuyTitlt: '立即购买',
safeAreaInsetBottom: true, safeAreaInsetBottom: true,
buyNowCustomStyle: {
'border': 'none',
'background-color': '#d33123',
'flex': 1,
'padding': '25rpx 0',
'font-size': '27rpx',
'text-align': 'center',
'color': '#fff',
'height': '90rpx'
},
buyNowNowloading: false,
addCartloading: false
}); });
const emits = defineEmits(['handleChangePopup', 'handleAddCart', 'handleBuyNow', 'handleChangeGoodSku']); const emits = defineEmits(['handleChangePopup', 'handleAddCart', 'handleBuyNow', 'handleChangeGoodSku']);
@@ -116,12 +156,12 @@
const handleChangeNumberVal = (e : any) => { const handleChangeNumberVal = (e : any) => {
state.numberVal = e.value; state.numberVal = e.value;
} }
/** sku弹框显示或者隐藏 */ /** sku弹框显示或者隐藏 */
const handleChangePopup = (e : any) => { const handleChangePopup = (e : any) => {
emits('handleChangePopup', e.show) emits('handleChangePopup', e.show)
} }
/** sku选择 */ /** sku选择 */
const handleChooseSku = (index : number, sku : GoodsSpecListType) => { const handleChooseSku = (index : number, sku : GoodsSpecListType) => {
let chooseSku : GoodsSkuListType = {}; // 选中的sku let chooseSku : GoodsSkuListType = {}; // 选中的sku
@@ -163,7 +203,7 @@
}); });
} }
/** 立即购买 */ /** 立即购买 */
const handleBuyNow = () => { const handleBuyNow = () => {
if (!handleHaveStock()) { if (!handleHaveStock()) {
@@ -174,7 +214,7 @@
nums: state.numberVal, nums: state.numberVal,
}); });
} }
/** 判断库存 */ /** 判断库存 */
const handleHaveStock = () => { const handleHaveStock = () => {
if (state.chooseSku.stock === 0) { if (state.chooseSku.stock === 0) {

View File

@@ -19,7 +19,7 @@
</view> </view>
</template> </template>
<script setup lang="ts"> <script setup lang="ts">
import { reactive, watch } from 'vue'; import { Ref, reactive, watch } from 'vue';
import { PayMethodCodeEnum, PaymentTypeEnum } from '@/core/enum'; import { PayMethodCodeEnum, PaymentTypeEnum } from '@/core/enum';
import { handleStaticResources, handleShowToast, handleRouteRedirectTo } from '@/core/utils'; import { handleStaticResources, handleShowToast, handleRouteRedirectTo } from '@/core/utils';
import type { PayMethodListType, Response } from '@/core/models'; import type { PayMethodListType, Response } from '@/core/models';
@@ -64,13 +64,13 @@
if (props.orderType === PaymentTypeEnum.recharge) { if (props.orderType === PaymentTypeEnum.recharge) {
payMethodList = payMethodList.filter(item => item.code !== 'balancepay' || !item.isOnline); payMethodList = payMethodList.filter(item => item.code !== 'balancepay' || !item.isOnline);
} }
/** 当支付方式只有一个的时候,默认选择 */ /** 当支付方式只有一个的时候,默认选择 */
if(payMethodList.length == 1){ if (payMethodList.length == 1) {
state.payCode = payMethodList[0].code; state.payCode = payMethodList[0].code;
emits('handleSelectPay', payMethodList[0].code); emits('handleSelectPay', payMethodList[0].code);
} }
state.payMethodList = payMethodList; state.payMethodList = payMethodList;
} }
}) })
@@ -118,7 +118,7 @@
) )
} }
const handlePayNow = async () => { const handlePayNow = async (loading : Ref<boolean>) => {
uni.showLoading({ uni.showLoading({
title: '加载中', title: '加载中',
}); });
@@ -150,18 +150,20 @@
const pay : Response<any> = await queryPay(data); const pay : Response<any> = await queryPay(data);
if (pay.status) { if (pay.status) {
if (state.payCode === PayMethodCodeEnum.wechatpay) { if (state.payCode === PayMethodCodeEnum.wechatpay) {
handleWxpay(pay); handleWxpay(pay, loading);
} else if (state.payCode === PayMethodCodeEnum.alipay) { } else if (state.payCode === PayMethodCodeEnum.alipay) {
handleAlipay(pay); handleAlipay(pay, loading);
} else if (state.payCode === PayMethodCodeEnum.balancepay) { } else if (state.payCode === PayMethodCodeEnum.balancepay) {
uni.hideLoading(); uni.hideLoading();
handleShowToast('支付成功', 'success', () => { handleShowToast('支付成功', 'success', () => {
setTimeout(() => { setTimeout(() => {
loading.value = false;
handleRouteRedirectTo(`/pages/order/result/result?id=${pay.data.paymentId}`) handleRouteRedirectTo(`/pages/order/result/result?id=${pay.data.paymentId}`)
}, 1000) }, 1000)
}) })
} else if (state.payCode === PayMethodCodeEnum.offline) { } else if (state.payCode === PayMethodCodeEnum.offline) {
uni.hideLoading(); uni.hideLoading();
loading.value = false;
uni.showModal({ uni.showModal({
title: '线下支付说明', title: '线下支付说明',
content: '请联系客服进行线下支付', content: '请联系客服进行线下支付',
@@ -170,6 +172,7 @@
} }
} else { } else {
handleShowToast(pay.msg, 'none', () => { handleShowToast(pay.msg, 'none', () => {
loading.value = false;
setTimeout(() => { setTimeout(() => {
uni.hideLoading(); uni.hideLoading();
}, 1000); }, 1000);
@@ -179,7 +182,7 @@
} }
/** 微信支付 */ /** 微信支付 */
const handleWxpay = (res : any) => { const handleWxpay = (res : any, loading : Ref<boolean>) => {
uni.requestPayment({ uni.requestPayment({
provider: 'wxpay', provider: 'wxpay',
// #ifdef MP-WEIXIN // #ifdef MP-WEIXIN
@@ -208,6 +211,7 @@
if (e.errMsg === 'requestPayment:ok') { if (e.errMsg === 'requestPayment:ok') {
handleShowToast('支付成功', 'success', () => { handleShowToast('支付成功', 'success', () => {
setTimeout(() => { setTimeout(() => {
loading.value = false;
handleRouteRedirectTo(`/pages/order/result/result?id=${res.data.paymentId}`) handleRouteRedirectTo(`/pages/order/result/result?id=${res.data.paymentId}`)
}, 1000) }, 1000)
}) })
@@ -217,12 +221,14 @@
// #ifdef APP-PLUS || APP-PLUS-NVUE // #ifdef APP-PLUS || APP-PLUS-NVUE
handleShowToast('支付成功', 'success', () => { handleShowToast('支付成功', 'success', () => {
setTimeout(() => { setTimeout(() => {
loading.value = false;
handleRouteRedirectTo(`/pages/order/result/result?id=${res.data.paymentId}`) handleRouteRedirectTo(`/pages/order/result/result?id=${res.data.paymentId}`)
}, 1000) }, 1000)
}) })
// #endif // #endif
}, },
fail: function (e : any) { fail: function (e : any) {
loading.value = false;
if (e.errMsg === 'requestPayment:fail cancel') { if (e.errMsg === 'requestPayment:fail cancel') {
handleShowToast('您已经取消此方式支付,可继续选择其他方式支付。'); handleShowToast('您已经取消此方式支付,可继续选择其他方式支付。');
} }
@@ -234,7 +240,7 @@
} }
/** 支付宝支付 */ /** 支付宝支付 */
const handleAlipay = (res : any) => { const handleAlipay = (res : any, loading : Ref<boolean>) => {
uni.requestPayment({ uni.requestPayment({
provider: 'alipay', provider: 'alipay',
orderInfo: res.data.tradeNo, orderInfo: res.data.tradeNo,
@@ -243,6 +249,7 @@
if (e.errMsg === 'requestPayment:ok') { if (e.errMsg === 'requestPayment:ok') {
handleShowToast('支付成功', 'success', () => { handleShowToast('支付成功', 'success', () => {
setTimeout(() => { setTimeout(() => {
loading.value = false;
handleRouteRedirectTo(`/pages/order/result/result?id=${res.data.paymentId}`) handleRouteRedirectTo(`/pages/order/result/result?id=${res.data.paymentId}`)
}, 1000) }, 1000)
}) })
@@ -252,12 +259,14 @@
// #ifdef APP-PLUS || APP-PLUS-NVUE // #ifdef APP-PLUS || APP-PLUS-NVUE
handleShowToast('支付成功', 'success', () => { handleShowToast('支付成功', 'success', () => {
setTimeout(() => { setTimeout(() => {
loading.value = false;
handleRouteRedirectTo(`/pages/order/result/result?id=${res.data.paymentId}`) handleRouteRedirectTo(`/pages/order/result/result?id=${res.data.paymentId}`)
}, 1000) }, 1000)
}) })
// #endif // #endif
}, },
fail: function (res) { fail: function (res) {
loading.value = false;
console.log(res); console.log(res);
} }
}); });

View File

@@ -72,11 +72,8 @@
<view class="tips-box">如果您在支付中选择的支付方式不适合或异常请再次选择其他支付方式</view> <view class="tips-box">如果您在支付中选择的支付方式不适合或异常请再次选择其他支付方式</view>
<!-- 底部按钮 --> <!-- 底部按钮 -->
<view class="fixed-box"> <coreshop-fixed-bottom-button title="立即支付" @onClick="onPayNow()"
<view class="fixed-btn"> :loading="loading"></coreshop-fixed-bottom-button>
<view class="btn-box" @click="handlePayNow">立即支付</view>
</view>
</view>
</view> </view>
</coreshop-page> </coreshop-page>
</template> </template>
@@ -98,7 +95,7 @@
} }
const payMethod = ref(); const payMethod = ref();
const loading = ref(false);
const state = reactive<{ const state = reactive<{
payMethodList : Array<PayMethodListType>; payMethodList : Array<PayMethodListType>;
payCode : string; payCode : string;
@@ -241,9 +238,11 @@
} }
/** 立即支付 */ /** 立即支付 */
const handlePayNow = () => { async function onPayNow() {
if (state.payCode) { if (state.payCode) {
payMethod.value.handlePayNow() loading.value = true;
payMethod.value.handlePayNow(loading);
console.log('xxx');
} else { } else {
handleShowToast('请选择支付方式'); handleShowToast('请选择支付方式');
} }

View File

@@ -226,7 +226,8 @@
<text>{{ state.cartData?.amount }}</text> <text>{{ state.cartData?.amount }}</text>
</view> </view>
</view> </view>
<view class="btn" @click="handleSubmit">确认下单</view> <coreshop-button class="btn" title="确认下单" @onClick="handleSubmit" :loading="loading"
:customStyle="{'border':'none','height':'90rpx'}"></coreshop-button>
</view> </view>
</view> </view>
</view> </view>
@@ -234,7 +235,7 @@
</coreshop-page> </coreshop-page>
</template> </template>
<script setup lang="ts"> <script setup lang="ts">
import { reactive, computed } from 'vue'; import { reactive, computed, ref } from 'vue';
import { onLoad, onShow } from '@dcloudio/uni-app'; import { onLoad, onShow } from '@dcloudio/uni-app';
import { import {
PaymentTypeEnum, OrderDistributionEnum, ShowStoresSwitchEnum, PaymentTypeEnum, OrderDistributionEnum, ShowStoresSwitchEnum,
@@ -247,6 +248,7 @@
import { mobile } from '@/uni_modules/uv-ui-tools/libs/function/test.js'; import { mobile } from '@/uni_modules/uv-ui-tools/libs/function/test.js';
import { handleRouteNavigateTo, handleShowToast, handleRouteRedirectTo } from '@/core/utils'; import { handleRouteNavigateTo, handleShowToast, handleRouteRedirectTo } from '@/core/utils';
import { addressUserShip, userInvoice, userStore } from '@/core/consts'; import { addressUserShip, userInvoice, userStore } from '@/core/consts';
import { useLoadingFn } from '@/core/hooks';
interface QueryParams { interface QueryParams {
cartIds ?: string; cartIds ?: string;
@@ -257,7 +259,6 @@
/** 获取项目配置 */ /** 获取项目配置 */
const shopConfigStore : ShopConfigStoreType = useShopConfigStore(); const shopConfigStore : ShopConfigStoreType = useShopConfigStore();
const state = reactive<{ const state = reactive<{
orderType : PaymentTypeEnum; // 订单类型 orderType : PaymentTypeEnum; // 订单类型
tabList : Array<{ // 送达方式 tabList : Array<{ // 送达方式
@@ -308,6 +309,8 @@
couponCodeList: [], couponCodeList: [],
}); });
const loading = ref(false);
const handleSubmit = useLoadingFn(onSubmit, loading);
/** 是否显示积分兑换价合计 */ /** 是否显示积分兑换价合计 */
const isShowPointRedemptionPrice = computed(() => { const isShowPointRedemptionPrice = computed(() => {
@@ -512,7 +515,7 @@
} else { } else {
state.couponCodeList.push(item.couponCode); state.couponCodeList.push(item.couponCode);
} }
getCartList({ getCartList({
success() { success() {
item.checked = !item.checked; item.checked = !item.checked;
@@ -561,7 +564,7 @@
} }
/** 立即购买 */ /** 立即购买 */
const handleSubmit = async () => { async function onSubmit() {
let delivery : any = {}; let delivery : any = {};
/** 如果是快递物流 / 同城送货 */ /** 如果是快递物流 / 同城送货 */
if (state.tabSelectType === OrderDistributionEnum.mailing || state.tabSelectType == OrderDistributionEnum.homeDelivery) { if (state.tabSelectType === OrderDistributionEnum.mailing || state.tabSelectType == OrderDistributionEnum.homeDelivery) {

View File

@@ -54,14 +54,14 @@
<!-- 商品sku弹框 --> <!-- 商品sku弹框 -->
<GoodsDetailSkuPopup :showSku="state.showSku" :goodsDetailData="state.goodsDetailData" <GoodsDetailSkuPopup :showSku="state.showSku" :goodsDetailData="state.goodsDetailData"
:isShowAddCartBtn="false" btnBuyTitlt="立即团购" @handleChangePopup="handleChangePopup" :isShowAddCartBtn="false" :buyNowNowloading="loading" btnBuyTitlt="立即团购"
@handleBuyNow="handleSeckillNow"></GoodsDetailSkuPopup> @handleChangePopup="handleChangePopup" @handleBuyNow="handleBuyNow"></GoodsDetailSkuPopup>
</view> </view>
</coreshop-page> </coreshop-page>
</template> </template>
<script setup lang="ts"> <script setup lang="ts">
import { reactive } from 'vue'; import { reactive, ref } from 'vue';
import { onLoad, onShareAppMessage, onShareTimeline } from '@dcloudio/uni-app'; import { onLoad, onShareAppMessage, onShareTimeline } from '@dcloudio/uni-app';
import { queryActivityDetial, queryCartNum, queryShare, queryAddCart } from '@/core/api'; import { queryActivityDetial, queryCartNum, queryShare, queryAddCart } from '@/core/api';
import { PaymentTypeEnum, ShareClientEnum, ShareModelEnum, ShareEnum } from '@/core/enum'; import { PaymentTypeEnum, ShareClientEnum, ShareModelEnum, ShareEnum } from '@/core/enum';
@@ -69,12 +69,11 @@
import { UserToken, shareUrl } from '@/core/consts' import { UserToken, shareUrl } from '@/core/consts'
import { useCartStore, useLoginStore } from '@/core/store'; import { useCartStore, useLoginStore } from '@/core/store';
import { handleShowToast, handleRouteNavigateTo } from '@/core/utils'; import { handleShowToast, handleRouteNavigateTo } from '@/core/utils';
import GoodsDetail from '@/pages/components/goods-detail/index.vue'; 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 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 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 GoodsDetailBottomTabbar from '@/pages/components/goods-detail/components/goods-detail-bottom-tabbar/goods-detail-bottom-tabbar.vue';
import { useLoadingFn } from '@/core/hooks';
interface QueryParams { interface QueryParams {
id : number; id : number;
} }
@@ -117,6 +116,9 @@
} }
}); });
const loading = ref(false);
const handleBuyNow = useLoadingFn(onBuyNow, loading)
onLoad((query : QueryParams) => { onLoad((query : QueryParams) => {
state.id = Number(query.id); state.id = Number(query.id);
/** 获取商品详情 */ /** 获取商品详情 */
@@ -177,7 +179,7 @@
} }
/** 立即秒杀 */ /** 立即秒杀 */
const handleSeckillNow = async ({ productId, nums } : any) => { async function onBuyNow({ productId, nums } : any) {
const addCart : Response<number> = await queryAddCart({ const addCart : Response<number> = await queryAddCart({
ProductId: productId, ProductId: productId,
Nums: nums, Nums: nums,

View File

@@ -3,7 +3,7 @@
<view class="goods-detail"> <view class="goods-detail">
<!-- 商品详情 --> <!-- 商品详情 -->
<GoodsDetail :goodsId="state.goodsDetailData?.id" :goodsDetailData="state.goodsDetailData" <GoodsDetail :goodsId="state.goodsDetailData?.id" :goodsDetailData="state.goodsDetailData"
:swiperBanner="state.swiperBanner" :shareType="ShareEnum.pinTuan" :swiperBanner="state.swiperBanner" :shareType="ShareEnum.pinTuan"
:goodsDetailContent="state.goodsDetailContent" :isActivityGoods="true"> :goodsDetailContent="state.goodsDetailContent" :isActivityGoods="true">
<template #activityGoodsOtheService> <template #activityGoodsOtheService>
<view class="pinTuan-record" v-if="state.goodsDetailData?.pinTuanRecord?.length > 0"> <view class="pinTuan-record" v-if="state.goodsDetailData?.pinTuanRecord?.length > 0">
@@ -62,14 +62,14 @@
<!-- 商品sku弹框 --> <!-- 商品sku弹框 -->
<GoodsDetailSkuPopup :showSku="state.showSku" :goodsDetailData="state.goodsDetailData" <GoodsDetailSkuPopup :showSku="state.showSku" :goodsDetailData="state.goodsDetailData"
:isShowAddCartBtn="false" @handleChangePopup="handleChangePopup" @handleBuyNow="handleBuyNow" :isShowAddCartBtn="false" :buyNowNowloading="loading" @handleChangePopup="handleChangePopup" @handleBuyNow="handleBuyNow"
:btnBuyTitlt="state.btnBuyTitlt"> :btnBuyTitlt="state.btnBuyTitlt">
</GoodsDetailSkuPopup> </GoodsDetailSkuPopup>
</view> </view>
</coreshop-page> </coreshop-page>
</template> </template>
<script setup lang="ts"> <script setup lang="ts">
import { reactive } from 'vue'; import { reactive, ref } from 'vue';
import { onLoad } from '@dcloudio/uni-app'; import { onLoad } from '@dcloudio/uni-app';
import { queryPinTuanGoodsDetail, queryCartNum, queryAddCart, queryOrderPinTuanTeamInfo } from '@/core/api'; import { queryPinTuanGoodsDetail, queryCartNum, queryAddCart, queryOrderPinTuanTeamInfo } from '@/core/api';
import type { Response } from '@/core/models'; import type { Response } from '@/core/models';
@@ -83,6 +83,7 @@
import GoodsDetailRecommend from '@/pages/components/goods-detail/components/goods-detail-recommend/goods-detail-recommend.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 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 GoodsDetailBottomTabbar from '@/pages/components/goods-detail/components/goods-detail-bottom-tabbar/goods-detail-bottom-tabbar.vue';
import { useLoadingFn } from '@/core/hooks';
interface QueryParams { interface QueryParams {
id : number; id : number;
@@ -107,7 +108,7 @@
teamId : number; teamId : number;
isSingleBuy : boolean; isSingleBuy : boolean;
btnBuyTitlt : string; btnBuyTitlt : string;
teamInfo : any; teamInfo : any;
}>({ }>({
id: 0, id: 0,
goodsDetailData: {}, goodsDetailData: {},
@@ -120,9 +121,12 @@
teamId: 0, teamId: 0,
isSingleBuy: true, isSingleBuy: true,
btnBuyTitlt: "发起拼团", btnBuyTitlt: "发起拼团",
teamInfo: {}, teamInfo: {},
}); });
const loading = ref(false);
const handleBuyNow = useLoadingFn(onBuyNow, loading)
onLoad((query : QueryParams) => { onLoad((query : QueryParams) => {
if (query?.teamId) { if (query?.teamId) {
state.goodsDetailData = { state.goodsDetailData = {
@@ -193,7 +197,7 @@
state.isSingleBuy = true; state.isSingleBuy = true;
state.btnBuyTitlt = '单独购买'; state.btnBuyTitlt = '单独购买';
state.goodsDetailData.skuList.sku_list = state.defaultSkuList; state.goodsDetailData.skuList.sku_list = state.defaultSkuList;
}); });
} }
/** 拼团购买 */ /** 拼团购买 */
@@ -204,7 +208,7 @@
state.isSingleBuy = false; state.isSingleBuy = false;
state.btnBuyTitlt = '发起拼团'; state.btnBuyTitlt = '发起拼团';
state.goodsDetailData.skuList.sku_list = state.activitySkuList; state.goodsDetailData.skuList.sku_list = state.activitySkuList;
}); });
} }
/** 去拼单 */ /** 去拼单 */
@@ -219,11 +223,11 @@
} }
/** 立即购买购买 */ /** 立即购买购买 */
const handleBuyNow = async ({ productId, nums } : any) => { async function onBuyNow({ productId, nums } : any) {
if (state.isSingleBuy) { if (state.isSingleBuy) {
handleSingleQuery(productId, nums) await handleSingleQuery(productId, nums)
} else { } else {
handleMultipleQuery(productId, nums) await handleMultipleQuery(productId, nums)
} }
} }
@@ -261,7 +265,7 @@
} else { } else {
handleShowToast(addCart.msg); handleShowToast(addCart.msg);
} }
} }
</script> </script>
<style lang="scss" scoped> <style lang="scss" scoped>
@import './detail.scss'; @import './detail.scss';

View File

@@ -3,7 +3,7 @@
<view class="goods-detail"> <view class="goods-detail">
<!-- 商品详情 --> <!-- 商品详情 -->
<GoodsDetail :goodsId="state.goodsDetailData?.id" :goodsDetailData="state.goodsDetailData" <GoodsDetail :goodsId="state.goodsDetailData?.id" :goodsDetailData="state.goodsDetailData"
:swiperBanner="state.swiperBanner" :spesDesc="state.spesDesc" :swiperBanner="state.swiperBanner" :spesDesc="state.spesDesc"
:goodsDetailContent="state.goodsDetailContent" :isActivityGoods="true" :shareType="ShareEnum.seckill" :goodsDetailContent="state.goodsDetailContent" :isActivityGoods="true" :shareType="ShareEnum.seckill"
@hanldeShowGoodSku="hanldeShowGoodSku"> @hanldeShowGoodSku="hanldeShowGoodSku">
<template #tip> <template #tip>
@@ -54,32 +54,33 @@
<!-- 商品sku弹框 --> <!-- 商品sku弹框 -->
<GoodsDetailSkuPopup :showSku="state.showSku" :goodsDetailData="state.goodsDetailData" <GoodsDetailSkuPopup :showSku="state.showSku" :goodsDetailData="state.goodsDetailData"
:isShowAddCartBtn="false" btnBuyTitlt="立即秒杀" @handleChangePopup="handleChangePopup" :isShowAddCartBtn="false" btnBuyTitlt="立即秒杀" :buyNowNowloading="loading"
@handleBuyNow="handleSeckillNow"></GoodsDetailSkuPopup> @handleChangePopup="handleChangePopup" @handleBuyNow="handleSeckillNow"></GoodsDetailSkuPopup>
</view> </view>
</coreshop-page> </coreshop-page>
</template> </template>
<script setup lang="ts"> <script setup lang="ts">
import { reactive } from 'vue'; import { reactive, ref } from 'vue';
import { onLoad, onShareAppMessage, onShareTimeline } from '@dcloudio/uni-app'; import { onLoad, onShareAppMessage, onShareTimeline } from '@dcloudio/uni-app';
import { queryActivityDetial, queryCartNum, queryShare, queryAddCart, queryUserInfo } from '@/core/api'; import { queryActivityDetial, queryCartNum, queryShare, queryAddCart, queryUserInfo } from '@/core/api';
import { PaymentTypeEnum, ShareClientEnum, ShareModelEnum, ShareEnum } from '@/core/enum'; import { PaymentTypeEnum, ShareClientEnum, ShareModelEnum, ShareEnum } from '@/core/enum';
import type { Response, UserInfoType } from '@/core/models'; import type { Response } from '@/core/models';
import { UserToken, shareUrl } from '@/core/consts' import { UserToken, shareUrl } from '@/core/consts'
import { useCartStore, useUserInfoStore ,useLoginStore} from '@/core/store'; import { useCartStore, useLoginStore } from '@/core/store';
import { handleShowToast, handleRouteNavigateTo } from '@/core/utils'; import { handleShowToast, handleRouteNavigateTo } from '@/core/utils';
import GoodsDetail from '@/pages/components/goods-detail/index.vue'; 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 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 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 GoodsDetailBottomTabbar from '@/pages/components/goods-detail/components/goods-detail-bottom-tabbar/goods-detail-bottom-tabbar.vue';
import { useLoadingFn } from '@/core/hooks';
interface QueryParams { interface QueryParams {
id : number; id : number;
} }
/** 登录store */ /** 登录store */
const _useLoginStore = useLoginStore(); const _useLoginStore = useLoginStore();
const cartStore = useCartStore(); const cartStore = useCartStore();
@@ -91,7 +92,7 @@
shareUrl : string; shareUrl : string;
id : number; id : number;
showTip : boolean; showTip : boolean;
spesDesc : string; spesDesc : string;
timeData : { timeData : {
days : number, days : number,
hours : number, hours : number,
@@ -106,7 +107,7 @@
shareUrl: "", shareUrl: "",
id: 0, id: 0,
showTip: true, showTip: true,
spesDesc: "", spesDesc: "",
timeData: { timeData: {
days: 0, days: 0,
hours: 0, hours: 0,
@@ -115,6 +116,9 @@
} }
}); });
const loading = ref(false);
const handleSeckillNow = useLoadingFn(onSeckillNow, loading)
onLoad((query : QueryParams) => { onLoad((query : QueryParams) => {
state.id = Number(query.id); state.id = Number(query.id);
/** 获取商品详情 */ /** 获取商品详情 */
@@ -171,11 +175,11 @@
const hanldeShowGoodSku = () => { const hanldeShowGoodSku = () => {
_useLoginStore.checkLogin(() => { _useLoginStore.checkLogin(() => {
state.showSku = true; state.showSku = true;
}); });
} }
/** 立即秒杀 */ /** 立即秒杀 */
const handleSeckillNow = async ({ productId, nums } : any) => { async function onSeckillNow({ productId, nums } : any) {
const addCart : Response<number> = await queryAddCart({ const addCart : Response<number> = await queryAddCart({
ProductId: productId, ProductId: productId,
Nums: nums, Nums: nums,
@@ -190,7 +194,7 @@
} else { } else {
handleShowToast(addCart.msg); handleShowToast(addCart.msg);
} }
} }
/** 获取分享url */ /** 获取分享url */
const getShareUrl = async () => { const getShareUrl = async () => {

View File

@@ -30,17 +30,18 @@
</view> </view>
</view> </view>
</view> </view>
<coreshop-fixed-bottom-button :radius="100" title="保存" <coreshop-fixed-bottom-button :radius="100" title="保存" :loading="loading"
@onClick="onConfirmStoreSet()"></coreshop-fixed-bottom-button> @onClick="hanldeConfirmStoreSet()"></coreshop-fixed-bottom-button>
</coreshop-page> </coreshop-page>
</template> </template>
<script setup lang="ts"> <script setup lang="ts">
import { reactive } from 'vue'; import { reactive, ref } from 'vue';
import { onLoad } from '@dcloudio/uni-app'; import { onLoad } from '@dcloudio/uni-app';
import { queryUploadImages, queryAgentInfo, queryAgentSetStore } from '@/core/api'; import { queryUploadImages, queryAgentInfo, queryAgentSetStore } from '@/core/api';
import type { Response } from '@/core/models'; import type { Response } from '@/core/models';
import { handleShowToast } from '@/core/utils'; import { handleShowToast } from '@/core/utils';
import { useLoadingFn } from '@/core/hooks/use-loading';
const state = reactive<{ const state = reactive<{
logoFile : Array<{ [key : string] : any }>; logoFile : Array<{ [key : string] : any }>;
@@ -54,6 +55,10 @@
storeDesc: null, storeDesc: null,
}) })
const loading = ref<boolean>(false);
const hanldeConfirmStoreSet = useLoadingFn(onConfirmStoreSet, loading);
onLoad(() => { onLoad(() => {
getAgentInfo(); getAgentInfo();
}); });
@@ -105,7 +110,7 @@
}; };
/** 保存 */ /** 保存 */
const onConfirmStoreSet = async () => { async function onConfirmStoreSet() {
if (!state.storeName) { if (!state.storeName) {
handleShowToast('请输入店铺名称'); return; handleShowToast('请输入店铺名称'); return;
} }

View File

@@ -30,17 +30,18 @@
</view> </view>
</view> </view>
</view> </view>
<coreshop-fixed-bottom-button :radius="100" title="保存" <coreshop-fixed-bottom-button :radius="100" title="保存" :loading="loading"
@onClick="onConfirmStoreSet()"></coreshop-fixed-bottom-button> @onClick="hanldeConfirmStoreSet()"></coreshop-fixed-bottom-button>
</coreshop-page> </coreshop-page>
</template> </template>
<script setup lang="ts"> <script setup lang="ts">
import { reactive } from 'vue'; import { reactive, ref } from 'vue';
import { onLoad } from '@dcloudio/uni-app'; import { onLoad } from '@dcloudio/uni-app';
import { queryUploadImages, queryDistributionInfo, querySetStore } from '@/core/api'; import { queryUploadImages, queryDistributionInfo, querySetStore } from '@/core/api';
import type { Response } from '@/core/models'; import type { Response } from '@/core/models';
import { handleShowToast } from '@/core/utils'; import { handleShowToast } from '@/core/utils';
import { useLoadingFn } from '@/core/hooks/use-loading';
const state = reactive<{ const state = reactive<{
logoFile : Array<{ [key : string] : any }>; logoFile : Array<{ [key : string] : any }>;
@@ -54,6 +55,10 @@
storeDesc: null, storeDesc: null,
}) })
const loading = ref<boolean>(false);
const hanldeConfirmStoreSet = useLoadingFn(onConfirmStoreSet, loading);
onLoad(() => { onLoad(() => {
getDistributionInfo(); getDistributionInfo();
}); });
@@ -105,7 +110,7 @@
}; };
/** 保存 */ /** 保存 */
const onConfirmStoreSet = async () => { async function onConfirmStoreSet() {
if (!state.storeName) { if (!state.storeName) {
handleShowToast('请输入店铺名称'); return; handleShowToast('请输入店铺名称'); return;
} }

View File

@@ -46,7 +46,7 @@
</view> </view>
</view> </view>
<coreshop-fixed-bottom-button :radius="100" title="保存" <coreshop-fixed-bottom-button :radius="100" title="保存" :loading="loading"
@onClick="handleSaveShip"></coreshop-fixed-bottom-button> @onClick="handleSaveShip"></coreshop-fixed-bottom-button>
<coreshop-select-city :show="state.showSelectCity" :pickerValue="state.pickerValue" <coreshop-select-city :show="state.showSelectCity" :pickerValue="state.pickerValue"
@@ -56,13 +56,14 @@
</coreshop-page> </coreshop-page>
</template> </template>
<script setup lang="ts"> <script setup lang="ts">
import { reactive } from 'vue'; import { reactive, ref } from 'vue';
import { onLoad, onShow, onUnload } from '@dcloudio/uni-app'; import { onLoad, onShow, onUnload } from '@dcloudio/uni-app';
import { AddressPageTitltEnum, ShowAllowAddressToUseMap } from '@/core/enum'; import { AddressPageTitltEnum, ShowAllowAddressToUseMap } from '@/core/enum';
import { queryAreaId, querySaveUserShip, queryShipDetail } from '@/core/api'; import { queryAreaId, querySaveUserShip, queryShipDetail } from '@/core/api';
import type { Response, ShopConfigStoreType, AddressType } from '@/core/models'; import type { Response, ShopConfigStoreType, AddressType } from '@/core/models';
import { useShopConfigStore } from '@/core/store'; import { useShopConfigStore } from '@/core/store';
import { handleShowToast } from '@/core/utils'; import { handleShowToast } from '@/core/utils';
import { useLoadingFn } from '@/core/hooks';
interface QueryParams { interface QueryParams {
type : string; type : string;
@@ -103,7 +104,7 @@
city: "", city: "",
longitude: 0, longitude: 0,
latitude: 0, latitude: 0,
region: ['湖南省', '怀化市', '鹤城区'], region: [],
shipId: 0, shipId: 0,
submitStatus: true, submitStatus: true,
pickerValue: '', pickerValue: '',
@@ -118,6 +119,11 @@
} }
}); });
const loading = ref(false);
const handleSaveShip = useLoadingFn(onSaveShip, loading)
onShow(() => { onShow(() => {
// #ifdef MP-WEIXIN // #ifdef MP-WEIXIN
const chooseLocation = requirePlugin('chooseLocation'); const chooseLocation = requirePlugin('chooseLocation');
@@ -278,7 +284,7 @@
} }
/** 提交地址 */ /** 提交地址 */
const handleSaveShip = async () => { async function onSaveShip() {
if (!state.submitStatus) { if (!state.submitStatus) {
return; return;
} }

View File

@@ -91,20 +91,23 @@
</view> </view>
<!-- 按钮 --> <!-- 按钮 -->
<view class="btn-box"> <!-- <view class="btn-box">
<view class="btn" @click="handlesubmit">提交</view> <view class="btn" @click="handlesubmit">提交</view>
</view> </view> -->
<coreshop-fixed-bottom-button :loading="loading" title="提交"
@onClick="handlesubmit()"></coreshop-fixed-bottom-button>
</view> </view>
</coreshop-page> </coreshop-page>
</template> </template>
<script setup lang="ts"> <script setup lang="ts">
import { reactive } from 'vue'; import { reactive, ref } from 'vue';
import { onLoad } from '@dcloudio/uni-app'; import { onLoad } from '@dcloudio/uni-app';
import { handleShowToast, handleRouteNavigateTo } from '@/core/utils'; import { handleShowToast, handleRouteNavigateTo } from '@/core/utils';
import { queryOrderDetails, queryUploadImages, queryAddAftersales } from '@/core/api'; import { queryOrderDetails, queryUploadImages, queryAddAftersales } from '@/core/api';
import type { Response } from '@/core/models'; import type { Response } from '@/core/models';
import { OrderAllStatusTypeEnum, OrderShipStatusEnum } from '@/core/enum'; import { OrderAllStatusTypeEnum, OrderShipStatusEnum } from '@/core/enum';
import { amount } from '@/uni_modules/uv-ui-tools/libs/function/test.js'; import { amount } from '@/uni_modules/uv-ui-tools/libs/function/test.js';
import { useLoadingFn } from '@/core/hooks';
enum RefundType { enum RefundType {
/** 仅退款 */ /** 仅退款 */
@@ -141,6 +144,9 @@
refundPrice: 0, refundPrice: 0,
}); });
const loading = ref(false);
const handlesubmit = useLoadingFn(onSubmit, loading)
onLoad((query : QueryParams) => { onLoad((query : QueryParams) => {
if (query?.orderId) { if (query?.orderId) {
state.orderId = query?.orderId; state.orderId = query?.orderId;
@@ -288,7 +294,7 @@
} }
/** 提交 */ /** 提交 */
const handlesubmit = async () => { async function onSubmit() {
if (!amount(state.refundPrice)) { if (!amount(state.refundPrice)) {
handleShowToast('请输入正确金额'); return; handleShowToast('请输入正确金额'); return;
} }