vue.js 微信支付前端代码
来源:互联网 发布:大数据分析师 证书 编辑:程序博客网 时间:2024/05/16 07:59
onBridgeReady: function () {
const openId = localStorage.getItem('openId')
payService.payment(this.$route.params.orderId, 1, openId).then(rt => { //1:支付类型,可不填
this.message = rt.t
WeixinJSBridge.invoke(
'getBrandWCPayRequest', {
'appId': this.message.appId,
'timeStamp': this.message.timeStamp,
'nonceStr': this.message.nonceStr,
'package': this.message.package,
'signType': this.message.signType,
'paySign': this.message.paySign
},
function (res) {
console.log(res)
if (res.err_msg === 'get_brand_wcpay_request:ok') {
Toast('微信支付成功')
this.$router.push('/MineOrder')
} else if (res.err_msg === 'get_brand_wcpay_request:cancel') {
Toast('用户取消支付')
// window.location.href = 'gift_failview.do?out_trade_no=' + this.orderId
} else if (res.err_msg === 'get_brand_wcpay_request:fail') {
Toast('网络异常,请重试')
}
}
)
})
},
callpay: function () {
if (typeof WeixinJSBridge === 'undefined') {
if (document.addEventListener) {
document.addEventListener('WeixinJSBridgeReady', this.onBridgeReady(), false)
} else if (document.attachEvent) {
document.attachEvent('WeixinJSBridgeReady', this.onBridgeReady())
document.attachEvent('onWeixinJSBridgeReady', this.onBridgeReady())
}
} else {
this.onBridgeReady()
}
}
const openId = localStorage.getItem('openId')
payService.payment(this.$route.params.orderId, 1, openId).then(rt => { //1:支付类型,可不填
this.message = rt.t
WeixinJSBridge.invoke(
'getBrandWCPayRequest', {
'appId': this.message.appId,
'timeStamp': this.message.timeStamp,
'nonceStr': this.message.nonceStr,
'package': this.message.package,
'signType': this.message.signType,
'paySign': this.message.paySign
},
function (res) {
console.log(res)
if (res.err_msg === 'get_brand_wcpay_request:ok') {
Toast('微信支付成功')
this.$router.push('/MineOrder')
} else if (res.err_msg === 'get_brand_wcpay_request:cancel') {
Toast('用户取消支付')
// window.location.href = 'gift_failview.do?out_trade_no=' + this.orderId
} else if (res.err_msg === 'get_brand_wcpay_request:fail') {
Toast('网络异常,请重试')
}
}
)
})
},
callpay: function () {
if (typeof WeixinJSBridge === 'undefined') {
if (document.addEventListener) {
document.addEventListener('WeixinJSBridgeReady', this.onBridgeReady(), false)
} else if (document.attachEvent) {
document.attachEvent('WeixinJSBridgeReady', this.onBridgeReady())
document.attachEvent('onWeixinJSBridgeReady', this.onBridgeReady())
}
} else {
this.onBridgeReady()
}
}
阅读全文
0 0
- vue.js 微信支付前端代码
- 微信JS支付代码 前端调用微信支付接口
- 前端-微信支付
- js微信支付
- java后端配合app前端的支付宝和微信支付(逻辑相关代码)
- 分享一下微信支付经验以及JS代码
- vue.js 微信定位
- 微信/支付宝支付js
- 微信js api支付
- 微信支付,服务端代码
- 微信支付JAVA代码
- 微信支付后台代码
- 前端调用微信支付接口
- 一份前端支付宝,微信支付及微信下面的支付充值接口
- 微信 统一下单支付 服务器代码和js代码
- Vue前端Js框架
- 微信支付--JS--傻瓜式学习
- js api微信支付接口
- Android6.0运行时权限扩展篇
- Android中aar和jar文件的认识
- HDU1269:迷宫城堡(强连通)
- MOOC清华《程序设计基础》期末考试第5题:解密外星人ET的聊天记录
- 杭电ACM1718 名次
- vue.js 微信支付前端代码
- Python学习6-函数
- 机器学习算法总结--提升方法
- libevent 示例代码
- jsp页面获取服务器时间
- sublime text 3 安装、添加命令行启动、汉化、注册码
- 游戏开发常用的算法
- [leetcode] 19. Remove Nth Node From End of Lis
- MAVEN的常用操作