|
@@ -4,16 +4,16 @@
|
|
|
<div class="close-icon-box">
|
|
|
<i class="el-icon-circle-close close-icon" @click="$emit('callback')"></i>
|
|
|
</div>
|
|
|
- <div class="login-form">
|
|
|
- <div class="login-tab" :class="{
|
|
|
- active1:nowTab.id === 1,
|
|
|
- active2:nowTab.id === 2
|
|
|
- }">
|
|
|
- <div class="tab-item" :class="{
|
|
|
- active:nowTab.id === tab.id
|
|
|
- }" v-for="(tab, index) in tabs" :key="index" @click="nowTab = tab">
|
|
|
- {{ tab.name }}
|
|
|
- </div>
|
|
|
+ <div class="login-form">
|
|
|
+ <div class="login-tab" :class="{
|
|
|
+ active1:nowTab.id === 1,
|
|
|
+ active2:nowTab.id === 2
|
|
|
+ }">
|
|
|
+ <div class="tab-item" :class="{
|
|
|
+ active:nowTab.id === tab.id
|
|
|
+ }" v-for="(tab, index) in tabs" :key="index" @click="nowTab = tab">
|
|
|
+ {{ tab.name }}
|
|
|
+ </div>
|
|
|
</div>
|
|
|
<el-form :model="loginForm" :rules="loginRules" status-icon ref="loginForm" label-position="left">
|
|
|
<el-form-item prop="phone">
|
|
@@ -21,26 +21,27 @@
|
|
|
placeholder="手机号" maxlength="11">
|
|
|
</el-input>
|
|
|
</el-form-item>
|
|
|
- <el-form-item prop="code" class="image-item" v-if="nowTab.id === 1">
|
|
|
- <el-input type="text" prefix-icon="iconfont huifont-tuxingyanzhengma" v-model="loginForm.code"
|
|
|
- placeholder="图片验证码" maxlength="4"></el-input>
|
|
|
- <img v-if="codeImg" :src="codeImg" alt="图片验证码" class="code-image" @click="imgCodeFunc">
|
|
|
- </el-form-item>
|
|
|
- <el-form-item prop="phoneCode" class="phone-code" v-if="nowTab.id === 1">
|
|
|
- <el-input type="number" prefix-icon="iconfont huifont-duanxinyanzhengma"
|
|
|
- v-model="loginForm.phoneCode" placeholder="短信验证码"
|
|
|
- oninput="if(value.length > 6) value=value.slice(0, 6)">
|
|
|
- </el-input>
|
|
|
- <div class="get-code-btn">
|
|
|
- <el-button type="primary" size="samll" @click="getPhoneCode" :disabled="codeName !== '获取验证码'">
|
|
|
- {{codeName}}
|
|
|
- </el-button>
|
|
|
- </div>
|
|
|
- </el-form-item>
|
|
|
- <el-form-item prop="password" v-if="nowTab.id === 2">
|
|
|
- <el-input type="password" prefix-icon="iconfont huifont-mima" v-model="loginForm.password"
|
|
|
- :show-password="true" placeholder="请输入密码">
|
|
|
- </el-input>
|
|
|
+ <el-form-item prop="code" class="image-item" v-if="nowTab.id === 1">
|
|
|
+ <el-input type="text" prefix-icon="iconfont huifont-tuxingyanzhengma" v-model="loginForm.code"
|
|
|
+ placeholder="图片验证码" maxlength="4"></el-input>
|
|
|
+ <img v-if="codeImg" :src="codeImg" alt="图片验证码" class="code-image" @click="imgCodeFunc">
|
|
|
+ </el-form-item>
|
|
|
+ <el-form-item prop="phoneCode" class="phone-code" v-if="nowTab.id === 1">
|
|
|
+ <el-input type="number" prefix-icon="iconfont huifont-duanxinyanzhengma"
|
|
|
+ v-model="loginForm.phoneCode" placeholder="短信验证码"
|
|
|
+ oninput="if(value.length > 6) value=value.slice(0, 6)">
|
|
|
+ </el-input>
|
|
|
+ <div class="get-code-btn">
|
|
|
+ <el-button type="primary" size="samll" @click="getPhoneCode"
|
|
|
+ :disabled="codeName !== '获取验证码'">
|
|
|
+ {{codeName}}
|
|
|
+ </el-button>
|
|
|
+ </div>
|
|
|
+ </el-form-item>
|
|
|
+ <el-form-item prop="password" v-if="nowTab.id === 2">
|
|
|
+ <el-input type="password" prefix-icon="iconfont huifont-mima" v-model="loginForm.password"
|
|
|
+ :show-password="true" placeholder="请输入密码">
|
|
|
+ </el-input>
|
|
|
</el-form-item>
|
|
|
</el-form>
|
|
|
<el-button class="submit" type="primary" @click="loginSubmit" :loading="loginLoading">登录</el-button>
|
|
@@ -99,17 +100,17 @@
|
|
|
message: '请输入短信验证码',
|
|
|
trigger: 'blur'
|
|
|
}]
|
|
|
- },
|
|
|
- tabs: [{
|
|
|
- id: 1,
|
|
|
- name: '验证码登录'
|
|
|
- }, {
|
|
|
- id: 2,
|
|
|
- name: '账号密码登录'
|
|
|
- }],
|
|
|
- nowTab: {
|
|
|
- id: 1,
|
|
|
- name: '验证码登录'
|
|
|
+ },
|
|
|
+ tabs: [{
|
|
|
+ id: 1,
|
|
|
+ name: '验证码登录'
|
|
|
+ }, {
|
|
|
+ id: 2,
|
|
|
+ name: '账号密码登录'
|
|
|
+ }],
|
|
|
+ nowTab: {
|
|
|
+ id: 1,
|
|
|
+ name: '验证码登录'
|
|
|
}
|
|
|
};
|
|
|
},
|
|
@@ -168,10 +169,13 @@
|
|
|
})
|
|
|
},
|
|
|
loginFunc() {
|
|
|
- let postData = {
|
|
|
+ let postData = this.nowTab.id === 1 ? {
|
|
|
phone: this.loginForm.phone,
|
|
|
phoneCode: this.loginForm.phoneCode
|
|
|
- }
|
|
|
+ } : {
|
|
|
+ phone: this.loginForm.phone,
|
|
|
+ password: this.loginForm.password
|
|
|
+ };
|
|
|
login(postData).then(res => {
|
|
|
if (res.state) {
|
|
|
setToken(res.data.token);
|
|
@@ -198,7 +202,7 @@
|
|
|
}
|
|
|
})
|
|
|
},
|
|
|
- successLogin(url) {
|
|
|
+ successLogin(url) {
|
|
|
this.$chat.connect();
|
|
|
this.loginLoading = false;
|
|
|
this.$emit('callback', 'init')
|
|
@@ -208,48 +212,48 @@
|
|
|
};
|
|
|
</script>
|
|
|
|
|
|
-<style lang="scss" scoped>
|
|
|
- .login-tab {
|
|
|
- display: flex;
|
|
|
- border: 1px solid #bebebe;
|
|
|
- margin-bottom: 28px;
|
|
|
- height: 36px;
|
|
|
- border-radius: 4px;
|
|
|
- align-items: center;
|
|
|
- position: relative;
|
|
|
-
|
|
|
- &:before {
|
|
|
- content: '';
|
|
|
- position: absolute;
|
|
|
- background: #bebebe;
|
|
|
- width: 159px;
|
|
|
- height: 28px;
|
|
|
- border-radius: 4px;
|
|
|
- z-index: 8;
|
|
|
- transition: left 0.3s;
|
|
|
- }
|
|
|
-
|
|
|
- &.active1:before {
|
|
|
- left: 4px;
|
|
|
- }
|
|
|
-
|
|
|
- &.active2:before {
|
|
|
- left: 167px;
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- .tab-item {
|
|
|
- flex: 1;
|
|
|
- text-align: center;
|
|
|
- z-index: 9;
|
|
|
- cursor: pointer;
|
|
|
- transition: color 0.3s;
|
|
|
-
|
|
|
- &.active {
|
|
|
- color: #fff;
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
+<style lang="scss" scoped>
|
|
|
+ .login-tab {
|
|
|
+ display: flex;
|
|
|
+ border: 1px solid #bebebe;
|
|
|
+ margin-bottom: 28px;
|
|
|
+ height: 36px;
|
|
|
+ border-radius: 4px;
|
|
|
+ align-items: center;
|
|
|
+ position: relative;
|
|
|
+
|
|
|
+ &:before {
|
|
|
+ content: '';
|
|
|
+ position: absolute;
|
|
|
+ background: #bebebe;
|
|
|
+ width: 159px;
|
|
|
+ height: 28px;
|
|
|
+ border-radius: 4px;
|
|
|
+ z-index: 8;
|
|
|
+ transition: left 0.3s;
|
|
|
+ }
|
|
|
+
|
|
|
+ &.active1:before {
|
|
|
+ left: 4px;
|
|
|
+ }
|
|
|
+
|
|
|
+ &.active2:before {
|
|
|
+ left: 167px;
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ .tab-item {
|
|
|
+ flex: 1;
|
|
|
+ text-align: center;
|
|
|
+ z-index: 9;
|
|
|
+ cursor: pointer;
|
|
|
+ transition: color 0.3s;
|
|
|
+
|
|
|
+ &.active {
|
|
|
+ color: #fff;
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
.website-login-box {
|
|
|
width: 100%;
|
|
|
height: 100%;
|