From 6a13b335efb39e4a736f9141843c3f74115797da Mon Sep 17 00:00:00 2001 From: dai <851733175@qq.com> Date: Tue, 27 Sep 2022 10:24:37 +0800 Subject: [PATCH 1/2] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E5=AF=86=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/utils/index.js | 173 +++++++++++------- .../main-navbar-update-password-work.vue | 149 +++++++++------ .../main-navbar-update-password-work.vue | 148 --------------- src/views/main-shuju/main-navbar.vue | 2 +- src/views/pages/login.vue | 14 +- 5 files changed, 201 insertions(+), 285 deletions(-) delete mode 100644 src/views/main-shuju/main-navbar-update-password-work.vue diff --git a/src/utils/index.js b/src/utils/index.js index 8cd1c35cb..9567f50d6 100644 --- a/src/utils/index.js +++ b/src/utils/index.js @@ -1,17 +1,18 @@ -import store from '@/js/store' +import store from "@/js/store"; +import JSEncrypt from "jsencrypt"; //引入加密 /** * 获取字典数据列表 * @param dictType 字典类型 */ export function getDictDataList(dictType) { - const type = window.SITE_CONFIG['dictList'].find( + const type = window.SITE_CONFIG["dictList"].find( (element) => element.dictType === dictType - ) + ); if (type) { - return type.dataList + return type.dataList; } else { - return [] + return []; } } @@ -21,20 +22,20 @@ export function getDictDataList(dictType) { * @param dictValue 字典值 */ export function getDictLabel(dictType, dictValue) { - const type = window.SITE_CONFIG['dictList'].find( + const type = window.SITE_CONFIG["dictList"].find( (element) => element.dictType === dictType - ) + ); if (type) { const val = type.dataList.find( (element) => element.dictValue === dictValue.toString() - ) + ); if (val) { - return val.dictLabel + return val.dictLabel; } else { - return dictValue + return dictValue; } } else { - return dictValue + return dictValue; } } @@ -42,29 +43,31 @@ export function getDictLabel(dictType, dictValue) { * 清除登录信息 */ export function clearLoginInfo() { - store.commit('resetStore') - localStorage.removeItem('token') - window.SITE_CONFIG['dynamicMenuRoutesHasAdded'] = false + store.commit("resetStore"); + localStorage.removeItem("token"); + window.SITE_CONFIG["dynamicMenuRoutesHasAdded"] = false; } /** * 获取uuid */ export function getUUID() { - return 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g, (c) => { - return (c === 'x' ? (Math.random() * 16) | 0 : 'r&0x3' | '0x8').toString(16) - }) + return "xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g, (c) => { + return (c === "x" ? (Math.random() * 16) | 0 : "r&0x3" | "0x8").toString( + 16 + ); + }); } /** * 获取svg图标(id)列表 */ export function getIconList() { - var res = [] - document.querySelectorAll('svg symbol').forEach((item) => { - res.push(item.id) - }) - return res + var res = []; + document.querySelectorAll("svg symbol").forEach((item) => { + res.push(item.id); + }); + return res; } /** @@ -73,46 +76,49 @@ export function getIconList() { * @param {*} id * @param {*} pid */ -export function treeDataTranslate(data, id = 'id', pid = 'pid') { - var res = [] - var temp = {} +export function treeDataTranslate(data, id = "id", pid = "pid") { + var res = []; + var temp = {}; 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++) { if (!temp[data[k][pid]] || data[k][id] === data[k][pid]) { - res.push(data[k]) - continue + res.push(data[k]); + continue; } - if (!temp[data[k][pid]]['children']) { - temp[data[k][pid]]['children'] = [] + if (!temp[data[k][pid]]["children"]) { + temp[data[k][pid]]["children"] = []; } - temp[data[k][pid]]['children'].push(data[k]) - data[k]['_level'] = (temp[data[k][pid]]._level || 0) + 1 + temp[data[k][pid]]["children"].push(data[k]); + data[k]["_level"] = (temp[data[k][pid]]._level || 0) + 1; } - return res + return res; } // 时间格式化 export function dateFormats(fmt, date) { - let ret - const _date = new Date(date) + let ret; + const _date = new Date(date); const opt = { - 'Y+': _date.getFullYear().toString(), // 年 - 'm+': (_date.getMonth() + 1).toString(), // 月 - 'd+': _date.getDate().toString(), // 日 - 'H+': _date.getHours().toString(), // 时 - 'M+': _date.getMinutes().toString(), // 分 - 'S+': _date.getSeconds().toString() // 秒 + "Y+": _date.getFullYear().toString(), // 年 + "m+": (_date.getMonth() + 1).toString(), // 月 + "d+": _date.getDate().toString(), // 日 + "H+": _date.getHours().toString(), // 时 + "M+": _date.getMinutes().toString(), // 分 + "S+": _date.getSeconds().toString(), // 秒 // 有其他格式化字符需求可以继续添加,必须转化成字符串 - } + }; for (const k in opt) { - ret = new RegExp('(' + k + ')').exec(fmt) + ret = new RegExp("(" + k + ")").exec(fmt); 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) { @@ -123,49 +129,78 @@ export function computedCard(idCard) { let day = myDate.getDate(); let age = 0; - if(idCard.length===18){ + if (idCard.length === 18) { age = myDate.getFullYear() - idCard.substring(6, 10) - 1; - sex = idCard.substring(16,17); - birth = 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++; - + sex = idCard.substring(16, 17); + birth = + 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; - sex = idCard.substring(13,14); - birth = "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++; + sex = idCard.substring(13, 14); + birth = + "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) - sex = '0'; // 性别代码 1代表男,0代表女,暂时不涉及其他类型性别 - else - sex = '1'; - return {age , sex, birth} + if (sex % 2 === 0) + sex = "0"; // 性别代码 1代表男,0代表女,暂时不涉及其他类型性别 + else sex = "1"; + return { age, sex, birth }; } // 将数组分成小块数组的集合 export function spliceIntoChunks(arr, chunkSize) { const res = []; while (arr.length > 0) { - const chunk = arr.splice(0, chunkSize); - res.push(chunk); + const chunk = arr.splice(0, chunkSize); + res.push(chunk); } return res; } + // 获取当前时间 如果有指定time则按指定的来 -export function getCurrentDate(hour,min,sec) { - console.log(hour,min,sec) +export function getCurrentDate(hour, min, sec) { + console.log(hour, min, sec); let date = new Date(); - if (hour){ + if (hour) { date.setHours(hour); - console.log(hour) - }if (min!==undefined){ + console.log(hour); + } + if (min !== undefined) { date.setMinutes(min); - console.log(min) - }if (sec!==undefined){ + console.log(min); + } + if (sec !== undefined) { date.setSeconds(sec); - console.log(sec) + console.log(sec); } return date; } +// 加密 +export function encryptedData(key, data) { + // 新建JSEncrypt对象 + let encryptor = new JSEncrypt(); + // 设置公钥 + encryptor.setPublicKey(key); + // 加密数据 + return encryptor.encrypt(data); +} diff --git a/src/views/main-navbar-update-password-work.vue b/src/views/main-navbar-update-password-work.vue index c29715ba6..e90d92ab7 100644 --- a/src/views/main-navbar-update-password-work.vue +++ b/src/views/main-navbar-update-password-work.vue @@ -16,13 +16,13 @@ {{ $store.state.user.realName }} - + diff --git a/src/views/main-shuju/main-navbar-update-password-work.vue b/src/views/main-shuju/main-navbar-update-password-work.vue deleted file mode 100644 index c29715ba6..000000000 --- a/src/views/main-shuju/main-navbar-update-password-work.vue +++ /dev/null @@ -1,148 +0,0 @@ - - - diff --git a/src/views/main-shuju/main-navbar.vue b/src/views/main-shuju/main-navbar.vue index e0715272f..2672b6952 100644 --- a/src/views/main-shuju/main-navbar.vue +++ b/src/views/main-shuju/main-navbar.vue @@ -139,7 +139,7 @@ import { messages } from "@/i18n"; import { mapGetters } from "vuex"; 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"; export default { inject: ["refresh"], diff --git a/src/views/pages/login.vue b/src/views/pages/login.vue index 10cf96a93..9a86fa5b5 100644 --- a/src/views/pages/login.vue +++ b/src/views/pages/login.vue @@ -95,9 +95,8 @@ import Cookies from "js-cookie"; import CDialog from "@c/CDialog"; import debounce from "lodash/debounce"; import { messages } from "@/i18n"; -import { getUUID } from "@/utils"; +import { getUUID, encryptedData } from "@/utils"; import { Loading } from "element-ui"; // 引入Loading服务 -import JSEncrypt from "jsencrypt"; //引入加密 let loading; // 加载动画 export default { @@ -262,7 +261,7 @@ export default { this.dataForm.customerId = row.customerId; let param = {}; Object.assign(param, this.dataForm); - param.password = this.encryptedData(this.pubKey, this.dataForm.password); + param.password = encryptedData(this.pubKey, this.dataForm.password); this.$http .post(url, param) .then(({ data: res }) => { @@ -301,15 +300,6 @@ export default { loading.close(); } }, - // 加密 - encryptedData(key, data) { - // 新建JSEncrypt对象 - let encryptor = new JSEncrypt(); - // 设置公钥 - encryptor.setPublicKey(key); - // 加密数据 - return encryptor.encrypt(data); - }, }, }; From 762efafd8d7b93794f34e684c7381514b6dfbcb4 Mon Sep 17 00:00:00 2001 From: dai <851733175@qq.com> Date: Tue, 27 Sep 2022 14:46:16 +0800 Subject: [PATCH 2/2] =?UTF-8?q?=E9=AB=98=E5=8D=B1=E6=BC=8F=E6=B4=9E?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/assets/scss/pages/loginWork.scss | 1 + src/views/pages/login.vue | 38 ++++++++-------------------- 2 files changed, 11 insertions(+), 28 deletions(-) diff --git a/src/assets/scss/pages/loginWork.scss b/src/assets/scss/pages/loginWork.scss index 534cccba9..7f5689f2f 100644 --- a/src/assets/scss/pages/loginWork.scss +++ b/src/assets/scss/pages/loginWork.scss @@ -64,6 +64,7 @@ .input { width: 85%; + margin-bottom: 0; input { display: block; diff --git a/src/views/pages/login.vue b/src/views/pages/login.vue index 9a86fa5b5..8e39a89e2 100644 --- a/src/views/pages/login.vue +++ b/src/views/pages/login.vue @@ -16,35 +16,35 @@
-
+ -
+
-
+ -
+
-
+ -
+
@@ -175,35 +175,16 @@ export default { // 表单提交 dataFormSubmitHandle() { this.$refs["dataForm"].validate((valid, messageObj) => { + console.log(valid, messageObj); if (!valid) { app.util.validateRule(messageObj); + return; } this.startLoading(); - // const url = 'https://nei.netease.com/api/apimock-v2/e3b1d0eb88e905f6c7ee559b2d6bb7ad/epmetuser/customerstaff/customerlist' const url = "/epmetuser/customerstaff/customerlist"; 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( url, params, @@ -261,6 +242,7 @@ export default { this.dataForm.customerId = row.customerId; let param = {}; Object.assign(param, this.dataForm); + param.phone = encryptedData(this.pubKey, this.dataForm.phone); param.password = encryptedData(this.pubKey, this.dataForm.password); this.$http .post(url, param)