|
|
|
@ -6,26 +6,19 @@ |
|
|
|
|
<h1>欢迎使用开发者平台</h1> |
|
|
|
|
<div class="form"> |
|
|
|
|
<ul class="tab"> |
|
|
|
|
<li v-for="(item, i) in tabList" :key="i" :class="{active: activeIndex == item.id}" @click="handleSelect(item.id)">{{item.label}}</li> |
|
|
|
|
<li v-for="(item, i) in tabList" :key="i" :class="{ active: activeIndex == item.id }" |
|
|
|
|
@click="handleSelect(item.id)">{{ item.label }}</li> |
|
|
|
|
</ul> |
|
|
|
|
<el-form v-show="activeIndex === '1'" :model="param" :rules="rules" ref="login" label-width="0px"> |
|
|
|
|
<el-form-item prop="account"> |
|
|
|
|
<el-input @blur="blur" v-model="param.account" placeholder="请输入账号"></el-input> |
|
|
|
|
</el-form-item> |
|
|
|
|
<el-form-item prop="password"> |
|
|
|
|
<el-input |
|
|
|
|
type="password" |
|
|
|
|
placeholder="请输入密码" |
|
|
|
|
v-model="param.password" |
|
|
|
|
> |
|
|
|
|
<el-input type="password" placeholder="请输入密码" v-model="param.password"> |
|
|
|
|
</el-input> |
|
|
|
|
</el-form-item> |
|
|
|
|
<el-form-item prop="code" v-if="showVerify"> |
|
|
|
|
<el-input |
|
|
|
|
placeholder="请输入验证码" |
|
|
|
|
v-model="param.code" |
|
|
|
|
@keyup.enter.native="submitForm()" |
|
|
|
|
> |
|
|
|
|
<el-input placeholder="请输入验证码" v-model="param.code" @keyup.enter.native="submitForm()"> |
|
|
|
|
</el-input> |
|
|
|
|
<img @click="blur" :src="verificationIMG" class="verification" alt=""> |
|
|
|
|
</el-form-item> |
|
|
|
@ -34,24 +27,17 @@ |
|
|
|
|
</div> |
|
|
|
|
</el-form> |
|
|
|
|
|
|
|
|
|
<el-form v-show="activeIndex==='2'" :model="phoneOrEmail" :rules="phoneOrEmailrules" ref="phoneOrEmail" label-width="0px"> |
|
|
|
|
<el-form v-show="activeIndex === '2'" :model="phoneOrEmail" :rules="phoneOrEmailrules" ref="phoneOrEmail" |
|
|
|
|
label-width="0px"> |
|
|
|
|
<el-form-item prop="account"> |
|
|
|
|
<el-input @blur="phoneBlur" v-model="phoneOrEmail.account" placeholder="请输入电话/邮箱"></el-input> |
|
|
|
|
</el-form-item> |
|
|
|
|
<el-form-item prop="password"> |
|
|
|
|
<el-input |
|
|
|
|
type="password" |
|
|
|
|
placeholder="请输入密码" |
|
|
|
|
v-model="phoneOrEmail.password" |
|
|
|
|
> |
|
|
|
|
<el-input type="password" placeholder="请输入密码" v-model="phoneOrEmail.password"> |
|
|
|
|
</el-input> |
|
|
|
|
</el-form-item> |
|
|
|
|
<el-form-item prop="code" v-if="showPhoneVerify"> |
|
|
|
|
<el-input |
|
|
|
|
placeholder="请输入验证码" |
|
|
|
|
v-model="phoneOrEmail.code" |
|
|
|
|
@keyup.enter.native="submitForm('phone')" |
|
|
|
|
> |
|
|
|
|
<el-input placeholder="请输入验证码" v-model="phoneOrEmail.code" @keyup.enter.native="submitForm('phone')"> |
|
|
|
|
</el-input> |
|
|
|
|
<img @click="phoneBlur" :src="PhoneVerificationIMG" class="verification" alt=""> |
|
|
|
|
</el-form-item> |
|
|
|
@ -71,7 +57,8 @@ |
|
|
|
|
<el-form-item label="验证码"> |
|
|
|
|
<div style="display:flex;"> |
|
|
|
|
<el-input v-model="phoneCode" placeholder="请输入验证码" maxlength="6"></el-input> |
|
|
|
|
<el-button style="margin-left:10px" @click="sendPhoneCode" :disabled="phoneDisabled">{{phoneBtnText}}</el-button> |
|
|
|
|
<el-button style="margin-left:10px" @click="sendPhoneCode" :disabled="phoneDisabled">{{ phoneBtnText |
|
|
|
|
}}</el-button> |
|
|
|
|
</div> |
|
|
|
|
</el-form-item> |
|
|
|
|
</el-form> |
|
|
|
@ -80,6 +67,20 @@ |
|
|
|
|
<el-button type="primary" @click="phoneSubmit">确 定</el-button> |
|
|
|
|
</span> |
|
|
|
|
</el-dialog> |
|
|
|
|
|
|
|
|
|
<el-dialog title="请选择您要登录的用户" :visible.sync="userVisible" :close-on-click-modal="false" custom-class="user-dia" |
|
|
|
|
width="500px"> |
|
|
|
|
<p class="tips">该手机号已绑定以下用户信息</p> |
|
|
|
|
<ul class="users"> |
|
|
|
|
<li :class="{ isEnable: !user.isEnable }" v-for="(user, i) in users" :key="i" @click="chooseUser(user)"> |
|
|
|
|
<span>{{ user.schoolName }},{{ user.userName }},{{ user.workNumber }}{{ |
|
|
|
|
user.isEnable |
|
|
|
|
? '' |
|
|
|
|
: '(已禁用)' }}</span> |
|
|
|
|
<i class="el-icon-right"></i> |
|
|
|
|
</li> |
|
|
|
|
</ul> |
|
|
|
|
</el-dialog> |
|
|
|
|
<v-footer class="footer" ref="footer"></v-footer> |
|
|
|
|
</div> |
|
|
|
|
</template> |
|
|
|
@ -87,6 +88,9 @@ |
|
|
|
|
<script> |
|
|
|
|
import vFooter from '../components/Footer' |
|
|
|
|
import Setting from '@/setting' |
|
|
|
|
import addRoutes from '@/libs/route/addRoutes' |
|
|
|
|
import CryptoJS from 'crypto-js' |
|
|
|
|
import JSEncrypt from 'jsencrypt' |
|
|
|
|
export default { |
|
|
|
|
data: function () { |
|
|
|
|
var regPhoneOrEmail = (rule, value, callback) => {// 验证手机或邮箱 |
|
|
|
@ -155,8 +159,10 @@ export default { |
|
|
|
|
phoneDisabled: false, |
|
|
|
|
phoneBtnText: '发送验证码', |
|
|
|
|
phoneTimer: '', |
|
|
|
|
phoneOpener:'' |
|
|
|
|
phoneOpener: '', |
|
|
|
|
|
|
|
|
|
userVisible: false, |
|
|
|
|
users: [], |
|
|
|
|
}; |
|
|
|
|
}, |
|
|
|
|
components: { |
|
|
|
@ -190,26 +196,29 @@ export default { |
|
|
|
|
let param = val === 'phone' ? this.phoneOrEmail : this.param |
|
|
|
|
this.$refs[ref].validate(valid => { |
|
|
|
|
if (valid) { |
|
|
|
|
this.$post(this.api.logins,param).then(res => { |
|
|
|
|
const { message } = res |
|
|
|
|
sessionStorage.setItem('token',res.data.token) |
|
|
|
|
this.$get(`${this.api.getUserRolesPermissionMenu}?platformId=${Setting.platformId}`).then(res => { |
|
|
|
|
const list = res.permissionMenu |
|
|
|
|
this.$store.commit('setDataPer', res.dataPermissionList) |
|
|
|
|
this.$message.success(message); |
|
|
|
|
this.$router.push({ |
|
|
|
|
path: list[0].children[0].path |
|
|
|
|
}); |
|
|
|
|
localStorage.setItem('ms_username', this.param.username); |
|
|
|
|
}).catch(err => { |
|
|
|
|
if (err.status === 500) { |
|
|
|
|
sessionStorage.clear() |
|
|
|
|
this.$post(this.api.logins, param).then(({ status, data, message }) => { |
|
|
|
|
localStorage.removeItem('examPath') |
|
|
|
|
localStorage.removeItem('reviewPath') |
|
|
|
|
this.getOss() |
|
|
|
|
if (status == 200) { |
|
|
|
|
const accounts = data.userAccounts |
|
|
|
|
// 如果返回的是数组,则弹框给用户选择登录哪个用户,否则,直接登录 |
|
|
|
|
if (accounts instanceof Array) { |
|
|
|
|
this.users = accounts |
|
|
|
|
this.userVisible = true |
|
|
|
|
} else { |
|
|
|
|
sessionStorage.setItem('token', data.token) |
|
|
|
|
this.setLogin() |
|
|
|
|
} |
|
|
|
|
} else { |
|
|
|
|
param.code = '' |
|
|
|
|
this.$message.error(message) |
|
|
|
|
} |
|
|
|
|
}) |
|
|
|
|
}).catch(err => { |
|
|
|
|
if (err.status === 30001) { |
|
|
|
|
this.phoneVisible = true |
|
|
|
|
}else if(err.status == 10004){ |
|
|
|
|
} else if (err.status == 10004 || err.status == 10005) { |
|
|
|
|
param.code = '' |
|
|
|
|
this.blur() |
|
|
|
|
} |
|
|
|
|
}); |
|
|
|
@ -218,7 +227,54 @@ export default { |
|
|
|
|
return false; |
|
|
|
|
} |
|
|
|
|
}); |
|
|
|
|
}, |
|
|
|
|
// 获取oss信息 |
|
|
|
|
async getOss () { |
|
|
|
|
const A = (key, encryptedData) => { |
|
|
|
|
const keyHex = CryptoJS.enc.Base64.parse(key) |
|
|
|
|
const decrypted = CryptoJS.AES.decrypt(encryptedData, keyHex, { |
|
|
|
|
mode: CryptoJS.mode.ECB, |
|
|
|
|
padding: CryptoJS.pad.Pkcs7 |
|
|
|
|
}) |
|
|
|
|
return decrypted.toString(CryptoJS.enc.Utf8) |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
const R = (encryptedKey, privateKey) => { |
|
|
|
|
const decrypt = new JSEncrypt() |
|
|
|
|
decrypt.setPrivateKey(privateKey) |
|
|
|
|
const decryptedKey = decrypt.decrypt(encryptedKey) |
|
|
|
|
return decryptedKey |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
const res = await this.$get(this.api.encrypt) |
|
|
|
|
const RE = A(R(res.encryptedKey, res.privateKey), res.encryptedData).split('/') |
|
|
|
|
localStorage.setItem('osc', JSON.stringify(RE)) |
|
|
|
|
}, |
|
|
|
|
// 选择用户回调 |
|
|
|
|
chooseUser (user) { |
|
|
|
|
user.isEnable && this.$post(`${this.api.getToken}?id=${user.id}`).then(({ data }) => { |
|
|
|
|
sessionStorage.setItem('token', data.token) |
|
|
|
|
this.token = data.token |
|
|
|
|
this.setLogin() |
|
|
|
|
}).catch(res => { }) |
|
|
|
|
}, |
|
|
|
|
// 处理登录成功 |
|
|
|
|
async setLogin () { |
|
|
|
|
try { |
|
|
|
|
const res = await this.$get(`${this.api.getUserRolesPermissionMenu}?platformId=${Setting.platformId}`) |
|
|
|
|
const list = res.permissionMenu |
|
|
|
|
addRoutes(res.permissionMenu[0].children) |
|
|
|
|
this.$store.commit('setDataPer', res.dataPermissionList) |
|
|
|
|
this.$message.success('登录成功!') |
|
|
|
|
this.$router.push({ |
|
|
|
|
path: list[0].children[0].path |
|
|
|
|
}); |
|
|
|
|
localStorage.setItem('ms_username', this.param.username); |
|
|
|
|
} catch (e) { |
|
|
|
|
if (e.status === 500) { |
|
|
|
|
sessionStorage.clear() |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
}, |
|
|
|
|
blur () { |
|
|
|
|
this.param.random = Math.floor(Math.random() * 999999999) |
|
|
|
@ -305,24 +361,28 @@ export default { |
|
|
|
|
.wrap { |
|
|
|
|
min-height: 100%; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
.logo { |
|
|
|
|
z-index: 2; |
|
|
|
|
position: absolute; |
|
|
|
|
top: 50px; |
|
|
|
|
left: 50px; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
.login { |
|
|
|
|
position: relative; |
|
|
|
|
height: 100%; |
|
|
|
|
background-image: url(../assets/img/devLogin.jpg); |
|
|
|
|
background-size: 100%; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
.box { |
|
|
|
|
width: 448px; |
|
|
|
|
position: absolute; |
|
|
|
|
right: 20%; |
|
|
|
|
top: 50%; |
|
|
|
|
transform: translateY(-50%); |
|
|
|
|
|
|
|
|
|
h1 { |
|
|
|
|
margin-bottom: 20px; |
|
|
|
|
font-size: 34px; |
|
|
|
@ -330,21 +390,25 @@ export default { |
|
|
|
|
text-align: center; |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/deep/ .form { |
|
|
|
|
padding: 20px 60px 0; |
|
|
|
|
background-color: rgba(255, 255, 255, .3); |
|
|
|
|
border-radius: 4px; |
|
|
|
|
box-sizing: border-box; |
|
|
|
|
border: 4px solid rgba(255, 255, 255, .2); |
|
|
|
|
|
|
|
|
|
.el-input__inner { |
|
|
|
|
height: 50px; |
|
|
|
|
line-height: 50px; |
|
|
|
|
border: 1px solid rgba(220, 220, 220, 1); |
|
|
|
|
border-radius: 2px; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
.el-form-item { |
|
|
|
|
margin-bottom: 25px; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
.verification { |
|
|
|
|
position: absolute; |
|
|
|
|
top: 1px; |
|
|
|
@ -354,11 +418,13 @@ export default { |
|
|
|
|
cursor: pointer; |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
.tab { |
|
|
|
|
display: flex; |
|
|
|
|
justify-content: center; |
|
|
|
|
align-items: center; |
|
|
|
|
margin-bottom: 24px; |
|
|
|
|
|
|
|
|
|
li { |
|
|
|
|
padding: 18px 5px; |
|
|
|
|
margin: 0 20px; |
|
|
|
@ -367,23 +433,28 @@ export default { |
|
|
|
|
color: #fff; |
|
|
|
|
cursor: pointer; |
|
|
|
|
border-bottom: 2px solid transparent; |
|
|
|
|
|
|
|
|
|
&:last-child { |
|
|
|
|
margin-right: 0; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
&.active { |
|
|
|
|
color: #fff; |
|
|
|
|
border-bottom-color: #ccc; |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
.title { |
|
|
|
|
font-size: 16px; |
|
|
|
|
text-align: center; |
|
|
|
|
font-weight: bold; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
.login-btn { |
|
|
|
|
text-align: center; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
.login-btn button { |
|
|
|
|
width: 100%; |
|
|
|
|
height: 48px; |
|
|
|
@ -393,13 +464,55 @@ export default { |
|
|
|
|
border-radius: 4px; |
|
|
|
|
border: 0; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
.forget { |
|
|
|
|
margin-bottom: 28px; |
|
|
|
|
text-align: right; |
|
|
|
|
color: #999; |
|
|
|
|
font-weight: bold; |
|
|
|
|
|
|
|
|
|
&:hover { |
|
|
|
|
color: #0092FF; |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/deep/.user-dia { |
|
|
|
|
.tips { |
|
|
|
|
margin-bottom: 20px; |
|
|
|
|
text-align: center; |
|
|
|
|
color: #666; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
.users { |
|
|
|
|
li { |
|
|
|
|
display: flex; |
|
|
|
|
justify-content: space-between; |
|
|
|
|
align-items: center; |
|
|
|
|
padding: 0 15px; |
|
|
|
|
margin-bottom: 10px; |
|
|
|
|
line-height: 40px; |
|
|
|
|
font-size: 14px; |
|
|
|
|
background-color: #ebeef5; |
|
|
|
|
cursor: pointer; |
|
|
|
|
|
|
|
|
|
&.isEnable { |
|
|
|
|
color: #c0c4cc; |
|
|
|
|
background-color: #f5f7fa; |
|
|
|
|
cursor: not-allowed; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
&:last-child { |
|
|
|
|
margin-bottom: 0; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
&:hover { |
|
|
|
|
background-color: #d3e0ff; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
i { |
|
|
|
|
font-size: 16px; |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
</style> |