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
51c39e27
Commit
51c39e27
authored
Jan 06, 2022
by
Mac
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
修改登录信息
parent
5b07dae4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
310 additions
and
9 deletions
+310
-9
indexassembly.vue
src/pages/index/components/indexassembly.vue
+236
-0
index.vue
src/pages/index/index.vue
+28
-7
login.vue
src/pages/login/login.vue
+42
-2
request.js
src/utils/request.js
+4
-0
No files found.
src/pages/index/components/indexassembly.vue
0 → 100644
View file @
51c39e27
<
template
>
<view
class=
"indexassembly"
>
<view>
登录
<button
class=
"hotsopt"
style=
""
open-type=
"getUserInfo"
@
tap=
"getUserProfile()"
></button>
</view>
<van-popup
:show=
"showPhone"
>
<view
style=
"width: 70vw;background: #FFF;display: flex;flex-direction: column;align-items: center;padding-bottom: 20px;border-radius: 8px;"
>
<view
style=
"width: 100%;height: 45px;display: flex;align-items: center;justify-content: center;border-bottom: 1px solid #EBEBEB;"
>
手机号授权
</view>
<image
:src=
"obj.Photo"
style=
"width: 120rpx;height: 120rpx;border-radius: 50%;margin-top: 15px;"
>
</image>
<text
style=
"margin-top: 15px;font-size: 18px;font-weight: bold;"
>
{{
obj
.
Name
}}
</text>
<text
style=
"margin-top: 5px;font-size: 13px;"
>
申请获取您微信绑定的手机号码
</text>
<view
class=
"btn"
>
获取手机号
<button
type=
"default"
open-type=
"getPhoneNumber"
v-if=
"showLogin == true"
style=
"position: absolute;left: 0;top: 0;width: 100%;height: 100%;opacity: 0;"
@
getphonenumber=
" decryptPhoneNumber"
></button>
</view>
</view>
</van-popup>
</view>
</
template
>
<
script
>
import
{
reactive
,
toRefs
,
onMounted
,
inject
}
from
"vue"
;
import
{
login
,
phoneLogin
,
parsePhone
}
from
"../../../api/index"
;
export
default
{
name
:
""
,
props
:
{
state
:
String
,
},
components
:
{},
setup
(
props
,{
attrs
,
slots
,
emit
})
{
let
Toast
=
inject
(
"$toast"
);
let
data
=
reactive
({
obj
:
{
Name
:
''
,
Photo
:
''
,
},
showPhone
:
false
,
showLogin
:
true
,
//多次点击
});
let
methods
=
{
getUserProfile
()
{
//新的获取用户资料
var
that
=
this
;
wx
.
getUserProfile
({
desc
:
"用于完善资料"
,
// 声明获取用户个人信息后的用途,后续会展示在弹窗中,请谨慎填写
success
:
(
info
)
=>
{
// console.log(info);
data
.
obj
.
Name
=
info
.
userInfo
.
nickName
;
data
.
obj
.
Photo
=
info
.
userInfo
.
avatarUrl
;
data
.
showPhone
=
true
;
//显示获取手机号码弹窗
},
fail
:
()
=>
{
uni
.
showToast
({
title
:
"微信登录授权失败"
,
icon
:
"none"
,
});
},
});
},
decryptPhoneNumber
(
e
)
{
//授权手机号码
if
(
e
.
detail
.
errMsg
==
'getPhoneNumber:fail user deny'
)
{
//用户点击拒绝
uni
.
showToast
({
title
:
"微信手机号码授权失败"
,
icon
:
"none"
,
});
}
else
{
//授权通过
// console.log(e)
data
.
obj
.
iv
=
e
.
detail
.
iv
data
.
obj
.
encryptedData
=
e
.
detail
.
encryptedData
that
.
getCode
()
}
},
getCode
()
{
//获取code
uni
.
getProvider
({
service
:
"oauth"
,
success
:
function
(
res
)
{
if
(
~
res
.
provider
.
indexOf
(
"weixin"
))
{
uni
.
login
({
provider
:
"weixin"
,
success
:
(
res
)
=>
{
//获取code
data
.
obj
.
code
=
res
.
code
that
.
parsePhoneNum
(
data
.
obj
.
encryptedData
,
data
.
obj
.
iv
,
res
.
code
)
},
fail
:
()
=>
{
uni
.
showToast
({
title
:
"微信登录授权失败"
,
icon
:
"none"
,
});
},
});
}
else
{
uni
.
showToast
({
title
:
"请先安装微信或升级版本"
,
icon
:
"none"
,
});
}
},
});
},
//解密手机号
async
parsePhoneNum
(
encryptedData
,
iv
,
code
)
{
uni
.
showLoading
({
title
:
"登录中"
,
});
data
.
showLogin
=
false
;
//防止多次点击登录
let
res
=
await
parsePhone
({
encryptedData
,
iv
,
code
})
if
(
res
&&
res
.
Data
.
phoneNumber
)
{
data
.
obj
.
phoneNum
=
res
.
Data
.
phoneNumber
// data.obj.phoneNum = '19138490575'
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'
)
}
}
else
{
Toast
.
fail
(
"授权失败,请重新授权"
)
data
.
showLogin
=
true
;
//防止多次点击登录
uni
.
hideLoading
();
}
},
//手机号授权登录
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
(
"登录成功"
);
emit
(
'success'
)
data
.
showPhone
=
false
}
else
{
data
.
showLogin
=
true
;
//防止多次点击登录
data
.
showPhone
=
false
uni
.
hideLoading
();
if
(
res
.
Data
.
Error
==-
1
){
//如果没找到电话号码 就跳入登录
setTimeout
(()
=>
{
uni
.
reLaunch
({
url
:
'/pages/login/login'
});
},
1000
);
}
}
}
};
onMounted
(()
=>
{
// console.log(38, props);
});
let
that
=
methods
;
return
{
...
toRefs
(
data
),
...
methods
,
};
},
};
</
script
>
<
style
scoped
>
.indexassembly
{
width
:
200
rpx
;
height
:
60
rpx
;
line-height
:
60
rpx
;
}
.hotsopt
{
position
:
absolute
;
background
:
transparent
;
border
:
none
;
outline
:
none
;
opacity
:
0
;
left
:
0
;
top
:
0
;
width
:
100%
;
height
:
100%
;
}
.btn
{
width
:
280
rpx
;
height
:
60
rpx
;
border-radius
:
30
rpx
;
background
:
#4C50E7
;
font-size
:
14px
;
color
:
#FFFEFE
;
display
:
flex
;
align-items
:
center
;
justify-content
:
center
;
margin-top
:
20px
;
position
:
relative
;
}
</
style
>
src/pages/index/index.vue
View file @
51c39e27
...
...
@@ -16,9 +16,15 @@
@
click=
"jumpPage('/pages/login/login')"
/>
<view
class=
"grow"
>
<view
class=
"name"
>
{{
userinfo
.
AccountName
}}
</view>
<view
class=
"name"
v-if=
"userinfo.AccountName"
>
{{
userinfo
.
AccountName
?
userinfo
.
AccountName
:
''
}}
</view>
<view
v-else
>
<indexassembly
@
success=
'againdata'
></indexassembly>
</view>
<view
class=
"phone"
>
{{
userinfo
.
Account
}}
{{
userinfo
.
Account
?
userinfo
.
Account
:
''
}}
</view>
</view>
<view
class=
"saleInfo"
>
...
...
@@ -31,7 +37,7 @@
</view>
<view
class=
"info2 one_line"
>
<text
style=
"margin-right: 10rpx"
>
课程顾问
</text
>
{{
userinfo
.
EnterPhone2
}}
>
{{
userinfo
.
EnterPhone2
?
userinfo
.
EnterPhone2
:
'无'
}}
</view>
</view>
</view>
...
...
@@ -67,10 +73,10 @@
<image
:src=
"item.img"
class=
"LearningGarden-item-img"
/>
</view>
</view>
<view
class=
"title"
v-if=
"indexData.FeedBackList.length > 0"
>
<view
class=
"title"
v-if=
"indexData
&& indexData.FeedBackList && indexData
.FeedBackList.length > 0"
>
课程反馈
</view>
<view
class=
"feedback"
v-if=
"indexData.FeedBackList.length > 0"
>
<view
class=
"feedback"
v-if=
"indexData
&& indexData.FeedBackList && indexData
.FeedBackList.length > 0"
>
<view
class=
"feedback-info flex flex_start_center"
>
<image
:src=
"indexData.FeedBackList[0].TeacherIcon"
...
...
@@ -236,10 +242,10 @@
</view>
</van-cell>
</van-cell-group>
<view
v-if=
"indexData.paperList.length == 0"
>
<view
v-if=
"indexData
&& indexData.paperList && indexData
.paperList.length == 0"
>
<van-empty
description=
"暂无数据"
/>
</view>
<view
class=
"mytest flex"
v-if=
"indexData.paperList.length > 0"
>
<view
class=
"mytest flex"
v-if=
"indexData
&& indexData.paperList && indexData
.paperList.length > 0"
>
<view
v-for=
"(item, index) in indexData.paperList"
:key=
"index"
...
...
@@ -301,7 +307,11 @@ import {
import
{
getIndexInfo
}
from
"../../api/index"
;
import
{
getActivityList
}
from
"../../api/activity"
;
import
{
desensitization
}
from
"../../utils/index"
;
import
indexassembly
from
'./components/indexassembly.vue'
export
default
{
components
:
{
indexassembly
,
},
setup
(
props
)
{
let
{
proxy
}
=
getCurrentInstance
();
proxy
.
$isLogin
();
...
...
@@ -460,6 +470,17 @@ export default {
data
.
controls
=
true
}
},
againdata
(){
data
.
userinfo
=
uni
.
getStorageSync
(
"userInfo"
);
that
.
getIndexdata
();
that
.
getActivityData
();
data
.
userinfo
.
EnterPhone2
=
desensitization
(
data
.
userinfo
.
EnterPhone
,
3
,
-
4
);
}
};
onMounted
(()
=>
{
...
...
src/pages/login/login.vue
View file @
51c39e27
...
...
@@ -37,11 +37,15 @@
</view>
<view
class=
"flex flex_between_center btnBox"
>
<view
class=
"loginBtn flex flex_center_center"
@
click=
"login"
>
账号登录
</view>
<button
class=
"phoneBtn flex flex_center_center"
open-type=
"getPhoneNumber"
@
getphonenumber=
"getphonenumber"
@
click=
"login2"
>
手机号一键登录
</button>
<view
class=
"phoneBtn flex flex_center_center"
@
click=
"show=true"
>
游客登录
</view>
<!--
<button
class=
"phoneBtn flex flex_center_center"
open-type=
"getPhoneNumber"
@
getphonenumber=
"getphonenumber"
@
click=
"login2"
>
手机号一键登录
</button>
-->
</view>
<!--
<view
class=
"auth"
@
click=
"authLogin"
>
授权手机号一键登录
</view>
-->
<van-toast
id=
"van-toast"
/>
<van-dialog
:show=
'show'
title=
"标题"
message=
'游客登录,不能使用全部功能!'
show-cancel-button
@
cancel=
'show = false'
@
confirm=
'login3'
>
</van-dialog>
</view>
</
template
>
...
...
@@ -59,6 +63,8 @@ import {
}
from
"vue"
;
// import Toast from "../../wxcomponents/vant/toast/toast";
import
{
login
,
phoneLogin
,
parsePhone
}
from
"../../api/index"
;
import
{
Dialog
}
from
'../../wxcomponents/vant/dialog/index'
;
export
default
{
setup
(
props
,
context
)
{
let
{
proxy
}
=
getCurrentInstance
();
...
...
@@ -71,7 +77,9 @@ export default {
phoneNum
:
""
,
openid
:
""
,
code
:
""
,
show
:
false
});
let
methods
=
{
usernameInput
(
val
)
{
msg
.
Account
=
val
.
detail
;
...
...
@@ -170,6 +178,38 @@ export default {
}
},
1000
);
}
},
async
login3
(){
//游客登录
data
.
show
=
false
console
.
log
(
uni
.
getStorageSync
(
"temporarydh"
))
let
temporarydh
=
uni
.
getStorageSync
(
"temporarydh"
)
if
(
temporarydh
){
let
msg
=
{
Account
:
temporarydh
.
Account
,
OpenId
:
temporarydh
.
OpenId
,
unionid
:
temporarydh
.
unionid
,
WeChatName
:
temporarydh
.
WeChatName
,
WeChatPhoto
:
temporarydh
.
WeChatPhoto
,
IsVisitor
:
1
,
}
let
res
=
await
phoneLogin
(
msg
)
if
(
res
){
res
.
Data
.
Account
=
data
.
phoneNum
;
uni
.
setStorageSync
(
"userInfo"
,
res
.
Data
);
Toast
.
success
(
"登录成功"
);
setTimeout
(()
=>
{
let
data
=
uni
.
getStorageSync
(
"userInfo"
);
if
(
data
)
{
that
.
jumpPage
();
}
},
1000
);
}
}
else
{
uni
.
reLaunch
({
url
:
'/pages/index/index'
//没有授权登录
});
}
}
};
onMounted
(()
=>
{});
...
...
@@ -181,7 +221,7 @@ export default {
};
},
onLoad
(){
uni
.
clearStorage
();
//
uni.clearStorage();
}
};
</
script
>
...
...
src/utils/request.js
View file @
51c39e27
...
...
@@ -26,6 +26,7 @@ let request = (param) => {
if
(
res
.
data
.
Code
===
1
)
{
resolve
(
res
.
data
)
}
else
{
// Toast({
// type: 'fail',
// message: res.data.Message,
...
...
@@ -60,6 +61,9 @@ let request = (param) => {
// });
// }
// }
if
(
res
.
data
.
Code
===
0
&&
res
.
data
.
Data
.
Error
==-
1
){
//如果电话号码没有
resolve
(
res
.
data
)
}
}
});
}
...
...
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