Vue. js WeChat payment front-end code sharing, vue. js payment front-end code

Source: Internet
Author: User

Vue. js payment front-end code sharing, vue. js payment front-end code

The instance is as follows:

OnBridgeReady: function () {const openId = localStorage. getItem ('openid') payService. payment (this. $ route. params. orderId, 1, openId ). then (rt => {// 1: Payment type. You can leave this blank. message = rt. t WeixinJSBridge. invoke ('getbrandwcpayrequest', {'appid ': this. message. appId, 'timestamp': this. message. timeStamp, 'noncestr ': this. message. nonceStr, 'package': this. message. package, 'signattype': this. message. signType, 'Pay Sign ': this. message. paySign}, function (res) {console. log (res) if (res. err_msg = 'get _ brand_wcpay_request: OK ') {Toast ('payment successful') this. $ router. push ('/mineorder')} else if (res. err_msg = 'get _ brand_wcpay_request: cancel ') {Toast ('user canceled pay') // window. location. href = 'gift _ failview. do? Out_trade_no = '+ this. orderId} else if (res. err_msg = 'get _ brand_wcpay_request: fail ') {Toast ('network exception, Please retry')}, 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 ()}}

The above vue. js payment front-end code is a small part of the Content shared to everyone, I hope to give you a reference, but also hope you can support a lot of help homes.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.