Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
E
educationStu
Project
Project
Details
Activity
Releases
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
向伟
educationStu
Commits
852491c9
Commit
852491c9
authored
Aug 27, 2021
by
罗超
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
1
parent
1cd727d5
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
37 additions
and
7 deletions
+37
-7
login.vue
src/pages/login/login.vue
+7
-2
index.js
src/utils/index.js
+21
-0
plugin.js
src/utils/plugin.js
+2
-3
request.js
src/utils/request.js
+7
-2
No files found.
src/pages/login/login.vue
View file @
852491c9
...
@@ -73,7 +73,7 @@ export default {
...
@@ -73,7 +73,7 @@ export default {
uni
.
navigateBack
();
uni
.
navigateBack
();
},
},
jumpPage
()
{
jumpPage
()
{
uni
.
navigateTo
({
uni
.
reLaunch
({
url
:
"/pages/index/index"
,
url
:
"/pages/index/index"
,
});
});
clearTimeout
();
clearTimeout
();
...
@@ -128,10 +128,15 @@ export default {
...
@@ -128,10 +128,15 @@ export default {
let
res
=
await
login
(
msg
);
let
res
=
await
login
(
msg
);
if
(
res
)
{
if
(
res
)
{
res
.
Data
.
Account
=
msg
.
Account
;
res
.
Data
.
Account
=
msg
.
Account
;
uni
.
clearStorage
();
uni
.
setStorageSync
(
"userInfo"
,
res
.
Data
);
uni
.
setStorageSync
(
"userInfo"
,
res
.
Data
);
Toast
.
success
(
"登录成功"
);
Toast
.
success
(
"登录成功"
);
setTimeout
(()
=>
{
setTimeout
(()
=>
{
that
.
jumpPage
();
let
data
=
uni
.
getStorageSync
(
"userInfo"
);
if
(
data
)
{
console
.
log
(
137
,
data
);
that
.
jumpPage
();
}
},
1000
);
},
1000
);
}
}
},
},
...
...
src/utils/index.js
View file @
852491c9
...
@@ -205,4 +205,25 @@ export let changeNumToHan = (num) => {
...
@@ -205,4 +205,25 @@ export let changeNumToHan = (num) => {
//将【一十】换成【十】
//将【一十】换成【十】
result
=
result
.
replace
(
/^一十/g
,
'十'
)
result
=
result
.
replace
(
/^一十/g
,
'十'
)
return
result
;
return
result
;
}
// 判断登录
export
let
isLogin
=
()
=>
{
let
userinfo
=
uni
.
getStorageSync
(
'userInfo'
);
if
(
!
userinfo
||
userinfo
===
""
)
{
uni
.
showToast
({
title
:
'请登录账号'
,
duration
:
2000
,
icon
:
"error"
,
success
:
()
=>
{
setTimeout
(()
=>
{
uni
.
navigateTo
({
url
:
'/pages/login/login'
});
clearTimeout
();
},
2000
)
}
});
}
}
}
\ No newline at end of file
src/utils/plugin.js
View file @
852491c9
import
{
isLogin
}
from
'./index'
export
default
{
export
default
{
install
:
(
app
,
options
)
=>
{
install
:
(
app
,
options
)
=>
{
app
.
config
.
globalProperties
.
$test
=
(
s
)
=>
{
app
.
config
.
globalProperties
.
$isLogin
=
isLogin
console
.
log
(
"5,plugin"
,
s
)
}
}
}
}
}
\ No newline at end of file
src/utils/request.js
View file @
852491c9
...
@@ -5,10 +5,10 @@ if (process.env.NODE_ENV === "development") {
...
@@ -5,10 +5,10 @@ if (process.env.NODE_ENV === "development") {
host
=
'http://192.168.20.17:8017/api'
host
=
'http://192.168.20.17:8017/api'
}
}
import
Toast
from
'../wxcomponents/vant/toast/toast'
;
import
Toast
from
'../wxcomponents/vant/toast/toast'
;
let
token
=
uni
.
getStorageSync
(
'userInfo'
).
Token
;
let
request
=
(
param
)
=>
{
let
request
=
(
param
)
=>
{
//网络请求
//网络请求
return
new
Promise
((
resolve
,
reject
)
=>
{
return
new
Promise
((
resolve
,
reject
)
=>
{
let
token
=
uni
.
getStorageSync
(
'userInfo'
).
Token
;
uni
.
request
({
uni
.
request
({
url
:
host
+
param
.
url
,
url
:
host
+
param
.
url
,
method
:
param
.
method
||
"Post"
,
method
:
param
.
method
||
"Post"
,
...
@@ -29,7 +29,12 @@ let request = (param) => {
...
@@ -29,7 +29,12 @@ let request = (param) => {
fail
:
(
err
)
=>
{
fail
:
(
err
)
=>
{
// reject(err)
// reject(err)
console
.
warn
(
"fail:"
+
JSON
.
stringify
(
err
));
console
.
warn
(
"fail:"
+
JSON
.
stringify
(
err
));
Toast
.
fail
(
"网络请求失败"
)
// Toast.fail("网络请求失败")
uni
.
showToast
({
title
:
'网络请求失败'
,
duration
:
2000
,
icon
:
"error"
,
});
}
}
});
});
})
})
...
...
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