feat(custom): 新增后结订单
This commit is contained in:
74
src/components/Back.vue
Normal file
74
src/components/Back.vue
Normal file
@@ -0,0 +1,74 @@
|
||||
<template>
|
||||
<view class="head-wrapper" :style="{ top: BarHeight + 'px' }">
|
||||
<view class="head-menu">
|
||||
<Left class="iconfont" @click="returns" />
|
||||
<view class="line"></view>
|
||||
<Home class="iconfont" @click="goHome" />
|
||||
</view>
|
||||
<text class="title">{{ props.title }}</text>
|
||||
</view>
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
import Taro from "@tarojs/taro";
|
||||
import { computed } from "vue";
|
||||
import { Home, Left } from "@nutui/icons-vue-taro";
|
||||
|
||||
const statusBarHeight = Taro.getSystemInfoSync()?.statusBarHeight as number;
|
||||
const BarHeight = computed(() => statusBarHeight - 7);
|
||||
|
||||
const props = defineProps({
|
||||
title: {
|
||||
type: String,
|
||||
default: "",
|
||||
},
|
||||
});
|
||||
|
||||
const returns = () => {
|
||||
Taro.navigateBack({
|
||||
delta: 1,
|
||||
});
|
||||
};
|
||||
|
||||
const goHome = () => {
|
||||
Taro.switchTab({
|
||||
url: "/pages/index/index",
|
||||
});
|
||||
};
|
||||
</script>
|
||||
|
||||
<style lang="scss">
|
||||
.head-wrapper {
|
||||
z-index: 999;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
position: fixed;
|
||||
left: 30px;
|
||||
height: 114px;
|
||||
}
|
||||
|
||||
.head-menu {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
height: 54px;
|
||||
width: 140px;
|
||||
background: rgba(0, 0, 0, 0.25);
|
||||
border-radius: 27px;
|
||||
.line {
|
||||
width: 1px;
|
||||
height: 25px;
|
||||
background: #fff;
|
||||
}
|
||||
.iconfont {
|
||||
flex: 1;
|
||||
text-align: center;
|
||||
color: #fff;
|
||||
box-sizing: border-box;
|
||||
}
|
||||
}
|
||||
|
||||
.title {
|
||||
width: 410px;
|
||||
text-align: center;
|
||||
}
|
||||
</style>
|
||||
@@ -4,6 +4,7 @@ import Taro from "@tarojs/taro";
|
||||
import { addCart, getCart, clearCart } from "@/api/cart";
|
||||
import { Del2 } from "@nutui/icons-vue-taro";
|
||||
import { createActiveOrder } from "@/api/goods";
|
||||
import { createAfterOrder } from "@/api/admin";
|
||||
import Pay from "@/components/Pay.vue";
|
||||
|
||||
interface CardList {
|
||||
@@ -23,6 +24,11 @@ const props = defineProps({
|
||||
required: true,
|
||||
type: Object,
|
||||
},
|
||||
IsPendingOrder: {
|
||||
required: true,
|
||||
type: Boolean,
|
||||
default: false,
|
||||
},
|
||||
});
|
||||
|
||||
const emit = defineEmits(["updateCart"]);
|
||||
@@ -75,6 +81,7 @@ const get_cart_list = async () => {
|
||||
const res = await getCart({
|
||||
Bid: props.merInfo.bid,
|
||||
});
|
||||
|
||||
card_list.value = res.data.data || [];
|
||||
cartInfo.value = {
|
||||
count: 0,
|
||||
@@ -124,20 +131,36 @@ const closePay = (val: boolean) => {
|
||||
|
||||
const create_order = async () => {
|
||||
try {
|
||||
const { data: res } = await createActiveOrder({
|
||||
Bid: [props.merInfo.bid],
|
||||
});
|
||||
if (res.oid) {
|
||||
orderData.value = res.oid;
|
||||
isShowPay.value = true;
|
||||
show.value = false;
|
||||
let res;
|
||||
if (props.IsPendingOrder) {
|
||||
const data = props.merInfo;
|
||||
delete data.$taroTimestamp;
|
||||
delete data.type;
|
||||
res = await createAfterOrder(data);
|
||||
await get_cart_list();
|
||||
Taro.navigateTo({
|
||||
url: `/pages/admin/add_order/pending_order/pending_order_detail/index?oid=${props.merInfo.oid}&bid=${props.merInfo.bid}`,
|
||||
});
|
||||
} else {
|
||||
res = await createActiveOrder({
|
||||
Bid: [props.merInfo.bid],
|
||||
});
|
||||
if (res.data.oid) {
|
||||
orderData.value = res.oid;
|
||||
isShowPay.value = true;
|
||||
}
|
||||
}
|
||||
Taro.showToast({
|
||||
title: res.msg,
|
||||
icon: "none",
|
||||
});
|
||||
} catch (e) {
|
||||
Taro.showToast({
|
||||
title: e.msg,
|
||||
icon: "none",
|
||||
});
|
||||
}
|
||||
// await get_cart_list();
|
||||
};
|
||||
|
||||
defineExpose({
|
||||
|
||||
@@ -14,11 +14,37 @@
|
||||
<nut-cell-group
|
||||
:style="{ margin: interval ? '40rpx 0 150rpx 0' : '40rpx 0' }"
|
||||
>
|
||||
<nut-cell
|
||||
title="微信支付"
|
||||
desc="使用微信快捷支付"
|
||||
<nut-cell
|
||||
title="微信支付"
|
||||
desc="使用微信快捷支付"
|
||||
is-link
|
||||
@click="goPay(1)"
|
||||
>
|
||||
<template v-slot:icon>
|
||||
<IconFont
|
||||
size="30"
|
||||
name="https://img11.360buyimg.com/imagetools/jfs/t1/137646/13/7132/1648/5f4c748bE43da8ddd/a3f06d51dcae7b60.png"
|
||||
/>
|
||||
</template>
|
||||
</nut-cell>
|
||||
<nut-cell
|
||||
title="积分支付"
|
||||
:desc="`剩余积分:${info.integral || 0}`"
|
||||
is-link
|
||||
@click="goPay(2)"
|
||||
>
|
||||
<template v-slot:icon>
|
||||
<IconFont
|
||||
size="30"
|
||||
name="https://img11.360buyimg.com/imagetools/jfs/t1/137646/13/7132/1648/5f4c748bE43da8ddd/a3f06d51dcae7b60.png"
|
||||
/>
|
||||
</template>
|
||||
</nut-cell>
|
||||
<!-- <nut-cell
|
||||
title="挂帐后结"
|
||||
desc="先消费后结账"
|
||||
is-link
|
||||
@click="goPay(1)"
|
||||
@click="goPay(3)"
|
||||
>
|
||||
<template v-slot:icon>
|
||||
<IconFont
|
||||
@@ -26,20 +52,7 @@
|
||||
name="https://img11.360buyimg.com/imagetools/jfs/t1/137646/13/7132/1648/5f4c748bE43da8ddd/a3f06d51dcae7b60.png"
|
||||
/>
|
||||
</template>
|
||||
</nut-cell>
|
||||
<nut-cell
|
||||
title="积分支付"
|
||||
:desc="`剩余积分:${info.integral || 0}`"
|
||||
is-link
|
||||
@click="goPay(2)"
|
||||
>
|
||||
<template v-slot:icon>
|
||||
<IconFont
|
||||
size="30"
|
||||
name="https://img11.360buyimg.com/imagetools/jfs/t1/137646/13/7132/1648/5f4c748bE43da8ddd/a3f06d51dcae7b60.png"
|
||||
/>
|
||||
</template>
|
||||
</nut-cell>
|
||||
</nut-cell> -->
|
||||
</nut-cell-group>
|
||||
</view>
|
||||
</nut-popup>
|
||||
@@ -106,51 +119,58 @@ const goPay = async (type: number) => {
|
||||
icon: "none",
|
||||
});
|
||||
try {
|
||||
const { data } = await payOrder({
|
||||
oid: prop.jfInfo,
|
||||
OrderType: prop.OrderType,
|
||||
PayType: type,
|
||||
});
|
||||
// 1微信支付 2积分支付
|
||||
if (type === 1) {
|
||||
if (data.data) {
|
||||
Taro.requestPayment({
|
||||
timeStamp: data.data.timeStamp,
|
||||
nonceStr: data.data.nonceStr,
|
||||
package: data.data.package,
|
||||
signType: data.data.signType,
|
||||
paySign: data.data.paySign,
|
||||
success: function () {
|
||||
Taro.showToast({
|
||||
title: "支付成功",
|
||||
icon: "success",
|
||||
duration: 2000,
|
||||
});
|
||||
emit("successPay", false);
|
||||
},
|
||||
fail: function () {
|
||||
Taro.showToast({
|
||||
title: "支付失败",
|
||||
icon: "none",
|
||||
duration: 2000,
|
||||
});
|
||||
emit("closePay", false);
|
||||
},
|
||||
});
|
||||
} else {
|
||||
// 1微信支付 2积分支付 3挂帐
|
||||
if (type === 1 || type === 2) {
|
||||
const { data } = await payOrder({
|
||||
oid: prop.jfInfo,
|
||||
OrderType: prop.OrderType,
|
||||
PayType: type,
|
||||
});
|
||||
if (type === 1) {
|
||||
if (data.data) {
|
||||
Taro.requestPayment({
|
||||
timeStamp: data.data.timeStamp,
|
||||
nonceStr: data.data.nonceStr,
|
||||
package: data.data.package,
|
||||
signType: data.data.signType,
|
||||
paySign: data.data.paySign,
|
||||
success: function () {
|
||||
Taro.showToast({
|
||||
title: "支付成功",
|
||||
icon: "success",
|
||||
duration: 2000,
|
||||
});
|
||||
emit("successPay", false);
|
||||
},
|
||||
fail: function () {
|
||||
Taro.showToast({
|
||||
title: "支付失败",
|
||||
icon: "none",
|
||||
duration: 2000,
|
||||
});
|
||||
emit("closePay", false);
|
||||
},
|
||||
});
|
||||
} else {
|
||||
Taro.showToast({
|
||||
title: "未知异常",
|
||||
icon: "none",
|
||||
});
|
||||
emit("closePay", false);
|
||||
}
|
||||
} else if (type === 2) {
|
||||
Taro.showToast({
|
||||
title: "未知异常",
|
||||
icon: "none",
|
||||
title: "支付成功",
|
||||
icon: "success",
|
||||
duration: 2000,
|
||||
});
|
||||
emit("closePay", false);
|
||||
emit("successPay", false);
|
||||
}
|
||||
} else {
|
||||
Taro.showToast({
|
||||
title: "支付成功",
|
||||
icon: "success",
|
||||
duration: 2000,
|
||||
title: "挂帐后结账",
|
||||
icon: "none",
|
||||
});
|
||||
emit("successPay", false);
|
||||
}
|
||||
} catch (e) {
|
||||
Taro.showToast({
|
||||
|
||||
Reference in New Issue
Block a user