123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244 |
- <template>
- <div class="l-con">
- <div class="l-top">
- <h1>场景转换列表登录</h1>
- </div>
- <div class="l_center">
- <vcenter>
- <div class="lc-l">
- <div class="text_01">大场景上传自动化</div>
- <div class="text_02">内部人员使用,便捷管理</div>
- <div class="text_02">请勿泄露</div>
- </div>
- <div class="lc-r">
- <div class="lc-title">
- <span>后台登录</span>
- </div>
- <div class="lc-form">
- <el-form
- label-position="top"
- :model="ruleForm2"
- status-icon
- :rules="rules2"
- ref="ruleForm2"
- label-width="100px"
- class="demo-ruleForm"
- >
- <el-form-item prop="phoneNum">
- <el-input
- type="phoneNum"
- placeholder="手机号码"
- v-model="ruleForm2.phoneNum"
- auto-complete="off"
- ></el-input>
- </el-form-item>
- <el-form-item prop="pass" id="no-bottom">
- <el-input
- type="password"
- placeholder="密码"
- @keyup.enter.native="submitForm('ruleForm2')"
- v-model="ruleForm2.pass"
- auto-complete="off"
- ></el-input>
- </el-form-item>
- <el-form-item>
- <el-checkbox v-model="checked">记住密码(在公共场所电脑请勿勾选)</el-checkbox>
- </el-form-item>
- </el-form>
- <div class="lc-btn">
- <el-button
- type="primary"
- v-loading.fullscreen.lock="fullscreenLoading"
- @click="submitForm('ruleForm2')"
- >登录</el-button>
- </div>
- </div>
- </div>
- </vcenter>
- </div>
- <div class="l_footer">
- <div>四维时代 Copyright © 2019 4DAGE Co., Ltd. All rights reserved.</div>
- <div class="sub">粤ICP备14078495号-2</div>
- </div>
- </div>
- </template>
- <script>
- import vcenter from '@/components/vcenter'
- import {encodeStr} from '@/util'
- import { Base64 } from 'js-base64'
- export default {
- name: 'login',
- components: {
- vcenter
- },
- data () {
- var validateUser = (rule, value, callback) => {
- if (!value) {
- return callback(new Error('手机号码不能为空'))
- } else if (value.length < 3) {
- callback(new Error('手机号码不合法'))
- } else {
- callback()
- }
- }
- var validatePass = (rule, value, callback) => {
- if (value === '') {
- return callback(new Error('请输入密码'))
- } else if (value.length < 4) {
- callback(new Error('密码不能小于4位'))
- } else {
- callback()
- }
- }
- return {
- fullscreenLoading: false,
- checked: true,
- ruleForm2: {
- phoneNum: '',
- pass: ''
- },
- rules2: {
- phoneNum: [
- {
- validator: validateUser,
- trigger: 'blur'
- }
- ],
- pass: [
- {
- validator: validatePass,
- trigger: 'blur'
- }
- ]
- }
- }
- },
- mounted () {
- this.ruleForm2.phoneNum = window.localStorage.getItem('cjt_phoneNum') || ''
- this.ruleForm2.pass = window.localStorage.getItem('cjt_pass') || ''
- },
- methods: {
- async login () {
- let {phoneNum, pass} = this.ruleForm2
- this.fullscreenLoading = true
- let res = await this.$http.post('/api/sso/user/login', {
- phoneNum,
- password: encodeStr(Base64.encode(pass)),
- })
- this.fullscreenLoading = false
- if (res.code === 0) {
- let data = res.data
- window.localStorage.setItem('cjt_token', data.token)
- if (this.checked) {
- window.localStorage.setItem(
- 'cjt_phoneNum',
- phoneNum
- )
- window.localStorage.setItem('cjt_pass', pass)
- } else {
- window.localStorage.setItem('cjt_phoneNum', '')
- window.localStorage.setItem('cjt_pass', '')
- }
- this.$router.push('/')
- } else {
- this.$notify.error({
- title: '错误',
- message: res.msg
- })
- }
- },
- submitForm (formName) {
- this.$refs[formName].validate(valid => {
- if (valid) {
- this.login()
- } else {
- this.$alert('请填写正确信息', '提示', {
- confirmButtonText: '确定',
- callback: action => {}
- })
- return false
- }
- })
- }
- }
- }
- </script>
- <style scoped>
- .l-con {
- width: 100%;
- }
- .l-top {
- color: #333;
- text-align: center;
- padding: 50px 0;
- }
- .lc-l {
- display: inline-block;
- color: #fff;
- }
- .lc-l img {
- width: 150px;
- }
- .text_01 {
- font-size: 60px;
- font-weight: bold;
- margin-top: 70px;
- }
- .text_02 {
- font-size: 40px;
- margin: 30px 0;
- }
- .text_03 {
- font-size: 20px;
- }
- .lc-r {
- float: right;
- width: 345px;
- height: 370px;
- background-color: #fff;
- padding: 28px 30px;
- }
- .lc-title {
- text-align: center;
- border-bottom: 2px solid #0175dc;
- padding-bottom: 20px;
- }
- .lc-title span {
- color: #333;
- font-size: 16px;
- }
- .lc-form {
- margin-top: 40px;
- }
- .lc-btn {
- width: 100%;
- }
- .lc-btn .el-button--primary {
- width: 100%;
- }
- .l_center {
- height: 600px;
- width: 100%;
- padding: 0 10% 0 20%;
- background: url("~@/assets/images/img_login_banbg.jpg") center center
- no-repeat;
- box-sizing: border-box;
- }
- .l_footer {
- font-size: 14px;
- text-align: center;
- margin-top: 45px;
- line-height: 1.5;
- }
- .sub {
- font-size: 12px;
- color: #999;
- margin-top: 10px;
- }
- </style>
|