7 changed files with 162 additions and 9 deletions
Split View
Diff Options
-
1app.json
-
139client/formate.wxs
-
2client/home/index.wxml
-
2client/workbench/index.wxml
-
18pages/login/index.js
-
2pages/login/index.wxml
-
7pages/process/index/index.js
@ -0,0 +1,139 @@ |
|||
function isEmpty(val) { |
|||
return typeof val === 'undefined' || val === '' || val === null |
|||
} |
|||
|
|||
function formatTime(time) { |
|||
if (isEmpty(time)) { |
|||
return '' |
|||
} |
|||
var minute = 60 * 1000 |
|||
var just = 3 * 60 * 1000 |
|||
var onehour = 60 * 60 * 1000 |
|||
var oneday = 24 * 60 * 60 * 1000 |
|||
time = time.replace(getRegExp('/\s/g', 'g'), '') |
|||
var datetime = getDate(time.trim()) |
|||
var gap = getDate().getTime() - datetime.getTime() |
|||
|
|||
if (gap > oneday) { |
|||
return time.substring(0, 10) |
|||
} else if (gap > onehour) { |
|||
return parseInt(gap / onehour) + '小时前' |
|||
} else if (gap > onehour) { |
|||
return parseInt(gap / onehour) + '小时前' |
|||
} else if (gap > just) { |
|||
return parseInt(gap / minute) + '分钟前' |
|||
} else { |
|||
return '刚刚更新' |
|||
} |
|||
} |
|||
|
|||
function formateDate(datetime) { |
|||
if (isEmpty(datetime)) { |
|||
return '' |
|||
} |
|||
var date = getDate(datetime.trim()) |
|||
var today = getDate() |
|||
var dayCode = 24 * 60 * 60 * 1000 |
|||
var week = '' |
|||
if (date.getTime() === today.getTime()) { |
|||
week = '(今天)' |
|||
} else if (date.getTime() === today.getTime() + dayCode) { |
|||
week = '(明天)' |
|||
} else if (date.getTime() === today.getTime() - dayCode) { |
|||
week = '(昨天)' |
|||
} else if (date.getTime() === today.getTime() + dayCode * 2) { |
|||
week = '(后天)' |
|||
} else { |
|||
week = ['(周日)', '(周一)', '(周二)', '(周三)', '(周四)', '(周五)', '(周六)'][date.getDay()] |
|||
} |
|||
if (isEmpty(week)) { |
|||
week = '' |
|||
} |
|||
return datetime + week |
|||
} |
|||
|
|||
function formateAmount(amount, fix) { |
|||
if (isEmpty(amount)) { |
|||
return '' |
|||
} |
|||
if(!fix){ |
|||
fix = 3 |
|||
} |
|||
return Number(amount).toFixed(fix) |
|||
} |
|||
|
|||
function formateWeight(weight) { |
|||
return (parseFloat(weight) / 1000).toFixed(1) |
|||
} |
|||
|
|||
function formatePrice(weight) { |
|||
return (parseFloat(weight) * 1000).toFixed(0) |
|||
} |
|||
|
|||
function maxWeight(fweight, sweight) { |
|||
if(fweight && sweight){ |
|||
if(fweight > sweight){ |
|||
return fweight |
|||
} |
|||
return sweight |
|||
} |
|||
if(sweight){ |
|||
return sweight |
|||
} |
|||
return '- -' |
|||
} |
|||
|
|||
function minWeight(fweight, sweight) { |
|||
if(fweight && sweight){ |
|||
if(fweight < sweight){ |
|||
return fweight |
|||
} |
|||
return sweight |
|||
} |
|||
if(fweight){ |
|||
return fweight |
|||
} |
|||
return '- -' |
|||
} |
|||
|
|||
function numberFormat (value) { |
|||
if (value || value == 0) { |
|||
return Number(value).toFixed(2) |
|||
} |
|||
return '' |
|||
} |
|||
|
|||
function substring(str, start, end){ |
|||
if(str){ |
|||
return str.substring(start, end) |
|||
} |
|||
return '' |
|||
} |
|||
|
|||
function formateDrice (value) { |
|||
if (value || value == 0) { |
|||
return (parseFloat(value) * 1000).toFixed(0) |
|||
} |
|||
return '- -' |
|||
} |
|||
|
|||
function formateDescripe (value) { |
|||
if (typeof(value) == 'number') { |
|||
return value + '%' |
|||
} |
|||
return '- -' |
|||
} |
|||
|
|||
module.exports = { |
|||
numberFormat: numberFormat, |
|||
formateAmount: formateAmount, |
|||
formatePrice: formatePrice, |
|||
formateWeight: formateWeight, |
|||
formatTime: formatTime, |
|||
formateDate: formateDate, |
|||
maxWeight: maxWeight, |
|||
minWeight: minWeight, |
|||
substring: substring, |
|||
formateDescripe: formateDescripe, |
|||
formateDrice: formateDrice |
|||
} |
|||
Write
Preview
Loading…
Cancel
Save