From f4313dce9dfc3893992fed1626cf90eca6f4b9f3 Mon Sep 17 00:00:00 2001 From: luyuan <1162963624@qq.com> Date: Fri, 7 Aug 2020 14:39:15 +0800 Subject: [PATCH] md5 --- common/http.interceptor.js | 22 ++++++++++++++++++++-- package-lock.json | 5 +++++ package.json | 5 +++-- static/js/md5.min.js | 2 ++ 4 files changed, 30 insertions(+), 4 deletions(-) create mode 100644 static/js/md5.min.js diff --git a/common/http.interceptor.js b/common/http.interceptor.js index 4d75a25..4bff349 100644 --- a/common/http.interceptor.js +++ b/common/http.interceptor.js @@ -1,3 +1,4 @@ +var md5 = require("../static/js/md5.min.js") const install = (Vue, vm) => { // 此为自定义配置参数,具体参数见上方说明 Vue.prototype.$u.http.setConfig({ @@ -12,8 +13,25 @@ const install = (Vue, vm) => { const token = uni.getStorageSync('token'); - config.header.Authorization = 'Bearer' + " " + token; - + config.header.Authorization = 'Bearer' + " " + token; + Date.prototype.Format = function (fmt) { // author: meizz + var o = { + "M+": this.getMonth() + 1, // 月份 + "d+": this.getDate(), // 日 + "h+": this.getHours(), // 小时 + "m+": this.getMinutes(), // 分 + "s+": this.getSeconds(), // 秒 + "q+": Math.floor((this.getMonth() + 3) / 3), // 季度 + "S": this.getMilliseconds() // 毫秒 + }; + if (/(y+)/.test(fmt)) + fmt = fmt.replace(RegExp.$1, (this.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; + } + let time = new Date().Format("yyyyMMddhhmmss") + config.header.Sign = md5('DBCA4F8DA7BC0BA2' + time) + '-' + time return config; } diff --git a/package-lock.json b/package-lock.json index dde9e73..ee7f5ca 100644 --- a/package-lock.json +++ b/package-lock.json @@ -4,6 +4,11 @@ "lockfileVersion": 1, "requires": true, "dependencies": { + "blueimp-md5": { + "version": "2.17.0", + "resolved": "https://registry.npm.taobao.org/blueimp-md5/download/blueimp-md5-2.17.0.tgz?cache=0&sync_timestamp=1595922448921&other_urls=https%3A%2F%2Fregistry.npm.taobao.org%2Fblueimp-md5%2Fdownload%2Fblueimp-md5-2.17.0.tgz", + "integrity": "sha1-9PysCIsRX3tARfGfXaWenQGxu5Y=" + }, "uview-ui": { "version": "1.5.0", "resolved": "https://registry.npmjs.org/uview-ui/-/uview-ui-1.5.0.tgz", diff --git a/package.json b/package.json index 2d632c1..a54aec3 100644 --- a/package.json +++ b/package.json @@ -11,9 +11,10 @@ "url": "http://git.luyuan.tk/luyuan/deming.git" }, "author": "", - "license": "ISC", + "license": "ISC", "dependencies": { - "uview-ui": "^1.5.0", + "blueimp-md5": "^2.17.0", + "uview-ui": "^1.5.0", "vuex": "^3.5.1" } } diff --git a/static/js/md5.min.js b/static/js/md5.min.js new file mode 100644 index 0000000..1456fcc --- /dev/null +++ b/static/js/md5.min.js @@ -0,0 +1,2 @@ +!function(n){"use strict";function d(n,t){var r=(65535&n)+(65535&t);return(n>>16)+(t>>16)+(r>>16)<<16|65535&r}function f(n,t,r,e,o,u){return d((c=d(d(t,n),d(e,u)))<<(f=o)|c>>>32-f,r);var c,f}function l(n,t,r,e,o,u,c){return f(t&r|~t&e,n,t,o,u,c)}function v(n,t,r,e,o,u,c){return f(t&e|r&~e,n,t,o,u,c)}function g(n,t,r,e,o,u,c){return f(t^r^e,n,t,o,u,c)}function m(n,t,r,e,o,u,c){return f(r^(t|~e),n,t,o,u,c)}function i(n,t){var r,e,o,u;n[t>>5]|=128<>>9<<4)]=t;for(var c=1732584193,f=-271733879,i=-1732584194,a=271733878,h=0;h>5]>>>e%32&255);return t}function h(n){var t=[];for(t[(n.length>>2)-1]=void 0,e=0;e>5]|=(255&n.charCodeAt(e/8))<>>4&15)+r.charAt(15&t);return e}function r(n){return unescape(encodeURIComponent(n))}function o(n){return a(i(h(t=r(n)),8*t.length));var t}function u(n,t){return function(n,t){var r,e,o=h(n),u=[],c=[];for(u[15]=c[15]=void 0,16