'use strict'; const md5 = require('md5'); class Common { static sortDict(obj) { //dict按key排序 return Object.keys(obj).sort().reduce(function(result, key) { result[key] = obj[key]; return result; }, {}); } static sign(params, token) { //对参数做MD5签名 return md5( JSON.stringify(Common.sortDict(params)) + token ); } static isPhoneNumber(number) { return /^1[3-9][0-9]{9}$/i.test(number); } static isVerifyCode(code) { return /^[0-9]{4}$/i.test(code); } } exports.default = Common;