| | |
| | | data, |
| | | ignoreToken, |
| | | form, |
| | | isShowLoding |
| | | isShowLoding, |
| | | timeout, |
| | | header |
| | | } = _options |
| | | const app = getApp() |
| | | // 设置请求头 |
| | | let header = {} |
| | | if (form) { |
| | | header = { |
| | | 'content-type': 'application/x-www-form-urlencoded' |
| | |
| | | 'content-type': 'application/json' //自定义请求头信息 |
| | | } |
| | | } |
| | | if (!timeout) { |
| | | timeout = 60000 |
| | | } |
| | | |
| | | if (!ignoreToken) { |
| | | // 从全局变量中获取token |
| | | let token = app.globalData.token |
| | | header.Authorization = `Bearer ${token}` |
| | | } |
| | | header.tag = app.globalData.tag; |
| | | return new Promise((resolve, reject) => { |
| | | console.log("url:" + BASEURL + url); |
| | | if (isShowLoding) { |
| | |
| | | data, |
| | | header, |
| | | method, |
| | | timeout: timeout, |
| | | success: (res) => { |
| | | let { |
| | | statusCode: code |
| | |
| | | if (isShowLoding) { |
| | | wx.hideLoading(); // 隐藏加载动画 |
| | | } |
| | | |
| | | // showToast(err.errMsg) |
| | | reject(err) |
| | | } |
| | |
| | | }) |
| | | }, |
| | | globalData: { |
| | | sessionId:'2024052821300200006', |
| | | APPID:"wxf773810cd5643196", |
| | | sessionId:'', |
| | | userInfo: null, |
| | | userId:"", |
| | | userCode:"", |
| | | token:"" |
| | | token:"", |
| | | tag:"ym" |
| | | |
| | | } |
| | | }) |
| | |
| | | { |
| | | "pages": [ |
| | | |
| | | |
| | | "pages/home/home", |
| | | "pages/valveList/valveList", |
| | | "pages/rechargeMoney/rechargMoney", |
| | | |
| | | "pages/feedback/feedback", |
| | | |
| | | "pages/valveList/valveList", |
| | | |
| | | "pages/wxlogin/wxlogin", |
| | | "pages/login/login", |
| | | "pages/wxbind/wxbind", |
| | |
| | | "pages/waterIntake/waterIntake", |
| | | "pages/personCharge/personcharge", |
| | | "pages/openCard/openCard", |
| | | "pages/rechargeMoney/rechargMoney", |
| | | |
| | | "pages/rechargeCard/rechargeCard" |
| | | ], |
| | | "window": { |
| | |
| | | var __REQUIRE__ = function(modId, source) { if(!__MODS__[modId]) return require(source); if(!__MODS__[modId].status) { var m = __MODS__[modId].m; m._exports = m._tempexports; var desp = Object.getOwnPropertyDescriptor(m, "exports"); if (desp && desp.configurable) Object.defineProperty(m, "exports", { set: function (val) { if(typeof val === "object" && val !== m._exports) { m._exports.__proto__ = val.__proto__; Object.keys(val).forEach(function (k) { m._exports[k] = val[k]; }); } m._tempexports = val }, get: function () { return m._tempexports; } }); __MODS__[modId].status = 1; __MODS__[modId].func(__MODS__[modId].req, m, m.exports); } return __MODS__[modId].m.exports; }; |
| | | var __REQUIRE_WILDCARD__ = function(obj) { if(obj && obj.__esModule) { return obj; } else { var newObj = {}; if(obj != null) { for(var k in obj) { if (Object.prototype.hasOwnProperty.call(obj, k)) newObj[k] = obj[k]; } } newObj.default = obj; return newObj; } }; |
| | | var __REQUIRE_DEFAULT__ = function(obj) { return obj && obj.__esModule ? obj.default : obj; }; |
| | | __DEFINE__(1718331186291, function(require, module, exports) { |
| | | __DEFINE__(1718586298038, function(require, module, exports) { |
| | | !function(t,e){"object"==typeof exports&&"undefined"!=typeof module?module.exports=e():"function"==typeof define&&define.amd?define(e):(t="undefined"!=typeof globalThis?globalThis:t||self).dayjs=e()}(this,(function(){var t=1e3,e=6e4,n=36e5,r="millisecond",i="second",s="minute",u="hour",a="day",o="week",c="month",f="quarter",h="year",d="date",l="Invalid Date",$=/^(\d{4})[-/]?(\d{1,2})?[-/]?(\d{0,2})[Tt\s]*(\d{1,2})?:?(\d{1,2})?:?(\d{1,2})?[.:]?(\d+)?$/,y=/\[([^\]]+)]|Y{1,4}|M{1,4}|D{1,2}|d{1,4}|H{1,2}|h{1,2}|a|A|m{1,2}|s{1,2}|Z{1,2}|SSS/g,M={name:"en",weekdays:"Sunday_Monday_Tuesday_Wednesday_Thursday_Friday_Saturday".split("_"),months:"January_February_March_April_May_June_July_August_September_October_November_December".split("_"),ordinal:function(t){var e=["th","st","nd","rd"],n=t%100;return"["+t+(e[(n-20)%10]||e[n]||e[0])+"]"}},m=function(t,e,n){var r=String(t);return!r||r.length>=e?t:""+Array(e+1-r.length).join(n)+t},v={s:m,z:function(t){var e=-t.utcOffset(),n=Math.abs(e),r=Math.floor(n/60),i=n%60;return(e<=0?"+":"-")+m(r,2,"0")+":"+m(i,2,"0")},m:function t(e,n){if(e.date()<n.date())return-t(n,e);var r=12*(n.year()-e.year())+(n.month()-e.month()),i=e.clone().add(r,c),s=n-i<0,u=e.clone().add(r+(s?-1:1),c);return+(-(r+(n-i)/(s?i-u:u-i))||0)},a:function(t){return t<0?Math.ceil(t)||0:Math.floor(t)},p:function(t){return{M:c,y:h,w:o,d:a,D:d,h:u,m:s,s:i,ms:r,Q:f}[t]||String(t||"").toLowerCase().replace(/s$/,"")},u:function(t){return void 0===t}},g="en",D={};D[g]=M;var p="$isDayjsObject",S=function(t){return t instanceof _||!(!t||!t[p])},w=function t(e,n,r){var i;if(!e)return g;if("string"==typeof e){var s=e.toLowerCase();D[s]&&(i=s),n&&(D[s]=n,i=s);var u=e.split("-");if(!i&&u.length>1)return t(u[0])}else{var a=e.name;D[a]=e,i=a}return!r&&i&&(g=i),i||!r&&g},O=function(t,e){if(S(t))return t.clone();var n="object"==typeof e?e:{};return n.date=t,n.args=arguments,new _(n)},b=v;b.l=w,b.i=S,b.w=function(t,e){return O(t,{locale:e.$L,utc:e.$u,x:e.$x,$offset:e.$offset})};var _=function(){function M(t){this.$L=w(t.locale,null,!0),this.parse(t),this.$x=this.$x||t.x||{},this[p]=!0}var m=M.prototype;return m.parse=function(t){this.$d=function(t){var e=t.date,n=t.utc;if(null===e)return new Date(NaN);if(b.u(e))return new Date;if(e instanceof Date)return new Date(e);if("string"==typeof e&&!/Z$/i.test(e)){var r=e.match($);if(r){var i=r[2]-1||0,s=(r[7]||"0").substring(0,3);return n?new Date(Date.UTC(r[1],i,r[3]||1,r[4]||0,r[5]||0,r[6]||0,s)):new Date(r[1],i,r[3]||1,r[4]||0,r[5]||0,r[6]||0,s)}}return new Date(e)}(t),this.init()},m.init=function(){var t=this.$d;this.$y=t.getFullYear(),this.$M=t.getMonth(),this.$D=t.getDate(),this.$W=t.getDay(),this.$H=t.getHours(),this.$m=t.getMinutes(),this.$s=t.getSeconds(),this.$ms=t.getMilliseconds()},m.$utils=function(){return b},m.isValid=function(){return!(this.$d.toString()===l)},m.isSame=function(t,e){var n=O(t);return this.startOf(e)<=n&&n<=this.endOf(e)},m.isAfter=function(t,e){return O(t)<this.startOf(e)},m.isBefore=function(t,e){return this.endOf(e)<O(t)},m.$g=function(t,e,n){return b.u(t)?this[e]:this.set(n,t)},m.unix=function(){return Math.floor(this.valueOf()/1e3)},m.valueOf=function(){return this.$d.getTime()},m.startOf=function(t,e){var n=this,r=!!b.u(e)||e,f=b.p(t),l=function(t,e){var i=b.w(n.$u?Date.UTC(n.$y,e,t):new Date(n.$y,e,t),n);return r?i:i.endOf(a)},$=function(t,e){return b.w(n.toDate()[t].apply(n.toDate("s"),(r?[0,0,0,0]:[23,59,59,999]).slice(e)),n)},y=this.$W,M=this.$M,m=this.$D,v="set"+(this.$u?"UTC":"");switch(f){case h:return r?l(1,0):l(31,11);case c:return r?l(1,M):l(0,M+1);case o:var g=this.$locale().weekStart||0,D=(y<g?y+7:y)-g;return l(r?m-D:m+(6-D),M);case a:case d:return $(v+"Hours",0);case u:return $(v+"Minutes",1);case s:return $(v+"Seconds",2);case i:return $(v+"Milliseconds",3);default:return this.clone()}},m.endOf=function(t){return this.startOf(t,!1)},m.$set=function(t,e){var n,o=b.p(t),f="set"+(this.$u?"UTC":""),l=(n={},n[a]=f+"Date",n[d]=f+"Date",n[c]=f+"Month",n[h]=f+"FullYear",n[u]=f+"Hours",n[s]=f+"Minutes",n[i]=f+"Seconds",n[r]=f+"Milliseconds",n)[o],$=o===a?this.$D+(e-this.$W):e;if(o===c||o===h){var y=this.clone().set(d,1);y.$d[l]($),y.init(),this.$d=y.set(d,Math.min(this.$D,y.daysInMonth())).$d}else l&&this.$d[l]($);return this.init(),this},m.set=function(t,e){return this.clone().$set(t,e)},m.get=function(t){return this[b.p(t)]()},m.add=function(r,f){var d,l=this;r=Number(r);var $=b.p(f),y=function(t){var e=O(l);return b.w(e.date(e.date()+Math.round(t*r)),l)};if($===c)return this.set(c,this.$M+r);if($===h)return this.set(h,this.$y+r);if($===a)return y(1);if($===o)return y(7);var M=(d={},d[s]=e,d[u]=n,d[i]=t,d)[$]||1,m=this.$d.getTime()+r*M;return b.w(m,this)},m.subtract=function(t,e){return this.add(-1*t,e)},m.format=function(t){var e=this,n=this.$locale();if(!this.isValid())return n.invalidDate||l;var r=t||"YYYY-MM-DDTHH:mm:ssZ",i=b.z(this),s=this.$H,u=this.$m,a=this.$M,o=n.weekdays,c=n.months,f=n.meridiem,h=function(t,n,i,s){return t&&(t[n]||t(e,r))||i[n].slice(0,s)},d=function(t){return b.s(s%12||12,t,"0")},$=f||function(t,e,n){var r=t<12?"AM":"PM";return n?r.toLowerCase():r};return r.replace(y,(function(t,r){return r||function(t){switch(t){case"YY":return String(e.$y).slice(-2);case"YYYY":return b.s(e.$y,4,"0");case"M":return a+1;case"MM":return b.s(a+1,2,"0");case"MMM":return h(n.monthsShort,a,c,3);case"MMMM":return h(c,a);case"D":return e.$D;case"DD":return b.s(e.$D,2,"0");case"d":return String(e.$W);case"dd":return h(n.weekdaysMin,e.$W,o,2);case"ddd":return h(n.weekdaysShort,e.$W,o,3);case"dddd":return o[e.$W];case"H":return String(s);case"HH":return b.s(s,2,"0");case"h":return d(1);case"hh":return d(2);case"a":return $(s,u,!0);case"A":return $(s,u,!1);case"m":return String(u);case"mm":return b.s(u,2,"0");case"s":return String(e.$s);case"ss":return b.s(e.$s,2,"0");case"SSS":return b.s(e.$ms,3,"0");case"Z":return i}return null}(t)||i.replace(":","")}))},m.utcOffset=function(){return 15*-Math.round(this.$d.getTimezoneOffset()/15)},m.diff=function(r,d,l){var $,y=this,M=b.p(d),m=O(r),v=(m.utcOffset()-this.utcOffset())*e,g=this-m,D=function(){return b.m(y,m)};switch(M){case h:$=D()/12;break;case c:$=D();break;case f:$=D()/3;break;case o:$=(g-v)/6048e5;break;case a:$=(g-v)/864e5;break;case u:$=g/n;break;case s:$=g/e;break;case i:$=g/t;break;default:$=g}return l?$:b.a($)},m.daysInMonth=function(){return this.endOf(c).$D},m.$locale=function(){return D[this.$L]},m.locale=function(t,e){if(!t)return this.$L;var n=this.clone(),r=w(t,e,!0);return r&&(n.$L=r),n},m.clone=function(){return b.w(this.$d,this)},m.toDate=function(){return new Date(this.valueOf())},m.toJSON=function(){return this.isValid()?this.toISOString():null},m.toISOString=function(){return this.$d.toISOString()},m.toString=function(){return this.$d.toUTCString()},M}(),k=_.prototype;return O.prototype=k,[["$ms",r],["$s",i],["$m",s],["$H",u],["$W",a],["$M",c],["$y",h],["$D",d]].forEach((function(t){k[t[1]]=function(e){return this.$g(e,t[0],t[1])}})),O.extend=function(t,e){return t.$i||(t(e,_,O),t.$i=!0),O},O.locale=w,O.isDayjs=S,O.unix=function(t){return O(1e3*t)},O.en=D[g],O.Ls=D,O.p={},O})); |
| | | }, function(modId) {var map = {}; return __REQUIRE__(map[modId], modId); }) |
| | | return __REQUIRE__(1718331186291); |
| | | return __REQUIRE__(1718586298038); |
| | | })() |
| | | //miniprogram-npm-outsideDeps=[] |
| | | //# sourceMappingURL=index.js.map |
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__(1718586298039, function(require, module, exports) { |
| | | /** |
| | | * [js-md5]{@link https://github.com/emn178/js-md5} |
| | | * |
| | | * @namespace md5 |
| | | * @version 0.8.3 |
| | | * @author Chen, Yi-Cyuan [emn178@gmail.com] |
| | | * @copyright Chen, Yi-Cyuan 2014-2023 |
| | | * @license MIT |
| | | */ |
| | | (function () { |
| | | |
| | | |
| | | var INPUT_ERROR = 'input is invalid type'; |
| | | var FINALIZE_ERROR = 'finalize already called'; |
| | | var WINDOW = typeof window === 'object'; |
| | | var root = WINDOW ? window : {}; |
| | | if (root.JS_MD5_NO_WINDOW) { |
| | | WINDOW = false; |
| | | } |
| | | var WEB_WORKER = !WINDOW && typeof self === 'object'; |
| | | var NODE_JS = !root.JS_MD5_NO_NODE_JS && typeof process === 'object' && process.versions && process.versions.node; |
| | | if (NODE_JS) { |
| | | root = global; |
| | | } else if (WEB_WORKER) { |
| | | root = self; |
| | | } |
| | | var COMMON_JS = !root.JS_MD5_NO_COMMON_JS && typeof module === 'object' && module.exports; |
| | | var AMD = typeof define === 'function' && define.amd; |
| | | var ARRAY_BUFFER = !root.JS_MD5_NO_ARRAY_BUFFER && typeof ArrayBuffer !== 'undefined'; |
| | | var HEX_CHARS = '0123456789abcdef'.split(''); |
| | | var EXTRA = [128, 32768, 8388608, -2147483648]; |
| | | var SHIFT = [0, 8, 16, 24]; |
| | | var OUTPUT_TYPES = ['hex', 'array', 'digest', 'buffer', 'arrayBuffer', 'base64']; |
| | | var BASE64_ENCODE_CHAR = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/'.split(''); |
| | | |
| | | var blocks = [], buffer8; |
| | | if (ARRAY_BUFFER) { |
| | | var buffer = new ArrayBuffer(68); |
| | | buffer8 = new Uint8Array(buffer); |
| | | blocks = new Uint32Array(buffer); |
| | | } |
| | | |
| | | var isArray = Array.isArray; |
| | | if (root.JS_MD5_NO_NODE_JS || !isArray) { |
| | | isArray = function (obj) { |
| | | return Object.prototype.toString.call(obj) === '[object Array]'; |
| | | }; |
| | | } |
| | | |
| | | var isView = ArrayBuffer.isView; |
| | | if (ARRAY_BUFFER && (root.JS_MD5_NO_ARRAY_BUFFER_IS_VIEW || !isView)) { |
| | | isView = function (obj) { |
| | | return typeof obj === 'object' && obj.buffer && obj.buffer.constructor === ArrayBuffer; |
| | | }; |
| | | } |
| | | |
| | | // [message: string, isString: bool] |
| | | var formatMessage = function (message) { |
| | | var type = typeof message; |
| | | if (type === 'string') { |
| | | return [message, true]; |
| | | } |
| | | if (type !== 'object' || message === null) { |
| | | throw new Error(INPUT_ERROR); |
| | | } |
| | | if (ARRAY_BUFFER && message.constructor === ArrayBuffer) { |
| | | return [new Uint8Array(message), false]; |
| | | } |
| | | if (!isArray(message) && !isView(message)) { |
| | | throw new Error(INPUT_ERROR); |
| | | } |
| | | return [message, false]; |
| | | } |
| | | |
| | | /** |
| | | * @method hex |
| | | * @memberof md5 |
| | | * @description Output hash as hex string |
| | | * @param {String|Array|Uint8Array|ArrayBuffer} message message to hash |
| | | * @returns {String} Hex string |
| | | * @example |
| | | * md5.hex('The quick brown fox jumps over the lazy dog'); |
| | | * // equal to |
| | | * md5('The quick brown fox jumps over the lazy dog'); |
| | | */ |
| | | /** |
| | | * @method digest |
| | | * @memberof md5 |
| | | * @description Output hash as bytes array |
| | | * @param {String|Array|Uint8Array|ArrayBuffer} message message to hash |
| | | * @returns {Array} Bytes array |
| | | * @example |
| | | * md5.digest('The quick brown fox jumps over the lazy dog'); |
| | | */ |
| | | /** |
| | | * @method array |
| | | * @memberof md5 |
| | | * @description Output hash as bytes array |
| | | * @param {String|Array|Uint8Array|ArrayBuffer} message message to hash |
| | | * @returns {Array} Bytes array |
| | | * @example |
| | | * md5.array('The quick brown fox jumps over the lazy dog'); |
| | | */ |
| | | /** |
| | | * @method arrayBuffer |
| | | * @memberof md5 |
| | | * @description Output hash as ArrayBuffer |
| | | * @param {String|Array|Uint8Array|ArrayBuffer} message message to hash |
| | | * @returns {ArrayBuffer} ArrayBuffer |
| | | * @example |
| | | * md5.arrayBuffer('The quick brown fox jumps over the lazy dog'); |
| | | */ |
| | | /** |
| | | * @method buffer |
| | | * @deprecated This maybe confuse with Buffer in node.js. Please use arrayBuffer instead. |
| | | * @memberof md5 |
| | | * @description Output hash as ArrayBuffer |
| | | * @param {String|Array|Uint8Array|ArrayBuffer} message message to hash |
| | | * @returns {ArrayBuffer} ArrayBuffer |
| | | * @example |
| | | * md5.buffer('The quick brown fox jumps over the lazy dog'); |
| | | */ |
| | | /** |
| | | * @method base64 |
| | | * @memberof md5 |
| | | * @description Output hash as base64 string |
| | | * @param {String|Array|Uint8Array|ArrayBuffer} message message to hash |
| | | * @returns {String} base64 string |
| | | * @example |
| | | * md5.base64('The quick brown fox jumps over the lazy dog'); |
| | | */ |
| | | var createOutputMethod = function (outputType) { |
| | | return function (message) { |
| | | return new Md5(true).update(message)[outputType](); |
| | | }; |
| | | }; |
| | | |
| | | /** |
| | | * @method create |
| | | * @memberof md5 |
| | | * @description Create Md5 object |
| | | * @returns {Md5} Md5 object. |
| | | * @example |
| | | * var hash = md5.create(); |
| | | */ |
| | | /** |
| | | * @method update |
| | | * @memberof md5 |
| | | * @description Create and update Md5 object |
| | | * @param {String|Array|Uint8Array|ArrayBuffer} message message to hash |
| | | * @returns {Md5} Md5 object. |
| | | * @example |
| | | * var hash = md5.update('The quick brown fox jumps over the lazy dog'); |
| | | * // equal to |
| | | * var hash = md5.create(); |
| | | * hash.update('The quick brown fox jumps over the lazy dog'); |
| | | */ |
| | | var createMethod = function () { |
| | | var method = createOutputMethod('hex'); |
| | | if (NODE_JS) { |
| | | method = nodeWrap(method); |
| | | } |
| | | method.create = function () { |
| | | return new Md5(); |
| | | }; |
| | | method.update = function (message) { |
| | | return method.create().update(message); |
| | | }; |
| | | for (var i = 0; i < OUTPUT_TYPES.length; ++i) { |
| | | var type = OUTPUT_TYPES[i]; |
| | | method[type] = createOutputMethod(type); |
| | | } |
| | | return method; |
| | | }; |
| | | |
| | | var nodeWrap = function (method) { |
| | | var crypto = require('crypto') |
| | | var Buffer = require('buffer').Buffer; |
| | | var bufferFrom; |
| | | if (Buffer.from && !root.JS_MD5_NO_BUFFER_FROM) { |
| | | bufferFrom = Buffer.from; |
| | | } else { |
| | | bufferFrom = function (message) { |
| | | return new Buffer(message); |
| | | }; |
| | | } |
| | | var nodeMethod = function (message) { |
| | | if (typeof message === 'string') { |
| | | return crypto.createHash('md5').update(message, 'utf8').digest('hex'); |
| | | } else { |
| | | if (message === null || message === undefined) { |
| | | throw new Error(INPUT_ERROR); |
| | | } else if (message.constructor === ArrayBuffer) { |
| | | message = new Uint8Array(message); |
| | | } |
| | | } |
| | | if (isArray(message) || isView(message) || |
| | | message.constructor === Buffer) { |
| | | return crypto.createHash('md5').update(bufferFrom(message)).digest('hex'); |
| | | } else { |
| | | return method(message); |
| | | } |
| | | }; |
| | | return nodeMethod; |
| | | }; |
| | | |
| | | /** |
| | | * @namespace md5.hmac |
| | | */ |
| | | /** |
| | | * @method hex |
| | | * @memberof md5.hmac |
| | | * @description Output hash as hex string |
| | | * @param {String|Array|Uint8Array|ArrayBuffer} key key |
| | | * @param {String|Array|Uint8Array|ArrayBuffer} message message to hash |
| | | * @returns {String} Hex string |
| | | * @example |
| | | * md5.hmac.hex('key', 'The quick brown fox jumps over the lazy dog'); |
| | | * // equal to |
| | | * md5.hmac('key', 'The quick brown fox jumps over the lazy dog'); |
| | | */ |
| | | |
| | | /** |
| | | * @method digest |
| | | * @memberof md5.hmac |
| | | * @description Output hash as bytes array |
| | | * @param {String|Array|Uint8Array|ArrayBuffer} key key |
| | | * @param {String|Array|Uint8Array|ArrayBuffer} message message to hash |
| | | * @returns {Array} Bytes array |
| | | * @example |
| | | * md5.hmac.digest('key', 'The quick brown fox jumps over the lazy dog'); |
| | | */ |
| | | /** |
| | | * @method array |
| | | * @memberof md5.hmac |
| | | * @description Output hash as bytes array |
| | | * @param {String|Array|Uint8Array|ArrayBuffer} key key |
| | | * @param {String|Array|Uint8Array|ArrayBuffer} message message to hash |
| | | * @returns {Array} Bytes array |
| | | * @example |
| | | * md5.hmac.array('key', 'The quick brown fox jumps over the lazy dog'); |
| | | */ |
| | | /** |
| | | * @method arrayBuffer |
| | | * @memberof md5.hmac |
| | | * @description Output hash as ArrayBuffer |
| | | * @param {String|Array|Uint8Array|ArrayBuffer} key key |
| | | * @param {String|Array|Uint8Array|ArrayBuffer} message message to hash |
| | | * @returns {ArrayBuffer} ArrayBuffer |
| | | * @example |
| | | * md5.hmac.arrayBuffer('key', 'The quick brown fox jumps over the lazy dog'); |
| | | */ |
| | | /** |
| | | * @method buffer |
| | | * @deprecated This maybe confuse with Buffer in node.js. Please use arrayBuffer instead. |
| | | * @memberof md5.hmac |
| | | * @description Output hash as ArrayBuffer |
| | | * @param {String|Array|Uint8Array|ArrayBuffer} key key |
| | | * @param {String|Array|Uint8Array|ArrayBuffer} message message to hash |
| | | * @returns {ArrayBuffer} ArrayBuffer |
| | | * @example |
| | | * md5.hmac.buffer('key', 'The quick brown fox jumps over the lazy dog'); |
| | | */ |
| | | /** |
| | | * @method base64 |
| | | * @memberof md5.hmac |
| | | * @description Output hash as base64 string |
| | | * @param {String|Array|Uint8Array|ArrayBuffer} key key |
| | | * @param {String|Array|Uint8Array|ArrayBuffer} message message to hash |
| | | * @returns {String} base64 string |
| | | * @example |
| | | * md5.hmac.base64('key', 'The quick brown fox jumps over the lazy dog'); |
| | | */ |
| | | var createHmacOutputMethod = function (outputType) { |
| | | return function (key, message) { |
| | | return new HmacMd5(key, true).update(message)[outputType](); |
| | | }; |
| | | }; |
| | | |
| | | /** |
| | | * @method create |
| | | * @memberof md5.hmac |
| | | * @description Create HmacMd5 object |
| | | * @param {String|Array|Uint8Array|ArrayBuffer} key key |
| | | * @returns {HmacMd5} HmacMd5 object. |
| | | * @example |
| | | * var hash = md5.hmac.create('key'); |
| | | */ |
| | | /** |
| | | * @method update |
| | | * @memberof md5.hmac |
| | | * @description Create and update HmacMd5 object |
| | | * @param {String|Array|Uint8Array|ArrayBuffer} key key |
| | | * @param {String|Array|Uint8Array|ArrayBuffer} message message to hash |
| | | * @returns {HmacMd5} HmacMd5 object. |
| | | * @example |
| | | * var hash = md5.hmac.update('key', 'The quick brown fox jumps over the lazy dog'); |
| | | * // equal to |
| | | * var hash = md5.hmac.create('key'); |
| | | * hash.update('The quick brown fox jumps over the lazy dog'); |
| | | */ |
| | | var createHmacMethod = function () { |
| | | var method = createHmacOutputMethod('hex'); |
| | | method.create = function (key) { |
| | | return new HmacMd5(key); |
| | | }; |
| | | method.update = function (key, message) { |
| | | return method.create(key).update(message); |
| | | }; |
| | | for (var i = 0; i < OUTPUT_TYPES.length; ++i) { |
| | | var type = OUTPUT_TYPES[i]; |
| | | method[type] = createHmacOutputMethod(type); |
| | | } |
| | | return method; |
| | | }; |
| | | |
| | | /** |
| | | * Md5 class |
| | | * @class Md5 |
| | | * @description This is internal class. |
| | | * @see {@link md5.create} |
| | | */ |
| | | function Md5(sharedMemory) { |
| | | if (sharedMemory) { |
| | | blocks[0] = blocks[16] = blocks[1] = blocks[2] = blocks[3] = |
| | | blocks[4] = blocks[5] = blocks[6] = blocks[7] = |
| | | blocks[8] = blocks[9] = blocks[10] = blocks[11] = |
| | | blocks[12] = blocks[13] = blocks[14] = blocks[15] = 0; |
| | | this.blocks = blocks; |
| | | this.buffer8 = buffer8; |
| | | } else { |
| | | if (ARRAY_BUFFER) { |
| | | var buffer = new ArrayBuffer(68); |
| | | this.buffer8 = new Uint8Array(buffer); |
| | | this.blocks = new Uint32Array(buffer); |
| | | } else { |
| | | this.blocks = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]; |
| | | } |
| | | } |
| | | this.h0 = this.h1 = this.h2 = this.h3 = this.start = this.bytes = this.hBytes = 0; |
| | | this.finalized = this.hashed = false; |
| | | this.first = true; |
| | | } |
| | | |
| | | /** |
| | | * @method update |
| | | * @memberof Md5 |
| | | * @instance |
| | | * @description Update hash |
| | | * @param {String|Array|Uint8Array|ArrayBuffer} message message to hash |
| | | * @returns {Md5} Md5 object. |
| | | * @see {@link md5.update} |
| | | */ |
| | | Md5.prototype.update = function (message) { |
| | | if (this.finalized) { |
| | | throw new Error(FINALIZE_ERROR); |
| | | } |
| | | |
| | | var result = formatMessage(message); |
| | | message = result[0]; |
| | | var isString = result[1]; |
| | | var code, index = 0, i, length = message.length, blocks = this.blocks; |
| | | var buffer8 = this.buffer8; |
| | | |
| | | while (index < length) { |
| | | if (this.hashed) { |
| | | this.hashed = false; |
| | | blocks[0] = blocks[16]; |
| | | blocks[16] = blocks[1] = blocks[2] = blocks[3] = |
| | | blocks[4] = blocks[5] = blocks[6] = blocks[7] = |
| | | blocks[8] = blocks[9] = blocks[10] = blocks[11] = |
| | | blocks[12] = blocks[13] = blocks[14] = blocks[15] = 0; |
| | | } |
| | | |
| | | if (isString) { |
| | | if (ARRAY_BUFFER) { |
| | | for (i = this.start; index < length && i < 64; ++index) { |
| | | code = message.charCodeAt(index); |
| | | if (code < 0x80) { |
| | | buffer8[i++] = code; |
| | | } else if (code < 0x800) { |
| | | buffer8[i++] = 0xc0 | (code >>> 6); |
| | | buffer8[i++] = 0x80 | (code & 0x3f); |
| | | } else if (code < 0xd800 || code >= 0xe000) { |
| | | buffer8[i++] = 0xe0 | (code >>> 12); |
| | | buffer8[i++] = 0x80 | ((code >>> 6) & 0x3f); |
| | | buffer8[i++] = 0x80 | (code & 0x3f); |
| | | } else { |
| | | code = 0x10000 + (((code & 0x3ff) << 10) | (message.charCodeAt(++index) & 0x3ff)); |
| | | buffer8[i++] = 0xf0 | (code >>> 18); |
| | | buffer8[i++] = 0x80 | ((code >>> 12) & 0x3f); |
| | | buffer8[i++] = 0x80 | ((code >>> 6) & 0x3f); |
| | | buffer8[i++] = 0x80 | (code & 0x3f); |
| | | } |
| | | } |
| | | } else { |
| | | for (i = this.start; index < length && i < 64; ++index) { |
| | | code = message.charCodeAt(index); |
| | | if (code < 0x80) { |
| | | blocks[i >>> 2] |= code << SHIFT[i++ & 3]; |
| | | } else if (code < 0x800) { |
| | | blocks[i >>> 2] |= (0xc0 | (code >>> 6)) << SHIFT[i++ & 3]; |
| | | blocks[i >>> 2] |= (0x80 | (code & 0x3f)) << SHIFT[i++ & 3]; |
| | | } else if (code < 0xd800 || code >= 0xe000) { |
| | | blocks[i >>> 2] |= (0xe0 | (code >>> 12)) << SHIFT[i++ & 3]; |
| | | blocks[i >>> 2] |= (0x80 | ((code >>> 6) & 0x3f)) << SHIFT[i++ & 3]; |
| | | blocks[i >>> 2] |= (0x80 | (code & 0x3f)) << SHIFT[i++ & 3]; |
| | | } else { |
| | | code = 0x10000 + (((code & 0x3ff) << 10) | (message.charCodeAt(++index) & 0x3ff)); |
| | | blocks[i >>> 2] |= (0xf0 | (code >>> 18)) << SHIFT[i++ & 3]; |
| | | blocks[i >>> 2] |= (0x80 | ((code >>> 12) & 0x3f)) << SHIFT[i++ & 3]; |
| | | blocks[i >>> 2] |= (0x80 | ((code >>> 6) & 0x3f)) << SHIFT[i++ & 3]; |
| | | blocks[i >>> 2] |= (0x80 | (code & 0x3f)) << SHIFT[i++ & 3]; |
| | | } |
| | | } |
| | | } |
| | | } else { |
| | | if (ARRAY_BUFFER) { |
| | | for (i = this.start; index < length && i < 64; ++index) { |
| | | buffer8[i++] = message[index]; |
| | | } |
| | | } else { |
| | | for (i = this.start; index < length && i < 64; ++index) { |
| | | blocks[i >>> 2] |= message[index] << SHIFT[i++ & 3]; |
| | | } |
| | | } |
| | | } |
| | | this.lastByteIndex = i; |
| | | this.bytes += i - this.start; |
| | | if (i >= 64) { |
| | | this.start = i - 64; |
| | | this.hash(); |
| | | this.hashed = true; |
| | | } else { |
| | | this.start = i; |
| | | } |
| | | } |
| | | if (this.bytes > 4294967295) { |
| | | this.hBytes += this.bytes / 4294967296 << 0; |
| | | this.bytes = this.bytes % 4294967296; |
| | | } |
| | | return this; |
| | | }; |
| | | |
| | | Md5.prototype.finalize = function () { |
| | | if (this.finalized) { |
| | | return; |
| | | } |
| | | this.finalized = true; |
| | | var blocks = this.blocks, i = this.lastByteIndex; |
| | | blocks[i >>> 2] |= EXTRA[i & 3]; |
| | | if (i >= 56) { |
| | | if (!this.hashed) { |
| | | this.hash(); |
| | | } |
| | | blocks[0] = blocks[16]; |
| | | blocks[16] = blocks[1] = blocks[2] = blocks[3] = |
| | | blocks[4] = blocks[5] = blocks[6] = blocks[7] = |
| | | blocks[8] = blocks[9] = blocks[10] = blocks[11] = |
| | | blocks[12] = blocks[13] = blocks[14] = blocks[15] = 0; |
| | | } |
| | | blocks[14] = this.bytes << 3; |
| | | blocks[15] = this.hBytes << 3 | this.bytes >>> 29; |
| | | this.hash(); |
| | | }; |
| | | |
| | | Md5.prototype.hash = function () { |
| | | var a, b, c, d, bc, da, blocks = this.blocks; |
| | | |
| | | if (this.first) { |
| | | a = blocks[0] - 680876937; |
| | | a = (a << 7 | a >>> 25) - 271733879 << 0; |
| | | d = (-1732584194 ^ a & 2004318071) + blocks[1] - 117830708; |
| | | d = (d << 12 | d >>> 20) + a << 0; |
| | | c = (-271733879 ^ (d & (a ^ -271733879))) + blocks[2] - 1126478375; |
| | | c = (c << 17 | c >>> 15) + d << 0; |
| | | b = (a ^ (c & (d ^ a))) + blocks[3] - 1316259209; |
| | | b = (b << 22 | b >>> 10) + c << 0; |
| | | } else { |
| | | a = this.h0; |
| | | b = this.h1; |
| | | c = this.h2; |
| | | d = this.h3; |
| | | a += (d ^ (b & (c ^ d))) + blocks[0] - 680876936; |
| | | a = (a << 7 | a >>> 25) + b << 0; |
| | | d += (c ^ (a & (b ^ c))) + blocks[1] - 389564586; |
| | | d = (d << 12 | d >>> 20) + a << 0; |
| | | c += (b ^ (d & (a ^ b))) + blocks[2] + 606105819; |
| | | c = (c << 17 | c >>> 15) + d << 0; |
| | | b += (a ^ (c & (d ^ a))) + blocks[3] - 1044525330; |
| | | b = (b << 22 | b >>> 10) + c << 0; |
| | | } |
| | | |
| | | a += (d ^ (b & (c ^ d))) + blocks[4] - 176418897; |
| | | a = (a << 7 | a >>> 25) + b << 0; |
| | | d += (c ^ (a & (b ^ c))) + blocks[5] + 1200080426; |
| | | d = (d << 12 | d >>> 20) + a << 0; |
| | | c += (b ^ (d & (a ^ b))) + blocks[6] - 1473231341; |
| | | c = (c << 17 | c >>> 15) + d << 0; |
| | | b += (a ^ (c & (d ^ a))) + blocks[7] - 45705983; |
| | | b = (b << 22 | b >>> 10) + c << 0; |
| | | a += (d ^ (b & (c ^ d))) + blocks[8] + 1770035416; |
| | | a = (a << 7 | a >>> 25) + b << 0; |
| | | d += (c ^ (a & (b ^ c))) + blocks[9] - 1958414417; |
| | | d = (d << 12 | d >>> 20) + a << 0; |
| | | c += (b ^ (d & (a ^ b))) + blocks[10] - 42063; |
| | | c = (c << 17 | c >>> 15) + d << 0; |
| | | b += (a ^ (c & (d ^ a))) + blocks[11] - 1990404162; |
| | | b = (b << 22 | b >>> 10) + c << 0; |
| | | a += (d ^ (b & (c ^ d))) + blocks[12] + 1804603682; |
| | | a = (a << 7 | a >>> 25) + b << 0; |
| | | d += (c ^ (a & (b ^ c))) + blocks[13] - 40341101; |
| | | d = (d << 12 | d >>> 20) + a << 0; |
| | | c += (b ^ (d & (a ^ b))) + blocks[14] - 1502002290; |
| | | c = (c << 17 | c >>> 15) + d << 0; |
| | | b += (a ^ (c & (d ^ a))) + blocks[15] + 1236535329; |
| | | b = (b << 22 | b >>> 10) + c << 0; |
| | | a += (c ^ (d & (b ^ c))) + blocks[1] - 165796510; |
| | | a = (a << 5 | a >>> 27) + b << 0; |
| | | d += (b ^ (c & (a ^ b))) + blocks[6] - 1069501632; |
| | | d = (d << 9 | d >>> 23) + a << 0; |
| | | c += (a ^ (b & (d ^ a))) + blocks[11] + 643717713; |
| | | c = (c << 14 | c >>> 18) + d << 0; |
| | | b += (d ^ (a & (c ^ d))) + blocks[0] - 373897302; |
| | | b = (b << 20 | b >>> 12) + c << 0; |
| | | a += (c ^ (d & (b ^ c))) + blocks[5] - 701558691; |
| | | a = (a << 5 | a >>> 27) + b << 0; |
| | | d += (b ^ (c & (a ^ b))) + blocks[10] + 38016083; |
| | | d = (d << 9 | d >>> 23) + a << 0; |
| | | c += (a ^ (b & (d ^ a))) + blocks[15] - 660478335; |
| | | c = (c << 14 | c >>> 18) + d << 0; |
| | | b += (d ^ (a & (c ^ d))) + blocks[4] - 405537848; |
| | | b = (b << 20 | b >>> 12) + c << 0; |
| | | a += (c ^ (d & (b ^ c))) + blocks[9] + 568446438; |
| | | a = (a << 5 | a >>> 27) + b << 0; |
| | | d += (b ^ (c & (a ^ b))) + blocks[14] - 1019803690; |
| | | d = (d << 9 | d >>> 23) + a << 0; |
| | | c += (a ^ (b & (d ^ a))) + blocks[3] - 187363961; |
| | | c = (c << 14 | c >>> 18) + d << 0; |
| | | b += (d ^ (a & (c ^ d))) + blocks[8] + 1163531501; |
| | | b = (b << 20 | b >>> 12) + c << 0; |
| | | a += (c ^ (d & (b ^ c))) + blocks[13] - 1444681467; |
| | | a = (a << 5 | a >>> 27) + b << 0; |
| | | d += (b ^ (c & (a ^ b))) + blocks[2] - 51403784; |
| | | d = (d << 9 | d >>> 23) + a << 0; |
| | | c += (a ^ (b & (d ^ a))) + blocks[7] + 1735328473; |
| | | c = (c << 14 | c >>> 18) + d << 0; |
| | | b += (d ^ (a & (c ^ d))) + blocks[12] - 1926607734; |
| | | b = (b << 20 | b >>> 12) + c << 0; |
| | | bc = b ^ c; |
| | | a += (bc ^ d) + blocks[5] - 378558; |
| | | a = (a << 4 | a >>> 28) + b << 0; |
| | | d += (bc ^ a) + blocks[8] - 2022574463; |
| | | d = (d << 11 | d >>> 21) + a << 0; |
| | | da = d ^ a; |
| | | c += (da ^ b) + blocks[11] + 1839030562; |
| | | c = (c << 16 | c >>> 16) + d << 0; |
| | | b += (da ^ c) + blocks[14] - 35309556; |
| | | b = (b << 23 | b >>> 9) + c << 0; |
| | | bc = b ^ c; |
| | | a += (bc ^ d) + blocks[1] - 1530992060; |
| | | a = (a << 4 | a >>> 28) + b << 0; |
| | | d += (bc ^ a) + blocks[4] + 1272893353; |
| | | d = (d << 11 | d >>> 21) + a << 0; |
| | | da = d ^ a; |
| | | c += (da ^ b) + blocks[7] - 155497632; |
| | | c = (c << 16 | c >>> 16) + d << 0; |
| | | b += (da ^ c) + blocks[10] - 1094730640; |
| | | b = (b << 23 | b >>> 9) + c << 0; |
| | | bc = b ^ c; |
| | | a += (bc ^ d) + blocks[13] + 681279174; |
| | | a = (a << 4 | a >>> 28) + b << 0; |
| | | d += (bc ^ a) + blocks[0] - 358537222; |
| | | d = (d << 11 | d >>> 21) + a << 0; |
| | | da = d ^ a; |
| | | c += (da ^ b) + blocks[3] - 722521979; |
| | | c = (c << 16 | c >>> 16) + d << 0; |
| | | b += (da ^ c) + blocks[6] + 76029189; |
| | | b = (b << 23 | b >>> 9) + c << 0; |
| | | bc = b ^ c; |
| | | a += (bc ^ d) + blocks[9] - 640364487; |
| | | a = (a << 4 | a >>> 28) + b << 0; |
| | | d += (bc ^ a) + blocks[12] - 421815835; |
| | | d = (d << 11 | d >>> 21) + a << 0; |
| | | da = d ^ a; |
| | | c += (da ^ b) + blocks[15] + 530742520; |
| | | c = (c << 16 | c >>> 16) + d << 0; |
| | | b += (da ^ c) + blocks[2] - 995338651; |
| | | b = (b << 23 | b >>> 9) + c << 0; |
| | | a += (c ^ (b | ~d)) + blocks[0] - 198630844; |
| | | a = (a << 6 | a >>> 26) + b << 0; |
| | | d += (b ^ (a | ~c)) + blocks[7] + 1126891415; |
| | | d = (d << 10 | d >>> 22) + a << 0; |
| | | c += (a ^ (d | ~b)) + blocks[14] - 1416354905; |
| | | c = (c << 15 | c >>> 17) + d << 0; |
| | | b += (d ^ (c | ~a)) + blocks[5] - 57434055; |
| | | b = (b << 21 | b >>> 11) + c << 0; |
| | | a += (c ^ (b | ~d)) + blocks[12] + 1700485571; |
| | | a = (a << 6 | a >>> 26) + b << 0; |
| | | d += (b ^ (a | ~c)) + blocks[3] - 1894986606; |
| | | d = (d << 10 | d >>> 22) + a << 0; |
| | | c += (a ^ (d | ~b)) + blocks[10] - 1051523; |
| | | c = (c << 15 | c >>> 17) + d << 0; |
| | | b += (d ^ (c | ~a)) + blocks[1] - 2054922799; |
| | | b = (b << 21 | b >>> 11) + c << 0; |
| | | a += (c ^ (b | ~d)) + blocks[8] + 1873313359; |
| | | a = (a << 6 | a >>> 26) + b << 0; |
| | | d += (b ^ (a | ~c)) + blocks[15] - 30611744; |
| | | d = (d << 10 | d >>> 22) + a << 0; |
| | | c += (a ^ (d | ~b)) + blocks[6] - 1560198380; |
| | | c = (c << 15 | c >>> 17) + d << 0; |
| | | b += (d ^ (c | ~a)) + blocks[13] + 1309151649; |
| | | b = (b << 21 | b >>> 11) + c << 0; |
| | | a += (c ^ (b | ~d)) + blocks[4] - 145523070; |
| | | a = (a << 6 | a >>> 26) + b << 0; |
| | | d += (b ^ (a | ~c)) + blocks[11] - 1120210379; |
| | | d = (d << 10 | d >>> 22) + a << 0; |
| | | c += (a ^ (d | ~b)) + blocks[2] + 718787259; |
| | | c = (c << 15 | c >>> 17) + d << 0; |
| | | b += (d ^ (c | ~a)) + blocks[9] - 343485551; |
| | | b = (b << 21 | b >>> 11) + c << 0; |
| | | |
| | | if (this.first) { |
| | | this.h0 = a + 1732584193 << 0; |
| | | this.h1 = b - 271733879 << 0; |
| | | this.h2 = c - 1732584194 << 0; |
| | | this.h3 = d + 271733878 << 0; |
| | | this.first = false; |
| | | } else { |
| | | this.h0 = this.h0 + a << 0; |
| | | this.h1 = this.h1 + b << 0; |
| | | this.h2 = this.h2 + c << 0; |
| | | this.h3 = this.h3 + d << 0; |
| | | } |
| | | }; |
| | | |
| | | /** |
| | | * @method hex |
| | | * @memberof Md5 |
| | | * @instance |
| | | * @description Output hash as hex string |
| | | * @returns {String} Hex string |
| | | * @see {@link md5.hex} |
| | | * @example |
| | | * hash.hex(); |
| | | */ |
| | | Md5.prototype.hex = function () { |
| | | this.finalize(); |
| | | |
| | | var h0 = this.h0, h1 = this.h1, h2 = this.h2, h3 = this.h3; |
| | | |
| | | return HEX_CHARS[(h0 >>> 4) & 0x0F] + HEX_CHARS[h0 & 0x0F] + |
| | | HEX_CHARS[(h0 >>> 12) & 0x0F] + HEX_CHARS[(h0 >>> 8) & 0x0F] + |
| | | HEX_CHARS[(h0 >>> 20) & 0x0F] + HEX_CHARS[(h0 >>> 16) & 0x0F] + |
| | | HEX_CHARS[(h0 >>> 28) & 0x0F] + HEX_CHARS[(h0 >>> 24) & 0x0F] + |
| | | HEX_CHARS[(h1 >>> 4) & 0x0F] + HEX_CHARS[h1 & 0x0F] + |
| | | HEX_CHARS[(h1 >>> 12) & 0x0F] + HEX_CHARS[(h1 >>> 8) & 0x0F] + |
| | | HEX_CHARS[(h1 >>> 20) & 0x0F] + HEX_CHARS[(h1 >>> 16) & 0x0F] + |
| | | HEX_CHARS[(h1 >>> 28) & 0x0F] + HEX_CHARS[(h1 >>> 24) & 0x0F] + |
| | | HEX_CHARS[(h2 >>> 4) & 0x0F] + HEX_CHARS[h2 & 0x0F] + |
| | | HEX_CHARS[(h2 >>> 12) & 0x0F] + HEX_CHARS[(h2 >>> 8) & 0x0F] + |
| | | HEX_CHARS[(h2 >>> 20) & 0x0F] + HEX_CHARS[(h2 >>> 16) & 0x0F] + |
| | | HEX_CHARS[(h2 >>> 28) & 0x0F] + HEX_CHARS[(h2 >>> 24) & 0x0F] + |
| | | HEX_CHARS[(h3 >>> 4) & 0x0F] + HEX_CHARS[h3 & 0x0F] + |
| | | HEX_CHARS[(h3 >>> 12) & 0x0F] + HEX_CHARS[(h3 >>> 8) & 0x0F] + |
| | | HEX_CHARS[(h3 >>> 20) & 0x0F] + HEX_CHARS[(h3 >>> 16) & 0x0F] + |
| | | HEX_CHARS[(h3 >>> 28) & 0x0F] + HEX_CHARS[(h3 >>> 24) & 0x0F]; |
| | | }; |
| | | |
| | | /** |
| | | * @method toString |
| | | * @memberof Md5 |
| | | * @instance |
| | | * @description Output hash as hex string |
| | | * @returns {String} Hex string |
| | | * @see {@link md5.hex} |
| | | * @example |
| | | * hash.toString(); |
| | | */ |
| | | Md5.prototype.toString = Md5.prototype.hex; |
| | | |
| | | /** |
| | | * @method digest |
| | | * @memberof Md5 |
| | | * @instance |
| | | * @description Output hash as bytes array |
| | | * @returns {Array} Bytes array |
| | | * @see {@link md5.digest} |
| | | * @example |
| | | * hash.digest(); |
| | | */ |
| | | Md5.prototype.digest = function () { |
| | | this.finalize(); |
| | | |
| | | var h0 = this.h0, h1 = this.h1, h2 = this.h2, h3 = this.h3; |
| | | return [ |
| | | h0 & 0xFF, (h0 >>> 8) & 0xFF, (h0 >>> 16) & 0xFF, (h0 >>> 24) & 0xFF, |
| | | h1 & 0xFF, (h1 >>> 8) & 0xFF, (h1 >>> 16) & 0xFF, (h1 >>> 24) & 0xFF, |
| | | h2 & 0xFF, (h2 >>> 8) & 0xFF, (h2 >>> 16) & 0xFF, (h2 >>> 24) & 0xFF, |
| | | h3 & 0xFF, (h3 >>> 8) & 0xFF, (h3 >>> 16) & 0xFF, (h3 >>> 24) & 0xFF |
| | | ]; |
| | | }; |
| | | |
| | | /** |
| | | * @method array |
| | | * @memberof Md5 |
| | | * @instance |
| | | * @description Output hash as bytes array |
| | | * @returns {Array} Bytes array |
| | | * @see {@link md5.array} |
| | | * @example |
| | | * hash.array(); |
| | | */ |
| | | Md5.prototype.array = Md5.prototype.digest; |
| | | |
| | | /** |
| | | * @method arrayBuffer |
| | | * @memberof Md5 |
| | | * @instance |
| | | * @description Output hash as ArrayBuffer |
| | | * @returns {ArrayBuffer} ArrayBuffer |
| | | * @see {@link md5.arrayBuffer} |
| | | * @example |
| | | * hash.arrayBuffer(); |
| | | */ |
| | | Md5.prototype.arrayBuffer = function () { |
| | | this.finalize(); |
| | | |
| | | var buffer = new ArrayBuffer(16); |
| | | var blocks = new Uint32Array(buffer); |
| | | blocks[0] = this.h0; |
| | | blocks[1] = this.h1; |
| | | blocks[2] = this.h2; |
| | | blocks[3] = this.h3; |
| | | return buffer; |
| | | }; |
| | | |
| | | /** |
| | | * @method buffer |
| | | * @deprecated This maybe confuse with Buffer in node.js. Please use arrayBuffer instead. |
| | | * @memberof Md5 |
| | | * @instance |
| | | * @description Output hash as ArrayBuffer |
| | | * @returns {ArrayBuffer} ArrayBuffer |
| | | * @see {@link md5.buffer} |
| | | * @example |
| | | * hash.buffer(); |
| | | */ |
| | | Md5.prototype.buffer = Md5.prototype.arrayBuffer; |
| | | |
| | | /** |
| | | * @method base64 |
| | | * @memberof Md5 |
| | | * @instance |
| | | * @description Output hash as base64 string |
| | | * @returns {String} base64 string |
| | | * @see {@link md5.base64} |
| | | * @example |
| | | * hash.base64(); |
| | | */ |
| | | Md5.prototype.base64 = function () { |
| | | var v1, v2, v3, base64Str = '', bytes = this.array(); |
| | | for (var i = 0; i < 15;) { |
| | | v1 = bytes[i++]; |
| | | v2 = bytes[i++]; |
| | | v3 = bytes[i++]; |
| | | base64Str += BASE64_ENCODE_CHAR[v1 >>> 2] + |
| | | BASE64_ENCODE_CHAR[(v1 << 4 | v2 >>> 4) & 63] + |
| | | BASE64_ENCODE_CHAR[(v2 << 2 | v3 >>> 6) & 63] + |
| | | BASE64_ENCODE_CHAR[v3 & 63]; |
| | | } |
| | | v1 = bytes[i]; |
| | | base64Str += BASE64_ENCODE_CHAR[v1 >>> 2] + |
| | | BASE64_ENCODE_CHAR[(v1 << 4) & 63] + |
| | | '=='; |
| | | return base64Str; |
| | | }; |
| | | |
| | | /** |
| | | * HmacMd5 class |
| | | * @class HmacMd5 |
| | | * @extends Md5 |
| | | * @description This is internal class. |
| | | * @see {@link md5.hmac.create} |
| | | */ |
| | | function HmacMd5(key, sharedMemory) { |
| | | var i, result = formatMessage(key); |
| | | key = result[0]; |
| | | if (result[1]) { |
| | | var bytes = [], length = key.length, index = 0, code; |
| | | for (i = 0; i < length; ++i) { |
| | | code = key.charCodeAt(i); |
| | | if (code < 0x80) { |
| | | bytes[index++] = code; |
| | | } else if (code < 0x800) { |
| | | bytes[index++] = (0xc0 | (code >>> 6)); |
| | | bytes[index++] = (0x80 | (code & 0x3f)); |
| | | } else if (code < 0xd800 || code >= 0xe000) { |
| | | bytes[index++] = (0xe0 | (code >>> 12)); |
| | | bytes[index++] = (0x80 | ((code >>> 6) & 0x3f)); |
| | | bytes[index++] = (0x80 | (code & 0x3f)); |
| | | } else { |
| | | code = 0x10000 + (((code & 0x3ff) << 10) | (key.charCodeAt(++i) & 0x3ff)); |
| | | bytes[index++] = (0xf0 | (code >>> 18)); |
| | | bytes[index++] = (0x80 | ((code >>> 12) & 0x3f)); |
| | | bytes[index++] = (0x80 | ((code >>> 6) & 0x3f)); |
| | | bytes[index++] = (0x80 | (code & 0x3f)); |
| | | } |
| | | } |
| | | key = bytes; |
| | | } |
| | | |
| | | if (key.length > 64) { |
| | | key = (new Md5(true)).update(key).array(); |
| | | } |
| | | |
| | | var oKeyPad = [], iKeyPad = []; |
| | | for (i = 0; i < 64; ++i) { |
| | | var b = key[i] || 0; |
| | | oKeyPad[i] = 0x5c ^ b; |
| | | iKeyPad[i] = 0x36 ^ b; |
| | | } |
| | | |
| | | Md5.call(this, sharedMemory); |
| | | |
| | | this.update(iKeyPad); |
| | | this.oKeyPad = oKeyPad; |
| | | this.inner = true; |
| | | this.sharedMemory = sharedMemory; |
| | | } |
| | | HmacMd5.prototype = new Md5(); |
| | | |
| | | HmacMd5.prototype.finalize = function () { |
| | | Md5.prototype.finalize.call(this); |
| | | if (this.inner) { |
| | | this.inner = false; |
| | | var innerHash = this.array(); |
| | | Md5.call(this, this.sharedMemory); |
| | | this.update(this.oKeyPad); |
| | | this.update(innerHash); |
| | | Md5.prototype.finalize.call(this); |
| | | } |
| | | }; |
| | | |
| | | var exports = createMethod(); |
| | | exports.md5 = exports; |
| | | exports.md5.hmac = createHmacMethod(); |
| | | |
| | | if (COMMON_JS) { |
| | | module.exports = exports; |
| | | } else { |
| | | /** |
| | | * @method md5 |
| | | * @description Md5 hash function, export to global in browsers. |
| | | * @param {String|Array|Uint8Array|ArrayBuffer} message message to hash |
| | | * @returns {String} md5 hashes |
| | | * @example |
| | | * md5(''); // d41d8cd98f00b204e9800998ecf8427e |
| | | * md5('The quick brown fox jumps over the lazy dog'); // 9e107d9d372bb6826bd81d3542a419d6 |
| | | * md5('The quick brown fox jumps over the lazy dog.'); // e4d909c290d0fb1ca068ffaddf22cbd0 |
| | | * |
| | | * // It also supports UTF-8 encoding |
| | | * md5('中文'); // a7bac2239fcdcb3a067903d8077c4a07 |
| | | * |
| | | * // It also supports byte `Array`, `Uint8Array`, `ArrayBuffer` |
| | | * md5([]); // d41d8cd98f00b204e9800998ecf8427e |
| | | * md5(new Uint8Array([])); // d41d8cd98f00b204e9800998ecf8427e |
| | | */ |
| | | root.md5 = exports; |
| | | if (AMD) { |
| | | define(function () { |
| | | return exports; |
| | | }); |
| | | } |
| | | } |
| | | })(); |
| | | |
| | | }, function(modId) {var map = {}; return __REQUIRE__(map[modId], modId); }) |
| | | return __REQUIRE__(1718586298039); |
| | | })() |
| | | //miniprogram-npm-outsideDeps=["crypto","buffer"] |
| | | //# sourceMappingURL=index.js.map |
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.11.tgz", |
| | | "integrity": "sha512-okzr3f11N6WuqYtZSvm+F776mB41wRZMhKP+hc34YdW+KmtYYK9iqvHSwo2k9FEH3fhGXvOPV6yz2IcSrfRUDg==" |
| | | }, |
| | | "node_modules/js-md5": { |
| | | "version": "0.8.3", |
| | | "resolved": "https://registry.npmjs.org/js-md5/-/js-md5-0.8.3.tgz", |
| | | "integrity": "sha512-qR0HB5uP6wCuRMrWPTrkMaev7MJZwJuuw4fnwAzRgP4J4/F8RwtodOKpGp4XpqsLBFzzgqIO42efFAyz2Et6KQ==" |
| | | }, |
| | | "node_modules/tdesign-miniprogram": { |
| | | "version": "1.4.2", |
| | | "resolved": "https://registry.npmjs.org/tdesign-miniprogram/-/tdesign-miniprogram-1.4.2.tgz", |
| | |
| | | { |
| | | "dependencies": { |
| | | "js-md5": "^0.8.3", |
| | | "tdesign-miniprogram": "^1.4.2" |
| | | } |
| | | }, |
| | | "name": "irrigate_user_ym", |
| | | "version": "1.0.0", |
| | | "main": ".eslintrc.js", |
| | | "devDependencies": {}, |
| | | "scripts": { |
| | | "test": "echo \"Error: no test specified\" && exit 1" |
| | | }, |
| | | "keywords": [], |
| | | "author": "", |
| | | "license": "ISC", |
| | | "description": "" |
| | | } |
| | |
| | | const audio = wx.createInnerAudioContext() |
| | | const recorderManager = wx.getRecorderManager() |
| | | Page({ |
| | | data: { |
| | | isRefreshing: false, |
| | | currentTab: 0, |
| | | recordingSrc: '', |
| | | isRecording: false, |
| | | isshowVoiceMask: true, //是否显示录音中 |
| | | voiceTime: 2, //录音时长 |
| | | isshowVoiceMask: false, //是否显示录音中 |
| | | isShowVoiceView: false, |
| | | voiceTime: 0, //录音时长 |
| | | maxVoiceTime: 60, //最长录音时间 |
| | | contDownTime: 0, |
| | | line2Opcity: 1, |
| | | line3Opcity: 1, |
| | | gridConfig: { |
| | | column: 3, |
| | | width: 160, |
| | |
| | | name: 'uploaded2.png', |
| | | type: 'image', |
| | | } |
| | | ] |
| | | ], |
| | | feedBackList: Array(19).fill({ |
| | | createTime: "2023-05-06 12:36:25", |
| | | responseTime: "2023-05-07 12:36:25" |
| | | }) |
| | | }, |
| | | |
| | | onLoad() { |
| | | this.recorderManager = wx.getRecorderManager(); |
| | | this.recorderManager.onStart(() => { |
| | | console.log('recorder start'); |
| | | this.setData({ |
| | | isRecording: true |
| | | }); |
| | | this.startWaveformDrawing(); |
| | | wx.getSetting({ |
| | | success: (res) => { |
| | | if (!res.authSetting['scope.record']) { |
| | | // 如果用户没有授权录音权限,发起授权窗口 |
| | | wx.authorize({ |
| | | scope: 'scope.record', |
| | | success() { |
| | | // 用户已经同意小程序使用录音功能,可以继续操作 |
| | | console.log('用户已授权录音'); |
| | | }, |
| | | fail() { |
| | | // 用户拒绝授权,可以给出提示或再次发起授权窗口 |
| | | console.log('用户拒绝了授权录音'); |
| | | } |
| | | }); |
| | | } else { |
| | | // 用户已经授权录音,可以直接进行录音操作 |
| | | console.log('用户已授权录音'); |
| | | } |
| | | } |
| | | }); |
| | | var that = this; |
| | | recorderManager.onStop((res) => { |
| | | console.log('录音停止', voiceTime); |
| | | const voiceTime = Math.floor(res.duration / 1000) |
| | | if (voiceTime < 2) { |
| | | this.setData({ |
| | | isShowVoiceMask: false, |
| | | contDownTime: this.data.maxVoiceTime, |
| | | isShowVoiceView: false |
| | | }) |
| | | wx.showToast({ |
| | | title: '录音时间过短', |
| | | icon: 'error', |
| | | time: 3000 |
| | | }) |
| | | } else { |
| | | |
| | | that.setData({ |
| | | voiceTime: voiceTime, |
| | | isShowVoiceMask: false, |
| | | contDownTime: this.data.maxVoiceTime, |
| | | isShowVoiceView: true |
| | | }) |
| | | console.log('res', res); |
| | | const { |
| | | tempFilePath |
| | | } = res; //这里松开按钮 会返回录音本地路径 |
| | | audio.src = tempFilePath |
| | | console.log(tempFilePath); |
| | | } |
| | | |
| | | this.recorderManager.onStop((res) => { |
| | | console.log('recorder stop', res); |
| | | const { |
| | | tempFilePath |
| | | } = res; |
| | | this.setData({ |
| | | recordingSrc: tempFilePath, |
| | | isRecording: false |
| | | }); |
| | | this.stopWaveformDrawing(); |
| | | //上传录制的音频到服务器 |
| | | // wx.uploadFile({ |
| | | // url: '接口地址' + api.voice, //接口地址 |
| | | // name: 'file', //上传文件名 |
| | | // filePath: tempFilePath, |
| | | // success: function (res) { //后台返回给前端识别后的文字 |
| | | // var model = res.data |
| | | // var modeljson = JSON.parse(model) |
| | | // if (modeljson.status_code == 500) { |
| | | // wx.showToast({ |
| | | // title: '语音转换失败', |
| | | // image: '/assets/image/icon/fail@2x.png' |
| | | // }) |
| | | // return false; |
| | | // } |
| | | // if (modeljson.meta.status_code === 200 && !modeljson.data.err_msg) { |
| | | // var saymessage = modeljson.data.message; |
| | | // wx.setStorageSync('sayinfo', saymessage) |
| | | // that.setData({ |
| | | // inpvalue: saymessage |
| | | // }) |
| | | // setTimeout(() =>{ |
| | | // wx.navigateTo({ |
| | | // url: '../loding/loding' |
| | | // }) |
| | | |
| | | // },2000) |
| | | // setTimeout(() => { |
| | | // wx.hideLoading(); |
| | | // }, 100) |
| | | // } else if (modeljson.data.err_msg) { |
| | | // wx.showToast({ |
| | | // title: '请大声说话', |
| | | // image: '/assets/image/icon/fail@2x.png' |
| | | // }) |
| | | // return false; |
| | | // } |
| | | // } |
| | | // }) |
| | | }); |
| | | |
| | | this.recorderManager.onError((res) => { |
| | | console.error(res); |
| | | this.setData({ |
| | | isRecording: false |
| | | }); |
| | | this.stopWaveformDrawing(); |
| | | recorderManager.onStart(() => { |
| | | console.log('录音开始'); |
| | | }); |
| | | recorderManager.onError((err) => { |
| | | console.log('录音错误', err); |
| | | }); |
| | | }, |
| | | handleRemove(e) { |
| | |
| | | }); |
| | | }, |
| | | //按住按钮 |
| | | startHandel () { |
| | | startHandel() { |
| | | this.setData({ |
| | | isShowVoiceMask:true |
| | | isShowVoiceMask: true, |
| | | contDownTime: this.data.maxVoiceTime, |
| | | voiceTime: 0, |
| | | isShowVoiceView: false |
| | | }) |
| | | console.log("开始录音") |
| | | wx.getRecorderManager().start({ |
| | | duration: 0 |
| | | recorderManager.start({ |
| | | duration: 0 |
| | | }) |
| | | }, |
| | | //松开按钮 |
| | | endHandle () { |
| | | this.setData({ |
| | | isShowVoiceMask:false |
| | | }) |
| | | this.startRecordingCountdown(); |
| | | }, |
| | | //松开按钮 |
| | | endHandle() { |
| | | this.stopRecordingCountdown(); |
| | | console.log("结束") |
| | | const recorderManager = wx.getRecorderManager() |
| | | //录音停止函数 |
| | | var that = this; |
| | | wx.getRecorderManager().onStop((res) => { |
| | | const voiceTime = Math.floor(res.duration/1000) |
| | | console.log('voiceTime',voiceTime); |
| | | that.setData({ |
| | | voiceTime |
| | | }) |
| | | console.log('res',res); |
| | | const { tempFilePath } = res; //这里松开按钮 会返回录音本地路径 |
| | | audio.src = tempFilePath |
| | | console.log(tempFilePath); |
| | | //上传录制的音频到服务器 |
| | | // wx.uploadFile({ |
| | | // url: '接口地址' + api.voice, //接口地址 |
| | | // name: 'file', //上传文件名 |
| | | // filePath: tempFilePath, |
| | | // success: function (res) { //后台返回给前端识别后的文字 |
| | | // var model = res.data |
| | | // var modeljson = JSON.parse(model) |
| | | // if (modeljson.status_code == 500) { |
| | | // wx.showToast({ |
| | | // title: '语音转换失败', |
| | | // image: '/assets/image/icon/fail@2x.png' |
| | | // }) |
| | | // return false; |
| | | // } |
| | | // if (modeljson.meta.status_code === 200 && !modeljson.data.err_msg) { |
| | | // var saymessage = modeljson.data.message; |
| | | // wx.setStorageSync('sayinfo', saymessage) |
| | | // that.setData({ |
| | | // inpvalue: saymessage |
| | | // }) |
| | | // setTimeout(() =>{ |
| | | // wx.navigateTo({ |
| | | // url: '../loding/loding' |
| | | // }) |
| | | |
| | | // },2000) |
| | | // setTimeout(() => { |
| | | // wx.hideLoading(); |
| | | // }, 100) |
| | | // } else if (modeljson.data.err_msg) { |
| | | // wx.showToast({ |
| | | // title: '请大声说话', |
| | | // image: '/assets/image/icon/fail@2x.png' |
| | | // }) |
| | | // return false; |
| | | // } |
| | | // } |
| | | // }) |
| | | }) |
| | | //触发录音停止 |
| | | wx.getRecorderManager().stop() |
| | | }, |
| | | // 播放 |
| | | handlePlay(e){ |
| | | // 倒计时 |
| | | let time = this.data.voiceTime |
| | | audio.play() |
| | | let timer1 = -1,timer2 = -1,timer3 = -1,timer4 = -1,timer5 = -1,timer6 = -1; |
| | | // 第一次播放为0 第二次播放2秒钟 |
| | | timer6 = setInterval(()=>{ |
| | | console.log('时间',time); |
| | | if(time <= 0){ |
| | | this.setData({ |
| | | line2Opcity: 1, |
| | | line3Opcity: 1 |
| | | }) |
| | | clearInterval(timer6) |
| | | clearTimeout(timer2) |
| | | clearTimeout(timer3) |
| | | clearTimeout(timer4) |
| | | clearTimeout(timer5) |
| | | return |
| | | } |
| | | timer2 = setTimeout(()=>{ |
| | | console.log('timer2'); |
| | | this.setData({ |
| | | line2Opcity: 0, |
| | | line3Opcity: 0 |
| | | }) |
| | | },300) |
| | | timer3 = setTimeout(()=>{ |
| | | console.log('timer3'); |
| | | this.setData({ |
| | | line2Opcity: 1, |
| | | line3Opcity:0 |
| | | }) |
| | | },600) |
| | | timer4 = setTimeout(()=>{ |
| | | console.log('timer4'); |
| | | recorderManager.stop() |
| | | }, |
| | | // 播放 |
| | | handlePlay(e) { |
| | | // 倒计时 |
| | | let time = this.data.voiceTime |
| | | audio.play() |
| | | let timer1 = -1, |
| | | timer2 = -1, |
| | | timer3 = -1, |
| | | timer4 = -1, |
| | | timer5 = -1, |
| | | timer6 = -1; |
| | | // 第一次播放为0 第二次播放2秒钟 |
| | | timer6 = setInterval(() => { |
| | | console.log('时间', time); |
| | | if (time <= 0) { |
| | | this.setData({ |
| | | line2Opcity: 1, |
| | | line3Opcity: 1 |
| | | }) |
| | | },900) |
| | | timer5 = setTimeout(()=>{ |
| | | console.log('timer5'); |
| | | }) |
| | | clearInterval(timer6) |
| | | clearTimeout(timer2) |
| | | clearTimeout(timer3) |
| | | clearTimeout(timer4) |
| | | clearTimeout(timer5) |
| | | return |
| | | } |
| | | timer2 = setTimeout(() => { |
| | | console.log('timer2'); |
| | | this.setData({ |
| | | line2Opcity: 0, |
| | | line3Opcity: 0 |
| | | }) |
| | | },1200) |
| | | },1200) |
| | | // 倒计时 |
| | | timer1 = setInterval(()=>{ |
| | | time--; |
| | | if(time <= 0){ |
| | | clearInterval(timer1) |
| | | return |
| | | } |
| | | },1000) |
| | | }, 200) |
| | | timer3 = setTimeout(() => { |
| | | console.log('timer3'); |
| | | this.setData({ |
| | | line2Opcity: 1, |
| | | line3Opcity: 0 |
| | | }) |
| | | }, 400) |
| | | timer4 = setTimeout(() => { |
| | | console.log('timer4'); |
| | | this.setData({ |
| | | line2Opcity: 1, |
| | | line3Opcity: 1 |
| | | }) |
| | | }, 600) |
| | | timer5 = setTimeout(() => { |
| | | console.log('timer5'); |
| | | this.setData({ |
| | | line2Opcity: 0, |
| | | line3Opcity: 0 |
| | | }) |
| | | }, 800) |
| | | }, 800) |
| | | // 倒计时 |
| | | timer1 = setInterval(() => { |
| | | time--; |
| | | if (time <= 0) { |
| | | clearInterval(timer1) |
| | | return |
| | | } |
| | | }, 1000) |
| | | |
| | | } |
| | | }, |
| | | //开启定时器 |
| | | startRecordingCountdown() { |
| | | console.log("startRecordingCountdown"); |
| | | const that = this; |
| | | this.recordingInterval = setInterval(() => { |
| | | const newVoiceTime = that.data.voiceTime + 1; |
| | | const newContDownTime = that.data.contDownTime - 1; |
| | | that.setData({ |
| | | voiceTime: newVoiceTime, |
| | | contDownTime: newContDownTime |
| | | }); |
| | | if (this.data.voiceTime >= this.data.maxVoiceTime) { |
| | | that.stopRecordingCountdown(); |
| | | that.endHandle(); |
| | | } |
| | | }, 1000); |
| | | }, |
| | | |
| | | stopRecordingCountdown() { |
| | | console.log("stopRecordingCountdown"); |
| | | if (this.recordingInterval) { |
| | | clearInterval(this.recordingInterval); |
| | | this.recordingInterval = null; |
| | | console.log("Recording countdown stopped"); |
| | | } |
| | | }, // 切换 Tabs |
| | | switchTab: function (e) { |
| | | const tab = parseInt(e.currentTarget.dataset.tab); |
| | | this.setData({ |
| | | currentTab: tab |
| | | }); |
| | | }, |
| | | onPullDownRefresh() { |
| | | this.setData({ |
| | | isRefreshing: false |
| | | }); |
| | | } |
| | | |
| | | }); |
| | |
| | | <view class="container"> |
| | | |
| | | <view class="container-item"> |
| | | <text class="fb-text">反馈详情:</text> |
| | | <textarea class="input-class" /> |
| | | </view> |
| | | <view class="divider"></view> |
| | | <view class="container-item"> |
| | | <text class="img-upload">图片(最多三张):</text> |
| | | <t-upload style="margin-top: 20rpx;" media-type="{{['image']}}" files="{{originFiles}}" gridConfig="{{gridConfig}}" bind:success="handleSuccess" max="3" bind:add="handleAdd" bind:remove="handleRemove" bind:click="handleClick" bind:sort-end="handleSortEnd" /> |
| | | </view> |
| | | <view class="divider"></view> |
| | | <view class="container-voice"> |
| | | <text class="fb-text">录音:</text> |
| | | <view class="voice_wrapper"> |
| | | <image class="voice_img" bindtouchstart='startHandel' bindtouchend='endHandle' src="/images/tape.svg" mode="" /> |
| | | <view class="voice_content" bind:tap="handlePlay" wx:if="{{voiceTime}}"> |
| | | <view class="left"> |
| | | <view class="line"></view> |
| | | <view class="line" style="opacity:{{line2Opcity}}" id="test2"></view> |
| | | <view class="line" style="opacity:{{line3Opcity}}" id="test3"></view> |
| | | </view> |
| | | <view class="right">{{voiceTime}}"</view> |
| | | </view> |
| | | <!-- 顶部 Tabs --> |
| | | <view class="tabs"> |
| | | <view class="tab" bindtap="switchTab" data-tab="0" id="tab0"> |
| | | 问题反馈 |
| | | <view class="indicator" wx:if="{{currentTab === 0}}"></view> |
| | | </view> |
| | | <view class="tab" bindtap="switchTab" data-tab="1" id="tab1"> |
| | | 已提问题 |
| | | <view class="indicator" wx:if="{{currentTab === 1}}"></view> |
| | | </view> |
| | | </view> |
| | | <!-- 录音中 --> |
| | | <view wx:if="{{isShowVoiceMask}}" class="voice_starting">录音中</view> |
| | | <button class="fb-submit">提交</button> |
| | | <view class="container-feedBack" wx:if="{{currentTab === 0}}"> |
| | | <view class="container-item"> |
| | | <text class="fb-text">反馈详情:</text> |
| | | <textarea style="position: relative; left: -2rpx; top: 0rpx" class="input-class" /> |
| | | </view> |
| | | <view class="divider"></view> |
| | | <view class="container-item"> |
| | | <text class="fb-text">图片(最多三张):</text> |
| | | <t-upload style="margin-top: 20rpx;" media-type="{{['image']}}" files="{{originFiles}}" gridConfig="{{gridConfig}}" bind:success="handleSuccess" max="3" bind:add="handleAdd" bind:remove="handleRemove" bind:click="handleClick" bind:sort-end="handleSortEnd" /> |
| | | </view> |
| | | <view class="divider"></view> |
| | | <view class="container-voice"> |
| | | <text class="fb-text">录音:</text> |
| | | <view class="voice_wrapper"> |
| | | <image class="voice_img" bindtouchstart='startHandel' bindtouchend='endHandle' src="/images/tape.svg" mode="" /> |
| | | <view class="voice_content" bind:tap="handlePlay" wx:if="{{isShowVoiceView}}"> |
| | | <view class="left"> |
| | | <view class="line"></view> |
| | | <view class="line" style="opacity:{{line2Opcity}}" id="test2"></view> |
| | | <view class="line" style="opacity:{{line3Opcity}}" id="test3"></view> |
| | | </view> |
| | | <view class="right">{{voiceTime}}"</view> |
| | | </view> |
| | | </view> |
| | | </view> |
| | | <!-- 录音中 --> |
| | | <view wx:if="{{isShowVoiceMask}}" class="voice_starting">录音中{{contDownTime}}秒</view> |
| | | <button class="fb-submit">提交</button> |
| | | </view> |
| | | |
| | | <scroll-view class="container-scroll" wx:if="{{currentTab === 1}}" scroll-y="true" refresher-enabled="true" refresher-threshold="50" bindrefresherrefresh="onPullDownRefresh" refresher-triggered="{{isRefreshing}}"> |
| | | <block wx:for="{{feedBackList}}" wx:key="index"> |
| | | <view class="item"> |
| | | <view class="item-data"> |
| | | <text>提问时间:</text> |
| | | <text>{{item.createTime}}</text> |
| | | </view> |
| | | <view class="item-data"> |
| | | <text>响应时间:</text> |
| | | <text>{{item.responseTime}}</text> |
| | | </view> |
| | | </view> |
| | | </block> |
| | | <view wx:if="{{feedBackList.length === 0}}" class="noMore-View"> |
| | | <image class="noMore-img" src="/images/no_more.svg" /> |
| | | <text class="noMore-text">没有数据</text> |
| | | </view> |
| | | </scroll-view> |
| | | |
| | | |
| | | </view> |
| | |
| | | .container { |
| | | display: flex; |
| | | flex-direction: column; |
| | | width: 100%; |
| | | height: 100vh; |
| | | padding-left: 30rpx; |
| | | padding-right: 30rpx; |
| | | width: calc(100% - 0rpx); |
| | | /* 考虑了左右边距后的实际宽度 */ |
| | | background-color: #fff; |
| | | justify-content: flex-start; |
| | | justify-content: center; |
| | | align-items: center; |
| | | } |
| | | |
| | | .container-scroll{ |
| | | flex: 1; |
| | | overflow-y: auto; |
| | | z-index: 0; |
| | | display: flex; |
| | | flex-direction: column; |
| | | padding-bottom: 20rpx; /* 增加底部填充 */ |
| | | } |
| | | |
| | | .container-feedBack { |
| | | width: calc(100% - 80rpx); |
| | | /* 40rpx 为左右 padding 的总和 */ |
| | | height: 100vh; |
| | | /* 考虑了左右边距后的实际宽度 */ |
| | | background-color: #fff; |
| | | padding-left: 40rpx; |
| | | padding-right: 40rpx; |
| | | padding-top: 1rpx; |
| | | padding-bottom: 1rpx; |
| | | } |
| | | |
| | | |
| | | |
| | | |
| | | .btn { |
| | | margin: 10px; |
| | |
| | | .input-class { |
| | | border-radius: 5px; |
| | | border: 2rpx solid #000000; |
| | | height: 20vh; |
| | | height: 10vh; |
| | | width: 100%; |
| | | background-color: #fcfcfc; |
| | | display: flex; |
| | | flex-direction: column; |
| | | justify-content: center; |
| | | align-items: center; |
| | | } |
| | | |
| | | .img-upload { |
| | |
| | | } |
| | | |
| | | .container-item { |
| | | width: 100%; |
| | | display: flex; |
| | | flex-direction: column; |
| | | |
| | | justify-content: flex-start |
| | | } |
| | | |
| | | .container-voice { |
| | | width: 100%; |
| | | display: flex; |
| | | flex-direction: row; |
| | | |
| | | align-items: center; |
| | | } |
| | | |
| | | .fb-text { |
| | | font-size: 35rpx; |
| | | margin-left: 30rpx; |
| | | margin-bottom: 10rpx; |
| | | } |
| | | |
| | | .fb-submit { |
| | |
| | | background-color: #1890FF; |
| | | font-size: 35rpx; |
| | | color: white; |
| | | margin-top: 50rpx; |
| | | margin-top: 200rpx; |
| | | } |
| | | |
| | | .voice_img { |
| | |
| | | margin-right: 20rpx; |
| | | } |
| | | |
| | | .voice_starting{ |
| | | .voice_starting { |
| | | position: fixed; |
| | | top: 30%; |
| | | left: 50%; |
| | | transform: translate(-50%, -50%); |
| | | width: 200rpx; |
| | | height: 200rpx; |
| | | line-height: 200rpx; |
| | | width: 300rpx; |
| | | height: 300rpx; |
| | | align-items: center; |
| | | line-height: 300rpx; |
| | | background-color: #787879; |
| | | color: #fff; |
| | | text-align: center; |
| | | border-radius: 100rpx; /* 使其呈现圆形 */ |
| | | border-radius: 150rpx; |
| | | /* 使其呈现圆形 */ |
| | | z-index: 10000; |
| | | } |
| | | |
| | | .tabs { |
| | | display: flex; |
| | | justify-content: space-around; |
| | | position: relative; |
| | | width: 100%; |
| | | border-bottom: 1px solid #eee; |
| | | margin-bottom: 20rpx; |
| | | /* Tabs 占满整个横向屏幕 */ |
| | | } |
| | | |
| | | .tab { |
| | | font-size: 16px; |
| | | padding: 10px; |
| | | cursor: pointer; |
| | | position: relative; |
| | | width: 50%; |
| | | /* Tabs 平分整个横向屏幕 */ |
| | | text-align: center; |
| | | /* 文字居中 */ |
| | | } |
| | | |
| | | .indicator { |
| | | width: 100%; |
| | | height: 3px; |
| | | background-color: #1890FF; |
| | | position: absolute; |
| | | bottom: 0; |
| | | left: 0; |
| | | transform: translateX(0); |
| | | /* 初始化位置 */ |
| | | } |
| | | |
| | | .item { |
| | | display: flex; |
| | | flex-direction: row; |
| | | flex-wrap: nowrap; |
| | | /*表示不换行*/ |
| | | padding-left: 40rpx; |
| | | padding-right: 40rpx; |
| | | width: calc(100% - 80rpx); |
| | | margin-bottom: 40rpx; |
| | | } |
| | | |
| | | .item-data { |
| | | display: flex; |
| | | flex-direction: column; |
| | | flex-grow: 1; |
| | | } |
| | | |
| | | .item-data text { |
| | | font-size: 30rpx; |
| | | } |
| | |
| | | get, |
| | | post |
| | | } = require('../../api/request.js'); |
| | | const app = getApp(); |
| | | Page({ |
| | | |
| | | /** |
| | | * 页面的初始数据 |
| | | */ |
| | | data: { |
| | | sessionId: "", |
| | | showConfirm: false, |
| | | myItem: {}, |
| | | waterIntakeName: "", |
| | | image: "/images/ic_head_bg.jpg", |
| | | userPhone: "158****0723", |
| | | userName: "张三", |
| | | userPhone: "未登录", |
| | | userName: "请登录", |
| | | scrollViewHeight: 0, |
| | | listData: [], |
| | | isRefreshing: false, |
| | | isWXRefreshing: false |
| | | isWXRefreshing: false, |
| | | wxCode: '', |
| | | errorData: '', //错误内容 |
| | | showErrorDialog: false |
| | | }, |
| | | |
| | | openValve: function (e) { |
| | |
| | | isRefreshing: true |
| | | }); |
| | | this.getOpenList(); |
| | | |
| | | } |
| | | |
| | | }, |
| | | //获取用户数据 |
| | | getUserData() { |
| | |
| | | console.error('Failed to fetch data:', error); |
| | | }); |
| | | }, |
| | | |
| | | |
| | | |
| | | /** |
| | | * 生命周期函数--监听页面加载 |
| | | */ |
| | |
| | | }) |
| | | this.getOpenList(); |
| | | } |
| | | this.getUserDataBySession(); |
| | | }, |
| | | |
| | | /** |
| | |
| | | this.setData({ |
| | | sessionId: data |
| | | }); |
| | | if (sessionId !== "") {} |
| | | }).catch((err) => { |
| | | console.error('Failed to load parameter:', err); |
| | | }); |
| | | if (sessionId) { |
| | | this.getOpenList(); |
| | | } |
| | | }).catch((err) => {}); |
| | | } else { |
| | | console.log('Failed to load parameter:false'); |
| | | this.wxLogin(); |
| | | } |
| | | this.getOpenList(); |
| | | }, |
| | | |
| | | /** |
| | |
| | | |
| | | }, |
| | | recharge() { |
| | | // wx.navigateTo({ |
| | | // url: '/pages/rechargeCard/rechargeCard', |
| | | // }) |
| | | wx.showToast({ |
| | | title: '暂未开放', |
| | | icon: 'none' |
| | | wx.navigateTo({ |
| | | url: '/pages/rechargeCard/rechargeCard', |
| | | }) |
| | | |
| | | }, |
| | | openValveList() { |
| | | // wx.navigateTo({ |
| | | // url: '/pages/valveList/valveList', |
| | | // }) |
| | | wx.showToast({ |
| | | title: '暂未开放', |
| | | icon: 'none' |
| | | wx.navigateTo({ |
| | | url: '/pages/valveList/valveList', |
| | | }) |
| | | |
| | | }, |
| | | feedBack() { |
| | | wx.showToast({ |
| | | title: '暂未开放', |
| | | icon: 'none' |
| | | wx.navigateTo({ |
| | | url: '/pages/feedback/feedback', |
| | | }) |
| | | }, |
| | | handleChange(e) { |
| | |
| | | post({ |
| | | url: "wx/valve/close_wx", |
| | | data: data, |
| | | isShowLoding: false |
| | | isShowLoding: false, |
| | | timeout: 185000 |
| | | }).then(response => { |
| | | |
| | | // 处理成功响应 |
| | |
| | | }) |
| | | }).catch(error => { |
| | | wx.hideLoading(); |
| | | if (error.code === "1002") { |
| | | wx.showToast({ |
| | | title: '关阀失败', |
| | | icon: 'error', |
| | | duration: 3000 // 提示的持续时间,单位毫秒 |
| | | }) |
| | | } |
| | | this.setData({ |
| | | showErrorDialog: true, |
| | | errorData: error.msg |
| | | }) |
| | | // 处理错误响应 |
| | | console.error('请求失败:', error); |
| | | |
| | |
| | | * 获取为关阀记录 |
| | | */ |
| | | getOpenList() { |
| | | const app = getApp(); |
| | | const params = { |
| | | url: 'wx/valve/get', |
| | | data: { |
| | |
| | | // 错误回调 |
| | | this.setData({ |
| | | isRefreshing: false, // 将triggered属性设置为false,表示下拉刷新已完成 |
| | | isWXRefreshing: false, // 将triggered属性设置为false,表示下拉刷新已完成 |
| | | }) |
| | | wx.showToast({ |
| | | title: err.msg, |
| | | icon: 'error', |
| | | duration: 3000 |
| | | }) |
| | | }); |
| | | }, |
| | |
| | | getUserDataBySession() { |
| | | const app = getApp(); |
| | | const params = { |
| | | url: 'sell/client/simple_info', |
| | | url: 'wx/client/simple_info', |
| | | data: { |
| | | sessionId: app.globalData.sessionId |
| | | } |
| | |
| | | |
| | | }) |
| | | }, |
| | | //将手机号中间四位隐藏 |
| | | maskPhoneNumber(phoneNumber) { |
| | | if (phoneNumber.length !== 11) { |
| | | throw new Error("Phone number must be 11 digits"); |
| | |
| | | // 使用正则表达式替换中间四位数字为星号 |
| | | const maskedPhoneNumber = phoneNumber.replace(/^(\d{3})\d{4}(\d{4})$/, "$1****$2"); |
| | | return maskedPhoneNumber; |
| | | }, |
| | | //没有sessionID时获取sessionID |
| | | getSessionID(code) { |
| | | const params = { |
| | | url: 'https://44978f7456.imdo.co/wx/client/code_login ', |
| | | data: { |
| | | code: code |
| | | } |
| | | }; |
| | | post(params).then(data => { |
| | | if (data.content.client.sessionId) { |
| | | //当前用户绑定过 |
| | | getApp().globalData.sessionId = data.content.client.sessionId |
| | | storage.setItem("sessionId", data.content.client.sessionId); |
| | | this.getOpenList(); |
| | | this.getUserDataBySession(); |
| | | |
| | | } else { |
| | | //当前用户没绑定过,跳转到绑定界面 |
| | | wx.navigateTo({ |
| | | url: '/pages/wxbind/wxbind?wxCode=' + this.data.wxCode, |
| | | }) |
| | | } |
| | | |
| | | }).catch(err => { |
| | | // 错误回调 |
| | | |
| | | }) |
| | | }, |
| | | wxLogin() { |
| | | // 登录 |
| | | wx.login({ |
| | | success: res => { |
| | | if (res.code) { |
| | | console.log('登录成功,获取到的code:', res.code); |
| | | this.setData({ |
| | | wxCode: res.code |
| | | }) |
| | | // 发送 res.code 到后台服务器换取 openId, sessionKey, unionId |
| | | this.getSessionID(res.code) |
| | | } else { |
| | | console.log('登录失败!' + res.errMsg); |
| | | } |
| | | } |
| | | }); |
| | | }, |
| | | closeDialog() { |
| | | this.setData({ |
| | | showErrorDialog:false |
| | | }) |
| | | } |
| | | |
| | | |
| | | |
| | | |
| | | }) |
| | |
| | | <view class="dot"></view> |
| | | </view> |
| | | <view class="scroll-bg"> |
| | | <view wx:if="{{listData.length > 0}}" class="list-item" wx:for="{{listData}}" wx:for-item="item" wx:for-index="index"> |
| | | <view wx:if="{{listData.length > 0}}" class="list-item" wx:for="{{listData}}" wx:for-item="item" wx:for-index="index"> |
| | | <view class="item-left"> |
| | | <!-- <image class="item-img" src="/images/pipeline.svg" /> --> |
| | | <text>{{item.intakeNum}}</text> |
| | |
| | | <text class="noMore-text">没有开泵记录</text> |
| | | </view> |
| | | </scroll-view> |
| | | <t-dialog class="t-dialog" visible="{{showConfirm}}" content="确认关闭{{waterIntakeName}}吗?" confirm-btn="{{ { content: '确认', variant: 'base', theme: 'danger' } }}" close-on-overlay-click="false" cancel-btn="取消" bind:confirm="confirmDialog" bind:cancel="closeDialog" /> |
| | | |
| | | <t-dialog class="dialog" visible="{{showConfirm}}" content="确认关闭{{waterIntakeName}}吗?" confirm-btn="{{ { content: '确认', variant: 'base', theme: 'danger' } }}" close-on-overlay-click="false" cancel-btn="取消" bind:confirm="confirmDialog" bind:cancel="closeDialog" /> |
| | | <t-dialog title="关阀错误" visible="{{showErrorDialog}}" content="{{errorData}}" confirm-btn="{{ confirmBtn }}" bind:confirm="closeDialog" /> |
| | | </view> |
| | |
| | | /* 允许垂直滚动 */ |
| | | z-index: 0; |
| | | /* 确保 scroll-view 在头部和 center-wrapper 之下 */ |
| | | margin-bottom: 20rpx; |
| | | } |
| | | |
| | | |
| | |
| | | margin-left: 20rpx; |
| | | } |
| | | |
| | | .t-dialog { |
| | | .dialog { |
| | | --td-dialog-content-font-size: 40rpx; |
| | | --td-dialog-content-line-height: 50rpx |
| | | } |
| | |
| | | width: 100%; |
| | | margin-top: 2rpx; |
| | | /* background-color: #e0e0e0; */ |
| | | } |
| | | |
| | | .error-dialog{ |
| | | --td-dialog-title-color:red; |
| | | --td-dialog-title-font-size:45rpx; |
| | | } |
| | |
| | | * 页面的初始数据 |
| | | */ |
| | | data: { |
| | | confirmBtn: { content: '确认', variant: 'base' }, |
| | | confirmBtn: { |
| | | content: '确认' |
| | | }, |
| | | currentTab: 0, // 当前显示的表格,默认为第一个表格 |
| | | allCardPoints: [], |
| | | allWaterPoints:[], |
| | | showDialog:false |
| | | allCardPoints: [{ |
| | | "id": "string", |
| | | "inUse": 0, |
| | | "inUseName": "string", |
| | | "money": 110, |
| | | "vcNum": "200030000000" |
| | | }, { |
| | | "id": "string", |
| | | "inUse": 0, |
| | | "inUseName": "string", |
| | | "money": 110, |
| | | "vcNum": "200030000000" |
| | | }, { |
| | | "id": "string", |
| | | "inUse": 0, |
| | | "inUseName": "string", |
| | | "money": 110, |
| | | "vcNum": "200030000000" |
| | | }, { |
| | | "id": "string", |
| | | "inUse": 0, |
| | | "inUseName": "string", |
| | | "money": 110, |
| | | "vcNum": "200030000000" |
| | | }, { |
| | | "id": "string", |
| | | "inUse": 1, |
| | | "inUseName": "string", |
| | | "money": 110, |
| | | "vcNum": "200030000000" |
| | | }], |
| | | allWaterPoints: [{ |
| | | "id": "string", |
| | | "inUse": 1, |
| | | "inUseName": "string", |
| | | "money": 110, |
| | | "vcNum": "200030000000" |
| | | },{ |
| | | "id": "string", |
| | | "inUse": 1, |
| | | "inUseName": "string", |
| | | "money": 110, |
| | | "vcNum": "200030000000" |
| | | },{ |
| | | "id": "string", |
| | | "inUse": 1, |
| | | "inUseName": "string", |
| | | "money": 110, |
| | | "vcNum": "200030000000" |
| | | },{ |
| | | "id": "string", |
| | | "inUse": 1, |
| | | "inUseName": "string", |
| | | "money": 110, |
| | | "vcNum": "200030000000" |
| | | },{ |
| | | "id": "string", |
| | | "inUse": 1, |
| | | "inUseName": "string", |
| | | "money": 110, |
| | | "vcNum": "200030000000" |
| | | }], |
| | | showDialog: false |
| | | }, |
| | | // 切换 Tabs |
| | | switchTab: function (e) { |
| | | const tab = parseInt(e.currentTarget.dataset.tab); |
| | | this.setData({ |
| | | currentTab: tab |
| | | }); |
| | | }, |
| | | // 切换 Tabs |
| | | switchTab: function (e) { |
| | | const tab = parseInt(e.currentTarget.dataset.tab); |
| | | this.setData({ |
| | | currentTab: tab |
| | | }); |
| | | }, |
| | | /** |
| | | * 生命周期函数--监听页面加载 |
| | | */ |
| | |
| | | */ |
| | | onShareAppMessage() { |
| | | |
| | | },//获取虚拟卡列表 |
| | | getCardList(){ |
| | | get({url:'https://d4x9787456.vicp.fun/sell/virtual_card/get', data: { |
| | | operator: getApp().globalData.sessionId |
| | | }}) |
| | | .then((data) => { |
| | | if(data.success&&data.code==="0001"){ |
| | | this.setData({ |
| | | allCardPoints: data.content |
| | | }); |
| | | }else{ |
| | | wx.showToast({ |
| | | title: data.msg, |
| | | }) |
| | | } |
| | | console.log('Failed to add item:'); |
| | | }) |
| | | .catch((error) => { |
| | | console.error('Failed to add item:', error); |
| | | }); |
| | | }, //获取虚拟卡列表 |
| | | getCardList() { |
| | | get({ |
| | | url: 'https://d4x9787456.vicp.fun/sell/virtual_card/get', |
| | | data: { |
| | | operator: getApp().globalData.sessionId |
| | | } |
| | | }) |
| | | .then((data) => { |
| | | if (data.success && data.code === "0001") { |
| | | this.setData({ |
| | | allCardPoints: data.content |
| | | }); |
| | | } else { |
| | | wx.showToast({ |
| | | title: data.msg, |
| | | }) |
| | | } |
| | | |
| | | }) |
| | | .catch((error) => { |
| | | |
| | | }); |
| | | }, |
| | | getWaterCardList(){ |
| | | get({url:'https://d4x9787456.vicp.fun/sell/virtual_card/get', data: { |
| | | operator: getApp().globalData.sessionId |
| | | }}) |
| | | .then((data) => { |
| | | if(data.success&&data.code==="0001"){ |
| | | this.setData({ |
| | | allWaterPoints: data.content |
| | | }); |
| | | }else{ |
| | | wx.showToast({ |
| | | title: data.msg, |
| | | }) |
| | | } |
| | | console.log('Failed to add item:'); |
| | | }) |
| | | .catch((error) => { |
| | | console.error('Failed to add item:', error); |
| | | }); |
| | | getWaterCardList() { |
| | | get({ |
| | | url: 'https://d4x9787456.vicp.fun/sell/virtual_card/get', |
| | | data: { |
| | | operator: getApp().globalData.sessionId |
| | | } |
| | | }) |
| | | .then((data) => { |
| | | if (data.success && data.code === "0001") { |
| | | this.setData({ |
| | | allWaterPoints: data.content |
| | | }); |
| | | } else { |
| | | wx.showToast({ |
| | | title: data.msg, |
| | | }) |
| | | } |
| | | console.log('Failed to add item:'); |
| | | }) |
| | | .catch((error) => { |
| | | console.error('Failed to add item:', error); |
| | | }); |
| | | }, |
| | | rechargeCard(item){ |
| | | rechargeCard(item) { |
| | | wx.navigateTo({ |
| | | url: '/pages/rechargeMoney/rechargMoney' // 首页的路径,根据实际情况填写 |
| | | }); |
| | | }, |
| | | ruinCard(){ |
| | | |
| | | }, |
| | | closeDialog(){ |
| | | ruinCard() { |
| | | this.setData({ |
| | | showDialog:false |
| | | showDialog: true |
| | | }) |
| | | }, |
| | | closeDialog() { |
| | | this.setData({ |
| | | showDialog: false |
| | | }) |
| | | } |
| | | |
| | |
| | | { |
| | | "usingComponents": { |
| | | "t-dialog": "tdesign-miniprogram/dialog/dialog" |
| | | "t-dialog": "tdesign-miniprogram/dialog/dialog", |
| | | "t-button": "tdesign-miniprogram/button/button" |
| | | } |
| | | } |
| | |
| | | <image class="noMore-img" src="/images/no_more.svg" /> |
| | | <text class="noMore-text">没有数据</text> |
| | | </view> |
| | | <t-dialog visible="{{showDialog}}" content="您还有余额未使用,如需销卡,请先使用完或退款后才可操作。" confirm-btn="{{ confirmBtn }}" bind:confirm="closeDialog" /> |
| | | <t-dialog visible="{{showDialog}}" content="您还有余额未使用,如需销卡,请先使用完或退款后才可操作。" confirm-btn="{{ confirmBtn }}" bind:confirm="closeDialog" /> |
| | | </scroll-view> |
| | | |
| | | <!-- 水卡 --> |
| | |
| | | <view class="item-card"> |
| | | <text class="item-card-text">卡编号:</text> |
| | | <text class="item-card-text">{{item.vcNum}}</text> |
| | | <text class="waterIntake-recharge">充值</text> |
| | | <text class="waterIntake-recharge" bind:tap="rechargeCard">充值</text> |
| | | </view> |
| | | </view> |
| | | </block> |
| | |
| | | border-radius: 30rpx; |
| | | font-size: 30rpx; |
| | | } |
| | | |
| | |
| | | // pages/rechargeMoney/rechargMoney.js |
| | | const { |
| | | get, |
| | | post |
| | | } = require('../../api/request.js'); |
| | | const md5 = require('js-md5'); |
| | | Page({ |
| | | |
| | | /** |
| | |
| | | userCode: "15584236", |
| | | balance: "1025元", |
| | | activeIndex: -1, |
| | | isClickable: false, |
| | | allRechargeList: [{ |
| | | time: "2024-05-12:20:20", |
| | | type: "远程", |
| | |
| | | if (index !== undefined) { |
| | | this.setData({ |
| | | activeIndex: parseInt(index), |
| | | isClickable: true |
| | | }); |
| | | } |
| | | }, |
| | | onPullDownRefresh() { |
| | | console.log("onPullDownRefresh") |
| | | }, |
| | | //创建订单并调起支付 |
| | | creatOrder() { |
| | | if (!this.data.isClickable) { |
| | | return; |
| | | } |
| | | const data = { |
| | | sessionId: "2024061708384800006", |
| | | vcId: "2024060610404500006", //虚拟卡ID |
| | | rechargeAmount: 1 //(单位是分) |
| | | }; |
| | | console.log("postCloseValaue" + data); |
| | | post({ |
| | | url: "https://44978f7456.imdo.co/sell/payment/placeOrder", |
| | | data: data |
| | | }).then(response => { |
| | | // 处理成功响应 |
| | | console.log('请求成功:', response); |
| | | const timeStamp = String(Math.floor(Date.now() / 1000)); |
| | | const nonceStr = timeStamp; |
| | | const prepayId = response.content.prepay_id; |
| | | const signType = 'MD5'; |
| | | |
| | | // 生成支付签名 |
| | | const paySign = this.generatePaySign({ |
| | | appId: getApp().globalData.APPID, |
| | | timeStamp: timeStamp, |
| | | nonceStr: nonceStr, |
| | | package: prepayId, |
| | | signType: signType |
| | | }); |
| | | |
| | | // 调起支付 |
| | | wx.requestPayment({ |
| | | timeStamp: timeStamp, |
| | | nonceStr: nonceStr, |
| | | package: prepayId, |
| | | signType: signType, |
| | | paySign: paySign, |
| | | success(res) { |
| | | console.log('支付成功', res); |
| | | }, |
| | | fail(err) { |
| | | console.log('支付失败', err); |
| | | } |
| | | }); |
| | | }).catch(error => { |
| | | if (error.code === "1002") {} |
| | | // 处理错误响应 |
| | | console.error('请求失败:', error); |
| | | |
| | | }); |
| | | }, |
| | | getRechargList() { |
| | | |
| | | }, |
| | | // 生成支付签名的函数 |
| | | generatePaySign(params) { |
| | | const sortedKeys = Object.keys(params).sort(); |
| | | const stringToSign = sortedKeys.map(key => `${key}=${params[key]}`).join('&') + `&key=your-mch-key`; |
| | | return md5(stringToSign).toUpperCase(); |
| | | } |
| | | }) |
| | |
| | | </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> |
| | | <scroll-view class="list-container" scroll-y="true" scroll-x="false"> |
| | | <block wx:if="{{listData.length > 0}}" wx:for="{{listData}}" wx:key="index"> |
| | | <view class="list-item" wx:for="{{listData}}" wx:for-item="item" wx:for-index="index"> |
| | | <view class="list-item"> |
| | | <!-- <image class="item-img" src="/images/pipeline.svg" /> --> |
| | | <view class="item-time"> |
| | | <text class="item-text">消费金额:</text> |
| | |
| | | wx.hideLoading(); |
| | | // 处理错误响应 |
| | | console.error('请求失败:', error); |
| | | if (error.code === "1002") { |
| | | wx.showToast({ |
| | | title: '开阀失败', |
| | | icon: 'error', |
| | | duration: 3000 // 提示的持续时间,单位毫秒 |
| | | }) |
| | | } |
| | | this.setData({ |
| | | showErrorDialog: true, |
| | | errorData: error.msg |
| | | }) |
| | | }); |
| | | }, |
| | | |
| | |
| | | this.setData({ |
| | | showConfirm: false |
| | | }) |
| | | }, |
| | | closeErrorDialog() { |
| | | this.setData({ |
| | | showErrorDialog: false |
| | | }) |
| | | } |
| | | |
| | | }) |
| | |
| | | </scroll-view> |
| | | </view> |
| | | |
| | | <t-dialog class="t-dialog" visible="{{showConfirm}}" content="确认打开{{choseItem.intakeNum}}吗?" confirm-btn="{{ { content: '确认', variant: 'base', theme: 'danger' } }}" close-on-overlay-click="false" cancel-btn="取消" bind:confirm="confirmDialog" bind:cancel="closeDialog" /> |
| | | <t-dialog class="dialog" visible="{{showConfirm}}" content="确认打开{{choseItem.intakeNum}}吗?" confirm-btn="{{ { content: '确认', variant: 'base', theme: 'danger' } }}" close-on-overlay-click="false" cancel-btn="取消" bind:confirm="confirmDialog" bind:cancel="closeDialog" /> |
| | | |
| | | <t-dialog class="error-dialog" title="开阀错误" visible="{{showErrorDialog}}" content="{{errorData}}" confirm-btn="{{ confirmBtn }}" bind:confirm="closeErrorDialog" /> |
| | | </view> |
| | |
| | | flex-direction: column; |
| | | padding-bottom: 10rpx; /* 增加底部填充 */ |
| | | } |
| | | .t-dialog{ |
| | | .dialog{ |
| | | --td-dialog-content-font-size:40rpx; |
| | | --td-dialog-content-line-height:50rpx |
| | | } |
| | | |
| | | .error-dialog{ |
| | | --td-dialog-title-color:red; |
| | | --td-dialog-title-font-size:45rpx; |
| | | } |
| | |
| | | // pages/wxbind/wxbind.js |
| | | const app = getApp(); |
| | | const { |
| | | get, |
| | | post |
| | | } = require('../../api/request.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; |
| | | } |
| | | |
| | | // 在这里处理发送验证码的逻辑,可以调用后台接口实现 |
| | | // 以下是一个简单的示例,仅作参考 |
| | | wx.showToast({ |
| | | title: '验证码已发送', |
| | | icon: 'success', |
| | | duration: 2000, |
| | | }); |
| | | |
| | | this.postCode(); |
| | | this.setData({ |
| | | codeSent: true, |
| | | }); |
| | | |
| | | // 启动倒计时 |
| | | this.startCountdown(); |
| | | }, |
| | |
| | | url: '/pages/home/home' // 这里填写你想要跳转的 TabBar 页面路径 |
| | | }); |
| | | }, |
| | | //获取验证码 |
| | | postCode: function () { |
| | | post('/items', { name: 'New Item' }) |
| | | const params = { |
| | | url: 'https://44978f7456.imdo.co/wx/client/send_sms?phoneNumber=' + this.data.mobile |
| | | }; |
| | | post(params) |
| | | .then((data) => { |
| | | this.setData({ |
| | | items: [...this.data.items, data] |
| | | }); |
| | | wx.showToast({ |
| | | title: '验证码已发送', |
| | | icon: 'success', |
| | | duration: 2000, |
| | | }); |
| | | }) |
| | | .catch((error) => { |
| | | console.error('Failed to add item:', error); |
| | | }); |
| | | }, |
| | | |
| | | bind() { |
| | | this.wsLogin(); |
| | | }, |
| | | wsLogin(){ |
| | | wx.login({ |
| | | success: res => { |
| | | if (res.code) { |
| | | console.log('登录成功,获取到的code:', res.code); |
| | | // 发送 res.code 到后台服务器换取 openId, sessionKey, unionId |
| | | this.verify(res.code) |
| | | } else { |
| | | console.log('登录失败!' + res.errMsg); |
| | | } |
| | | } |
| | | }); |
| | | }, |
| | | //用户绑定 |
| | | verify(wxCode){ |
| | | const params = { |
| | | url: 'https://44978f7456.imdo.co/wx/client/verify', |
| | | data: { |
| | | phoneNumber: this.data.mobile, |
| | | securityCode: this.data.phoneCode, |
| | | code: wxCode |
| | | } |
| | | }; |
| | | post(params) |
| | | .then((data) => { |
| | | getApp().globalData.sessionId= data.content |
| | | this.setData({ |
| | | items: [...this.data.items, data] |
| | | }); |
| | | wx.showToast({ |
| | | title: '绑定成功', |
| | | icon: 'success', |
| | | duration: 2000, |
| | | }); |
| | | }) |
| | | .catch((error) => { |
| | | wx.showToast({ |
| | | title: error.msg, |
| | | icon: 'error', |
| | | duration: 3000, |
| | | }); |
| | | console.error('Failed to add item:', error); |
| | | }); |
| | | } |
| | | }) |
| | |
| | | "description": "项目私有配置文件。此文件中的内容将覆盖 project.config.json 中的相同字段。项目的改动优先同步到此文件中。详见文档:https://developers.weixin.qq.com/miniprogram/dev/devtools/projectconfig.html", |
| | | "projectname": "irrigate_user_ym", |
| | | "setting": { |
| | | "compileHotReLoad": true |
| | | "compileHotReLoad": true, |
| | | "urlCheck": false |
| | | } |
| | | } |
| | |
| | | //缓存工具类 |
| | | //保存数据 |
| | | const setItem = (key, data) => { |
| | | return new Promise((resolve, reject) => { |
| | | wx.setStorage({ |