How to jump to the specified page after payment in WeChat Mini Program

Many people say to use the reLaunch method to jump. This method jumps normally on IOS, but on Android it reports an error relaunch: fail can not invoka lelaunch in background.

The reason is that after the payment is successful, it will immediately try to execute relaunch, and the page still stays on the page where the payment is completed, causing the applet to actually be in the background, and relaunch cannot be executed in the background, so it cannot be redirected.

So you can try to use other adjustment methods, if you need to jump to the first level (tab) page, use wx.switchTab. If you jump to a secondary (non-tab) page, use wx.redirectTo:

wx.requestPayment({

	success: function (res) {
		
		//一级(tab)页面
		wx.switchTab({
			url: ''
		});

		//二级(非tab)页面
		wx.redirectTo({
			url: ''
		});

	},

	fail: function (err) {
	}

});

Reprinted from: http://www.oneue.com/articles/1435.html

Guess you like

Origin blog.csdn.net/z3287852/article/details/112544139