Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
M
mingPayMobile
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
fengzhaoyu
mingPayMobile
Commits
12b6f5a9
Commit
12b6f5a9
authored
5 years ago
by
liang ce
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
小程序支付websocket
parent
acb0a57d
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
10 additions
and
50 deletions
+10
-50
app.js
app.js
+0
-5
payment.js
pages/payment/payment.js
+10
-45
No files found.
app.js
View file @
12b6f5a9
...
...
@@ -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'
}
});
This diff is collapsed.
Click to expand it.
pages/payment/payment.js
View file @
12b6f5a9
...
...
@@ -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
()
{
// 标题被点击
...
...
This diff is collapsed.
Click to expand it.
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment