qingcheng-xiaochengxu/utils/util.js

52 lines
1.0 KiB
JavaScript

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}`
}
const formatPassword = (pwd , currentPwd) => {
if (pwd === '') {
wx.showToast({
title: '密码不能为空',
icon: 'error'
})
return;
}
if (pwd.length < 6) {
wx.showToast({
title: '密码不能小于6位',
icon: 'error'
})
return;
}
if (currentPwd === '') {
wx.showToast({
title: '请输入二次确认密码',
icon: 'error'
})
return;
}
if (currentPwd !== pwd) {
wx.showToast({
title: '两次密码不一致',
icon: 'error'
})
return;
}
}
module.exports = {
formatTime,
formatPassword
}