Record the WeChat public account H5 payment encapsulated in a JS

import wx from 'weixin-js-sdk' import router from '@/router/index' const handlePayment = res => { if (res.errMsg === 'chooseWXPay:ok') { router.replace('/success') } else if (res.errMsg === 'chooseWXPay:cancel') { router.replace({ path: '/fail', query: {failure: 'user cancels payment'}})} else {router.replace({path: '/fail', query: {failure: }}} export const callWxPay = (config) = bb0 {wx.config({debug: false, // true) Config.appid // WeChat appId}) wx.ready(function () {wx.choosewxpay ({appId: config.appid, // WeChat appId timestamp: Config. Timestamp, // timestamp nonceStr: config.nonceStr, // random string package: config.package, // SignType: Config. SignType, // Signature PaySign: config. PaySign, // Payment Signature Success: HandlePayment, Cancel: HandlePayment, Fail: handlePayment }) }) }