1.开关阀记录界面。2.虚拟卡充值相关。3.问题反馈相关
| | |
| | | case 'test': |
| | | // BASEURL = 'https://irrigate.dayuyanjiuyuan.top/' |
| | | // BASEURL = 'https://d4x9787456.vicp.fun/' |
| | | // BASEURL = 'http://127.0.0.1:8087/' |
| | | BASEURL = 'http://192.168.40.166:8087/' |
| | | BASEURL = 'http://127.0.0.1:8087/' |
| | | // BASEURL = 'http://192.168.40.166:8087/' |
| | | break |
| | | default: |
| | | BASEURL = '' |
| | |
| | | form, |
| | | isShowLoding, |
| | | timeout, |
| | | header |
| | | header, |
| | | useParams |
| | | } = _options |
| | | const app = getApp() |
| | | // 设置请求头 |
| | |
| | | header.Authorization = `Bearer ${token}` |
| | | } |
| | | header.tag = app.globalData.tag; |
| | | header.appId = app.globalData.AppID; |
| | | |
| | | return new Promise((resolve, reject) => { |
| | | console.log("url:" + BASEURL + url); |
| | | if (isShowLoding) { |
| | |
| | | } else { |
| | | myUrl = BASEURL + url; |
| | | } |
| | | // 如果 useParams 为 true,拼接查询参数 |
| | | if (useParams && data) { |
| | | const queryString = objToQueryString(data); // 使用上面定义的函数 |
| | | myUrl += `?${queryString}`; // 拼接查询字符串 |
| | | data = {}; // 请求体数据设为空 |
| | | } |
| | | wx.request({ |
| | | url: myUrl, |
| | | data, |
| | |
| | | }) |
| | | }) |
| | | } |
| | | |
| | | function objToQueryString(obj) { |
| | | return Object.keys(obj) |
| | | .map(key => { |
| | | // 对键和值进行 URL 编码 |
| | | return `${encodeURIComponent(key)}=${encodeURIComponent(obj[key])}`; |
| | | }) |
| | | .join('&'); // 将所有键值对用 '&' 连接起来 |
| | | } |
| | | // 封装toast函数 |
| | | function showToast(title, icon = 'none', duration = 2500, mask = false) { |
| | | wx.showToast({ |
| | |
| | | }) |
| | | }, |
| | | globalData: { |
| | | sessionId:'2024052821300200006', |
| | | clientId:'2024091215314000006', |
| | | tag:'ym', |
| | | sessionId:2024102118013700009, |
| | | clientId:"", |
| | | tag:'test', |
| | | userInfo: null, |
| | | userId:"", |
| | | userCode:"", |
| | | token:"" |
| | | token:"", |
| | | AppID:"wxc5e09d2676d31e15" |
| | | } |
| | | }) |
| | |
| | | { |
| | | "pages": [ |
| | | |
| | | "pages/home/home", |
| | | "pages/valveList/valveList", |
| | | "pages/feedback/feedback", |
| | |
| | | overflow-y: auto; |
| | | z-index: 0; |
| | | margin-top: 10rpx; |
| | | } |
| | | |
| | | |
| | | .loading { |
| | | text-align: center; |
| | | padding: 20px; |
| | | } |
| | |
| | | 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__(1724049949958, function(require, module, exports) { |
| | | __DEFINE__(1729495434246, 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__(1724049949958); |
| | | return __REQUIRE__(1729495434246); |
| | | })() |
| | | //miniprogram-npm-outsideDeps=[] |
| | | //# sourceMappingURL=index.js.map |
| New file |
| | |
| | | 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__(1729495434247, 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__(1729495434247); |
| | | })() |
| | | //miniprogram-npm-outsideDeps=["crypto","buffer"] |
| | | //# sourceMappingURL=index.js.map |
| New file |
| | |
| | | {"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"]} |
| | |
| | | "packages": { |
| | | "": { |
| | | "dependencies": { |
| | | "js-md5": "^0.8.3", |
| | | "tdesign-miniprogram": "^1.4.2" |
| | | } |
| | | }, |
| | |
| | | "resolved": "https://registry.npmjs.org/dayjs/-/dayjs-1.11.12.tgz", |
| | | "integrity": "sha512-Rt2g+nTbLlDWZTwwrIXjy9MeiZmSDI375FvZs72ngxx8PDC6YXOeR3q5LAuPzjZQxhiWdRKac7RKV+YyQYfYIg==" |
| | | }, |
| | | "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", |
| | |
| | | { |
| | | "dependencies": { |
| | | "js-md5": "^0.8.3", |
| | | "tdesign-miniprogram": "^1.4.2" |
| | | } |
| | | } |
| | |
| | | const audio = wx.createInnerAudioContext() |
| | | const recorderManager = wx.getRecorderManager() |
| | | const { |
| | | BASEURL |
| | | } = require('../../api/config') |
| | | Page({ |
| | | data: { |
| | | isRefreshing: false, |
| | |
| | | width: 160, |
| | | height: 160, |
| | | }, |
| | | originFiles: [ |
| | | ], |
| | | originFiles: [], |
| | | feedBackList: Array(19).fill({ |
| | | createTime: "2023-05-06 12:36:25", |
| | | responseTime: "2023-05-07 12:36:25" |
| | | }), |
| | | contentValue:''//反馈详情 |
| | | contentValue: '', //反馈详情 |
| | | accSavePath: '', //上传的音频文件接口返回的地址 |
| | | photoSavePath: [] //上传的照片文件返回的地址 |
| | | }, |
| | | |
| | | onLoad() { |
| | |
| | | time: 3000 |
| | | }) |
| | | } else { |
| | | |
| | | |
| | | that.setData({ |
| | | voiceTime: voiceTime, |
| | | isShowVoiceMask: false, |
| | |
| | | } = res; //这里松开按钮 会返回录音本地路径 |
| | | audio.src = tempFilePath |
| | | console.log(tempFilePath); |
| | | that.upACC(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; |
| | | // } |
| | | // } |
| | | // }) |
| | | }); |
| | | recorderManager.onStart(() => { |
| | | console.log('录音开始'); |
| | |
| | | recorderManager.onError((err) => { |
| | | console.log('录音错误', err); |
| | | }); |
| | | }, |
| | | //上传音频文件 |
| | | upACC(tempFilePath) { |
| | | //上传录制的音频到服务器 |
| | | wx.uploadFile({ |
| | | url: BASEURL + "wx/webFile/upPhone", //接口地址 |
| | | name: 'file.acc', //上传文件名 |
| | | filePath: tempFilePath, |
| | | success: function (res) { //后台返回给前端识别后的文字 |
| | | |
| | | } |
| | | }) |
| | | }, |
| | | handleRemove(e) { |
| | | console.log("handleRemove"); |
| | |
| | | const { |
| | | originFiles |
| | | } = this.data; |
| | | let imgPath = e.detail.file.url; |
| | | const updatedFiles = this.data.originFiles.map((file) => { |
| | | //当上传失败点击时重新上传 |
| | | if (file.url === imgPath && file.uploadTask) { |
| | | file.uploadTask.abort(); |
| | | } |
| | | }); |
| | | originFiles.splice(index, 1); |
| | | this.setData({ |
| | | originFiles, |
| | | }); |
| | | |
| | | }, |
| | | handleClick() { |
| | | handleClick(e) { |
| | | console.log("handleClick"); |
| | | let imgPath = e.detail.file.url; |
| | | const updatedFiles = this.data.originFiles.map((file) => { |
| | | //当上传失败点击时重新上传 |
| | | if (file.url === imgPath && file.status === "reload") { |
| | | this.onUploadPhoto(imgPath); |
| | | } |
| | | }); |
| | | }, |
| | | handleAdd(e) { |
| | | console.log("handleAdd"); |
| | |
| | | const { |
| | | originFiles |
| | | } = this.data; |
| | | this.setData({ |
| | | originFiles: [...originFiles, ...files], // 此时设置了 fileList 之后才会展示选择的图片 |
| | | const updatedList = files.map(item => { |
| | | return { |
| | | ...item, |
| | | status: 'loading', |
| | | uploadTask: this.onUploadPhoto(e.detail.files[0].url) |
| | | }; // 保留所有其他字段,并添加 displayText 字段 |
| | | }); |
| | | // 更新列表数据 |
| | | this.setData({ |
| | | originFiles: [...originFiles, ...updatedList], // 此时设置了 fileList 之后才会展示选择的图片 |
| | | }); |
| | | }, |
| | | handleSuccess(e) { |
| | | |
| | | }, |
| | | /** |
| | | * 上传图片 |
| | | */ |
| | | onUpload() { |
| | | wx.uploadFile({ |
| | | url: 'https://example.weixin.qq.com/upload', // 仅为示例,非真实的接口地址 |
| | | filePath: file.url, |
| | | onUploadPhoto(imgPath) { |
| | | const uploadTask = wx.uploadFile({ |
| | | url: BASEURL + "wx/webFile/upPhone", // 仅为示例,非真实的接口地址 |
| | | filePath: imgPath, |
| | | name: 'file', |
| | | formData: { |
| | | user: 'test' |
| | | }, |
| | | success: () => { |
| | | this.setData({ |
| | | [`fileList[${length}].status`]: 'done', |
| | | }); |
| | | |
| | | }, |
| | | fail: (err) => { |
| | | // 处理上传失败的逻辑 |
| | | const updatedFiles = this.data.originFiles.map((file) => { |
| | | if (file.url === imgPath) { |
| | | return { |
| | | ...file, |
| | | percent: progress, |
| | | status: "reload", // 上传失败状态 |
| | | }; |
| | | } |
| | | return file; |
| | | }); |
| | | this.setData({ |
| | | originFiles: updatedFiles, |
| | | }); |
| | | } |
| | | }); |
| | | if (uploadTask) { |
| | | uploadTask.onProgressUpdate((res) => { |
| | | //处理 |
| | | const progress = Math.round((res.progress / 100) * 100) |
| | | const updatedFiles = this.data.originFiles.map((file) => { |
| | | if (file.url === imgPath) { |
| | | return { |
| | | ...file, |
| | | percent: progress, |
| | | status: progress < 100 ? 'loading' : undefined, // 更新状态 |
| | | uploadTask: progress < 100 ? file.uploadTask : undefined, // 保持或删除uploadTask |
| | | }; |
| | | } |
| | | return file; |
| | | }); |
| | | this.setData({ |
| | | originFiles: updatedFiles, |
| | | }); |
| | | }); |
| | | } |
| | | return uploadTask; |
| | | }, |
| | | //按住按钮 |
| | | startHandel() { |
| | |
| | | isRefreshing: false |
| | | }); |
| | | }, |
| | | feelBack(){ |
| | | feelBack() { |
| | | wx.showLoading({ |
| | | title: '正在提交...', // 加载提示文字 |
| | | mask: true // 是否显示透明蒙层,防止触摸穿透,默认为 false |
| | |
| | | // } |
| | | }); |
| | | }, |
| | | handleDelete(){ |
| | | this.setData({ |
| | | isShowVoiceView:false, |
| | | voiceTime:0, |
| | | }) |
| | | handleDelete() { |
| | | this.setData({ |
| | | isShowVoiceView: false, |
| | | voiceTime: 0, |
| | | }) |
| | | } |
| | | |
| | | }); |
| | |
| | | get, |
| | | post |
| | | } = require('../../api/request.js'); |
| | | const app = getApp(); |
| | | Page({ |
| | | |
| | | /** |
| | |
| | | myItem: {}, |
| | | waterIntakeName: "", |
| | | image: "/images/ic_head_bg.jpg", |
| | | userPhone: "000****0000", |
| | | userName: "未知", |
| | | userPhone: "未登录", |
| | | userName: "点击登录", |
| | | scrollViewHeight: 0, |
| | | listData: [], |
| | | isRefreshing: false, |
| | |
| | | }, |
| | | errorDialogTitle: "关阀错误", |
| | | showForceConfirm: false, //是否强制开阀 |
| | | lastIntakeName: "" |
| | | lastIntakeName: "", |
| | | isLogin: false, //是否已经登录 |
| | | }, |
| | | |
| | | openValve: function (e) { |
| | | wx.navigateTo({ |
| | | url: '/pages/waterIntake/waterIntake', |
| | | }) |
| | | if (this.data.isLogin) { |
| | | wx.navigateTo({ |
| | | url: '/pages/waterIntake/waterIntake', |
| | | }) |
| | | } else { |
| | | wx.showToast({ |
| | | title: '请先登录', |
| | | icon: 'error' |
| | | }) |
| | | } |
| | | |
| | | }, |
| | | calculateScrollViewHeight: function () { |
| | | wx.createSelectorQuery().selectAll('.list-item').boundingClientRect((rects) => { |
| | |
| | | }).exec(); |
| | | }, |
| | | startPullDownRefresh() { |
| | | if (!this.data.isWXRefreshing) { |
| | | var self = this; |
| | | console.log(this.data.isRefreshing); |
| | | this.setData({ |
| | | isRefreshing: true |
| | | }); |
| | | this.getOpenList(); |
| | | |
| | | if(this.data.isLogin){ |
| | | if (!this.data.isWXRefreshing) { |
| | | var self = this; |
| | | console.log(this.data.isRefreshing); |
| | | this.setData({ |
| | | isRefreshing: true |
| | | }); |
| | | this.getOpenList(); |
| | | } |
| | | }else{ |
| | | wx.showToast({ |
| | | title: '请先登录', |
| | | icon: 'error' |
| | | }) |
| | | } |
| | | |
| | | |
| | | }, |
| | | //获取用户数据 |
| | |
| | | console.error('Failed to fetch data:', error); |
| | | }); |
| | | }, |
| | | |
| | | |
| | | |
| | | /** |
| | | * 生命周期函数--监听页面加载 |
| | | */ |
| | | onLoad(options) { |
| | | //判断本地是否保存sessionId |
| | | |
| | | |
| | | // 使用 wx.nextTick 等待页面渲染完成 |
| | | wx.nextTick(() => { |
| | | this.calculateScrollViewHeight(); |
| | |
| | | }) |
| | | this.getOpenList(); |
| | | } |
| | | this.initData(); |
| | | |
| | | }, |
| | | |
| | | /** |
| | | * 生命周期函数--监听页面初次渲染完成 |
| | | */ |
| | | onReady() { |
| | | |
| | | //判断本地是否保存sessionId |
| | | if (storage.isHasKeySync("sessionId")) { |
| | | const app = getApp(); |
| | | storage.getItem('sessionId').then((data) => { |
| | | app.globalData.sessionId = data; |
| | | if (app.globalData.sessionId) { |
| | | this.getOpenList(); |
| | | this.getUserDataBySession(); |
| | | } |
| | | }).catch((err) => {}); |
| | | storage.getItem('clientId').then((data) => { |
| | | app.globalData.clientId = data; |
| | | }).catch((err) => {}); |
| | | } else { |
| | | //本地没有缓存微信登录 |
| | | this.wxLogin(); |
| | | } |
| | | }, |
| | | |
| | | /** |
| | | * 生命周期函数--监听页面显示 |
| | | */ |
| | | onShow() { |
| | | |
| | | wxLogin() { |
| | | const that = this; |
| | | wx.login({ |
| | | success: function (res) { |
| | | if (res.code) { |
| | | var code = res.code; |
| | | console.log(code); |
| | | // 将code发送到服务器获取openid |
| | | that.codeLogin(code); |
| | | } else { |
| | | console.log('登录失败!' + res.errMsg); |
| | | } |
| | | } |
| | | }); |
| | | }, |
| | | //微信code登录 |
| | | codeLogin(codeData) { |
| | | wx.showLoading({ |
| | | title: '正在登录请稍候...', // 加载提示文字 |
| | | mask: true // 是否显示透明蒙层,防止触摸穿透,默认为 false |
| | | }); |
| | | const data = { |
| | | code: codeData, //临时登录凭证 |
| | | }; |
| | | post({ |
| | | url: "wx/client/code_login", |
| | | data: data, |
| | | }).then(response => { |
| | | // 处理成功响应 |
| | | console.log('请求成功:', response); |
| | | // 加载完成后隐藏加载动画 |
| | | wx.hideLoading(); |
| | | if (response.code === "0001") { |
| | | //假如为空则跳转到绑定界面 |
| | | if (response.content.client.clientId === "") { |
| | | wx.navigateTo({ |
| | | url: '/pages/wxbind/wxbind' |
| | | }) |
| | | } else { |
| | | //缓存在本地 |
| | | this.setData({ |
| | | isLogin: true |
| | | }) |
| | | getApp().globalData.sessionId = response.content.client.sessionId |
| | | storage.setItem("sessionId", response.content.client.sessionId) |
| | | getApp().globalData.clientId = response.content.client.clientId |
| | | storage.setItem("clientId", response.content.client.clientId) |
| | | this.initData(); |
| | | } |
| | | } else { |
| | | |
| | | /** |
| | | * 生命周期函数--监听页面隐藏 |
| | | */ |
| | | onHide() { |
| | | |
| | | } |
| | | }).catch(error => { |
| | | // 加载完成后隐藏加载动画 |
| | | wx.hideLoading(); |
| | | // 处理错误响应 |
| | | console.error('请求失败:', error); |
| | | }); |
| | | }, |
| | | |
| | | /** |
| | | * 生命周期函数--监听页面卸载 |
| | | */ |
| | | onUnload() { |
| | | |
| | | }, |
| | | |
| | | /** |
| | | * 页面相关事件处理函数--监听用户下拉动作 |
| | | */ |
| | |
| | | // 数据请求完成后,停止下拉刷新的动画 |
| | | this.getOpenList(); |
| | | }, |
| | | |
| | | /** |
| | | * 页面上拉触底事件的处理函数 |
| | | */ |
| | | onReachBottom() { |
| | | |
| | | }, |
| | | |
| | | /** |
| | | * 用户点击右上角分享 |
| | | */ |
| | | onShareAppMessage() { |
| | | |
| | | }, |
| | | // 充值 |
| | | recharge() { |
| | | wx.navigateTo({ |
| | | url: '/pages/rechargeCard/rechargeCard', |
| | | }) |
| | | // wx.showToast({ |
| | | // title: '暂未开放', |
| | | // icon: 'none' |
| | | // }) |
| | | if (this.data.isLogin) { |
| | | wx.navigateTo({ |
| | | url: '/pages/rechargeCard/rechargeCard', |
| | | }) |
| | | } else { |
| | | wx.showToast({ |
| | | title: '请先登录', |
| | | icon: 'error' |
| | | }) |
| | | } |
| | | }, |
| | | //开关阀记录 |
| | | openValveList() { |
| | | wx.navigateTo({ |
| | | url: '/pages/valveList/valveList', |
| | | }) |
| | | // wx.showToast({ |
| | | // title: '暂未开放', |
| | | // icon: 'none' |
| | | // }) |
| | | if (this.data.isLogin) { |
| | | wx.navigateTo({ |
| | | url: '/pages/valveList/valveList', |
| | | }) |
| | | } else { |
| | | wx.showToast({ |
| | | title: '请先登录', |
| | | icon: 'error' |
| | | }) |
| | | } |
| | | |
| | | }, |
| | | //问题反馈 |
| | | feedBack() { |
| | | // wx.showToast({ |
| | | // title: '暂未开放', |
| | | // icon: 'none' |
| | | // }) |
| | | wx.navigateTo({ |
| | | url: '/pages/feedback/feedback', |
| | | }) |
| | | if (this.data.isLogin) { |
| | | wx.navigateTo({ |
| | | url: '/pages/feedback/feedback', |
| | | }) |
| | | } else { |
| | | wx.showToast({ |
| | | title: '请先登录', |
| | | icon: 'error' |
| | | }) |
| | | } |
| | | }, |
| | | handleChange(e) { |
| | | const item = e.currentTarget.dataset.item; |
| | |
| | | // 加载完成后隐藏加载动画 |
| | | wx.hideLoading(); |
| | | this.getOpenList(); |
| | | if(response.content.data.success){ |
| | | if (response.content.data.success) { |
| | | wx.showToast({ |
| | | title: '关阀成功', |
| | | icon: 'success', |
| | | duration: 3000 |
| | | }) |
| | | }else{ |
| | | } else { |
| | | wx.showToast({ |
| | | title: '关阀失败', |
| | | icon: 'error', |
| | | duration: 3000 |
| | | }) |
| | | } |
| | | |
| | | |
| | | }).catch(error => { |
| | | wx.hideLoading(); |
| | | this.setData({ |
| | |
| | | isRefreshing: false, // 将triggered属性设置为false,表示下拉刷新已完成 |
| | | isWXRefreshing: false, // 将triggered属性设置为false,表示下拉刷新已完成 |
| | | }) |
| | | this.updateDisplayText(); |
| | | }).catch(err => { |
| | | // 错误回调 |
| | | this.setData({ |
| | |
| | | get(params).then(data => { |
| | | this.setData({ |
| | | userName: data.content.clientName, |
| | | userPhone: this.maskPhoneNumber(data.content.phone) |
| | | userPhone: this.maskPhoneNumber(data.content.phone), |
| | | isLogin: true |
| | | }) |
| | | }).catch(err => { |
| | | // 错误回调 |
| | |
| | | if (res.result.startsWith("content://")) { |
| | | let jsonStr = res.result.replace("content://", "") |
| | | try { |
| | | |
| | | that.saveData(jsonStr) |
| | | } catch (error) { |
| | | console.error('Error parsing JSON:', error); |
| | | } |
| | | |
| | | } else { |
| | | that.postOppenValva(res.result) |
| | | } |
| | | |
| | | }, |
| | | fail(err) { |
| | | console.error(err); |
| | |
| | | this.postOppenValva(this.data.lastIntakeName, true) |
| | | }, |
| | | /** |
| | | * |
| | | * 扫码开阀调用开阀接口 |
| | | * @param {*} intakeName |
| | | */ |
| | | postOppenValva(intakeName, isforce) { |
| | |
| | | //进入界面获取界面数据 |
| | | initData() { |
| | | const app = getApp(); |
| | | console.log("tag>>>>:" +app.globalData.tag) |
| | | |
| | | console.log("tag>>>>:" + app.globalData.tag) |
| | | if (storage.isHasKeySync("userData")) { |
| | | storage.getItem('userData').then((data) => { |
| | | let jsonObj = JSON.parse(data); |
| | |
| | | this.getOpenList(); |
| | | console.log('Failed to load parameter:false'); |
| | | } |
| | | |
| | | |
| | | }, |
| | | onDelete(){ |
| | | |
| | | //强制删除 |
| | | onDelete(e) { |
| | | const item = e.currentTarget.dataset.item; |
| | | const that = this; |
| | | wx.showLoading({ |
| | | title: '正在强制删除请稍候...', // 加载提示文字 |
| | | mask: true // 是否显示透明蒙层,防止触摸穿透,默认为 false |
| | | }); |
| | | that.setData({ |
| | | lastIntakeName: intakeName |
| | | }) |
| | | const data = { |
| | | vcNum: item.vcNum, //取水口ID |
| | | rtuAddr: item.rtuAddr, //阀控器地址 |
| | | }; |
| | | post({ |
| | | url: "wx/valve/deleteUnclosed", |
| | | data: data, |
| | | timeout: 180000 |
| | | }).then(response => { |
| | | // 处理成功响应 |
| | | console.log('请求成功:', response); |
| | | // 加载完成后隐藏加载动画 |
| | | wx.hideLoading(); |
| | | //重新获取列表刷新数据 |
| | | this.getOpenList(); |
| | | }).catch(error => { |
| | | // 加载完成后隐藏加载动画 |
| | | wx.hideLoading(); |
| | | // 处理错误响应 |
| | | console.error('请求失败:', error); |
| | | }); |
| | | }, |
| | | //修改按钮文字 |
| | | updateDisplayText() { |
| | | const updatedList = this.data.listData.map(item => { |
| | | let displayText = ''; |
| | | if (item.planned) { |
| | | displayText = '取消'; |
| | | } else { |
| | | displayText = "关阀" |
| | | } |
| | | return { |
| | | ...item, |
| | | displayText |
| | | }; // 保留所有其他字段,并添加 displayText 字段 |
| | | }); |
| | | // 更新列表数据 |
| | | this.setData({ |
| | | listData: updatedList |
| | | }); |
| | | }, |
| | | //解绑 |
| | | unbind() { |
| | | //清空数据 |
| | | this.setData({ |
| | | userPhone: "请登录", |
| | | userName: "未登录", |
| | | listData: [] |
| | | }) |
| | | wx.showLoading({ |
| | | title: '正在解绑请稍候...', // 加载提示文字 |
| | | mask: true // 是否显示透明蒙层,防止触摸穿透,默认为 false |
| | | }); |
| | | const data = { |
| | | sessionId: getApp().globalData.sessionId //取水口ID |
| | | }; |
| | | post({ |
| | | url: 'wx/client/unbind', |
| | | data: data, |
| | | useParams: true |
| | | }).then(response => { |
| | | // 处理成功响应 |
| | | console.log('请求成功:', response); |
| | | // 加载完成后隐藏加载动画 |
| | | wx.hideLoading(); |
| | | //清空数据 |
| | | this.setData({ |
| | | userPhone: "请登录", |
| | | userName: "未登录", |
| | | listData: [], |
| | | isLogin:false |
| | | }) |
| | | app.globalData.sessionId = ""; |
| | | app.globalData.clientId = "" |
| | | storage.removeItem("sessionId") |
| | | storage.removeItem("clientId") |
| | | wx.showToast({ |
| | | title: '解绑成功', |
| | | icon: 'success', |
| | | duration: 3000 |
| | | }) |
| | | }).catch(error => { |
| | | // 加载完成后隐藏加载动画 |
| | | wx.hideLoading(); |
| | | // 处理错误响应 |
| | | console.error('请求失败:', error); |
| | | }); |
| | | } |
| | | }) |
| | |
| | | <view class="head-top"> |
| | | <t-avatar class="avatar-example" image="{{image}}" size="120rpx" /> |
| | | <view class="head-text-wrapper"> |
| | | <text>{{userName}}</text> |
| | | <text class="head-bottom">{{userPhone}}</text> |
| | | <text bind:tap="wxLogin">{{userName}}</text> |
| | | <text wx:if="{{isLogin}}" class="head-bottom">{{userPhone}}</text> |
| | | </view> |
| | | <view class="head-button-wrapper"> |
| | | <text class="unbind" bind:tap="">解绑</text> |
| | | <text wx:if="{{isLogin}}" class="unbind" bind:tap="unbind">解绑</text> |
| | | <text class="head-bottom" bind:tap="feedBack">联系客服</text> |
| | | </view> |
| | | <view class="scen-view" bind:tap="scenCode"> |
| | |
| | | |
| | | <view class="bottom-title"> |
| | | <text class="bottom-title-text">快速关阀</text> |
| | | <text class="refresh-button" bind:tap="startPullDownRefresh">刷新</text> |
| | | <text class="refresh-button" bind:tap="startPullDownRefresh">刷新</text> |
| | | </view> |
| | | <view class="divider"></view> |
| | | <!-- refresher-enabled="true" refresher-threshold="50" --> |
| | |
| | | <text class="item-button" bind:tap="handleChange" data-item="{{item}}">关阀</text> |
| | | </view> |
| | | </view> |
| | | <view slot="right" class="delete-btn" bind:tap="onDelete">删除</view> |
| | | <view slot="right" class="delete-btn" bind:tap="onDelete" data-item="{{item}}">{{item.displayText}}</view> |
| | | </t-swipe-cell> |
| | | </view> |
| | | </view> |
| | |
| | | margin-bottom: 2rpx; |
| | | width: 100wh; |
| | | } |
| | | .swipe-cell-base{ |
| | | |
| | | } |
| | |
| | | // pages/rechargeCard/rechargeCard.js |
| | | //虚拟卡列表 |
| | | const { |
| | | get, |
| | | post |
| | |
| | | content: '确认' |
| | | }, |
| | | currentTab: 0, // 当前显示的表格,默认为第一个表格 |
| | | 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" |
| | | }], |
| | | allCardPoints: [], |
| | | 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 |
| | | showDialog: false, |
| | | isWXRefreshing: false |
| | | }, |
| | | // 切换 Tabs |
| | | switchTab: function (e) { |
| | |
| | | */ |
| | | onLoad(options) { |
| | | this.getCardList(); |
| | | this.getWaterCardList(); |
| | | // this.getWaterCardList(); |
| | | }, |
| | | |
| | | /** |
| | |
| | | * 页面相关事件处理函数--监听用户下拉动作 |
| | | */ |
| | | onPullDownRefresh() { |
| | | |
| | | this.setData({ |
| | | isWXRefreshing: true |
| | | }) |
| | | this.getCardList(); |
| | | }, |
| | | |
| | | /** |
| | |
| | | } |
| | | }) |
| | | .then((data) => { |
| | | this.setData({ |
| | | isWXRefreshing: false |
| | | }); |
| | | if (data.success && data.code === "0001") { |
| | | this.setData({ |
| | | allCardPoints: data.content |
| | | }); |
| | | this.updateDisplayText(); |
| | | } else { |
| | | wx.showToast({ |
| | | title: data.msg, |
| | |
| | | console.log('Failed to add item:'); |
| | | }) |
| | | .catch((error) => { |
| | | this.setData({ |
| | | isWXRefreshing: false |
| | | }); |
| | | console.error('Failed to add item:', error); |
| | | }); |
| | | }, |
| | |
| | | console.error('Failed to add item:', error); |
| | | }); |
| | | }, |
| | | rechargeCard(item) { |
| | | rechargeCard(event) { |
| | | wx.navigateTo({ |
| | | url: '/pages/rechargeMoney/rechargMoney' // 首页的路径,根据实际情况填写 |
| | | url: '/pages/rechargeMoney/rechargMoney?vcId='+event.currentTarget.dataset.item.id // 首页的路径,根据实际情况填写 |
| | | }); |
| | | }, |
| | | ruinCard() { |
| | | this.setData({ |
| | | showDialog: true |
| | | }) |
| | | ruinCard(item) { |
| | | const mItem = item.currentTarget.dataset.item; |
| | | |
| | | if (mItem.money > 0) { |
| | | //金额大于0不能销卡 |
| | | this.setData({ |
| | | showDialog: true |
| | | }) |
| | | } else { |
| | | //金额等于0才可销卡 |
| | | this.deleteID(mItem.id); |
| | | } |
| | | }, |
| | | closeDialog() { |
| | | this.setData({ |
| | | showDialog: false |
| | | }) |
| | | } |
| | | }, |
| | | //添加虚拟卡 |
| | | handleClick() { |
| | | wx.showLoading({ |
| | | title: '正在添加请稍候...', // 加载提示文字 |
| | | mask: true // 是否显示透明蒙层,防止触摸穿透,默认为 false |
| | | }); |
| | | const data = { |
| | | clientId: getApp().globalData.clientId, //临时登录凭证 |
| | | }; |
| | | post({ |
| | | url: "wx/virtual_card/add_vc", |
| | | data: data, |
| | | }).then(response => { |
| | | // 处理成功响应 |
| | | console.log('请求成功:', response); |
| | | // 加载完成后隐藏加载动画 |
| | | wx.hideLoading(); |
| | | if (response.code === "0001") { |
| | | wx.showToast({ |
| | | title: '添加成功', |
| | | icon: 'success', |
| | | duration: 3000 |
| | | }) |
| | | this.getCardList(); |
| | | } |
| | | }).catch(error => { |
| | | // 加载完成后隐藏加载动画 |
| | | wx.hideLoading(); |
| | | // 处理错误响应 |
| | | console.error('请求失败:', error); |
| | | wx.showToast({ |
| | | title: '添加失败', |
| | | icon: 'error', |
| | | duration: 2000 |
| | | }) |
| | | }); |
| | | }, |
| | | //注销虚拟卡 |
| | | deleteID(vcId) { |
| | | wx.showLoading({ |
| | | title: '正在销卡请稍候...', // 加载提示文字 |
| | | mask: true // 是否显示透明蒙层,防止触摸穿透,默认为 false |
| | | }); |
| | | const data = { |
| | | clientId: getApp().globalData.clientId, //临时登录凭证 |
| | | vcId: vcId //虚拟卡id |
| | | }; |
| | | post({ |
| | | url: "wx/virtual_card/cancel", |
| | | data: data, |
| | | }).then(response => { |
| | | // 处理成功响应 |
| | | console.log('请求成功:', response); |
| | | // 加载完成后隐藏加载动画 |
| | | wx.hideLoading(); |
| | | if (response.code === "0001") { |
| | | wx.showToast({ |
| | | title: '销卡成功', |
| | | icon: 'success', |
| | | duration: 3000 |
| | | }) |
| | | this.getCardList(); |
| | | } |
| | | }).catch(error => { |
| | | // 加载完成后隐藏加载动画 |
| | | wx.hideLoading(); |
| | | // 处理错误响应 |
| | | console.error('请求失败:', error); |
| | | wx.showToast({ |
| | | title: '注销失败', |
| | | icon: 'error', |
| | | duration: 2000 |
| | | }) |
| | | }); |
| | | }, |
| | | |
| | | |
| | | |
| | | |
| | | }) |
| | |
| | | { |
| | | "component": true, |
| | | "usingComponents": { |
| | | "t-dialog": "tdesign-miniprogram/dialog/dialog" |
| | | } |
| | | "t-dialog": "tdesign-miniprogram/dialog/dialog", |
| | | "t-fab": "tdesign-miniprogram/fab/fab" |
| | | }, |
| | | "navigationBarTitleText": "虚拟卡", |
| | | "navigationBarTextStyle": "white" |
| | | } |
| | |
| | | <!--pages/rechargeCard/rechargeCard.wxml 充值界面--> |
| | | <view class="container"> |
| | | <!-- 顶部 Tabs --> |
| | | <view class="tabs"> |
| | | <view class="tab" bindtap="switchTab" data-tab="0" id="tab0"> |
| | | <!-- <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> --> |
| | | <!-- <view class="tab" bindtap="switchTab" data-tab="1" id="tab1"> |
| | | 水卡 |
| | | <view class="indicator" wx:if="{{currentTab === 1}}"></view> |
| | | </view> |
| | | </view> |
| | | </view> --> |
| | | <!-- </view> --> |
| | | |
| | | <!-- 虚拟卡 --> |
| | | <scroll-view class="list-container" wx:if="{{currentTab === 0}}" scroll-y="true" scroll-x="false"> |
| | | <scroll-view class="list-container" wx:if="{{currentTab === 0}}" scroll-y="true" refresher-enabled="true" bindrefresherrefresh="onPullDownRefresh" scroll-x="false" refresher-triggered="{{isWXRefreshing}}"> |
| | | <block wx:if="{{allCardPoints.length > 0}}" wx:for="{{allCardPoints}}" wx:key="index"> |
| | | <view class="{{item.inUse===false?'item':'item-gray'}}"> |
| | | <view class="item-card"> |
| | |
| | | <text class="item-balance-text-yuan">元</text> |
| | | </view> |
| | | <view class="button-view"> |
| | | <text wx:if="{{item.inUse==0}}" class="ruinCard" bind:tap="ruinCard">销卡</text> |
| | | <text wx:if="{{item.inUse==0}}" class="recharge" bind:tap="rechargeCard">充值</text> |
| | | <text wx:if="{{item.inUse==0}}" class="ruinCard" data-item="{{item}}" bind:tap="ruinCard">销卡</text> |
| | | <text wx:if="{{item.inUse==0}}" class="recharge" data-item="{{item}}" bind:tap="rechargeCard">充值</text> |
| | | </view> |
| | | </view> |
| | | </view> |
| | | </block> |
| | | |
| | | |
| | | <view wx:if="{{allCardPoints.length === 0}}" class="noMore-View"> |
| | | <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" /> |
| | | |
| | | </scroll-view> |
| | | |
| | | <!-- 水卡 --> |
| | |
| | | </scroll-view> |
| | | |
| | | </view> |
| | | <t-fab icon="gesture-add" text="添加虚拟卡" bind:click="handleClick" bind:move="handleMove" aria-label="增加" usingCustomNavbar draggable y-bounds="{{[0, 32]}}" style="--td-primary-color-7:#2D8BF7"></t-fab> |
| | | <t-dialog visible="{{showDialog}}" content="您还有余额未使用,如需销卡,请先使用完或退款后才可操作。" confirm-btn="{{ confirmBtn }}" bind:confirm="closeDialog" /> |
| | | </view> |
| | |
| | | } |
| | | |
| | | .waterIntake-recharge { |
| | | margin-left: auto; /* 将按钮推到容器最右侧 */ |
| | | margin-left: auto; |
| | | /* 将按钮推到容器最右侧 */ |
| | | cursor: pointer; |
| | | background-color: #32CD32; |
| | | color: white; |
| | |
| | | // pages/rechargeMoney/rechargMoney.js |
| | | //充值界面 |
| | | const { |
| | | get, |
| | | post |
| | | } = require('../../api/request.js'); |
| | | const md5 = require('js-md5'); |
| | | Page({ |
| | | |
| | | /** |
| | |
| | | userCode: "15584236", |
| | | balance: "1025元", |
| | | activeIndex: -1, |
| | | allRechargeList: [{ |
| | | time: "2024-05-12:20:20", |
| | | type: "远程", |
| | | morny: "500元" |
| | | }, { |
| | | time: "2024-05-12:20:20", |
| | | type: "远程", |
| | | morny: "500元" |
| | | }, { |
| | | time: "2024-05-12:20:20", |
| | | type: "远程", |
| | | morny: "500元" |
| | | }, { |
| | | time: "2024-05-12:20:20", |
| | | type: "远程", |
| | | morny: "500元" |
| | | }] |
| | | isClickable: false, |
| | | allRechargeList: [], |
| | | vcId: "", |
| | | pageCurr: 1, //充值记录当前页码 |
| | | pageSize: 20, //充值记录每页记录数 |
| | | loading: false, //是否正在加载 |
| | | hasMore: true, |
| | | }, |
| | | |
| | | /** |
| | | * 生命周期函数--监听页面加载 |
| | | */ |
| | | onLoad(options) { |
| | | |
| | | this.setData({ |
| | | vcId: options.vcId |
| | | }) |
| | | }, |
| | | |
| | | /** |
| | | * 生命周期函数--监听页面初次渲染完成 |
| | | */ |
| | | onReady() { |
| | | |
| | | this.getRechargList() |
| | | }, |
| | | |
| | | /** |
| | |
| | | * 页面相关事件处理函数--监听用户下拉动作 |
| | | */ |
| | | onPullDownRefresh() { |
| | | |
| | | this.setData({ |
| | | pageCurr: 1 |
| | | }) |
| | | this.getRechargList() |
| | | }, |
| | | |
| | | /** |
| | |
| | | if (index !== undefined) { |
| | | this.setData({ |
| | | activeIndex: parseInt(index), |
| | | isClickable: true |
| | | }); |
| | | } |
| | | }, |
| | | onPullDownRefresh() { |
| | | console.log("onPullDownRefresh") |
| | | //创建订单并调起支付 |
| | | creatOrder() { |
| | | if (!this.data.isClickable) { |
| | | return; |
| | | } |
| | | const data = { |
| | | sessionId: getApp().globalData.sessionId, |
| | | vcId: this.data.vcId, //虚拟卡ID |
| | | rechargeAmount: 1 //(单位是分) |
| | | }; |
| | | console.log("postCloseValaue" + data); |
| | | post({ |
| | | url: "wx/payment/placeOrder", |
| | | data: data |
| | | }).then(response => { |
| | | // 处理成功响应 |
| | | console.log('请求成功:', response); |
| | | this.getOrderSign(response.content.prepay_id) |
| | | }).catch(error => { |
| | | if (error.code === "1002") {} |
| | | // 处理错误响应 |
| | | console.error('请求失败:', error); |
| | | }); |
| | | }, |
| | | //获取订单返回的prepay_id的签名 |
| | | getOrderSign(id) { |
| | | const params = { |
| | | url: 'wx/payment/signAgain', |
| | | data: { |
| | | prepayId: id |
| | | } |
| | | }; |
| | | get(params).then(data => { |
| | | // 调起支付 |
| | | wx.requestPayment({ |
| | | timeStamp: data.content.timeStamp, |
| | | nonceStr: data.content.nonceStr, |
| | | package: data.content.package, |
| | | signType: data.content.signType, |
| | | paySign: data.content.paySign, |
| | | success(res) { |
| | | console.log('支付成功', res); |
| | | }, |
| | | fail(err) { |
| | | console.log('支付失败', err); |
| | | } |
| | | }); |
| | | }).catch(err => { |
| | | wx.showToast({ |
| | | title: err.msg, |
| | | icon: 'error', |
| | | duration: 3000 |
| | | }) |
| | | }); |
| | | }, |
| | | //获取充值记录 |
| | | getRechargList() { |
| | | const params = { |
| | | url: 'wx/virtual_card/getVcRechargeRecords', |
| | | data: { |
| | | vcId: this.data.vcId, |
| | | pageCurr: this.data.pageCurr, |
| | | pageSize: this.data.pageSize, |
| | | } |
| | | }; |
| | | get(params).then(data => { |
| | | this.setData({ |
| | | allRechargeList:this.data.allRechargeList.concat( data.content.obj), |
| | | isWXRefreshing: false, // 将triggered属性设置为false,表示下拉刷新已完成 |
| | | loading: false, |
| | | hasMore: !data.content.obj.pageTotal === this.data.pageCurr |
| | | }) |
| | | this.updateDisplayText(); |
| | | }).catch(err => { |
| | | // 错误回调 |
| | | this.setData({ |
| | | isWXRefreshing: false, // 将triggered属性设置为false,表示下拉刷新已完成 |
| | | loading: false |
| | | }) |
| | | wx.showToast({ |
| | | title: err.msg, |
| | | icon: 'error', |
| | | duration: 3000 |
| | | }) |
| | | }); |
| | | }, |
| | | // 生成支付签名的函数 |
| | | 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(); |
| | | }, |
| | | //加载更多 |
| | | loadMore() { |
| | | if (this.data.hasMore && !this.data.loading) { |
| | | this.setData({ |
| | | loading: true, |
| | | pageCurr: this.data.pageCurr + 1 |
| | | }) |
| | | this.getRechargList(); |
| | | } |
| | | }, |
| | | updateDisplayText() { |
| | | const updatedList = this.data.allRechargeList.map(item => { |
| | | let morny = item.rechargeAmount / 100 + "元" |
| | | return { |
| | | ...item, |
| | | morny |
| | | }; // 保留所有其他字段,并添加 displayText 字段 |
| | | }); |
| | | // 更新列表数据 |
| | | this.setData({ |
| | | allRechargeList: updatedList |
| | | }); |
| | | } |
| | | }) |
| | |
| | | </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> |
| | | |
| | | <view class="rechageList-view"> |
| | | <text class="rechageList-view-head">充值记录</text> |
| | | <scroll-view class="list-container" scroll-y="true" scroll-x="false" refresher-enabled="true" refresher-threshold="50" bindrefresherrefresh="onPullDownRefresh"> |
| | | <scroll-view class="list-container" scroll-y="true" scroll-x="false" refresher-enabled="true" refresher-threshold="50" |
| | | bindrefresherrefresh="onPullDownRefresh" refresher-triggered="{{isWXRefreshing}}" bindscrolltolower="loadMore"> |
| | | <block wx:if="{{allRechargeList.length > 0}}" wx:for="{{allRechargeList}}" wx:key="index"> |
| | | <view class="itemList"> |
| | | <text class="item-card-text">{{item.time}}</text> |
| | | <text class="item-card-text">{{item.rechargeTime}}</text> |
| | | <text class="item-card-text">{{item.type}}</text> |
| | | <text class="item-card-text">{{item.morny}}</text> |
| | | </view> |
| | |
| | | <image class="noMore-img" src="/images/no_more.svg" /> |
| | | <text class="noMore-text">没有数据</text> |
| | | </view> |
| | | <view wx:if="{{loading}}" class="loading">加载中...</view> <!-- 加载指示器 --> |
| | | </scroll-view> |
| | | |
| | | |
| | |
| | | |
| | | .item-card-text { |
| | | font-size: 35rpx; |
| | | } |
| | | |
| | | .loading { |
| | | text-align: center; |
| | | padding: 20px; |
| | | } |
| | |
| | | // pages/valveList/valveList.js 开关阀记录 |
| | | const { |
| | | get, |
| | | post |
| | | } = require('../../api/request.js'); |
| | | |
| | | Page({ |
| | | |
| | | /** |
| | | * 页面的初始数据 |
| | | */ |
| | | data: { |
| | | listData: [{ |
| | | listVirtualData: [{ |
| | | intakeNum: "1023356646612", |
| | | watername:"测试", |
| | | startTime:"2024.10.15 12:23", |
| | | endTime:"2024.10.15 16:23" |
| | | watername: "测试", |
| | | startTime: "2024.10.15 12:23", |
| | | endTime: "2024.10.15 16:23" |
| | | |
| | | }, { |
| | | intakeNum: "1023356646612", |
| | | watername:"测试1", |
| | | startTime:"2024.10.15 12:23", |
| | | endTime:"2024.10.15 16:23" |
| | | watername: "测试1", |
| | | startTime: "2024.10.15 12:23", |
| | | endTime: "2024.10.15 16:23" |
| | | }, { |
| | | intakeNum: "1023356646612", |
| | | watername:"测试2", |
| | | startTime:"2024.10.15 12:23", |
| | | endTime:"2024.10.15 16:23" |
| | | watername: "测试2", |
| | | startTime: "2024.10.15 12:23", |
| | | endTime: "2024.10.15 16:23" |
| | | }, { |
| | | intakeNum: "1023356646612", |
| | | watername:"测试3", |
| | | startTime:"2024.10.15 12:23", |
| | | endTime:"2024.10.15 16:23" |
| | | watername: "测试3", |
| | | startTime: "2024.10.15 12:23", |
| | | endTime: "2024.10.15 16:23" |
| | | }, { |
| | | intakeNum: "1023356646612", |
| | | watername:"测试4", |
| | | startTime:"2024.10.15 12:23", |
| | | endTime:"2024.10.15 16:23" |
| | | }] |
| | | watername: "测试4", |
| | | startTime: "2024.10.15 12:23", |
| | | endTime: "2024.10.15 16:23" |
| | | }], |
| | | listPhysicalData: [], |
| | | currentTab: 0, |
| | | isVirtualRefreshing: false, //虚拟卡刷新中 |
| | | isPhysicalRefreshing: false, //实体卡刷新中 |
| | | physicalPageCurr: 1, //实体卡当前页数 |
| | | pageSize: 20, |
| | | virtualPageCurr: 1, //虚拟卡当前页数 |
| | | virtualhasMore: true, |
| | | physicalHasMore: true, |
| | | virtualIsLoding: false, |
| | | physicalIsLoding: false, |
| | | |
| | | }, |
| | | |
| | | /** |
| | |
| | | * 生命周期函数--监听页面初次渲染完成 |
| | | */ |
| | | onReady() { |
| | | |
| | | this.getPhysicalListData(); |
| | | this.getVirtualListData(); |
| | | }, |
| | | |
| | | /** |
| | |
| | | */ |
| | | onShareAppMessage() { |
| | | |
| | | }, |
| | | switchTab(e) { |
| | | const tab = parseInt(e.currentTarget.dataset.tab); |
| | | this.setData({ |
| | | currentTab: tab |
| | | }); |
| | | }, |
| | | //虚拟卡刷新 |
| | | onPullVirtualDownRefresh() { |
| | | this.setData({ |
| | | isVirtualRefreshing: true, |
| | | }) |
| | | this.getVirtualListData(); |
| | | }, |
| | | //实体卡刷新 |
| | | onPullPhysicalDownRefresh() { |
| | | this.setData({ |
| | | isPhysicalRefreshing: true, |
| | | }) |
| | | this.getPhysicalListData(); |
| | | }, |
| | | //获取实体卡列表 |
| | | getPhysicalListData() { |
| | | get({ |
| | | url: 'wx/intake/getCardOpenClose', |
| | | data: { |
| | | // clientId: getApp().globalData.clientId, |
| | | pageCurr: this.data.physicalPageCurr, |
| | | pageSize: this.data.pageSize |
| | | } |
| | | }) |
| | | .then((data) => { |
| | | this.setData({ |
| | | isPhysicalRefreshing: false, |
| | | physicalIsLoding: false |
| | | }); |
| | | if (data.success && data.code === "0001") { |
| | | this.setData({ |
| | | listPhysicalData: data.content.obj, |
| | | physicalHasMore: !data.content.obj.pageTotal === this.data.physicalPageCurr, |
| | | |
| | | }); |
| | | } else { |
| | | wx.showToast({ |
| | | title: data.msg, |
| | | }) |
| | | } |
| | | console.log('Failed to add item:'); |
| | | }) |
| | | .catch((error) => { |
| | | this.setData({ |
| | | isWXRefreshing: false |
| | | }); |
| | | console.error('Failed to add item:', error); |
| | | }); |
| | | }, |
| | | //获取虚拟卡开关阀记录 |
| | | getVirtualListData() { |
| | | get({ |
| | | url: 'wx/intake/getVcCardOpenClose', |
| | | data: { |
| | | clientId: getApp().globalData.clientId, |
| | | pageCurr: this.data.physicalPageCurr, |
| | | pageSize: this.data.pageSize |
| | | } |
| | | }) |
| | | .then((data) => { |
| | | this.setData({ |
| | | isVirtualRefreshing: false, |
| | | virtualIsLoding: false |
| | | }); |
| | | if (data.success && data.code === "0001") { |
| | | this.setData({ |
| | | listPhysicalData: data.content.obj, |
| | | physicalHasMore: !data.content.obj.pageTotal === this.data.virtualPageCurr, |
| | | |
| | | }); |
| | | } else { |
| | | wx.showToast({ |
| | | title: data.msg, |
| | | }) |
| | | } |
| | | console.log('Failed to add item:'); |
| | | }) |
| | | .catch((error) => { |
| | | this.setData({ |
| | | isWXRefreshing: false |
| | | }); |
| | | console.error('Failed to add item:', error); |
| | | }); |
| | | }, |
| | | //加载更多的实体卡 |
| | | loadPhysicalMore() { |
| | | if (this.data.physicalHasMore) { |
| | | this.setData({ |
| | | physicalIsLoding: true, |
| | | physicalPageCurr: this.data.physicalPageCurr + 1 |
| | | }) |
| | | this.getPhysicalListData(); |
| | | } |
| | | }, |
| | | //加载更多的虚拟卡 |
| | | loadVirtualMore() { |
| | | if (this.data.virtualhasMore) { |
| | | this.setData({ |
| | | virtualIsLoding: true, |
| | | virtualPageCurr: this.data.virtualPageCurr + 1 |
| | | }) |
| | | this.getVirtualListData(); |
| | | } |
| | | |
| | | } |
| | | |
| | | }) |
| | |
| | | <!--pages/valveList/valveList.wxml 开关阀记录--> |
| | | <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="container"> |
| | | <!-- 顶部 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> |
| | | <scroll-view class="list-container" wx:if="{{currentTab === 0}}" scroll-y="true" scroll-x="false" refresher-enabled="true" bindrefresherrefresh="onPullVirtualDownRefresh" scroll-x="false" refresher-triggered="{{isVirtualRefreshing}}" bindscrolltolower="loadVirtualMore"> |
| | | <block wx:if="{{listVirtualData.length > 0}}" wx:for="{{listVirtualData}}" wx:key="index"> |
| | | <view class="list-item" > |
| | | <!-- <image class="item-img" src="/images/pipeline.svg" /> --> |
| | | <view class="item-time"> |
| | | <text class="item-text">消费金额:</text> |
| | | <view> |
| | | <text class="item-morny">50</text> |
| | | <text class="item-morny">{{item.expense}}</text> |
| | | <text class="item-text"> 元</text> |
| | | </view> |
| | | </view> |
| | | <text class="item-text">虚拟卡编号:{{item.intakeNum}}</text> |
| | | <text class="item-text">取水口名称:{{item.watername}}</text> |
| | | <text class="item-text">开阀时间:{{item.startTime}}</text> |
| | | <text class="item-text">关阀时间:{{item.endTime}}</text> |
| | | <text class="item-text">水卡编号:{{item.cardNum}}</text> |
| | | <text class="item-text">取水口编号:{{item.intakeNum}}</text> |
| | | <text class="item-text">开阀类型:{{item.openType}}</text> |
| | | <text class="item-text">开阀时间:{{item.openTime}}</text> |
| | | <text class="item-text">关阀时间:{{item.closeTime}}</text> |
| | | <view class="item-time"> |
| | | <text class="item-text">用水时长:120 分钟</text> |
| | | <text class="item-text">用水量:2 m³</text> |
| | | <text class="item-text">用水时长:{{item.duration}}分钟</text> |
| | | <text class="item-text">用水量:{{item.amount}} m³</text> |
| | | </view> |
| | | |
| | | </view> |
| | |
| | | <image class="noMore-img" src="/images/no_more.svg" /> |
| | | <text class="noMore-text">没有数据</text> |
| | | </view> |
| | | <view wx:if="{{virtualIsLoding}}" class="loading">加载中...</view> <!-- 加载指示器 --> |
| | | </scroll-view> |
| | | |
| | | <scroll-view class="list-container" wx:else scroll-y="true" scroll-x="false" refresher-enabled="true" bindrefresherrefresh="onPullPhysicalDownRefresh" scroll-x="false" refresher-triggered="{{isPhysicalRefreshing}}" bindscrolltolower="loadPhysicalMore"> |
| | | <block wx:if="{{listPhysicalData.length > 0}}" wx:for="{{listPhysicalData}}" wx:key="index"> |
| | | <view class="list-item" > |
| | | <!-- <image class="item-img" src="/images/pipeline.svg" /> --> |
| | | <view class="item-time"> |
| | | <text class="item-text">消费金额:</text> |
| | | <view> |
| | | <text class="item-morny">{{item.expense}}</text> |
| | | <text class="item-text"> 元</text> |
| | | </view> |
| | | </view> |
| | | <text class="item-text">水卡编号:{{item.cardNum}}</text> |
| | | <text class="item-text">取水口编号:{{item.intakeNum}}</text> |
| | | <text class="item-text">开阀类型:{{item.openType}}</text> |
| | | <text class="item-text">开阀时间:{{item.openTime}}</text> |
| | | <text class="item-text">关阀时间:{{item.closeTime}}</text> |
| | | <view class="item-time"> |
| | | <text class="item-text">用水时长:{{item.duration}}分钟</text> |
| | | <text class="item-text">用水量:{{item.amount}} m³</text> |
| | | </view> |
| | | |
| | | </view> |
| | | </block> |
| | | <view wx:if="{{listData.length === 0}}" class="noMore-View"> |
| | | <image class="noMore-img" src="/images/no_more.svg" /> |
| | | <text class="noMore-text">没有数据</text> |
| | | </view> |
| | | <view wx:if="{{physicalIsLoding}}" class="loading">加载中...</view> <!-- 加载指示器 --> |
| | | </scroll-view> |
| | | </view> |
| | |
| | | /* pages/valveList/valveList.wxss */ |
| | | .container { |
| | | display: flex; |
| | | flex-direction: column; |
| | | height: 100vh; |
| | | width: 100%; |
| | | padding-left: 20rpx; |
| | | padding-right: 20rpx; |
| | | padding-top: 5rpx; |
| | | padding-bottom: 5rpx; |
| | | background-color: #fff; |
| | | } |
| | | |
| | | .list-item { |
| | | display: flex; |
| | | flex-direction: column; |
| | |
| | | color: #FFFF00; |
| | | font-size: 50rpx; |
| | | font-weight: bold; |
| | | } |
| | | |
| | | .tab { |
| | | font-size: 16px; |
| | | padding: 10px; |
| | | cursor: pointer; |
| | | position: relative; |
| | | width: 50%; |
| | | /* Tabs 平分整个横向屏幕 */ |
| | | text-align: center; |
| | | /* 文字居中 */ |
| | | } |
| | | |
| | | .tabs { |
| | | display: flex; |
| | | justify-content: space-around; |
| | | position: relative; |
| | | width: 100%; |
| | | border-bottom: 1px solid #eee; |
| | | /* Tabs 占满整个横向屏幕 */ |
| | | } |
| | | |
| | | .indicator { |
| | | width: 100%; |
| | | height: 3px; |
| | | background-color: #1890FF; |
| | | position: absolute; |
| | | bottom: 0; |
| | | left: 0; |
| | | transform: translateX(0); |
| | | /* 初始化位置 */ |
| | | } |
| | |
| | | // pages/wxbind/wxbind.js |
| | | const app = getApp(); |
| | | const { |
| | | get, |
| | | post |
| | | } = require('../../api/request.js'); |
| | | const storage = require('../../utils/storage.js'); |
| | | Page({ |
| | | |
| | | /** |
| | |
| | | */ |
| | | data: { |
| | | mobile: '', |
| | | code: '', |
| | | phoneCode: '', |
| | | codeSent: false, |
| | | countdown: 60, |
| | | isButtonEnabled: false |
| | | }, |
| | | onLoad(options) { |
| | | |
| | | }, |
| | | bindMobileInput(e) { |
| | | this.setData({ |
| | |
| | | |
| | | 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); |
| | | }, |
| | |
| | | }); |
| | | return; |
| | | } |
| | | |
| | | if (this.data.mobile.length != 11) { |
| | | wx.showToast({ |
| | | title: '请输入完整手机号', |
| | | icon: 'none', |
| | | duration: 2000, |
| | | }); |
| | | return; |
| | | } |
| | | // 在这里处理发送验证码的逻辑,可以调用后台接口实现 |
| | | // 以下是一个简单的示例,仅作参考 |
| | | wx.showToast({ |
| | | title: '验证码已发送', |
| | | icon: 'success', |
| | | duration: 2000, |
| | | }); |
| | | |
| | | this.postCode(); |
| | | this.setData({ |
| | | codeSent: true, |
| | | }); |
| | | |
| | | // 启动倒计时 |
| | | this.startCountdown(); |
| | | }, |
| | |
| | | } |
| | | }, 1000); |
| | | }, |
| | | bind: function () { |
| | | bindSuccess: function () { |
| | | if (!this.data.isButtonEnabled) return; |
| | | wx.showToast({ |
| | | title: '绑定成功', |
| | | icon: 'success' |
| | | }); |
| | | // 跳转到 TabBar 页面 |
| | | wx.switchTab({ |
| | | wx.navigateTo({ |
| | | url: '/pages/home/home' // 这里填写你想要跳转的 TabBar 页面路径 |
| | | }); |
| | | }, |
| | | //获取验证码 |
| | | postCode: function () { |
| | | post('/items', { name: 'New Item' }) |
| | | const params = { |
| | | url: '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('登录成功,获取到的code:', res.code); |
| | | // 发送 res.code 到后台服务器换取 openId, sessionKey, unionId |
| | | this.verify(res.code) |
| | | } else { |
| | | console.log('登录失败!' + res.errMsg); |
| | | } |
| | | } |
| | | }); |
| | | }, |
| | | //用户绑定 |
| | | verify(wxCode) { |
| | | const params = { |
| | | url: 'wx/client/verify', |
| | | data: { |
| | | phoneNumber: this.data.mobile, |
| | | securityCode: this.data.phoneCode, |
| | | code: wxCode |
| | | } |
| | | }; |
| | | post(params) |
| | | .then((data) => { |
| | | getApp().globalData.sessionId = data.content.sessionId |
| | | storage.setItem("sessionId", data.content.sessionId) |
| | | getApp().globalData.clientId = data.content.clientId |
| | | storage.setItem("clientId", data.content.clientId) |
| | | this.bindSuccess(); |
| | | }) |
| | | .catch((error) => { |
| | | wx.showToast({ |
| | | title: error.msg, |
| | | icon: 'error', |
| | | duration: 3000, |
| | | }); |
| | | console.error('Failed to add item:', error); |
| | | }); |
| | | } |
| | | }) |
| | |
| | | // pages/wxlogin/wxlogin.js |
| | | const { |
| | | get, |
| | | post |
| | | } = require('../../api/request.js'); |
| | | Page({ |
| | | data: { |
| | | userInfo: null |
| | | }, |
| | | |
| | | /** |
| | | /** |
| | | * 获取微信code |
| | | */ |
| | | getCode: function (e) { |
| | | const that = this; |
| | | wx.login({ |
| | | success: function (res) { |
| | | if (res.code) { |
| | | var code = res.code; |
| | | console.log(code); |
| | | wx.navigateTo({ |
| | | url: '/pages/wxbind/wxbind' |
| | | }) |
| | | // 将code发送到服务器获取openid |
| | | that.codeLogin(code); |
| | | } else { |
| | | console.log('登录失败!' + res.errMsg); |
| | | } |
| | | } |
| | | }); |
| | | }, |
| | | //微信code登录 |
| | | codeLogin(codeData) { |
| | | wx.showLoading({ |
| | | title: '正在登录请稍候...', // 加载提示文字 |
| | | mask: true // 是否显示透明蒙层,防止触摸穿透,默认为 false |
| | | }); |
| | | const data = { |
| | | code: codeData, //临时登录凭证 |
| | | }; |
| | | post({ |
| | | url: "wx/client/code_login", |
| | | data: data, |
| | | }).then(response => { |
| | | // 处理成功响应 |
| | | console.log('请求成功:', response); |
| | | // 加载完成后隐藏加载动画 |
| | | wx.hideLoading(); |
| | | //重新获取列表刷新数据 |
| | | if (response.code === "0001") { |
| | | if (response.content.client.clientId === "") { |
| | | wx.navigateTo({ |
| | | url: '/pages/wxbind/wxbind' |
| | | }) |
| | | } else { |
| | | wx.navigateTo({ |
| | | url: '/pages/home/home' |
| | | }) |
| | | } |
| | | } else { |
| | | |
| | | } |
| | | }).catch(error => { |
| | | // 加载完成后隐藏加载动画 |
| | | wx.hideLoading(); |
| | | // 处理错误响应 |
| | | console.error('请求失败:', error); |
| | | }); |
| | | } |
| | | |
| | | }) |