Commit dfe4197e authored by zhanglw's avatar zhanglw

登录

parent ff1e7584
...@@ -597,6 +597,16 @@ export const HttpReq = { ...@@ -597,6 +597,16 @@ export const HttpReq = {
return res return res
}) })
}, },
// 请求短信验证
sendSmsCode: function(data) {
return request({
url: '/api/bsw/bigScreen/personalCenter/sendSmsCode',
method: 'post',
data: data
}).then((res) => {
return res
})
},
id: null id: null
} }
} }
......
import request from '@/utils/request' import request from '@/utils/request'
export function login(username, password, code, uuid) { export function login(username, password, code, uuid, smsCode) {
return request({ return request({
url: 'auth/login', url: 'auth/login',
method: 'post', method: 'post',
...@@ -8,7 +8,8 @@ export function login(username, password, code, uuid) { ...@@ -8,7 +8,8 @@ export function login(username, password, code, uuid) {
username, username,
password, password,
code, code,
uuid uuid,
smsCode
} }
}) })
} }
......
...@@ -30,7 +30,7 @@ const user = { ...@@ -30,7 +30,7 @@ const user = {
Login({ commit }, userInfo) { Login({ commit }, userInfo) {
const rememberMe = userInfo.rememberMe const rememberMe = userInfo.rememberMe
return new Promise((resolve, reject) => { return new Promise((resolve, reject) => {
login(userInfo.username, userInfo.password, userInfo.code, userInfo.uuid).then(res => { login(userInfo.username, userInfo.password, userInfo.code, userInfo.uuid, userInfo.smsCode).then(res => {
setToken(res.token, rememberMe) setToken(res.token, rememberMe)
commit('SET_TOKEN', res.token) commit('SET_TOKEN', res.token)
setUserInfo(res.user, commit) setUserInfo(res.user, commit)
......
...@@ -37,8 +37,8 @@ ...@@ -37,8 +37,8 @@
<img :src="codeUrl" @click="getCode"> <img :src="codeUrl" @click="getCode">
</div> </div>
</el-form-item> </el-form-item>
<el-form-item v-show="mode!==1" prop="sms"> <el-form-item v-show="mode!==1" prop="smsCode">
<el-input v-model="loginForm.sms" size="medium" auto-complete="off" placeholder="短信验证码" style="width: 70%" @keyup.enter.native="handleLogin"> <el-input v-model="loginForm.smsCode" size="medium" auto-complete="off" placeholder="短信验证码" style="width: 70%" @keyup.enter.native="handleLogin">
<svg-icon slot="prefix" icon-class="validCode" class="el-input__icon input-icon" /> <svg-icon slot="prefix" icon-class="validCode" class="el-input__icon input-icon" />
</el-input> </el-input>
<div class="login-code"> <div class="login-code">
...@@ -66,14 +66,15 @@ ...@@ -66,14 +66,15 @@
<span class="underline touch" @click="changeMode(1)">使用已有账号登录</span> <span class="underline touch" @click="changeMode(1)">使用已有账号登录</span>
</div> </div>
<div style="padding: 10px 0;"> <div style="padding: 10px 0;">
<el-checkbox v-model="loginForm.rememberMe" style="margin:0;opacity:0.8" /> <el-checkbox v-model="loginForm.agreement" style="margin:0;opacity:0.8" />
<div class="login-agreement"><span class="touch">阅读并接受《中国基建传感器网用户协议》及《中国基建传感器网隐私权保护声明》</span></div> <div class="login-agreement"><span style="opacity:0.8">阅读并接受</span><span class="touch" @click="openView(1)">《中国基建传感器网用户协议》</span><span style="opacity:0.8"></span><span class="touch" @click="openView(3)">《中国基建传感器网隐私权保护声明》</span></div>
</div> </div>
</el-form-item> </el-form-item>
</el-form> </el-form>
</div> </div>
</div> </div>
<home-footer ref="homeFooter" /> <home-footer ref="homeFooter" />
<user-agreement ref="userAgreement" />
</div> </div>
</template> </template>
...@@ -87,9 +88,11 @@ import titleMenus from './components/titleMenus' ...@@ -87,9 +88,11 @@ import titleMenus from './components/titleMenus'
import userLogin from './components/userLogin' import userLogin from './components/userLogin'
import languageSetting from './components/languageSetting' import languageSetting from './components/languageSetting'
import homeFooter from './components/homeFooter' import homeFooter from './components/homeFooter'
import { HttpReq } from '@/api/common'
import userAgreement from './userAgreement'
export default { export default {
components: { titleMenus, userLogin, languageSetting, homeFooter }, components: { titleMenus, userLogin, languageSetting, homeFooter, userAgreement },
data() { data() {
const validateMobile = (rule, value, callback) => { const validateMobile = (rule, value, callback) => {
if (value === 'admin') { if (value === 'admin') {
...@@ -137,15 +140,16 @@ export default { ...@@ -137,15 +140,16 @@ export default {
username: '', username: '',
password: '', password: '',
rememberMe: false, rememberMe: false,
agreement: true,
code: '', code: '',
sms: '', smsCode: '',
uuid: '' uuid: ''
}, },
loginRules: { loginRules: {
username: [{ required: true, trigger: 'blur', message: '手机号不能为空' }, { validator: validateMobile, trigger: 'blur' }], username: [{ required: true, trigger: 'blur', message: '手机号不能为空' }, { validator: validateMobile, trigger: 'blur' }],
password: [{ validator: validatePass, trigger: 'blur' }], password: [{ validator: validatePass, trigger: 'blur' }],
code: [{ validator: validateCode, trigger: 'change' }], code: [{ validator: validateCode, trigger: 'change' }],
sms: [{ validator: validateSms, trigger: 'change' }] smsCode: [{ validator: validateSms, trigger: 'change' }]
}, },
loading: false, loading: false,
redirect: undefined redirect: undefined
...@@ -182,12 +186,21 @@ export default { ...@@ -182,12 +186,21 @@ export default {
} }
}, },
methods: { methods: {
openView(item) {
this.$refs.userAgreement.loadData(item)
},
changeMode(mode) { changeMode(mode) {
this.mode = mode this.mode = mode
if (mode === 1) { if (mode === 1) {
this.title = '登录' this.title = '登录'
this.loginForm.password = ''
this.loginForm.code = ''
this.loginForm.smsCode = ''
} else if (mode === 2) { } else if (mode === 2) {
this.title = '快捷登录' this.title = '快捷登录'
this.loginForm.password = ''
this.loginForm.code = ''
this.loginForm.smsCode = ''
} else { } else {
this.title = '注册' this.title = '注册'
} }
...@@ -196,6 +209,22 @@ export default { ...@@ -196,6 +209,22 @@ export default {
if (this.timer && this.smsTime) { if (this.timer && this.smsTime) {
return return
} }
if (!this.loginForm.username) {
return this.$notify({
message: '请输入手机号!',
type: 'warning',
duration: 5000
})
}
HttpReq.webClientApi.sendSmsCode({
tel: this.loginForm.username
}).then((res) => {
this.$notify({
title: res.msg,
type: 'success',
duration: 2500
})
if (res.code === 200) {
this.smsBtn = '短信已发送' this.smsBtn = '短信已发送'
this.smsTime = 30 this.smsTime = 30
this.timer = setInterval(() => { this.timer = setInterval(() => {
...@@ -206,6 +235,8 @@ export default { ...@@ -206,6 +235,8 @@ export default {
this.smsBtn = '短信获取验证码' this.smsBtn = '短信获取验证码'
} }
}, 1000) }, 1000)
}
})
}, },
getCode() { getCode() {
getCodeImg().then(res => { getCodeImg().then(res => {
...@@ -224,7 +255,10 @@ export default { ...@@ -224,7 +255,10 @@ export default {
username: username === undefined ? this.loginForm.username : username, username: username === undefined ? this.loginForm.username : username,
password: password, password: password,
rememberMe: rememberMe === undefined ? false : Boolean(rememberMe), rememberMe: rememberMe === undefined ? false : Boolean(rememberMe),
code: '' code: '',
agreement: true,
smsCode: '',
uuid: ''
} }
}, },
handleRegister() { handleRegister() {
...@@ -234,7 +268,7 @@ export default { ...@@ -234,7 +268,7 @@ export default {
password: this.loginForm.password, password: this.loginForm.password,
rememberMe: this.loginForm.rememberMe, rememberMe: this.loginForm.rememberMe,
code: this.loginForm.code, code: this.loginForm.code,
sms: this.loginForm.sms, smsCode: this.loginForm.smsCode,
uuid: this.loginForm.uuid uuid: this.loginForm.uuid
} }
if (user.password !== this.cookiePass) { if (user.password !== this.cookiePass) {
...@@ -271,7 +305,7 @@ export default { ...@@ -271,7 +305,7 @@ export default {
password: this.loginForm.password, password: this.loginForm.password,
rememberMe: this.loginForm.rememberMe, rememberMe: this.loginForm.rememberMe,
code: this.loginForm.code, code: this.loginForm.code,
sms: this.loginForm.sms, smsCode: this.loginForm.smsCode,
uuid: this.loginForm.uuid uuid: this.loginForm.uuid
} }
if (user.password !== this.cookiePass) { if (user.password !== this.cookiePass) {
......
This diff is collapsed.
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment