diff --git a/api/commonRequest.js b/api/commonRequest.js new file mode 100644 index 0000000..e945a67 --- /dev/null +++ b/api/commonRequest.js @@ -0,0 +1,23 @@ +const aqEnnable = true;// 参数加密开关 +const commonUrl = "http://10.40.92.33:18080/zhgd/"; +/* 登录相关 */ +const login_url = commonUrl + "auth/login"; // 登录url +const login_out = commonUrl + "auth/logout"; // 登出url +const login_page = "http://127.0.0.1:8100/login.html" // 登录页面 + +// ajax 请求封装 +function ajaxRequest(url, type, data, async, beforeFn, successFn, errorFn, contentType) { + $.ajax({ + url: url, + type: type, + headers: { + "authorization": localStorage.getItem("zhgd_token") + }, + data: data, + async: async, + beforeSend: beforeFn, + contentType: contentType || "application/x-www-form-urlencoded; charset=utf-8", + success: successFn, + error: errorFn + }); +} \ No newline at end of file diff --git a/css/login.css b/css/login.css new file mode 100644 index 0000000..0580d7e --- /dev/null +++ b/css/login.css @@ -0,0 +1,90 @@ +html, +body { + width: 100%; + height: 100%; + margin: 0; + padding: 0; + color: #fff; + font-family: 'Alibaba PuHuiTi R'; + letter-spacing: 1px; + font-size: 16px; +} + +html { + background: url("../img/login_back.png") no-repeat 0 0 / 100% 100%; + background-position: center center !important; +} + +#content { + width: 34%; + height: 48%; + position: relative; + left: 33%; + top: 27%; + flex-direction: column; +} + +.layout { + display: flex; + align-items: center; + justify-content: center; +} + +#pro-title { + width: 100%; + height: 55px; + font-size: 28px; +} + +#login-form { + width: 60%; + height: calc(100% - 55px); +} + +.layui-form-item input { + background-color: transparent; + color: #fff; + height: 40px; + border-color: #2EA699; +} + +.layui-form-item img { + width: 20px; + height: 20px; +} + +.layui-form-item .layui-btn { + font-size: 16px; + letter-spacing: 1px; +} + +.layui-layer-dialog .layui-layer-content { + color: #000; +} + +.layui-input-affix .layui-icon { + color: #fff; +} + +.layui-input-affix .layui-icon:hover { + color: #fff; +} + +input::-webkit-input-placeholder { + color: rgb(153, 152, 152) !important; +} + +input::-moz-placeholder { + /* Mozilla Firefox 19+ */ + color: rgb(191, 191, 191) !important; +} + +input:-moz-placeholder { + /* Mozilla Firefox 4 to 18 */ + color: rgb(191, 191, 191) !important; +} + +input:-ms-input-placeholder { + /* Internet Explorer 10-11 */ + color: rgb(191, 191, 191) !important; +} \ No newline at end of file diff --git a/img/code.png b/img/code.png new file mode 100644 index 0000000..de2fd71 Binary files /dev/null and b/img/code.png differ diff --git a/img/login_back.png b/img/login_back.png new file mode 100644 index 0000000..27348cf Binary files /dev/null and b/img/login_back.png differ diff --git a/img/pwd.png b/img/pwd.png new file mode 100644 index 0000000..7c04bb6 Binary files /dev/null and b/img/pwd.png differ diff --git a/img/un.png b/img/un.png new file mode 100644 index 0000000..2f96c9d Binary files /dev/null and b/img/un.png differ diff --git a/js/login/login.js b/js/login/login.js new file mode 100644 index 0000000..ee2a47b --- /dev/null +++ b/js/login/login.js @@ -0,0 +1,29 @@ +let form, layer; +layui.use(function () { + form = layui.form; + layer = layui.layer; + form.on('submit(demo-login)', function (data) { + let field = data.field; + const params = { + "username": field.username, + "password": field.password, + "loginType": "2" + } + let encryptStr = encryptCBC(JSON.stringify(params)); + ajaxRequest(login_url, "POST", encryptStr, true, function () { + }, function (result) { + console.log(result); + if (result.code === 200) { + top.layer.msg(result.msg, { icon: 1, time: 1000 }, function () { + localStorage.setItem("zhgd_token", result.data.access_token); + localStorage.setItem("zhgd_us", result.data.us); + window.location.href = "pages/home/navigation.html"; + }); + } else if (result.code === 500) { + layer.msg(result.msg, { icon: 2 }); + } + }, function (xhr) { + error(xhr) + }, "application/json"); + }); +}); \ No newline at end of file diff --git a/js/publics/aescbc.js b/js/publics/aescbc.js new file mode 100644 index 0000000..219f4dc --- /dev/null +++ b/js/publics/aescbc.js @@ -0,0 +1,71 @@ +!function(t,n){"object"==typeof exports?module.exports=exports=n():"function"==typeof define&&define.amd?define([],n):t.CryptoJS=n()}(this,function(){var t=t||function(t,n){var i=Object.create||function(){function t(){}return function(n){var i;return t.prototype=n,i=new t,t.prototype=null,i}}(),e={},r=e.lib={},o=r.Base=function(){return{extend:function(t){var n=i(this);return t&&n.mixIn(t),n.hasOwnProperty("init")&&this.init!==n.init||(n.init=function(){n.$super.init.apply(this,arguments)}),n.init.prototype=n,n.$super=this,n},create:function(){var t=this.extend();return t.init.apply(t,arguments),t},init:function(){},mixIn:function(t){for(var n in t)t.hasOwnProperty(n)&&(this[n]=t[n]);t.hasOwnProperty("toString")&&(this.toString=t.toString)},clone:function(){return this.init.prototype.extend(this)}}}(),s=r.WordArray=o.extend({init:function(t,i){t=this.words=t||[],i!=n?this.sigBytes=i:this.sigBytes=4*t.length},toString:function(t){return(t||c).stringify(this)},concat:function(t){var n=this.words,i=t.words,e=this.sigBytes,r=t.sigBytes;if(this.clamp(),e%4)for(var o=0;o>>2]>>>24-o%4*8&255;n[e+o>>>2]|=s<<24-(e+o)%4*8}else for(var o=0;o>>2]=i[o>>>2];return this.sigBytes+=r,this},clamp:function(){var n=this.words,i=this.sigBytes;n[i>>>2]&=4294967295<<32-i%4*8,n.length=t.ceil(i/4)},clone:function(){var t=o.clone.call(this);return t.words=this.words.slice(0),t},random:function(n){for(var i,e=[],r=function(n){var n=n,i=987654321,e=4294967295;return function(){i=36969*(65535&i)+(i>>16)&e,n=18e3*(65535&n)+(n>>16)&e;var r=(i<<16)+n&e;return r/=4294967296,r+=.5,r*(t.random()>.5?1:-1)}},o=0;o>>2]>>>24-r%4*8&255;e.push((o>>>4).toString(16)),e.push((15&o).toString(16))}return e.join("")},parse:function(t){for(var n=t.length,i=[],e=0;e>>3]|=parseInt(t.substr(e,2),16)<<24-e%8*4;return new s.init(i,n/2)}},u=a.Latin1={stringify:function(t){for(var n=t.words,i=t.sigBytes,e=[],r=0;r>>2]>>>24-r%4*8&255;e.push(String.fromCharCode(o))}return e.join("")},parse:function(t){for(var n=t.length,i=[],e=0;e>>2]|=(255&t.charCodeAt(e))<<24-e%4*8;return new s.init(i,n)}},f=a.Utf8={stringify:function(t){try{return decodeURIComponent(escape(u.stringify(t)))}catch(t){throw new Error("Malformed UTF-8 data")}},parse:function(t){return u.parse(unescape(encodeURIComponent(t)))}},h=r.BufferedBlockAlgorithm=o.extend({reset:function(){this._data=new s.init,this._nDataBytes=0},_append:function(t){"string"==typeof t&&(t=f.parse(t)),this._data.concat(t),this._nDataBytes+=t.sigBytes},_process:function(n){var i=this._data,e=i.words,r=i.sigBytes,o=this.blockSize,a=4*o,c=r/a;c=n?t.ceil(c):t.max((0|c)-this._minBufferSize,0);var u=c*o,f=t.min(4*u,r);if(u){for(var h=0;h>>6-o%4*2;n[i>>>2]|=(f|c)<<24-i%4*8,i++}return a.create(n,i)}var t=r,n=t.lib,a=n.WordArray,i=t.enc;i.Base64={stringify:function(r){var e=r.words,t=r.sigBytes,n=this._map;r.clamp();for(var a=[],i=0;i>>2]>>>24-i%4*8&255,f=e[i+1>>>2]>>>24-(i+1)%4*8&255,c=e[i+2>>>2]>>>24-(i+2)%4*8&255,s=o<<16|f<<8|c,h=0;h<4&&i+.75*h>>6*(3-h)&63));var p=n.charAt(64);if(p)for(;a.length%4;)a.push(p);return a.join("")},parse:function(r){var t=r.length,n=this._map,a=this._reverseMap;if(!a){a=this._reverseMap=[];for(var i=0;i>>2];e.sigBytes-=t}},y=(i.BlockCipher=d.extend({cfg:d.cfg.extend({mode:l,padding:v}),reset:function(){d.reset.call(this);var e=this.cfg,t=e.iv,r=e.mode;if(this._xformMode==this._ENC_XFORM_MODE)var i=r.createEncryptor;else{var i=r.createDecryptor;this._minBufferSize=1}this._mode&&this._mode.__creator==i?this._mode.init(this,t&&t.words):(this._mode=i.call(r,this,t&&t.words),this._mode.__creator=i)},_doProcessBlock:function(e,t){this._mode.processBlock(e,t)},_doFinalize:function(){var e=this.cfg.padding;if(this._xformMode==this._ENC_XFORM_MODE){e.pad(this._data,this.blockSize);var t=this._process(!0)}else{var t=this._process(!0);e.unpad(t)}return t},blockSize:4}),i.CipherParams=n.extend({init:function(e){this.mixIn(e)},toString:function(e){return(e||this.formatter).stringify(this)}})),m=r.format={},k=m.OpenSSL={stringify:function(e){var t=e.ciphertext,r=e.salt;if(r)var i=c.create([1398893684,1701076831]).concat(r).concat(t);else var i=t;return i.toString(a)},parse:function(e){var t=a.parse(e),r=t.words;if(1398893684==r[0]&&1701076831==r[1]){var i=c.create(r.slice(2,4));r.splice(0,4),t.sigBytes-=16}return y.create({ciphertext:t,salt:i})}},x=i.SerializableCipher=n.extend({cfg:n.extend({format:k}),encrypt:function(e,t,r,i){i=this.cfg.extend(i);var n=e.createEncryptor(r,i),c=n.finalize(t),o=n.cfg;return y.create({ciphertext:c,key:r,iv:o.iv,algorithm:e,mode:o.mode,padding:o.padding,blockSize:e.blockSize,formatter:i.format})},decrypt:function(e,t,r,i){i=this.cfg.extend(i),t=this._parse(t,i.format);var n=e.createDecryptor(r,i).finalize(t.ciphertext);return n},_parse:function(e,t){return"string"==typeof e?t.parse(e,this):e}}),g=r.kdf={},S=g.OpenSSL={execute:function(e,t,r,i){i||(i=c.random(8));var n=p.create({keySize:t+r}).compute(e,i),o=c.create(n.words.slice(t),4*r);return n.sigBytes=4*t,y.create({key:n,iv:o,salt:i})}},B=i.PasswordBasedCipher=x.extend({cfg:x.cfg.extend({kdf:S}),encrypt:function(e,t,r,i){i=this.cfg.extend(i);var n=i.kdf.execute(r,e.keySize,e.ivSize);i.iv=n.iv;var c=x.encrypt.call(this,e,t,n.key,i);return c.mixIn(n),c},decrypt:function(e,t,r,i){i=this.cfg.extend(i),t=this._parse(t,i.format);var n=i.kdf.execute(r,e.keySize,e.ivSize,t.salt);i.iv=n.iv;var c=x.decrypt.call(this,e,t,n.key,i);return c}})}()}); +//# sourceMappingURL=cipher-core.min.js.map +!function(e,i){"object"==typeof exports?module.exports=exports=i(require("./core.min")):"function"==typeof define&&define.amd?define(["./core.min"],i):i(e.CryptoJS)}(this,function(e){!function(){var i=e,t=i.lib,n=t.Base,s=i.enc,r=s.Utf8,o=i.algo;o.HMAC=n.extend({init:function(e,i){e=this._hasher=new e.init,"string"==typeof i&&(i=r.parse(i));var t=e.blockSize,n=4*t;i.sigBytes>n&&(i=e.finalize(i)),i.clamp();for(var s=this._oKey=i.clone(),o=this._iKey=i.clone(),a=s.words,f=o.words,c=0;c>>8^255&o^99,t[i]=o,c[o]=i;var p=e[i],l=e[p],_=e[l],k=257*e[o]^16843008*o;s[i]=k<<24|k>>>8,f[i]=k<<16|k>>>16,a[i]=k<<8|k>>>24,d[i]=k;var k=16843009*_^65537*l^257*p^16843008*i;u[o]=k<<24|k>>>8,v[o]=k<<16|k>>>16,h[o]=k<<8|k>>>24,y[o]=k,i?(i=p^e[e[e[_^p]]],n^=e[e[n]]):i=n=1}}();var p=[0,1,2,4,8,16,32,64,128,27,54],l=o.AES=n.extend({_doReset:function(){if(!this._nRounds||this._keyPriorReset!==this._key){for(var e=this._keyPriorReset=this._key,r=e.words,i=e.sigBytes/4,n=this._nRounds=i+6,o=4*(n+1),c=this._keySchedule=[],s=0;s6&&s%i==4&&(f=t[f>>>24]<<24|t[f>>>16&255]<<16|t[f>>>8&255]<<8|t[255&f]):(f=f<<8|f>>>24,f=t[f>>>24]<<24|t[f>>>16&255]<<16|t[f>>>8&255]<<8|t[255&f],f^=p[s/i|0]<<24),c[s]=c[s-i]^f}for(var a=this._invKeySchedule=[],d=0;d>>24]]^v[t[f>>>16&255]]^h[t[f>>>8&255]]^y[t[255&f]]}}},encryptBlock:function(e,r){this._doCryptBlock(e,r,this._keySchedule,s,f,a,d,t)},decryptBlock:function(e,r){var i=e[r+1];e[r+1]=e[r+3],e[r+3]=i,this._doCryptBlock(e,r,this._invKeySchedule,u,v,h,y,c);var i=e[r+1];e[r+1]=e[r+3],e[r+3]=i},_doCryptBlock:function(e,r,i,n,o,t,c,s){for(var f=this._nRounds,a=e[r]^i[0],d=e[r+1]^i[1],u=e[r+2]^i[2],v=e[r+3]^i[3],h=4,y=1;y>>24]^o[d>>>16&255]^t[u>>>8&255]^c[255&v]^i[h++],l=n[d>>>24]^o[u>>>16&255]^t[v>>>8&255]^c[255&a]^i[h++],_=n[u>>>24]^o[v>>>16&255]^t[a>>>8&255]^c[255&d]^i[h++],k=n[v>>>24]^o[a>>>16&255]^t[d>>>8&255]^c[255&u]^i[h++];a=p,d=l,u=_,v=k}var p=(s[a>>>24]<<24|s[d>>>16&255]<<16|s[u>>>8&255]<<8|s[255&v])^i[h++],l=(s[d>>>24]<<24|s[u>>>16&255]<<16|s[v>>>8&255]<<8|s[255&a])^i[h++],_=(s[u>>>24]<<24|s[v>>>16&255]<<16|s[a>>>8&255]<<8|s[255&d])^i[h++],k=(s[v>>>24]<<24|s[a>>>16&255]<<16|s[d>>>8&255]<<8|s[255&u])^i[h++];e[r]=p,e[r+1]=l,e[r+2]=_,e[r+3]=k},keySize:8});r.AES=n._createHelper(l)}(),e.AES}); +//# sourceMappingURL=aes.min.js.map +!function(e,n){"object"==typeof exports?module.exports=exports=n(require("./core.min")):"function"==typeof define&&define.amd?define(["./core.min"],n):n(e.CryptoJS)}(this,function(e){return e.enc.Utf8}); +//# sourceMappingURL=enc-utf8.min.js.map +var cbc_key = CryptoJS.enc.Utf8.parse("zhgd@bonus@zhgd@bonus@1234567890"); +var cbc_iv = CryptoJS.enc.Utf8.parse("1234567812345678"); +function encryptCBC(word){ + if(!aqEnnable){ + return word; + } + var srcs = CryptoJS.enc.Utf8.parse(word) + var encrypted = CryptoJS.AES.encrypt(srcs, cbc_key, { + iv: cbc_iv, + mode: CryptoJS.mode.CBC, + padding: CryptoJS.pad.Pkcs7 + }); + return encrypted.toString(); +} +/** + * 解密 + * @param word + * @returns {*} + */ +function decryptCBC(word){ + if(!aqEnnable){ + return word; + } + var encrypted = CryptoJS.AES.decrypt(word, cbc_key, { + iv: cbc_iv, + mode: CryptoJS.mode.CBC, + padding: CryptoJS.pad.Pkcs7 + }); + return encrypted.toString(CryptoJS.enc.Utf8); +} + + +/** + * @param {Object} fmt + * @param {Object} date时间格式化工具类 + */ +function dateFtt(fmt, date) { //author: meizz + var o = { + "M+": date.getMonth() + 1, //月份 + "d+": date.getDate(), //日 + "h+": date.getHours(), //小时 + "m+": date.getMinutes(), //分 + "s+": date.getSeconds(), //秒 + "q+": Math.floor((date.getMonth() + 3) / 3), //季度 + "S": date.getMilliseconds() //毫秒 + }; + if(/(y+)/.test(fmt)) + fmt = fmt.replace(RegExp.$1, (date.getFullYear() + "").substr(4 - RegExp.$1.length)); + for(var k in o) + if(new RegExp("(" + k + ")").test(fmt)) + fmt = fmt.replace(RegExp.$1, (RegExp.$1.length == 1) ? (o[k]) : (("00" + o[k]).substr(("" + o[k]).length))); + return fmt; +} \ No newline at end of file diff --git a/js/publics/public.js b/js/publics/public.js index e69de29..410029b 100644 --- a/js/publics/public.js +++ b/js/publics/public.js @@ -0,0 +1,46 @@ +const token = localStorage.getItem("zhgd_token"); +const us = localStorage.getItem("zhgd_us"); + +/* 退出登录 */ +function loginout(type) { + if (type) { + localStorage.removeItem("zhgd_token"); + localStorage.removeItem("zhgd_us"); + top.layer.confirm('登录已过期,请点击确定后重新登录!', { + btn: ['确认', '取消'], + move: false, + cancel: function (index, layero) { + top.location.href = login_page; + } + }, function () { + top.location.href = login_page; + }, function () { + top.location.href = login_page; + }); + } else { + top.layer.confirm('请您确定注销?', { + btn: ['确认', '取消'], + move: false, + }, function () { + loginOutAjax(); + }, function () { + }); + } + // 登出请求 + function loginOutAjax() { + ajaxRequest(login_out, "POST", null, true, function () { + }, function (result) { + if (result.code === 200) { + top.layer.msg(result.msg, { icon: 1, time: 1000 }, function () { + localStorage.removeItem("zhgd_token"); + localStorage.removeItem("zhgd_us"); + top.location.href = login_page; + }); + } else if (result.code === 500) { + layer.msg(result.msg, { icon: 2 }); + } + }, function (xhr) { + error(xhr) + }); + } +} \ No newline at end of file diff --git a/login.html b/login.html index 6c84baa..aafc1d4 100644 --- a/login.html +++ b/login.html @@ -1,11 +1,52 @@ + + + + + + + + + 登录 + - +
+
+

基建智慧现场工地

+
+
+
+
+
+
+ +
+ +
+
+
+
+
+ +
+ +
+
+
+ +
+
+
+
+ + \ No newline at end of file diff --git a/pages/home/navigation.html b/pages/home/navigation.html index 71c239b..3e2e0ec 100644 --- a/pages/home/navigation.html +++ b/pages/home/navigation.html @@ -12,8 +12,8 @@ - + 导航页 @@ -21,7 +21,7 @@