Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
T
thinkApp
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
游洁
thinkApp
Commits
976e2a75
Commit
976e2a75
authored
May 30, 2022
by
罗超
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
调整
parent
4326f227
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
122 additions
and
80 deletions
+122
-80
index.js
src/api/index.js
+1
-1
indexassembly.vue
src/pages/index/components/indexassembly.vue
+52
-55
accountLogin.vue
src/pages/login/accountLogin.vue
+65
-20
request.js
src/utils/request.js
+4
-4
No files found.
src/api/index.js
View file @
976e2a75
...
...
@@ -18,7 +18,7 @@ export function login(data) {
*/
export
function
parsePhone
(
data
)
{
return
request
({
url
:
'/
AppletLogin/GetGuestWeiXinMobil
e'
,
url
:
'/
Login/LoginByAuthoriz
e'
,
method
:
'post'
,
data
})
...
...
src/pages/index/components/indexassembly.vue
View file @
976e2a75
...
...
@@ -145,30 +145,27 @@
});
data
.
showLogin
=
false
;
//防止多次点击登录
let
res
=
await
parsePhone
({
code
,
encryptedData
,
iv
,
code
iv
})
if
(
res
&&
res
.
Data
.
phoneNumber
)
{
console
.
log
(
'dsadas'
,
res
)
data
.
obj
.
phoneNum
=
res
.
Data
.
phoneNumber
// data.obj.phoneNum = '18328620563'
data
.
obj
.
openid
=
res
.
Data
.
openid
data
.
obj
.
unionid
=
res
.
Data
.
unionid
that
.
phoneNumLogin
()
let
obj
=
{
Account
:
data
.
obj
.
phoneNum
,
WeChatName
:
data
.
obj
.
Name
,
WeChatPhoto
:
data
.
obj
.
Photo
,
OpenId
:
data
.
obj
.
openid
,
unionid
:
data
.
obj
.
unionid
,
}
try
{
uni
.
setStorageSync
(
"temporarydh"
,
obj
);
}
catch
(
e
)
{
console
.
log
(
e
,
'eeeeeee'
)
}
console
.
log
(
res
)
if
(
res
&&
res
.
Data
.
UserMobile
)
{
// console.log('dsadas', res)
// data.obj.phoneNum = res.Data.UserMobile
// that.phoneNumLogin()
// let obj = {
// Account: data.obj.phoneNum,
// WeChatName: data.obj.Name,
// WeChatPhoto: data.obj.Photo,
// OpenId: data.obj.openid,
// unionid: data.obj.unionid,
// }
uni
.
setStorageSync
(
"userInfo"
,
res
.
Data
);
uni
.
reLaunch
({
url
:
'/pages/index/index'
})
}
else
{
Toast
.
fail
(
"授权失败,请重新授权"
)
data
.
showLogin
=
true
;
//防止多次点击登录
...
...
@@ -176,40 +173,40 @@
}
},
//手机号授权登录
async
phoneNumLogin
()
{
let
res
=
await
phoneLogin
({
Account
:
data
.
obj
.
phoneNum
,
OpenId
:
data
.
obj
.
openid
,
unionid
:
data
.
obj
.
unionid
,
})
if
(
res
.
Code
==
1
)
{
uni
.
hideLoading
();
data
.
showLogin
=
true
;
//防止多次点击登录
res
.
Data
.
Account
=
data
.
obj
.
phoneNum
;
uni
.
setStorageSync
(
"userInfo"
,
res
.
Data
);
Toast
.
success
(
"登录成功"
);
setTimeout
(()
=>
{
emit
(
'success'
)
},
1000
)
data
.
showPhone
=
false
uni
.
showTabBar
()
}
else
{
data
.
showLogin
=
true
;
//防止多次点击登录
data
.
showPhone
=
false
if
(
currentRoute
==
"pages/index/index"
)
{
uni
.
showTabBar
()
//手机授权弹窗出现 隐藏tabbar
}
uni
.
hideLoading
();
if
(
res
.
Data
.
Error
==
-
1
)
{
//如果没找到电话号码 就跳入登录
// setTimeout(() => {
// uni.reLaunch({
// url: '/pages/login/login'
// });
// }, 1000);
}
//
async phoneNumLogin() {
//
let res = await phoneLogin({
//
Account: data.obj.phoneNum,
//
OpenId: data.obj.openid,
//
unionid: data.obj.unionid,
//
})
//
if (res.Code == 1) {
//
uni.hideLoading();
//
data.showLogin = true; //防止多次点击登录
//
res.Data.Account = data.obj.phoneNum;
//
uni.setStorageSync("userInfo", res.Data);
//
Toast.success("登录成功");
//
setTimeout(()=>{
//
emit('success')
//
},1000)
//
data.showPhone = false
//
uni.showTabBar()
//
} else {
//
data.showLogin = true; //防止多次点击登录
//
data.showPhone = false
//
if (currentRoute == "pages/index/index") {
//
uni.showTabBar() //手机授权弹窗出现 隐藏tabbar
//
}
//
uni.hideLoading();
//
if (res.Data.Error == -1) { //如果没找到电话号码 就跳入登录
//
// setTimeout(() => {
//
// uni.reLaunch({
//
// url: '/pages/login/login'
//
// });
//
// }, 1000);
//
}
}
}
//
}
//
}
};
onMounted
(()
=>
{
...
...
src/pages/login/accountLogin.vue
View file @
976e2a75
...
...
@@ -13,22 +13,38 @@
<view
class=
"login-title"
>
账号登录
</view>
<view
style=
"margin:60rpx auto;text-align: center;"
>
<div
style=
"display: inline-block;"
@
click=
"changeTypeHandler(1)"
>
<image
:class=
"
{'login-grey-avatar':userLoginType==2}" src="https://viitto-1301420277.cos.ap-chengdu.myqcloud.com/Test/Upload/Goods/1653894192000_645.png" mode="widthFix" style="width:142rpx;">
</image>
<view
style=
"color: #282828;font-size: 24rpx;font-weight: 800;"
>
学员
</view>
</div>
<div
style=
"display: inline-block;margin-left:148rpx;"
@
click=
"changeTypeHandler(2)"
>
<image
:class=
"
{'login-grey-avatar':userLoginType==1}" src="https://viitto-1301420277.cos.ap-chengdu.myqcloud.com/Test/Upload/Goods/1653894197000_691.png" mode="widthFix" style="width:142rpx;">
</image>
<view
style=
"color: #282828;font-size: 24rpx;font-weight: 800;"
>
教师
</view>
</div>
</view>
<view
class=
"main"
>
<van-cell-group>
<van-field
:value=
"Account"
placeholder=
"请输入
用户名
"
clearable
input-align=
"center"
@
input=
"usernameInput"
>
<van-field
:value=
"Account"
placeholder=
"请输入
预留手机号
"
clearable
input-align=
"center"
@
input=
"usernameInput"
>
</van-field>
<van-field
:value=
"Password"
password
placeholder=
"请输入密码"
clearable
input-align=
"center"
@
input=
"passwordInput"
>
<van-field
:value=
"Password"
v-if=
"userLoginType==2"
password
placeholder=
"请输入密码"
clearable
input-align=
"center"
@
input=
"passwordInput"
>
</van-field>
</van-cell-group>
</view>
<view
class=
"btnBox"
@
click=
"login"
>
立即登录
<van-loading
color=
"#f5f5f5"
v-if=
"loading"
/>
<text
v-else
>
立即登录
</text>
</view>
<view
class=
"login-bottom"
>
<view
class=
"login-bottom-text"
@
click=
"back"
>
返回
</view>
<!--
<view
class=
"login-bottom-text"
>
忘记密码
</view>
-->
</view>
</view>
<van-toast
id=
"van-toast"
/>
</view>
</
template
>
...
...
@@ -71,9 +87,17 @@
openid
:
""
,
code
:
""
,
show
:
false
,
userLoginType
:
1
,
//1为学员,2为老师
loading
:
false
});
let
methods
=
{
changeTypeHandler
(
t
){
data
.
userLoginType
=
t
if
(
t
==
1
){
msg
.
Password
=
''
}
},
usernameInput
(
val
)
{
msg
.
Account
=
val
.
detail
;
},
...
...
@@ -87,31 +111,43 @@
},
jumpPage
()
{
uni
.
reLaunch
({
url
:
"/pages/index/index"
,
url
:
data
.
userLoginType
==
1
?
"/pages/index/index"
:
'/pages/index/workSituation'
,
});
clearTimeout
();
//
clearTimeout();
},
async
login
()
{
if
(
data
.
loading
)
return
;
data
.
loading
=
true
if
(
msg
.
Account
==
""
||
!
msg
.
Account
)
{
Toast
.
fail
(
"请输入账号"
);
data
.
loading
=
true
return
;
}
if
(
msg
.
Password
==
""
||
!
msg
.
Password
)
{
if
(
(
msg
.
Password
==
""
||
!
msg
.
Password
)
&&
data
.
userLoginType
==
2
)
{
Toast
.
fail
(
"请输入密码"
);
data
.
loading
=
true
return
;
}
let
res
=
await
this
.
$request
(
'/Login/Login'
,
msg
).
then
(
res
=>
{
let
url
=
data
.
userLoginType
==
2
?
'/Login/Login'
:
'/Login/LoginByAccount'
let
res
=
await
this
.
$request
(
url
,
msg
).
then
(
res
=>
{
if
(
res
.
Code
==
1
){
res
.
Data
.
Account
=
msg
.
Account
;
uni
.
setStorageSync
(
"userInfo"
,
res
.
Data
);
Toast
.
success
(
"登录成功"
);
setTimeout
(()
=>
{
let
data
=
uni
.
getStorageSync
(
"userInfo"
);
if
(
data
)
{
that
.
jumpPage
();
}
},
1000
);
if
((
res
.
Data
.
AccountType
==
1
&&
data
.
userLoginType
==
2
)
||
res
.
Data
.
AccountType
==
2
&&
data
.
userLoginType
==
1
){
res
.
Data
.
Account
=
msg
.
Account
;
uni
.
setStorageSync
(
"userInfo"
,
res
.
Data
);
Toast
.
success
(
"登录成功"
);
setTimeout
(()
=>
{
let
data
=
uni
.
getStorageSync
(
"userInfo"
);
if
(
data
)
{
that
.
jumpPage
();
}
},
1000
);
}
else
{
data
.
loading
=
false
Toast
.
fail
(
"账号类型选择错误,请根据真实身份选择"
)
}
}
}).
catch
(
e
=>
{
data
.
loading
=
false
})
},
};
...
...
@@ -166,7 +202,7 @@
display
:
inline-block
;
}
.login-bottom
{
margin-bottom
:
1
36
rpx
;
margin-bottom
:
1
00
rpx
;
text-align
:
center
;
}
.login-title
{
...
...
@@ -198,11 +234,17 @@
background
:
-ms-linear-gradient
(
top
,
#C41726
0%
,
#831D1C
100%
);
background
:
linear-gradient
(
top
bottom
,
#C41726
0%
,
#831D1C
100%
);
}
.login-grey-avatar
{
-webkit-filter
:
grayscale
(
100%
);
}
.main
{
height
:
250
rpx
;
box-sizing
:
border-box
;
vertical-align
:
middle
;
padding
:
0
0
;
display
:
flex
;
flex-direction
:
column
;
justify-content
:
center
;
}
/
deep
/
.van-cell
{
height
:
88
rpx
;
...
...
@@ -217,12 +259,15 @@
overflow
:
hidden
;
margin
:
0
auto
;
margin-top
:
26
rpx
;
margin-bottom
:
11
0
rpx
;
margin-bottom
:
3
0
rpx
;
background-color
:
#C91727
;
font-size
:
30
rpx
;
font-weight
:
500
;
color
:
#FFFFFF
;
text-align
:
center
;
line-height
:
88
rpx
;
/* line-height: 88rpx; */
display
:
flex
;
flex-direction
:
column
;
justify-content
:
center
;
}
</
style
>
src/utils/request.js
View file @
976e2a75
//请求教育接口
let
host
=
''
if
(
process
.
env
.
NODE_ENV
===
"development"
)
{
host
=
'http://192.168.10.
46:8900
/api'
host
=
'http://192.168.10.
36:8082
/api'
// host = 'http://192.168.10.65:8085/api'
}
else
{
host
=
'https://eduapi.oytour.com/api'
...
...
@@ -32,9 +32,9 @@ let request = (param) => {
icon
:
"none"
,
});
uni
.
removeStorageSync
(
'userInfo'
);
//
uni.reLaunch({
//
url:"/pages/login/login"
//
})
uni
.
reLaunch
({
url
:
"/pages/login/login"
})
reject
()
}
else
{
uni
.
showToast
({
...
...
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