feat(custom): build
This commit is contained in:
@@ -11,13 +11,14 @@
|
||||
>
|
||||
<view class="div">
|
||||
<view style="text-align: center">支付方式</view>
|
||||
<nut-cell-group>
|
||||
<nut-cell-group
|
||||
:style="{ margin: interval ? '40rpx 0 150rpx 0' : '40rpx 0' }"
|
||||
>
|
||||
<nut-cell
|
||||
v-if="payType === 'wx'"
|
||||
title="微信支付"
|
||||
desc="使用微信快捷支付"
|
||||
is-link
|
||||
@click="goPay()"
|
||||
@click="goPay(1)"
|
||||
>
|
||||
<template v-slot:icon>
|
||||
<IconFont
|
||||
@@ -27,11 +28,10 @@
|
||||
</template>
|
||||
</nut-cell>
|
||||
<nut-cell
|
||||
v-if="payType === 'jf'"
|
||||
title="积分支付"
|
||||
:desc="`剩余积分:${info.integral || 0}`"
|
||||
is-link
|
||||
@click="goPay()"
|
||||
@click="goPay(2)"
|
||||
>
|
||||
<template v-slot:icon>
|
||||
<IconFont
|
||||
@@ -50,26 +50,28 @@ import { ref, watch } from "vue";
|
||||
import { IconFont } from "@nutui/icons-vue-taro";
|
||||
import Taro from "@tarojs/taro";
|
||||
import { payOrder } from "@/api/order";
|
||||
import { payJfOrder } from "@/api/goods";
|
||||
import { getPersonalInfo } from "@/api/user";
|
||||
|
||||
const prop = defineProps({
|
||||
interval: {
|
||||
type: Boolean,
|
||||
default: true,
|
||||
},
|
||||
isShowPay: {
|
||||
required: true,
|
||||
type: Boolean,
|
||||
default: false,
|
||||
},
|
||||
payType: {
|
||||
required: true,
|
||||
type: String,
|
||||
default: "wx",
|
||||
},
|
||||
jfInfo: {
|
||||
type: Object,
|
||||
default: () => {
|
||||
return {};
|
||||
},
|
||||
},
|
||||
OrderType: {
|
||||
type: Number,
|
||||
default: 1,
|
||||
},
|
||||
});
|
||||
|
||||
const emit = defineEmits(["closePay", "successPay"]);
|
||||
@@ -96,61 +98,67 @@ const getInfo = async () => {
|
||||
}
|
||||
};
|
||||
|
||||
const goPay = async () => {
|
||||
console.log(prop.jfInfo);
|
||||
const goPay = async (type: number) => {
|
||||
console.log(prop);
|
||||
if (!prop.jfInfo)
|
||||
return Taro.showToast({
|
||||
title: "未获取到订单信息",
|
||||
icon: "none",
|
||||
});
|
||||
if (prop.payType === "wx") {
|
||||
try {
|
||||
const { data } = await payOrder({
|
||||
oid: prop.jfInfo.oid,
|
||||
});
|
||||
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,
|
||||
});
|
||||
Taro.navigateTo({
|
||||
url: "/pages/hotGoods/hot_list/index",
|
||||
});
|
||||
},
|
||||
fail: function () {
|
||||
Taro.showToast({
|
||||
title: "支付失败",
|
||||
icon: "none",
|
||||
duration: 2000,
|
||||
});
|
||||
},
|
||||
});
|
||||
emit("closePay", false);
|
||||
} catch (e) {
|
||||
try {
|
||||
const { data } = await payOrder({
|
||||
oid: prop.jfInfo,
|
||||
OrderType: prop.OrderType,
|
||||
PayType: type,
|
||||
});
|
||||
if (data.data) {
|
||||
// 1微信支付 2积分支付
|
||||
if (type === 1) {
|
||||
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: "success",
|
||||
duration: 2000,
|
||||
});
|
||||
emit("successPay", false);
|
||||
}
|
||||
} else {
|
||||
Taro.showToast({
|
||||
title: e.msg,
|
||||
title: "未知异常",
|
||||
icon: "none",
|
||||
});
|
||||
throw e;
|
||||
emit("closePay", false);
|
||||
}
|
||||
} else {
|
||||
const res = await payJfOrder(prop.jfInfo);
|
||||
} catch (e) {
|
||||
Taro.showToast({
|
||||
title: res.msg,
|
||||
icon: "success",
|
||||
duration: 2000,
|
||||
title: e.msg,
|
||||
icon: "none",
|
||||
});
|
||||
Taro.navigateTo({
|
||||
url: "/pages/users/order_list/index?type=0",
|
||||
});
|
||||
emit("closePay", false);
|
||||
// emit("closePay", false);
|
||||
throw e;
|
||||
}
|
||||
};
|
||||
|
||||
@@ -166,13 +174,13 @@ const closePay = () => {
|
||||
<style lang="scss">
|
||||
.nut-popup {
|
||||
.nut-popup__container {
|
||||
border-radius: 10px;
|
||||
border-radius: 10rpx;
|
||||
}
|
||||
}
|
||||
|
||||
.div {
|
||||
padding: 20px;
|
||||
// text-align: center;
|
||||
padding: 20rpx;
|
||||
--nut-cell-box-shadow: none;
|
||||
|
||||
.nut-cell {
|
||||
align-items: center;
|
||||
|
||||
Reference in New Issue
Block a user