2 Commits c73af2ec64 ... b3a7fa5e2a

Auteur SHA1 Bericht Datum
  blade b3a7fa5e2a Merge branch 'master' of http://git.bocai108.com:10180/aqm/Customer-Service-Web 6 jaren geleden
  blade ef24a3b67f update 6 jaren geleden
5 gewijzigde bestanden met toevoegingen van 49 en 41 verwijderingen
  1. 1 1
      service/config/index.js
  2. 2 5
      service/src/api/ports.js
  3. 25 0
      service/src/assets/common.js
  4. 3 0
      service/src/main.js
  5. 18 35
      service/src/pages/login.vue

+ 1 - 1
service/config/index.js

@@ -9,7 +9,7 @@ module.exports = {
 
     // Paths
     assetsSubDirectory: 'static',
-    assetsPublicPath: '/',
+    assetsPublicPath: './',
     // proxyTable: {
     //   '/api': {
     //     target: 'http://103.108.43.176:8080', // 后台访问地址 http://kfadmin.bocai186.com

+ 2 - 5
service/src/api/ports.js

@@ -11,6 +11,7 @@ export default {
 
     
   },
+
   // 历史会话
   SessionHistory:{
     historyList:'/service/history/historyList',//历史会话列表
@@ -37,7 +38,6 @@ export default {
   history:{
     historyList:'/service/history/historyList',
     historyInfo:"/service/history/historyInfo",
-    userHistory: "/service/history/userHistory"
   },
 
   //留言 
@@ -57,9 +57,6 @@ export default {
     allConversation:"/service/history/allConversation",
     chatByTime:'/service/history/chatByTime',
   },
-  // 验证码权限
-  securityCode: {
-    getconfigs: '/index/index/getconfigs'
-  }
+  checkValidCodeEnabledUrl:"/index/index/getConfigs"
 
 }

+ 25 - 0
service/src/assets/common.js

@@ -0,0 +1,25 @@
+import md5 from 'js-md5';
+import http from '../api/http';
+import ports from '../api/ports.js';
+export default{
+    //检测验证码是否开启
+    checkValidCodeEnabled(){
+        let params={
+            headers: {
+                apiToken:this.getApiToken('index','index','getConfigs')
+            }
+        };
+        this.checkEnabled=false;
+        http.get(ports.checkValidCodeEnabledUrl,params).then(res => {
+            // console.log(res);
+            if (res.data.code == 1) {
+                //私有库
+                this.checkEnabled = res.data.data.checkcodeflag; // res.data.data.sysWords
+            }
+        });
+        return this.checkEnabled;
+    },
+    getApiToken(m,c,act){
+       return md5(act+'customer-service'+c+m);
+    }
+}

+ 3 - 0
service/src/main.js

@@ -13,6 +13,7 @@ import axios from 'axios'; //引入axios
 import ports from './api/ports.js'; //api接口文档
 import publicMethods from '../static/publicMethods.js';
 import md5 from 'js-md5';
+import comm from './assets/common.js';
 Vue.use(ElementUI);
 
 Vue.config.productionTip = false;
@@ -20,10 +21,12 @@ Vue.config.productionTip = false;
 Vue.prototype.$frce = frce.frce;
 // 注册加密文档
 Vue.prototype.$md5 = md5;
+
 // 公共方法
 Vue.prototype.$ports = ports;
 Vue.prototype.$http = http;
 Vue.prototype.$public = publicMethods;
+Vue.prototype.$comm=comm;
 /* eslint-disable no-new */
 new Vue({
   el: '#app',

+ 18 - 35
service/src/pages/login.vue

@@ -24,7 +24,7 @@
 							<p v-if="0" style="color:#f60;font-size:14px;margin-top:5px;margin-left:3px;">密码错误,请重新输入</p>
 						</div>
 					</div>
-					<div class="box row center" v-if="needCode && showSecurityCode">
+					<div class="box row center" v-if="showSecurityCode">
 						<div class="boxData" :class="0?'errBd':''">
 							<input maxlength="6" @keyup.enter="loginBtn()" @blur="testCode()" type="text" v-model="securityCode" placeholder="验证码">
 							<img src="@/assets/img/password.png">
@@ -54,7 +54,6 @@
 				time:'',
 				loading:false,
 				showSecurityCode:false,
-				needCode: 1, // 是否需要验证码验证
 				logo: '',
 				verifySystem:"",
 				verifySystemId:"",
@@ -64,12 +63,10 @@
 		},
 		methods:{
 			testCode(){
-				if(this.needCode) {
-					if(this.showSecurityCode){
-						if (!(/^[0-9]+$/.test(this.securityCode))) {
-							this.$message.error('验证码错误!')
-							this.securityCode = '';
-						}
+				if(this.showSecurityCode){
+					if (!(/^[0-9]+$/.test(this.securityCode))) {
+						this.$message.error('验证码错误!')
+						this.securityCode = '';
 					}
 				}
 			},
@@ -90,7 +87,7 @@
 						// console.log(this.verifySystem)
 						// console.log(this.securityCode)
 						let parmas;
-						if(this.needCode && this.showSecurityCode){
+						if(this.showSecurityCode){
 							 parmas = {
 								username:this.account,
 								password:this.password,
@@ -100,11 +97,12 @@
 							parmas = {
 								username:this.account,
 								password:this.password,
-								verifySystemId:this.verifySystemId ? this.verifySystemId : '',
-								verifySystem:this.verifySystem ? this.verifySystem : '',
+								verifySystemId:this.verifySystemId,
+								verifySystem:this.verifySystem,
 							}
 						}
 						this.$http.post(this.$ports.login, parmas).then((res)=>{
+
 							if(res.data.code == 1){
 								this.$store.dispatch("SET_USER",res.data.data.user);
 								this.$store.dispatch("SET_IS_INIT",true);
@@ -159,33 +157,12 @@
 				this.$websocket.onopen();
 				//console.log('已经链接')
 			},
-			getSecurityCode() { // 获取登录是否需要验证码
-				let obj = {
-					headers: {
-						// 公共接口只需要传apitoken
-						apiToken: this.$md5('getconfigs' + "customer-service" + 'index' + 'index'),
-					}
-				}
-				this.$http.get(this.$ports.securityCode.getconfigs, obj).then(res => {
-					if(res.data.code == 1) {
-						this.needCode = res.data.data.checkcodeflag
-					}
-					else {
-						this.$message.error(err.message)
-					}
-				})
-				.catch(err => {
-					this.$message.error(err.message)
-				})
-			}
-		},
-		created() {
-			this.getSecurityCode();
 		},
 		mounted(){
 			// 判断验证码参数
 			let SystemId = this.$public.getQueryString("id");
 			let System = this.$public.getQueryString("code");
+			
 			if( !SystemId && !System ){
 				this.showSecurityCode = true;
 			}else {
@@ -195,6 +172,12 @@
 				localStorage.clear();
 				sessionStorage.clear();
 			}
+			this.checkEnabled=this.$comm.checkValidCodeEnabled();
+			if(this.checkEnabled==0){
+				this.showSecurityCode = false;
+			
+			}
+
 			this.$http.get(this.$ports.TIME).then(res => {
 				if (res.data.code == 1) {
 					let time = res.data.data.time.split(' ');
@@ -204,11 +187,11 @@
 					sessionStorage.setItem("logo",res.data.data.logo);
 					
 				}
-			})
+			});
 			// this.logo = sessionStorage.getItem('logo');
 			//console.log(this.logo, '========logo')
 		}
-	}
+	};
 </script>
 
 <style scoped>