You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
91 lines
2.0 KiB
JavaScript
91 lines
2.0 KiB
JavaScript
9 months ago
|
const formatTime = date => {
|
||
|
const year = date.getFullYear()
|
||
|
const month = date.getMonth() + 1
|
||
|
const day = date.getDate()
|
||
|
const hour = date.getHours()
|
||
|
const minute = date.getMinutes()
|
||
|
const second = date.getSeconds()
|
||
|
|
||
|
return [year, month, day].map(formatNumber).join('/') + ' ' + [hour, minute, second].map(formatNumber).join(':')
|
||
|
}
|
||
|
|
||
|
const formatNumber = n => {
|
||
|
n = n.toString()
|
||
|
return n[1] ? n : '0' + n
|
||
|
}
|
||
|
|
||
|
function formatTimeV(date, fmt) {
|
||
|
var o = {
|
||
|
"M+": date.getMonth() + 1, // 月份
|
||
|
"d+": date.getDate(), // 日
|
||
|
"h+": date.getHours(), // 小时
|
||
|
"m+": date.getMinutes(), // 分
|
||
|
"s+": date.getSeconds(), // 秒
|
||
|
"q+": Math.floor((date.getMonth() + 3) / 3), // 季度
|
||
|
"S": date.getMilliseconds()
|
||
|
// 毫秒
|
||
|
};
|
||
|
if (/(y+)/.test(fmt))
|
||
|
fmt = fmt.replace(RegExp.$1, (date.getFullYear() + "").substr(4 - RegExp.$1.length));
|
||
|
for (var k in o)
|
||
|
if (new RegExp("(" + k + ")").test(fmt))
|
||
|
fmt = fmt.replace(RegExp.$1, (RegExp.$1.length == 1) ? (o[k]) : (("00" + o[k]).substr(("" + o[k]).length)));
|
||
|
return fmt;
|
||
|
}
|
||
|
|
||
|
function setNavTitle4Color(title, color,bgColor) {
|
||
|
var bc = '#000000';
|
||
|
if (bgColor){
|
||
|
bc = bgColor;
|
||
|
}
|
||
|
wx.setNavigationBarColor({
|
||
|
frontColor: bc,
|
||
|
backgroundColor: color,
|
||
|
})
|
||
|
wx.setNavigationBarTitle({
|
||
|
title: title
|
||
|
})
|
||
|
}
|
||
|
|
||
|
function showFailureMsg(error) {
|
||
|
var title = "系统繁忙!!!";
|
||
|
if (error.errMessage) {
|
||
|
title = error.errMessage
|
||
|
} else
|
||
|
if (error.message) {
|
||
|
title = error.message
|
||
|
}
|
||
|
wx.showToast({
|
||
|
title: title,
|
||
|
icon: "none"
|
||
|
})
|
||
|
}
|
||
|
|
||
|
function showSuccessMsg(msg) {
|
||
|
var title = "操作成功";
|
||
|
if (msg){
|
||
|
title = msg;
|
||
|
}
|
||
|
wx.showToast({
|
||
|
title: title
|
||
|
})
|
||
|
}
|
||
|
function showWaring(msg) {
|
||
|
var title = "警告";
|
||
|
if (msg) {
|
||
|
title = msg;
|
||
|
}
|
||
|
wx.showToast({
|
||
|
title: title,
|
||
|
icon: "none"
|
||
|
})
|
||
|
}
|
||
|
|
||
|
module.exports = {
|
||
|
formatTime: formatTime,
|
||
|
formatTimeV: formatTimeV,
|
||
|
setNavTitle4Color: setNavTitle4Color,
|
||
|
showFailureMsg: showFailureMsg,
|
||
|
showSuccessMsg: showSuccessMsg,
|
||
|
showWaring: showWaring
|
||
|
}
|