Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
S
self-support
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
李俊赕
self-support
Commits
01078be8
Commit
01078be8
authored
Apr 18, 2023
by
刘文虎
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
更改用户授权方式-无需用户授权-code+手机验证码登录
parent
87f94581
Changes
10
Show whitespace changes
Inline
Side-by-side
Showing
10 changed files
with
770 additions
and
401 deletions
+770
-401
App.vue
src/App.vue
+3
-3
common.js
src/common/api/common.js
+10
-1
manifest.json
src/manifest.json
+10
-16
pages.json
src/pages.json
+1
-1
index.vue
src/pages/index/index.vue
+4
-0
learn.vue
src/pages/index/learn.vue
+7
-0
mine.vue
src/pages/index/mine.vue
+5
-1
index - 副本.vue
src/pages/login/index - 副本.vue
+418
-0
index.vue
src/pages/login/index.vue
+304
-372
about.vue
src/pages/mine/about/about.vue
+8
-7
No files found.
src/App.vue
View file @
01078be8
...
...
@@ -138,9 +138,9 @@ export default {
this
.
profileSet
(
this
)
this
.
profileAppend
(
this
)
}
else
{
uni
.
navigateTo
({
url
:
"pages/login/index"
,
});
//
uni.navigateTo({
//
url: "pages/login/index",
//
});
}
}
else
{
uni
.
showModal
({
...
...
src/common/api/common.js
View file @
01078be8
const
globalUrl
=
process
.
uniEnv
||
{}
const
ucenterApiUrl
=
globalUrl
.
ucenterUrl
.
apiUrl
let
commonApiFun
=
function
(
vm
){
/* 登录 */
let
loginWechatAuth
=
async
(
params
=
{})
=>
await
vm
.
$u
.
post
(
'/wxh-support-rest/rest/ssoinfo/wxapp/unify/authorization'
,
params
,
{
'content-type'
:
'application/x-www-form-urlencoded'
});
/* 2023-04-18 新版登录 */
let
newLoginWechatAuth
=
async
(
params
=
{})
=>
await
vm
.
$u
.
post
(
'/wxh-support-rest/rest/ssoinfo/wxapp/unify/authorization/v2'
,
params
,
{
'content-type'
:
'application/x-www-form-urlencoded'
});
/* 发送验证码 */
let
sendCode
=
async
(
params
=
{})
=>
await
vm
.
$u
.
post
(
'/wxh-support-rest/rest/ssoinfo/wxapp/sendMessage'
,
params
,
{
'content-type'
:
'application/x-www-form-urlencoded'
});
// 水印-查询用户自定义设置
let
getUserWatermark
=
async
(
params
=
{})
=>
await
vm
.
$u
.
post
(
'http://apidoc.banshouhui.com:3000/mock/89/getUserWatermark'
,
params
);
// 水印-保存用户自定义设置
...
...
@@ -9,6 +16,8 @@ let commonApiFun = function(vm){
const
commonApi
=
{
loginWechatAuth
,
newLoginWechatAuth
,
sendCode
,
getUserWatermark
,
saveUserWatermark
,
saveImage
...
...
src/manifest.json
View file @
01078be8
{
"name"
:
"
自营平台
"
,
"name"
:
"
扳手会
"
,
"appid"
:
"__UNI__05F3AA2"
,
"description"
:
""
,
"versionName"
:
"1.0.0"
,
"versionCode"
:
"100"
,
"transformPx"
:
false
,
"networkTimeout"
:
{
"connectSocket"
:
100000
,
"uploadFile"
:
100000
,
"downloadFile"
:
100000
"connectSocket"
:
100000
,
"uploadFile"
:
100000
,
"downloadFile"
:
100000
},
"app-plus"
:
{
"optimization"
:
{
...
...
@@ -67,7 +67,6 @@
"quickapp"
:
{},
/*
快应用特有相关
*/
"mp-weixin"
:
{
/*
微信小程序特有相关
*/
"appid"
:
"wx402a711597dddbaf"
,
"optimization"
:
{
"subPackages"
:
true
...
...
@@ -78,24 +77,19 @@
"minified"
:
true
},
"usingComponents"
:
true
,
"permission"
:
{
"scope.userLocation"
:
{
"desc"
:
"方便查看订单与你的距离"
}
},
"requiredPrivateInfos"
:
[
"getLocation"
,
"onLocationChange"
,
"startLocationUpdate"
],
"permission"
:
{
"scope.userLocation"
:
{
"desc"
:
"你的位置信息将用于小程序获取所在地与订单地点的距离"
}
},
"requiredPrivateInfos"
:
[
"getLocation"
,
"onLocationChange"
,
"startLocationUpdate"
],
"uniStatistics"
:
{
"enable"
:
true
},
"plugins"
:
{
"contactPlugin"
:
{
"version"
:
"1.4.4"
,
"provider"
:
"wx104a1a20c3f81ec2"
"plugins"
:
{
"contactPlugin"
:
{
"version"
:
"1.4.4"
,
"provider"
:
"wx104a1a20c3f81ec2"
}
}
},
...
...
src/pages.json
View file @
01078be8
...
...
@@ -40,7 +40,7 @@
{
"path"
:
"pages/login/index"
,
"style"
:
{
//
"navigationBarTitleText"
:
"授权登录
"
,
"navigationBarTitleText"
:
"绑定手机
"
,
"navigationBarBackgroundColor"
:
"#FFFFFF"
,
"disableScroll"
:
true
}
...
...
src/pages/index/index.vue
View file @
01078be8
...
...
@@ -205,6 +205,10 @@ export default {
this
.
loaded
=
true
;
}
else
{
this
.
loaded
=
true
;
if
(
this
.
freshing
)
{
this
.
triggered
=
false
;
this
.
freshing
=
false
;
}
}
},
loadMessageList
()
{
...
...
src/pages/index/learn.vue
View file @
01078be8
...
...
@@ -787,6 +787,13 @@ export default {
},
//跳转到assessment页面
aaa
(
index
)
{
if
(
!
this
.
vuex_token
)
{
uni
.
showToast
({
icon
:
'none'
,
title
:
"请先登录"
})
return
false
;
}
//examStatus 用户考试状态 0考试中 1考试完成 2未参与
//考试完成分成通过、未通过
getApp
().
globalData
.
questionTime
=
this
.
examList
[
index
].
questionTime
;
...
...
src/pages/index/mine.vue
View file @
01078be8
...
...
@@ -272,7 +272,11 @@ export default {
app
.
getBaseInfo
(
self
);
},
handleClick
(
path
,
isWarehouse
)
{
if
(
this
.
vuex_token
)
{
if
(
path
===
'about/about'
){
this
.
$u
.
route
({
url
:
'pages/mine/'
+
path
});
}
else
if
(
this
.
vuex_token
)
{
// 没入驻不能进入仓配相关页面
if
(
isWarehouse
&&
this
.
needSettled
)
{
this
.
$refs
.
uToast
.
show
({
...
...
src/pages/login/index - 副本.vue
0 → 100644
View file @
01078be8
<
template
>
<view
class=
""
>
<!--
<w-navbar></w-navbar>
-->
<view
class=
"backView"
>
<view
class=
"login-block"
v-if=
"needAuth"
>
<u-image
:fade=
"false"
class=
"u-flex u-row-center logo"
:src=
"logo"
width=
"200"
height=
"200"
>
<u-loading
slot=
"loading"
></u-loading>
<view
slot=
"error"
style=
"font-size: 24rpx;"
>
加载失败
</view>
</u-image>
<u-image
:fade=
"false"
class=
"u-flex u-row-center logo2"
:src=
"logo2"
width=
"214"
height=
"60"
>
<u-loading
slot=
"loading"
></u-loading>
<view
slot=
"error"
style=
"font-size: 24rpx;"
>
加载失败
</view>
</u-image>
</view>
<view
class=
"bind-block"
v-else
>
<u-image
:fade=
"false"
class=
"u-flex u-row-between logo"
:src=
"logo"
width=
"148"
height=
"148"
>
<u-loading
slot=
"loading"
></u-loading>
<view
slot=
"error"
style=
"font-size: 24rpx;"
>
加载失败
</view>
</u-image>
<view
class=
"bind-phone"
>
{{
bindPhone
}}
</view>
<view
class=
"bind-tips"
>
{{
bindTips
}}
</view>
</view>
<u-gap
height=
"480"
></u-gap>
<view
v-if=
"needAuth"
@
click
.
capture=
"loadLogin"
>
<button
class=
"loginBtn"
lang=
"zh_CN"
@
tap=
"getUserProfile"
>
<text
class=
"u-font-32 white"
>
{{
loginTitle
}}
</text>
</button>
</view>
<view
@
click
.
capture=
"getCode"
v-else
>
<button
class=
"loginBtn"
open-type=
"getPhoneNumber"
throttle-time=
"1000"
@
getphonenumber=
"signupLogin"
>
<text
class=
"u-font-32 white"
>
{{
bindTitle
}}
</text>
</button>
</view>
</view>
</view>
</
template
>
<
script
>
import
util
from
'@/utils/util.js'
import
login
from
'@/utils/login.js'
const
app
=
getApp
()
export
default
{
data
()
{
return
{
needAuth
:
true
,
TimeID
:
-
1
,
loginTitle
:
'用户登录'
,
bindTitle
:
'立即绑定'
,
bindPhone
:
'绑定手机'
,
bindTips
:
'首次登录的用户需绑定手机才可接单'
,
code
:
''
,
}
},
computed
:
{
logo
()
{
return
this
.
qnFile
(
'logo.png'
)
},
logo2
()
{
return
this
.
qnFile
(
'logo-2.png'
)
},
},
onLoad
(
e
)
{
app
.
trackPage
(
'授权登录页'
)
},
onShow
()
{
// 微信授权过用户信息,则无需重复授权
if
(
this
.
vuex_auth_user
&&
Object
.
keys
(
this
.
vuex_auth_user
).
length
)
{
this
.
needAuth
=
false
}
},
methods
:
{
loadLogin
()
{
uni
.
showLoading
({
title
:
'加载中..'
,
mask
:
true
});
},
qnFile
(
src
)
{
return
process
.
uniEnv
.
qn_base_url
+
src
},
async
getCode
()
{
login
.
appLogin
().
then
(
res
=>
{
this
.
code
=
res
.
code
})
},
// 微信授权用户信息
getUserProfile
()
{
var
that
=
this
if
(
uni
.
getUserProfile
)
{
// 每次触发 uni.getUserProfile 均会弹出授权窗口,用户授权后可成功获取用户信息
uni
.
getUserProfile
({
desc
:
'用于授权登录'
,
success
:
function
(
res
)
{
const
userInfo
=
res
.
userInfo
;
that
.
$u
.
vuex
(
'vuex_auth_user'
,
userInfo
)
uni
.
showLoading
({
title
:
'授权中..'
,
mask
:
true
});
if
(
getApp
().
globalData
.
logout
)
{
uni
.
hideLoading
()
that
.
setLoginStatus
()
}
else
{
that
.
authLogin
()
}
},
fail
:
function
(
res
)
{
uni
.
hideLoading
()
uni
.
showModal
({
title
:
'授权失败'
,
content
:
'请允许获取用户信息的授权'
,
showCancel
:
false
});
}
})
}
else
{
uni
.
hideLoading
()
// 可能由于账号配置,或者其他原因导致无法调起微信用户授权
uni
.
showModal
({
title
:
'授权失败'
,
content
:
'请确认你的用户授权是否可用'
,
showCancel
:
false
});
}
},
authLogin
()
{
var
that
=
this
let
params
=
{
nickname
:
this
.
vuex_auth_user
.
nickName
||
''
,
avatar
:
this
.
vuex_auth_user
.
avatarUrl
||
''
,
}
login
.
appLogin
().
then
(
res
=>
{
params
.
code
=
res
.
code
return
login
.
authorization
(
params
);
}).
then
(
res
=>
{
uni
.
hideLoading
();
if
(
res
&&
res
.
code
==
200
&&
res
.
data
&&
res
.
data
.
token
)
{
login
.
setUserData
(
res
.
data
,
that
)
app
.
track
(
'auth_login'
,
{
mobile
:
res
.
data
.
mobile
});
app
.
profileSet
(
that
)
app
.
profileAppend
(
that
)
that
.
goBackPage
()
}
else
{
that
.
setLoginStatus
()
}
}).
catch
(
res
=>
{
uni
.
hideLoading
()
that
.
setLoginStatus
()
})
},
inGetAuth
()
{
uni
.
showLoading
({
title
:
'授权中..'
,
mask
:
true
});
},
signupLogin
(
e
)
{
var
that
=
this
if
(
e
&&
e
.
detail
)
{
if
(
e
.
detail
.
errMsg
.
indexOf
(
'user deny'
)
>
-
1
)
{
uni
.
showModal
({
title
:
'提示'
,
showCancel
:
false
,
content
:
'用户未授权不能完成注册'
});
}
else
if
(
e
.
detail
.
encryptedData
&&
e
.
detail
.
iv
)
{
let
params
=
{
nickname
:
this
.
vuex_auth_user
.
nickName
||
''
,
avatar
:
this
.
vuex_auth_user
.
avatarUrl
||
''
,
encryptedData
:
e
.
detail
.
encryptedData
,
iv
:
e
.
detail
.
iv
,
}
if
(
that
.
code
)
{
that
.
inGetAuth
()
uni
.
checkSession
({
success
()
{
//session_key 未过期,并且在本生命周期一直有效
params
.
code
=
that
.
code
that
.
inGetAuth
()
login
.
signup
(
params
).
then
(
res
=>
{
that
.
inGetAuth
()
if
(
res
)
{
login
.
setUserData
(
res
.
data
,
that
)
app
.
track
(
'signup_login'
,
{
mobile
:
res
.
data
.
mobile
});
app
.
profileSet
(
that
)
app
.
profileAppend
(
that
)
app
.
getBaseInfo
(
that
)
uni
.
hideLoading
()
that
.
goBackPage
()
}
else
{
uni
.
hideLoading
()
uni
.
showToast
({
title
:
'授权失败,请重新授权'
,
icon
:
'none'
});
that
.
setLoginStatus
(
false
)
}
}).
catch
(
res
=>
{
uni
.
hideLoading
()
that
.
setLoginStatus
(
false
)
})
},
fail
()
{
// session_key 已经失效,需要重新执行登录流程
that
.
toLogin
(
params
)
}
})
}
else
{
that
.
toLogin
(
params
)
}
}
else
{
uni
.
hideLoading
()
uni
.
showModal
({
title
:
'提示'
,
showCancel
:
false
,
content
:
'用户取消授权'
});
}
}
else
{
uni
.
hideLoading
()
uni
.
showModal
({
title
:
'提示'
,
showCancel
:
false
,
content
:
'授权失败,请重新授权'
});
}
},
toLogin
(
params
)
{
login
.
appLogin
().
then
(
res
=>
{
params
.
code
=
res
.
code
return
login
.
signup
(
params
);
}).
then
(
res
=>
{
if
(
res
)
{
login
.
setUserData
(
res
.
data
,
this
)
app
.
track
(
'signup_login'
,
{
mobile
:
res
.
data
.
mobile
});
app
.
profileSet
(
this
)
app
.
profileAppend
(
this
)
app
.
getBaseInfo
(
this
)
this
.
goBackPage
()
}
else
{
uni
.
hideLoading
()
uni
.
showToast
({
title
:
'授权失败,请重新授权'
,
icon
:
'none'
});
this
.
setLoginStatus
(
false
)
}
}).
catch
(
res
=>
{
uni
.
hideLoading
()
this
.
setLoginStatus
(
false
)
})
},
goBackPage
()
{
let
pages
=
getCurrentPages
();
if
(
pages
.
length
)
{
let
index
=
pages
.
length
-
1
;
if
(
index
)
{
let
prevPage
=
pages
[
index
];
//上一个页面
if
(
prevPage
&&
prevPage
.
$vm
)
{
prevPage
.
$vm
.
isRefresh
=
true
;
}
uni
.
navigateBack
({
delta
:
1
})
}
else
{
uni
.
redirectTo
({
url
:
'pages/index/index'
})
}
}
else
{
uni
.
reLaunch
({
url
:
"pages/index/mine"
})
}
},
setLoginStatus
(
authed
=
true
)
{
getApp
().
globalData
.
logout
=
false
this
.
code
=
''
if
(
authed
)
{
this
.
needAuth
=
false
uni
.
setNavigationBarTitle
({
title
:
'登录页'
});
}
else
{
if
(
!
this
.
vuex_auth_user
||
!
Object
.
keys
(
this
.
vuex_auth_user
).
length
)
{
this
.
needAuth
=
true
uni
.
setNavigationBarTitle
({
title
:
'授权页'
});
}
}
},
//取消点击
cancelClick
:
function
()
{
uni
.
navigateBack
({})
},
}
}
</
script
>
<
style
lang=
"scss"
scoped
>
.backView
{
background-color
:
#FFFFFF
;
position
:
absolute
;
top
:
0
;
left
:
0
;
width
:
100%
;
height
:
100%
;
.login-block
{
margin-top
:
240rpx
;
}
.bind-block
{
margin-top
:
202rpx
;
margin-left
:
50rpx
;
.bind-phone
{
font-size
:
52rpx
;
margin-top
:
48rpx
;
font-weight
:
bold
;
color
:
#333333
;
line-height
:
52rpx
;
margin-left
:
10rpx
;
}
.bind-tips
{
margin
:
24rpx
60rpx
14rpx
10rpx
;
font-size
:
28rpx
;
font-weight
:
400
;
color
:
#999999
;
line-height
:
40rpx
;
}
}
}
.logo2
{
margin-top
:
28rpx
;
}
.noticeView
{
background-color
:
#FFFFFF
;
width
:
100%
;
height
:
470rpx
;
display
:
flex
;
flex-direction
:
column
;
align-items
:
center
;
}
.noticeImage
{
background-color
:
#FFFFFF
;
width
:
386rpx
;
height
:
270rpx
;
margin-top
:
180rpx
;
}
.noticeTitleView
{
margin-top
:
80rpx
;
width
:
100%
;
display
:
flex
;
align-items
:
center
;
justify-content
:
center
;
}
.noticeTitle
{
width
:
60%
;
font-size
:
24rpx
;
color
:
#999999
;
text-align
:
center
;
line-height
:
40rpx
;
}
.loginBtn
{
background-color
:
#2272FF
;
font-size
:
32rpx
;
font-weight
:
600
;
color
:
#FFFFFF
;
line-height
:
104px
;
width
:
600rpx
;
height
:
104rpx
;
border-radius
:
52rpx
;
display
:
flex
;
align-items
:
center
;
justify-content
:
center
;
}
.disable
{
background-color
:
#2272FF
!
important
;
font-size
:
32rpx
;
font-weight
:
600
;
color
:
#FFFFFF
!
important
;
line-height
:
104px
;
width
:
600rpx
;
height
:
104rpx
;
border-radius
:
52rpx
;
display
:
flex
;
align-items
:
center
;
justify-content
:
center
;
}
.cancelView
{
width
:
100%
;
margin-top
:
30rpx
;
display
:
flex
;
align-items
:
center
;
justify-content
:
center
;
}
.cancelText
{
color
:
#666666
;
font-size
:
32rpx
;
}
.white
{
color
:
#FFFFFF
;
}
</
style
>
src/pages/login/index.vue
View file @
01078be8
<
template
>
<view
class=
""
>
<!--
<w-navbar></w-navbar>
-->
<view
class=
"backView"
>
<view
class=
"login-block"
v-if=
"needAuth"
>
<u-image
:fade=
"false"
class=
"u-flex u-row-center logo"
:src=
"logo"
width=
"200"
height=
"200"
>
<u-loading
slot=
"loading"
></u-loading>
<view
slot=
"error"
style=
"font-size: 24rpx;"
>
加载失败
</view>
</u-image>
<u-image
:fade=
"false"
class=
"u-flex u-row-center logo2"
:src=
"logo2"
width=
"214"
height=
"60"
>
<u-loading
slot=
"loading"
></u-loading>
<view
slot=
"error"
style=
"font-size: 24rpx;"
>
加载失败
</view>
</u-image>
<view
class=
"binding-phone-view"
>
<view
class=
"title-view"
>
绑定手机
</view>
<view
class=
"text-view"
>
首次登录的用户需绑定手机
</view>
<view
class=
"phone-view"
>
<view
class=
"left-view"
>
+86
</view>
<view
class=
"middle-view"
></view>
<view
class=
"right-view"
><input
v-model=
"phone"
type=
"number"
width=
"100%"
maxlength=
"20"
clearable
/>
</view>
<view
class=
"bind-block"
v-else
>
<u-image
:fade=
"false"
class=
"u-flex u-row-between logo"
:src=
"logo"
width=
"148"
height=
"148"
>
<u-loading
slot=
"loading"
></u-loading>
<view
slot=
"error"
style=
"font-size: 24rpx;"
>
加载失败
</view>
</u-image>
<view
class=
"bind-phone"
>
{{
bindPhone
}}
</view>
<view
class=
"bind-tips"
>
{{
bindTips
}}
</view>
</view>
<u-gap
height=
"480"
></u-gap>
<view
v-if=
"needAuth"
@
click
.
capture=
"loadLogin"
>
<button
class=
"loginBtn"
lang=
"zh_CN"
@
tap=
"getUserProfile"
>
<text
class=
"u-font-32 white"
>
{{
loginTitle
}}
</text>
</button>
<view
class=
"code-view"
>
<view
class=
"left-view"
><input
v-model=
"code"
type=
"number"
maxlength=
"6"
clearable
/></view>
<view
class=
"right-view"
>
<u-toast
ref=
"uToast"
></u-toast>
<u-verification-code
keep-running
unique-key=
"binding-phone"
:seconds=
"seconds"
@
end=
"end"
@
start=
"start"
ref=
"uCode"
@
change=
"codeChange"
></u-verification-code>
<text
:class=
"
{ active: canGetCode }" @tap="$u.throttle(handleClick, 500)">
{{
tips
}}
</text>
</view>
<view
@
click
.
capture=
"getCode"
v-else
>
<button
class=
"loginBtn"
open-type=
"getPhoneNumber"
throttle-time=
"1000"
@
getphonenumber=
"signupLogin"
>
<text
class=
"u-font-32 white"
>
{{
bindTitle
}}
</text>
</button>
</view>
<view
class=
"bottom-vew"
>
<u-button
type=
"primary"
:disabled=
"disabled"
:customStyle=
"buttonStyle"
:loading=
"loading"
@
click=
"handleClickSave"
>
<view
class=
"button-text"
>
立即绑定
</view>
</u-button>
</view>
</view>
</
template
>
<
script
>
import
util
from
'@/utils/util.js'
import
login
from
'@/utils/login.js'
const
app
=
getApp
()
export
default
{
import
login
from
'@/utils/login.js'
;
const
app
=
getApp
()
export
default
{
data
()
{
return
{
needAuth
:
true
,
TimeID
:
-
1
,
loginTitle
:
'用户登录'
,
bindTitle
:
'立即绑定'
,
bindPhone
:
'绑定手机'
,
bindTips
:
'首次登录的用户需绑定手机才可接单'
,
code
:
''
,
phone
:
'13423831191'
,
code
:
'174253'
,
timer
:
null
,
canGetCode
:
true
,
seconds
:
60
,
encryptedData
:
''
,
iv
:
''
,
loading
:
false
,
weixinAuthService
:
null
,
params
:
{},
tips
:
''
,
buttonStyle
:
{
height
:
'104rpx'
,
backgroundColor
:
'#2979ff'
,
color
:
'transparent'
}
};
},
computed
:
{
logo
()
{
return
this
.
qnFile
(
'logo.png'
)
},
logo2
()
{
return
this
.
qnFile
(
'logo-2.png'
)
},
disabled
()
{
return
this
.
code
&&
this
.
phone
?
false
:
true
;
}
},
onLoad
(
e
)
{
app
.
trackPage
(
'授权登录页'
)
onReady
(
)
{
this
.
canGetCode
=
this
.
$refs
.
uCode
.
canGetCode
?
true
:
false
;
},
onShow
()
{
// 微信授权过用户信息,则无需重复授权
if
(
this
.
vuex_auth_user
&&
Object
.
keys
(
this
.
vuex_auth_user
).
length
)
{
this
.
needAuth
=
false
onLoad
(
options
)
{
console
.
log
(
'-----options----'
,
options
);
if
(
options
)
{
let
{
unionId
}
=
options
;
if
(
unionId
)
{
this
.
params
=
options
;
}
}
},
methods
:
{
loadLogin
()
{
uni
.
showLoading
({
title
:
'加载中..'
,
mask
:
true
handleClick
()
{
if
(
this
.
phone
==
''
)
{
uni
.
showToast
({
title
:
'请输入手机号'
,
icon
:
'none'
,
duration
:
1500
});
return
;
}
var
reg
=
/^
[
1
][
3456789
][
0-9
]{9}
$/
;
if
(
!
reg
.
test
(
this
.
phone
))
{
uni
.
showToast
({
icon
:
'none'
,
title
:
'请输入正确的手机号'
});
return
false
;
}
this
.
startCode
();
},
qnFile
(
src
)
{
return
process
.
uniEnv
.
qn_base_url
+
src
startCode
()
{
if
(
this
.
$refs
.
uCode
.
canGetCode
)
{
// 模拟向后端请求验证码
this
.
$u
.
toast
(
'正在获取验证码'
);
this
.
getCode
();
}
},
async
getCode
()
{
login
.
appLogin
().
then
(
res
=>
{
this
.
code
=
res
.
code
})
},
// 微信授权用户信息
getUserProfile
()
{
var
that
=
this
if
(
uni
.
getUserProfile
)
{
// 每次触发 uni.getUserProfile 均会弹出授权窗口,用户授权后可成功获取用户信息
uni
.
getUserProfile
({
desc
:
'用于授权登录'
,
success
:
function
(
res
)
{
const
userInfo
=
res
.
userInfo
;
that
.
$u
.
vuex
(
'vuex_auth_user'
,
userInfo
)
uni
.
showLoading
({
title
:
'授权中..'
,
mask
:
true
try
{
let
res
=
await
uni
.
$u
.
api
.
sendCode
({
mobile
:
this
.
phone
});
if
(
getApp
().
globalData
.
logout
)
{
uni
.
hideLoading
()
that
.
setLoginStatus
()
uni
.
hideLoading
();
if
(
res
.
data
)
{
this
.
$u
.
toast
(
'验证码已发送'
);
this
.
$refs
.
uCode
.
start
();
console
.
log
(
'--------发送成功----------'
);
}
else
{
that
.
authLogin
()
}
},
fail
:
function
(
res
)
{
uni
.
hideLoading
()
uni
.
showModal
({
title
:
'授权失败'
,
content
:
'请允许获取用户信息的授权'
,
showCancel
:
false
uni
.
showToast
({
title
:
'获取验证码失败'
,
icon
:
'none'
});
}
})
}
else
{
uni
.
hideLoading
()
// 可能由于账号配置,或者其他原因导致无法调起微信用户授权
uni
.
showModal
({
title
:
'授权失败'
,
content
:
'请确认你的用户授权是否可用'
,
showCancel
:
false
}
catch
(
e
)
{
console
.
log
(
e
);
if
(
e
.
msg
)
{
uni
.
showToast
({
title
:
e
.
msg
,
icon
:
'none'
});
}
},
authLogin
()
{
var
that
=
this
let
params
=
{
nickname
:
this
.
vuex_auth_user
.
nickName
||
''
,
avatar
:
this
.
vuex_auth_user
.
avatarUrl
||
''
,
}
login
.
appLogin
().
then
(
res
=>
{
params
.
code
=
res
.
code
return
login
.
authorization
(
params
);
}).
then
(
res
=>
{
//TODO handle the exception
uni
.
hideLoading
();
if
(
res
&&
res
.
code
==
200
&&
res
.
data
&&
res
.
data
.
token
)
{
login
.
setUserData
(
res
.
data
,
that
)
app
.
track
(
'auth_login'
,
{
mobile
:
res
.
data
.
mobile
});
app
.
profileSet
(
that
)
app
.
profileAppend
(
that
)
that
.
goBackPage
()
}
else
{
that
.
setLoginStatus
()
}
}).
catch
(
res
=>
{
uni
.
hideLoading
()
that
.
setLoginStatus
()
})
},
inGetAuth
()
{
uni
.
showLoading
({
title
:
'授权中..'
,
mask
:
true
});
handleClickSave
()
{
this
.
signup
();
},
signupLogin
(
e
)
{
var
that
=
this
if
(
e
&&
e
.
detail
)
{
if
(
e
.
detail
.
errMsg
.
indexOf
(
'user deny'
)
>
-
1
)
{
uni
.
showModal
({
title
:
'提示'
,
showCancel
:
false
,
content
:
'用户未授权不能完成注册'
});
}
else
if
(
e
.
detail
.
encryptedData
&&
e
.
detail
.
iv
)
{
let
params
=
{
nickname
:
this
.
vuex_auth_user
.
nickName
||
''
,
avatar
:
this
.
vuex_auth_user
.
avatarUrl
||
''
,
encryptedData
:
e
.
detail
.
encryptedData
,
iv
:
e
.
detail
.
iv
,
}
if
(
that
.
code
)
{
that
.
inGetAuth
()
uni
.
checkSession
({
success
()
{
//session_key 未过期,并且在本生命周期一直有效
params
.
code
=
that
.
code
that
.
inGetAuth
()
login
.
signup
(
params
).
then
(
res
=>
{
that
.
inGetAuth
()
if
(
res
)
{
login
.
setUserData
(
res
.
data
,
that
)
app
.
track
(
'signup_login'
,
{
mobile
:
res
.
data
.
mobile
});
app
.
profileSet
(
that
)
app
.
profileAppend
(
that
)
app
.
getBaseInfo
(
that
)
uni
.
hideLoading
()
that
.
goBackPage
()
}
else
{
uni
.
hideLoading
()
signup
()
{
this
.
loading
=
true
;
var
reg
=
/^
[
1
][
3456789
][
0-9
]{9}
$/
;
if
(
!
reg
.
test
(
this
.
phone
))
{
uni
.
showToast
({
title
:
'授权失败,请重新授权
'
,
icon
:
'none
'
icon
:
'none
'
,
title
:
'请输入正确的手机号
'
});
that
.
setLoginStatus
(
false
)
}
}).
catch
(
res
=>
{
uni
.
hideLoading
()
that
.
setLoginStatus
(
false
)
})
},
fail
()
{
// session_key 已经失效,需要重新执行登录流程
that
.
toLogin
(
params
)
this
.
loading
=
false
;
return
false
;
}
})
if
(
uni
.
$u
.
platform
===
'4'
)
{
this
.
onAppLogin
();
}
else
{
that
.
toLogin
(
params
)
}
}
else
{
uni
.
hideLoading
()
uni
.
showModal
({
title
:
'提示'
,
showCancel
:
false
,
content
:
'用户取消授权'
});
this
.
onWxLogin
();
}
}
else
{
uni
.
hideLoading
()
uni
.
showModal
({
title
:
'提示'
,
showCancel
:
false
,
content
:
'授权失败,请重新授权'
});
},
async
onWxLogin
()
{
try
{
let
res
=
await
login
.
appLogin
();
let
params
=
{
code
:
res
.
code
,
// nickname: userInfo.nickName,
// avatar: userInfo.avatarUrl,
// encryptedData: this.encryptedData,
// iv: this.iv,
// verify: this.code,
};
this
.
onAppLogin
(
params
)
}
catch
(
e
)
{
console
.
log
(
'onWxLogin:fail'
,
e
);
this
.
loading
=
false
;
//TODO handle the exception
}
this
.
loading
=
false
;
},
toLogin
(
params
)
{
login
.
appLogin
().
then
(
res
=>
{
params
.
code
=
res
.
code
return
login
.
signup
(
params
);
}).
then
(
res
=>
{
if
(
res
)
{
async
onAppLogin
(
paramsData
=
{})
{
let
params
=
{
...
paramsData
,
mobileCode
:
this
.
code
,
mobile
:
this
.
phone
,
wxAppNo
:
1
};
try
{
let
res
=
await
uni
.
$u
.
api
.
newLoginWechatAuth
(
params
);
if
(
res
&&
res
.
code
===
200
)
{
login
.
setUserData
(
res
.
data
,
this
)
app
.
track
(
'signup_login'
,
{
mobile
:
res
.
data
.
mobile
});
app
.
profileSet
(
this
)
app
.
profileAppend
(
this
)
app
.
getBaseInfo
(
this
)
uni
.
showToast
({
title
:
'登录成功'
,
icon
:
'none'
,
mask
:
true
});
setTimeout
(()
=>
{
this
.
goBackPage
()
},
1000
);
}
else
{
this
.
loading
=
false
;
uni
.
hideLoading
()
uni
.
showToast
({
title
:
'授权失败,请重新授权
'
,
title
:
'登录失败,请重新登录
'
,
icon
:
'none'
});
this
.
setLoginStatus
(
false
)
}
}).
catch
(
res
=>
{
uni
.
hideLoading
()
this
.
setLoginStatus
(
false
)
})
}
catch
(
e
)
{
console
.
log
(
'onAppLogin'
,
e
);
//TODO handle the exception
}
this
.
loading
=
false
;
},
toPage
(){
if
(
this
.
returnUrl
)
{
// 需要跳转到特定页面
var
isSwitchTab
=
this
.
returnUrl
.
indexOf
(
'pages/index/'
)
!=
-
1
;
this
.
$u
.
route
({
url
:
this
.
returnUrl
,
type
:
isSwitchTab
?
'switchTab'
:
'redirectTo'
});
}
else
{
uni
.
switchTab
({
url
:
'/pages/index/index'
});
}
},
goBackPage
()
{
let
pages
=
getCurrentPages
();
...
...
@@ -279,140 +243,108 @@ export default {
setLoginStatus
(
authed
=
true
)
{
getApp
().
globalData
.
logout
=
false
this
.
code
=
''
if
(
authed
)
{
this
.
needAuth
=
false
uni
.
setNavigationBarTitle
({
title
:
'登录页'
});
}
else
{
if
(
!
this
.
vuex_auth_user
||
!
Object
.
keys
(
this
.
vuex_auth_user
).
length
)
{
this
.
needAuth
=
true
uni
.
setNavigationBarTitle
({
title
:
'授权页'
});
}
}
},
codeChange
(
text
)
{
this
.
tips
=
text
;
},
//取消点击
cancelClick
:
function
()
{
uni
.
navigateBack
({})
end
()
{
console
.
log
(
'end'
);
this
.
canGetCode
=
true
;
},
start
()
{
console
.
log
(
'start'
);
this
.
canGetCode
=
false
;
},
}
}
};
</
script
>
<
style
lang=
"scss"
scoped
>
.backView
{
background-color
:
#FFFFFF
;
position
:
absolute
;
top
:
0
;
left
:
0
;
width
:
100%
;
height
:
100%
;
<
style
scoped
lang=
"scss"
>
.binding-phone-view
{
padding
:
60rpx
;
background-color
:
#ffffff
;
height
:
100vh
;
.login-block
{
margin-top
:
240rpx
;
}
.bind-block
{
margin-top
:
202rpx
;
margin-left
:
50rpx
;
.bind-phone
{
.title-view
{
font-size
:
52rpx
;
margin-top
:
48rpx
;
font-weight
:
bold
;
color
:
#333333
;
line-height
:
52rpx
;
margin-
left
:
10
rpx
;
font-weight
:
bold
;
margin-
bottom
:
24
rpx
;
}
.bind-tips
{
margin
:
24rpx
60rpx
14rpx
10rpx
;
.text-view
{
font-size
:
28rpx
;
font-weight
:
400
;
color
:
#999999
;
line-height
:
40rpx
;
}
color
:
#8d8d8d
;
margin-bottom
:
88rpx
;
}
}
.logo2
{
margin-top
:
28rpx
;
}
.noticeView
{
background-color
:
#FFFFFF
;
width
:
100%
;
height
:
470rpx
;
.phone-view
{
display
:
flex
;
flex-direction
:
column
;
align-items
:
center
;
}
font-weight
:
bold
;
font-size
:
28rpx
;
color
:
#333333
;
background-color
:
#fafafa
;
border-radius
:
16rpx
;
height
:
104rpx
;
padding
:
0
32rpx
;
margin-bottom
:
48rpx
;
.noticeImage
{
background-color
:
#FFFFFF
;
width
:
386rpx
;
height
:
270rpx
;
margin-top
:
180rpx
;
}
.left-view
{
width
:
66rpx
;
text-align
:
left
;
flex-shrink
:
0
;
}
.noticeTitleV
iew
{
margin-top
:
80rpx
;
width
:
100%
;
display
:
fle
x
;
align-items
:
center
;
justify-content
:
center
;
}
.middle-v
iew
{
background-color
:
#8d8d8d
;
width
:
4rpx
;
height
:
28rp
x
;
margin
:
0
12rpx
;
flex-shrink
:
0
;
}
.noticeTitle
{
width
:
60%
;
font-size
:
24rpx
;
color
:
#999999
;
text-align
:
center
;
line-height
:
40rpx
;
}
.right-view
{
flex
:
1
;
padding-left
:
8rpx
;
}
}
.loginBtn
{
background-color
:
#2272FF
;
font-size
:
32rpx
;
font-weight
:
600
;
color
:
#FFFFFF
;
line-height
:
104px
;
width
:
600rpx
;
height
:
104rpx
;
border-radius
:
52rpx
;
.code-view
{
display
:
flex
;
align-items
:
center
;
justify-content
:
center
;
}
.disable
{
background-color
:
#2272FF
!
important
;
font-size
:
32rpx
;
font-weight
:
600
;
color
:
#FFFFFF
!
important
;
line-height
:
104px
;
width
:
600rpx
;
justify-content
:
space-between
;
font-weight
:
bold
;
font-size
:
28rpx
;
color
:
#333333
;
background-color
:
#fafafa
;
border-radius
:
16rpx
;
height
:
104rpx
;
border-radius
:
52rpx
;
display
:
flex
;
align-items
:
center
;
justify-content
:
center
;
}
padding
:
0
32rpx
;
margin-bottom
:
96rpx
;
.cancelView
{
width
:
100%
;
margin-top
:
30rpx
;
display
:
flex
;
align-items
:
center
;
justify-content
:
center
;
}
.left-view
{
width
:
330rpx
;
}
.cancelText
{
color
:
#666666
;
font-size
:
32rpx
;
}
.right-view
{
font-weight
:
400
;
.white
{
color
:
#FFFFFF
;
}
.active
{
color
:
#3383fe
;
}
}
}
.bottom-vew
{
.button-text
{
color
:
#ffffff
;
height
:
104rpx
;
line-height
:
104rpx
;
font-weight
:
bold
;
font-size
:
32rpx
;
}
}
}
</
style
>
\ No newline at end of file
src/pages/mine/about/about.vue
View file @
01078be8
...
...
@@ -40,13 +40,14 @@
},
methods
:
{
handleClick
(
path
)
{
if
(
this
.
vuex_token
)
{
this
.
$u
.
route
({
url
:
'pages/mine/'
+
path
})
}
else
{
this
.
$u
.
route
({
url
:
"pages/login/index"
})
}
// if(this.vuex_token) {
// } else {
// this.$u.route({url: "pages/login/index"})
// }
},
}
};
...
...
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