Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
F
fns_front_2
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
JIRA
JIRA
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
chenqikuai
fns_front_2
Commits
855b8371
Commit
855b8371
authored
Nov 22, 2021
by
chenqikuai
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix: 修复鉴权两次的问题
parent
953e29f0
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
172 additions
and
172 deletions
+172
-172
App.vue
src/App.vue
+0
-0
index.ts
src/service/UserManagementService/index.ts
+47
-53
index.ts
src/service/UserService/index.ts
+27
-21
userMsg.ts
src/types/userMsg.ts
+7
-10
userMsg.ts
src/utils/userMsg.ts
+19
-20
index.vue
src/views/Auth/index.vue
+70
-62
index.vue
src/views/withMenu/Loan/index.vue
+2
-6
No files found.
src/App.vue
View file @
855b8371
This diff is collapsed.
Click to expand it.
src/service/UserManagementService/index.ts
View file @
855b8371
import
{
eLevel
,
eNewRoleRelatedToBackEnd
,
eRole
}
from
'@/types/roleType'
import
baseAxios
from
'../index'
import
{
eCheckPhoneStatus
}
from
'./types'
import
{
eLevel
,
eNewRoleRelatedToBackEnd
,
eRole
}
from
"@/types/roleType"
;
import
baseAxios
from
"../index"
;
import
{
eCheckPhoneStatus
}
from
"./types"
;
const
prefix
=
'/user'
const
prefix
=
"/user"
;
/* 成功修改后会退出登录 */
export
function
userChangePhone
(
data
:
{
newPhone
:
string
newVerifyCode
:
string
phone
:
string
verifyCode
:
string
newPhone
:
string
;
newVerifyCode
:
string
;
phone
:
string
;
verifyCode
:
string
;
})
{
return
baseAxios
({
method
:
'post'
,
url
:
prefix
+
'/change/phone'
,
method
:
"post"
,
url
:
prefix
+
"/change/phone"
,
data
,
})
})
;
}
/* 成功修改后会退出登录 */
export
function
userChangePwd
(
data
:
{
new_pwd
:
string
phone
:
string
verify_code
:
string
new_pwd
:
string
;
phone
:
string
;
verify_code
:
string
;
})
{
return
baseAxios
({
method
:
'post'
,
url
:
'/change/pwd'
,
method
:
"post"
,
url
:
"/change/pwd"
,
data
,
})
})
;
}
export
function
userCheckPhone
(
phone
:
string
)
{
return
baseAxios
<
eCheckPhoneStatus
>
({
url
:
prefix
+
'/check/phone'
,
method
:
'get'
,
url
:
prefix
+
"/check/phone"
,
method
:
"get"
,
params
:
{
phone
,
},
})
})
;
}
export
function
userCreate
(
data
:
{
phone
:
string
staffID
?:
string
verifyCode
:
string
phone
:
string
;
staffID
?:
string
;
verifyCode
:
string
;
})
{
return
baseAxios
({
url
:
prefix
+
'/create'
,
method
:
'POST'
,
url
:
prefix
+
"/create"
,
method
:
"POST"
,
data
,
})
})
;
}
/* 用户可通过验证码或密码登录 */
export
function
userLogin
(
data
:
{
is_admin
:
boolean
phone
:
string
use_pwd
:
boolean
pwd
?:
string
verify_code
?:
string
is_admin
:
boolean
;
phone
:
string
;
use_pwd
:
boolean
;
pwd
?:
string
;
verify_code
?:
string
;
})
{
return
baseAxios
<
{
accessToken
:
string
level
:
eLevel
phone
:
string
role
:
eNewRoleRelatedToBackEnd
pri_key
:
string
pub_key
:
string
addr
:
string
accessToken
:
string
;
level
:
eLevel
;
phone
:
string
;
role
:
eNewRoleRelatedToBackEnd
;
}
>
({
url
:
'/login'
,
method
:
'POST'
,
url
:
"/login"
,
method
:
"POST"
,
data
,
})
})
;
}
export
function
userLogout
()
{
return
baseAxios
({
url
:
'/logout'
,
method
:
'GET'
,
})
url
:
"/logout"
,
method
:
"GET"
,
})
;
}
export
function
userRegister
(
data
:
{
phone
:
string
;
verify_code
:
string
})
{
return
baseAxios
<
{
accessToken
:
string
phone
:
string
role
:
eNewRoleRelatedToBackEnd
pri_key
:
string
pub_key
:
string
addr
:
string
accessToken
:
string
;
phone
:
string
;
role
:
eNewRoleRelatedToBackEnd
;
}
>
({
url
:
'/user/register'
,
method
:
'post'
,
url
:
"/user/register"
,
method
:
"post"
,
data
,
})
})
;
}
// function padding(all: number): any;
...
...
src/service/UserService/index.ts
View file @
855b8371
import
baseAxios
from
'../index'
import
{
iContact
,
iUserinfo
}
from
'./types'
import
baseAxios
from
"../index"
;
import
{
iContact
,
iUserinfo
}
from
"./types"
;
class
UserService
{
static
instance
:
UserService
static
instance
:
UserService
;
static
getInstance
()
{
if
(
!
UserService
.
instance
)
{
UserService
.
instance
=
new
UserService
()
UserService
.
instance
=
new
UserService
()
;
}
return
UserService
.
instance
return
UserService
.
instance
;
}
contact_custom_service
(
data
:
{
outLetID
:
number
})
{
return
baseAxios
<
iContact
>
({
url
:
'/user/contact_custom_service'
,
method
:
'post'
,
url
:
"/user/contact_custom_service"
,
method
:
"post"
,
data
,
})
})
;
}
staffInfo
(
data
:
{
addrs
:
string
[]
})
{
return
baseAxios
<
{
total
:
number
item
:
(
iContact
&
{
out_let_name
:
string
})[]
total
:
number
;
item
:
(
iContact
&
{
out_let_name
:
string
})[]
;
}
>
({
url
:
'/user/staff_info'
,
method
:
'get'
,
url
:
"/user/staff_info"
,
method
:
"get"
,
params
:
data
,
paramsSerializer
:
(
data
:
{
addrs
:
string
[]
})
=>
{
console
.
log
(
data
)
return
`addrs=
${
data
.
addrs
.
toString
()}
`
console
.
log
(
data
)
;
return
`addrs=
${
data
.
addrs
.
toString
()}
`
;
},
})
})
;
}
userInfo
(
data
:
{
addrs
:
string
[]
})
{
return
baseAxios
<
iUserinfo
[]
>
({
url
:
'/user/user_info'
,
method
:
'get'
,
url
:
"/user/user_info"
,
method
:
"get"
,
params
:
data
,
paramsSerializer
:
(
data
:
{
addrs
:
string
[]
})
=>
{
console
.
log
(
data
)
return
`addrs=
${
data
.
addrs
.
toString
()}
`
console
.
log
(
data
)
;
return
`addrs=
${
data
.
addrs
.
toString
()}
`
;
},
})
});
}
getChatToken
()
{
return
baseAxios
<
{
addr
:
string
;
token
:
string
}
>
({
url
:
"/chat_info"
,
});
}
}
export
default
UserService
export
default
UserService
;
src/types/userMsg.ts
View file @
855b8371
import
{
eRole
}
from
'./roleType'
import
{
eRole
}
from
"./roleType"
;
export
interface
iUserMsg
{
token
:
string
role
:
eRole
role2
:
eRole
token
:
string
;
role
:
eRole
;
role2
:
eRole
;
userInfo
:
{
phone
?:
string
addr
:
string
pri_key
:
string
pub_key
:
string
[
key
:
string
]:
any
}
phone
?:
string
;
addr
?:
string
;
};
}
src/utils/userMsg.ts
View file @
855b8371
import
{
dispatchLoginAction
}
from
'@/store/chatStore'
import
{
iUserMsg
}
from
'@/types/userMsg'
import
Bridge
from
'@/utils/jsBridge2'
import
userAvatarUrl
from
'@/assets/icons/avatar.png'
import
staffAvatarUrl
from
'@/assets/icons/staff.png'
import
{
eRole
}
from
'@/types/roleType'
import
{
dispatchLoginAction
}
from
"@/store/chatStore"
;
import
{
iUserMsg
}
from
"@/types/userMsg"
;
import
Bridge
from
"@/utils/jsBridge2"
;
import
userAvatarUrl
from
"@/assets/icons/avatar.png"
;
import
staffAvatarUrl
from
"@/assets/icons/staff.png"
;
import
{
eRole
}
from
"@/types/roleType"
;
const
USER_MSG
=
'USER_MSG'
const
USER_MSG
=
"USER_MSG"
;
export
function
setUserMsg
(
msg
:
iUserMsg
)
{
dispatchLoginAction
(
'login'
)
const
{
token
}
=
msg
const
{
token
}
=
msg
;
new
Bridge
().
bridge_sendToken
({
msg
,
url
:
window
.
location
.
protocol
+
'//'
+
"//"
+
window
.
location
.
host
+
'/proxyApi/api/v1'
,
})
localStorage
.
setItem
(
USER_MSG
,
JSON
.
stringify
(
msg
))
"/proxyApi/api/v1"
,
})
;
localStorage
.
setItem
(
USER_MSG
,
JSON
.
stringify
(
msg
))
;
}
export
function
getUserMsg
():
iUserMsg
|
undefined
{
const
value
=
localStorage
.
getItem
(
USER_MSG
)
return
(
value
&&
JSON
.
parse
(
value
))
||
undefined
const
value
=
localStorage
.
getItem
(
USER_MSG
)
;
return
(
value
&&
JSON
.
parse
(
value
))
||
undefined
;
}
export
function
deleteUserMsg
()
{
dispatchLoginAction
(
'logout'
)
localStorage
.
removeItem
(
USER_MSG
)
dispatchLoginAction
(
"logout"
);
localStorage
.
removeItem
(
USER_MSG
)
;
}
export
function
getCurrentUserAvatarUrl
()
{
if
(
getUserMsg
()?.
role
===
eRole
.
staff
)
{
return
staffAvatarUrl
return
staffAvatarUrl
;
}
else
if
(
getUserMsg
()?.
role
===
eRole
.
user
)
{
return
userAvatarUrl
return
userAvatarUrl
;
}
else
{
return
userAvatarUrl
return
userAvatarUrl
;
}
}
src/views/Auth/index.vue
View file @
855b8371
...
...
@@ -9,15 +9,22 @@
</
template
>
<
script
lang=
"ts"
>
import
{
userChangePwd
,
userCheckPhone
,
userCreate
,
userLogin
,
userRegister
}
from
'@/service/UserManagementService'
import
{
eCheckPhoneStatus
}
from
'@/service/UserManagementService/types'
import
{
eSmsType
,
sendVerifyCode
}
from
'@/service/VerificationService'
import
{
eNewRoleRelatedToBackEnd
,
eRole
}
from
'@/types/roleType'
import
transformRole
from
'@/utils/transformRole'
import
{
setUserMsg
}
from
'@/utils/userMsg'
import
{
defineComponent
}
from
'vue'
import
LoginService
from
'./Login/LoginService'
import
{
eAccountType
}
from
'./Login/types'
import
{
userChangePwd
,
userCheckPhone
,
userCreate
,
userLogin
,
userRegister
,
}
from
"@/service/UserManagementService"
;
import
{
eCheckPhoneStatus
}
from
"@/service/UserManagementService/types"
;
import
{
eSmsType
,
sendVerifyCode
}
from
"@/service/VerificationService"
;
import
{
dispatchLoginAction
}
from
"@/store/chatStore"
;
import
{
eNewRoleRelatedToBackEnd
,
eRole
}
from
"@/types/roleType"
;
import
transformRole
from
"@/utils/transformRole"
;
import
{
setUserMsg
}
from
"@/utils/userMsg"
;
import
{
defineComponent
}
from
"vue"
;
import
LoginService
from
"./Login/LoginService"
;
import
{
eAccountType
}
from
"./Login/types"
;
export
default
defineComponent
({
provide
():
object
{
...
...
@@ -29,48 +36,50 @@ export default defineComponent({
loginByPwdFunc
:
this
.
loginByPwdFunc
,
setPwdFunc
:
this
.
setPwdFunc
,
modifyPwdFunc
:
this
.
modifyPwdFunc
,
}
}
;
},
methods
:
{
async
sendSmsFunc
(
phone
:
string
,
smsType
?:
eSmsType
)
{
return
sendVerifyCode
({
phone
:
phone
,
smsType
:
smsType
!==
undefined
?
smsType
:
eSmsType
.
registerOrLogin
,
})
})
;
},
async
accountStatusCheckFunc
(
phone
:
string
)
{
const
ret
=
await
userCheckPhone
(
phone
)
const
ret
=
await
userCheckPhone
(
phone
)
;
if
(
ret
&&
ret
.
code
===
200
)
{
if
(
ret
.
data
===
eCheckPhoneStatus
.
staff
||
ret
.
data
===
eCheckPhoneStatus
.
user
)
{
return
eAccountType
.
REG_PDSET
if
(
ret
.
data
===
eCheckPhoneStatus
.
staff
||
ret
.
data
===
eCheckPhoneStatus
.
user
)
{
return
eAccountType
.
REG_PDSET
;
}
else
if
(
ret
.
data
===
eCheckPhoneStatus
.
no_reg
)
{
return
eAccountType
.
NO_REG
return
eAccountType
.
NO_REG
;
}
}
},
async
registerFunc
(
phone
:
string
,
code
:
string
)
{
const
ret
=
await
userRegister
({
phone
,
verify_code
:
code
})
verify_code
:
code
,
})
;
if
(
ret
.
code
===
200
)
{
const
{
accessToken
,
role
,
phone
,
addr
,
pri_key
,
pub_key
}
=
ret
.
data
const
{
accessToken
,
role
,
phone
}
=
ret
.
data
;
setUserMsg
({
token
:
accessToken
,
role
:
role
===
eNewRoleRelatedToBackEnd
.
ACM
?
eRole
.
staff
:
eRole
.
user
,
role
:
role
===
eNewRoleRelatedToBackEnd
.
ACM
?
eRole
.
staff
:
eRole
.
user
,
role2
:
transformRole
(
role
),
userInfo
:
{
phone
:
phone
,
addr
,
pri_key
,
pub_key
},
})
});
dispatchLoginAction
(
"login"
);
this
.
$router
.
push
({
name
:
'Home'
,
})
name
:
"Home"
,
})
;
}
else
{
throw
new
Error
(
ret
.
msg
)
throw
new
Error
(
ret
.
msg
)
;
}
},
async
loginByCodeFunc
(
phone
:
string
,
code
:
string
)
{
...
...
@@ -78,73 +87,72 @@ export default defineComponent({
is_admin
:
false
,
use_pwd
:
false
,
verify_code
:
code
,
phone
:
phone
})
phone
:
phone
,
})
;
if
(
ret
.
code
===
200
)
{
const
{
accessToken
,
phone
,
role
,
pri_key
,
pub_key
,
addr
}
=
ret
.
data
const
{
accessToken
,
phone
,
role
}
=
ret
.
data
;
setUserMsg
({
token
:
accessToken
,
role2
:
transformRole
(
role
),
role
:
eNewRoleRelatedToBackEnd
.
ACM
===
role
?
eRole
.
staff
:
eRole
.
user
,
role
:
eNewRoleRelatedToBackEnd
.
ACM
===
role
?
eRole
.
staff
:
eRole
.
user
,
userInfo
:
{
phone
,
addr
,
pri_key
,
pub_key
}
})
},
});
dispatchLoginAction
(
"login"
);
this
.
$router
.
push
({
name
:
'Home'
})
name
:
"Home"
,
})
;
}
},
async
loginByPwdFunc
(
phone
:
string
,
pwd
:
string
,
config
=
{
gohome
:
true
})
{
async
loginByPwdFunc
(
phone
:
string
,
pwd
:
string
,
config
=
{
gohome
:
true
}
)
{
const
ret
=
await
userLogin
({
is_admin
:
false
,
use_pwd
:
true
,
pwd
,
phone
:
phone
})
phone
:
phone
,
})
;
if
(
ret
.
code
===
200
)
{
const
{
accessToken
,
phone
,
role
,
addr
,
pub_key
,
pri_key
}
=
ret
.
data
const
{
accessToken
,
phone
,
role
}
=
ret
.
data
;
setUserMsg
({
token
:
accessToken
,
role2
:
transformRole
(
role
),
role
:
eNewRoleRelatedToBackEnd
.
ACM
===
role
?
eRole
.
staff
:
eRole
.
user
,
role
:
eNewRoleRelatedToBackEnd
.
ACM
===
role
?
eRole
.
staff
:
eRole
.
user
,
userInfo
:
{
phone
,
addr
,
pub_key
,
pri_key
}
})
config
.
gohome
&&
this
.
$router
.
push
({
name
:
'Home'
})
},
});
dispatchLoginAction
(
"login"
);
config
.
gohome
&&
this
.
$router
.
push
({
name
:
"Home"
,
});
}
else
{
throw
new
Error
(
ret
.
msg
)
throw
new
Error
(
ret
.
msg
)
;
}
},
async
setPwdFunc
(
phone
:
string
,
code
:
string
,
pwd
:
string
)
{
const
ret
=
await
userChangePwd
({
new_pwd
:
pwd
,
phone
,
verify_code
:
code
})
verify_code
:
code
,
})
;
if
(
ret
.
code
!==
200
)
{
throw
new
Error
(
ret
.
msg
)
throw
new
Error
(
ret
.
msg
)
;
}
await
this
.
loginByPwdFunc
(
phone
,
pwd
,
{
gohome
:
true
})
await
this
.
loginByPwdFunc
(
phone
,
pwd
,
{
gohome
:
true
})
;
},
async
modifyPwdFunc
(
phone
:
string
,
originalPwd
:
string
,
newPwd
:
string
)
{
console
.
log
(
phone
,
originalPwd
,
newPwd
)
console
.
log
(
phone
,
originalPwd
,
newPwd
)
;
},
},
})
})
;
</
script
>
<
style
lang=
"less"
>
</
style
>
<
style
lang=
"less"
></
style
>
src/views/withMenu/Loan/index.vue
View file @
855b8371
...
...
@@ -74,12 +74,8 @@
class=
"mt-24"
@
seeMore=
"$router.push(
{ name: 'LoanList', params: { mode: mode } })"
/>
<Skeleton
:row=
"3"
:loading=
"skeLoading"
style=
"margin-top: 20px"
v-if=
"state.allProductList"
>
<div
style=
"margin-top: 20px"
v-if=
"state.allProductList"
></div>
<Skeleton
:row=
"3"
:loading=
"skeLoading"
v-if=
"state.allProductList"
>
<LoanCard
v-for=
"item in state.allProductList"
:key=
"item.uuid"
...
...
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