Wechat payment process

Wechat official link document:Pay.weixin.qq.com/wiki/doc/ap…

// Obtain the wechat authorization codegetWxCode() { wx.login({ success: res => { this.wxCode = res.code; console.log(this.wxCode); }}); }, // wechat paytoPayConst data = {body: this.toclass.className, notifyUrl: {body: this.toclassName, notifyUrl:'url',
				outTradeNo: this.toClass.orderId + ' ',
				spbillCreateIp: '127.0.0.1',
				totalFee: this.totalPrice,
				tradeType: 'JSAPI'
			};
			var that = this;
			toPay(data).then(res => {
				if ((res.resultCode = 'SUCCESS')) {
					console.log('res 11111111111111111111111111', res);

					try {
						console.log(typeof wx.requestPayment);
						var timest = new Date().getTime();
						var d_timeStamp = Math.round(timest / 1000, 0) + ' '; Wx. RequestPayment ({wx."timeStamp":res.timeStamp,
							"nonceStr":res.nonceStr,
							"package": res.packageValue,
							"signType": res.signType,
							"paySign": res.paySign,
							"success":function(resp){
							console.log('success:' + JSON.stringify(resp));
						},
						"success":function(resp){
							console.log('success:' + JSON.stringify(resp));
							uni.showToast({
							  title: 'Payment successful',
							  icon: 'none',
							  duration: 2000
							});
							const params = {
								outTradeNo : that.toClass.orderId + ' ',
							}
							getwxorder(params).then(orderStatus=>{
								console.log(orderStatus)
								setTimeout(function() {
									uni.navigateTo({
										url: '/pages/course/order? item=2'}); }, 0); })},"fail":function(resp){
							console.log('fail:' + JSON.stringify(resp));
							uni.showToast({
							  title: 'Payment failure',
							  icon: 'none'
							});
						}
						})
					} catch (e) {
						//TODO handle the exception
						console.error('222222', e); }}}); },Copy the code

Payment screenshot:

Helpful to you, please pay attention to a wave of bloggers!!