export function dateFormat(fmt, date) { let ret; const opt = { "Y+": date.getFullYear().toString(), // 年 "m+": (date.getMonth() + 1).toString(), // 月 "d+": date.getDate().toString(), // 日 "H+": date.getHours().toString(), // 时 "M+": date.getMinutes().toString(), // 分 "S+": date.getSeconds().toString() // 秒 // 有其他格式化字符需求可以继续添加,必须转化成字符串 }; for (let k in opt) { ret = new RegExp("(" + k + ")").exec(fmt); if (ret) { fmt = fmt.replace(ret[1], (ret[1].length == 1) ? (opt[k]) : (opt[k].padStart(ret[1].length, "0"))) }; }; return fmt; } export function MatchVersion(oldVersion,newVersion){ var old = oldVersion.split('.'); var newV = newVersion.split('.'); // console.log(old); // console.log(newV) if(parseInt(old[0])< parseInt(newV[0])){ return true; } if(parseInt(old[1])< parseInt(newV[1])){ return true; } if(parseInt(old[2])< parseInt(newV[2])){ return true; } return false; } //中国标准时间---》日期 export function msToDate (dates) {     const datetime = new Date(dates);     const year = datetime.getFullYear();     const month = datetime.getMonth();     const date = datetime.getDate();     const hour = datetime.getHours();     const minute = datetime.getMinutes();     const second = datetime.getSeconds();     const result1 = year +                  '-' +                  ((month + 1) >= 10 ? (month + 1) : '0' + (month + 1)) +                  '-' +                  ((date + 1) < 10 ? '0' + date : date) +                  ' ' +                  ((hour + 1) < 10 ? '0' + hour : hour) +                  ':' +                  ((minute + 1) < 10 ? '0' + minute : minute) +                  ':' +                  ((second + 1) < 10 ? '0' + second : second);     const result2 = year +                  '-' +                  ((month + 1) >= 10 ? (month + 1) : '0' + (month + 1)) +                  '-' +                  ((date + 1) < 10 ? '0' + date : date);     const result = {         hasTime: result1,         withoutTime: result2     };     return result; } //去除数字0 export function removeZeros(number) { // 去除数字后面为0 // return number.toString().replace(/\.?0*$/, ''); // 去除数字后面2个0 return number.toString().replace(/00$/, ''); } function arrIndexOf(arr, id) { if(arr.indexOf(id) != -1){ return true; } else { return false; } } export function menuLimit(id){ // 从本地缓存中异步获取menuArray的内容 let arr = uni.getStorageSync('menuArray'); console.log(id) return arrIndexOf(arr, id); }