Commit 12b6f5a9 by liang ce

小程序支付websocket

parent acb0a57d
......@@ -12,14 +12,9 @@ App({
onError(msg) {
console.log(msg)
},
// axios.defaults.baseURL = 'http://192.168.1.106:8400' // 本地荣
// axios.defaults.baseURL = 'http://192.168.1.102:8400' // 本地钱
// axios.defaults.baseURL = 'http://139.224.55.14:9999' // beta环境
globalData: {
loadingType: 0,
// globalUrl: 'http://192.167.1.101:9999'
// globalUrl: '192.168.1.102:9999'
// globalUrl: 'https://gateway.com'
globalUrl: 'https://gateway.mingwork.com'
}
});
......@@ -32,7 +32,6 @@ Page({
},
// 生成二维码
refreshQRcode(){
console.log('erweima')
const _that = this;
let hasToken = dd.getStorageSync({ key: 'token' }).data;
let token = dd.getStorageSync({ key: 'token' }).data.access_token;
......@@ -120,25 +119,13 @@ Page({
dd.hideLoading()
}
})
})
}
// let timestamp = (new Date()).getTime();
// let url = aes.getAES(JSON.stringify({
// "token": token,
// "timestamp": timestamp,
// }))
// let size = 272
// let ecc = 2
// let name = 'myQrcode'
// const ctx = dd.createCanvasContext(name);
// QR.draw(url, ctx, size, Number(ecc));
},
onReady() {
// 页面加载完成
// console.log(' onReady')
// console.log(' onReady')s
// dd.closeSocket()
},
onShow() {
console.log('进入onshow')
......@@ -155,22 +142,6 @@ Page({
//页面显示
dd.connectSocket({
url: `wss://gateway.mingwork.com/mingpay-phone/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",
success: (res) => {
console.log(res,'res')
},
fail: (err) => {
console.log(err,'err')
},
complete: (e) => {
console.log(e,'err')
}
});
dd.onSocketOpen(function(res) {
console.log('WebSocket 连接已打开!');
......@@ -179,18 +150,17 @@ Page({
console.log(res)
console.log('WebSocket 连接打开失败,请检查!');
});
dd.onSocketClose(function(res) {
console.log('WebSocket 已关闭!')
})
dd.onSocketMessage(function(res) {
let resData = JSON.parse(res.data)
console.log(resData)
if(resData.paymentCode === 0){
dd.closeSocket()
dd.onSocketClose(function() {
dd.redirectTo({
url: `./../paySuccess/paySuccess?money=${(JSON.parse(res.data).orderAmount.toFixed(2))}`
})
// dd.closeSocket();
dd.navigateTo({
url: `./../paySuccess/paySuccess?money=${(JSON.parse(res.data).orderAmount.toFixed(2))}`
})
}else if(resData.paymentCode === 10001){
dd.alert({
content: '账户状态异常',
......@@ -217,9 +187,6 @@ Page({
},
onHide() {
// 页面隐藏
dd.onSocketClose(function(res) {
console.log('WebSocket 已关闭!')
})
clearInterval(timeRefreshQRcode);
},
onUnload() {
......@@ -227,11 +194,9 @@ Page({
console.log('onUnload')
const _that = this;
clearInterval(timeRefreshQRcode);
dd.closeSocket();
// dd.offSocketMessage()
dd.closeSocket()
dd.onSocketClose(function(res) {
console.log('WebSocket 已关闭!')
})
},
onTitleClick() {
// 标题被点击
......
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