|
@@ -114,7 +114,7 @@
|
|
|
// eslint-disable-next-line no-undef
|
|
|
import { getProductList } from '@/api/product'
|
|
|
import { getUserInfo } from '@/api/user'
|
|
|
-import { aliPayCoin } from '@/api/pay'
|
|
|
+import { aliPayCoin, aliPayH5 } from '@/api/pay'
|
|
|
import { getDevicePayWayId, getPlatformType } from '@/utils/config'
|
|
|
|
|
|
export default {
|
|
@@ -290,22 +290,29 @@ export default {
|
|
|
productId: product.id
|
|
|
}
|
|
|
|
|
|
- // 调用支付宝支付接口
|
|
|
- const res = await aliPayCoin(payData, platform)
|
|
|
+ // 调用支付宝H5支付接口
|
|
|
+ const res = await aliPayH5(payData, platform)
|
|
|
this.$toast.clear()
|
|
|
this.isLoading = false
|
|
|
|
|
|
- // 处理支付结果
|
|
|
- if (res.code === 200) {
|
|
|
- // 支付宝支付成功,通常会返回一个支付链接或表单
|
|
|
- if (res.data && res.data.payUrl) {
|
|
|
- // 跳转到支付宝支付页面
|
|
|
- window.location.href = res.data.payUrl
|
|
|
- } else {
|
|
|
- this.$toast.fail('获取支付链接失败')
|
|
|
- }
|
|
|
+ // 处理HTML表单响应
|
|
|
+ if (typeof res === 'string' && res.includes('<form')) {
|
|
|
+ // 创建一个div来放置表单
|
|
|
+ const div = document.createElement('div')
|
|
|
+ div.innerHTML = res
|
|
|
+ document.body.appendChild(div)
|
|
|
+
|
|
|
+ // 自动提交表单
|
|
|
+ setTimeout(() => {
|
|
|
+ const form = div.querySelector('form')
|
|
|
+ if (form) {
|
|
|
+ form.submit()
|
|
|
+ } else {
|
|
|
+ this.$toast.fail('支付表单加载失败')
|
|
|
+ }
|
|
|
+ }, 100)
|
|
|
} else {
|
|
|
- this.$toast.fail(res.message || '支付请求失败')
|
|
|
+ this.$toast.fail('获取支付表单失败')
|
|
|
}
|
|
|
} catch (error) {
|
|
|
this.$toast.clear()
|