Quellcode durchsuchen

登录及个人中心

lipengtao vor 6 Jahren
Ursprung
Commit
e0016e8e63

+ 11 - 6
src/components/global-component/citypick/CityPick.vue

@ -9,7 +9,7 @@
9 9
          <el-option
10 10
            v-for="item in provs"
11 11
            :label="item.text"
12
            :value="item.text"
12
            :value="item.value"
13 13
            :key="item.index">
14 14
          </el-option>
15 15
        </el-select>
@ -24,7 +24,7 @@
24 24
        <el-option
25 25
          v-for="item in citys"
26 26
          :label="item.text"
27
          :value="item.text"
27
          :value="item.value"
28 28
          :key="item.index">
29 29
        </el-option>
30 30
      </el-select>
@ -65,6 +65,13 @@
65 65
      },
66 66
      city() {
67 67
        if (this.city) {
68
          if (this.citys.length === 0) {
69
            for (var val of this.provs) {
70
              if (this.prov === val.value) {
71
                this.citys = val.children;
72
              };
73
            };
74
          }
68 75
          this.selectCity = this.city;
69 76
        };
70 77
      }
@ -75,19 +82,17 @@
75 82
        this.citys = [];
76 83
        this.selectCity = '';
77 84
        for (var val of this.provs) {
78
          if (prov === val.text) {
85
          if (prov === val.value) {
79 86
            tempCity = val.children;
80 87
          };
81 88
        };
82 89
        this.citys = tempCity;
83 90
        this.$emit('selectProv', this.selectProv);
84
        this.$emit('selectCity', this.selectCity);
85 91
      },
86 92
      getCity(city) {
87 93
        console.log(city);
88 94
        console.log(this.selectCity);
89
        this.$emit('selectProv', this.selectProv);
90
        this.$emit('selectCity', this.selectCity);
95
        this.$emit('selectProv', this.selectCity);
91 96
      },
92 97
      resetProvCity() {
93 98
        this.selectProv = '';

+ 148 - 0
src/components/uploadFile/index.vue

@ -0,0 +1,148 @@
1
<template>
2
  <div class="upload-box">
3
    <div class="el-upload-list el-upload-list--picture-card">
4
      <div class="el-upload-list__item is-success" v-for="(imgIt,imgIndex) in imageUrl" :key="imgIt.index" :style="{ width: uploadImg.width, height: uploadImg.height }">
5
        <img class="flex-img__image" :src="imgIt" :style="{ maxWidth: uploadImg.width, maxHeight: uploadImg.height }">
6
        <label class="el-upload-list__item-status-label">
7
          <i class="el-icon-upload-success el-icon-check"></i>
8
        </label>
9
        <span class="el-upload-list__item-actions">
10
          <span class="el-upload-list__item-delete">
11
            <i class="el-icon-delete" @click.stop="handleRemove(imgIndex)"></i>
12
          </span>
13
        </span>
14
      </div>
15
    </div>
16
    <el-upload class="avatar-uploader" :action="uploadImg.url" v-show="!plusShow" :show-file-list="false" :on-success="handleAvatarSuccess"
17
      :before-upload="beforeAvatarUpload" :style="{ width: uploadImg.width, height: uploadImg.height }">
18
      <i class="el-icon-plus avatar-uploader-icon" :style="{ width: uploadImg.width, height: uploadImg.height, lineHeight: uploadImg.height }">
19
        <div slot="tip" class="el-upload__tip" align="center" :style="{ width: uploadImg.width }">
20
          <div>{{uploadImg.tip || ''}}</div>
21
          <div>PNG/JPG/JPEG格式<br />2M以内</div>
22
        </div>
23
      </i>
24
    </el-upload>
25
  </div>
26
</template>
27
28
<script>
29
  /* 使用说明
30
   * imgsArr: [], // 数据动态回显图片数组
31
   * uploadImg: {
32
   *  url: uploadLogo, // upload--action
33
   *  tip: '上传平台LOGO图片', // 上传图片的提示tip
34
   *  width: '280px',
35
   *  height: '200px',
36
   *  fun: 'uploadfun',
37
   *  limit: 3 //最多可以传输数量
38
   * }
39
  */
40
  import util from '@/libs/util'
41
  export default {
42
    props: ['upImgsStr', 'uploadImg'],
43
    data() {
44
      return {
45
        imageUrl: util.strToArr(this.upImgsStr) || []
46
      }
47
    },
48
    watch: {
49
      upImgsStr(value) {
50
        console.log(value)
51
        this.imageUrl = util.strToArr(value)
52
      },
53
      imageUrl(value) {
54
        const list = util.arrToStr(value)
55
        this.$emit('uploadfun', list)
56
      }
57
    },
58
    computed: {
59
      limitNum() {
60
        return this.uploadImg.limit || 1
61
      },
62
      plusShow() { // 当图片多于N张的时候,就隐藏上传框
63
        if (this.imageUrl) {
64
          return this.imageUrl.length >= this.limitNum
65
        } else {
66
          return false
67
        }
68
      }
69
    },
70
    methods: {
71
      handleRemove(index) {
72
        this.imageUrl.splice(index, 1)
73
      },
74
      handleAvatarSuccess(res) {
75
        this.imageUrl.push(res.data.uri)
76
      },
77
      beforeAvatarUpload(file) {
78
        const isJPG = file.type === 'image/jpeg'
79
        const isPNG = file.type === 'image/png'
80
        const isLt2M = file.size / 1024 / 1024 < 2
81
        if (!isJPG && !isPNG) {
82
          this.$message.error('只能上传jpg/jpeg/png格式的图片,请重新上传')
83
        }
84
        if (!isLt2M) {
85
          this.$message.error('图片大小不能超过2MB,请重新上传')
86
        }
87
        return isJPG && isLt2M
88
      }
89
    }
90
  }
91
</script>
92
<style>
93
  .upload-box {
94
    display: flex;
95
  }
96
  .avatar-uploader .el-upload {
97
    border: 1px dashed #d9d9d9;
98
    border-radius: 6px;
99
    cursor: pointer;
100
    position: relative;
101
    overflow: hidden;
102
    display: flex;
103
    justify-content: center;
104
    align-items: center;
105
  }
106
  .el-upload--picture-card {
107
    width: 100%;
108
    height: 100%;
109
  }
110
  .avatar-uploader .el-upload:hover {
111
    border-color: #409EFF;
112
  }
113
  .avatar-uploader-icon {
114
    font-size: 28px;
115
    color: #8c939d;
116
    text-align: center;
117
  }
118
  .el-icon-plus:before {
119
    bottom: 10%;
120
    position: relative;
121
  }
122
  .avatar {
123
    display: block;
124
  }
125
  .el-upload__tip {
126
    position: absolute;
127
    bottom: 12%;
128
    padding: 10px;
129
    line-height: 16px;
130
    z-index: 0;
131
  }
132
  .el-upload-list--picture-card {
133
    overflow: hidden;
134
  }
135
  .el-upload-list--picture-card .el-upload-list__item {
136
    float: left;
137
    display: flex;
138
    justify-content: center;
139
    align-items: center;
140
    height: auto;
141
  }
142
  .el-upload-list--picture-card .el-upload-list__item-thumbnail {
143
    width: auto;
144
    height: auto;
145
    max-width: 100%;
146
    max-height: 100%;
147
  }
148
</style>

+ 1 - 1
src/libs/axios.js

@ -11,7 +11,7 @@ axiosUtil.interceptors.request.use(function (config) {
11 11
    if (config.method === 'post') {
12 12
      config.data = qs.stringify(config.data, {arrayFormat: 'repeat'});
13 13
      // 处理后后台无需添加RequestBody
14
      config.headers['Content-Type'] = 'application/x-www-form-urlencoded; charset=UTF-8';
14
      config.headers['Content-Type'] = 'application/x-www-form-urlencoded';
15 15
    };
16 16
    return config;
17 17
});

+ 43 - 0
src/permission.js

@ -0,0 +1,43 @@
1
import router from './router'
2
import store from './store'
3
import { Message } from 'element-ui'
4
import Cookies from 'js-cookie'
5
6
const whiteList = ['/publishProduct', '/companyProduct', '/companyInformation', '/myDemand', '/examineDemand', '/modifyDemand', '/modifyData', '/modifyPassword', '/attentionCollect'] // 不重定向白名单
7
router.beforeEach((to, from, next) => {
8
  if (Cookies.get('userid')) {
9
    if (to.path === '/loginPlat') {
10
      next({ path: '/home' });
11
    } else {
12
      if (!store.getters.account) { // 判断当前用户是否已拉取完user_info信息
13
        store.dispatch('GetUserInfo').then(res => { // 拉取user_info
14
          if (res.success && res.data) {
15
            next();
16
          } else {
17
            store.dispatch('FedLogOut').then(() => {
18
              if (whiteList.indexOf(to.path) !== -1) {
19
                Message.error('登录状态失效,请重新登录');
20
                router.push({ path: '/loginPlat' });
21
              } else {
22
                next();
23
              }
24
            })
25
          }
26
        }).catch((err) => {
27
          store.dispatch('FedLogOut').then(() => {
28
            Message.error(err || '登录状态失效,请重新登录');
29
            next({ path: '/loginPlat' })
30
          })
31
        })
32
      } else {
33
        next();
34
      }
35
    }
36
  } else {
37
    if (whiteList.indexOf(to.path) !== -1) {
38
      router.push({ path: '/loginPlat' });
39
    } else {
40
      next();
41
    }
42
  }
43
})

+ 4 - 1
src/store/getters.js

@ -1,4 +1,7 @@
1 1
const getters = {
2
  pinfo: state => state.plat.pinfo
2
  pinfo: state => state.plat.pinfo,
3
  account: state => state.user.account,
4
  bindCompany: state => state.user.bindCompany,
5
  headPhoto: state => state.user.headPhoto
3 6
};
4 7
export default getters;

+ 3 - 1
src/store/index.js

@ -1,13 +1,15 @@
1 1
import Vue from 'vue';
2 2
import Vuex from 'vuex';
3 3
import plat from './modules/plat';
4
import user from './modules/user';
4 5
import getters from './getters';
5 6
6 7
Vue.use(Vuex);
7 8
8 9
const store = new Vuex.Store({
9 10
  modules: {
10
    plat
11
    plat,
12
    user
11 13
  },
12 14
  getters
13 15
});

+ 32 - 61
src/store/modules/user.js

@ -1,14 +1,13 @@
1
import { login, logout, getInfo } from '@/api/login'
2
import { getCookiesName, setCookiesName, removeCookiesName } from '@/utils/auth'
1
import http from '@/libs/axios'
2
import Cookies from 'js-cookie'
3
import util from '@/libs/util'
3 4
4 5
const user = {
5 6
  state: {
6 7
    account: '',
7 8
    userid: '',
8
    name: '',
9
    roles: [],
10
    logins: '',
11
    session: getCookiesName()
9
    bindCompany: '',
10
    headPhoto: ''
12 11
  },
13 12
  mutations: {
14 13
    SET_ACCOUNT: (state, account) => {
@ -17,61 +16,31 @@ const user = {
17 16
    SET_USERID: (state, userid) => {
18 17
      state.userid = userid
19 18
    },
20
    SET_NAME: (state, name) => {
21
      state.name = name
19
    SET_BINDCOMPANY: (state, bindCompany) => {
20
      state.bindCompany = bindCompany
22 21
    },
23
    SET_ROLES: (state, roles) => {
24
      state.roles = roles
25
    },
26
    SET_LOGIN: (state, logins) => {
27
      state.logins = logins
28
    },
29
    SET_SESSION: (state, session) => {
30
      state.session = session
22
    SET_HEADPHOTO: (state, headPhoto) => {
23
      state.headPhoto = headPhoto || util.defaultSet.img.expert;
31 24
    }
32 25
  },
33 26
34 27
  actions: {
35
    // 用户名登录
36
    LoginByUsername({ commit }, userInfo) {
37
      const account = userInfo.username.trim()
38
      const pw = userInfo.password
39
      const vc = userInfo.imgVerifyCode.toLocaleUpperCase()
40
      return new Promise((resolve, reject) => {
41
        login(account, pw, vc).then((response) => {
42
          if (response.success) {
43
            if (response.data) {
44
              const dataS = response.data
45
              if (dataS.active) {
46
                commit('SET_ACCOUNT', dataS.account)
47
                commit('SET_USERID', dataS.id)
48
                commit('SET_ROLES', [dataS.type.toString()])
49
                commit('SET_NAME', dataS.name)
50
                setCookiesName(dataS.name)
51
              }
52
            }
53
          }
54
          resolve(response)
55
        }).catch(error => {
56
          reject(error)
57
        })
58
      })
59
    },
60
61 28
    // 获取用户信息
62 29
    GetUserInfo({ commit, state }) {
63 30
      return new Promise((resolve, reject) => {
64
        getInfo().then(response => {
65
          if (response.success) {
66
            if (response.data) {
67
              const dataS = response.data
68
              if (dataS.active) {
69
                commit('SET_ACCOUNT', dataS.account)
70
                commit('SET_USERID', dataS.id)
71
                commit('SET_ROLES', [dataS.type.toString()])
72
                commit('SET_NAME', dataS.name)
73
              }
74
            }
31
        http.get('/ajax/sys/user').then(response => {
32
          if (response.data) {
33
            const dataS = response.data
34
            commit('SET_USERID', dataS.id);
35
            commit('SET_ACCOUNT', dataS.account);
36
            commit('SET_HEADPHOTO', dataS.head);
37
            commit('SET_BINDCOMPANY', dataS.bindCompany);
38
            Cookies.set('userid', dataS.id);
39
          } else {
40
            commit('SET_USERID', '')
41
            commit('SET_ACCOUNT', '')
42
            commit('SET_HEADPHOTO', '');
43
            Cookies.remove('userid')
75 44
          }
76 45
          resolve(response)
77 46
        }).catch(error => {
@ -83,13 +52,12 @@ const user = {
83 52
    // 登出
84 53
    LogOut({ commit, state }) {
85 54
      return new Promise((resolve, reject) => {
86
        logout().then(() => {
87
          commit('SET_ACCOUNT', '')
55
        http.get('/ajax/sys/logout').then(() => {
88 56
          commit('SET_USERID', '')
89
          commit('SET_ROLES', [])
90
          commit('SET_NAME', '')
91
          commit('SET_SESSION', '')
92
          removeCookiesName()
57
          commit('SET_ACCOUNT', '')
58
          commit('SET_BINDCOMPANY', '')
59
          commit('SET_HEADPHOTO', '');
60
          Cookies.remove('userid')
93 61
          resolve()
94 62
        }).catch(error => {
95 63
          reject(error)
@ -100,8 +68,11 @@ const user = {
100 68
    // 前端 登出
101 69
    FedLogOut({ commit }) {
102 70
      return new Promise(resolve => {
103
        commit('SET_SESSION', '')
104
        removeCookiesName()
71
        commit('SET_USERID', '')
72
        commit('SET_ACCOUNT', '')
73
        commit('SET_BINDCOMPANY', '')
74
        commit('SET_HEADPHOTO', '');
75
        Cookies.remove('userid')
105 76
        resolve()
106 77
      })
107 78
    }

+ 68 - 22
src/views/logforms/Captcha.vue

@ -1,40 +1,86 @@
1 1
<template>
2
<el-dialog title="请完成验证" :visible.sync="dialogFormVisible" width="460px">
3
  <el-form :model="form">
4
    <el-form-item>
5
      <el-input v-model="form.name" autocomplete="off" placeholder="请输入图片验证码" class="imageCode"></el-input>
6
      <img src="/ajax/PictureVC" class="frmtypeW">
7
    </el-form-item>
8
  </el-form>
9
  <div slot="footer" class="dialog-footer">
10
    <el-button @click="dialogFormVisible = false">取 消</el-button>
11
    <el-button type="primary" @click="dialogFormVisible = false">确 定</el-button>
12
  </div>
13
</el-dialog>
2
  <el-dialog title="请完成验证" :visible.sync="dialogFormVisible" width="460px" @closed="resetCode">
3
    <el-form :model="form" :rules="rules" ref="form">
4
      <el-form-item prop="vc">
5
        <el-input v-model="form.vc" autocomplete="off" placeholder="请输入图片验证码" class="imageCode"></el-input>
6
        <img :src="src" class="frmtypeW" @click.stop="refreshImageCode">
7
      </el-form-item>
8
    </el-form>
9
    <div slot="footer" class="dialog-footer">
10
      <el-button @click="resetCode">取 消</el-button>
11
      <el-button type="primary" @click="submitForm('form')">确 定</el-button>
12
    </div>
13
  </el-dialog>
14 14
</template>
15 15
<script>
16 16
  export default {
17
    props: ['phone'],
17 18
    data() {
18 19
      return {
20
        src: '',
19 21
        dialogFormVisible: false,
20 22
        form: {
21
          name: ''
23
          vc: '',
24
          phone: ''
25
        },
26
        rules: {
27
          vc: [
28
            { required: true, message: '请输入验证码' }
29
          ]
22 30
        }
23 31
      };
24 32
    },
25 33
    methods: {
26
        capShow() {
27
            this.dialogFormVisible = !this.dialogFormVisible;
28
        }
34
      resetCode() {
35
        this.$refs.form.resetFields();
36
        this.dialogFormVisible = false;
37
      },
38
      refreshImageCode() {
39
        this.src = `/ajax/PictureVC?flag=PIC_REG&time=${new Date().getTime()}`;
40
      },
41
      capShow() {
42
        this.refreshImageCode();
43
        this.dialogFormVisible = !this.dialogFormVisible;
44
      },
45
      submitForm(formName) {
46
        this.$refs[formName].validate((valid) => {
47
          if (valid) {
48
            this.form.phone = this.phone;
49
            this.form.vc = this.form.vc.toUpperCase();
50
            this.$axios.post('ajax/sys/registe/phone/msg', this.form, res => {
51
              if (res.success) {
52
                this.$emit('touchSetin');
53
                this.resetCode();
54
              } else {
55
                const errMsg = {
56
                  '-60001': '验证超时',
57
                  '-60003': '验证码错误,请重新输入',
58
                  '0': '一小时内发送短信次数超过限制,请稍后再试'
59
                }
60
                this.$message.error(errMsg[res.code]);
61
                this.refreshImageCode();
62
              }
63
            })
64
          } else {
65
            return false;
66
          }
67
        });
68
      }
29 69
    }
30 70
  };
31 71
</script>
32 72
33
<style lang="stylus" rel="stylesheet/stylus" scoped>
34
  .frmtypeW
35
    float: right
36
  .imageCode
37
    width: 70%
38
  .dialog-footer
73
<style lang="scss" rel="stylesheet/scss" scoped>
74
  .frmtypeW {
75
    float: right;
76
    cursor: pointer;
77
  }
78
79
  .imageCode {
80
    width: 70%;
81
  }
82
83
  .dialog-footer {
39 84
    text-align: center
85
  }
40 86
</style>

+ 95 - 48
src/views/logforms/enteringRegister.vue

@ -3,53 +3,94 @@
3 3
    <div class="logo-wrapper"></div>
4 4
    <div class="form-wrapper">
5 5
      <div class="form-contain">
6
        <p class="form-title">北京科袖科技有限公司</p>
6
        <p class="form-title">{{$route.query.orgName}}</p>
7 7
        <p class="form-title">欢迎入驻平台</p>
8 8
        <p class="promptText">请先绑定手机并设置密码</p>
9 9
        <el-form :model="ruleForm" :rules="rules" ref="ruleForm" class="demo-ruleForm">
10 10
          <el-form-item prop="phone">
11 11
            <el-input v-model="ruleForm.phone" placeholder="请输入手机号码"></el-input>
12 12
          </el-form-item>
13
          <el-form-item prop="pass">
14
            <el-input type="password" v-model="ruleForm.pass" placeholder="请输入登录密码" auto-complete="off"></el-input>
13
          <el-form-item prop="pw">
14
            <el-input type="password" v-model="ruleForm.pw" placeholder="请输入登录密码" auto-complete="off"></el-input>
15 15
          </el-form-item>
16
          <el-form-item prop="mail">
17
            <el-input v-model="ruleForm.mail" placeholder="请输入短信验证码" class='codeWidth'></el-input>
18
            <el-button type="primary" class='codeWidth codeButton'>获取短信验证码</el-button>
16
          <el-form-item prop="vc">
17
            <el-input v-model="ruleForm.vc" placeholder="请输入短信验证码" class='codeWidth'></el-input>
18
            <el-button type="primary" class='codeWidth codeButton' :disabled='isDisabled' @click="buttonCheck">{{buttonMsg}}</el-button>
19 19
          </el-form-item>
20 20
          <el-form-item>
21 21
            <i class="el-icon-check successSelect"></i><span class="protocol">我已阅读并同意<a href='#/userAgreement'>《邢台科技条件平台用户协议》</a></span>
22 22
          </el-form-item>
23 23
          <el-form-item>
24
            <el-button type="primary" :disabled="isDisabl" :loading="logining" @click="submitForm('ruleForm')">绑定</el-button>
24
            <el-button type="primary" :disabled="isDisabl" :loading="logining" @click="submitForm('ruleForm')">注册</el-button>
25
            <div class='existing-account'>已有账号<a href="#/loginPlat">立即登录</a></div>
25 26
          </el-form-item>
26 27
        </el-form>
27 28
      </div>
28 29
    </div>
29
    <Captcha ref="obj"></Captcha>
30
    <Captcha ref="obj" :phone="ruleForm.phone" v-on:touchSetin="touchSetin"></Captcha>
30 31
  </div>
31 32
</template>
32 33
33 34
<script type="text/ecmascript-6">
34
  import httpUrl from '@/libs/http';
35 35
  import Captcha from './Captcha.vue';
36
  import Cookies from 'js-cookie';
36 37
  export default {
37 38
     data() {
39
      let validatePhone = (rule, value, callback) => {
40
        const pattern = /^1[34578]\d{9}$/;
41
        if (value === '') {
42
          this.phoneFlag = false;
43
          callback(new Error('请输入您的手机号码'));
44
        } else {
45
          if (!pattern.test(value)) {
46
            this.phoneFlag = false;
47
            callback(new Error('请输入正确的手机号码'));
48
          } else {
49
            let phone = this.ruleForm.phone;
50
            this.$axios.get('/ajax/sys/user/exists', { phone }, response => {
51
              if (response.success && response.data) {
52
                this.phoneFlag = false;
53
                callback(new Error('该账号已存在,请重新输入'))
54
              } else {
55
                this.phoneFlag = true;
56
                callback();
57
              }
58
            });
59
          }
60
        }
61
      };
62
      let validatePw = (rule, value, callback) => {
63
        const reg = /^[a-zA-Z0-9]{6,24}$/
64
        if (value === '') {
65
          callback(new Error('请设置您的登录密码'));
66
        } else {
67
          if (!reg.test(value)) {
68
            callback(new Error('密码由6-24个数字和字母组成,区分大小写'));
69
          } else {
70
            callback();
71
          }
72
        }
73
      }
38 74
      return {
39 75
        logining: false,
40 76
        isDisabl: false,
77
        isDisabled: false,
78
        buttonMsg: '获取短信验证码',
79
        phoneFlag: false,
41 80
        ruleForm: {
42
          mail: '',
43
          pass: ''
81
          phone: '',
82
          vc: '',
83
          pw: ''
44 84
        },
45 85
        rules: {
46
          mail: [
47
            { required: true, message: '请输入邮箱账号', trigger: 'blur' },
48
            { type: 'email', message: '请输入正确的邮箱地址', trigger: ['blur'] }
86
          phone: [
87
            { required: true, validator: validatePhone, trigger: 'blur' }
88
          ],
89
          pw: [
90
            { required: true, validator: validatePw, trigger: 'blur' }
49 91
          ],
50
          pass: [
51
            { required: true, message: '请输入登录密码', trigger: 'blur' },
52
            { min: 6, max: 24, message: '密码由6-24个字符组成,区分大小写', trigger: 'blur' }
92
          vc: [
93
            { required: true, message: '请输入验证码' }
53 94
          ]
54 95
        }
55 96
      };
@ -57,51 +98,57 @@
57 98
    components: {
58 99
      Captcha
59 100
    },
60
    mounted() {
61
      this.$refs.obj.capShow();
62
    },
63 101
    methods: {
102
      touchSetin() {
103
        this.setInt(60)
104
      },
105
      setInt(num) {
106
        this.isDisabled = true;
107
        let timer = setInterval(() => {
108
          this.buttonMsg = `重新获取(${num--}秒)`
109
          if (num === 0) {
110
            this.isDisabled = false;
111
            this.buttonMsg = '获取短信验证码';
112
            clearInterval(timer);
113
          }
114
        }, 1000);
115
      },
116
      buttonCheck() {
117
        this.$refs.ruleForm.validateField('phone');
118
        if (this.phoneFlag) {
119
          this.$refs.obj.capShow();
120
        }
121
      },
64 122
      submitForm(formName) {
65 123
        this.$refs[formName].validate((valid) => {
66 124
          if (valid) {
67 125
            this.logining = true;
68
            let paramsData = {
69
              'email': this.ruleForm.mail,
70
              'pw': this.ruleForm.pass
71
            };
72
            this.$axios.post(httpUrl.hQuery.sign.login, paramsData).then(res => {
126
            this.ruleForm.companyId = this.$route.query.id;
127
            this.$axios.post('/ajax/sys/registe/comp', this.ruleForm, res => {
73 128
              this.logining = false;
74
              console.log(res);
75 129
              if (res.success) {
76
                this.$router.push({path: '/WorkHome'});
130
                this.$store.commit('SET_ACCOUNT', res.data.account);
131
                this.$store.commit('SET_USERID', res.data.id);
132
                this.$store.commit('SET_HEADPHOTO', res.data.head);
133
                this.$store.commit('SET_BINDCOMPANY', res.data.bindCompany);
134
                Cookies.set('userid', res.data.id);
135
                this.$router.push({path: '/home'});
77 136
              } else {
78
                let errorCode = [{
79
                  code: -600001,
80
                  msg: '用户不存在'
81
                }, {
82
                  code: -600002,
83
                  msg: '密码不正确'
84
                }, {
85
                  code: -600003,
86
                  msg: '平台信息不存在'
87
                }, {
88
                  code: -600004,
89
                  msg: '用户被禁用'
90
                }];
91
                for (let i = 0; i < errorCode.length; i++) {
92
                  if (res.code === errorCode[i].code) {
93
                    this.$message.error(errorCode[i].msg);
94
                    return;
95
                  };
137
                const errorCode = {
138
                  '-60001': '验证码已过期,请重新获取',
139
                  '-60002': '验证码错误,请重新输入',
140
                  '-60003': '该账号已存在,请重新输入'
96 141
                };
142
                this.$message.error(errorCode[res.code]);
97 143
              }
98
            }).catch(error => {
99
              console.log(error);
100
            });
144
            })
101 145
          } else {
102 146
            return false;
103 147
          }
104 148
        });
149
      },
150
      goBackPwd() {
151
        this.$router.push({path: '/findPwd'});
105 152
      }
106 153
    }
107 154
  };

+ 83 - 77
src/views/logforms/findPwd.vue

@ -13,19 +13,19 @@
13 13
14 14
        <div class="step-contain">
15 15
          <el-form v-show="stepFisrt" :model="ruleForm" :rules="rules" ref="ruleForm" class="demo-ruleForm">
16
            <el-form-item prop="mail">
17
              <el-input v-model="ruleForm.mail" placeholder="请输入手机号码"></el-input>
16
            <el-form-item prop="phone">
17
              <el-input v-model="ruleForm.phone" placeholder="请输入手机号码"></el-input>
18 18
            </el-form-item>
19
            <el-form-item prop="mail">
20
              <el-input v-model="ruleForm.mail" placeholder="请输入短信验证码" class='codeWidth'></el-input>
21
              <el-button type="primary" class='codeWidth codeButton'>获取短信验证码</el-button>
19
            <el-form-item prop="vc">
20
              <el-input v-model="ruleForm.vc" placeholder="请输入短信验证码" class='codeWidth'></el-input>
21
              <el-button type="primary" class='codeWidth codeButton' @click.stop="buttonCheck" :disabled="isDisabled">{{buttonMsg}}</el-button>
22 22
            </el-form-item>
23 23
            <el-form-item></el-form-item>
24 24
            <el-form-item class="textButton-box">
25 25
              <el-button type="primary" :disabled="isDisabl" @click="nextStep('ruleForm')">下一步</el-button>
26 26
            </el-form-item>
27 27
          </el-form>
28
          <el-form v-show="stepThird" :model="ruleForm2" :rules="rules2" ref="ruleForm2" class="demo-ruleForm">
28
          <el-form v-show="!stepFisrt" :model="ruleForm2" :rules="rules2" ref="ruleForm2" class="demo-ruleForm">
29 29
            <el-form-item prop="pass">
30 30
              <el-input type="password" v-model="ruleForm2.pass" placeholder="请设置您的新密码" auto-complete="off"></el-input>
31 31
            </el-form-item>
@ -44,17 +44,37 @@
44 44
</template>
45 45
46 46
<script type="text/ecmascript-6">
47
  import Cookies from 'js-cookie';
48
  import httpUrl from '@/libs/http';
49
  import util from '@/libs/util';
50
51 47
  export default {
52 48
    data() {
49
      let validatePhone = (rule, value, callback) => {
50
        const pattern = /^1[34578]\d{9}$/;
51
        if (value === '') {
52
          this.phoneFlag = false;
53
          callback(new Error('请输入您的手机号码'));
54
        } else {
55
          if (!pattern.test(value)) {
56
            this.phoneFlag = false;
57
            callback(new Error('请输入正确的手机号码'));
58
          } else {
59
            let phone = this.ruleForm.phone;
60
            this.$axios.get('/ajax/sys/user/exists', { phone }, response => {
61
              if (response.success && response.data) {
62
                this.phoneFlag = true;
63
                callback();
64
              } else {
65
                this.phoneFlag = false;
66
                callback(new Error('该账号不存在,请重新输入'))
67
              }
68
            });
69
          }
70
        }
71
      };
53 72
      var validatePass = (rule, value, callback) => {
73
        const reg = /^[a-zA-Z0-9]{6,24}$/
54 74
        if (value === '') {
55 75
          callback(new Error('请设置您的新密码'));
56
        } else if (value.length < 6 || value.length > 24) {
57
         callback(new Error('密码由6-24个字符组成,区分大小写'));
76
        } else if (!reg.test(value)) {
77
          callback(new Error('密码由6-24个数字和字母组成,区分大小写'));
58 78
        } else {
59 79
          if (this.ruleForm2.checkPass !== '') {
60 80
            this.$refs.ruleForm2.validateField('checkPass');
@ -63,30 +83,32 @@
63 83
        }
64 84
      };
65 85
      var validatePass2 = (rule, value, callback) => {
86
        const reg = /^[a-zA-Z0-9]{6,24}$/
66 87
        if (value === '') {
67 88
          callback(new Error('请再次输入密码确认'));
68
        } else if (value !== this.ruleForm2.pass) {
69
          callback(new Error('两次输入密码不一致,请重新输入!'));
89
        } else if (!reg.test(value)) {
90
          callback(new Error('密码由6-24个数字和字母组成,区分大小写'));
70 91
        } else {
92
          if (value !== this.ruleForm2.pass) {
93
            callback(new Error('两次输入密码不一致,请重新输入!'));
94
          }
71 95
          callback();
72 96
        }
73 97
      };
74 98
      return {
75
        platId: '',
76
        resetStepNum: '',
77
        resetCode: '',
99
        phoneFlag: false,
100
        isDisabled: false,
101
        buttonMsg: '获取短信验证码',
78 102
        stepVal: 0,
79 103
        stepFisrt: true,
80
        stepThird: false,
81 104
        isDisabl: false,
82 105
        ruleForm: {
83
          mail: ''
106
          phone: '',
107
          vc: ''
84 108
        },
85 109
        rules: {
86
          mail: [
87
            { required: true, message: '请输入邮箱账号', trigger: 'blur' },
88
            { type: 'email', message: '请输入正确的邮箱地址', trigger: ['blur'] }
89
          ]
110
          phone: [{ required: true, validator: validatePhone, trigger: 'blur' }],
111
          vc: [{ required: true, message: '请输入验证码' }]
90 112
        },
91 113
        ruleForm2: {
92 114
          pass: '',
@ -102,43 +124,44 @@
102 124
        }
103 125
      };
104 126
    },
105
    created() {
106
      this.platId = Cookies.get('platId');
107
      this.resetStepNum = util.urlParse('step');
108
      this.resetCode = util.urlParse('sc');
109
      if (this.resetStepNum === '2') {
110
        this.stepFisrt = false;
111
        this.stepThird = true;
112
        this.stepVal = 2;
113
      }
114
    },
115 127
    methods: {
128
      setInt(num = 60) {
129
        this.isDisabled = true;
130
        let timer = setInterval(() => {
131
          this.buttonMsg = `重新获取(${num--}秒)`
132
          if (num === 0) {
133
            this.isDisabled = false;
134
            this.buttonMsg = '获取短信验证码'
135
            clearInterval(timer);
136
          }
137
        }, 1000);
138
      },
139
      buttonCheck() {
140
        this.$refs.ruleForm.validateField('phone')
141
        if (this.phoneFlag) {
142
          let phone = this.ruleForm.phone;
143
          this.$axios.post('/ajax/sys/resetpw/phone/msg', {phone}, res => {
144
          })
145
          this.setInt();
146
        }
147
      },
116 148
      nextStep(formName) {
117 149
        this.$refs[formName].validate((valid) => {
118 150
          if (valid) {
119
            this.$axios.post(httpUrl.hQuery.sign.reqResetPw, {
120
              id: this.platId,
121
              mail: this.ruleForm.mail,
122
              url: httpUrl.platUrl + '/#/findPwd?step=2&sc'
123
            }).then(res => {
151
            this.$axios.get('/ajax/sys/resetpw/phone/msgCheck', this.ruleForm, res => {
124 152
              console.log(res);
125 153
              if (res.success) {
126
                this.stepFisrt = false;
127
                this.stepVal = 1;
154
                if (res.data) {
155
                  this.stepFisrt = false;
156
                  this.stepVal = 1;
157
                } else {
158
                  this.$message.error('验验证码错误,请重新输入');
159
                }
128 160
              } else {
129
                let errorCode = [{
130
                  code: -600001,
131
                  msg: '用户不存在'
132
                }, {
133
                  code: -600002,
134
                  msg: '发送邮箱错误'
135
                }];
136
                for (let i = 0; i < errorCode.length; i++) {
137
                  if (res.code === errorCode[i].code) {
138
                    this.$message.error(errorCode[i].msg);
139
                    return;
140
                  };
141
                };
161
                let errorCode = {
162
                  '-60001': '验证码已过期,请重新获取'
163
                }
164
                this.$message.error(errorCode[res.code]);
142 165
              }
143 166
            });
144 167
          } else {
@ -149,39 +172,22 @@
149 172
      resetPwd(formName) {
150 173
        this.$refs[formName].validate((valid) => {
151 174
          if (valid) {
152
            this.$axios.post(httpUrl.hQuery.sign.resetpw, {
153
              code: this.resetCode,
154
              pw: this.ruleForm2.pass
155
            }).then(res => {
156
              console.log(res);
175
            this.ruleForm.pw = this.ruleForm2.pass;
176
            this.$axios.post('/ajax/sys/resetpw', this.ruleForm, res => {
157 177
              if (res.success) {
158
                this.$alert('您可以使用新密码登录您的账户了', '恭喜您,您的密码重置成功', {
178
                this.$alert('您可以使用新密码登录您的账户了', '密码重置成功', {
159 179
                  confirmButtonText: '重新登录',
160 180
                  type: 'success',
161 181
                  center: true,
162 182
                  callback: action => {
163 183
                    if (action === 'confirm') {
164
                      this.$router.push({path: '/loginPlat'});
184
                      this.$store.dispatch('LogOut').then(() => {
185
                        this.$router.push({ path: '/loginPlat' });
186
                      });
165 187
                    };
166 188
                  }
167 189
                });
168
              } else {
169
                if (res.code === -600001) {
170
                  this.$alert('小提示:邮件内的链接有效时长为10分钟', '很抱歉,当前的链接已失效。', {
171
                    confirmButtonText: '重新找回密码',
172
                    type: 'warning',
173
                    center: true,
174
                    callback: action => {
175
                      if (action === 'confirm') {
176
                        this.stepFisrt = true;
177
                        this.stepThird = false;
178
                        this.stepVal = 0;
179
                      };
180
                    }
181
                  });
182
                  return;
183
                };
184
              };
190
              }
185 191
            });
186 192
          } else {
187 193
            return false;

+ 22 - 41
src/views/logforms/inviteCodeLogin.vue

@ -9,13 +9,12 @@
9 9
          <li class="table-panel-single tablePanelActive">邀请码登录</li>
10 10
        </ul>
11 11
        <el-form :model="ruleForm" :rules="rules" ref="ruleForm" class="demo-ruleForm">
12
          <el-form-item prop="mail">
13
            <el-input v-model="ruleForm.mail" placeholder="请输入邮箱地址"></el-input>
12
          <el-form-item prop="email">
13
            <el-input v-model="ruleForm.email" placeholder="请输入邮箱地址"></el-input>
14 14
          </el-form-item>
15
          <el-form-item prop="pass">
16
            <el-input type="password" v-model="ruleForm.pass" placeholder="请输入邀请码" auto-complete="off"></el-input>
15
          <el-form-item prop="inviteCode">
16
            <el-input type="password" v-model="ruleForm.inviteCode" placeholder="请输入邀请码" auto-complete="off"></el-input>
17 17
          </el-form-item>
18
          <el-form-item></el-form-item>
19 18
          <el-form-item>
20 19
            <el-button type="primary" :disabled="isDisabl" :loading="logining" @click="submitForm('ruleForm')">登录</el-button>
21 20
          </el-form-item>
@ -26,24 +25,22 @@
26 25
</template>
27 26
28 27
<script type="text/ecmascript-6">
29
    import httpUrl from '@/libs/http';
30 28
    export default {
31 29
       data() {
32 30
        return {
33 31
          logining: false,
34 32
          isDisabl: false,
35 33
          ruleForm: {
36
            mail: '',
37
            pass: ''
34
            email: '',
35
            inviteCode: ''
38 36
          },
39 37
          rules: {
40
            mail: [
41
              { required: true, message: '请输入邮箱账号', trigger: 'blur' },
38
            email: [
39
              { required: true, message: '请输入您的邮箱地址', trigger: 'blur' },
42 40
              { type: 'email', message: '请输入正确的邮箱地址', trigger: ['blur'] }
43 41
            ],
44
            pass: [
45
              { required: true, message: '请输入登录密码', trigger: 'blur' },
46
              { min: 6, max: 24, message: '密码由6-24个字符组成,区分大小写', trigger: 'blur' }
42
            inviteCode: [
43
              { required: true, message: '请输入邀请码', trigger: 'blur' }
47 44
            ]
48 45
          }
49 46
        };
@ -53,38 +50,22 @@
53 50
          this.$refs[formName].validate((valid) => {
54 51
            if (valid) {
55 52
              this.logining = true;
56
              let paramsData = {
57
                'email': this.ruleForm.mail,
58
                'pw': this.ruleForm.pass
59
              };
60
              this.$axios.post(httpUrl.hQuery.sign.login, paramsData).then(res => {
53
              this.$axios.post('/ajax/sys/inviteLogin', this.ruleForm, res => {
61 54
                this.logining = false;
62
                console.log(res);
63 55
                if (res.success) {
64
                  this.$router.push({path: '/WorkHome'});
56
                  if (res.data) {
57
                    this.$router.push({path: 'enterRegister', query: { id: res.data.id, orgName: res.data.name }});
58
                  } else {
59
                    this.$message.error('邮箱或邀请码错误,请重新输入');
60
                  }
65 61
                } else {
66
                  let errorCode = [{
67
                    code: -600001,
68
                    msg: '用户不存在'
69
                  }, {
70
                    code: -600002,
71
                    msg: '密码不正确'
72
                  }, {
73
                    code: -600003,
74
                    msg: '平台信息不存在'
75
                  }, {
76
                    code: -600004,
77
                    msg: '用户被禁用'
78
                  }];
79
                  for (let i = 0; i < errorCode.length; i++) {
80
                    if (res.code === errorCode[i].code) {
81
                      this.$message.error(errorCode[i].msg);
82
                      return;
83
                    };
84
                  };
62
                  const errorMsg = {
63
                    '-60001': '该账号已激活,请直接登录'
64
                  }
65
                  if (errorMsg[res.code]) {
66
                    this.$message.error(errorMsg[res.code]);
67
                  }
85 68
                }
86
              }).catch(error => {
87
                console.log(error);
88 69
              });
89 70
            } else {
90 71
              return false;

+ 56 - 37
src/views/logforms/loginPlat.vue

@ -28,9 +28,40 @@
28 28
</template>
29 29
30 30
<script type="text/ecmascript-6">
31
  import httpUrl from '@/libs/http';
31
  import Cookies from 'js-cookie';
32 32
  export default {
33 33
     data() {
34
      let validatePhone = (rule, value, callback) => {
35
        const pattern = /^1[34578]\d{9}$/;
36
        if (value === '') {
37
          callback(new Error('请输入您的手机号码'));
38
        } else {
39
          if (!pattern.test(value)) {
40
            callback(new Error('请输入正确的手机号码'));
41
          } else {
42
            let phone = this.ruleForm.phone;
43
            this.$axios.get('/ajax/sys/user/exists', { phone }, response => {
44
              if (response.success && response.data) {
45
                callback();
46
              } else {
47
                callback(new Error('该账号不存在,请先注册'))
48
              }
49
            });
50
          }
51
        }
52
      };
53
      let validatePw = (rule, value, callback) => {
54
        const reg = /^[a-zA-Z0-9]{6,24}$/
55
        if (value === '') {
56
          callback(new Error('请设置您的登录密码'));
57
        } else {
58
          if (!reg.test(value)) {
59
            callback(new Error('密码由6-24个数字和字母组成,区分大小写'));
60
          } else {
61
            callback();
62
          }
63
        }
64
      }
34 65
      return {
35 66
        logining: false,
36 67
        isDisabl: false,
@ -39,13 +70,11 @@
39 70
          pw: ''
40 71
        },
41 72
        rules: {
42
          mail: [
43
            { required: true, message: '请输入邮箱账号', trigger: 'blur' },
44
            { type: 'email', message: '请输入正确的邮箱地址', trigger: ['blur'] }
45
          ],
46
          pass: [
47
            { required: true, message: '请输入登录密码', trigger: 'blur' },
48
            { min: 6, max: 24, message: '密码由6-24个字符组成,区分大小写', trigger: 'blur' }
73
          phone: [
74
          { required: true, validator: validatePhone, trigger: 'blur' }
75
        ],
76
          pw: [
77
            { required: true, validator: validatePw, trigger: 'blur' }
49 78
          ]
50 79
        }
51 80
      };
@ -55,39 +84,29 @@
55 84
        this.$refs[formName].validate((valid) => {
56 85
          if (valid) {
57 86
            this.logining = true;
58
            let paramsData = {
59
              'email': this.ruleForm.mail,
60
              'pw': this.ruleForm.pass
61
            };
62
            this.$axios.post(httpUrl.hQuery.sign.login, paramsData).then(res => {
87
            this.$axios.post('/ajax/sys/login', this.ruleForm, res => {
63 88
              this.logining = false;
64
              console.log(res);
65 89
              if (res.success) {
66
                this.$router.push({path: '/WorkHome'});
90
                if (res.data == null) {
91
                  this.$message.error('登录账号与密码不匹配');
92
                } else {
93
                  this.$store.commit('SET_ACCOUNT', res.data.account);
94
                  this.$store.commit('SET_USERID', res.data.id);
95
                  this.$store.commit('SET_HEADPHOTO', res.data.head);
96
                  this.$store.commit('SET_BINDCOMPANY', res.data.bindCompany);
97
                  Cookies.set('userid', res.data.id);
98
                  this.$router.push({path: '/home'});
99
                  this.logining = true;
100
                }
67 101
              } else {
68
                let errorCode = [{
69
                  code: -600001,
70
                  msg: '用户不存在'
71
                }, {
72
                  code: -600002,
73
                  msg: '密码不正确'
74
                }, {
75
                  code: -600003,
76
                  msg: '平台信息不存在'
77
                }, {
78
                  code: -600004,
79
                  msg: '用户被禁用'
80
                }];
81
                for (let i = 0; i < errorCode.length; i++) {
82
                  if (res.code === errorCode[i].code) {
83
                    this.$message.error(errorCode[i].msg);
84
                    return;
85
                  };
86
                };
102
                let errorCode = {
103
                  '-60001': '该账号不存在,请先注册',
104
                  '-60002': '登录账号与密码不匹配',
105
                  '-60003': '该账号状态异常,请联系客服'
106
                }
107
                this.$message.error(errorCode[res.code]);
87 108
              }
88
            }).catch(error => {
89
              console.log(error);
90
            });
109
            })
91 110
          } else {
92 111
            return false;
93 112
          }

+ 88 - 60
src/views/logforms/register.vue

@ -8,16 +8,16 @@
8 8
          <el-form-item prop="phone">
9 9
            <el-input v-model="ruleForm.phone" placeholder="请输入手机号码"></el-input>
10 10
          </el-form-item>
11
          <el-form-item prop="pass">
12
            <el-input type="password" v-model="ruleForm.pass" placeholder="请输入登录密码" auto-complete="off"></el-input>
11
          <el-form-item prop="pw">
12
            <el-input type="password" v-model="ruleForm.pw" placeholder="请输入登录密码" auto-complete="off"></el-input>
13 13
          </el-form-item>
14
          <el-form-item prop="mail">
15
            <el-input v-model="ruleForm.mail" placeholder="请输入短信验证码" class='codeWidth'></el-input>
16
            <el-button type="primary" class='codeWidth codeButton'>获取短信验证码</el-button>
14
          <el-form-item prop="vc">
15
            <el-input v-model="ruleForm.vc" placeholder="请输入短信验证码" class='codeWidth'></el-input>
16
            <el-button type="primary" class='codeWidth codeButton' :disabled='isDisabled' @click="buttonCheck">{{buttonMsg}}</el-button>
17
          </el-form-item>
18
          <el-form-item>
19
            <i class="el-icon-check successSelect"></i><span class="protocol">我已阅读并同意<a href='#/userAgreement'>《邢台科技条件平台用户协议》</a></span>
17 20
          </el-form-item>
18
           <el-form-item>
19
             <i class="el-icon-check successSelect"></i><span class="protocol">我已阅读并同意<a href='#/loginPlat'>《邢台科技条件平台用户协议》</a></span>
20
           </el-form-item>
21 21
          <el-form-item>
22 22
            <el-button type="primary" :disabled="isDisabl" :loading="logining" @click="submitForm('ruleForm')">注册</el-button>
23 23
            <div class='existing-account'>已有账号<a href="#/loginPlat">立即登录</a></div>
@ -25,34 +25,70 @@
25 25
        </el-form>
26 26
      </div>
27 27
    </div>
28
    <Captcha ref="obj"></Captcha>
28
    <Captcha ref="obj" :phone="ruleForm.phone" v-on:touchSetin="touchSetin"></Captcha>
29 29
  </div>
30 30
</template>
31 31
32 32
<script type="text/ecmascript-6">
33
  import httpUrl from '@/libs/http';
33
  import Cookies from 'js-cookie';
34 34
  import Captcha from './Captcha.vue';
35
36 35
  export default {
37 36
     data() {
37
      let validatePhone = (rule, value, callback) => {
38
        const pattern = /^1[34578]\d{9}$/;
39
        if (value === '') {
40
          this.phoneFlag = false;
41
          callback(new Error('请输入您的手机号码'));
42
        } else {
43
          if (!pattern.test(value)) {
44
            this.phoneFlag = false;
45
            callback(new Error('请输入正确的手机号码'));
46
          } else {
47
            let phone = this.ruleForm.phone;
48
            this.$axios.get('/ajax/sys/user/exists', { phone }, response => {
49
              if (response.success && response.data) {
50
                this.phoneFlag = false;
51
                callback(new Error('该账号已存在,请直接登录'))
52
              } else {
53
                this.phoneFlag = true;
54
                callback();
55
              }
56
            });
57
          }
58
        }
59
      };
60
      let validatePw = (rule, value, callback) => {
61
        const reg = /^[a-zA-Z0-9]{6,24}$/
62
        if (value === '') {
63
          callback(new Error('请设置您的登录密码'));
64
        } else {
65
          if (!reg.test(value)) {
66
            callback(new Error('密码由6-24个数字和字母组成,区分大小写'));
67
          } else {
68
            callback();
69
          }
70
        }
71
      }
38 72
      return {
39
        isActive: true,
40
        ActiveNumber: 1,
41
        activeName: 'second',
42 73
        logining: false,
43 74
        isDisabl: false,
75
        isDisabled: false,
76
        buttonMsg: '获取短信验证码',
77
        phoneFlag: false,
44 78
        ruleForm: {
45
          mail: '',
46
          pass: ''
79
          phone: '',
80
          vc: '',
81
          pw: ''
47 82
        },
48 83
        rules: {
49
          mail: [
50
            { required: true, message: '请输入邮箱账号', trigger: 'blur' },
51
            { type: 'email', message: '请输入正确的邮箱地址', trigger: ['blur'] }
84
          phone: [
85
            { required: true, validator: validatePhone, trigger: 'blur' }
86
          ],
87
          pw: [
88
            { required: true, validator: validatePw, trigger: 'blur' }
52 89
          ],
53
          pass: [
54
            { required: true, message: '请输入登录密码', trigger: 'blur' },
55
            { min: 6, max: 24, message: '密码由6-24个字符组成,区分大小写', trigger: 'blur' }
90
          vc: [
91
            { required: true, message: '请输入验证码' }
56 92
          ]
57 93
        }
58 94
      };
@ -60,56 +96,48 @@
60 96
    components: {
61 97
      Captcha
62 98
    },
63
    mounted() {
64
      this.$refs.obj.capShow();
65
    },
66 99
    methods: {
67
      panelSwitch(event) {
68
       if (event.target.className.includes('tablePanelActive')) {
69
         return;
70
       }
71
        this.isActive = !this.isActive;
100
      touchSetin() {
101
        this.setInt(60)
72 102
      },
73
      handleClick(tab, event) {
74
        console.log(tab, event);
103
      setInt(num) {
104
        this.isDisabled = true;
105
        let timer = setInterval(() => {
106
          this.buttonMsg = `重新获取(${num--}秒)`
107
          if (num === 0) {
108
            this.isDisabled = false;
109
            this.buttonMsg = '获取短信验证码'
110
            clearInterval(timer);
111
          }
112
        }, 1000);
113
      },
114
      buttonCheck() {
115
        this.$refs.ruleForm.validateField('phone')
116
        if (this.phoneFlag) {
117
          this.$refs.obj.capShow();
118
        }
75 119
      },
76 120
      submitForm(formName) {
77 121
        this.$refs[formName].validate((valid) => {
78 122
          if (valid) {
79 123
            this.logining = true;
80
            let paramsData = {
81
              'email': this.ruleForm.mail,
82
              'pw': this.ruleForm.pass
83
            };
84
            this.$axios.post(httpUrl.hQuery.sign.login, paramsData).then(res => {
124
            this.$axios.post('/ajax/sys/registe', this.ruleForm, res => {
85 125
              this.logining = false;
86
              console.log(res);
87 126
              if (res.success) {
88
                this.$router.push({path: '/WorkHome'});
127
                this.$store.commit('SET_ACCOUNT', res.data.account);
128
                this.$store.commit('SET_USERID', res.data.id);
129
                this.$store.commit('SET_HEADPHOTO', '');
130
                Cookies.set('userid', res.data.id)
131
                this.$router.push({path: '/home'});
89 132
              } else {
90
                let errorCode = [{
91
                  code: -600001,
92
                  msg: '用户不存在'
93
                }, {
94
                  code: -600002,
95
                  msg: '密码不正确'
96
                }, {
97
                  code: -600003,
98
                  msg: '平台信息不存在'
99
                }, {
100
                  code: -600004,
101
                  msg: '用户被禁用'
102
                }];
103
                for (let i = 0; i < errorCode.length; i++) {
104
                  if (res.code === errorCode[i].code) {
105
                    this.$message.error(errorCode[i].msg);
106
                    return;
107
                  };
133
                const errorCode = {
134
                  '-60001': '验证码已过期,请重新获取',
135
                  '-60002': '验证码错误,请重新输入',
136
                  '-60003': '该账号已存在,请直接登录'
108 137
                };
138
                this.$message.error(errorCode[res.code]);
109 139
              }
110
            }).catch(error => {
111
              console.log(error);
112
            });
140
            })
113 141
          } else {
114 142
            return false;
115 143
          }

+ 10 - 2
src/views/personalCenter/common/index.vue

@ -3,7 +3,7 @@
3 3
    <div class="boxLeft">
4 4
        <div class="headPhoto">
5 5
          <div class="userInfo">
6
            <img src="../../logforms/img/e-sign-on_bg_img_nor.png" alt="">
6
            <img :src="headPhoto" alt="">
7 7
            <p>专家姓名</p>
8 8
          </div>
9 9
        </div>
@ -27,7 +27,7 @@
27 27
        <el-menu-item index="modifyDemand">修改需求</el-menu-item>
28 28
        <el-menu-item index="examineDemand">查看需求</el-menu-item>
29 29
      </el-submenu>
30
      <el-submenu index="2">
30
      <el-submenu index="2" v-if="bindCompany">
31 31
        <template slot="title">
32 32
          <i class="el-icon-location"></i>
33 33
          <span>我的企业</span>
@ -55,11 +55,19 @@
55 55
</template>
56 56
57 57
<script>
58
  import { mapGetters } from 'vuex';
58 59
  export default {
59 60
    data() {
60 61
      return {
62
        img: ''
61 63
      };
62 64
    },
65
    computed: {
66
      ...mapGetters([
67
        'bindCompany',
68
        'headPhoto'
69
      ])
70
    },
63 71
    created() {
64 72
    },
65 73
    methods: {

+ 104 - 144
src/views/personalCenter/modifyData.vue

@ -6,139 +6,143 @@
6 6
    <div class='formHeadFormBox'>
7 7
      <div class='formBox'>
8 8
        <el-form :model="ruleForm2" status-icon :rules="rules2" ref="ruleForm2" label-width="80px" class="demo-ruleForm">
9
            <el-form-item label="用户名" prop="pass">
10
                <el-input v-model="ruleForm2.pass" autocomplete="off" placeholder="请输入用户名"></el-input>
9
          <el-col :span="12">
10
            <el-form-item label="用户名" prop="account">
11
              <el-input v-model="ruleForm2.account" autocomplete="off" placeholder="请输入用户名" maxlength="20"></el-input>
11 12
            </el-form-item>
12
            <el-form-item label="真实姓名" prop="checkPass">
13
                <el-input v-model="ruleForm2.checkPass" autocomplete="off" placeholder="请输入真实姓名"></el-input>
13
            <el-form-item label="真实姓名" prop="name">
14
              <el-input v-model="ruleForm2.name" autocomplete="off" placeholder="请输入真实姓名" maxlength="10"></el-input>
14 15
            </el-form-item>
15
            <el-form-item label="性别">
16
                <el-select v-model="ruleForm2.region" placeholder="请选择性别" style="width:100%">
17
                <el-option label="男" value="shanghai"></el-option>
18
                <el-option label="女" value="beijing"></el-option>
19
                </el-select>
16
            <el-form-item label="性别" prop="sex">
17
              <el-select v-model="ruleForm2.sex" placeholder="请选择性别" style="width: 100%">
18
                <el-option label="男" value="0"></el-option>
19
                <el-option label="女" value="1"></el-option>
20
              </el-select>
20 21
            </el-form-item>
21
            <el-form-item label="职位" prop="age">
22
                <el-input v-model.number="ruleForm2.age" placeholder="请输入职位"></el-input>
22
            <el-form-item label="职位" prop="job">
23
              <el-input v-model.number="ruleForm2.job" placeholder="请输入职位" maxlength="20"></el-input>
23 24
            </el-form-item>
24
            <el-form-item label="所在机构" prop="age">
25
                <el-input v-model.number="ruleForm2.age" placeholder="请输入所在机构"></el-input>
25
            <el-form-item label="所在机构" prop="comp">
26
              <el-input v-model.number="ruleForm2.comp" placeholder="请输入所在机构" maxlength="50"></el-input>
26 27
            </el-form-item>
27
            <el-form-item label="联系电话" prop="age">
28
                <el-input v-model.number="ruleForm2.age" placeholder="请输入联系电话"></el-input>
28
            <el-form-item label="联系电话" prop="linkPhone">
29
              <el-input v-model.number="ruleForm2.linkPhone" placeholder="请输入联系电话" maxlength="50"></el-input>
29 30
            </el-form-item>
30
            <el-form-item label="联系邮箱" prop="age">
31
                <el-input v-model.number="ruleForm2.age" placeholder="请输入联系邮箱"></el-input>
31
            <el-form-item label="联系邮箱" prop="email">
32
              <el-input v-model="ruleForm2.email" placeholder="请输入联系邮箱" maxlength="100"></el-input>
32 33
            </el-form-item>
33
            <CityPick ref="cityPick"  :widthselect="206" :prov="ruleForm2.province" :city="ruleForm2.city" v-on:selectProv="getSelectProv($event)" v-on:selectCity="getSelectCity($event)"></CityPick>
34
            <el-form-item style="text-align:right">
35
                <el-button type="primary" @click="submitForm('ruleForm2')">保存修改</el-button>
34
            <CityPick ref="cityPick" :widthselect="180" :prov="province" :city="city"
35
              v-on:selectProv="getSelectProv($event)">
36
            </CityPick>
37
          </el-col>
38
          <el-col :span="12">
39
            <el-form-item prop="head">
40
              <uploadFile :uploadImg='uploadImg' v-on:uploadfun="uploadfun" :upImgsStr="upImgsStr"></uploadFile>
36 41
            </el-form-item>
42
          </el-col>
43
          <el-col :span="24">
44
            <el-form-item style="text-align: center;margin:15px 0">
45
              <el-button type="primary" @click="submitForm('ruleForm2')">保存修改</el-button>
46
            </el-form-item>
47
          </el-col>
37 48
        </el-form>
38 49
      </div>
39
      <div class="headPhotoBox">
40
        <el-upload
41
        class="avatar-uploader"
42
        action="https://jsonplaceholder.typicode.com/posts/"
43
        :show-file-list="false"
44
        :on-success="handleAvatarSuccess"
45
        :before-upload="beforeAvatarUpload">
46
        <img v-if="imageUrl" :src="imageUrl" class="avatar">
47
        <i v-else class="el-icon-plus avatar-uploader-icon"></i>
48
      </el-upload>
49
      <p>上传头像</p>
50
      </div>
51 50
    </div>
52 51
  </div>
53 52
</template>
54 53
55 54
<script>
55
  import uploadFile from '@/components/uploadFile/index';
56
  import Cookies from 'js-cookie'
56 57
  export default {
57 58
    data() {
58
      var checkAge = (rule, value, callback) => {
59
        if (!value) {
60
          return callback(new Error('年龄不能为空'));
61
        }
62
        setTimeout(() => {
63
          if (!Number.isInteger(value)) {
64
            callback(new Error('请输入数字值'));
65
          } else {
66
            if (value < 18) {
67
              callback(new Error('必须年满18岁'));
68
            } else {
69
              callback();
70
            }
71
          }
72
        }, 1000);
73
      };
74
      var validatePass = (rule, value, callback) => {
75
        if (value === '') {
76
          callback(new Error('请输入密码'));
77
        } else {
78
          if (this.ruleForm2.checkPass !== '') {
79
            this.$refs.ruleForm2.validateField('checkPass');
80
          }
81
          callback();
82
        }
83
      };
84
      var validatePass2 = (rule, value, callback) => {
85
        if (value === '') {
86
          callback(new Error('请再次输入密码'));
87
        } else if (value !== this.ruleForm2.pass) {
88
          callback(new Error('两次输入密码不一致!'));
89
        } else {
90
          callback();
91
        }
92
      };
93 59
      return {
94
        imageUrl: '',
60
        province: '',
61
        city: '',
62
        upImgsStr: '',
63
        uploadImg: {
64
          url: '/ajax/product/logo',
65
          width: '200px',
66
          height: '200px',
67
          tip: '上传头像'
68
        },
95 69
        ruleForm2: {
96
          pass: '',
97
          checkPass: '',
98
          age: '',
99
          region: '',
100
          province: '',
101
          city: ''
70
          account: '',
71
          name: '',
72
          sex: '',
73
          job: '',
74
          comp: '',
75
          linkPhone: '',
76
          email: '',
77
          addr: '',
78
          head: ''
102 79
        },
103 80
        rules2: {
104
          pass: [
105
            { validator: validatePass, trigger: 'blur' }
81
          account: [
82
            { message: '请输入用户名', trigger: 'blur', required: true }
106 83
          ],
107
          checkPass: [
108
            { validator: validatePass2, trigger: 'blur' }
109
          ],
110
          age: [
111
            { validator: checkAge, trigger: 'blur' }
84
          email: [
85
            { type: 'email', message: '请输入正确的邮箱地址', trigger: 'blur' }
112 86
          ]
113 87
        }
114 88
      };
115 89
    },
90
    components: {
91
      uploadFile
92
    },
93
    created() {
94
      let id = Cookies.get('userid');
95
      this.$axios.get('/ajax/sys/user/get', {id}, res => { // 拉取user_info
96
        if (res.success && res.data) {
97
          const response = res.data;
98
          this.ruleForm2 = {
99
            account: response.account,
100
            name: response.name,
101
            sex: response.sex,
102
            job: response.job,
103
            comp: response.comp,
104
            linkPhone: response.linkPhone,
105
            email: response.email,
106
            addr: response.addr,
107
            head: response.head
108
          };
109
          this.upImgsStr = response.head;
110
          this.province = `${response.addr.substr(0, 2)}0000`;
111
          this.city = response.addr;
112
        } else {
113
          this.$store.dispatch('FedLogOut').then(res => {
114
            this.$message.error('登录状态失效,请重新登录');
115
            this.$router.push({ path: '/loginPlat' });
116
          })
117
        }
118
      })
119
    },
116 120
    methods: {
117
     handleAvatarSuccess(res, file) {
118
        this.imageUrl = URL.createObjectURL(file.raw);
119
      },
120
      beforeAvatarUpload(file) {
121
        const isJPG = file.type === 'image/jpeg';
122
        const isLt2M = file.size / 1024 / 1024 < 2;
123
124
        // if (!isJPG) {
125
        //   this.$message.error('上传头像图片只能是 JPG 格式!');
126
        // }
127
        // if (!isLt2M) {
128
        //   this.$message.error('上传头像图片大小不能超过 2MB!');
129
        // }
130
        return isJPG && isLt2M;
121
      uploadfun(value) {
122
        this.ruleForm2.head = value
131 123
      },
132 124
      getSelectProv(prov) {
133
        this.ruleForm2.province = prov;
134
      },
135
      getSelectCity(city) {
136
        this.ruleForm2.city = city;
125
        this.ruleForm2.addr = prov;
137 126
      },
138 127
      submitForm(formName) {
139 128
        this.$refs[formName].validate((valid) => {
140 129
          if (valid) {
141
            alert('submit!');
130
            this.$axios.post('/ajax/sys/user', this.ruleForm2, res => {
131
              console.log(res)
132
              if (res.success) {
133
                this.$store.commit('SET_ACCOUNT', this.ruleForm2.account);
134
                this.$store.commit('SET_HEADPHOTO', this.ruleForm2.head);
135
                this.$message({
136
                  message: '资料修改成功',
137
                  type: 'success'
138
                });
139
              } else {
140
                this.$store.dispatch('FedLogOut').then(res => {
141
                  this.$message.error('登录状态失效,请重新登录');
142
                  this.$router.push({ path: '/loginPlat' });
143
                })
144
              }
145
            })
142 146
          } else {
143 147
            console.log('error submit!!');
144 148
            return false;
@ -151,47 +155,3 @@
151 155
    }
152 156
  };
153 157
</script>
154
155
<style>
156
    .formHeadFormBox {
157
      margin-left: 20px;
158
      position: relative;
159
    }
160
    .formBox {
161
      width: 500px;
162
    }
163
    .headPhotoBox {
164
      position: absolute;
165
      right: 90px;
166
      top: 0px;
167
    }
168
    .headPhotoBox p {
169
        text-align: center;
170
        line-height: 30px;
171
        color: #606266;
172
        font-size: 14px
173
    }
174
  .avatar-uploader .el-upload {
175
    border: 1px dashed #d9d9d9;
176
    border-radius: 6px;
177
    cursor: pointer;
178
    position: relative;
179
    overflow: hidden;
180
  }
181
  .avatar-uploader .el-upload:hover {
182
    border-color: #409EFF;
183
  }
184
  .avatar-uploader-icon {
185
    font-size: 28px;
186
    color: #8c939d;
187
    width: 178px;
188
    height: 178px;
189
    line-height: 178px;
190
    text-align: center;
191
  }
192
  .avatar {
193
    width: 178px;
194
    height: 178px;
195
    display: block;
196
  }
197
</style>

+ 81 - 62
src/views/personalCenter/modifyPassword.vue

@ -4,21 +4,21 @@
4 4
      <el-tab-pane label="修改密码"></el-tab-pane>
5 5
    </el-tabs>
6 6
    <div class="formBoxCenter">
7
         <a href="#/findPwd">忘记密码?</a>
8
        <div class="boxCenter">
9
          <el-form :model="ruleForm2" status-icon :rules="rules2" ref="ruleForm2" label-width="100px" class="demo-ruleForm">
10
            <el-form-item label="原密码" prop="pass">
11
                <el-input type="password" v-model="ruleForm2.pass" autocomplete="off" placeholder="请输入原密码"></el-input>
12
            </el-form-item>
13
            <el-form-item label="新密码" prop="checkPass">
14
                <el-input type="password" v-model="ruleForm2.checkPass" autocomplete="off" placeholder="请输入新密码"></el-input>
15
            </el-form-item>
16
            <el-form-item label="再次输入" prop="age">
17
                <el-input v-model.number="ruleForm2.age"></el-input>
18
            </el-form-item>
19
            <el-form-item style="text-align:center">
20
                <el-button type="primary" @click="submitForm('ruleForm2')">保存修改</el-button>
21
            </el-form-item>
7
      <a href="#/findPwd">忘记密码?</a>
8
      <div class="boxCenter">
9
        <el-form :model="ruleForm2" status-icon :rules="rules2" ref="ruleForm2" label-width="100px" class="demo-ruleForm">
10
          <el-form-item label="原密码" prop="opw">
11
            <el-input type="password" v-model="ruleForm2.opw" autocomplete="off" placeholder="请输入原密码"></el-input>
12
          </el-form-item>
13
          <el-form-item label="新密码" prop="npw">
14
            <el-input type="password" v-model="ruleForm2.npw" autocomplete="off" placeholder="请输入新密码"></el-input>
15
          </el-form-item>
16
          <el-form-item label="再次输入" prop="npwCheck">
17
            <el-input type="password" v-model="ruleForm2.npwCheck" placeholder="请确认新密码"></el-input>
18
          </el-form-item>
19
          <el-form-item style="text-align:center">
20
            <el-button type="primary" @click="submitForm('ruleForm2')">保存修改</el-button>
21
          </el-form-item>
22 22
        </el-form>
23 23
      </div>
24 24
    </div>
@ -27,56 +27,60 @@
27 27
<script>
28 28
  export default {
29 29
    data() {
30
      var checkAge = (rule, value, callback) => {
31
        if (!value) {
32
          return callback(new Error('年龄不能为空'));
33
        }
34
        setTimeout(() => {
35
          if (!Number.isInteger(value)) {
36
            callback(new Error('请输入数字值'));
30
      const reg = /^[a-zA-Z0-9]{6,24}$/;
31
      var checkOpw = (rule, value, callback) => {
32
        if (value === '') {
33
          callback(new Error('请输入原密码'));
34
        } else {
35
          if (!reg.test(value)) {
36
            callback(new Error('密码由6-24个数字和字母组成,区分大小写'));
37 37
          } else {
38
            if (value < 18) {
39
              callback(new Error('必须年满18岁'));
40
            } else {
41
              callback();
42
            }
38
            callback();
43 39
          }
44
        }, 1000);
40
        }
45 41
      };
46
      var validatePass = (rule, value, callback) => {
42
      var validateNpw = (rule, value, callback) => {
47 43
        if (value === '') {
48
          callback(new Error('请输入密码'));
44
          callback(new Error('请设置您的新密码'));
49 45
        } else {
50
          if (this.ruleForm2.checkPass !== '') {
51
            this.$refs.ruleForm2.validateField('checkPass');
46
          if (!reg.test(value)) {
47
            callback(new Error('密码由6-24个数字和字母组成,区分大小写'));
48
          } else {
49
            if (this.ruleForm2.npwCheck !== '') {
50
              this.$refs.ruleForm2.validateField('npwCheck');
51
            }
52
            callback();
52 53
          }
53
          callback();
54 54
        }
55 55
      };
56
      var validatePass2 = (rule, value, callback) => {
56
      var validateNpwCheck = (rule, value, callback) => {
57 57
        if (value === '') {
58
          callback(new Error('请再次输入密码'));
59
        } else if (value !== this.ruleForm2.pass) {
60
          callback(new Error('两次输入密码不一致!'));
58
          callback(new Error('请再次输入密码确认'));
59
        } else if (!reg.test(value)) {
60
          callback(new Error('密码由6-24个数字和字母组成,区分大小写'));
61 61
        } else {
62
          callback();
62
          if (value !== this.ruleForm2.npw) {
63
            callback(new Error('两次输入不一致,请重新输入!'));
64
          } else {
65
            callback();
66
          }
63 67
        }
64 68
      };
65 69
      return {
66 70
        ruleForm2: {
67
          pass: '',
68
          checkPass: '',
69
          age: ''
71
          opw: '',
72
          npw: '',
73
          npwCheck: ''
70 74
        },
71 75
        rules2: {
72
          pass: [
73
            { validator: validatePass, trigger: 'blur' }
76
          npw: [
77
            { validator: validateNpw, trigger: 'blur', required: true }
74 78
          ],
75
          checkPass: [
76
            { validator: validatePass2, trigger: 'blur' }
79
          npwCheck: [
80
            { validator: validateNpwCheck, trigger: 'blur', required: true }
77 81
          ],
78
          age: [
79
            { validator: checkAge, trigger: 'blur' }
82
          opw: [
83
            { validator: checkOpw, trigger: 'blur', required: true }
80 84
          ]
81 85
        }
82 86
      };
@ -85,9 +89,21 @@
85 89
      submitForm(formName) {
86 90
        this.$refs[formName].validate((valid) => {
87 91
          if (valid) {
88
            alert('submit!');
92
            this.$axios.post('/ajax/sys/user/changepasswd', this.ruleForm2, res => {
93
              if (res.success) {
94
                if (res.data) {
95
                  this.$message({
96
                    message: '密码修改成功',
97
                    type: 'success'
98
                  });
99
                } else if (res.data === 0) {
100
                  this.$message.error('旧密码输入错误,请重新输入');
101
                } else {
102
                  this.$message.error('登录账号与密码不匹配');
103
                }
104
              }
105
            });
89 106
          } else {
90
            console.log('error submit!!');
91 107
            return false;
92 108
          }
93 109
        });
@ -99,17 +115,20 @@
99 115
  };
100 116
</script>
101 117
102
<style lang="stylus" rel="stylesheet/stylus" scoped>
103
  .formBoxCenter
104
    display:flex
105
    align-items: center
106
    justify-content: center
107
    .boxCenter
108
      width: 450px
109
      position: relative
110
    a
111
      position: absolute
112
      top: 60px
113
      right: 140px
114
      color: #409EFF
118
<style lang="scss" rel="stylesheet/scss" scoped>
119
  .formBoxCenter {
120
    display: flex;
121
    align-items: center;
122
    justify-content: center;
123
    .boxCenter {
124
      width: 450px;
125
      position: relative;
126
    }
127
    a {
128
      position: absolute;
129
      top: 60px;
130
      right: 140px;
131
      color: $mainColor;
132
    }
133
  }
115 134
</style>