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
Oct 17, 2019
by
liang ce
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
小程序支付websocket
parent
acb0a57d
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
9 additions
and
49 deletions
+9
-49
app.js
app.js
+0
-5
payment.js
pages/payment/payment.js
+9
-44
No files found.
app.js
View file @
12b6f5a9
...
@@ -12,14 +12,9 @@ App({
...
@@ -12,14 +12,9 @@ App({
onError
(
msg
)
{
onError
(
msg
)
{
console
.
log
(
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
:
{
globalData
:
{
loadingType
:
0
,
loadingType
:
0
,
// globalUrl: 'http://192.167.1.101:9999'
// globalUrl: 'http://192.167.1.101:9999'
// globalUrl: '192.168.1.102:9999'
// globalUrl: 'https://gateway.com'
globalUrl
:
'https://gateway.mingwork.com'
globalUrl
:
'https://gateway.mingwork.com'
}
}
});
});
pages/payment/payment.js
View file @
12b6f5a9
...
@@ -32,7 +32,6 @@ Page({
...
@@ -32,7 +32,6 @@ Page({
},
},
// 生成二维码
// 生成二维码
refreshQRcode
(){
refreshQRcode
(){
console
.
log
(
'erweima'
)
const
_that
=
this
;
const
_that
=
this
;
let
hasToken
=
dd
.
getStorageSync
({
key
:
'token'
}).
data
;
let
hasToken
=
dd
.
getStorageSync
({
key
:
'token'
}).
data
;
let
token
=
dd
.
getStorageSync
({
key
:
'token'
}).
data
.
access_token
;
let
token
=
dd
.
getStorageSync
({
key
:
'token'
}).
data
.
access_token
;
...
@@ -120,25 +119,13 @@ Page({
...
@@ -120,25 +119,13 @@ Page({
dd
.
hideLoading
()
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
()
{
onReady
()
{
// 页面加载完成
// 页面加载完成
// console.log(' onReady')
// console.log(' onReady')s
// dd.closeSocket()
},
},
onShow
()
{
onShow
()
{
console
.
log
(
'进入onshow'
)
console
.
log
(
'进入onshow'
)
...
@@ -155,22 +142,6 @@ Page({
...
@@ -155,22 +142,6 @@ Page({
//页面显示
//页面显示
dd
.
connectSocket
({
dd
.
connectSocket
({
url
:
`wss://gateway.mingwork.com/mingpay-phone/v1/mingpaywebsocket?param=
${
dd
.
corpId
}
_
${
dd
.
getStorageSync
({
key
:
'userId'
}).
data
}
`
,
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
)
{
dd
.
onSocketOpen
(
function
(
res
)
{
console
.
log
(
'WebSocket 连接已打开!'
);
console
.
log
(
'WebSocket 连接已打开!'
);
...
@@ -179,18 +150,17 @@ Page({
...
@@ -179,18 +150,17 @@ Page({
console
.
log
(
res
)
console
.
log
(
res
)
console
.
log
(
'WebSocket 连接打开失败,请检查!'
);
console
.
log
(
'WebSocket 连接打开失败,请检查!'
);
});
});
dd
.
onSocketClose
(
function
(
res
)
{
console
.
log
(
'WebSocket 已关闭!'
)
})
dd
.
onSocketMessage
(
function
(
res
)
{
dd
.
onSocketMessage
(
function
(
res
)
{
let
resData
=
JSON
.
parse
(
res
.
data
)
let
resData
=
JSON
.
parse
(
res
.
data
)
console
.
log
(
resData
)
console
.
log
(
resData
)
if
(
resData
.
paymentCode
===
0
){
if
(
resData
.
paymentCode
===
0
){
dd
.
closeSocket
()
// dd.closeSocket();
dd
.
onSocketClose
(
function
()
{
dd
.
navigateTo
({
dd
.
redirectTo
({
url
:
`./../paySuccess/paySuccess?money=
${(
JSON
.
parse
(
res
.
data
).
orderAmount
.
toFixed
(
2
))}
`
url
:
`./../paySuccess/paySuccess?money=
${(
JSON
.
parse
(
res
.
data
).
orderAmount
.
toFixed
(
2
))}
`
})
})
})
}
else
if
(
resData
.
paymentCode
===
10001
){
}
else
if
(
resData
.
paymentCode
===
10001
){
dd
.
alert
({
dd
.
alert
({
content
:
'账户状态异常'
,
content
:
'账户状态异常'
,
...
@@ -217,9 +187,6 @@ Page({
...
@@ -217,9 +187,6 @@ Page({
},
},
onHide
()
{
onHide
()
{
// 页面隐藏
// 页面隐藏
dd
.
onSocketClose
(
function
(
res
)
{
console
.
log
(
'WebSocket 已关闭!'
)
})
clearInterval
(
timeRefreshQRcode
);
clearInterval
(
timeRefreshQRcode
);
},
},
onUnload
()
{
onUnload
()
{
...
@@ -227,11 +194,9 @@ Page({
...
@@ -227,11 +194,9 @@ Page({
console
.
log
(
'onUnload'
)
console
.
log
(
'onUnload'
)
const
_that
=
this
;
const
_that
=
this
;
clearInterval
(
timeRefreshQRcode
);
clearInterval
(
timeRefreshQRcode
);
dd
.
closeSocket
();
// dd.offSocketMessage()
// dd.offSocketMessage()
dd
.
closeSocket
()
dd
.
onSocketClose
(
function
(
res
)
{
console
.
log
(
'WebSocket 已关闭!'
)
})
},
},
onTitleClick
()
{
onTitleClick
()
{
// 标题被点击
// 标题被点击
...
...
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