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
4db97799
Commit
4db97799
authored
5 years ago
by
fengzhaoyu
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
创建分支 鉴权修改 小程序br去掉
parent
ecc0c064
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
234 additions
and
134 deletions
+234
-134
http.js
API/http.js
+85
-42
app.js
app.js
+2
-2
action.js
pages/action/action.js
+142
-42
allowanceRecordList.axml
pages/allowanceRecordList/allowanceRecordList.axml
+1
-1
index.js
pages/index/index.js
+2
-1
payment.js
pages/payment/payment.js
+1
-45
recordList.axml
pages/recordList/recordList.axml
+1
-1
No files found.
API/http.js
View file @
4db97799
...
...
@@ -11,6 +11,9 @@ const $http = (url, data, type, loadingType) => {
let
expires_in
=
hasToken
.
expires_in
||
''
;
// 过期时效
let
loginTime
=
hasToken
.
expires_in
||
''
;
// 用户登陆时间
let
token
=
hasToken
.
access_token
||
''
;
let
refresh_token
=
hasToken
.
refresh_token
// 刷新token
let
mingUserId
=
dd
.
getStorageSync
({
key
:
'mingUserId'
}.
data
)
// 时间戳未过期
if
(
!!
hasToken
&&
((
new
Date
()).
getTime
()
-
hasToken
.
loginTime
<
hasToken
.
expires_in
*
1000
)){
data
.
orgId
=
dd
.
corpId
;
let
sendData
=
''
;
...
...
@@ -25,11 +28,11 @@ const $http = (url, data, type, loadingType) => {
"Content-Type"
:
"application/json"
,
"Authorization"
:
`Bearer
${
token
}
`
},
url
:
`http://
${
app
.
globalData
.
globalUrl
}
/v1/
${
url
}
?
${
sendData
}
`
,
url
:
`http://
${
app
.
globalData
.
globalUrl
}
/
mingpay-phone/
v1/
${
url
}
?
${
sendData
}
`
,
method
:
type
,
dataType
:
'json'
,
success
:
function
(
res
)
{
if
(
res
.
data
.
resultCode
===
"0"
)
{
if
(
res
.
data
.
resultCode
===
0
)
{
return
resolve
(
res
.
data
.
data
)
}
else
{
// 修改系统繁忙时loading隐藏
...
...
@@ -49,53 +52,93 @@ const $http = (url, data, type, loadingType) => {
}
})
})
}
else
{
}
// 时间戳过期
else
{
dd
.
getNetworkType
({
success
:
(
res
)
=>
{
// 有网的情况下
if
(
res
.
networkAvailable
)
{
dd
.
getAuthCode
({
success
:
function
(
resultCode
){
dd
.
httpRequest
({
headers
:
{
"Content-Type"
:
"application/json"
},
url
:
`http://
${
app
.
globalUrl
}
/v1/auth/token?version=v1&code=
${
resultCode
.
authCode
}
&orgId=
${
dd
.
corpId
}
`
,
method
:
'POST'
,
dataType
:
'json'
,
success
:
function
(
res
)
{
// 全局存储用户信息token和用户信息
const
data
=
res
.
data
.
data
// 更新用户内部信息
dd
.
setStorageSync
({
key
:
'token'
,
data
:
{
access_token
:
data
.
accessToken
.
access_token
,
token_type
:
data
.
accessToken
.
token_type
,
expires_in
:
data
.
accessToken
.
expires_in
,
loginTime
:
(
new
Date
()).
getTime
()
}
});
dd
.
setStorageSync
({
key
:
'userId'
,
data
:
data
.
oapiUser
.
userid
});
$http
(
url
,
data
,
type
)
},
fail
:
function
(
res
)
{
console
.
log
(
res
)
}
});
},
fail
:
function
(
err
){
dd
.
alert
({
content
:
'系统繁忙'
,
buttonText
:
'确定'
});
}
});
}
else
{
dd
.
httpRequest
({
headers
:
{
'Authorization'
:
'Basic bWluZ3BheS1waG9uZTptaW5ncGF5LXBob25l'
,
'Content-Type'
:
'application/x-www-form-urlencoded'
},
data
:
{
username
:
mingUserId
,
password
:
mingUserId
,
scope
:
'server'
,
grant_type
:
'password'
,
refresh_token
:
refresh_token
},
url
:
`http://
${
app
.
globalData
.
globalUrl
}
/auth/oauth/token`
,
method
:
'POST'
,
success
:
function
(
res
)
{
dd
.
setStorageSync
({
key
:
'token'
,
data
:
{
access_token
:
res
.
data
.
access_token
,
expires_in
:
res
.
data
.
expires_in
,
refresh_token
:
res
.
data
.
refresh_token
,
loginTime
:
(
new
Date
()).
getTime
()
}
})
$http
(
url
,
data
,
type
)
},
fail
:
function
(
res
)
{
console
.
log
(
'err'
,
res
)
dd
.
alert
({
content
:
'系统繁忙'
,
buttonText
:
'确定'
})
dd
.
hideLoading
()
}
})
// dd.getAuthCode({
// success:function(resultCode){
// dd.httpRequest({
// headers: {"Content-Type": "application/json"},
// url: `http://${app.globalUrl}/v1/auth/token?version=v1&code=${resultCode.authCode}&orgId=${dd.corpId}`,
// method: 'POST',
// dataType: 'json',
// success: function(res) {
// // 全局存储用户信息token和用户信息
// const data = res.data.data
// // 更新用户内部信息
// dd.setStorageSync({
// key: 'token',
// data: {
// access_token: data.accessToken.access_token,
// token_type: data.accessToken.token_type,
// expires_in: data.accessToken.expires_in,
// loginTime: (new Date()).getTime()
// }
// });
// dd.setStorageSync({
// key: 'userId',
// data: data.oapiUser.userid
// });
// $http(url, data, type)
// },
// fail: function(res) {
// console.log(res)
// }
// });
// },
// fail:function(err){
// dd.alert({
// content: '系统繁忙',
// buttonText: '确定'
// });
// }
// });
}
else
{
dd
.
alert
({
content
:
'登录超时,请连接网络重新登录'
,
buttonText
:
'确定'
});
dd
.
hideLoading
()
}
}
});
...
...
This diff is collapsed.
Click to expand it.
app.js
View file @
4db97799
...
...
@@ -17,8 +17,8 @@ App({
// axios.defaults.baseURL = 'http://139.196.213.18:8400' // beta环境
globalData
:
{
loadingType
:
0
,
// globalUrl: '192.168.1.106:8400
'
globalUrl
:
'192.168.1.101:9999
'
// globalUrl: '192.168.1.102:8400'
globalUrl
:
'139.196.213.18:8400'
//
globalUrl: '139.196.213.18:8400'
}
});
This diff is collapsed.
Click to expand it.
pages/action/action.js
View file @
4db97799
...
...
@@ -9,22 +9,28 @@ Page({
});
dd
.
getNetworkType
({
success
:
(
res
)
=>
{
// 有网络状态
if
(
res
.
networkAvailable
)
{
// 获取免登授权码
dd
.
getAuthCode
({
success
:
function
(
res
){
// 获取用户信息
//
根据免登授权码
获取用户信息
_that
.
getUserMsg
(
res
.
authCode
)
},
// 获取免登授权码失败
fail
:
function
(
err
){
console
.
log
(
err
)
}
});
}
else
{
if
(
dd
.
getStorageSync
({
key
:
'userId'
}).
data
)
{
}
// 无网络状态
else
{
if
(
dd
.
getStorageSync
({
key
:
'token'
}).
data
)
{
dd
.
redirectTo
({
url
:
'/pages/index/index'
})
}
else
{
}
else
{
dd
.
alert
({
content
:
'系统繁忙'
,
buttonText
:
'确定'
...
...
@@ -34,63 +40,157 @@ Page({
}
});
},
//
有网络的状态更新用户userId和token
//
根据免登授权码获取用户的信息并进行全局存储
getUserMsg
(
code
)
{
const
_that
=
this
;
let
token
=
dd
.
getStorageSync
({
key
:
'token'
}).
data
?
dd
.
getStorageSync
({
key
:
'token'
}).
data
.
access_token
:
''
;
let
orgId
=
dd
.
corpId
;
dd
.
httpRequest
({
headers
:
{
"Content-Type"
:
"application/json"
,
"Authorization"
:
`Bearer
${
token
}
`
"Content-Type"
:
"application/x-www-form-urlencoded"
},
url
:
`http://
${
app
.
globalData
.
globalUrl
}
/
v1/auth/userToken?version=v1&code=
${
code
}
&token=
${
token
}
&orgId=
${
orgId
}
`
,
url
:
`http://
${
app
.
globalData
.
globalUrl
}
/
mingpay-phone/v1/skipAuth/getUserInfoByCode?code=
${
code
}
&orgId=
${
orgId
}
`
,
method
:
'POST'
,
dataType
:
'json'
,
success
:
function
(
res
)
{
console
.
log
(
res
)
// 全局存储用户信息token和用户信息
if
(
res
.
data
.
resultCode
===
'0'
){
const
data
=
res
.
data
.
data
;
// 更新用户内部信息
dd
.
setStorageSync
({
key
:
'token'
,
data
:
{
access_token
:
data
.
accessToken
.
access_token
,
token_type
:
data
.
accessToken
.
token_type
,
expires_in
:
data
.
accessToken
.
expires_in
,
loginTime
:
(
new
Date
()).
getTime
()
}
});
dd
.
setStorageSync
({
key
:
'userId'
,
data
:
data
.
oapiUser
.
userid
});
dd
.
setStorageSync
({
key
:
'avatar'
,
data
:
data
.
oapiUser
.
avatar
});
dd
.
hideLoading
();
dd
.
redirectTo
({
url
:
'/pages/index/index'
})
}
else
{
dd
.
hideLoading
();
dd
.
redirectTo
({
url
:
'/pages/noPermission/noPermission'
if
(
res
.
data
.
resultCode
==
0
)
{
const
data
=
res
.
data
.
data
dd
.
setStorageSync
({
key
:
'mingUserId'
,
data
:
data
.
mingUserId
})
dd
.
setStorageSync
({
key
:
'userId'
,
data
:
data
.
oapiUser
.
userid
})
dd
.
setStorageSync
({
key
:
'avatar'
,
data
:
data
.
oapiUser
.
avatar
})
_that
.
getUserToken
(
data
.
mingUserId
)
}
else
{
dd
.
alert
({
content
:
'系统繁忙'
,
buttonText
:
'确定'
})
}
dd
.
hideLoading
()
}
},
fail
:
function
(
res
)
{
console
.
log
(
'err'
,
res
)
dd
.
alert
({
content
:
'系统繁忙'
,
buttonText
:
'确定'
})
;
})
dd
.
hideLoading
();
}
});
})
},
// 获取token接口
getUserToken
(
mingUserId
)
{
dd
.
httpRequest
({
headers
:
{
'Authorization'
:
'Basic bWluZ3BheS1waG9uZTptaW5ncGF5LXBob25l'
,
'Content-Type'
:
'application/x-www-form-urlencoded'
},
data
:
{
username
:
mingUserId
,
password
:
mingUserId
,
scope
:
'server'
,
grant_type
:
'password'
},
url
:
`http://
${
app
.
globalData
.
globalUrl
}
/auth/oauth/token`
,
method
:
'POST'
,
dataType
:
'json'
,
success
:
function
(
res
)
{
dd
.
setStorageSync
({
key
:
'token'
,
data
:
{
access_token
:
res
.
data
.
access_token
,
expires_in
:
res
.
data
.
expires_in
,
refresh_token
:
res
.
data
.
refresh_token
,
loginTime
:
(
new
Date
()).
getTime
()
}
})
dd
.
hideLoading
()
dd
.
redirectTo
({
url
:
'/pages/index/index'
})
},
fail
:
function
(
res
)
{
console
.
log
(
'err'
,
res
)
dd
.
alert
({
content
:
'系统繁忙'
,
buttonText
:
'确定'
})
dd
.
hideLoading
()
}
})
},
// 有网络的状态更新用户userId和token
// getUserMsg(code) {
// const _that = this;
// let token = dd.getStorageSync({ key: 'token' }).data ? dd.getStorageSync({ key: 'token' }).data.access_token : '';
// let orgId = dd.corpId;
// dd.httpRequest({
// headers: {
// "Content-Type": "application/json",
// "Authorization": `Bearer ${token}`
// },
// url: `http://${app.globalData.globalUrl}/v1/auth/userToken?version=v1&code=${code}&token=${token}&orgId=${orgId}`,
// method: 'POST',
// dataType: 'json',
// success: function(res) {
// console.log(res)
// // 全局存储用户信息token和用户信息
// if(res.data.resultCode === '0'){
// const data = res.data.data;
// // 更新用户内部信息
// dd.setStorageSync({
// key: 'token',
// data: {
// access_token: data.accessToken.access_token,
// token_type: data.accessToken.token_type,
// expires_in: data.accessToken.expires_in,
// loginTime: (new Date()).getTime()
// }
// });
// dd.setStorageSync({
// key: 'userId',
// data: data.oapiUser.userid
// });
// dd.setStorageSync({
// key: 'avatar',
// data: data.oapiUser.avatar
// });
// dd.hideLoading();
// dd.redirectTo({
// url: '/pages/index/index'
// })
// }else{
// dd.hideLoading();
// dd.redirectTo({
// url: '/pages/noPermission/noPermission'
// })
// }
// },
// fail: function(res) {
// console.log('err',res)
// dd.alert({
// content: '系统繁忙',
// buttonText: '确定'
// });
// dd.hideLoading();
// }
// });
// },
onReady
()
{
// 页面加载完成
},
...
...
This diff is collapsed.
Click to expand it.
pages/allowanceRecordList/allowanceRecordList.axml
View file @
4db97799
<view>
<view class="nullImage" a:if="{{recordAlliwanceListData.length === 0}}">
<image mode="scaleToFill" src="../../../assets/recordNull.png"/>
<br/>
<image mode="scaleToFill" src="../../../assets/recordNull.png"/>
<text>当前暂无账单记录</text>
</view>
<view class="recordList">
...
...
This diff is collapsed.
Click to expand it.
pages/index/index.js
View file @
4db97799
...
...
@@ -23,9 +23,10 @@ Page({
}
else
{
dd
.
showToast
({
type
:
'fail'
,
content
:
'未
联
网仅支持离线支付'
,
content
:
'未
连
网仅支持离线支付'
,
duration
:
3000
,
});
dd
.
hideLoading
()
}
}
});
...
...
This diff is collapsed.
Click to expand it.
pages/payment/payment.js
View file @
4db97799
...
...
@@ -49,50 +49,6 @@ 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: '确定'
// });
// }
// })
},
onShow
()
{
//刷新二维码
...
...
@@ -102,7 +58,7 @@ Page({
timeRefreshQRcode
=
setInterval
(
function
()
{
_that
.
refreshQRcode
();
},
55000
);
//页面显示
dd
.
connectSocket
({
url
:
`ws://
${
app
.
globalData
.
globalUrl
}
/v1/mingpaywebsocket?param=
${
dd
.
corpId
}
_
${
dd
.
getStorageSync
({
key
:
'userId'
}).
data
}
`
,
...
...
This diff is collapsed.
Click to expand it.
pages/recordList/recordList.axml
View file @
4db97799
...
...
@@ -19,7 +19,7 @@
</view>
<!-- <text class="money">支出:¥386.00 充值:¥500.00</text> -->
<view class="nullImage" a:if="{{recordListData.length === 0}}">
<image mode="scaleToFill" src="../../../assets/recordNull.png"/>
<br/>
<image mode="scaleToFill" src="../../../assets/recordNull.png"/>
<text>当前暂无账单记录</text>
</view>
<view class="recordList">
...
...
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