提交 ff90a660 authored 作者: haodaking's avatar haodaking

优化支付

上级 fd70082d
...@@ -8,7 +8,7 @@ export default class API { ...@@ -8,7 +8,7 @@ export default class API {
// 让ajax携带cookie // 让ajax携带cookie
axios.defaults.withCredentials = true axios.defaults.withCredentials = true
this._axios = axios.create({ this._axios = axios.create({
timeout: config.timeout || 5 * 1000, timeout: config.timeout || 60 * 1000,
/* 表示服务器响应的数据类型,可以是 'arraybuffer', 'blob', 'document', 'json', 'text', 'stream' */ /* 表示服务器响应的数据类型,可以是 'arraybuffer', 'blob', 'document', 'json', 'text', 'stream' */
responseType: config.resType || 'json', responseType: config.resType || 'json',
/* 将自动加在 `url` 前面,除非 `url` 是一个绝对 URL */ /* 将自动加在 `url` 前面,除非 `url` 是一个绝对 URL */
......
<template> <template>
<div class="h5pay"> <div class="h5pay">
<el-button type="primary" @click="handlePay">去支付</el-button> <el-button type="primary" @click="handlePay" :disabled="disabled">去支付</el-button>
</div> </div>
</template> </template>
...@@ -9,7 +9,9 @@ import * as api from '@/api/my' ...@@ -9,7 +9,9 @@ import * as api from '@/api/my'
export default { export default {
data() { data() {
return { return {
openId: window.localStorage.getItem('open_id') openId: window.localStorage.getItem('open_id'),
order: {},
disabled: false
} }
}, },
computed: { computed: {
...@@ -20,16 +22,22 @@ export default { ...@@ -20,16 +22,22 @@ export default {
methods: { methods: {
// 获取订单 // 获取订单
getOrder(callback) { getOrder(callback) {
api.getOrder({ wx_open_id: this.openId, payment_method: 'WX_PAY' }).then(response => { this.disabled = true
const { data, error, message } = response api
if (error.toString() === '0') { .getOrder({ wx_open_id: this.openId, payment_method: 'WX_PAY' })
this.order = data .then(response => {
this.$emit('update', this.order) const { data, error, message } = response
callback && callback(this.order) if (error.toString() === '0') {
} else { this.order = data
this.$message.error(message) this.$emit('update', this.order)
} callback && callback(this.order)
}) } else {
this.$message.error(message)
}
})
.finally(() => {
this.disabled = false
})
}, },
// 获取微信code // 获取微信code
getCode() { getCode() {
......
...@@ -106,7 +106,7 @@ export default { ...@@ -106,7 +106,7 @@ export default {
return return
} }
this.orderList.forEach(order => this.checkPay(order)) this.orderList.forEach(order => this.checkPay(order))
}, 3000) }, 10000)
}, },
// 填写个人资料 // 填写个人资料
toApplication() { toApplication() {
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论