Skip to content
Toggle navigation
Toggle navigation
This project
Loading...
Sign in
杨炀
/
ztx_wx_minapp
Go to a project
Toggle navigation
Toggle navigation pinning
Projects
Groups
Snippets
Help
Project
Activity
Repository
Pipelines
Graphs
Issues
0
Merge Requests
0
Wiki
Network
Create a new issue
Builds
Commits
Issue Boards
Files
Commits
Network
Compare
Branches
Tags
6f893b30
authored
2023-12-23 15:42:33 +0800
by
华明祺
Browse Files
Options
Browse Files
Tag
Download
Email Patches
Plain Diff
登录调整
1 parent
c0aee960
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
113 additions
and
110 deletions
App.vue
common/login.js
common/request.js
webView/vipSystem.vue
App.vue
View file @
6f893b3
...
...
@@ -13,7 +13,6 @@ export default {
firstload
=
true
this
.
globalData
.
baseUrl_api
=
config
.
baseUrl_api
;
let
userName
=
uni
.
getStorageSync
(
'userName'
)
if
(
userName
)
{
this
.
globalData
.
isLogin
=
true
;
...
...
common/login.js
View file @
6f893b3
...
...
@@ -89,16 +89,22 @@ function loginByPhone(phonenumber, code) {
}
// 获取用户详细信息
function
getInfo
()
{
function
getInfo
()
{
let
app
return
request
({
url
:
`
${
config
.
baseUrl_api
}
/getInfoForPc`
,
method
:
'get'
}).
then
(
res
=>
{
const
app
=
getApp
()
}).
then
(
res
=>
{
app
=
getApp
()
const
user
=
res
.
data
.
user
uni
.
setStorageSync
(
'userName'
,
user
.
userName
)
uni
.
setStorageSync
(
'perId'
,
aes
.
encrypt
(
user
.
userId
))
app
.
globalData
.
userInfo
=
user
}).
catch
(()
=>
{
app
=
getApp
()
uni
.
removeStorageSync
(
'token'
)
uni
.
removeStorageSync
(
'userName'
)
app
.
globalData
.
isLogin
=
false
})
}
...
...
common/request.js
View file @
6f893b3
// import config from '@/config.js'
import
{
h5LoginAuto
}
from
'./login'
// import config from '@/config.js'
import
_
from
'lodash'
const
excludeUrls
=
[
'
pages/index/login'
,
'pages/index/register
'
]
const
excludeUrls
=
[
'
getMemberCountInfo'
,
'getInfoForPc
'
]
// 获取Token
function
getToken
()
{
try
{
const
token
=
uni
.
getStorageSync
(
'token'
)
if
(
token
)
{
return
token
}
else
{
return
''
}
}
catch
(
e
)
{
console
.
log
(
e
)
}
try
{
const
token
=
uni
.
getStorageSync
(
'token'
)
if
(
token
)
{
return
token
}
else
{
return
''
}
}
catch
(
e
)
{
console
.
log
(
e
)
}
}
// 获取请求头
function
getHeaders
()
{
const
token
=
getToken
()
const
header
=
{
'Authorization'
:
token
,
'Content-Type'
:
'application/json'
,
// 根据自己的数据类型
// "Content-Type":"application/x-www-form-urlencoded",
'Ztx-Per-Id'
:
uni
.
getStorageSync
(
'perId'
)
||
'-1'
}
return
header
const
token
=
getToken
()
const
header
=
{
'Authorization'
:
token
,
'Content-Type'
:
'application/json'
,
// 根据自己的数据类型
// "Content-Type":"application/x-www-form-urlencoded",
'Ztx-Per-Id'
:
uni
.
getStorageSync
(
'perId'
)
||
'-1'
}
return
header
}
const
request
=
function
(
req
)
{
req
.
method
=
req
.
method
.
toUpperCase
()
if
(
!
[
'GET'
,
'POST'
,
'PUT'
,
'DELETE'
].
includes
(
req
.
method
))
{
uni
.
showToast
({
title
:
`暂不支持的请求方式:
${
req
.
method
}
`
,
icon
:
'none'
})
return
}
req
.
method
=
req
.
method
.
toUpperCase
()
if
(
!
[
'GET'
,
'POST'
,
'PUT'
,
'DELETE'
].
includes
(
req
.
method
))
{
uni
.
showToast
({
title
:
`暂不支持的请求方式:
${
req
.
method
}
`
,
icon
:
'none'
})
return
}
// if (req.method === 'GET') {
// if (!req.params) {
// req.params = {}
// }
// req.params.pageNum = req.params.pageNum || 1
// req.params.pageSize = req.params.pageSize || 50
// }
// if (req.method === 'GET') {
// if (!req.params) {
// req.params = {}
// }
// req.params.pageNum = req.params.pageNum || 1
// req.params.pageSize = req.params.pageSize || 50
// }
// if (req.method == 'POST' && !req.hideLoding) {
// uni.showLoading({
// title: '提交中...'
// })
// }
// if (req.method == 'POST' && !req.hideLoding) {
// uni.showLoading({
// title: '提交中...'
// })
// }
return
new
Promise
((
resolve
,
reject
)
=>
{
uni
.
request
({
url
:
req
.
url
,
method
:
req
.
method
,
data
:
req
.
params
,
header
:
getHeaders
()
}).
then
(
res
=>
{
switch
(
res
.
statusCode
)
{
case
200
:
const
data
=
res
.
data
||
{}
if
(
!
data
||
data
.
code
===
0
||
data
.
code
===
200
||
data
.
pageData
?.
code
===
200
)
{
resolve
(
data
)
}
else
if
(
req
.
url
.
indexOf
(
'getMemberCountInfo'
)
>
-
1
)
{
resolve
(
data
)
}
else
{
if
(
data
.
msg
)
{
uni
.
showToast
({
title
:
data
.
msg
,
icon
:
'none'
,
duration
:
2000
})
}
return
new
Promise
((
resolve
,
reject
)
=>
{
uni
.
request
({
url
:
req
.
url
,
method
:
req
.
method
,
data
:
req
.
params
,
header
:
getHeaders
()
}).
then
(
res
=>
{
switch
(
res
.
statusCode
)
{
case
200
:
const
data
=
res
.
data
||
{}
if
(
!
data
||
data
.
code
===
0
||
data
.
code
===
200
||
data
.
pageData
?.
code
===
200
)
{
resolve
(
data
)
}
else
if
(
_
.
some
(
excludeUrls
,
(
url
)
=>
req
.
url
.
indexOf
(
url
)
>
-
1
))
{
resolve
(
data
)
}
else
{
if
(
data
.
msg
)
{
uni
.
showToast
({
title
:
data
.
msg
,
icon
:
'none'
,
duration
:
2000
})
}
// 登录超时
if
(
data
.
code
===
60002
||
data
.
code
===
60001
)
{
uni
.
redirectTo
({
url
:
'/pages/index/login'
})
}
else
if
(
data
.
code
===
401
)
{
h5LoginAuto
()
.
then
(()
=>
{
uni
.
hideLoading
()
uni
.
redirectTo
({
url
:
getCurrentPages
()[
getCurrentPages
()
.
length
-
1
].
$page
.
fullPath
})
})
.
catch
(()
=>
{
uni
.
showToast
({
title
:
'服务异常,请稍后重试'
,
icon
:
'none'
})
})
}
// 登录超时
// if (data.code === 60002 || data.code === 60001) {
// uni.redirectTo({
// url: '/pages/index/login'
// })
// } else if (data.code === 401) {
// h5LoginAuto()
// .then(() => {
// uni.hideLoading()
// uni.redirectTo({
// url: getCurrentPages()[getCurrentPages()
// .length - 1].$page.fullPath
// })
// })
// .catch(() => {
// debugger
// uni.showToast({
// title: '服务异常,请稍后重试',
// icon: 'none'
// })
// })
// }
reject
(
res
)
}
break
default
:
reject
(
res
)
}
}).
catch
(
res
=>
{
reject
(
res
)
}).
finally
(()
=>
{
// if (req.method == 'POST' && !req.hideLoding) {
// uni.hideLoading()
// }
})
})
reject
(
res
)
}
break
default
:
reject
(
res
)
}
}).
catch
(
res
=>
{
reject
(
res
)
}).
finally
(()
=>
{
// if (req.method == 'POST' && !req.hideLoding) {
// uni.hideLoading()
// }
})
})
}
export
default
request
\ No newline at end of file
export
default
request
...
...
webView/vipSystem.vue
View file @
6f893b3
<
template
>
<view>
<web-view
src=
"http://192.168.1.194
:5173"
>
<view>
<web-view
src=
"http://192.168.1.98
:5173"
>
</web-view>
</view>
</web-view>
</view>
</
template
>
<
script
setup
>
...
...
Write
Preview
Styling with
Markdown
is supported
Attach a file
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 post a comment