提交 585b11ba authored 作者: lihuihui's avatar lihuihui

updata

上级 12a7b545
...@@ -97,6 +97,10 @@ export default class API { ...@@ -97,6 +97,10 @@ export default class API {
window.G.$instance_vue.$router.replace({ window.G.$instance_vue.$router.replace({
path: '/pay' path: '/pay'
}) })
// const routeData = window.G.$instance_vue.$router.resolve({
// name: 'pay'
// })
// window.open(routeData.href, '_blank')
} }
} }
err = new Error(JSON.stringify(res.response)) err = new Error(JSON.stringify(res.response))
......
...@@ -3,10 +3,13 @@ ...@@ -3,10 +3,13 @@
<div class="pay-box"></div> <div class="pay-box"></div>
</template> </template>
<script> <script>
import { Toast } from 'vant'
import Pay from '../action' import Pay from '../action'
export default { export default {
name: 'PayH5', name: 'PayH5',
components: {}, components: {
[Toast.name]: Toast
},
data () { data () {
const _this = this const _this = this
return { return {
...@@ -108,7 +111,6 @@ export default { ...@@ -108,7 +111,6 @@ export default {
this.requestParam.nonceStr = res.data.options.nonceStr this.requestParam.nonceStr = res.data.options.nonceStr
this.requestParam.signType = res.data.options.signType this.requestParam.signType = res.data.options.signType
this.requestParam.paySign = res.data.options.paySign this.requestParam.paySign = res.data.options.paySign
this.wxWakeUpToPay(obj) this.wxWakeUpToPay(obj)
} else { } else {
obj.code = 3003 obj.code = 3003
...@@ -123,6 +125,14 @@ export default { ...@@ -123,6 +125,14 @@ export default {
}) })
}, },
wxWakeUpToPay (obj) { wxWakeUpToPay (obj) {
Toast(obj)
if (typeof WeixinJSBridge === 'undefined') {
obj.code = 4001
obj.msg = '缺少微信api'
this.VueEvent.$emit('pay-wx-h5-callback', obj)
return obj
}
const _this = this
/* 直接调用微信支付 */ /* 直接调用微信支付 */
// const timestamp = parseInt(new Date().getTime() / 1000) // const timestamp = parseInt(new Date().getTime() / 1000)
// const noncestr = parseInt(Math.random() * 10000000000000000) // const noncestr = parseInt(Math.random() * 10000000000000000)
...@@ -144,7 +154,7 @@ export default { ...@@ -144,7 +154,7 @@ export default {
// res.err_msg将在用户支付成功后返回ok,但并不保证它绝对可靠。 // res.err_msg将在用户支付成功后返回ok,但并不保证它绝对可靠。
obj.code = 200 obj.code = 200
} }
this.VueEvent.$emit('pay-wx-h5-callback', obj) _this.VueEvent.$emit('pay-wx-h5-callback', obj)
} }
) )
} }
......
...@@ -52,8 +52,9 @@ export default { ...@@ -52,8 +52,9 @@ export default {
this.VueEvent.$emit('pay-wx-h5', {}) this.VueEvent.$emit('pay-wx-h5', {})
this.VueEvent.$off('pay-wx-h5-callback').$on('pay-wx-h5-callback', obj => { this.VueEvent.$off('pay-wx-h5-callback').$on('pay-wx-h5-callback', obj => {
if (obj.code === 200) { if (obj.code === 200) {
this.$router.go(-1) this.$router.back()
} else { } else {
// this.$router.go(-2)
Toast('支付失败!') Toast('支付失败!')
} }
console.log(obj, '======') console.log(obj, '======')
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论