From 06b93604f8f9bfbcc740decfe5a5b922d75a0de3 Mon Sep 17 00:00:00 2001 From: zuoxiao <470321431@qq.com> Date: 星期三, 03 七月 2024 10:05:51 +0800 Subject: [PATCH] 完成界面 --- pages/home/home.js | 126 ++- package-lock.json | 6 pages/rechargeCard/rechargeCard.js | 182 +++- pages/rechargeMoney/rechargMoney.js | 68 ++ pages/feedback/feedback.wxml | 85 + pages/feedback/feedback.wxss | 109 ++ pages/rechargeCard/rechargeCard.wxml | 4 pages/rechargeCard/rechargeCard.wxss | 1 app.js | 7 utils/storage.js | 2 pages/rechargeMoney/rechargMoney.wxml | 4 pages/waterIntake/waterIntake.wxss | 7 pages/waterIntake/waterIntake.js | 16 pages/waterIntake/waterIntake.wxml | 4 pages/home/home.wxml | 6 pages/home/home.wxss | 8 miniprogram_npm/js-md5/index.js | 889 ++++++++++++++++++++++++++ pages/feedback/feedback.js | 362 ++++++---- pages/valveList/valveList.wxml | 2 pages/rechargeCard/rechargeCard.json | 3 miniprogram_npm/dayjs/index.js | 4 project.private.config.json | 3 app.json | 10 pages/wxbind/wxbind.js | 90 ++ api/request.js | 12 package.json | 14 miniprogram_npm/js-md5/index.js.map | 1 27 files changed, 1,695 insertions(+), 330 deletions(-) diff --git a/api/request.js b/api/request.js index 2b8e5f2..0833bc0 100644 --- a/api/request.js +++ b/api/request.js @@ -31,11 +31,12 @@ data, ignoreToken, form, - isShowLoding + isShowLoding, + timeout, + header } = _options const app = getApp() // 璁剧疆璇锋眰澶� - let header = {} if (form) { header = { 'content-type': 'application/x-www-form-urlencoded' @@ -45,11 +46,16 @@ 'content-type': 'application/json' //鑷畾涔夎姹傚ご淇℃伅 } } + if (!timeout) { + timeout = 60000 + } + if (!ignoreToken) { // 浠庡叏灞�鍙橀噺涓幏鍙杢oken let token = app.globalData.token header.Authorization = `Bearer ${token}` } + header.tag = app.globalData.tag; return new Promise((resolve, reject) => { console.log("url:" + BASEURL + url); if (isShowLoding) { @@ -69,6 +75,7 @@ data, header, method, + timeout: timeout, success: (res) => { let { statusCode: code @@ -101,7 +108,6 @@ if (isShowLoding) { wx.hideLoading(); // 闅愯棌鍔犺浇鍔ㄧ敾 } - // showToast(err.errMsg) reject(err) } diff --git a/app.js b/app.js index aa1d3eb..e862932 100644 --- a/app.js +++ b/app.js @@ -14,10 +14,13 @@ }) }, globalData: { - sessionId:'2024052821300200006', + APPID:"wxf773810cd5643196", + sessionId:'', userInfo: null, userId:"", userCode:"", - token:"" + token:"", + tag:"ym" + } }) diff --git a/app.json b/app.json index c680884..d270bc4 100644 --- a/app.json +++ b/app.json @@ -1,9 +1,13 @@ { "pages": [ - + "pages/home/home", - "pages/valveList/valveList", + "pages/rechargeMoney/rechargMoney", + "pages/feedback/feedback", + + "pages/valveList/valveList", + "pages/wxlogin/wxlogin", "pages/login/login", "pages/wxbind/wxbind", @@ -14,7 +18,7 @@ "pages/waterIntake/waterIntake", "pages/personCharge/personcharge", "pages/openCard/openCard", - "pages/rechargeMoney/rechargMoney", + "pages/rechargeCard/rechargeCard" ], "window": { diff --git a/miniprogram_npm/dayjs/index.js b/miniprogram_npm/dayjs/index.js index f273179..b6ce192 100644 --- a/miniprogram_npm/dayjs/index.js +++ b/miniprogram_npm/dayjs/index.js @@ -4,10 +4,10 @@ var __REQUIRE__ = function(modId, source) { if(!__MODS__[modId]) return require(source); if(!__MODS__[modId].status) { var m = __MODS__[modId].m; m._exports = m._tempexports; var desp = Object.getOwnPropertyDescriptor(m, "exports"); if (desp && desp.configurable) Object.defineProperty(m, "exports", { set: function (val) { if(typeof val === "object" && val !== m._exports) { m._exports.__proto__ = val.__proto__; Object.keys(val).forEach(function (k) { m._exports[k] = val[k]; }); } m._tempexports = val }, get: function () { return m._tempexports; } }); __MODS__[modId].status = 1; __MODS__[modId].func(__MODS__[modId].req, m, m.exports); } return __MODS__[modId].m.exports; }; var __REQUIRE_WILDCARD__ = function(obj) { if(obj && obj.__esModule) { return obj; } else { var newObj = {}; if(obj != null) { for(var k in obj) { if (Object.prototype.hasOwnProperty.call(obj, k)) newObj[k] = obj[k]; } } newObj.default = obj; return newObj; } }; var __REQUIRE_DEFAULT__ = function(obj) { return obj && obj.__esModule ? obj.default : obj; }; -__DEFINE__(1718331186291, function(require, module, exports) { +__DEFINE__(1718586298038, function(require, module, exports) { !function(t,e){"object"==typeof exports&&"undefined"!=typeof module?module.exports=e():"function"==typeof define&&define.amd?define(e):(t="undefined"!=typeof globalThis?globalThis:t||self).dayjs=e()}(this,(function(){var t=1e3,e=6e4,n=36e5,r="millisecond",i="second",s="minute",u="hour",a="day",o="week",c="month",f="quarter",h="year",d="date",l="Invalid Date",$=/^(\d{4})[-/]?(\d{1,2})?[-/]?(\d{0,2})[Tt\s]*(\d{1,2})?:?(\d{1,2})?:?(\d{1,2})?[.:]?(\d+)?$/,y=/\[([^\]]+)]|Y{1,4}|M{1,4}|D{1,2}|d{1,4}|H{1,2}|h{1,2}|a|A|m{1,2}|s{1,2}|Z{1,2}|SSS/g,M={name:"en",weekdays:"Sunday_Monday_Tuesday_Wednesday_Thursday_Friday_Saturday".split("_"),months:"January_February_March_April_May_June_July_August_September_October_November_December".split("_"),ordinal:function(t){var e=["th","st","nd","rd"],n=t%100;return"["+t+(e[(n-20)%10]||e[n]||e[0])+"]"}},m=function(t,e,n){var r=String(t);return!r||r.length>=e?t:""+Array(e+1-r.length).join(n)+t},v={s:m,z:function(t){var e=-t.utcOffset(),n=Math.abs(e),r=Math.floor(n/60),i=n%60;return(e<=0?"+":"-")+m(r,2,"0")+":"+m(i,2,"0")},m:function t(e,n){if(e.date()<n.date())return-t(n,e);var r=12*(n.year()-e.year())+(n.month()-e.month()),i=e.clone().add(r,c),s=n-i<0,u=e.clone().add(r+(s?-1:1),c);return+(-(r+(n-i)/(s?i-u:u-i))||0)},a:function(t){return t<0?Math.ceil(t)||0:Math.floor(t)},p:function(t){return{M:c,y:h,w:o,d:a,D:d,h:u,m:s,s:i,ms:r,Q:f}[t]||String(t||"").toLowerCase().replace(/s$/,"")},u:function(t){return void 0===t}},g="en",D={};D[g]=M;var p="$isDayjsObject",S=function(t){return t instanceof _||!(!t||!t[p])},w=function t(e,n,r){var i;if(!e)return g;if("string"==typeof e){var s=e.toLowerCase();D[s]&&(i=s),n&&(D[s]=n,i=s);var u=e.split("-");if(!i&&u.length>1)return t(u[0])}else{var a=e.name;D[a]=e,i=a}return!r&&i&&(g=i),i||!r&&g},O=function(t,e){if(S(t))return t.clone();var n="object"==typeof e?e:{};return n.date=t,n.args=arguments,new _(n)},b=v;b.l=w,b.i=S,b.w=function(t,e){return O(t,{locale:e.$L,utc:e.$u,x:e.$x,$offset:e.$offset})};var _=function(){function M(t){this.$L=w(t.locale,null,!0),this.parse(t),this.$x=this.$x||t.x||{},this[p]=!0}var m=M.prototype;return m.parse=function(t){this.$d=function(t){var e=t.date,n=t.utc;if(null===e)return new Date(NaN);if(b.u(e))return new Date;if(e instanceof Date)return new Date(e);if("string"==typeof e&&!/Z$/i.test(e)){var r=e.match($);if(r){var i=r[2]-1||0,s=(r[7]||"0").substring(0,3);return n?new Date(Date.UTC(r[1],i,r[3]||1,r[4]||0,r[5]||0,r[6]||0,s)):new Date(r[1],i,r[3]||1,r[4]||0,r[5]||0,r[6]||0,s)}}return new Date(e)}(t),this.init()},m.init=function(){var t=this.$d;this.$y=t.getFullYear(),this.$M=t.getMonth(),this.$D=t.getDate(),this.$W=t.getDay(),this.$H=t.getHours(),this.$m=t.getMinutes(),this.$s=t.getSeconds(),this.$ms=t.getMilliseconds()},m.$utils=function(){return b},m.isValid=function(){return!(this.$d.toString()===l)},m.isSame=function(t,e){var n=O(t);return this.startOf(e)<=n&&n<=this.endOf(e)},m.isAfter=function(t,e){return O(t)<this.startOf(e)},m.isBefore=function(t,e){return this.endOf(e)<O(t)},m.$g=function(t,e,n){return b.u(t)?this[e]:this.set(n,t)},m.unix=function(){return Math.floor(this.valueOf()/1e3)},m.valueOf=function(){return this.$d.getTime()},m.startOf=function(t,e){var n=this,r=!!b.u(e)||e,f=b.p(t),l=function(t,e){var i=b.w(n.$u?Date.UTC(n.$y,e,t):new Date(n.$y,e,t),n);return r?i:i.endOf(a)},$=function(t,e){return b.w(n.toDate()[t].apply(n.toDate("s"),(r?[0,0,0,0]:[23,59,59,999]).slice(e)),n)},y=this.$W,M=this.$M,m=this.$D,v="set"+(this.$u?"UTC":"");switch(f){case h:return r?l(1,0):l(31,11);case c:return r?l(1,M):l(0,M+1);case o:var g=this.$locale().weekStart||0,D=(y<g?y+7:y)-g;return l(r?m-D:m+(6-D),M);case a:case d:return $(v+"Hours",0);case u:return $(v+"Minutes",1);case s:return $(v+"Seconds",2);case i:return $(v+"Milliseconds",3);default:return this.clone()}},m.endOf=function(t){return this.startOf(t,!1)},m.$set=function(t,e){var n,o=b.p(t),f="set"+(this.$u?"UTC":""),l=(n={},n[a]=f+"Date",n[d]=f+"Date",n[c]=f+"Month",n[h]=f+"FullYear",n[u]=f+"Hours",n[s]=f+"Minutes",n[i]=f+"Seconds",n[r]=f+"Milliseconds",n)[o],$=o===a?this.$D+(e-this.$W):e;if(o===c||o===h){var y=this.clone().set(d,1);y.$d[l]($),y.init(),this.$d=y.set(d,Math.min(this.$D,y.daysInMonth())).$d}else l&&this.$d[l]($);return this.init(),this},m.set=function(t,e){return this.clone().$set(t,e)},m.get=function(t){return this[b.p(t)]()},m.add=function(r,f){var d,l=this;r=Number(r);var $=b.p(f),y=function(t){var e=O(l);return b.w(e.date(e.date()+Math.round(t*r)),l)};if($===c)return this.set(c,this.$M+r);if($===h)return this.set(h,this.$y+r);if($===a)return y(1);if($===o)return y(7);var M=(d={},d[s]=e,d[u]=n,d[i]=t,d)[$]||1,m=this.$d.getTime()+r*M;return b.w(m,this)},m.subtract=function(t,e){return this.add(-1*t,e)},m.format=function(t){var e=this,n=this.$locale();if(!this.isValid())return n.invalidDate||l;var r=t||"YYYY-MM-DDTHH:mm:ssZ",i=b.z(this),s=this.$H,u=this.$m,a=this.$M,o=n.weekdays,c=n.months,f=n.meridiem,h=function(t,n,i,s){return t&&(t[n]||t(e,r))||i[n].slice(0,s)},d=function(t){return b.s(s%12||12,t,"0")},$=f||function(t,e,n){var r=t<12?"AM":"PM";return n?r.toLowerCase():r};return r.replace(y,(function(t,r){return r||function(t){switch(t){case"YY":return String(e.$y).slice(-2);case"YYYY":return b.s(e.$y,4,"0");case"M":return a+1;case"MM":return b.s(a+1,2,"0");case"MMM":return h(n.monthsShort,a,c,3);case"MMMM":return h(c,a);case"D":return e.$D;case"DD":return b.s(e.$D,2,"0");case"d":return String(e.$W);case"dd":return h(n.weekdaysMin,e.$W,o,2);case"ddd":return h(n.weekdaysShort,e.$W,o,3);case"dddd":return o[e.$W];case"H":return String(s);case"HH":return b.s(s,2,"0");case"h":return d(1);case"hh":return d(2);case"a":return $(s,u,!0);case"A":return $(s,u,!1);case"m":return String(u);case"mm":return b.s(u,2,"0");case"s":return String(e.$s);case"ss":return b.s(e.$s,2,"0");case"SSS":return b.s(e.$ms,3,"0");case"Z":return i}return null}(t)||i.replace(":","")}))},m.utcOffset=function(){return 15*-Math.round(this.$d.getTimezoneOffset()/15)},m.diff=function(r,d,l){var $,y=this,M=b.p(d),m=O(r),v=(m.utcOffset()-this.utcOffset())*e,g=this-m,D=function(){return b.m(y,m)};switch(M){case h:$=D()/12;break;case c:$=D();break;case f:$=D()/3;break;case o:$=(g-v)/6048e5;break;case a:$=(g-v)/864e5;break;case u:$=g/n;break;case s:$=g/e;break;case i:$=g/t;break;default:$=g}return l?$:b.a($)},m.daysInMonth=function(){return this.endOf(c).$D},m.$locale=function(){return D[this.$L]},m.locale=function(t,e){if(!t)return this.$L;var n=this.clone(),r=w(t,e,!0);return r&&(n.$L=r),n},m.clone=function(){return b.w(this.$d,this)},m.toDate=function(){return new Date(this.valueOf())},m.toJSON=function(){return this.isValid()?this.toISOString():null},m.toISOString=function(){return this.$d.toISOString()},m.toString=function(){return this.$d.toUTCString()},M}(),k=_.prototype;return O.prototype=k,[["$ms",r],["$s",i],["$m",s],["$H",u],["$W",a],["$M",c],["$y",h],["$D",d]].forEach((function(t){k[t[1]]=function(e){return this.$g(e,t[0],t[1])}})),O.extend=function(t,e){return t.$i||(t(e,_,O),t.$i=!0),O},O.locale=w,O.isDayjs=S,O.unix=function(t){return O(1e3*t)},O.en=D[g],O.Ls=D,O.p={},O})); }, function(modId) {var map = {}; return __REQUIRE__(map[modId], modId); }) -return __REQUIRE__(1718331186291); +return __REQUIRE__(1718586298038); })() //miniprogram-npm-outsideDeps=[] //# sourceMappingURL=index.js.map \ No newline at end of file diff --git a/miniprogram_npm/js-md5/index.js b/miniprogram_npm/js-md5/index.js new file mode 100644 index 0000000..ffb62ec --- /dev/null +++ b/miniprogram_npm/js-md5/index.js @@ -0,0 +1,889 @@ +module.exports = (function() { +var __MODS__ = {}; +var __DEFINE__ = function(modId, func, req) { var m = { exports: {}, _tempexports: {} }; __MODS__[modId] = { status: 0, func: func, req: req, m: m }; }; +var __REQUIRE__ = function(modId, source) { if(!__MODS__[modId]) return require(source); if(!__MODS__[modId].status) { var m = __MODS__[modId].m; m._exports = m._tempexports; var desp = Object.getOwnPropertyDescriptor(m, "exports"); if (desp && desp.configurable) Object.defineProperty(m, "exports", { set: function (val) { if(typeof val === "object" && val !== m._exports) { m._exports.__proto__ = val.__proto__; Object.keys(val).forEach(function (k) { m._exports[k] = val[k]; }); } m._tempexports = val }, get: function () { return m._tempexports; } }); __MODS__[modId].status = 1; __MODS__[modId].func(__MODS__[modId].req, m, m.exports); } return __MODS__[modId].m.exports; }; +var __REQUIRE_WILDCARD__ = function(obj) { if(obj && obj.__esModule) { return obj; } else { var newObj = {}; if(obj != null) { for(var k in obj) { if (Object.prototype.hasOwnProperty.call(obj, k)) newObj[k] = obj[k]; } } newObj.default = obj; return newObj; } }; +var __REQUIRE_DEFAULT__ = function(obj) { return obj && obj.__esModule ? obj.default : obj; }; +__DEFINE__(1718586298039, function(require, module, exports) { +/** + * [js-md5]{@link https://github.com/emn178/js-md5} + * + * @namespace md5 + * @version 0.8.3 + * @author Chen, Yi-Cyuan [emn178@gmail.com] + * @copyright Chen, Yi-Cyuan 2014-2023 + * @license MIT + */ +(function () { + + + var INPUT_ERROR = 'input is invalid type'; + var FINALIZE_ERROR = 'finalize already called'; + var WINDOW = typeof window === 'object'; + var root = WINDOW ? window : {}; + if (root.JS_MD5_NO_WINDOW) { + WINDOW = false; + } + var WEB_WORKER = !WINDOW && typeof self === 'object'; + var NODE_JS = !root.JS_MD5_NO_NODE_JS && typeof process === 'object' && process.versions && process.versions.node; + if (NODE_JS) { + root = global; + } else if (WEB_WORKER) { + root = self; + } + var COMMON_JS = !root.JS_MD5_NO_COMMON_JS && typeof module === 'object' && module.exports; + var AMD = typeof define === 'function' && define.amd; + var ARRAY_BUFFER = !root.JS_MD5_NO_ARRAY_BUFFER && typeof ArrayBuffer !== 'undefined'; + var HEX_CHARS = '0123456789abcdef'.split(''); + var EXTRA = [128, 32768, 8388608, -2147483648]; + var SHIFT = [0, 8, 16, 24]; + var OUTPUT_TYPES = ['hex', 'array', 'digest', 'buffer', 'arrayBuffer', 'base64']; + var BASE64_ENCODE_CHAR = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/'.split(''); + + var blocks = [], buffer8; + if (ARRAY_BUFFER) { + var buffer = new ArrayBuffer(68); + buffer8 = new Uint8Array(buffer); + blocks = new Uint32Array(buffer); + } + + var isArray = Array.isArray; + if (root.JS_MD5_NO_NODE_JS || !isArray) { + isArray = function (obj) { + return Object.prototype.toString.call(obj) === '[object Array]'; + }; + } + + var isView = ArrayBuffer.isView; + if (ARRAY_BUFFER && (root.JS_MD5_NO_ARRAY_BUFFER_IS_VIEW || !isView)) { + isView = function (obj) { + return typeof obj === 'object' && obj.buffer && obj.buffer.constructor === ArrayBuffer; + }; + } + + // [message: string, isString: bool] + var formatMessage = function (message) { + var type = typeof message; + if (type === 'string') { + return [message, true]; + } + if (type !== 'object' || message === null) { + throw new Error(INPUT_ERROR); + } + if (ARRAY_BUFFER && message.constructor === ArrayBuffer) { + return [new Uint8Array(message), false]; + } + if (!isArray(message) && !isView(message)) { + throw new Error(INPUT_ERROR); + } + return [message, false]; + } + + /** + * @method hex + * @memberof md5 + * @description Output hash as hex string + * @param {String|Array|Uint8Array|ArrayBuffer} message message to hash + * @returns {String} Hex string + * @example + * md5.hex('The quick brown fox jumps over the lazy dog'); + * // equal to + * md5('The quick brown fox jumps over the lazy dog'); + */ + /** + * @method digest + * @memberof md5 + * @description Output hash as bytes array + * @param {String|Array|Uint8Array|ArrayBuffer} message message to hash + * @returns {Array} Bytes array + * @example + * md5.digest('The quick brown fox jumps over the lazy dog'); + */ + /** + * @method array + * @memberof md5 + * @description Output hash as bytes array + * @param {String|Array|Uint8Array|ArrayBuffer} message message to hash + * @returns {Array} Bytes array + * @example + * md5.array('The quick brown fox jumps over the lazy dog'); + */ + /** + * @method arrayBuffer + * @memberof md5 + * @description Output hash as ArrayBuffer + * @param {String|Array|Uint8Array|ArrayBuffer} message message to hash + * @returns {ArrayBuffer} ArrayBuffer + * @example + * md5.arrayBuffer('The quick brown fox jumps over the lazy dog'); + */ + /** + * @method buffer + * @deprecated This maybe confuse with Buffer in node.js. Please use arrayBuffer instead. + * @memberof md5 + * @description Output hash as ArrayBuffer + * @param {String|Array|Uint8Array|ArrayBuffer} message message to hash + * @returns {ArrayBuffer} ArrayBuffer + * @example + * md5.buffer('The quick brown fox jumps over the lazy dog'); + */ + /** + * @method base64 + * @memberof md5 + * @description Output hash as base64 string + * @param {String|Array|Uint8Array|ArrayBuffer} message message to hash + * @returns {String} base64 string + * @example + * md5.base64('The quick brown fox jumps over the lazy dog'); + */ + var createOutputMethod = function (outputType) { + return function (message) { + return new Md5(true).update(message)[outputType](); + }; + }; + + /** + * @method create + * @memberof md5 + * @description Create Md5 object + * @returns {Md5} Md5 object. + * @example + * var hash = md5.create(); + */ + /** + * @method update + * @memberof md5 + * @description Create and update Md5 object + * @param {String|Array|Uint8Array|ArrayBuffer} message message to hash + * @returns {Md5} Md5 object. + * @example + * var hash = md5.update('The quick brown fox jumps over the lazy dog'); + * // equal to + * var hash = md5.create(); + * hash.update('The quick brown fox jumps over the lazy dog'); + */ + var createMethod = function () { + var method = createOutputMethod('hex'); + if (NODE_JS) { + method = nodeWrap(method); + } + method.create = function () { + return new Md5(); + }; + method.update = function (message) { + return method.create().update(message); + }; + for (var i = 0; i < OUTPUT_TYPES.length; ++i) { + var type = OUTPUT_TYPES[i]; + method[type] = createOutputMethod(type); + } + return method; + }; + + var nodeWrap = function (method) { + var crypto = require('crypto') + var Buffer = require('buffer').Buffer; + var bufferFrom; + if (Buffer.from && !root.JS_MD5_NO_BUFFER_FROM) { + bufferFrom = Buffer.from; + } else { + bufferFrom = function (message) { + return new Buffer(message); + }; + } + var nodeMethod = function (message) { + if (typeof message === 'string') { + return crypto.createHash('md5').update(message, 'utf8').digest('hex'); + } else { + if (message === null || message === undefined) { + throw new Error(INPUT_ERROR); + } else if (message.constructor === ArrayBuffer) { + message = new Uint8Array(message); + } + } + if (isArray(message) || isView(message) || + message.constructor === Buffer) { + return crypto.createHash('md5').update(bufferFrom(message)).digest('hex'); + } else { + return method(message); + } + }; + return nodeMethod; + }; + + /** + * @namespace md5.hmac + */ + /** + * @method hex + * @memberof md5.hmac + * @description Output hash as hex string + * @param {String|Array|Uint8Array|ArrayBuffer} key key + * @param {String|Array|Uint8Array|ArrayBuffer} message message to hash + * @returns {String} Hex string + * @example + * md5.hmac.hex('key', 'The quick brown fox jumps over the lazy dog'); + * // equal to + * md5.hmac('key', 'The quick brown fox jumps over the lazy dog'); + */ + + /** + * @method digest + * @memberof md5.hmac + * @description Output hash as bytes array + * @param {String|Array|Uint8Array|ArrayBuffer} key key + * @param {String|Array|Uint8Array|ArrayBuffer} message message to hash + * @returns {Array} Bytes array + * @example + * md5.hmac.digest('key', 'The quick brown fox jumps over the lazy dog'); + */ + /** + * @method array + * @memberof md5.hmac + * @description Output hash as bytes array + * @param {String|Array|Uint8Array|ArrayBuffer} key key + * @param {String|Array|Uint8Array|ArrayBuffer} message message to hash + * @returns {Array} Bytes array + * @example + * md5.hmac.array('key', 'The quick brown fox jumps over the lazy dog'); + */ + /** + * @method arrayBuffer + * @memberof md5.hmac + * @description Output hash as ArrayBuffer + * @param {String|Array|Uint8Array|ArrayBuffer} key key + * @param {String|Array|Uint8Array|ArrayBuffer} message message to hash + * @returns {ArrayBuffer} ArrayBuffer + * @example + * md5.hmac.arrayBuffer('key', 'The quick brown fox jumps over the lazy dog'); + */ + /** + * @method buffer + * @deprecated This maybe confuse with Buffer in node.js. Please use arrayBuffer instead. + * @memberof md5.hmac + * @description Output hash as ArrayBuffer + * @param {String|Array|Uint8Array|ArrayBuffer} key key + * @param {String|Array|Uint8Array|ArrayBuffer} message message to hash + * @returns {ArrayBuffer} ArrayBuffer + * @example + * md5.hmac.buffer('key', 'The quick brown fox jumps over the lazy dog'); + */ + /** + * @method base64 + * @memberof md5.hmac + * @description Output hash as base64 string + * @param {String|Array|Uint8Array|ArrayBuffer} key key + * @param {String|Array|Uint8Array|ArrayBuffer} message message to hash + * @returns {String} base64 string + * @example + * md5.hmac.base64('key', 'The quick brown fox jumps over the lazy dog'); + */ + var createHmacOutputMethod = function (outputType) { + return function (key, message) { + return new HmacMd5(key, true).update(message)[outputType](); + }; + }; + + /** + * @method create + * @memberof md5.hmac + * @description Create HmacMd5 object + * @param {String|Array|Uint8Array|ArrayBuffer} key key + * @returns {HmacMd5} HmacMd5 object. + * @example + * var hash = md5.hmac.create('key'); + */ + /** + * @method update + * @memberof md5.hmac + * @description Create and update HmacMd5 object + * @param {String|Array|Uint8Array|ArrayBuffer} key key + * @param {String|Array|Uint8Array|ArrayBuffer} message message to hash + * @returns {HmacMd5} HmacMd5 object. + * @example + * var hash = md5.hmac.update('key', 'The quick brown fox jumps over the lazy dog'); + * // equal to + * var hash = md5.hmac.create('key'); + * hash.update('The quick brown fox jumps over the lazy dog'); + */ + var createHmacMethod = function () { + var method = createHmacOutputMethod('hex'); + method.create = function (key) { + return new HmacMd5(key); + }; + method.update = function (key, message) { + return method.create(key).update(message); + }; + for (var i = 0; i < OUTPUT_TYPES.length; ++i) { + var type = OUTPUT_TYPES[i]; + method[type] = createHmacOutputMethod(type); + } + return method; + }; + + /** + * Md5 class + * @class Md5 + * @description This is internal class. + * @see {@link md5.create} + */ + function Md5(sharedMemory) { + if (sharedMemory) { + blocks[0] = blocks[16] = blocks[1] = blocks[2] = blocks[3] = + blocks[4] = blocks[5] = blocks[6] = blocks[7] = + blocks[8] = blocks[9] = blocks[10] = blocks[11] = + blocks[12] = blocks[13] = blocks[14] = blocks[15] = 0; + this.blocks = blocks; + this.buffer8 = buffer8; + } else { + if (ARRAY_BUFFER) { + var buffer = new ArrayBuffer(68); + this.buffer8 = new Uint8Array(buffer); + this.blocks = new Uint32Array(buffer); + } else { + this.blocks = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]; + } + } + this.h0 = this.h1 = this.h2 = this.h3 = this.start = this.bytes = this.hBytes = 0; + this.finalized = this.hashed = false; + this.first = true; + } + + /** + * @method update + * @memberof Md5 + * @instance + * @description Update hash + * @param {String|Array|Uint8Array|ArrayBuffer} message message to hash + * @returns {Md5} Md5 object. + * @see {@link md5.update} + */ + Md5.prototype.update = function (message) { + if (this.finalized) { + throw new Error(FINALIZE_ERROR); + } + + var result = formatMessage(message); + message = result[0]; + var isString = result[1]; + var code, index = 0, i, length = message.length, blocks = this.blocks; + var buffer8 = this.buffer8; + + while (index < length) { + if (this.hashed) { + this.hashed = false; + blocks[0] = blocks[16]; + blocks[16] = blocks[1] = blocks[2] = blocks[3] = + blocks[4] = blocks[5] = blocks[6] = blocks[7] = + blocks[8] = blocks[9] = blocks[10] = blocks[11] = + blocks[12] = blocks[13] = blocks[14] = blocks[15] = 0; + } + + if (isString) { + if (ARRAY_BUFFER) { + for (i = this.start; index < length && i < 64; ++index) { + code = message.charCodeAt(index); + if (code < 0x80) { + buffer8[i++] = code; + } else if (code < 0x800) { + buffer8[i++] = 0xc0 | (code >>> 6); + buffer8[i++] = 0x80 | (code & 0x3f); + } else if (code < 0xd800 || code >= 0xe000) { + buffer8[i++] = 0xe0 | (code >>> 12); + buffer8[i++] = 0x80 | ((code >>> 6) & 0x3f); + buffer8[i++] = 0x80 | (code & 0x3f); + } else { + code = 0x10000 + (((code & 0x3ff) << 10) | (message.charCodeAt(++index) & 0x3ff)); + buffer8[i++] = 0xf0 | (code >>> 18); + buffer8[i++] = 0x80 | ((code >>> 12) & 0x3f); + buffer8[i++] = 0x80 | ((code >>> 6) & 0x3f); + buffer8[i++] = 0x80 | (code & 0x3f); + } + } + } else { + for (i = this.start; index < length && i < 64; ++index) { + code = message.charCodeAt(index); + if (code < 0x80) { + blocks[i >>> 2] |= code << SHIFT[i++ & 3]; + } else if (code < 0x800) { + blocks[i >>> 2] |= (0xc0 | (code >>> 6)) << SHIFT[i++ & 3]; + blocks[i >>> 2] |= (0x80 | (code & 0x3f)) << SHIFT[i++ & 3]; + } else if (code < 0xd800 || code >= 0xe000) { + blocks[i >>> 2] |= (0xe0 | (code >>> 12)) << SHIFT[i++ & 3]; + blocks[i >>> 2] |= (0x80 | ((code >>> 6) & 0x3f)) << SHIFT[i++ & 3]; + blocks[i >>> 2] |= (0x80 | (code & 0x3f)) << SHIFT[i++ & 3]; + } else { + code = 0x10000 + (((code & 0x3ff) << 10) | (message.charCodeAt(++index) & 0x3ff)); + blocks[i >>> 2] |= (0xf0 | (code >>> 18)) << SHIFT[i++ & 3]; + blocks[i >>> 2] |= (0x80 | ((code >>> 12) & 0x3f)) << SHIFT[i++ & 3]; + blocks[i >>> 2] |= (0x80 | ((code >>> 6) & 0x3f)) << SHIFT[i++ & 3]; + blocks[i >>> 2] |= (0x80 | (code & 0x3f)) << SHIFT[i++ & 3]; + } + } + } + } else { + if (ARRAY_BUFFER) { + for (i = this.start; index < length && i < 64; ++index) { + buffer8[i++] = message[index]; + } + } else { + for (i = this.start; index < length && i < 64; ++index) { + blocks[i >>> 2] |= message[index] << SHIFT[i++ & 3]; + } + } + } + this.lastByteIndex = i; + this.bytes += i - this.start; + if (i >= 64) { + this.start = i - 64; + this.hash(); + this.hashed = true; + } else { + this.start = i; + } + } + if (this.bytes > 4294967295) { + this.hBytes += this.bytes / 4294967296 << 0; + this.bytes = this.bytes % 4294967296; + } + return this; + }; + + Md5.prototype.finalize = function () { + if (this.finalized) { + return; + } + this.finalized = true; + var blocks = this.blocks, i = this.lastByteIndex; + blocks[i >>> 2] |= EXTRA[i & 3]; + if (i >= 56) { + if (!this.hashed) { + this.hash(); + } + blocks[0] = blocks[16]; + blocks[16] = blocks[1] = blocks[2] = blocks[3] = + blocks[4] = blocks[5] = blocks[6] = blocks[7] = + blocks[8] = blocks[9] = blocks[10] = blocks[11] = + blocks[12] = blocks[13] = blocks[14] = blocks[15] = 0; + } + blocks[14] = this.bytes << 3; + blocks[15] = this.hBytes << 3 | this.bytes >>> 29; + this.hash(); + }; + + Md5.prototype.hash = function () { + var a, b, c, d, bc, da, blocks = this.blocks; + + if (this.first) { + a = blocks[0] - 680876937; + a = (a << 7 | a >>> 25) - 271733879 << 0; + d = (-1732584194 ^ a & 2004318071) + blocks[1] - 117830708; + d = (d << 12 | d >>> 20) + a << 0; + c = (-271733879 ^ (d & (a ^ -271733879))) + blocks[2] - 1126478375; + c = (c << 17 | c >>> 15) + d << 0; + b = (a ^ (c & (d ^ a))) + blocks[3] - 1316259209; + b = (b << 22 | b >>> 10) + c << 0; + } else { + a = this.h0; + b = this.h1; + c = this.h2; + d = this.h3; + a += (d ^ (b & (c ^ d))) + blocks[0] - 680876936; + a = (a << 7 | a >>> 25) + b << 0; + d += (c ^ (a & (b ^ c))) + blocks[1] - 389564586; + d = (d << 12 | d >>> 20) + a << 0; + c += (b ^ (d & (a ^ b))) + blocks[2] + 606105819; + c = (c << 17 | c >>> 15) + d << 0; + b += (a ^ (c & (d ^ a))) + blocks[3] - 1044525330; + b = (b << 22 | b >>> 10) + c << 0; + } + + a += (d ^ (b & (c ^ d))) + blocks[4] - 176418897; + a = (a << 7 | a >>> 25) + b << 0; + d += (c ^ (a & (b ^ c))) + blocks[5] + 1200080426; + d = (d << 12 | d >>> 20) + a << 0; + c += (b ^ (d & (a ^ b))) + blocks[6] - 1473231341; + c = (c << 17 | c >>> 15) + d << 0; + b += (a ^ (c & (d ^ a))) + blocks[7] - 45705983; + b = (b << 22 | b >>> 10) + c << 0; + a += (d ^ (b & (c ^ d))) + blocks[8] + 1770035416; + a = (a << 7 | a >>> 25) + b << 0; + d += (c ^ (a & (b ^ c))) + blocks[9] - 1958414417; + d = (d << 12 | d >>> 20) + a << 0; + c += (b ^ (d & (a ^ b))) + blocks[10] - 42063; + c = (c << 17 | c >>> 15) + d << 0; + b += (a ^ (c & (d ^ a))) + blocks[11] - 1990404162; + b = (b << 22 | b >>> 10) + c << 0; + a += (d ^ (b & (c ^ d))) + blocks[12] + 1804603682; + a = (a << 7 | a >>> 25) + b << 0; + d += (c ^ (a & (b ^ c))) + blocks[13] - 40341101; + d = (d << 12 | d >>> 20) + a << 0; + c += (b ^ (d & (a ^ b))) + blocks[14] - 1502002290; + c = (c << 17 | c >>> 15) + d << 0; + b += (a ^ (c & (d ^ a))) + blocks[15] + 1236535329; + b = (b << 22 | b >>> 10) + c << 0; + a += (c ^ (d & (b ^ c))) + blocks[1] - 165796510; + a = (a << 5 | a >>> 27) + b << 0; + d += (b ^ (c & (a ^ b))) + blocks[6] - 1069501632; + d = (d << 9 | d >>> 23) + a << 0; + c += (a ^ (b & (d ^ a))) + blocks[11] + 643717713; + c = (c << 14 | c >>> 18) + d << 0; + b += (d ^ (a & (c ^ d))) + blocks[0] - 373897302; + b = (b << 20 | b >>> 12) + c << 0; + a += (c ^ (d & (b ^ c))) + blocks[5] - 701558691; + a = (a << 5 | a >>> 27) + b << 0; + d += (b ^ (c & (a ^ b))) + blocks[10] + 38016083; + d = (d << 9 | d >>> 23) + a << 0; + c += (a ^ (b & (d ^ a))) + blocks[15] - 660478335; + c = (c << 14 | c >>> 18) + d << 0; + b += (d ^ (a & (c ^ d))) + blocks[4] - 405537848; + b = (b << 20 | b >>> 12) + c << 0; + a += (c ^ (d & (b ^ c))) + blocks[9] + 568446438; + a = (a << 5 | a >>> 27) + b << 0; + d += (b ^ (c & (a ^ b))) + blocks[14] - 1019803690; + d = (d << 9 | d >>> 23) + a << 0; + c += (a ^ (b & (d ^ a))) + blocks[3] - 187363961; + c = (c << 14 | c >>> 18) + d << 0; + b += (d ^ (a & (c ^ d))) + blocks[8] + 1163531501; + b = (b << 20 | b >>> 12) + c << 0; + a += (c ^ (d & (b ^ c))) + blocks[13] - 1444681467; + a = (a << 5 | a >>> 27) + b << 0; + d += (b ^ (c & (a ^ b))) + blocks[2] - 51403784; + d = (d << 9 | d >>> 23) + a << 0; + c += (a ^ (b & (d ^ a))) + blocks[7] + 1735328473; + c = (c << 14 | c >>> 18) + d << 0; + b += (d ^ (a & (c ^ d))) + blocks[12] - 1926607734; + b = (b << 20 | b >>> 12) + c << 0; + bc = b ^ c; + a += (bc ^ d) + blocks[5] - 378558; + a = (a << 4 | a >>> 28) + b << 0; + d += (bc ^ a) + blocks[8] - 2022574463; + d = (d << 11 | d >>> 21) + a << 0; + da = d ^ a; + c += (da ^ b) + blocks[11] + 1839030562; + c = (c << 16 | c >>> 16) + d << 0; + b += (da ^ c) + blocks[14] - 35309556; + b = (b << 23 | b >>> 9) + c << 0; + bc = b ^ c; + a += (bc ^ d) + blocks[1] - 1530992060; + a = (a << 4 | a >>> 28) + b << 0; + d += (bc ^ a) + blocks[4] + 1272893353; + d = (d << 11 | d >>> 21) + a << 0; + da = d ^ a; + c += (da ^ b) + blocks[7] - 155497632; + c = (c << 16 | c >>> 16) + d << 0; + b += (da ^ c) + blocks[10] - 1094730640; + b = (b << 23 | b >>> 9) + c << 0; + bc = b ^ c; + a += (bc ^ d) + blocks[13] + 681279174; + a = (a << 4 | a >>> 28) + b << 0; + d += (bc ^ a) + blocks[0] - 358537222; + d = (d << 11 | d >>> 21) + a << 0; + da = d ^ a; + c += (da ^ b) + blocks[3] - 722521979; + c = (c << 16 | c >>> 16) + d << 0; + b += (da ^ c) + blocks[6] + 76029189; + b = (b << 23 | b >>> 9) + c << 0; + bc = b ^ c; + a += (bc ^ d) + blocks[9] - 640364487; + a = (a << 4 | a >>> 28) + b << 0; + d += (bc ^ a) + blocks[12] - 421815835; + d = (d << 11 | d >>> 21) + a << 0; + da = d ^ a; + c += (da ^ b) + blocks[15] + 530742520; + c = (c << 16 | c >>> 16) + d << 0; + b += (da ^ c) + blocks[2] - 995338651; + b = (b << 23 | b >>> 9) + c << 0; + a += (c ^ (b | ~d)) + blocks[0] - 198630844; + a = (a << 6 | a >>> 26) + b << 0; + d += (b ^ (a | ~c)) + blocks[7] + 1126891415; + d = (d << 10 | d >>> 22) + a << 0; + c += (a ^ (d | ~b)) + blocks[14] - 1416354905; + c = (c << 15 | c >>> 17) + d << 0; + b += (d ^ (c | ~a)) + blocks[5] - 57434055; + b = (b << 21 | b >>> 11) + c << 0; + a += (c ^ (b | ~d)) + blocks[12] + 1700485571; + a = (a << 6 | a >>> 26) + b << 0; + d += (b ^ (a | ~c)) + blocks[3] - 1894986606; + d = (d << 10 | d >>> 22) + a << 0; + c += (a ^ (d | ~b)) + blocks[10] - 1051523; + c = (c << 15 | c >>> 17) + d << 0; + b += (d ^ (c | ~a)) + blocks[1] - 2054922799; + b = (b << 21 | b >>> 11) + c << 0; + a += (c ^ (b | ~d)) + blocks[8] + 1873313359; + a = (a << 6 | a >>> 26) + b << 0; + d += (b ^ (a | ~c)) + blocks[15] - 30611744; + d = (d << 10 | d >>> 22) + a << 0; + c += (a ^ (d | ~b)) + blocks[6] - 1560198380; + c = (c << 15 | c >>> 17) + d << 0; + b += (d ^ (c | ~a)) + blocks[13] + 1309151649; + b = (b << 21 | b >>> 11) + c << 0; + a += (c ^ (b | ~d)) + blocks[4] - 145523070; + a = (a << 6 | a >>> 26) + b << 0; + d += (b ^ (a | ~c)) + blocks[11] - 1120210379; + d = (d << 10 | d >>> 22) + a << 0; + c += (a ^ (d | ~b)) + blocks[2] + 718787259; + c = (c << 15 | c >>> 17) + d << 0; + b += (d ^ (c | ~a)) + blocks[9] - 343485551; + b = (b << 21 | b >>> 11) + c << 0; + + if (this.first) { + this.h0 = a + 1732584193 << 0; + this.h1 = b - 271733879 << 0; + this.h2 = c - 1732584194 << 0; + this.h3 = d + 271733878 << 0; + this.first = false; + } else { + this.h0 = this.h0 + a << 0; + this.h1 = this.h1 + b << 0; + this.h2 = this.h2 + c << 0; + this.h3 = this.h3 + d << 0; + } + }; + + /** + * @method hex + * @memberof Md5 + * @instance + * @description Output hash as hex string + * @returns {String} Hex string + * @see {@link md5.hex} + * @example + * hash.hex(); + */ + Md5.prototype.hex = function () { + this.finalize(); + + var h0 = this.h0, h1 = this.h1, h2 = this.h2, h3 = this.h3; + + return HEX_CHARS[(h0 >>> 4) & 0x0F] + HEX_CHARS[h0 & 0x0F] + + HEX_CHARS[(h0 >>> 12) & 0x0F] + HEX_CHARS[(h0 >>> 8) & 0x0F] + + HEX_CHARS[(h0 >>> 20) & 0x0F] + HEX_CHARS[(h0 >>> 16) & 0x0F] + + HEX_CHARS[(h0 >>> 28) & 0x0F] + HEX_CHARS[(h0 >>> 24) & 0x0F] + + HEX_CHARS[(h1 >>> 4) & 0x0F] + HEX_CHARS[h1 & 0x0F] + + HEX_CHARS[(h1 >>> 12) & 0x0F] + HEX_CHARS[(h1 >>> 8) & 0x0F] + + HEX_CHARS[(h1 >>> 20) & 0x0F] + HEX_CHARS[(h1 >>> 16) & 0x0F] + + HEX_CHARS[(h1 >>> 28) & 0x0F] + HEX_CHARS[(h1 >>> 24) & 0x0F] + + HEX_CHARS[(h2 >>> 4) & 0x0F] + HEX_CHARS[h2 & 0x0F] + + HEX_CHARS[(h2 >>> 12) & 0x0F] + HEX_CHARS[(h2 >>> 8) & 0x0F] + + HEX_CHARS[(h2 >>> 20) & 0x0F] + HEX_CHARS[(h2 >>> 16) & 0x0F] + + HEX_CHARS[(h2 >>> 28) & 0x0F] + HEX_CHARS[(h2 >>> 24) & 0x0F] + + HEX_CHARS[(h3 >>> 4) & 0x0F] + HEX_CHARS[h3 & 0x0F] + + HEX_CHARS[(h3 >>> 12) & 0x0F] + HEX_CHARS[(h3 >>> 8) & 0x0F] + + HEX_CHARS[(h3 >>> 20) & 0x0F] + HEX_CHARS[(h3 >>> 16) & 0x0F] + + HEX_CHARS[(h3 >>> 28) & 0x0F] + HEX_CHARS[(h3 >>> 24) & 0x0F]; + }; + + /** + * @method toString + * @memberof Md5 + * @instance + * @description Output hash as hex string + * @returns {String} Hex string + * @see {@link md5.hex} + * @example + * hash.toString(); + */ + Md5.prototype.toString = Md5.prototype.hex; + + /** + * @method digest + * @memberof Md5 + * @instance + * @description Output hash as bytes array + * @returns {Array} Bytes array + * @see {@link md5.digest} + * @example + * hash.digest(); + */ + Md5.prototype.digest = function () { + this.finalize(); + + var h0 = this.h0, h1 = this.h1, h2 = this.h2, h3 = this.h3; + return [ + h0 & 0xFF, (h0 >>> 8) & 0xFF, (h0 >>> 16) & 0xFF, (h0 >>> 24) & 0xFF, + h1 & 0xFF, (h1 >>> 8) & 0xFF, (h1 >>> 16) & 0xFF, (h1 >>> 24) & 0xFF, + h2 & 0xFF, (h2 >>> 8) & 0xFF, (h2 >>> 16) & 0xFF, (h2 >>> 24) & 0xFF, + h3 & 0xFF, (h3 >>> 8) & 0xFF, (h3 >>> 16) & 0xFF, (h3 >>> 24) & 0xFF + ]; + }; + + /** + * @method array + * @memberof Md5 + * @instance + * @description Output hash as bytes array + * @returns {Array} Bytes array + * @see {@link md5.array} + * @example + * hash.array(); + */ + Md5.prototype.array = Md5.prototype.digest; + + /** + * @method arrayBuffer + * @memberof Md5 + * @instance + * @description Output hash as ArrayBuffer + * @returns {ArrayBuffer} ArrayBuffer + * @see {@link md5.arrayBuffer} + * @example + * hash.arrayBuffer(); + */ + Md5.prototype.arrayBuffer = function () { + this.finalize(); + + var buffer = new ArrayBuffer(16); + var blocks = new Uint32Array(buffer); + blocks[0] = this.h0; + blocks[1] = this.h1; + blocks[2] = this.h2; + blocks[3] = this.h3; + return buffer; + }; + + /** + * @method buffer + * @deprecated This maybe confuse with Buffer in node.js. Please use arrayBuffer instead. + * @memberof Md5 + * @instance + * @description Output hash as ArrayBuffer + * @returns {ArrayBuffer} ArrayBuffer + * @see {@link md5.buffer} + * @example + * hash.buffer(); + */ + Md5.prototype.buffer = Md5.prototype.arrayBuffer; + + /** + * @method base64 + * @memberof Md5 + * @instance + * @description Output hash as base64 string + * @returns {String} base64 string + * @see {@link md5.base64} + * @example + * hash.base64(); + */ + Md5.prototype.base64 = function () { + var v1, v2, v3, base64Str = '', bytes = this.array(); + for (var i = 0; i < 15;) { + v1 = bytes[i++]; + v2 = bytes[i++]; + v3 = bytes[i++]; + base64Str += BASE64_ENCODE_CHAR[v1 >>> 2] + + BASE64_ENCODE_CHAR[(v1 << 4 | v2 >>> 4) & 63] + + BASE64_ENCODE_CHAR[(v2 << 2 | v3 >>> 6) & 63] + + BASE64_ENCODE_CHAR[v3 & 63]; + } + v1 = bytes[i]; + base64Str += BASE64_ENCODE_CHAR[v1 >>> 2] + + BASE64_ENCODE_CHAR[(v1 << 4) & 63] + + '=='; + return base64Str; + }; + + /** + * HmacMd5 class + * @class HmacMd5 + * @extends Md5 + * @description This is internal class. + * @see {@link md5.hmac.create} + */ + function HmacMd5(key, sharedMemory) { + var i, result = formatMessage(key); + key = result[0]; + if (result[1]) { + var bytes = [], length = key.length, index = 0, code; + for (i = 0; i < length; ++i) { + code = key.charCodeAt(i); + if (code < 0x80) { + bytes[index++] = code; + } else if (code < 0x800) { + bytes[index++] = (0xc0 | (code >>> 6)); + bytes[index++] = (0x80 | (code & 0x3f)); + } else if (code < 0xd800 || code >= 0xe000) { + bytes[index++] = (0xe0 | (code >>> 12)); + bytes[index++] = (0x80 | ((code >>> 6) & 0x3f)); + bytes[index++] = (0x80 | (code & 0x3f)); + } else { + code = 0x10000 + (((code & 0x3ff) << 10) | (key.charCodeAt(++i) & 0x3ff)); + bytes[index++] = (0xf0 | (code >>> 18)); + bytes[index++] = (0x80 | ((code >>> 12) & 0x3f)); + bytes[index++] = (0x80 | ((code >>> 6) & 0x3f)); + bytes[index++] = (0x80 | (code & 0x3f)); + } + } + key = bytes; + } + + if (key.length > 64) { + key = (new Md5(true)).update(key).array(); + } + + var oKeyPad = [], iKeyPad = []; + for (i = 0; i < 64; ++i) { + var b = key[i] || 0; + oKeyPad[i] = 0x5c ^ b; + iKeyPad[i] = 0x36 ^ b; + } + + Md5.call(this, sharedMemory); + + this.update(iKeyPad); + this.oKeyPad = oKeyPad; + this.inner = true; + this.sharedMemory = sharedMemory; + } + HmacMd5.prototype = new Md5(); + + HmacMd5.prototype.finalize = function () { + Md5.prototype.finalize.call(this); + if (this.inner) { + this.inner = false; + var innerHash = this.array(); + Md5.call(this, this.sharedMemory); + this.update(this.oKeyPad); + this.update(innerHash); + Md5.prototype.finalize.call(this); + } + }; + + var exports = createMethod(); + exports.md5 = exports; + exports.md5.hmac = createHmacMethod(); + + if (COMMON_JS) { + module.exports = exports; + } else { + /** + * @method md5 + * @description Md5 hash function, export to global in browsers. + * @param {String|Array|Uint8Array|ArrayBuffer} message message to hash + * @returns {String} md5 hashes + * @example + * md5(''); // d41d8cd98f00b204e9800998ecf8427e + * md5('The quick brown fox jumps over the lazy dog'); // 9e107d9d372bb6826bd81d3542a419d6 + * md5('The quick brown fox jumps over the lazy dog.'); // e4d909c290d0fb1ca068ffaddf22cbd0 + * + * // It also supports UTF-8 encoding + * md5('涓枃'); // a7bac2239fcdcb3a067903d8077c4a07 + * + * // It also supports byte `Array`, `Uint8Array`, `ArrayBuffer` + * md5([]); // d41d8cd98f00b204e9800998ecf8427e + * md5(new Uint8Array([])); // d41d8cd98f00b204e9800998ecf8427e + */ + root.md5 = exports; + if (AMD) { + define(function () { + return exports; + }); + } + } +})(); + +}, function(modId) {var map = {}; return __REQUIRE__(map[modId], modId); }) +return __REQUIRE__(1718586298039); +})() +//miniprogram-npm-outsideDeps=["crypto","buffer"] +//# sourceMappingURL=index.js.map \ No newline at end of file diff --git a/miniprogram_npm/js-md5/index.js.map b/miniprogram_npm/js-md5/index.js.map new file mode 100644 index 0000000..f574fbc --- /dev/null +++ b/miniprogram_npm/js-md5/index.js.map @@ -0,0 +1 @@ +{"version":3,"sources":["md5.js"],"names":[],"mappings":";;;;;;;AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA","file":"index.js","sourcesContent":["/**\n * [js-md5]{@link https://github.com/emn178/js-md5}\n *\n * @namespace md5\n * @version 0.8.3\n * @author Chen, Yi-Cyuan [emn178@gmail.com]\n * @copyright Chen, Yi-Cyuan 2014-2023\n * @license MIT\n */\n(function () {\n \n\n var INPUT_ERROR = 'input is invalid type';\n var FINALIZE_ERROR = 'finalize already called';\n var WINDOW = typeof window === 'object';\n var root = WINDOW ? window : {};\n if (root.JS_MD5_NO_WINDOW) {\n WINDOW = false;\n }\n var WEB_WORKER = !WINDOW && typeof self === 'object';\n var NODE_JS = !root.JS_MD5_NO_NODE_JS && typeof process === 'object' && process.versions && process.versions.node;\n if (NODE_JS) {\n root = global;\n } else if (WEB_WORKER) {\n root = self;\n }\n var COMMON_JS = !root.JS_MD5_NO_COMMON_JS && typeof module === 'object' && module.exports;\n var AMD = typeof define === 'function' && define.amd;\n var ARRAY_BUFFER = !root.JS_MD5_NO_ARRAY_BUFFER && typeof ArrayBuffer !== 'undefined';\n var HEX_CHARS = '0123456789abcdef'.split('');\n var EXTRA = [128, 32768, 8388608, -2147483648];\n var SHIFT = [0, 8, 16, 24];\n var OUTPUT_TYPES = ['hex', 'array', 'digest', 'buffer', 'arrayBuffer', 'base64'];\n var BASE64_ENCODE_CHAR = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/'.split('');\n\n var blocks = [], buffer8;\n if (ARRAY_BUFFER) {\n var buffer = new ArrayBuffer(68);\n buffer8 = new Uint8Array(buffer);\n blocks = new Uint32Array(buffer);\n }\n\n var isArray = Array.isArray;\n if (root.JS_MD5_NO_NODE_JS || !isArray) {\n isArray = function (obj) {\n return Object.prototype.toString.call(obj) === '[object Array]';\n };\n }\n\n var isView = ArrayBuffer.isView;\n if (ARRAY_BUFFER && (root.JS_MD5_NO_ARRAY_BUFFER_IS_VIEW || !isView)) {\n isView = function (obj) {\n return typeof obj === 'object' && obj.buffer && obj.buffer.constructor === ArrayBuffer;\n };\n }\n\n // [message: string, isString: bool]\n var formatMessage = function (message) {\n var type = typeof message;\n if (type === 'string') {\n return [message, true];\n }\n if (type !== 'object' || message === null) {\n throw new Error(INPUT_ERROR);\n }\n if (ARRAY_BUFFER && message.constructor === ArrayBuffer) {\n return [new Uint8Array(message), false];\n }\n if (!isArray(message) && !isView(message)) {\n throw new Error(INPUT_ERROR);\n }\n return [message, false];\n }\n\n /**\n * @method hex\n * @memberof md5\n * @description Output hash as hex string\n * @param {String|Array|Uint8Array|ArrayBuffer} message message to hash\n * @returns {String} Hex string\n * @example\n * md5.hex('The quick brown fox jumps over the lazy dog');\n * // equal to\n * md5('The quick brown fox jumps over the lazy dog');\n */\n /**\n * @method digest\n * @memberof md5\n * @description Output hash as bytes array\n * @param {String|Array|Uint8Array|ArrayBuffer} message message to hash\n * @returns {Array} Bytes array\n * @example\n * md5.digest('The quick brown fox jumps over the lazy dog');\n */\n /**\n * @method array\n * @memberof md5\n * @description Output hash as bytes array\n * @param {String|Array|Uint8Array|ArrayBuffer} message message to hash\n * @returns {Array} Bytes array\n * @example\n * md5.array('The quick brown fox jumps over the lazy dog');\n */\n /**\n * @method arrayBuffer\n * @memberof md5\n * @description Output hash as ArrayBuffer\n * @param {String|Array|Uint8Array|ArrayBuffer} message message to hash\n * @returns {ArrayBuffer} ArrayBuffer\n * @example\n * md5.arrayBuffer('The quick brown fox jumps over the lazy dog');\n */\n /**\n * @method buffer\n * @deprecated This maybe confuse with Buffer in node.js. Please use arrayBuffer instead.\n * @memberof md5\n * @description Output hash as ArrayBuffer\n * @param {String|Array|Uint8Array|ArrayBuffer} message message to hash\n * @returns {ArrayBuffer} ArrayBuffer\n * @example\n * md5.buffer('The quick brown fox jumps over the lazy dog');\n */\n /**\n * @method base64\n * @memberof md5\n * @description Output hash as base64 string\n * @param {String|Array|Uint8Array|ArrayBuffer} message message to hash\n * @returns {String} base64 string\n * @example\n * md5.base64('The quick brown fox jumps over the lazy dog');\n */\n var createOutputMethod = function (outputType) {\n return function (message) {\n return new Md5(true).update(message)[outputType]();\n };\n };\n\n /**\n * @method create\n * @memberof md5\n * @description Create Md5 object\n * @returns {Md5} Md5 object.\n * @example\n * var hash = md5.create();\n */\n /**\n * @method update\n * @memberof md5\n * @description Create and update Md5 object\n * @param {String|Array|Uint8Array|ArrayBuffer} message message to hash\n * @returns {Md5} Md5 object.\n * @example\n * var hash = md5.update('The quick brown fox jumps over the lazy dog');\n * // equal to\n * var hash = md5.create();\n * hash.update('The quick brown fox jumps over the lazy dog');\n */\n var createMethod = function () {\n var method = createOutputMethod('hex');\n if (NODE_JS) {\n method = nodeWrap(method);\n }\n method.create = function () {\n return new Md5();\n };\n method.update = function (message) {\n return method.create().update(message);\n };\n for (var i = 0; i < OUTPUT_TYPES.length; ++i) {\n var type = OUTPUT_TYPES[i];\n method[type] = createOutputMethod(type);\n }\n return method;\n };\n\n var nodeWrap = function (method) {\n var crypto = require('crypto')\n var Buffer = require('buffer').Buffer;\n var bufferFrom;\n if (Buffer.from && !root.JS_MD5_NO_BUFFER_FROM) {\n bufferFrom = Buffer.from;\n } else {\n bufferFrom = function (message) {\n return new Buffer(message);\n };\n }\n var nodeMethod = function (message) {\n if (typeof message === 'string') {\n return crypto.createHash('md5').update(message, 'utf8').digest('hex');\n } else {\n if (message === null || message === undefined) {\n throw new Error(INPUT_ERROR);\n } else if (message.constructor === ArrayBuffer) {\n message = new Uint8Array(message);\n }\n }\n if (isArray(message) || isView(message) ||\n message.constructor === Buffer) {\n return crypto.createHash('md5').update(bufferFrom(message)).digest('hex');\n } else {\n return method(message);\n }\n };\n return nodeMethod;\n };\n\n /**\n * @namespace md5.hmac\n */\n /**\n * @method hex\n * @memberof md5.hmac\n * @description Output hash as hex string\n * @param {String|Array|Uint8Array|ArrayBuffer} key key\n * @param {String|Array|Uint8Array|ArrayBuffer} message message to hash\n * @returns {String} Hex string\n * @example\n * md5.hmac.hex('key', 'The quick brown fox jumps over the lazy dog');\n * // equal to\n * md5.hmac('key', 'The quick brown fox jumps over the lazy dog');\n */\n\n /**\n * @method digest\n * @memberof md5.hmac\n * @description Output hash as bytes array\n * @param {String|Array|Uint8Array|ArrayBuffer} key key\n * @param {String|Array|Uint8Array|ArrayBuffer} message message to hash\n * @returns {Array} Bytes array\n * @example\n * md5.hmac.digest('key', 'The quick brown fox jumps over the lazy dog');\n */\n /**\n * @method array\n * @memberof md5.hmac\n * @description Output hash as bytes array\n * @param {String|Array|Uint8Array|ArrayBuffer} key key\n * @param {String|Array|Uint8Array|ArrayBuffer} message message to hash\n * @returns {Array} Bytes array\n * @example\n * md5.hmac.array('key', 'The quick brown fox jumps over the lazy dog');\n */\n /**\n * @method arrayBuffer\n * @memberof md5.hmac\n * @description Output hash as ArrayBuffer\n * @param {String|Array|Uint8Array|ArrayBuffer} key key\n * @param {String|Array|Uint8Array|ArrayBuffer} message message to hash\n * @returns {ArrayBuffer} ArrayBuffer\n * @example\n * md5.hmac.arrayBuffer('key', 'The quick brown fox jumps over the lazy dog');\n */\n /**\n * @method buffer\n * @deprecated This maybe confuse with Buffer in node.js. Please use arrayBuffer instead.\n * @memberof md5.hmac\n * @description Output hash as ArrayBuffer\n * @param {String|Array|Uint8Array|ArrayBuffer} key key\n * @param {String|Array|Uint8Array|ArrayBuffer} message message to hash\n * @returns {ArrayBuffer} ArrayBuffer\n * @example\n * md5.hmac.buffer('key', 'The quick brown fox jumps over the lazy dog');\n */\n /**\n * @method base64\n * @memberof md5.hmac\n * @description Output hash as base64 string\n * @param {String|Array|Uint8Array|ArrayBuffer} key key\n * @param {String|Array|Uint8Array|ArrayBuffer} message message to hash\n * @returns {String} base64 string\n * @example\n * md5.hmac.base64('key', 'The quick brown fox jumps over the lazy dog');\n */\n var createHmacOutputMethod = function (outputType) {\n return function (key, message) {\n return new HmacMd5(key, true).update(message)[outputType]();\n };\n };\n\n /**\n * @method create\n * @memberof md5.hmac\n * @description Create HmacMd5 object\n * @param {String|Array|Uint8Array|ArrayBuffer} key key\n * @returns {HmacMd5} HmacMd5 object.\n * @example\n * var hash = md5.hmac.create('key');\n */\n /**\n * @method update\n * @memberof md5.hmac\n * @description Create and update HmacMd5 object\n * @param {String|Array|Uint8Array|ArrayBuffer} key key\n * @param {String|Array|Uint8Array|ArrayBuffer} message message to hash\n * @returns {HmacMd5} HmacMd5 object.\n * @example\n * var hash = md5.hmac.update('key', 'The quick brown fox jumps over the lazy dog');\n * // equal to\n * var hash = md5.hmac.create('key');\n * hash.update('The quick brown fox jumps over the lazy dog');\n */\n var createHmacMethod = function () {\n var method = createHmacOutputMethod('hex');\n method.create = function (key) {\n return new HmacMd5(key);\n };\n method.update = function (key, message) {\n return method.create(key).update(message);\n };\n for (var i = 0; i < OUTPUT_TYPES.length; ++i) {\n var type = OUTPUT_TYPES[i];\n method[type] = createHmacOutputMethod(type);\n }\n return method;\n };\n\n /**\n * Md5 class\n * @class Md5\n * @description This is internal class.\n * @see {@link md5.create}\n */\n function Md5(sharedMemory) {\n if (sharedMemory) {\n blocks[0] = blocks[16] = blocks[1] = blocks[2] = blocks[3] =\n blocks[4] = blocks[5] = blocks[6] = blocks[7] =\n blocks[8] = blocks[9] = blocks[10] = blocks[11] =\n blocks[12] = blocks[13] = blocks[14] = blocks[15] = 0;\n this.blocks = blocks;\n this.buffer8 = buffer8;\n } else {\n if (ARRAY_BUFFER) {\n var buffer = new ArrayBuffer(68);\n this.buffer8 = new Uint8Array(buffer);\n this.blocks = new Uint32Array(buffer);\n } else {\n this.blocks = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0];\n }\n }\n this.h0 = this.h1 = this.h2 = this.h3 = this.start = this.bytes = this.hBytes = 0;\n this.finalized = this.hashed = false;\n this.first = true;\n }\n\n /**\n * @method update\n * @memberof Md5\n * @instance\n * @description Update hash\n * @param {String|Array|Uint8Array|ArrayBuffer} message message to hash\n * @returns {Md5} Md5 object.\n * @see {@link md5.update}\n */\n Md5.prototype.update = function (message) {\n if (this.finalized) {\n throw new Error(FINALIZE_ERROR);\n }\n\n var result = formatMessage(message);\n message = result[0];\n var isString = result[1];\n var code, index = 0, i, length = message.length, blocks = this.blocks;\n var buffer8 = this.buffer8;\n\n while (index < length) {\n if (this.hashed) {\n this.hashed = false;\n blocks[0] = blocks[16];\n blocks[16] = blocks[1] = blocks[2] = blocks[3] =\n blocks[4] = blocks[5] = blocks[6] = blocks[7] =\n blocks[8] = blocks[9] = blocks[10] = blocks[11] =\n blocks[12] = blocks[13] = blocks[14] = blocks[15] = 0;\n }\n\n if (isString) {\n if (ARRAY_BUFFER) {\n for (i = this.start; index < length && i < 64; ++index) {\n code = message.charCodeAt(index);\n if (code < 0x80) {\n buffer8[i++] = code;\n } else if (code < 0x800) {\n buffer8[i++] = 0xc0 | (code >>> 6);\n buffer8[i++] = 0x80 | (code & 0x3f);\n } else if (code < 0xd800 || code >= 0xe000) {\n buffer8[i++] = 0xe0 | (code >>> 12);\n buffer8[i++] = 0x80 | ((code >>> 6) & 0x3f);\n buffer8[i++] = 0x80 | (code & 0x3f);\n } else {\n code = 0x10000 + (((code & 0x3ff) << 10) | (message.charCodeAt(++index) & 0x3ff));\n buffer8[i++] = 0xf0 | (code >>> 18);\n buffer8[i++] = 0x80 | ((code >>> 12) & 0x3f);\n buffer8[i++] = 0x80 | ((code >>> 6) & 0x3f);\n buffer8[i++] = 0x80 | (code & 0x3f);\n }\n }\n } else {\n for (i = this.start; index < length && i < 64; ++index) {\n code = message.charCodeAt(index);\n if (code < 0x80) {\n blocks[i >>> 2] |= code << SHIFT[i++ & 3];\n } else if (code < 0x800) {\n blocks[i >>> 2] |= (0xc0 | (code >>> 6)) << SHIFT[i++ & 3];\n blocks[i >>> 2] |= (0x80 | (code & 0x3f)) << SHIFT[i++ & 3];\n } else if (code < 0xd800 || code >= 0xe000) {\n blocks[i >>> 2] |= (0xe0 | (code >>> 12)) << SHIFT[i++ & 3];\n blocks[i >>> 2] |= (0x80 | ((code >>> 6) & 0x3f)) << SHIFT[i++ & 3];\n blocks[i >>> 2] |= (0x80 | (code & 0x3f)) << SHIFT[i++ & 3];\n } else {\n code = 0x10000 + (((code & 0x3ff) << 10) | (message.charCodeAt(++index) & 0x3ff));\n blocks[i >>> 2] |= (0xf0 | (code >>> 18)) << SHIFT[i++ & 3];\n blocks[i >>> 2] |= (0x80 | ((code >>> 12) & 0x3f)) << SHIFT[i++ & 3];\n blocks[i >>> 2] |= (0x80 | ((code >>> 6) & 0x3f)) << SHIFT[i++ & 3];\n blocks[i >>> 2] |= (0x80 | (code & 0x3f)) << SHIFT[i++ & 3];\n }\n }\n }\n } else {\n if (ARRAY_BUFFER) {\n for (i = this.start; index < length && i < 64; ++index) {\n buffer8[i++] = message[index];\n }\n } else {\n for (i = this.start; index < length && i < 64; ++index) {\n blocks[i >>> 2] |= message[index] << SHIFT[i++ & 3];\n }\n }\n }\n this.lastByteIndex = i;\n this.bytes += i - this.start;\n if (i >= 64) {\n this.start = i - 64;\n this.hash();\n this.hashed = true;\n } else {\n this.start = i;\n }\n }\n if (this.bytes > 4294967295) {\n this.hBytes += this.bytes / 4294967296 << 0;\n this.bytes = this.bytes % 4294967296;\n }\n return this;\n };\n\n Md5.prototype.finalize = function () {\n if (this.finalized) {\n return;\n }\n this.finalized = true;\n var blocks = this.blocks, i = this.lastByteIndex;\n blocks[i >>> 2] |= EXTRA[i & 3];\n if (i >= 56) {\n if (!this.hashed) {\n this.hash();\n }\n blocks[0] = blocks[16];\n blocks[16] = blocks[1] = blocks[2] = blocks[3] =\n blocks[4] = blocks[5] = blocks[6] = blocks[7] =\n blocks[8] = blocks[9] = blocks[10] = blocks[11] =\n blocks[12] = blocks[13] = blocks[14] = blocks[15] = 0;\n }\n blocks[14] = this.bytes << 3;\n blocks[15] = this.hBytes << 3 | this.bytes >>> 29;\n this.hash();\n };\n\n Md5.prototype.hash = function () {\n var a, b, c, d, bc, da, blocks = this.blocks;\n\n if (this.first) {\n a = blocks[0] - 680876937;\n a = (a << 7 | a >>> 25) - 271733879 << 0;\n d = (-1732584194 ^ a & 2004318071) + blocks[1] - 117830708;\n d = (d << 12 | d >>> 20) + a << 0;\n c = (-271733879 ^ (d & (a ^ -271733879))) + blocks[2] - 1126478375;\n c = (c << 17 | c >>> 15) + d << 0;\n b = (a ^ (c & (d ^ a))) + blocks[3] - 1316259209;\n b = (b << 22 | b >>> 10) + c << 0;\n } else {\n a = this.h0;\n b = this.h1;\n c = this.h2;\n d = this.h3;\n a += (d ^ (b & (c ^ d))) + blocks[0] - 680876936;\n a = (a << 7 | a >>> 25) + b << 0;\n d += (c ^ (a & (b ^ c))) + blocks[1] - 389564586;\n d = (d << 12 | d >>> 20) + a << 0;\n c += (b ^ (d & (a ^ b))) + blocks[2] + 606105819;\n c = (c << 17 | c >>> 15) + d << 0;\n b += (a ^ (c & (d ^ a))) + blocks[3] - 1044525330;\n b = (b << 22 | b >>> 10) + c << 0;\n }\n\n a += (d ^ (b & (c ^ d))) + blocks[4] - 176418897;\n a = (a << 7 | a >>> 25) + b << 0;\n d += (c ^ (a & (b ^ c))) + blocks[5] + 1200080426;\n d = (d << 12 | d >>> 20) + a << 0;\n c += (b ^ (d & (a ^ b))) + blocks[6] - 1473231341;\n c = (c << 17 | c >>> 15) + d << 0;\n b += (a ^ (c & (d ^ a))) + blocks[7] - 45705983;\n b = (b << 22 | b >>> 10) + c << 0;\n a += (d ^ (b & (c ^ d))) + blocks[8] + 1770035416;\n a = (a << 7 | a >>> 25) + b << 0;\n d += (c ^ (a & (b ^ c))) + blocks[9] - 1958414417;\n d = (d << 12 | d >>> 20) + a << 0;\n c += (b ^ (d & (a ^ b))) + blocks[10] - 42063;\n c = (c << 17 | c >>> 15) + d << 0;\n b += (a ^ (c & (d ^ a))) + blocks[11] - 1990404162;\n b = (b << 22 | b >>> 10) + c << 0;\n a += (d ^ (b & (c ^ d))) + blocks[12] + 1804603682;\n a = (a << 7 | a >>> 25) + b << 0;\n d += (c ^ (a & (b ^ c))) + blocks[13] - 40341101;\n d = (d << 12 | d >>> 20) + a << 0;\n c += (b ^ (d & (a ^ b))) + blocks[14] - 1502002290;\n c = (c << 17 | c >>> 15) + d << 0;\n b += (a ^ (c & (d ^ a))) + blocks[15] + 1236535329;\n b = (b << 22 | b >>> 10) + c << 0;\n a += (c ^ (d & (b ^ c))) + blocks[1] - 165796510;\n a = (a << 5 | a >>> 27) + b << 0;\n d += (b ^ (c & (a ^ b))) + blocks[6] - 1069501632;\n d = (d << 9 | d >>> 23) + a << 0;\n c += (a ^ (b & (d ^ a))) + blocks[11] + 643717713;\n c = (c << 14 | c >>> 18) + d << 0;\n b += (d ^ (a & (c ^ d))) + blocks[0] - 373897302;\n b = (b << 20 | b >>> 12) + c << 0;\n a += (c ^ (d & (b ^ c))) + blocks[5] - 701558691;\n a = (a << 5 | a >>> 27) + b << 0;\n d += (b ^ (c & (a ^ b))) + blocks[10] + 38016083;\n d = (d << 9 | d >>> 23) + a << 0;\n c += (a ^ (b & (d ^ a))) + blocks[15] - 660478335;\n c = (c << 14 | c >>> 18) + d << 0;\n b += (d ^ (a & (c ^ d))) + blocks[4] - 405537848;\n b = (b << 20 | b >>> 12) + c << 0;\n a += (c ^ (d & (b ^ c))) + blocks[9] + 568446438;\n a = (a << 5 | a >>> 27) + b << 0;\n d += (b ^ (c & (a ^ b))) + blocks[14] - 1019803690;\n d = (d << 9 | d >>> 23) + a << 0;\n c += (a ^ (b & (d ^ a))) + blocks[3] - 187363961;\n c = (c << 14 | c >>> 18) + d << 0;\n b += (d ^ (a & (c ^ d))) + blocks[8] + 1163531501;\n b = (b << 20 | b >>> 12) + c << 0;\n a += (c ^ (d & (b ^ c))) + blocks[13] - 1444681467;\n a = (a << 5 | a >>> 27) + b << 0;\n d += (b ^ (c & (a ^ b))) + blocks[2] - 51403784;\n d = (d << 9 | d >>> 23) + a << 0;\n c += (a ^ (b & (d ^ a))) + blocks[7] + 1735328473;\n c = (c << 14 | c >>> 18) + d << 0;\n b += (d ^ (a & (c ^ d))) + blocks[12] - 1926607734;\n b = (b << 20 | b >>> 12) + c << 0;\n bc = b ^ c;\n a += (bc ^ d) + blocks[5] - 378558;\n a = (a << 4 | a >>> 28) + b << 0;\n d += (bc ^ a) + blocks[8] - 2022574463;\n d = (d << 11 | d >>> 21) + a << 0;\n da = d ^ a;\n c += (da ^ b) + blocks[11] + 1839030562;\n c = (c << 16 | c >>> 16) + d << 0;\n b += (da ^ c) + blocks[14] - 35309556;\n b = (b << 23 | b >>> 9) + c << 0;\n bc = b ^ c;\n a += (bc ^ d) + blocks[1] - 1530992060;\n a = (a << 4 | a >>> 28) + b << 0;\n d += (bc ^ a) + blocks[4] + 1272893353;\n d = (d << 11 | d >>> 21) + a << 0;\n da = d ^ a;\n c += (da ^ b) + blocks[7] - 155497632;\n c = (c << 16 | c >>> 16) + d << 0;\n b += (da ^ c) + blocks[10] - 1094730640;\n b = (b << 23 | b >>> 9) + c << 0;\n bc = b ^ c;\n a += (bc ^ d) + blocks[13] + 681279174;\n a = (a << 4 | a >>> 28) + b << 0;\n d += (bc ^ a) + blocks[0] - 358537222;\n d = (d << 11 | d >>> 21) + a << 0;\n da = d ^ a;\n c += (da ^ b) + blocks[3] - 722521979;\n c = (c << 16 | c >>> 16) + d << 0;\n b += (da ^ c) + blocks[6] + 76029189;\n b = (b << 23 | b >>> 9) + c << 0;\n bc = b ^ c;\n a += (bc ^ d) + blocks[9] - 640364487;\n a = (a << 4 | a >>> 28) + b << 0;\n d += (bc ^ a) + blocks[12] - 421815835;\n d = (d << 11 | d >>> 21) + a << 0;\n da = d ^ a;\n c += (da ^ b) + blocks[15] + 530742520;\n c = (c << 16 | c >>> 16) + d << 0;\n b += (da ^ c) + blocks[2] - 995338651;\n b = (b << 23 | b >>> 9) + c << 0;\n a += (c ^ (b | ~d)) + blocks[0] - 198630844;\n a = (a << 6 | a >>> 26) + b << 0;\n d += (b ^ (a | ~c)) + blocks[7] + 1126891415;\n d = (d << 10 | d >>> 22) + a << 0;\n c += (a ^ (d | ~b)) + blocks[14] - 1416354905;\n c = (c << 15 | c >>> 17) + d << 0;\n b += (d ^ (c | ~a)) + blocks[5] - 57434055;\n b = (b << 21 | b >>> 11) + c << 0;\n a += (c ^ (b | ~d)) + blocks[12] + 1700485571;\n a = (a << 6 | a >>> 26) + b << 0;\n d += (b ^ (a | ~c)) + blocks[3] - 1894986606;\n d = (d << 10 | d >>> 22) + a << 0;\n c += (a ^ (d | ~b)) + blocks[10] - 1051523;\n c = (c << 15 | c >>> 17) + d << 0;\n b += (d ^ (c | ~a)) + blocks[1] - 2054922799;\n b = (b << 21 | b >>> 11) + c << 0;\n a += (c ^ (b | ~d)) + blocks[8] + 1873313359;\n a = (a << 6 | a >>> 26) + b << 0;\n d += (b ^ (a | ~c)) + blocks[15] - 30611744;\n d = (d << 10 | d >>> 22) + a << 0;\n c += (a ^ (d | ~b)) + blocks[6] - 1560198380;\n c = (c << 15 | c >>> 17) + d << 0;\n b += (d ^ (c | ~a)) + blocks[13] + 1309151649;\n b = (b << 21 | b >>> 11) + c << 0;\n a += (c ^ (b | ~d)) + blocks[4] - 145523070;\n a = (a << 6 | a >>> 26) + b << 0;\n d += (b ^ (a | ~c)) + blocks[11] - 1120210379;\n d = (d << 10 | d >>> 22) + a << 0;\n c += (a ^ (d | ~b)) + blocks[2] + 718787259;\n c = (c << 15 | c >>> 17) + d << 0;\n b += (d ^ (c | ~a)) + blocks[9] - 343485551;\n b = (b << 21 | b >>> 11) + c << 0;\n\n if (this.first) {\n this.h0 = a + 1732584193 << 0;\n this.h1 = b - 271733879 << 0;\n this.h2 = c - 1732584194 << 0;\n this.h3 = d + 271733878 << 0;\n this.first = false;\n } else {\n this.h0 = this.h0 + a << 0;\n this.h1 = this.h1 + b << 0;\n this.h2 = this.h2 + c << 0;\n this.h3 = this.h3 + d << 0;\n }\n };\n\n /**\n * @method hex\n * @memberof Md5\n * @instance\n * @description Output hash as hex string\n * @returns {String} Hex string\n * @see {@link md5.hex}\n * @example\n * hash.hex();\n */\n Md5.prototype.hex = function () {\n this.finalize();\n\n var h0 = this.h0, h1 = this.h1, h2 = this.h2, h3 = this.h3;\n\n return HEX_CHARS[(h0 >>> 4) & 0x0F] + HEX_CHARS[h0 & 0x0F] +\n HEX_CHARS[(h0 >>> 12) & 0x0F] + HEX_CHARS[(h0 >>> 8) & 0x0F] +\n HEX_CHARS[(h0 >>> 20) & 0x0F] + HEX_CHARS[(h0 >>> 16) & 0x0F] +\n HEX_CHARS[(h0 >>> 28) & 0x0F] + HEX_CHARS[(h0 >>> 24) & 0x0F] +\n HEX_CHARS[(h1 >>> 4) & 0x0F] + HEX_CHARS[h1 & 0x0F] +\n HEX_CHARS[(h1 >>> 12) & 0x0F] + HEX_CHARS[(h1 >>> 8) & 0x0F] +\n HEX_CHARS[(h1 >>> 20) & 0x0F] + HEX_CHARS[(h1 >>> 16) & 0x0F] +\n HEX_CHARS[(h1 >>> 28) & 0x0F] + HEX_CHARS[(h1 >>> 24) & 0x0F] +\n HEX_CHARS[(h2 >>> 4) & 0x0F] + HEX_CHARS[h2 & 0x0F] +\n HEX_CHARS[(h2 >>> 12) & 0x0F] + HEX_CHARS[(h2 >>> 8) & 0x0F] +\n HEX_CHARS[(h2 >>> 20) & 0x0F] + HEX_CHARS[(h2 >>> 16) & 0x0F] +\n HEX_CHARS[(h2 >>> 28) & 0x0F] + HEX_CHARS[(h2 >>> 24) & 0x0F] +\n HEX_CHARS[(h3 >>> 4) & 0x0F] + HEX_CHARS[h3 & 0x0F] +\n HEX_CHARS[(h3 >>> 12) & 0x0F] + HEX_CHARS[(h3 >>> 8) & 0x0F] +\n HEX_CHARS[(h3 >>> 20) & 0x0F] + HEX_CHARS[(h3 >>> 16) & 0x0F] +\n HEX_CHARS[(h3 >>> 28) & 0x0F] + HEX_CHARS[(h3 >>> 24) & 0x0F];\n };\n\n /**\n * @method toString\n * @memberof Md5\n * @instance\n * @description Output hash as hex string\n * @returns {String} Hex string\n * @see {@link md5.hex}\n * @example\n * hash.toString();\n */\n Md5.prototype.toString = Md5.prototype.hex;\n\n /**\n * @method digest\n * @memberof Md5\n * @instance\n * @description Output hash as bytes array\n * @returns {Array} Bytes array\n * @see {@link md5.digest}\n * @example\n * hash.digest();\n */\n Md5.prototype.digest = function () {\n this.finalize();\n\n var h0 = this.h0, h1 = this.h1, h2 = this.h2, h3 = this.h3;\n return [\n h0 & 0xFF, (h0 >>> 8) & 0xFF, (h0 >>> 16) & 0xFF, (h0 >>> 24) & 0xFF,\n h1 & 0xFF, (h1 >>> 8) & 0xFF, (h1 >>> 16) & 0xFF, (h1 >>> 24) & 0xFF,\n h2 & 0xFF, (h2 >>> 8) & 0xFF, (h2 >>> 16) & 0xFF, (h2 >>> 24) & 0xFF,\n h3 & 0xFF, (h3 >>> 8) & 0xFF, (h3 >>> 16) & 0xFF, (h3 >>> 24) & 0xFF\n ];\n };\n\n /**\n * @method array\n * @memberof Md5\n * @instance\n * @description Output hash as bytes array\n * @returns {Array} Bytes array\n * @see {@link md5.array}\n * @example\n * hash.array();\n */\n Md5.prototype.array = Md5.prototype.digest;\n\n /**\n * @method arrayBuffer\n * @memberof Md5\n * @instance\n * @description Output hash as ArrayBuffer\n * @returns {ArrayBuffer} ArrayBuffer\n * @see {@link md5.arrayBuffer}\n * @example\n * hash.arrayBuffer();\n */\n Md5.prototype.arrayBuffer = function () {\n this.finalize();\n\n var buffer = new ArrayBuffer(16);\n var blocks = new Uint32Array(buffer);\n blocks[0] = this.h0;\n blocks[1] = this.h1;\n blocks[2] = this.h2;\n blocks[3] = this.h3;\n return buffer;\n };\n\n /**\n * @method buffer\n * @deprecated This maybe confuse with Buffer in node.js. Please use arrayBuffer instead.\n * @memberof Md5\n * @instance\n * @description Output hash as ArrayBuffer\n * @returns {ArrayBuffer} ArrayBuffer\n * @see {@link md5.buffer}\n * @example\n * hash.buffer();\n */\n Md5.prototype.buffer = Md5.prototype.arrayBuffer;\n\n /**\n * @method base64\n * @memberof Md5\n * @instance\n * @description Output hash as base64 string\n * @returns {String} base64 string\n * @see {@link md5.base64}\n * @example\n * hash.base64();\n */\n Md5.prototype.base64 = function () {\n var v1, v2, v3, base64Str = '', bytes = this.array();\n for (var i = 0; i < 15;) {\n v1 = bytes[i++];\n v2 = bytes[i++];\n v3 = bytes[i++];\n base64Str += BASE64_ENCODE_CHAR[v1 >>> 2] +\n BASE64_ENCODE_CHAR[(v1 << 4 | v2 >>> 4) & 63] +\n BASE64_ENCODE_CHAR[(v2 << 2 | v3 >>> 6) & 63] +\n BASE64_ENCODE_CHAR[v3 & 63];\n }\n v1 = bytes[i];\n base64Str += BASE64_ENCODE_CHAR[v1 >>> 2] +\n BASE64_ENCODE_CHAR[(v1 << 4) & 63] +\n '==';\n return base64Str;\n };\n\n /**\n * HmacMd5 class\n * @class HmacMd5\n * @extends Md5\n * @description This is internal class.\n * @see {@link md5.hmac.create}\n */\n function HmacMd5(key, sharedMemory) {\n var i, result = formatMessage(key);\n key = result[0];\n if (result[1]) {\n var bytes = [], length = key.length, index = 0, code;\n for (i = 0; i < length; ++i) {\n code = key.charCodeAt(i);\n if (code < 0x80) {\n bytes[index++] = code;\n } else if (code < 0x800) {\n bytes[index++] = (0xc0 | (code >>> 6));\n bytes[index++] = (0x80 | (code & 0x3f));\n } else if (code < 0xd800 || code >= 0xe000) {\n bytes[index++] = (0xe0 | (code >>> 12));\n bytes[index++] = (0x80 | ((code >>> 6) & 0x3f));\n bytes[index++] = (0x80 | (code & 0x3f));\n } else {\n code = 0x10000 + (((code & 0x3ff) << 10) | (key.charCodeAt(++i) & 0x3ff));\n bytes[index++] = (0xf0 | (code >>> 18));\n bytes[index++] = (0x80 | ((code >>> 12) & 0x3f));\n bytes[index++] = (0x80 | ((code >>> 6) & 0x3f));\n bytes[index++] = (0x80 | (code & 0x3f));\n }\n }\n key = bytes;\n }\n\n if (key.length > 64) {\n key = (new Md5(true)).update(key).array();\n }\n\n var oKeyPad = [], iKeyPad = [];\n for (i = 0; i < 64; ++i) {\n var b = key[i] || 0;\n oKeyPad[i] = 0x5c ^ b;\n iKeyPad[i] = 0x36 ^ b;\n }\n\n Md5.call(this, sharedMemory);\n\n this.update(iKeyPad);\n this.oKeyPad = oKeyPad;\n this.inner = true;\n this.sharedMemory = sharedMemory;\n }\n HmacMd5.prototype = new Md5();\n\n HmacMd5.prototype.finalize = function () {\n Md5.prototype.finalize.call(this);\n if (this.inner) {\n this.inner = false;\n var innerHash = this.array();\n Md5.call(this, this.sharedMemory);\n this.update(this.oKeyPad);\n this.update(innerHash);\n Md5.prototype.finalize.call(this);\n }\n };\n\n var exports = createMethod();\n exports.md5 = exports;\n exports.md5.hmac = createHmacMethod();\n\n if (COMMON_JS) {\n module.exports = exports;\n } else {\n /**\n * @method md5\b\n * @description Md5 hash function, export to global in browsers.\n * @param {String|Array|Uint8Array|ArrayBuffer} message message to hash\n * @returns {String} md5 hashes\n * @example\n * md5(''); // d41d8cd98f00b204e9800998ecf8427e\n * md5('The quick brown fox jumps over the lazy dog'); // 9e107d9d372bb6826bd81d3542a419d6\n * md5('The quick brown fox jumps over the lazy dog.'); // e4d909c290d0fb1ca068ffaddf22cbd0\n *\n * // It also supports UTF-8 encoding\n * md5('涓枃'); // a7bac2239fcdcb3a067903d8077c4a07\n *\n * // It also supports byte `Array`, `Uint8Array`, `ArrayBuffer`\n * md5([]); // d41d8cd98f00b204e9800998ecf8427e\n * md5(new Uint8Array([])); // d41d8cd98f00b204e9800998ecf8427e\n */\n root.md5 = exports;\n if (AMD) {\n define(function () {\n return exports;\n });\n }\n }\n})();\n"]} \ No newline at end of file diff --git a/package-lock.json b/package-lock.json index b062c99..6037837 100644 --- a/package-lock.json +++ b/package-lock.json @@ -5,6 +5,7 @@ "packages": { "": { "dependencies": { + "js-md5": "^0.8.3", "tdesign-miniprogram": "^1.4.2" } }, @@ -13,6 +14,11 @@ "resolved": "https://registry.npmjs.org/dayjs/-/dayjs-1.11.11.tgz", "integrity": "sha512-okzr3f11N6WuqYtZSvm+F776mB41wRZMhKP+hc34YdW+KmtYYK9iqvHSwo2k9FEH3fhGXvOPV6yz2IcSrfRUDg==" }, + "node_modules/js-md5": { + "version": "0.8.3", + "resolved": "https://registry.npmjs.org/js-md5/-/js-md5-0.8.3.tgz", + "integrity": "sha512-qR0HB5uP6wCuRMrWPTrkMaev7MJZwJuuw4fnwAzRgP4J4/F8RwtodOKpGp4XpqsLBFzzgqIO42efFAyz2Et6KQ==" + }, "node_modules/tdesign-miniprogram": { "version": "1.4.2", "resolved": "https://registry.npmjs.org/tdesign-miniprogram/-/tdesign-miniprogram-1.4.2.tgz", diff --git a/package.json b/package.json index 132dfea..1ff335a 100644 --- a/package.json +++ b/package.json @@ -1,5 +1,17 @@ { "dependencies": { + "js-md5": "^0.8.3", "tdesign-miniprogram": "^1.4.2" - } + }, + "name": "irrigate_user_ym", + "version": "1.0.0", + "main": ".eslintrc.js", + "devDependencies": {}, + "scripts": { + "test": "echo \"Error: no test specified\" && exit 1" + }, + "keywords": [], + "author": "", + "license": "ISC", + "description": "" } diff --git a/pages/feedback/feedback.js b/pages/feedback/feedback.js index 7887046..6d93beb 100644 --- a/pages/feedback/feedback.js +++ b/pages/feedback/feedback.js @@ -1,9 +1,18 @@ +const audio = wx.createInnerAudioContext() +const recorderManager = wx.getRecorderManager() Page({ data: { + isRefreshing: false, + currentTab: 0, recordingSrc: '', isRecording: false, - isshowVoiceMask: true, //鏄惁鏄剧ず褰曢煶涓� - voiceTime: 2, //褰曢煶鏃堕暱 + isshowVoiceMask: false, //鏄惁鏄剧ず褰曢煶涓� + isShowVoiceView: false, + voiceTime: 0, //褰曢煶鏃堕暱 + maxVoiceTime: 60, //鏈�闀垮綍闊虫椂闂� + contDownTime: 0, + line2Opcity: 1, + line3Opcity: 1, gridConfig: { column: 3, width: 160, @@ -19,37 +28,111 @@ name: 'uploaded2.png', type: 'image', } - ] + ], + feedBackList: Array(19).fill({ + createTime: "2023-05-06 12:36:25", + responseTime: "2023-05-07 12:36:25" + }) }, onLoad() { - this.recorderManager = wx.getRecorderManager(); - this.recorderManager.onStart(() => { - console.log('recorder start'); - this.setData({ - isRecording: true - }); - this.startWaveformDrawing(); + wx.getSetting({ + success: (res) => { + if (!res.authSetting['scope.record']) { + // 濡傛灉鐢ㄦ埛娌℃湁鎺堟潈褰曢煶鏉冮檺锛屽彂璧锋巿鏉冪獥鍙� + wx.authorize({ + scope: 'scope.record', + success() { + // 鐢ㄦ埛宸茬粡鍚屾剰灏忕▼搴忎娇鐢ㄥ綍闊冲姛鑳斤紝鍙互缁х画鎿嶄綔 + console.log('鐢ㄦ埛宸叉巿鏉冨綍闊�'); + }, + fail() { + // 鐢ㄦ埛鎷掔粷鎺堟潈锛屽彲浠ョ粰鍑烘彁绀烘垨鍐嶆鍙戣捣鎺堟潈绐楀彛 + console.log('鐢ㄦ埛鎷掔粷浜嗘巿鏉冨綍闊�'); + } + }); + } else { + // 鐢ㄦ埛宸茬粡鎺堟潈褰曢煶锛屽彲浠ョ洿鎺ヨ繘琛屽綍闊虫搷浣� + console.log('鐢ㄦ埛宸叉巿鏉冨綍闊�'); + } + } }); + var that = this; + recorderManager.onStop((res) => { + console.log('褰曢煶鍋滄', voiceTime); + const voiceTime = Math.floor(res.duration / 1000) + if (voiceTime < 2) { + this.setData({ + isShowVoiceMask: false, + contDownTime: this.data.maxVoiceTime, + isShowVoiceView: false + }) + wx.showToast({ + title: '褰曢煶鏃堕棿杩囩煭', + icon: 'error', + time: 3000 + }) + } else { + + that.setData({ + voiceTime: voiceTime, + isShowVoiceMask: false, + contDownTime: this.data.maxVoiceTime, + isShowVoiceView: true + }) + console.log('res', res); + const { + tempFilePath + } = res; //杩欓噷鏉惧紑鎸夐挳 浼氳繑鍥炲綍闊虫湰鍦拌矾寰� + audio.src = tempFilePath + console.log(tempFilePath); + } - this.recorderManager.onStop((res) => { - console.log('recorder stop', res); - const { - tempFilePath - } = res; - this.setData({ - recordingSrc: tempFilePath, - isRecording: false - }); - this.stopWaveformDrawing(); + //涓婁紶褰曞埗鐨勯煶棰戝埌鏈嶅姟鍣� + // wx.uploadFile({ + // url: '鎺ュ彛鍦板潃' + api.voice, //鎺ュ彛鍦板潃 + // name: 'file', //涓婁紶鏂囦欢鍚� + // filePath: tempFilePath, + // success: function (res) { //鍚庡彴杩斿洖缁欏墠绔瘑鍒悗鐨勬枃瀛� + // var model = res.data + // var modeljson = JSON.parse(model) + // if (modeljson.status_code == 500) { + // wx.showToast({ + // title: '璇煶杞崲澶辫触', + // image: '/assets/image/icon/fail@2x.png' + // }) + // return false; + // } + // if (modeljson.meta.status_code === 200 && !modeljson.data.err_msg) { + // var saymessage = modeljson.data.message; + // wx.setStorageSync('sayinfo', saymessage) + // that.setData({ + // inpvalue: saymessage + // }) + // setTimeout(() =>{ + // wx.navigateTo({ + // url: '../loding/loding' + // }) + + // },2000) + // setTimeout(() => { + // wx.hideLoading(); + // }, 100) + // } else if (modeljson.data.err_msg) { + // wx.showToast({ + // title: '璇峰ぇ澹拌璇�', + // image: '/assets/image/icon/fail@2x.png' + // }) + // return false; + // } + // } + // }) }); - - this.recorderManager.onError((res) => { - console.error(res); - this.setData({ - isRecording: false - }); - this.stopWaveformDrawing(); + recorderManager.onStart(() => { + console.log('褰曢煶寮�濮�'); + }); + recorderManager.onError((err) => { + console.log('褰曢煶閿欒', err); }); }, handleRemove(e) { @@ -99,136 +182,127 @@ }); }, //鎸変綇鎸夐挳 - startHandel () { + startHandel() { this.setData({ - isShowVoiceMask:true + isShowVoiceMask: true, + contDownTime: this.data.maxVoiceTime, + voiceTime: 0, + isShowVoiceView: false }) console.log("寮�濮嬪綍闊�") - wx.getRecorderManager().start({ - duration: 0 + recorderManager.start({ + duration: 0 }) - }, - //鏉惧紑鎸夐挳 - endHandle () { - this.setData({ - isShowVoiceMask:false - }) + this.startRecordingCountdown(); + }, + //鏉惧紑鎸夐挳 + endHandle() { + this.stopRecordingCountdown(); console.log("缁撴潫") - const recorderManager = wx.getRecorderManager() - //褰曢煶鍋滄鍑芥暟 - var that = this; - wx.getRecorderManager().onStop((res) => { - const voiceTime = Math.floor(res.duration/1000) - console.log('voiceTime',voiceTime); - that.setData({ - voiceTime - }) - console.log('res',res); - const { tempFilePath } = res; //杩欓噷鏉惧紑鎸夐挳 浼氳繑鍥炲綍闊虫湰鍦拌矾寰� - audio.src = tempFilePath - console.log(tempFilePath); - //涓婁紶褰曞埗鐨勯煶棰戝埌鏈嶅姟鍣� - // wx.uploadFile({ - // url: '鎺ュ彛鍦板潃' + api.voice, //鎺ュ彛鍦板潃 - // name: 'file', //涓婁紶鏂囦欢鍚� - // filePath: tempFilePath, - // success: function (res) { //鍚庡彴杩斿洖缁欏墠绔瘑鍒悗鐨勬枃瀛� - // var model = res.data - // var modeljson = JSON.parse(model) - // if (modeljson.status_code == 500) { - // wx.showToast({ - // title: '璇煶杞崲澶辫触', - // image: '/assets/image/icon/fail@2x.png' - // }) - // return false; - // } - // if (modeljson.meta.status_code === 200 && !modeljson.data.err_msg) { - // var saymessage = modeljson.data.message; - // wx.setStorageSync('sayinfo', saymessage) - // that.setData({ - // inpvalue: saymessage - // }) - // setTimeout(() =>{ - // wx.navigateTo({ - // url: '../loding/loding' - // }) - - // },2000) - // setTimeout(() => { - // wx.hideLoading(); - // }, 100) - // } else if (modeljson.data.err_msg) { - // wx.showToast({ - // title: '璇峰ぇ澹拌璇�', - // image: '/assets/image/icon/fail@2x.png' - // }) - // return false; - // } - // } - // }) - }) //瑙﹀彂褰曢煶鍋滄 - wx.getRecorderManager().stop() - }, -// 鎾斁 -handlePlay(e){ - // 鍊掕鏃� - let time = this.data.voiceTime - audio.play() - let timer1 = -1,timer2 = -1,timer3 = -1,timer4 = -1,timer5 = -1,timer6 = -1; - // 绗竴娆℃挱鏀句负0 绗簩娆℃挱鏀�2绉掗挓 - timer6 = setInterval(()=>{ - console.log('鏃堕棿',time); - if(time <= 0){ - this.setData({ - line2Opcity: 1, - line3Opcity: 1 - }) - clearInterval(timer6) - clearTimeout(timer2) - clearTimeout(timer3) - clearTimeout(timer4) - clearTimeout(timer5) - return - } - timer2 = setTimeout(()=>{ - console.log('timer2'); - this.setData({ - line2Opcity: 0, - line3Opcity: 0 - }) - },300) - timer3 = setTimeout(()=>{ - console.log('timer3'); - this.setData({ - line2Opcity: 1, - line3Opcity:0 - }) - },600) - timer4 = setTimeout(()=>{ - console.log('timer4'); + recorderManager.stop() + }, + // 鎾斁 + handlePlay(e) { + // 鍊掕鏃� + let time = this.data.voiceTime + audio.play() + let timer1 = -1, + timer2 = -1, + timer3 = -1, + timer4 = -1, + timer5 = -1, + timer6 = -1; + // 绗竴娆℃挱鏀句负0 绗簩娆℃挱鏀�2绉掗挓 + timer6 = setInterval(() => { + console.log('鏃堕棿', time); + if (time <= 0) { this.setData({ line2Opcity: 1, line3Opcity: 1 - }) - },900) - timer5 = setTimeout(()=>{ - console.log('timer5'); + }) + clearInterval(timer6) + clearTimeout(timer2) + clearTimeout(timer3) + clearTimeout(timer4) + clearTimeout(timer5) + return + } + timer2 = setTimeout(() => { + console.log('timer2'); this.setData({ line2Opcity: 0, line3Opcity: 0 }) - },1200) - },1200) - // 鍊掕鏃� - timer1 = setInterval(()=>{ - time--; - if(time <= 0){ - clearInterval(timer1) - return - } -},1000) + }, 200) + timer3 = setTimeout(() => { + console.log('timer3'); + this.setData({ + line2Opcity: 1, + line3Opcity: 0 + }) + }, 400) + timer4 = setTimeout(() => { + console.log('timer4'); + this.setData({ + line2Opcity: 1, + line3Opcity: 1 + }) + }, 600) + timer5 = setTimeout(() => { + console.log('timer5'); + this.setData({ + line2Opcity: 0, + line3Opcity: 0 + }) + }, 800) + }, 800) + // 鍊掕鏃� + timer1 = setInterval(() => { + time--; + if (time <= 0) { + clearInterval(timer1) + return + } + }, 1000) -} + }, + //寮�鍚畾鏃跺櫒 + startRecordingCountdown() { + console.log("startRecordingCountdown"); + const that = this; + this.recordingInterval = setInterval(() => { + const newVoiceTime = that.data.voiceTime + 1; + const newContDownTime = that.data.contDownTime - 1; + that.setData({ + voiceTime: newVoiceTime, + contDownTime: newContDownTime + }); + if (this.data.voiceTime >= this.data.maxVoiceTime) { + that.stopRecordingCountdown(); + that.endHandle(); + } + }, 1000); + }, + + stopRecordingCountdown() { + console.log("stopRecordingCountdown"); + if (this.recordingInterval) { + clearInterval(this.recordingInterval); + this.recordingInterval = null; + console.log("Recording countdown stopped"); + } + }, // 鍒囨崲 Tabs + switchTab: function (e) { + const tab = parseInt(e.currentTarget.dataset.tab); + this.setData({ + currentTab: tab + }); + }, + onPullDownRefresh() { + this.setData({ + isRefreshing: false + }); + } }); \ No newline at end of file diff --git a/pages/feedback/feedback.wxml b/pages/feedback/feedback.wxml index c55587b..30df3cc 100644 --- a/pages/feedback/feedback.wxml +++ b/pages/feedback/feedback.wxml @@ -1,30 +1,63 @@ <view class="container"> - - <view class="container-item"> - <text class="fb-text">鍙嶉璇︽儏锛�</text> - <textarea class="input-class" /> - </view> - <view class="divider"></view> - <view class="container-item"> - <text class="img-upload">鍥剧墖锛堟渶澶氫笁寮狅級:</text> - <t-upload style="margin-top: 20rpx;" media-type="{{['image']}}" files="{{originFiles}}" gridConfig="{{gridConfig}}" bind:success="handleSuccess" max="3" bind:add="handleAdd" bind:remove="handleRemove" bind:click="handleClick" bind:sort-end="handleSortEnd" /> - </view> - <view class="divider"></view> - <view class="container-voice"> - <text class="fb-text">褰曢煶锛�</text> - <view class="voice_wrapper"> - <image class="voice_img" bindtouchstart='startHandel' bindtouchend='endHandle' src="/images/tape.svg" mode="" /> - <view class="voice_content" bind:tap="handlePlay" wx:if="{{voiceTime}}"> - <view class="left"> - <view class="line"></view> - <view class="line" style="opacity:{{line2Opcity}}" id="test2"></view> - <view class="line" style="opacity:{{line3Opcity}}" id="test3"></view> - </view> - <view class="right">{{voiceTime}}"</view> - </view> + <!-- 椤堕儴 Tabs --> + <view class="tabs"> + <view class="tab" bindtap="switchTab" data-tab="0" id="tab0"> + 闂鍙嶉 + <view class="indicator" wx:if="{{currentTab === 0}}"></view> + </view> + <view class="tab" bindtap="switchTab" data-tab="1" id="tab1"> + 宸叉彁闂 + <view class="indicator" wx:if="{{currentTab === 1}}"></view> </view> </view> - <!-- 褰曢煶涓� --> - <view wx:if="{{isShowVoiceMask}}" class="voice_starting">褰曢煶涓�</view> - <button class="fb-submit">鎻愪氦</button> + <view class="container-feedBack" wx:if="{{currentTab === 0}}"> + <view class="container-item"> + <text class="fb-text">鍙嶉璇︽儏锛�</text> + <textarea style="position: relative; left: -2rpx; top: 0rpx" class="input-class" /> + </view> + <view class="divider"></view> + <view class="container-item"> + <text class="fb-text">鍥剧墖锛堟渶澶氫笁寮狅級:</text> + <t-upload style="margin-top: 20rpx;" media-type="{{['image']}}" files="{{originFiles}}" gridConfig="{{gridConfig}}" bind:success="handleSuccess" max="3" bind:add="handleAdd" bind:remove="handleRemove" bind:click="handleClick" bind:sort-end="handleSortEnd" /> + </view> + <view class="divider"></view> + <view class="container-voice"> + <text class="fb-text">褰曢煶锛�</text> + <view class="voice_wrapper"> + <image class="voice_img" bindtouchstart='startHandel' bindtouchend='endHandle' src="/images/tape.svg" mode="" /> + <view class="voice_content" bind:tap="handlePlay" wx:if="{{isShowVoiceView}}"> + <view class="left"> + <view class="line"></view> + <view class="line" style="opacity:{{line2Opcity}}" id="test2"></view> + <view class="line" style="opacity:{{line3Opcity}}" id="test3"></view> + </view> + <view class="right">{{voiceTime}}"</view> + </view> + </view> + </view> + <!-- 褰曢煶涓� --> + <view wx:if="{{isShowVoiceMask}}" class="voice_starting">褰曢煶涓瓄{contDownTime}}绉�</view> + <button class="fb-submit">鎻愪氦</button> + </view> + + <scroll-view class="container-scroll" wx:if="{{currentTab === 1}}" scroll-y="true" refresher-enabled="true" refresher-threshold="50" bindrefresherrefresh="onPullDownRefresh" refresher-triggered="{{isRefreshing}}"> + <block wx:for="{{feedBackList}}" wx:key="index"> + <view class="item"> + <view class="item-data"> + <text>鎻愰棶鏃堕棿锛�</text> + <text>{{item.createTime}}</text> + </view> + <view class="item-data"> + <text>鍝嶅簲鏃堕棿锛�</text> + <text>{{item.responseTime}}</text> + </view> + </view> + </block> + <view wx:if="{{feedBackList.length === 0}}" class="noMore-View"> + <image class="noMore-img" src="/images/no_more.svg" /> + <text class="noMore-text">娌℃湁鏁版嵁</text> + </view> + </scroll-view> + + </view> \ No newline at end of file diff --git a/pages/feedback/feedback.wxss b/pages/feedback/feedback.wxss index 6218e0a..7a16002 100644 --- a/pages/feedback/feedback.wxss +++ b/pages/feedback/feedback.wxss @@ -2,15 +2,37 @@ .container { display: flex; flex-direction: column; + width: 100%; height: 100vh; - padding-left: 30rpx; - padding-right: 30rpx; - width: calc(100% - 0rpx); /* 鑰冭檻浜嗗乏鍙宠竟璺濆悗鐨勫疄闄呭搴� */ background-color: #fff; - justify-content: flex-start; + justify-content: center; align-items: center; } + +.container-scroll{ + flex: 1; + overflow-y: auto; + z-index: 0; + display: flex; + flex-direction: column; + padding-bottom: 20rpx; /* 澧炲姞搴曢儴濉厖 */ +} + +.container-feedBack { + width: calc(100% - 80rpx); + /* 40rpx 涓哄乏鍙� padding 鐨勬�诲拰 */ + height: 100vh; + /* 鑰冭檻浜嗗乏鍙宠竟璺濆悗鐨勫疄闄呭搴� */ + background-color: #fff; + padding-left: 40rpx; + padding-right: 40rpx; + padding-top: 1rpx; + padding-bottom: 1rpx; +} + + + .btn { margin: 10px; @@ -43,9 +65,13 @@ .input-class { border-radius: 5px; border: 2rpx solid #000000; - height: 20vh; + height: 10vh; width: 100%; background-color: #fcfcfc; + display: flex; + flex-direction: column; + justify-content: center; + align-items: center; } .img-upload { @@ -54,23 +80,21 @@ } .container-item { - width: 100%; display: flex; flex-direction: column; - + justify-content: flex-start } .container-voice { width: 100%; display: flex; flex-direction: row; - align-items: center; } .fb-text { font-size: 35rpx; - margin-left: 30rpx; + margin-bottom: 10rpx; } .fb-submit { @@ -78,7 +102,7 @@ background-color: #1890FF; font-size: 35rpx; color: white; - margin-top: 50rpx; + margin-top: 200rpx; } .voice_img { @@ -146,17 +170,72 @@ margin-right: 20rpx; } -.voice_starting{ +.voice_starting { position: fixed; top: 30%; left: 50%; transform: translate(-50%, -50%); - width: 200rpx; - height: 200rpx; - line-height: 200rpx; + width: 300rpx; + height: 300rpx; + align-items: center; + line-height: 300rpx; background-color: #787879; color: #fff; text-align: center; - border-radius: 100rpx; /* 浣垮叾鍛堢幇鍦嗗舰 */ + border-radius: 150rpx; + /* 浣垮叾鍛堢幇鍦嗗舰 */ z-index: 10000; +} + +.tabs { + display: flex; + justify-content: space-around; + position: relative; + width: 100%; + border-bottom: 1px solid #eee; + margin-bottom: 20rpx; + /* Tabs 鍗犳弧鏁翠釜妯悜灞忓箷 */ +} + +.tab { + font-size: 16px; + padding: 10px; + cursor: pointer; + position: relative; + width: 50%; + /* Tabs 骞冲垎鏁翠釜妯悜灞忓箷 */ + text-align: center; + /* 鏂囧瓧灞呬腑 */ +} + +.indicator { + width: 100%; + height: 3px; + background-color: #1890FF; + position: absolute; + bottom: 0; + left: 0; + transform: translateX(0); + /* 鍒濆鍖栦綅缃� */ +} + +.item { + display: flex; + flex-direction: row; + flex-wrap: nowrap; + /*琛ㄧず涓嶆崲琛�*/ + padding-left: 40rpx; + padding-right: 40rpx; + width: calc(100% - 80rpx); + margin-bottom: 40rpx; +} + +.item-data { + display: flex; + flex-direction: column; + flex-grow: 1; +} + +.item-data text { + font-size: 30rpx; } \ No newline at end of file diff --git a/pages/home/home.js b/pages/home/home.js index 023bfac..e88ea82 100644 --- a/pages/home/home.js +++ b/pages/home/home.js @@ -4,23 +4,26 @@ get, post } = require('../../api/request.js'); +const app = getApp(); Page({ /** * 椤甸潰鐨勫垵濮嬫暟鎹� */ data: { - sessionId: "", showConfirm: false, myItem: {}, waterIntakeName: "", image: "/images/ic_head_bg.jpg", - userPhone: "158****0723", - userName: "寮犱笁", + userPhone: "鏈櫥褰�", + userName: "璇风櫥褰�", scrollViewHeight: 0, listData: [], isRefreshing: false, - isWXRefreshing: false + isWXRefreshing: false, + wxCode: '', + errorData: '', //閿欒鍐呭 + showErrorDialog: false }, openValve: function (e) { @@ -44,9 +47,7 @@ isRefreshing: true }); this.getOpenList(); - } - }, //鑾峰彇鐢ㄦ埛鏁版嵁 getUserData() { @@ -60,9 +61,6 @@ console.error('Failed to fetch data:', error); }); }, - - - /** * 鐢熷懡鍛ㄦ湡鍑芥暟--鐩戝惉椤甸潰鍔犺浇 */ @@ -81,7 +79,6 @@ }) this.getOpenList(); } - this.getUserDataBySession(); }, /** @@ -94,14 +91,13 @@ this.setData({ sessionId: data }); - if (sessionId !== "") {} - }).catch((err) => { - console.error('Failed to load parameter:', err); - }); + if (sessionId) { + this.getOpenList(); + } + }).catch((err) => {}); } else { - console.log('Failed to load parameter:false'); + this.wxLogin(); } - this.getOpenList(); }, /** @@ -154,27 +150,20 @@ }, recharge() { - // wx.navigateTo({ - // url: '/pages/rechargeCard/rechargeCard', - // }) - wx.showToast({ - title: '鏆傛湭寮�鏀�', - icon: 'none' + wx.navigateTo({ + url: '/pages/rechargeCard/rechargeCard', }) + }, openValveList() { - // wx.navigateTo({ - // url: '/pages/valveList/valveList', - // }) - wx.showToast({ - title: '鏆傛湭寮�鏀�', - icon: 'none' + wx.navigateTo({ + url: '/pages/valveList/valveList', }) + }, feedBack() { - wx.showToast({ - title: '鏆傛湭寮�鏀�', - icon: 'none' + wx.navigateTo({ + url: '/pages/feedback/feedback', }) }, handleChange(e) { @@ -213,7 +202,8 @@ post({ url: "wx/valve/close_wx", data: data, - isShowLoding: false + isShowLoding: false, + timeout: 185000 }).then(response => { // 澶勭悊鎴愬姛鍝嶅簲 @@ -228,13 +218,10 @@ }) }).catch(error => { wx.hideLoading(); - if (error.code === "1002") { - wx.showToast({ - title: '鍏抽榾澶辫触', - icon: 'error', - duration: 3000 // 鎻愮ず鐨勬寔缁椂闂达紝鍗曚綅姣 - }) - } + this.setData({ + showErrorDialog: true, + errorData: error.msg + }) // 澶勭悊閿欒鍝嶅簲 console.error('璇锋眰澶辫触:', error); @@ -244,7 +231,6 @@ * 鑾峰彇涓哄叧闃�璁板綍 */ getOpenList() { - const app = getApp(); const params = { url: 'wx/valve/get', data: { @@ -261,6 +247,12 @@ // 閿欒鍥炶皟 this.setData({ isRefreshing: false, // 灏唗riggered灞炴�ц缃负false锛岃〃绀轰笅鎷夊埛鏂板凡瀹屾垚 + isWXRefreshing: false, // 灏唗riggered灞炴�ц缃负false锛岃〃绀轰笅鎷夊埛鏂板凡瀹屾垚 + }) + wx.showToast({ + title: err.msg, + icon: 'error', + duration: 3000 }) }); }, @@ -278,7 +270,7 @@ getUserDataBySession() { const app = getApp(); const params = { - url: 'sell/client/simple_info', + url: 'wx/client/simple_info', data: { sessionId: app.globalData.sessionId } @@ -293,6 +285,7 @@ }) }, + //灏嗘墜鏈哄彿涓棿鍥涗綅闅愯棌 maskPhoneNumber(phoneNumber) { if (phoneNumber.length !== 11) { throw new Error("Phone number must be 11 digits"); @@ -300,8 +293,59 @@ // 浣跨敤姝e垯琛ㄨ揪寮忔浛鎹腑闂村洓浣嶆暟瀛椾负鏄熷彿 const maskedPhoneNumber = phoneNumber.replace(/^(\d{3})\d{4}(\d{4})$/, "$1****$2"); return maskedPhoneNumber; + }, + //娌℃湁sessionID鏃惰幏鍙杝essionID + getSessionID(code) { + const params = { + url: 'https://44978f7456.imdo.co/wx/client/code_login ', + data: { + code: code + } + }; + post(params).then(data => { + if (data.content.client.sessionId) { + //褰撳墠鐢ㄦ埛缁戝畾杩� + getApp().globalData.sessionId = data.content.client.sessionId + storage.setItem("sessionId", data.content.client.sessionId); + this.getOpenList(); + this.getUserDataBySession(); + + } else { + //褰撳墠鐢ㄦ埛娌$粦瀹氳繃锛岃烦杞埌缁戝畾鐣岄潰 + wx.navigateTo({ + url: '/pages/wxbind/wxbind?wxCode=' + this.data.wxCode, + }) + } + + }).catch(err => { + // 閿欒鍥炶皟 + + }) + }, + wxLogin() { + // 鐧诲綍 + wx.login({ + success: res => { + if (res.code) { + console.log('鐧诲綍鎴愬姛锛岃幏鍙栧埌鐨刢ode:', res.code); + this.setData({ + wxCode: res.code + }) + // 鍙戦�� res.code 鍒板悗鍙版湇鍔″櫒鎹㈠彇 openId, sessionKey, unionId + this.getSessionID(res.code) + } else { + console.log('鐧诲綍澶辫触锛�' + res.errMsg); + } + } + }); + }, + closeDialog() { + this.setData({ + showErrorDialog:false + }) } + }) \ No newline at end of file diff --git a/pages/home/home.wxml b/pages/home/home.wxml index f4ee37e..155e80a 100644 --- a/pages/home/home.wxml +++ b/pages/home/home.wxml @@ -47,7 +47,7 @@ <view class="dot"></view> </view> <view class="scroll-bg"> - <view wx:if="{{listData.length > 0}}" class="list-item" wx:for="{{listData}}" wx:for-item="item" wx:for-index="index"> + <view wx:if="{{listData.length > 0}}" class="list-item" wx:for="{{listData}}" wx:for-item="item" wx:for-index="index"> <view class="item-left"> <!-- <image class="item-img" src="/images/pipeline.svg" /> --> <text>{{item.intakeNum}}</text> @@ -64,6 +64,6 @@ <text class="noMore-text">娌℃湁寮�娉佃褰�</text> </view> </scroll-view> - <t-dialog class="t-dialog" visible="{{showConfirm}}" content="纭鍏抽棴{{waterIntakeName}}鍚楋紵" confirm-btn="{{ { content: '纭', variant: 'base', theme: 'danger' } }}" close-on-overlay-click="false" cancel-btn="鍙栨秷" bind:confirm="confirmDialog" bind:cancel="closeDialog" /> - + <t-dialog class="dialog" visible="{{showConfirm}}" content="纭鍏抽棴{{waterIntakeName}}鍚楋紵" confirm-btn="{{ { content: '纭', variant: 'base', theme: 'danger' } }}" close-on-overlay-click="false" cancel-btn="鍙栨秷" bind:confirm="confirmDialog" bind:cancel="closeDialog" /> + <t-dialog title="鍏抽榾閿欒" visible="{{showErrorDialog}}" content="{{errorData}}" confirm-btn="{{ confirmBtn }}" bind:confirm="closeDialog" /> </view> \ No newline at end of file diff --git a/pages/home/home.wxss b/pages/home/home.wxss index 0b70b8e..6748985 100644 --- a/pages/home/home.wxss +++ b/pages/home/home.wxss @@ -143,6 +143,7 @@ /* 鍏佽鍨傜洿婊氬姩 */ z-index: 0; /* 纭繚 scroll-view 鍦ㄥご閮ㄥ拰 center-wrapper 涔嬩笅 */ + margin-bottom: 20rpx; } @@ -281,7 +282,7 @@ margin-left: 20rpx; } -.t-dialog { +.dialog { --td-dialog-content-font-size: 40rpx; --td-dialog-content-line-height: 50rpx } @@ -315,4 +316,9 @@ width: 100%; margin-top: 2rpx; /* background-color: #e0e0e0; */ +} + +.error-dialog{ + --td-dialog-title-color:red; + --td-dialog-title-font-size:45rpx; } \ No newline at end of file diff --git a/pages/rechargeCard/rechargeCard.js b/pages/rechargeCard/rechargeCard.js index 56a094a..138afb6 100644 --- a/pages/rechargeCard/rechargeCard.js +++ b/pages/rechargeCard/rechargeCard.js @@ -9,19 +9,81 @@ * 椤甸潰鐨勫垵濮嬫暟鎹� */ data: { - confirmBtn: { content: '纭', variant: 'base' }, + confirmBtn: { + content: '纭' + }, currentTab: 0, // 褰撳墠鏄剧ず鐨勮〃鏍硷紝榛樿涓虹涓�涓〃鏍� - allCardPoints: [], - allWaterPoints:[], - showDialog:false + allCardPoints: [{ + "id": "string", + "inUse": 0, + "inUseName": "string", + "money": 110, + "vcNum": "200030000000" + }, { + "id": "string", + "inUse": 0, + "inUseName": "string", + "money": 110, + "vcNum": "200030000000" + }, { + "id": "string", + "inUse": 0, + "inUseName": "string", + "money": 110, + "vcNum": "200030000000" + }, { + "id": "string", + "inUse": 0, + "inUseName": "string", + "money": 110, + "vcNum": "200030000000" + }, { + "id": "string", + "inUse": 1, + "inUseName": "string", + "money": 110, + "vcNum": "200030000000" + }], + allWaterPoints: [{ + "id": "string", + "inUse": 1, + "inUseName": "string", + "money": 110, + "vcNum": "200030000000" + },{ + "id": "string", + "inUse": 1, + "inUseName": "string", + "money": 110, + "vcNum": "200030000000" + },{ + "id": "string", + "inUse": 1, + "inUseName": "string", + "money": 110, + "vcNum": "200030000000" + },{ + "id": "string", + "inUse": 1, + "inUseName": "string", + "money": 110, + "vcNum": "200030000000" + },{ + "id": "string", + "inUse": 1, + "inUseName": "string", + "money": 110, + "vcNum": "200030000000" + }], + showDialog: false }, - // 鍒囨崲 Tabs - switchTab: function (e) { - const tab = parseInt(e.currentTarget.dataset.tab); - this.setData({ - currentTab: tab - }); -}, + // 鍒囨崲 Tabs + switchTab: function (e) { + const tab = parseInt(e.currentTarget.dataset.tab); + this.setData({ + currentTab: tab + }); + }, /** * 鐢熷懡鍛ㄦ湡鍑芥暟--鐩戝惉椤甸潰鍔犺浇 */ @@ -77,58 +139,66 @@ */ onShareAppMessage() { - },//鑾峰彇铏氭嫙鍗″垪琛� - getCardList(){ - get({url:'https://d4x9787456.vicp.fun/sell/virtual_card/get', data: { - operator: getApp().globalData.sessionId - }}) - .then((data) => { - if(data.success&&data.code==="0001"){ - this.setData({ - allCardPoints: data.content - }); - }else{ - wx.showToast({ - title: data.msg, - }) - } - console.log('Failed to add item:'); - }) - .catch((error) => { - console.error('Failed to add item:', error); - }); + }, //鑾峰彇铏氭嫙鍗″垪琛� + getCardList() { + get({ + url: 'https://d4x9787456.vicp.fun/sell/virtual_card/get', + data: { + operator: getApp().globalData.sessionId + } + }) + .then((data) => { + if (data.success && data.code === "0001") { + this.setData({ + allCardPoints: data.content + }); + } else { + wx.showToast({ + title: data.msg, + }) + } + + }) + .catch((error) => { + + }); }, - getWaterCardList(){ - get({url:'https://d4x9787456.vicp.fun/sell/virtual_card/get', data: { - operator: getApp().globalData.sessionId - }}) - .then((data) => { - if(data.success&&data.code==="0001"){ - this.setData({ - allWaterPoints: data.content - }); - }else{ - wx.showToast({ - title: data.msg, - }) - } - console.log('Failed to add item:'); - }) - .catch((error) => { - console.error('Failed to add item:', error); - }); + getWaterCardList() { + get({ + url: 'https://d4x9787456.vicp.fun/sell/virtual_card/get', + data: { + operator: getApp().globalData.sessionId + } + }) + .then((data) => { + if (data.success && data.code === "0001") { + this.setData({ + allWaterPoints: data.content + }); + } else { + wx.showToast({ + title: data.msg, + }) + } + console.log('Failed to add item:'); + }) + .catch((error) => { + console.error('Failed to add item:', error); + }); }, - rechargeCard(item){ + rechargeCard(item) { wx.navigateTo({ url: '/pages/rechargeMoney/rechargMoney' // 棣栭〉鐨勮矾寰勶紝鏍规嵁瀹為檯鎯呭喌濉啓 }); }, - ruinCard(){ - - }, - closeDialog(){ + ruinCard() { this.setData({ - showDialog:false + showDialog: true + }) + }, + closeDialog() { + this.setData({ + showDialog: false }) } diff --git a/pages/rechargeCard/rechargeCard.json b/pages/rechargeCard/rechargeCard.json index 84ea31a..16ff454 100644 --- a/pages/rechargeCard/rechargeCard.json +++ b/pages/rechargeCard/rechargeCard.json @@ -1,5 +1,6 @@ { "usingComponents": { - "t-dialog": "tdesign-miniprogram/dialog/dialog" + "t-dialog": "tdesign-miniprogram/dialog/dialog", + "t-button": "tdesign-miniprogram/button/button" } } \ No newline at end of file diff --git a/pages/rechargeCard/rechargeCard.wxml b/pages/rechargeCard/rechargeCard.wxml index cf37a96..d57100b 100644 --- a/pages/rechargeCard/rechargeCard.wxml +++ b/pages/rechargeCard/rechargeCard.wxml @@ -39,7 +39,7 @@ <image class="noMore-img" src="/images/no_more.svg" /> <text class="noMore-text">娌℃湁鏁版嵁</text> </view> - <t-dialog visible="{{showDialog}}" content="鎮ㄨ繕鏈変綑棰濇湭浣跨敤锛屽闇�閿�鍗★紝璇峰厛浣跨敤瀹屾垨閫�娆惧悗鎵嶅彲鎿嶄綔銆�" confirm-btn="{{ confirmBtn }}" bind:confirm="closeDialog" /> + <t-dialog visible="{{showDialog}}" content="鎮ㄨ繕鏈変綑棰濇湭浣跨敤锛屽闇�閿�鍗★紝璇峰厛浣跨敤瀹屾垨閫�娆惧悗鎵嶅彲鎿嶄綔銆�" confirm-btn="{{ confirmBtn }}" bind:confirm="closeDialog" /> </scroll-view> <!-- 姘村崱 --> @@ -50,7 +50,7 @@ <view class="item-card"> <text class="item-card-text">鍗$紪鍙凤細</text> <text class="item-card-text">{{item.vcNum}}</text> - <text class="waterIntake-recharge">鍏呭��</text> + <text class="waterIntake-recharge" bind:tap="rechargeCard">鍏呭��</text> </view> </view> </block> diff --git a/pages/rechargeCard/rechargeCard.wxss b/pages/rechargeCard/rechargeCard.wxss index 2457a03..d1002e4 100644 --- a/pages/rechargeCard/rechargeCard.wxss +++ b/pages/rechargeCard/rechargeCard.wxss @@ -178,4 +178,3 @@ border-radius: 30rpx; font-size: 30rpx; } - diff --git a/pages/rechargeMoney/rechargMoney.js b/pages/rechargeMoney/rechargMoney.js index dfc163e..41826bd 100644 --- a/pages/rechargeMoney/rechargMoney.js +++ b/pages/rechargeMoney/rechargMoney.js @@ -1,4 +1,9 @@ // pages/rechargeMoney/rechargMoney.js +const { + get, + post +} = require('../../api/request.js'); +const md5 = require('js-md5'); Page({ /** @@ -10,6 +15,7 @@ userCode: "15584236", balance: "1025鍏�", activeIndex: -1, + isClickable: false, allRechargeList: [{ time: "2024-05-12:20:20", type: "杩滅▼", @@ -90,10 +96,72 @@ if (index !== undefined) { this.setData({ activeIndex: parseInt(index), + isClickable: true }); } }, onPullDownRefresh() { console.log("onPullDownRefresh") + }, + //鍒涘缓璁㈠崟骞惰皟璧锋敮浠� + creatOrder() { + if (!this.data.isClickable) { + return; + } + const data = { + sessionId: "2024061708384800006", + vcId: "2024060610404500006", //铏氭嫙鍗D + rechargeAmount: 1 //锛堝崟浣嶆槸鍒嗭級 + }; + console.log("postCloseValaue" + data); + post({ + url: "https://44978f7456.imdo.co/sell/payment/placeOrder", + data: data + }).then(response => { + // 澶勭悊鎴愬姛鍝嶅簲 + console.log('璇锋眰鎴愬姛:', response); + const timeStamp = String(Math.floor(Date.now() / 1000)); + const nonceStr = timeStamp; + const prepayId = response.content.prepay_id; + const signType = 'MD5'; + + // 鐢熸垚鏀粯绛惧悕 + const paySign = this.generatePaySign({ + appId: getApp().globalData.APPID, + timeStamp: timeStamp, + nonceStr: nonceStr, + package: prepayId, + signType: signType + }); + + // 璋冭捣鏀粯 + wx.requestPayment({ + timeStamp: timeStamp, + nonceStr: nonceStr, + package: prepayId, + signType: signType, + paySign: paySign, + success(res) { + console.log('鏀粯鎴愬姛', res); + }, + fail(err) { + console.log('鏀粯澶辫触', err); + } + }); + }).catch(error => { + if (error.code === "1002") {} + // 澶勭悊閿欒鍝嶅簲 + console.error('璇锋眰澶辫触:', error); + + }); + }, + getRechargList() { + + }, + // 鐢熸垚鏀粯绛惧悕鐨勫嚱鏁� + generatePaySign(params) { + const sortedKeys = Object.keys(params).sort(); + const stringToSign = sortedKeys.map(key => `${key}=${params[key]}`).join('&') + `&key=your-mch-key`; + return md5(stringToSign).toUpperCase(); } }) \ No newline at end of file diff --git a/pages/rechargeMoney/rechargMoney.wxml b/pages/rechargeMoney/rechargMoney.wxml index ae395e1..cd6c038 100644 --- a/pages/rechargeMoney/rechargMoney.wxml +++ b/pages/rechargeMoney/rechargMoney.wxml @@ -57,8 +57,8 @@ </view> <view class="rechage-view"> - <view class="rechage{{activeIndex === -1 ? 'active' : ''}}"> - <text class="rechage-text">鍏呭��</text> + <view class="rechage{{activeIndex === -1 ? 'active' : ''}}" disabled="{{isClickable}}" bind:tap="creatOrder"> + <text class="rechage-text" >鍏呭��</text> </view> </view> diff --git a/pages/valveList/valveList.wxml b/pages/valveList/valveList.wxml index b48f7ae..fc62d56 100644 --- a/pages/valveList/valveList.wxml +++ b/pages/valveList/valveList.wxml @@ -2,7 +2,7 @@ <view> <scroll-view class="list-container" scroll-y="true" scroll-x="false"> <block wx:if="{{listData.length > 0}}" wx:for="{{listData}}" wx:key="index"> - <view class="list-item" wx:for="{{listData}}" wx:for-item="item" wx:for-index="index"> + <view class="list-item"> <!-- <image class="item-img" src="/images/pipeline.svg" /> --> <view class="item-time"> <text class="item-text">娑堣垂閲戦锛�</text> diff --git a/pages/waterIntake/waterIntake.js b/pages/waterIntake/waterIntake.js index 81ded95..4ca47c8 100644 --- a/pages/waterIntake/waterIntake.js +++ b/pages/waterIntake/waterIntake.js @@ -84,13 +84,10 @@ wx.hideLoading(); // 澶勭悊閿欒鍝嶅簲 console.error('璇锋眰澶辫触:', error); - if (error.code === "1002") { - wx.showToast({ - title: '寮�闃�澶辫触', - icon: 'error', - duration: 3000 // 鎻愮ず鐨勬寔缁椂闂达紝鍗曚綅姣 - }) - } + this.setData({ + showErrorDialog: true, + errorData: error.msg + }) }); }, @@ -235,6 +232,11 @@ this.setData({ showConfirm: false }) + }, + closeErrorDialog() { + this.setData({ + showErrorDialog: false + }) } }) \ No newline at end of file diff --git a/pages/waterIntake/waterIntake.wxml b/pages/waterIntake/waterIntake.wxml index f9a559a..e433296 100644 --- a/pages/waterIntake/waterIntake.wxml +++ b/pages/waterIntake/waterIntake.wxml @@ -51,5 +51,7 @@ </scroll-view> </view> - <t-dialog class="t-dialog" visible="{{showConfirm}}" content="纭鎵撳紑{{choseItem.intakeNum}}鍚楋紵" confirm-btn="{{ { content: '纭', variant: 'base', theme: 'danger' } }}" close-on-overlay-click="false" cancel-btn="鍙栨秷" bind:confirm="confirmDialog" bind:cancel="closeDialog" /> + <t-dialog class="dialog" visible="{{showConfirm}}" content="纭鎵撳紑{{choseItem.intakeNum}}鍚楋紵" confirm-btn="{{ { content: '纭', variant: 'base', theme: 'danger' } }}" close-on-overlay-click="false" cancel-btn="鍙栨秷" bind:confirm="confirmDialog" bind:cancel="closeDialog" /> + + <t-dialog class="error-dialog" title="寮�闃�閿欒" visible="{{showErrorDialog}}" content="{{errorData}}" confirm-btn="{{ confirmBtn }}" bind:confirm="closeErrorDialog" /> </view> diff --git a/pages/waterIntake/waterIntake.wxss b/pages/waterIntake/waterIntake.wxss index 4369c9a..519475c 100644 --- a/pages/waterIntake/waterIntake.wxss +++ b/pages/waterIntake/waterIntake.wxss @@ -135,7 +135,12 @@ flex-direction: column; padding-bottom: 10rpx; /* 澧炲姞搴曢儴濉厖 */ } -.t-dialog{ +.dialog{ --td-dialog-content-font-size:40rpx; --td-dialog-content-line-height:50rpx +} + +.error-dialog{ + --td-dialog-title-color:red; + --td-dialog-title-font-size:45rpx; } \ No newline at end of file diff --git a/pages/wxbind/wxbind.js b/pages/wxbind/wxbind.js index d0ee79f..a944de6 100644 --- a/pages/wxbind/wxbind.js +++ b/pages/wxbind/wxbind.js @@ -1,5 +1,9 @@ // pages/wxbind/wxbind.js const app = getApp(); +const { + get, + post +} = require('../../api/request.js'); Page({ /** @@ -7,10 +11,14 @@ */ data: { mobile: '', - code: '', + phoneCode: '', + codeSent: false, countdown: 60, isButtonEnabled: false + }, + onLoad(options) { + }, bindMobileInput(e) { this.setData({ @@ -20,17 +28,18 @@ bindCodeInput(e) { this.setData({ - code: e.detail.value - }, this.checkButtonState); + phoneCode: e.detail.value + }); + this.checkButtonState(); }, checkButtonState() { const { mobile, - code + phoneCode } = this.data; - const isButtonEnabled = mobile.length === 11 && code.length == 6; + const isButtonEnabled = mobile.length === 11 && phoneCode.length == 6; this.setData({ - isButtonEnabled + isButtonEnabled: isButtonEnabled }); console.log(isButtonEnabled); }, @@ -43,19 +52,11 @@ }); return; } - // 鍦ㄨ繖閲屽鐞嗗彂閫侀獙璇佺爜鐨勯�昏緫锛屽彲浠ヨ皟鐢ㄥ悗鍙版帴鍙e疄鐜� - // 浠ヤ笅鏄竴涓畝鍗曠殑绀轰緥锛屼粎浣滃弬鑰� - wx.showToast({ - title: '楠岃瘉鐮佸凡鍙戦��', - icon: 'success', - duration: 2000, - }); - + this.postCode(); this.setData({ codeSent: true, }); - // 鍚姩鍊掕鏃� this.startCountdown(); }, @@ -88,15 +89,72 @@ url: '/pages/home/home' // 杩欓噷濉啓浣犳兂瑕佽烦杞殑 TabBar 椤甸潰璺緞 }); }, + //鑾峰彇楠岃瘉鐮� postCode: function () { - post('/items', { name: 'New Item' }) + const params = { + url: 'https://44978f7456.imdo.co/wx/client/send_sms?phoneNumber=' + this.data.mobile + }; + post(params) .then((data) => { this.setData({ items: [...this.data.items, data] }); + wx.showToast({ + title: '楠岃瘉鐮佸凡鍙戦��', + icon: 'success', + duration: 2000, + }); }) .catch((error) => { console.error('Failed to add item:', error); }); + }, + + bind() { + this.wsLogin(); + }, + wsLogin(){ + wx.login({ + success: res => { + if (res.code) { + console.log('鐧诲綍鎴愬姛锛岃幏鍙栧埌鐨刢ode:', res.code); + // 鍙戦�� res.code 鍒板悗鍙版湇鍔″櫒鎹㈠彇 openId, sessionKey, unionId + this.verify(res.code) + } else { + console.log('鐧诲綍澶辫触锛�' + res.errMsg); + } + } + }); + }, + //鐢ㄦ埛缁戝畾 + verify(wxCode){ + const params = { + url: 'https://44978f7456.imdo.co/wx/client/verify', + data: { + phoneNumber: this.data.mobile, + securityCode: this.data.phoneCode, + code: wxCode + } + }; + post(params) + .then((data) => { + getApp().globalData.sessionId= data.content + this.setData({ + items: [...this.data.items, data] + }); + wx.showToast({ + title: '缁戝畾鎴愬姛', + icon: 'success', + duration: 2000, + }); + }) + .catch((error) => { + wx.showToast({ + title: error.msg, + icon: 'error', + duration: 3000, + }); + console.error('Failed to add item:', error); + }); } }) \ No newline at end of file diff --git a/project.private.config.json b/project.private.config.json index 0cee8f2..3a17523 100644 --- a/project.private.config.json +++ b/project.private.config.json @@ -2,6 +2,7 @@ "description": "椤圭洰绉佹湁閰嶇疆鏂囦欢銆傛鏂囦欢涓殑鍐呭灏嗚鐩� project.config.json 涓殑鐩稿悓瀛楁銆傞」鐩殑鏀瑰姩浼樺厛鍚屾鍒版鏂囦欢涓�傝瑙佹枃妗o細https://developers.weixin.qq.com/miniprogram/dev/devtools/projectconfig.html", "projectname": "irrigate_user_ym", "setting": { - "compileHotReLoad": true + "compileHotReLoad": true, + "urlCheck": false } } \ No newline at end of file diff --git a/utils/storage.js b/utils/storage.js index 3ca562d..e3637c4 100644 --- a/utils/storage.js +++ b/utils/storage.js @@ -1,3 +1,5 @@ +//缂撳瓨宸ュ叿绫� +//淇濆瓨鏁版嵁 const setItem = (key, data) => { return new Promise((resolve, reject) => { wx.setStorage({ -- Gitblit v1.8.0