i
This commit is contained in:
@@ -1,134 +1,151 @@
|
||||
<template>
|
||||
<nut-popup
|
||||
position="bottom"
|
||||
closeable
|
||||
round
|
||||
safe-area-inset-bottom
|
||||
:close-on-click-overlay="false"
|
||||
:style="{ height: 'auto' }"
|
||||
v-model:visible="isShowPay"
|
||||
@click-close-icon="closePay"
|
||||
>
|
||||
<view class="div">
|
||||
<view style="text-align: center">支付方式</view>
|
||||
<nut-cell-group>
|
||||
<nut-cell
|
||||
v-if="payType === 'wx'"
|
||||
title="微信支付"
|
||||
desc="使用微信快捷支付"
|
||||
is-link
|
||||
@click="goPay()"
|
||||
>
|
||||
<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
|
||||
v-if="payType === 'jf'"
|
||||
title="积分支付"
|
||||
desc="剩余积分:18888"
|
||||
is-link
|
||||
@click="goPay()"
|
||||
>
|
||||
<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-group>
|
||||
</view>
|
||||
</nut-popup>
|
||||
<nut-popup
|
||||
position="bottom"
|
||||
closeable
|
||||
round
|
||||
safe-area-inset-bottom
|
||||
:close-on-click-overlay="false"
|
||||
:style="{ height: 'auto' }"
|
||||
v-model:visible="isShowPay"
|
||||
@click-close-icon="closePay"
|
||||
>
|
||||
<view class="div">
|
||||
<view style="text-align: center">支付方式</view>
|
||||
<nut-cell-group>
|
||||
<nut-cell
|
||||
v-if="payType === 'wx'"
|
||||
title="微信支付"
|
||||
desc="使用微信快捷支付"
|
||||
is-link
|
||||
@click="goPay()"
|
||||
>
|
||||
<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
|
||||
v-if="payType === 'jf'"
|
||||
title="积分支付"
|
||||
desc="剩余积分:18888"
|
||||
is-link
|
||||
@click="goPay()"
|
||||
>
|
||||
<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-group>
|
||||
</view>
|
||||
</nut-popup>
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
import {IconFont} from '@nutui/icons-vue-taro'
|
||||
import Taro from '@tarojs/taro'
|
||||
import {payOrder} from '@/api/order'
|
||||
import {payJfOrder} from '@/api/goods'
|
||||
import { IconFont } from "@nutui/icons-vue-taro";
|
||||
import Taro from "@tarojs/taro";
|
||||
import { payOrder } from "@/api/order";
|
||||
import { payJfOrder } from "@/api/goods";
|
||||
|
||||
const prop = defineProps({
|
||||
isShowPay: {
|
||||
required: true,
|
||||
type: Boolean,
|
||||
default: false
|
||||
},
|
||||
payType: {
|
||||
required: true,
|
||||
type: String,
|
||||
default: 'wx'
|
||||
},
|
||||
jfInfo: {
|
||||
type: Object,
|
||||
default: () => {
|
||||
return {}
|
||||
}
|
||||
}
|
||||
})
|
||||
isShowPay: {
|
||||
required: true,
|
||||
type: Boolean,
|
||||
default: false,
|
||||
},
|
||||
payType: {
|
||||
required: true,
|
||||
type: String,
|
||||
default: "wx",
|
||||
},
|
||||
jfInfo: {
|
||||
type: Object,
|
||||
default: () => {
|
||||
return {};
|
||||
},
|
||||
},
|
||||
});
|
||||
|
||||
const emit = defineEmits(['closePay'])
|
||||
const emit = defineEmits(["closePay"]);
|
||||
|
||||
const goPay = async () => {
|
||||
if (prop.payType === 'wx') {
|
||||
try {
|
||||
const {data} = await payOrder({gid: 1, token: Taro.getStorageSync('token')})
|
||||
Taro.requestPayment({
|
||||
timeStamp: data.data.timeStamp,
|
||||
nonceStr: data.data.nonceStr,
|
||||
package: data.data.package,
|
||||
signType: data.data.signType,
|
||||
paySign: data.data.paySign,
|
||||
success: function (res) {
|
||||
console.log(res)
|
||||
},
|
||||
fail: function (res) {
|
||||
console.log(res)
|
||||
if (!prop.jfInfo)
|
||||
return Taro.showToast({
|
||||
title: "未获取到订单信息",
|
||||
icon: "none",
|
||||
});
|
||||
if (prop.payType === "wx") {
|
||||
try {
|
||||
console.log(prop.jfInfo);
|
||||
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 (res) {
|
||||
console.log(res);
|
||||
Taro.showToast({
|
||||
title: "支付成功",
|
||||
icon: "success",
|
||||
duration: 2000,
|
||||
});
|
||||
},
|
||||
fail: function (res) {
|
||||
console.log(res);
|
||||
Taro.showToast({
|
||||
title: "支付失败",
|
||||
icon: "none",
|
||||
duration: 2000,
|
||||
});
|
||||
},
|
||||
});
|
||||
} catch (e) {
|
||||
Taro.showToast({
|
||||
title: e.msg,
|
||||
icon: "none",
|
||||
});
|
||||
}
|
||||
})
|
||||
} catch (e) {
|
||||
Taro.showToast({
|
||||
title: e.msg,
|
||||
icon: 'none'
|
||||
})
|
||||
} else {
|
||||
const res = await payJfOrder(prop.jfInfo);
|
||||
Taro.showToast({
|
||||
title: res.msg,
|
||||
icon: "success",
|
||||
duration: 2000,
|
||||
});
|
||||
}
|
||||
} else {
|
||||
if (!prop.jfInfo) return Taro.showToast({
|
||||
title: '未获取到订单信息',
|
||||
icon: 'none'
|
||||
})
|
||||
console.log(prop.jfInfo)
|
||||
const res = await payJfOrder(prop.jfInfo)
|
||||
Taro.showToast({
|
||||
title: res.msg,
|
||||
icon: 'success',
|
||||
duration: 2000
|
||||
})
|
||||
}
|
||||
emit('closePay', false)
|
||||
}
|
||||
emit("closePay", false);
|
||||
};
|
||||
|
||||
const closePay = () => {
|
||||
emit('closePay', false)
|
||||
}
|
||||
Taro.showToast({
|
||||
title: "取消支付",
|
||||
icon: "none",
|
||||
});
|
||||
emit("closePay", false);
|
||||
};
|
||||
</script>
|
||||
|
||||
<style lang="scss">
|
||||
.nut-popup {
|
||||
.nut-popup__container {
|
||||
border-radius: 10px;
|
||||
}
|
||||
.nut-popup__container {
|
||||
border-radius: 10px;
|
||||
}
|
||||
}
|
||||
|
||||
.div {
|
||||
padding: 20px;
|
||||
// text-align: center;
|
||||
padding: 20px;
|
||||
// text-align: center;
|
||||
|
||||
.nut-cell {
|
||||
align-items: center;
|
||||
}
|
||||
.nut-cell {
|
||||
align-items: center;
|
||||
}
|
||||
}
|
||||
</style>
|
||||
|
||||
Reference in New Issue
Block a user