Commit d4bcc59f by fengzhaoyu

修改:猜测连接在onready和onshow中开了两次,导致有异常会弹两次弹窗框,去掉onready中的连接

parent 4a6485ae
......@@ -49,50 +49,50 @@ Page({
timeRefreshQRcode = setInterval(function () {
_that.refreshQRcode();
}, 55000);
dd.connectSocket({
url: `ws://${app.globalData.globalUrl}/v1/mingpaywebsocket?param=${dd.corpId}_${dd.getStorageSync({ key: 'userId' }).data}`,
data: {},
header:{
'content-type': 'application/json',
'Authorization': `Bearer ${dd.getStorageSync({ key: 'token' }).data.access_token}`
},
method:"GET",
});
dd.onSocketOpen(function(res) {
console.log('WebSocket 连接已打开!');
});
dd.onSocketError(function(res){
console.log('WebSocket 连接打开失败,请检查!');
});
dd.onSocketMessage(function(res) {
console.log(JSON.parse(res.data))
let resData = JSON.parse(res.data)
if(resData.paymentCode === 0){
dd.redirectTo({
url: `./../paySuccess/paySuccess?money=${(JSON.parse(res.data).orderAmount).toFixed(2)}`
})
}else if(resData.paymentCode === 10001){
dd.alert({
content: '账户状态异常',
buttonText: '确定'
});
}else if(resData.paymentCode === 10002){
dd.alert({
content: '卡片状态异常',
buttonText: '确定'
});
}else if(resData.paymentCode === 10003){
dd.alert({
content: '账户余额不足',
buttonText: '确定'
});
}else if(resData.paymentCode === 10004){
dd.alert({
content: '二维码失效',
buttonText: '确定'
});
}
})
// dd.connectSocket({
// url: `ws://${app.globalData.globalUrl}/v1/mingpaywebsocket?param=${dd.corpId}_${dd.getStorageSync({ key: 'userId' }).data}`,
// data: {},
// header:{
// 'content-type': 'application/json',
// 'Authorization': `Bearer ${dd.getStorageSync({ key: 'token' }).data.access_token}`
// },
// method:"GET",
// });
// dd.onSocketOpen(function(res) {
// console.log('WebSocket 连接已打开!');
// });
// dd.onSocketError(function(res){
// console.log('WebSocket 连接打开失败,请检查!');
// });
// dd.onSocketMessage(function(res) {
// console.log(JSON.parse(res.data))
// let resData = JSON.parse(res.data)
// if(resData.paymentCode === 0){
// dd.redirectTo({
// url: `./../paySuccess/paySuccess?money=${(JSON.parse(res.data).orderAmount).toFixed(2)}`
// })
// }else if(resData.paymentCode === 10001){
// dd.alert({
// content: '账户状态异常',
// buttonText: '确定'
// });
// }else if(resData.paymentCode === 10002){
// dd.alert({
// content: '卡片状态异常',
// buttonText: '确定'
// });
// }else if(resData.paymentCode === 10003){
// dd.alert({
// content: '账户余额不足',
// buttonText: '确定'
// });
// }else if(resData.paymentCode === 10004){
// dd.alert({
// content: '二维码失效',
// buttonText: '确定'
// });
// }
// })
},
onShow() {
//刷新二维码
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment