-
+
@@ -130,9 +140,10 @@
- 请打开手机支付宝扫码支付
+ 请打开手机{{ payName }}扫码支付
+
@@ -152,6 +163,7 @@ import RewardVerify from "@/components/RewardVerify.vue";
import {useRouter} from "vue-router";
import {removeUserToken} from "@/store/session";
import UserOrder from "@/components/UserOrder.vue";
+import CountDown from "@/components/CountDown.vue";
const listBoxHeight = window.innerHeight - 97
const list = ref([])
@@ -171,11 +183,15 @@ const isLogin = ref(false)
const router = useRouter()
const curPayProduct = ref(null)
const activeOrderNo = ref("")
-const countDown = ref(null)
+const countDownRef = ref(null)
const orderTimeout = ref(1800)
const loading = ref(true)
const orderPayInfoText = ref("")
+const payWays = ref({})
+const payName = ref("支付宝")
+const curPay = ref("alipay") // 当前支付方式
+
onMounted(() => {
checkSession().then(_user => {
@@ -200,9 +216,48 @@ onMounted(() => {
}).catch(e => {
ElMessage.error("获取系统配置失败:" + e.message)
})
+
+ httpGet("/api/payment/payWays").then(res => {
+ payWays.value = res.data
+ }).catch(e => {
+ ElMessage.error("获取支付方式失败:" + e.message)
+ })
})
-const orderPay = (row) => {
+// refresh payment qrcode
+const refreshPayCode = () => {
+ if (curPay.value === 'alipay') {
+ alipay()
+ } else if (curPay.value === 'hupi') {
+ huPiPay()
+ }
+}
+
+const genPayQrcode = () => {
+ loading.value = true
+ text.value = ""
+ httpPost("/api/payment/qrcode", {
+ pay_way: curPay.value,
+ product_id: curPayProduct.value.id,
+ user_id: user.value.id
+ }).then(res => {
+ showPayDialog.value = true
+ qrcode.value = res.data['image']
+ activeOrderNo.value = res.data['order_no']
+ queryOrder(activeOrderNo.value)
+ loading.value = false
+ // 重置计数器
+ if (countDownRef.value) {
+ countDownRef.value.resetTimer()
+ }
+ }).catch(e => {
+ ElMessage.error("生成支付订单失败:" + e.message)
+ })
+}
+
+const alipay = (row) => {
+ payName.value = "支付宝"
+ curPay.value = "alipay"
if (!user.value.id) {
showLoginDialog.value = true
return
@@ -210,21 +265,22 @@ const orderPay = (row) => {
if (row) {
curPayProduct.value = row
}
- loading.value = true
- text.value = ""
- httpPost("/api/payment/alipay/qrcode", {product_id: curPayProduct.value.id, user_id: user.value.id}).then(res => {
- showPayDialog.value = true
- qrcode.value = res.data['image']
- activeOrderNo.value = res.data['order_no']
- queryOrder(activeOrderNo.value)
- loading.value = false
- // 重置计数器
- if (countDown.value) {
- countDown.value.resetTimer()
- }
- }).catch(e => {
- ElMessage.error("生成支付订单失败:" + e.message)
- })
+ genPayQrcode()
+}
+
+// 虎皮椒支付
+const huPiPay = (row) => {
+ payName.value = payWays.value["hupi"]["name"] === "wechat" ? '微信' : '支付宝'
+ curPay.value = "hupi"
+ if (!user.value.id) {
+ showLoginDialog.value = true
+ return
+ }
+ if (row) {
+ curPayProduct.value = row
+ }
+ genPayQrcode()
+
}
const queryOrder = (orderNo) => {
@@ -416,6 +472,16 @@ const logout = function () {
}
}
+
+ .pay-way {
+ padding 10px 0
+ display flex
+ justify-content: space-between
+
+ .iconfont {
+ margin-right 5px
+ }
+ }
}
&:hover {