Browse Source

Merge branch 'master' into yantai_master

feature
dai 3 years ago
parent
commit
8de21f47df
  1. 1
      src/assets/scss/pages/loginWork.scss
  2. 173
      src/utils/index.js
  3. 149
      src/views/main-navbar-update-password-work.vue
  4. 148
      src/views/main-shuju/main-navbar-update-password-work.vue
  5. 2
      src/views/main-shuju/main-navbar.vue
  6. 52
      src/views/pages/login.vue

1
src/assets/scss/pages/loginWork.scss

@ -64,6 +64,7 @@
.input { .input {
width: 85%; width: 85%;
margin-bottom: 0;
input { input {
display: block; display: block;

173
src/utils/index.js

@ -1,17 +1,18 @@
import store from '@/js/store' import store from "@/js/store";
import JSEncrypt from "jsencrypt"; //引入加密
/** /**
* 获取字典数据列表 * 获取字典数据列表
* @param dictType 字典类型 * @param dictType 字典类型
*/ */
export function getDictDataList(dictType) { export function getDictDataList(dictType) {
const type = window.SITE_CONFIG['dictList'].find( const type = window.SITE_CONFIG["dictList"].find(
(element) => element.dictType === dictType (element) => element.dictType === dictType
) );
if (type) { if (type) {
return type.dataList return type.dataList;
} else { } else {
return [] return [];
} }
} }
@ -21,20 +22,20 @@ export function getDictDataList(dictType) {
* @param dictValue 字典值 * @param dictValue 字典值
*/ */
export function getDictLabel(dictType, dictValue) { export function getDictLabel(dictType, dictValue) {
const type = window.SITE_CONFIG['dictList'].find( const type = window.SITE_CONFIG["dictList"].find(
(element) => element.dictType === dictType (element) => element.dictType === dictType
) );
if (type) { if (type) {
const val = type.dataList.find( const val = type.dataList.find(
(element) => element.dictValue === dictValue.toString() (element) => element.dictValue === dictValue.toString()
) );
if (val) { if (val) {
return val.dictLabel return val.dictLabel;
} else { } else {
return dictValue return dictValue;
} }
} else { } else {
return dictValue return dictValue;
} }
} }
@ -42,29 +43,31 @@ export function getDictLabel(dictType, dictValue) {
* 清除登录信息 * 清除登录信息
*/ */
export function clearLoginInfo() { export function clearLoginInfo() {
store.commit('resetStore') store.commit("resetStore");
localStorage.removeItem('token') localStorage.removeItem("token");
window.SITE_CONFIG['dynamicMenuRoutesHasAdded'] = false window.SITE_CONFIG["dynamicMenuRoutesHasAdded"] = false;
} }
/** /**
* 获取uuid * 获取uuid
*/ */
export function getUUID() { export function getUUID() {
return 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g, (c) => { return "xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g, (c) => {
return (c === 'x' ? (Math.random() * 16) | 0 : 'r&0x3' | '0x8').toString(16) return (c === "x" ? (Math.random() * 16) | 0 : "r&0x3" | "0x8").toString(
}) 16
);
});
} }
/** /**
* 获取svg图标(id)列表 * 获取svg图标(id)列表
*/ */
export function getIconList() { export function getIconList() {
var res = [] var res = [];
document.querySelectorAll('svg symbol').forEach((item) => { document.querySelectorAll("svg symbol").forEach((item) => {
res.push(item.id) res.push(item.id);
}) });
return res return res;
} }
/** /**
@ -73,46 +76,49 @@ export function getIconList() {
* @param {*} id * @param {*} id
* @param {*} pid * @param {*} pid
*/ */
export function treeDataTranslate(data, id = 'id', pid = 'pid') { export function treeDataTranslate(data, id = "id", pid = "pid") {
var res = [] var res = [];
var temp = {} var temp = {};
for (var i = 0; i < data.length; i++) { for (var i = 0; i < data.length; i++) {
temp[data[i][id]] = data[i] temp[data[i][id]] = data[i];
} }
for (var k = 0; k < data.length; k++) { for (var k = 0; k < data.length; k++) {
if (!temp[data[k][pid]] || data[k][id] === data[k][pid]) { if (!temp[data[k][pid]] || data[k][id] === data[k][pid]) {
res.push(data[k]) res.push(data[k]);
continue continue;
} }
if (!temp[data[k][pid]]['children']) { if (!temp[data[k][pid]]["children"]) {
temp[data[k][pid]]['children'] = [] temp[data[k][pid]]["children"] = [];
} }
temp[data[k][pid]]['children'].push(data[k]) temp[data[k][pid]]["children"].push(data[k]);
data[k]['_level'] = (temp[data[k][pid]]._level || 0) + 1 data[k]["_level"] = (temp[data[k][pid]]._level || 0) + 1;
} }
return res return res;
} }
// 时间格式化 // 时间格式化
export function dateFormats(fmt, date) { export function dateFormats(fmt, date) {
let ret let ret;
const _date = new Date(date) const _date = new Date(date);
const opt = { const opt = {
'Y+': _date.getFullYear().toString(), // 年 "Y+": _date.getFullYear().toString(), // 年
'm+': (_date.getMonth() + 1).toString(), // 月 "m+": (_date.getMonth() + 1).toString(), // 月
'd+': _date.getDate().toString(), // 日 "d+": _date.getDate().toString(), // 日
'H+': _date.getHours().toString(), // 时 "H+": _date.getHours().toString(), // 时
'M+': _date.getMinutes().toString(), // 分 "M+": _date.getMinutes().toString(), // 分
'S+': _date.getSeconds().toString() // 秒 "S+": _date.getSeconds().toString(), // 秒
// 有其他格式化字符需求可以继续添加,必须转化成字符串 // 有其他格式化字符需求可以继续添加,必须转化成字符串
} };
for (const k in opt) { for (const k in opt) {
ret = new RegExp('(' + k + ')').exec(fmt) ret = new RegExp("(" + k + ")").exec(fmt);
if (ret) { if (ret) {
fmt = fmt.replace(ret[1], (ret[1].length === 1) ? (opt[k]) : (opt[k].padStart(ret[1].length, '0'))) fmt = fmt.replace(
ret[1],
ret[1].length === 1 ? opt[k] : opt[k].padStart(ret[1].length, "0")
);
} }
} }
return fmt return fmt;
} }
// 根据身份证计算出生日期,性别,年龄 // 根据身份证计算出生日期,性别,年龄
export function computedCard(idCard) { export function computedCard(idCard) {
@ -123,49 +129,78 @@ export function computedCard(idCard) {
let day = myDate.getDate(); let day = myDate.getDate();
let age = 0; let age = 0;
if(idCard.length===18){ if (idCard.length === 18) {
age = myDate.getFullYear() - idCard.substring(6, 10) - 1; age = myDate.getFullYear() - idCard.substring(6, 10) - 1;
sex = idCard.substring(16,17); sex = idCard.substring(16, 17);
birth = idCard.substring(6,10)+"-"+idCard.substring(10,12)+"-"+idCard.substring(12,14); birth =
if (idCard.substring(10, 12) < month || idCard.substring(10, 12) === month && idCard.substring(12, 14) <= day) age++; idCard.substring(6, 10) +
"-" +
idCard.substring(10, 12) +
"-" +
idCard.substring(12, 14);
if (
idCard.substring(10, 12) < month ||
(idCard.substring(10, 12) === month && idCard.substring(12, 14) <= day)
)
age++;
} }
if(idCard.length===15){ if (idCard.length === 15) {
age = myDate.getFullYear() - idCard.substring(6, 8) - 1901; age = myDate.getFullYear() - idCard.substring(6, 8) - 1901;
sex = idCard.substring(13,14); sex = idCard.substring(13, 14);
birth = "19"+idCard.substring(6,8)+"-"+idCard.substring(8,10)+"-"+idCard.substring(10,12); birth =
if (idCard.substring(8, 10) < month || idCard.substring(8, 10) === month && idCard.substring(10, 12) <= day) age++; "19" +
idCard.substring(6, 8) +
"-" +
idCard.substring(8, 10) +
"-" +
idCard.substring(10, 12);
if (
idCard.substring(8, 10) < month ||
(idCard.substring(8, 10) === month && idCard.substring(10, 12) <= day)
)
age++;
} }
if(sex%2 === 0) if (sex % 2 === 0)
sex = '0'; // 性别代码 1代表男,0代表女,暂时不涉及其他类型性别 sex = "0"; // 性别代码 1代表男,0代表女,暂时不涉及其他类型性别
else else sex = "1";
sex = '1'; return { age, sex, birth };
return {age , sex, birth}
} }
// 将数组分成小块数组的集合 // 将数组分成小块数组的集合
export function spliceIntoChunks(arr, chunkSize) { export function spliceIntoChunks(arr, chunkSize) {
const res = []; const res = [];
while (arr.length > 0) { while (arr.length > 0) {
const chunk = arr.splice(0, chunkSize); const chunk = arr.splice(0, chunkSize);
res.push(chunk); res.push(chunk);
} }
return res; return res;
} }
// 获取当前时间 如果有指定time则按指定的来 // 获取当前时间 如果有指定time则按指定的来
export function getCurrentDate(hour,min,sec) { export function getCurrentDate(hour, min, sec) {
console.log(hour,min,sec) console.log(hour, min, sec);
let date = new Date(); let date = new Date();
if (hour){ if (hour) {
date.setHours(hour); date.setHours(hour);
console.log(hour) console.log(hour);
}if (min!==undefined){ }
if (min !== undefined) {
date.setMinutes(min); date.setMinutes(min);
console.log(min) console.log(min);
}if (sec!==undefined){ }
if (sec !== undefined) {
date.setSeconds(sec); date.setSeconds(sec);
console.log(sec) console.log(sec);
} }
return date; return date;
} }
// 加密
export function encryptedData(key, data) {
// 新建JSEncrypt对象
let encryptor = new JSEncrypt();
// 设置公钥
encryptor.setPublicKey(key);
// 加密数据
return encryptor.encrypt(data);
}

149
src/views/main-navbar-update-password-work.vue

@ -16,13 +16,13 @@
<el-form-item :label="$t('updatePassword.username')"> <el-form-item :label="$t('updatePassword.username')">
<span>{{ $store.state.user.realName }}</span> <span>{{ $store.state.user.realName }}</span>
</el-form-item> </el-form-item>
<!-- <el-form-item prop="password" :label="$t('updatePassword.password')"> <el-form-item prop="password" :label="$t('updatePassword.password')">
<el-input <el-input
v-model="dataForm.password" v-model="dataForm.password"
type="password" type="password"
:placeholder="$t('updatePassword.password')" :placeholder="$t('updatePassword.password')"
></el-input> ></el-input>
</el-form-item> --> </el-form-item>
<el-form-item <el-form-item
prop="newPassword" prop="newPassword"
:label="$t('updatePassword.newPassword')" :label="$t('updatePassword.newPassword')"
@ -30,7 +30,7 @@
<el-input <el-input
v-model="dataForm.newPassword" v-model="dataForm.newPassword"
type="password" type="password"
:placeholder="$t('updatePassword.newPassword')" placeholder="密码必须8-20个字符,而且同时包含大小写字母和数字"
></el-input> ></el-input>
</el-form-item> </el-form-item>
<el-form-item <el-form-item
@ -45,104 +45,143 @@
</el-form-item> </el-form-item>
</el-form> </el-form>
<template slot="footer"> <template slot="footer">
<el-button @click="visible = false">{{ $t('cancel') }}</el-button> <el-button @click="visible = false">{{ $t("cancel") }}</el-button>
<el-button type="primary" @click="dataFormSubmitHandle()">{{ <el-button type="primary" @click="dataFormSubmitHandle()">{{
$t('confirm') $t("confirm")
}}</el-button> }}</el-button>
</template> </template>
</el-dialog> </el-dialog>
</template> </template>
<script> <script>
import debounce from 'lodash/debounce' import debounce from "lodash/debounce";
import { clearLoginInfo } from '@/utils' import { clearLoginInfo, encryptedData } from "@/utils";
export default { export default {
data() { data() {
return { return {
visible: false, visible: false,
pubKey: "",
dataForm: { dataForm: {
password: '', password: "",
newPassword: '', newPassword: "",
confirmPassword: '' confirmPassword: "",
} },
} };
}, },
computed: { computed: {
dataRule() { dataRule() {
var validateConfirmPassword = (rule, value, callback) => { var validateConfirmPassword = (rule, value, callback) => {
if (this.dataForm.newPassword !== value) { if (this.dataForm.newPassword !== value) {
return callback( return callback(
new Error(this.$t('updatePassword.validate.confirmPassword')) new Error(this.$t("updatePassword.validate.confirmPassword"))
) );
} }
callback() callback();
} };
return { return {
// password: [ password: [
// { {
// required: true, required: true,
// message: this.$t('validate.required'), message: this.$t("validate.required"),
// trigger: 'blur' trigger: "blur",
// } },
// ], ],
newPassword: [ newPassword: [
{ {
required: true, required: true,
message: this.$t('validate.required'), message: this.$t("validate.required"),
trigger: 'blur' trigger: "blur",
} },
], ],
confirmPassword: [ confirmPassword: [
{ {
required: true, required: true,
message: this.$t('validate.required'), message: this.$t("validate.required"),
trigger: 'blur' trigger: "blur",
}, },
{ validator: validateConfirmPassword, trigger: 'blur' } { validator: validateConfirmPassword, trigger: "blur" },
] ],
} };
} },
}, },
methods: { methods: {
init() { init() {
this.visible = true this.visible = true;
this.$nextTick(() => { this.$nextTick(() => {
this.$refs['dataForm'].resetFields() this.$refs["dataForm"].resetFields();
}) });
//
this.getPubKey();
}, },
//
getPubKey() {
this.$http
.post("/auth/govweb/getKey")
.then(({ data: res }) => {
if (res.code !== 0) {
return this.$message.error(res.msg);
}
this.pubKey = res.data; // ;
})
.catch(() => {});
},
validateComplexity(pwd) {
let regex = new RegExp("(?=.*[0-9])(?=.*[A-Z])(?=.*[a-z]).{8,20}");
if (!regex.test(pwd)) {
this.$message({
message:
"密码必须8-20个字符,而且同时包含大小写字母和数字",
type: "error",
});
return false;
}
return true;
},
// //
dataFormSubmitHandle: debounce( dataFormSubmitHandle: debounce(
function () { function () {
this.$refs['dataForm'].validate((valid) => { this.$refs["dataForm"].validate((valid) => {
if (!valid) { if (!valid) return false;
return false
} if (!this.validateComplexity(this.dataForm.newPassword)) return false;
const { pubKey } = this;
this.$http this.$http
.post('/gov/mine/mine/resetpassword', { .post("/gov/mine/mine/resetpassword", {
newPassword: this.dataForm.newPassword, oldPassword: encryptedData(pubKey, this.dataForm.password),
confirmNewPassword: this.dataForm.confirmPassword newPassword: encryptedData(pubKey, this.dataForm.newPassword),
confirmNewPassword: encryptedData(
pubKey,
this.dataForm.confirmPassword
),
}) })
.then(({ data: res }) => { .then(({ data: res }) => {
if (res.code !== 0) { if (res.code !== 0) {
return this.$message.error(res.msg) return this.$message.error(res.msg);
} }
this.$message({ this.$message({
message: this.$t('prompt.success'), message: this.$t("prompt.success"),
type: 'success', type: "success",
duration: 500, duration: 500,
onClose: () => { onClose: () => {
this.visible = false this.visible = false;
clearLoginInfo() clearLoginInfo();
this.$router.replace({ name: 'loginWork' }) this.$router.replace({ name: "login" });
} },
}) });
}) })
.catch(() => {}) .catch(() => {});
}) });
}, },
1000, 1000,
{ leading: true, trailing: false } { leading: true, trailing: false }
) ),
} },
} };
</script> </script>

148
src/views/main-shuju/main-navbar-update-password-work.vue

@ -1,148 +0,0 @@
<template>
<el-dialog
:visible.sync="visible"
:title="$t('updatePassword.title')"
:close-on-click-modal="false"
:close-on-press-escape="false"
:append-to-body="true"
>
<el-form
:model="dataForm"
:rules="dataRule"
ref="dataForm"
@keyup.enter.native="dataFormSubmitHandle()"
label-width="120px"
>
<el-form-item :label="$t('updatePassword.username')">
<span>{{ $store.state.user.realName }}</span>
</el-form-item>
<!-- <el-form-item prop="password" :label="$t('updatePassword.password')">
<el-input
v-model="dataForm.password"
type="password"
:placeholder="$t('updatePassword.password')"
></el-input>
</el-form-item> -->
<el-form-item
prop="newPassword"
:label="$t('updatePassword.newPassword')"
>
<el-input
v-model="dataForm.newPassword"
type="password"
:placeholder="$t('updatePassword.newPassword')"
></el-input>
</el-form-item>
<el-form-item
prop="confirmPassword"
:label="$t('updatePassword.confirmPassword')"
>
<el-input
v-model="dataForm.confirmPassword"
type="password"
:placeholder="$t('updatePassword.confirmPassword')"
></el-input>
</el-form-item>
</el-form>
<template slot="footer">
<el-button @click="visible = false">{{ $t('cancel') }}</el-button>
<el-button type="primary" @click="dataFormSubmitHandle()">{{
$t('confirm')
}}</el-button>
</template>
</el-dialog>
</template>
<script>
import debounce from 'lodash/debounce'
import { clearLoginInfo } from '@/utils'
export default {
data() {
return {
visible: false,
dataForm: {
password: '',
newPassword: '',
confirmPassword: ''
}
}
},
computed: {
dataRule() {
var validateConfirmPassword = (rule, value, callback) => {
if (this.dataForm.newPassword !== value) {
return callback(
new Error(this.$t('updatePassword.validate.confirmPassword'))
)
}
callback()
}
return {
// password: [
// {
// required: true,
// message: this.$t('validate.required'),
// trigger: 'blur'
// }
// ],
newPassword: [
{
required: true,
message: this.$t('validate.required'),
trigger: 'blur'
}
],
confirmPassword: [
{
required: true,
message: this.$t('validate.required'),
trigger: 'blur'
},
{ validator: validateConfirmPassword, trigger: 'blur' }
]
}
}
},
methods: {
init() {
this.visible = true
this.$nextTick(() => {
this.$refs['dataForm'].resetFields()
})
},
//
dataFormSubmitHandle: debounce(
function () {
this.$refs['dataForm'].validate((valid) => {
if (!valid) {
return false
}
this.$http
.post('/gov/mine/mine/resetpassword', {
newPassword: this.dataForm.newPassword,
confirmNewPassword: this.dataForm.confirmPassword
})
.then(({ data: res }) => {
if (res.code !== 0) {
return this.$message.error(res.msg)
}
this.$message({
message: this.$t('prompt.success'),
type: 'success',
duration: 500,
onClose: () => {
this.visible = false
clearLoginInfo()
this.$router.replace({ name: 'loginWork' })
}
})
})
.catch(() => {})
})
},
1000,
{ leading: true, trailing: false }
)
}
}
</script>

2
src/views/main-shuju/main-navbar.vue

@ -139,7 +139,7 @@
import { messages } from "@/i18n"; import { messages } from "@/i18n";
import { mapGetters } from "vuex"; import { mapGetters } from "vuex";
import screenfull from "screenfull"; import screenfull from "screenfull";
import UpdatePasswordWork from "./main-navbar-update-password-work"; import UpdatePasswordWork from "@/views/main-navbar-update-password-work";
import { clearLoginInfo } from "@/utils"; import { clearLoginInfo } from "@/utils";
export default { export default {
inject: ["refresh"], inject: ["refresh"],

52
src/views/pages/login.vue

@ -16,35 +16,35 @@
<div class="ico"> <div class="ico">
<img src="@/assets/img/login/zhanghao.png" alt="" /> <img src="@/assets/img/login/zhanghao.png" alt="" />
</div> </div>
<div class="input"> <el-form-item prop="phone" class="input">
<input <input
type="text" type="text"
v-model="dataForm.phone" v-model="dataForm.phone"
placeholder="账号" placeholder="账号"
/> />
</div> </el-form-item>
</div> </div>
<div class="fm-item"> <div class="fm-item">
<div class="ico"> <div class="ico">
<img src="@/assets/img/login/mima.png" alt="" /> <img src="@/assets/img/login/mima.png" alt="" />
</div> </div>
<div class="input"> <el-form-item prop="password" class="input">
<input <input
type="password" type="password"
v-model="dataForm.password" v-model="dataForm.password"
:placeholder="$t('login.password')" :placeholder="$t('login.password')"
/> />
</div> </el-form-item>
</div> </div>
<div class="fm-captcha"> <div class="fm-captcha">
<div class="fm-item"> <div class="fm-item">
<div class="input"> <el-form-item prop="captcha" class="input">
<input <input
type="text" type="text"
v-model="dataForm.captcha" v-model="dataForm.captcha"
placeholder="验证码" placeholder="验证码"
/> />
</div> </el-form-item>
</div> </div>
<div class="captcha"> <div class="captcha">
<img :src="captchaPath" @click="getCaptcha()" /> <img :src="captchaPath" @click="getCaptcha()" />
@ -95,9 +95,8 @@ import Cookies from "js-cookie";
import CDialog from "@c/CDialog"; import CDialog from "@c/CDialog";
import debounce from "lodash/debounce"; import debounce from "lodash/debounce";
import { messages } from "@/i18n"; import { messages } from "@/i18n";
import { getUUID } from "@/utils"; import { getUUID, encryptedData } from "@/utils";
import { Loading } from "element-ui"; // Loading import { Loading } from "element-ui"; // Loading
import JSEncrypt from "jsencrypt"; //
let loading; // let loading; //
export default { export default {
@ -176,35 +175,16 @@ export default {
// //
dataFormSubmitHandle() { dataFormSubmitHandle() {
this.$refs["dataForm"].validate((valid, messageObj) => { this.$refs["dataForm"].validate((valid, messageObj) => {
console.log(valid, messageObj);
if (!valid) { if (!valid) {
app.util.validateRule(messageObj); app.util.validateRule(messageObj);
return;
} }
this.startLoading(); this.startLoading();
// const url = 'https://nei.netease.com/api/apimock-v2/e3b1d0eb88e905f6c7ee559b2d6bb7ad/epmetuser/customerstaff/customerlist'
const url = "/epmetuser/customerstaff/customerlist"; const url = "/epmetuser/customerstaff/customerlist";
const params = { const params = {
phone: this.dataForm.phone, phone: encryptedData(this.pubKey, this.dataForm.phone),
}; };
// this.$http
// .post(url, params).then(({ data })=> {
// console.log('res--comll', data)
// if (data.data.length === 0) {
// //
// this.$message.error('')
// this.endLoading()
// } else if (data.data.length === 1) {
// this.selectCustomer(data.data[0])
// } else {
// this.endLoading()
// this.diaVisible = true
// this.$nextTick(() => {
// this.tableData = data.data
// })
// }
// }).catch((err) => {
// this.endLoading()
// this.$message.error(err)
// })
window.app.ajax.post( window.app.ajax.post(
url, url,
params, params,
@ -262,7 +242,8 @@ export default {
this.dataForm.customerId = row.customerId; this.dataForm.customerId = row.customerId;
let param = {}; let param = {};
Object.assign(param, this.dataForm); Object.assign(param, this.dataForm);
param.password = this.encryptedData(this.pubKey, this.dataForm.password); param.phone = encryptedData(this.pubKey, this.dataForm.phone);
param.password = encryptedData(this.pubKey, this.dataForm.password);
this.$http this.$http
.post(url, param) .post(url, param)
.then(({ data: res }) => { .then(({ data: res }) => {
@ -301,15 +282,6 @@ export default {
loading.close(); loading.close();
} }
}, },
//
encryptedData(key, data) {
// JSEncrypt
let encryptor = new JSEncrypt();
//
encryptor.setPublicKey(key);
//
return encryptor.encrypt(data);
},
}, },
}; };
</script> </script>

Loading…
Cancel
Save