第一句子网 - 唯美句子、句子迷、好句子大全
第一句子网 > vue 微信公众号开发——微信支付(Jsapi支付)

vue 微信公众号开发——微信支付(Jsapi支付)

时间:2020-09-26 21:40:31

相关推荐

vue 微信公众号开发——微信支付(Jsapi支付)

在公众号商户平台配置

点击立即支付:

在uniapp項目中使用

pay() {let charges = this.chargeItemInfoList.filter((item) => {return item.settlementStatus == 1}).map((item) => {return item.realityCharge}).reduce((prev, next) => {return this.plus(prev, next)}) * 100//调后端接口返回所需要的参数this.$u.api.getWxPayConfig({openId:localStorage.getItem('openId'),businessType:1,businessCode:this.businessCode}).then((res) => {console.log(res,typeof(res),res.data,'获取微信支付参数');if(res.code!==1) return uni.showToast({title:res.message,icon:"error"})this.wxReadyToPay(res.data)})},wxReadyToPay(options){// let that = thisif (typeof WeixinJSBridge == "undefined"){if( document.addEventListener){document.addEventListener('WeixinJSBridgeReady',this.onBridgeReady(options), false);}else if(document.attachEvent){document.attachEvent('WeixinJSBridgeReady',this.onBridgeReady(options));document.attachEvent('onWeixinJSBridgeReady',this.onBridgeReady(options));}}else{this.onBridgeReady(options);}},onBridgeReady(options){// console.log(options,typeof(options),'支付参数')if (WeixinJSBridge && options.appId) {WeixinJSBridge.invoke('getBrandWCPayRequest', options, function(res) {if (res.err_msg == "get_brand_wcpay_request:ok") {// 使用以上方式判断前端返回,微信团队郑重提示://res.err_msg将在用户支付成功后返回ok,但并不保证它绝对可靠。// console.log('支付成功');this.show()}});} else {console.log('请在微信浏览器中打开支付');}},

本内容不代表本网观点和政治立场,如有侵犯你的权益请联系我们处理。
网友评论
网友评论仅供其表达个人看法,并不表明网站立场。