Skip to content
Toggle navigation
Toggle navigation
This project
Loading...
Sign in
杨炀
/
gd_yc
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
d60f1935
authored
2023-10-07 17:07:19 +0800
by
华明祺
1
Browse Files
Options
Browse Files
Tag
Download
Email Patches
Plain Diff
no message
1 parent
36d3ae2a
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
108 additions
and
87 deletions
App.vue
common/login.js
common/request.js
components/login/index.vue
config.js
main.js
pages/index/index.vue
App.vue
View file @
d60f193
<
script
>
import
*
as
loginServer
from
'@/common/login.js'
;
import
*
as
api
from
'@/common/api.js'
;
import
{
showLogin
,
h5Login
}
from
'@/common/login.js'
;
import
config
from
'@/config.js'
;
let
firstload
=
false
export
default
{
onLaunch
:
function
()
{
console
.
log
(
'App Launch'
);
firstload
=
true
this
.
globalData
.
baseUrl_api
=
config
.
baseUrl_api
;
let
userName
=
uni
.
getStorageSync
(
'userName'
)
if
(
userName
)
{
h5Login
(
userName
)
.
then
(()
=>
{
this
.
globalData
.
isLogin
=
true
;
let
firstLoadCallback
=
getApp
().
firstLoadCallback
;
if
(
firstLoadCallback
)
{
firstLoadCallback
();
}
})
.
catch
(()
=>
{
showLogin
()
})
}
else
{
this
.
globalData
.
isLogin
=
false
;
showLogin
()
}
},
onShow
:
function
()
{
console
.
log
(
'App Show'
);
uni
.
getStorage
({
key
:
'token'
,
success
:
()
=>
{
this
.
globalData
.
isLogin
=
true
;
let
firstLoadCallback
=
getApp
().
firstLoadCallback
;
if
(
firstLoadCallback
)
{
firstLoadCallback
();
}
},
fail
:
()
=>
{
this
.
globalData
.
isLogin
=
false
;
}
})
},
onHide
:
function
()
{
console
.
log
(
'App Hide'
);
...
...
common/login.js
View file @
d60f193
...
...
@@ -187,11 +187,70 @@ function h5Login(userName) {
params
:
{
username
:
userName
}
}).
then
((
res
)
=>
{
}).
then
((
res
)
=>
{
uni
.
setStorageSync
(
'token'
,
'Bearer '
+
res
.
data
.
token
);
})
}
function
showLogin
(
callback
)
{
uni
.
clearStorageSync
()
uni
.
showModal
({
title
:
'请输入工号,进行身份验证'
,
showCancel
:
false
,
editable
:
true
,
placeholderText
:
'工号'
,
complete
:
(
res
)
=>
{
if
(
res
.
cancel
)
{
setTimeout
(()
=>
{
showLogin
(
callback
)
})
return
}
if
(
!
res
.
content
)
{
uni
.
showToast
({
title
:
'工号不能为空'
,
icon
:
'none'
,
duration
:
3000
})
setTimeout
(()
=>
{
showLogin
(
callback
)
})
return
}
if
(
res
.
confirm
)
{
h5Login
(
res
.
content
)
.
then
(()
=>
{
uni
.
showToast
({
title
:
'验证成功'
,
icon
:
'none'
,
duration
:
1000
})
uni
.
setStorageSync
(
'userName'
,
res
.
content
)
if
(
callback
)
{
callback
()
}
})
.
catch
(()
=>
{
showLogin
(
callback
)
})
}
}
})
}
function
h5LoginAuto
()
{
let
userName
=
uni
.
getStorageSync
(
'userName'
)
if
(
userName
)
{
return
h5Login
(
userName
)
}
else
{
showLogin
()
}
}
function
initData
()
{
console
.
log
(
'initData'
)
...
...
@@ -241,5 +300,7 @@ export {
getWxUserPhone
,
checkUserAuth
,
h5Login
,
showLogin
,
h5LoginAuto
,
initData
}
\ No newline at end of file
...
...
common/request.js
View file @
d60f193
import
config
from
'@/config.js'
import
{
pcLogin
,
getNowOpenId
,
initData
pcLogin
,
getNowOpenId
,
initData
,
showLogin
,
h5LoginAuto
}
from
'./login'
const
excludeUrls
=
[
'/system/wx/getUserInfo'
]
...
...
@@ -34,7 +36,7 @@ function getHeaders() {
let
request
=
function
(
req
)
{
req
.
method
=
req
.
method
.
toUpperCase
()
if
(
!
[
'GET'
,
'POST'
,
'PUT'
,
'DELETE'
].
includes
(
req
.
method
))
{
if
(
!
[
'GET'
,
'POST'
,
'PUT'
,
'DELETE'
].
includes
(
req
.
method
))
{
uni
.
showToast
({
title
:
`暂不支持的请求方式:
${
req
.
method
}
`
,
icon
:
'none'
...
...
@@ -63,26 +65,17 @@ let request = function(req) {
}
else
{
//登录超时
if
(
data
.
code
==
60002
||
data
.
code
==
60001
)
{
if
(
req
.
url
!=
'/system/wx/getUserInfo'
)
{
reLogin
();
}
}
else
if
(
data
.
code
==
401
&&
req
.
url
!=
'/system/wx/getUserInfo'
)
{
pcLogin
()
.
then
(()
=>
{
return
getNowOpenId
()
})
.
then
(()
=>
{
return
initData
()
})
.
then
(()
=>
{
uni
.
hideLoading
();
uni
.
redirectTo
({
url
:
getCurrentPages
()[
getCurrentPages
().
length
-
1
].
$page
.
fullPath
})
})
}
else
{
showLogin
()
}
else
if
(
data
.
code
==
401
)
{
h5LoginAuto
()
.
then
(()
=>
{
uni
.
hideLoading
();
uni
.
redirectTo
({
url
:
getCurrentPages
()[
getCurrentPages
()
.
length
-
1
].
$page
.
fullPath
})
})
}
else
{
if
(
!
excludeUrls
.
includes
(
req
.
url
))
{
uni
.
showToast
({
title
:
data
.
msg
,
...
...
@@ -142,4 +135,4 @@ function pcLoginByOpenId(appId, openId) {
}
export
default
request
;
export
default
request
;
\ No newline at end of file
...
...
components/login/index.vue
deleted
100644 → 0
View file @
36d3ae2
<
template
>
<uni-popup
class=
"popYanZhengBox"
ref=
"popYanZheng"
type=
"center"
>
<view
class=
"popup-content"
>
<view
class=
"t"
>
温馨提示
</view>
<view
class=
"p"
>
该微信未绑定系统内手机号,绑定手机号后正常使用。
</view>
<button
class=
"start"
type=
"default"
@
click=
"login"
>
绑定手机号
</button>
</view>
</uni-popup>
</
template
>
<
script
setup
>
import
{
onMounted
,
ref
}
from
"vue"
;
import
{
h5Login
}
from
'@/common/login.js'
;
const
app
=
getApp
();
const
popYanZheng
=
ref
(
null
);
onMounted
(()
=>
{
if
(
!
app
.
globalData
.
isLogin
)
{
popYanZheng
.
value
.
open
()
}
})
function
login
()
{
h5Login
(
'12000013583'
)
.
then
(()
=>
{
popYanZheng
.
value
.
close
()
})
}
</
script
>
<
style
>
</
style
>
\ No newline at end of file
config.js
View file @
d60f193
// prod
// const baseUrl_api = 'https://research.wtwuxicenter.com/';
// const baseUrl_api = 'https://research.wtwuxicenter.com/';
// staging
const
baseUrl_api
=
"http://192.168.1.118:8080"
;
export
default
{
baseUrl_api
:
baseUrl_api
baseUrl_api
};
\ No newline at end of file
...
...
main.js
View file @
d60f193
...
...
@@ -18,8 +18,6 @@ import login from '@/components/login'
export
function
createApp
()
{
const
app
=
createSSRApp
(
App
)
app
.
component
(
'showLogin'
,
login
)
return
{
app
}
...
...
pages/index/index.vue
View file @
d60f193
<
template
>
<view
class=
"page"
>
<show-login></show-login>
<view
class=
"uni-margin-wrap"
>
<!--
<view
class=
"logobox"
>
<image
class=
"logo"
:src=
"venue.venueLogo"
></image>
...
...
杨炀
@yangyang
mentioned in commit
970c84e7
2023-10-07 09:10:56 UTC
mentioned in commit
970c84e7
Toggle commit list
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