Files
supplier-dispatch-h5/src/utils/common.js

130 lines
3.5 KiB
JavaScript

const formatDate = date => {
let tempDate = new Date(date)
const year = tempDate.getFullYear()
const month = tempDate.getMonth() + 1
const day = tempDate.getDate()
return `${[year, month, day].map(formatNumber).join('-')}`
}
const formatDate1 = date => {
let value=date.replace(/\./g, '/')
let tempDate = new Date(value)
const year = tempDate.getFullYear()
const month = tempDate.getMonth() + 1
const day = tempDate.getDate()
return `${[year, month, day].map(formatNumber).join('/')}`
}
const formatNumber = n => {
n = n.toString()
return n[1] ? n : `0${n}`
}
const leftCopy = (obj, source) => {
let sourceKey = Object.keys(source)
if (obj && source) {
Object.keys(obj).forEach(key => {
if (sourceKey.includes(key)) {
obj[key] = source[key] == null ? '' : source[key]
}
})
}
}
const timeFormat=(data) =>{
const currentDate = new Date(data);
const year = currentDate.getFullYear();
const month = String(currentDate.getMonth() + 1).padStart(2, '0');
const day = String(currentDate.getDate()).padStart(2, '0');
const hours = String(currentDate.getHours()).padStart(2, '0');
const minutes = String(currentDate.getMinutes()).padStart(2, '0');
const seconds = String(currentDate.getSeconds()).padStart(2, '0');
const formattedDate = `${year}-${month}-${day} ${hours}:${minutes}:${seconds}`;
// console.log("formattedDate",formattedDate)
return formattedDate;
}
// 认证状态
const verifyStatus=(id)=> {
const ids = String(id)
const status = {
'0': 1, // 个人信息认证
'-1': 1, // 已注册
'7': 1, // 已发送待认证
'1': 2, // 驾照信息认证
'2': 3, // 车辆信息审核
'3': 4, // 银行卡信息审核
'4': 5, // 认证中
'8': 6, // 审核中
'11': 6, // 审核失败
'12': 6 // 审核成功
}
return status[ids]
}
// 认证状态 简易版
const verifyStatusSimple=(id)=> {
const ids = String(id)
const status = {
'0': 1, // 个人信息认证
'-1': 1, // 已注册
'7': 1, // 已发送待认证
'1': 3, // 驾照信息认证
'2': 3, // 车辆信息审核
'3': 4, // 银行卡信息审核
'4': 5, // 认证中
'8': 6, // 审核中
'11': 6, // 审核失败
'12': 6 // 审核成功
}
return status[ids]
}
// 认证状态
const tipString=(id)=> {
const ids = String(id)
const status = {
'0': { // 个人信息认证
tip: '认证待提交',
button: '待认证'
},
'1': { // 驾照信息认证
tip: '认证待提交',
button: '待认证'
},
'2': { // 车辆信息审核
tip: '认证待提交',
button: '待认证'
},
'3': { // 银行卡信息审核
tip: '认证待提交',
button: '待认证'
},
'4': { // 认证中
tip: '认证待提交',
button: '待认证'
},
'8': { // 审核中
tip: '认证审核中',
button: '审核中'
},
'11': { // 审核失败
tip: '认证审核失败',
button: '审核失败'
},
'12': { // 审核成功
tip: '认证审核成功',
button: '审核成功'
},
}
return status[ids]
}
module.exports = {
formatNumber,
formatDate,
leftCopy,
timeFormat,
formatDate1,
verifyStatus,
verifyStatusSimple,
tipString
}