| 1234567891011121314151617181920212223242526272829303132333435363738 |
- /**
- * 常用正则表达式替换方法
- *
- * @replaceSale 月销量,超过一万的加上'w+'
- */
- // 月销量,超过一万的加上'w+'
- export const replaceSale = (sale) => {
- return sale > 10000 ? sale.replace(/\d{4}$/, 'w+') : sale
- }
- // 对象key 排序
- export const objKeySort = (arys) => {
- var newkey = Object.keys(arys).sort();
- var newObj = {};
- for (var i = 0; i < newkey.length; i++) {
- newObj[newkey[i]] = arys[newkey[i]];
- }
- return JSON.stringify(newObj)
- }
- // 返回并刷新指定接口
- export const naviBackEmit = (fun) => {
- uni.$emit(fun);
- uni.navigateBack({delta:1});
- }
- export const formatDate = (v, type) => {
- var date = new Date(v);
- const Y = date.getFullYear();
- const M = (date.getMonth()+1)< 10 ? '0'+(date.getMonth()+1) : date.getMonth()+1;
- const D = date.getDate()< 10 ? '0'+date.getDate() : date.getDate();
- const h = date.getHours() < 10 ? '0'+date.getHours() : date.getHours();
- const m = date.getMinutes() < 10 ? '0'+date.getMinutes() : date.getMinutes();
- const s = date.getSeconds() < 10 ? '0'+date.getSeconds() : date.getSeconds();
- if (type == 'all') {
- return Y+'/'+M+'/'+D+' '+h+':'+m+':'+s;
- }
- return Y+'/'+M+'/'+D;
- }
|