用户模块
This commit is contained in:
@@ -9,14 +9,19 @@
|
||||
<image class="login-box-logo" mode="widthFix" src="/static/logo.png"></image>
|
||||
<template v-if="loginType == 'yzm'">
|
||||
<view class="login-box-input mt100">
|
||||
<input class="login-box-input-main" maxlength="11" v-model="yzmForm.phone" placeholder="请输入手机号" />
|
||||
<input
|
||||
class="login-box-input-main"
|
||||
maxlength="11"
|
||||
v-model="yzmForm.phone"
|
||||
placeholder="请输入手机号"
|
||||
/>
|
||||
</view>
|
||||
<!-- <view class="login-box-input mt40">
|
||||
<input class="login-box-input-main" v-model="yzmForm.imgCode" placeholder="图形验证码" />
|
||||
<view class="login-box-input-img"></view>
|
||||
</view> -->
|
||||
<view class="login-box-input mt40">
|
||||
<input class="login-box-input-main" v-model="yzmForm.code" placeholder="手机验证码" />
|
||||
<input class="login-box-input-main" v-model="yzmForm.code" placeholder="手机验证码" />
|
||||
<view
|
||||
class="ml40"
|
||||
style="font-size: 28rpx; color: #666; width: 200rpx; text-align: center"
|
||||
@@ -28,10 +33,15 @@
|
||||
</template>
|
||||
<template v-else>
|
||||
<view class="login-box-input mt100">
|
||||
<input class="login-box-input-main" v-model="pwdForm.phone" placeholder="请输入账号" />
|
||||
<input class="login-box-input-main" maxlength="11" v-model="pwdForm.phone" placeholder="请输入账号" />
|
||||
</view>
|
||||
<view class="login-box-input mt40">
|
||||
<input type="password" class="login-box-input-main" v-model="pwdForm.pwd" placeholder="请输入密码" />
|
||||
<input
|
||||
type="password"
|
||||
class="login-box-input-main"
|
||||
v-model="pwdForm.pwd"
|
||||
placeholder="请输入密码"
|
||||
/>
|
||||
</view>
|
||||
<!-- <view class="login-box-input mt40">
|
||||
<view class="login-box-input-icon"></view>
|
||||
@@ -59,15 +69,18 @@
|
||||
</Cn-page>
|
||||
</template>
|
||||
<script>
|
||||
import { apiGetYms, apiLogin, apiYsmLogin } from '@/common/api/user'
|
||||
import { apiGetYms, apiPwdLogin, apiYsmLogin, gongkey } from '@/common/api/user'
|
||||
import { sm2, encrypt } from '@/common/js/sm2.js'
|
||||
import { sm3Digest } from '@/common/js/sm3.js'
|
||||
|
||||
export default {
|
||||
data() {
|
||||
return {
|
||||
loading: false,
|
||||
loginType: 'pwd',
|
||||
pwdForm: {
|
||||
phone: '',
|
||||
pwd: '',
|
||||
phone: '13888888888',
|
||||
pwd: 'gwo6H8Kb',
|
||||
imgCode: '',
|
||||
},
|
||||
yzmForm: {
|
||||
@@ -122,15 +135,19 @@ export default {
|
||||
if (!this.pwdForm.phone && !this.pwdForm.pwd) {
|
||||
return this.$util.toast('请填写登录信息!')
|
||||
}
|
||||
apiLogin({
|
||||
phone: this.pwdForm.phone,
|
||||
key: this.pwdForm.pwd,
|
||||
type: 1,
|
||||
}).then((res) => {
|
||||
console.log(res)
|
||||
uni.setStorageSync('userInfo', res.data)
|
||||
uni.reLaunch({
|
||||
url: '/pages/index/index',
|
||||
let loginName = encrypt(this.pwdForm.phone)
|
||||
gongkey({ loginName }).then((response) => {
|
||||
let publicKey = response.data
|
||||
let sm3Pwd = sm3Digest(this.pwdForm.pwd)
|
||||
let jiamipassword = sm2(sm3Pwd + '|' + this.pwdForm.pwd, publicKey, 0)
|
||||
apiPwdLogin({
|
||||
username: loginName,
|
||||
password: jiamipassword,
|
||||
imageCode: '',
|
||||
grant_type: 'captcha',
|
||||
verifyCode: 0,
|
||||
}).then((res) => {
|
||||
this.$util.loginSuccess(res.data)
|
||||
})
|
||||
})
|
||||
},
|
||||
@@ -142,21 +159,13 @@ export default {
|
||||
phone: this.yzmForm.phone,
|
||||
smsCode: this.yzmForm.code,
|
||||
}).then((res) => {
|
||||
console.log(res)
|
||||
uni.setStorageSync('access_token', res.data.token_type + ' ' + res.data.access_token)
|
||||
uni.setStorageSync('refresh_token', res.data.refresh_token)
|
||||
let strings = res.data.access_token.split('.') //截取token,获取载体
|
||||
var userInfo = JSON.parse(decodeURIComponent(escape(window.atob(strings[1].replace(/-/g, '+').replace(/_/g, '/')))))
|
||||
userInfo.authorities = userInfo.authorities[0]
|
||||
uni.setStorageSync('userInfo', userInfo)
|
||||
uni.reLaunch({
|
||||
url: '/pages/index/index',
|
||||
})
|
||||
this.$util.loginSuccess(res.data)
|
||||
})
|
||||
},
|
||||
},
|
||||
onLoad(o) {
|
||||
uni.removeStorageSync('engineering')
|
||||
// 移除所有的缓存
|
||||
uni.clearStorageSync()
|
||||
},
|
||||
}
|
||||
</script>
|
||||
|
||||
Reference in New Issue
Block a user