There is a problem in the written H5 page in the mobile app. After running WeChat payment, a result callback notification will be sent to the H5 page. Often the methods we wrote inside the component cannot respond.
Inside the script tag:
In the methods inside the component:
It is unresponsive in the script tag or methods inside the component.
Approach:
And write the response method in main.js, the window object registered in the browser can respond!
window.onPayResult = function (code) {
alert("按键code="+code);
if (code == 0) {
alert("成功");
} else if(code==1) {
alert("失败");
}else{
alert("用户取消");
}
// "0"成功 “1”失败,"2"用户取消
}