You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
|
|
|
export default {
|
|
|
|
// 路由跳转
|
|
|
|
to(url) {
|
|
|
|
uni.navigateTo({
|
|
|
|
url
|
|
|
|
})
|
|
|
|
},
|
|
|
|
// 成功提示
|
|
|
|
sucMsg(title) {
|
|
|
|
uni.showToast({
|
|
|
|
title
|
|
|
|
})
|
|
|
|
},
|
|
|
|
// 错误提示
|
|
|
|
errMsg(title) {
|
|
|
|
uni.showToast({
|
|
|
|
title,
|
|
|
|
icon: 'none'
|
|
|
|
})
|
|
|
|
},
|
|
|
|
// 如果非数字,则返回0
|
|
|
|
handleNaN(val) {
|
|
|
|
return isNaN(val) ? 0 : val
|
|
|
|
},
|
|
|
|
//返回格式化时间,传参例如:"yyyy-MM-dd hh:mm:ss"
|
|
|
|
formatDate(date, fmt = 'yyyy-MM-dd hh:mm:ss') {
|
|
|
|
var date = date ? date : new Date()
|
|
|
|
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
|
|
|
|
}
|
|
|
|
}
|