提交 24f5855c authored 作者: zyx's avatar zyx

update

上级 02cd9bd4
...@@ -79,7 +79,7 @@ export default { ...@@ -79,7 +79,7 @@ export default {
_callback(_obj) _callback(_obj)
}) })
}, },
goToPay () { async goToPay () {
const obj = { code: 0, msg: '', data: {} } const obj = { code: 0, msg: '', data: {} }
if (!this.requestParam.product_id) { if (!this.requestParam.product_id) {
obj.code = 3001 obj.code = 3001
...@@ -91,34 +91,47 @@ export default { ...@@ -91,34 +91,47 @@ export default {
obj.msg = '没有小程序用户openid' obj.msg = '没有小程序用户openid'
return obj return obj
} }
return Pay.getOrderId(this.requestParam).then(res => { return await Pay.getOrderId(this.requestParam).then(res => {
obj.data = res if (res.code) {
this.wxWakeUpToPay() // this.requestParam.product_id
// return // this.requestParam.open_id
this.requestParam.prepay_id = res.data.prepay_id
this.requestParam.app_id = res.data.options.appId
// this.requestParam.app_secret
this.requestParam.timeStamp = res.data.options.timeStamp
this.requestParam.nonceStr = res.data.options.nonceStr
this.requestParam.signType = res.data.options.signType
this.requestParam.paySign = res.data.options.paySign
this.wxWakeUpToPay(obj)
}
}).catch(e => { }).catch(e => {
obj.code = 5001 obj.code = 5001
obj.msg = e.message obj.msg = e.message
return obj return obj
}) })
}, },
wxWakeUpToPay () { async wxWakeUpToPay (obj) {
/* 直接调用微信支付 */ /* 直接调用微信支付 */
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)
WeixinJSBridge.invoke( WeixinJSBridge.invoke(
'getBrandWCPayRequest', { 'getBrandWCPayRequest', {
appId: this.requestParam.app_id, // 公众号名称,由商户传入 appId: this.requestParam.app_id, // 公众号名称,由商户传入
timeStamp: timestamp + '', // 时间戳,自1970年以来的秒数 timeStamp: this.requestParam.timeStamp, // 时间戳,自1970年以来的秒数
nonceStr: noncestr + '', // 随机串 nonceStr: this.requestParam.nonceStr, // 随机串
package: 'prepay_id=' + this.requestParam.prepay_id, package: 'prepay_id=' + this.requestParam.prepay_id,
signType: 'MD5', // 微信签名方式: signType: this.requestParam.signType, // 微信签名方式:MD5
paySign: '70EA570631E4BB79628FBCA90534C63FF7FADD89' // 微信签名 paySign: this.requestParam.paySign // 微信签名
}, },
function (res) { function (res) {
if (res.err_msg === 'get_brand_wcpay_request:ok') { obj.msg = res.err_msg
// 使用以上方式判断前端返回,微信团队郑重提示: return obj
// res.err_msg将在用户支付成功后返回ok,但并不保证它绝对可靠。 // if (res.err_msg === 'get_brand_wcpay_request:ok') {
} // // 使用以上方式判断前端返回,微信团队郑重提示:
// // res.err_msg将在用户支付成功后返回ok,但并不保证它绝对可靠。
// }
} }
) )
} }
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论