diff --git a/wuye-manager-uniapp/App.vue b/wuye-manager-uniapp/App.vue index 7dc69c1..b8969b1 100644 --- a/wuye-manager-uniapp/App.vue +++ b/wuye-manager-uniapp/App.vue @@ -74,6 +74,12 @@ export default { .overflow-auto { overflow: auto; } +.nodata { + color: #ccc; + text-align: center; + margin-top: 200rpx; + letter-spacing: 1rpx; +} /* 自定义导航栏专用 */ .custom-header { height: calc(var(--status-bar-height) + 88rpx); diff --git a/wuye-manager-uniapp/api/BaseUrl.js b/wuye-manager-uniapp/api/BaseUrl.js new file mode 100644 index 0000000..eeee3c9 --- /dev/null +++ b/wuye-manager-uniapp/api/BaseUrl.js @@ -0,0 +1,15 @@ +/** + * @Description: 抽离 公共基础地址 + * @Author: Zy + * @Date: 2026-05-18 15:36:10 + * @LastEditor: Zy + * @LastEditTime: 2026-05-18 15:36:21 + */ +let baseUrl = '' + +if (process.env.NODE_ENV === 'development') { + baseUrl = 'http://192.168.0.239:8080' // 开发环境 +} else { + baseUrl = 'http://192.168.0.239:8080' // 生产环境 +} +export default baseUrl; diff --git a/wuye-manager-uniapp/api/common.js b/wuye-manager-uniapp/api/common.js index 4ac9cf4..64261bb 100644 --- a/wuye-manager-uniapp/api/common.js +++ b/wuye-manager-uniapp/api/common.js @@ -3,9 +3,12 @@ * @Author: Zy * @Date: 2026-05-15 11:37:01 * @LastEditor: Zy - * @LastEditTime: 2026-05-15 17:02:25 + * @LastEditTime: 2026-05-19 16:32:46 */ -import request, { get, post } from './request.js' +import request, { + get, + post +} from './request.js' /** * @typedef EmployeeItem 员工信息项 @@ -61,8 +64,19 @@ export function getSystemUsers_employee(roleKey, keyword) { * @param {string} [keyword=''] - 搜索关键词(可选),房屋号/业主姓名 * @returns {Promise>} */ -export function getVillageHouseList_keyword(data, keyword) { +export function getVillageHouseList_keyword(data, searchValue = '') { return get( - `/manage/replace/sdb/village/house?pageSize=${data.pageSize}&pageNum=${data.pageNum}&keyword=${keyword}` + `/manage/replace/sdb/village/house?pageSize=${data.pageSize}&pageNum=${data.pageNum}&searchValue=${searchValue}` ) } + + + +/** + * @description: 管家端通用 文件上传 + * @param {FormData} file + * @return + */ +export function uploadFile(file) { + return post('/resource/oss/upload', file) +} diff --git a/wuye-manager-uniapp/api/complain.js b/wuye-manager-uniapp/api/complain.js index 1ddcf62..5b6690a 100644 --- a/wuye-manager-uniapp/api/complain.js +++ b/wuye-manager-uniapp/api/complain.js @@ -3,7 +3,7 @@ * @Author: Zy * @Date: 2026-05-15 08:50:47 * @LastEditor: Zy - * @LastEditTime: 2026-05-15 16:47:31 + * @LastEditTime: 2026-05-19 16:34:23 */ import request, { filterParams, diff --git a/wuye-manager-uniapp/api/insepction.js b/wuye-manager-uniapp/api/insepction.js new file mode 100644 index 0000000..a24b52b --- /dev/null +++ b/wuye-manager-uniapp/api/insepction.js @@ -0,0 +1,110 @@ +/** + * @Description: 巡检记录 API + * @Author: Zy + * @Date: 2026-05-16 15:43:07 + * @LastEditor: Zy + * @LastEditTime: 2026-05-19 16:25:14 + */ + +import request, { + filterParams, + get, + put, + post +} from "./request.js"; + + + +/** + * @typedef PointsType 巡检任务表 + * @property {string} id = [巡检点ID] + * @property {string[]} itemNames = [巡检项目名称] + * @property {string[]} itemIds = [巡检项目ID] + * @property {string} pointName = [巡检点名称] + * */ +/** + * @typedef InspectionListType 巡检任务表 + * @property {string} id = [巡检任务ID] + * + * @property {0|1} inspectSetting = [0必须拍照, 1允许跳检] + * @property {string} inspectorName = [巡检人员] + * @property {string} phoneNumber = [巡检人员 联系方式] + * @property {string} inspectTime = [巡检时间] + * + * @property {string} taskName = [巡检任务名称] + * @property {string} taskTime = [巡检任务执行时间] + * @property {string} taskStatus = [巡检状态] + * @property {string} planName = [巡检计划] + * @property {string} executeDate = [巡检日期] + * @property {PointsType[]} points = [巡检点] + * @property {string[]} [itemslist] = [巡检项目] + * */ +/** + * @description: 获取巡检任务列表 + * @param { RequestParams<{ date?:string }> } data + * @return { Promise> } + */ +export const getInspectionList = (data) => { + return get('/api/inspection/today/list', filterParams(data)) +} + + +/** + * @typedef PointType 巡检点 信息 + * @property {string} imgUrl = [0必须拍照, 1允许跳检] + * @property {string} itemNames = [巡检人员] + * @property {string} itemStandards = [巡检人员 联系方式] + * @property {string} pointId = [巡检时间] + * @property {string} pointName = [巡检点名称] + * @property {string} remark = [巡检描述] + * @property { 0 | 1 } status = [巡检点状态 ] + * */ +/** + * @typedef RoutesType 巡检路线 信息 + * @property {string} inspectSetting = [0必须拍照, 1允许跳检] + * @property {string} description = [巡检人员] + * @property {string} routeId = [巡检人员 联系方式] + * @property {string} routeName = [巡检时间] + * @property {PointType[]} points = [巡检计划] + * */ +/** + * @typedef InspectionMainType 巡检任务详情 + * @property {0|1} inspectSetting = [0必须拍照, 1允许跳检] + * @property {string} inspectorName = [巡检人员] + * @property {string} villageName = [巡检小区] + * @property {string} phoneNumber = [巡检人员 联系方式] + * @property {string} inspectTime = [巡检时间] + * @property {string} planName = [巡检计划] + * @property {string} remindTime = [提醒时间] + * @property {string} taskId = [巡检任务ID] + * @property {string} taskName = [巡检任务名称] + * @property {string} taskTime = [巡检任务执行时间] + * @property {RoutesType[]} routes = [巡检路线信息] + * */ +/** + * @description: 获取 巡检任务详情 + * @param {string} id + * @return {Promise>} + */ +export const getInspectionMain = (id) => { + return get('/api/inspection/today/detail', { + taskId: id + }) +} + + +/** + * @typedef inspectionPointParams 巡检任务表 + * @property {string} pointId = [巡检点ID] + * @property {string} imgUrl = [巡检点,图片上传] + * @property {string} remark = [巡检点 巡检描述] + * @property {string} taskId = [巡检任务ID] + * @property {number} status = [巡检点状态] 0正常1异常 + * */ +/** + * @description: 巡检点上传 + * @param {inspectionPointParams} data + */ +export const putInsepctionPoint = (data) => { + return post('/api/inspection/today/pointImg', data) +} diff --git a/wuye-manager-uniapp/api/instrument.js b/wuye-manager-uniapp/api/instrument.js index 8529763..e143d3b 100644 --- a/wuye-manager-uniapp/api/instrument.js +++ b/wuye-manager-uniapp/api/instrument.js @@ -1,4 +1,50 @@ +/** + * @Description: 仪表换新API + * @Author: Zy + * @Date: 2026-05-16 15:53:23 + * @LastEditor: Zy + * @LastEditTime: 2026-05-16 16:38:54 + */ import request, { + filterParams, get, - post + post, + put } from "./request.js" + + +/** + * 设备类型枚举 + * @typedef {1 | 2} DeviceType + * @description 1=水表 2=电表 + */ +/** + * @typedef ReplaceMentRecordList 巡检任务表 + * @property {string} deviceCode = [设备编号] + * @property {DeviceType} deviceType = [设备类型] + * @property {string} houseId = [楼栋ID] + * @property {string} buildingName = [楼栋名称] + * @property {string} unitNo = [单元号] + * @property {string} houseNo = [房屋号] + * @property {string} addressCn = [房屋地址] + * @property {string} addressHyphen = [房屋地址] + * @property {string} createTime = [创建时间] + * */ + +/** + * 获取仪表换新记录 + * @param {RequestParams} data 请求参数 + * @return {Promise>} + */ +export const getReplaceMainList = (data) => { + return get('/manage/replace/sdb/record/list', filterParams(data)) +} + + +/** + * @description: 添加仪表API + * @param {{ deviceType:DeviceType, deviceCode:string,houseId:string }} data + */ +export const AddReplaceMainList = (data) => { + return put('/manage/replace/sdb/replace/device', filterParams(data)) +} diff --git a/wuye-manager-uniapp/api/request.js b/wuye-manager-uniapp/api/request.js index 7ae9447..40906da 100644 --- a/wuye-manager-uniapp/api/request.js +++ b/wuye-manager-uniapp/api/request.js @@ -1,9 +1,4 @@ -let baseUrl = '' -if (process.env.NODE_ENV === 'development') { - baseUrl = 'http://192.168.0.239:8080' // 开发环境 -} else { - baseUrl = 'http://192.168.0.239:8080' // 生产环境 -} +import baseUrl from './BaseUrl.js' export default function request(url, data = {}, method = 'GET') { return new Promise((resolve, reject) => { diff --git a/wuye-manager-uniapp/api/ticket.js b/wuye-manager-uniapp/api/ticket.js new file mode 100644 index 0000000..a099204 --- /dev/null +++ b/wuye-manager-uniapp/api/ticket.js @@ -0,0 +1,106 @@ +/** + * @Description: 工单API + * @Author: Zy + * @Date: 2026-05-19 16:29:20 + * @LastEditor: Zy + * @LastEditTime: 2026-05-20 08:36:23 + */ +import request, { + get, + filterParams, + post, + put, +} from './request.js' + + + +/** + * @typedef myOrderListType 个人维修工单列表 + * @property {String} id = [工单ID] + * @property {String} houseId = [维修房屋ID] + * @property {String} maintenanceItemId = [维修项目ID] + * @property {String} maintenanceItemName = [维修项目名称] + * @property {String} problem = [报修描述] + * @property {String} residentId = [报修用户ID] + * @property {String} residentName = [报修用户名称] + * @property {String} phone = [报修用户 联系方式] + * @property {String} orderDate = [工单日期] + * @property {String} problemImageUrl = [报修图片] + * @property {String} problemStatus = [报修状态] + * @property {String} repairDes = [维修描述] + * @property {String} repairImageUrl = [维修描述] + * @property {String} repairId = [维修ID] + * @property {String} repairName = [维修人员名称] + * @property {String} houseName = [维修房屋地址] + * @property {String} item = [] + * @property {String} projectType = [报修项目类型] + * @property {String} projectTypeStr = [报修 项目 名称] + * @property {String} repairIsCheck = [维修人员 已读] + * @property {String} manageIsCheck = [管理人员 已读] + * @property {String} isCheckStr = [状态已读] + */ +/** + * @description: 获取我的维修工单 + * @param {RequestParams<{ + itemType?: 0 | 1 + problemStatus:1|2 + }>} data + * @return { Promise>} + */ +export function getUserTicketlist(data) { + return get(`/manage/repair/order/myorderlist`, filterParams(data)) +} + + + +/** + * @typedef TicketMainInfoTyp 维修工单信息 + * @property {String} id = [工单ID] + * @property {String} houseId = [维修房屋ID] + * @property {String} houseName = [维修房屋地址] + * @property {String} isCheckStr = [状态已读] + * @property {String} item = [标题] + * @property {String} maintenanceItemId = [维修项目ID] + * @property {String} maintenanceItemName = [维修项目名称] + * @property {String} manageIsCheck = [管理人员 已读] + * @property {String} orderDate = [工单日期] + * @property {String} phone = [报修用户 联系方式] + * @property {String} problem = [报修描述] + * @property {String} problemImageUrl = [报修图片] + * @property {String} problemStatus = [报修状态] + * @property {String} projectType = [报修项目类型] + * @property {String} projectTypeStr = [报修 项目 名称] + * @property {String} repairDes = [维修描述] + * @property {String} repairId = [维修ID] + * @property {String} repairImageUrl = [维修描述] + * @property {String} repairIsCheck = [维修人员 已读] + * @property {String} residentName = [报修用户名称] + * @property {String} residentId = [报修用户ID] + * @property {String} repairName = [维修人员名称] + */ +/** + * @description: 获取工单详细信息 by id + * @param {string} id + * @return { Promise>} + */ +export function getTicketMainById(id) { + return get('/manage/repair/order/orderdetail', { + id, + }) +} + + + +/** + * @typedef ticketComputedInfo 维修工单信息 + * @property {String} id = [工单ID] + * @property {String} repairDes = [维修房屋ID] + * @property {String} repairImageUrl = [维修房屋地址] + */ +/** + * @description: 维修工单完成 + * @param {ticketComputedInfo} data + */ +export function ticketComputed(data) { + return put('/manage/repair/order', filterParams(data)) +} diff --git a/wuye-manager-uniapp/components/filePicker/filePicker.vue b/wuye-manager-uniapp/components/filePicker/filePicker.vue index 1bae843..e185032 100644 --- a/wuye-manager-uniapp/components/filePicker/filePicker.vue +++ b/wuye-manager-uniapp/components/filePicker/filePicker.vue @@ -24,6 +24,7 @@ diff --git a/wuye-manager-uniapp/pageSubPack/inspection/toDays_inscpection.vue b/wuye-manager-uniapp/pageSubPack/inspection/toDays_inscpection.vue index 3984583..f7fa00c 100644 --- a/wuye-manager-uniapp/pageSubPack/inspection/toDays_inscpection.vue +++ b/wuye-manager-uniapp/pageSubPack/inspection/toDays_inscpection.vue @@ -3,41 +3,45 @@ - - + - {{ item.address }} + {{ item.taskName }} - 未巡检 + 未巡检 已巡检 - + {{ ite }} 巡检时间: - {{ item.time }} + {{ item.taskTime }} - - 巡检人: - {{ item.user }} - + + + 巡检人: + {{ item.inspectorName }} + + 去巡检 + + 暂无数据 + @@ -46,85 +50,104 @@ diff --git a/wuye-manager-uniapp/pageSubPack/instrument/addreplacement.vue b/wuye-manager-uniapp/pageSubPack/instrument/addreplacement.vue index 41f569f..8c6a119 100644 --- a/wuye-manager-uniapp/pageSubPack/instrument/addreplacement.vue +++ b/wuye-manager-uniapp/pageSubPack/instrument/addreplacement.vue @@ -2,7 +2,7 @@ - + @@ -14,7 +14,13 @@ :clearable="true" > - + @@ -42,19 +48,22 @@ diff --git a/wuye-manager-uniapp/pageSubPack/instrument/checkouthouse.vue b/wuye-manager-uniapp/pageSubPack/instrument/checkouthouse.vue index 9f6a877..8d9ef38 100644 --- a/wuye-manager-uniapp/pageSubPack/instrument/checkouthouse.vue +++ b/wuye-manager-uniapp/pageSubPack/instrument/checkouthouse.vue @@ -4,23 +4,25 @@ 请输入关键字进行搜索 - + + + 暂无数据 + @@ -54,18 +59,31 @@ import { getVillageHouseList_keyword } from '@/api/common.js' const Searching = ref(true) const queryParmas = ref({ - keyword: '', + searchValue: '', pageNum: 1, pageSize: 10 }) /** 点击时切换到input,并聚焦 */ function handleClick() { Searching.value = false + queryParmas.value.searchValue = '' } /** 判断 失去焦点时 切换回 view */ function handleInput() { - if (queryParmas.value.keyword.trim()) { + const value = queryParmas.value.searchValue.trim() + if (value) { + handleSearch() + } else if (value === '') { + queryParmas.value.searchValue = '' Searching.value = true + handleSearch() + } +} +function handleInputString() { + if (queryParmas.value.searchValue.trim() === '') { + queryParmas.value.searchValue = '' + Searching.value = true + handleSearch() } } @@ -102,13 +120,20 @@ function getlist() { title: '加载中', mask: true }) - getVillageHouseList_keyword(queryParmas.value, queryParmas.value.keyword) + getVillageHouseList_keyword(queryParmas.value, queryParmas.value.searchValue) .then(res => { // 追加数据(正确方式) searchlist.value = [...searchlist.value, ...res.rows] + total.value = res.total // 判断是否还有更多 hasMore.value = searchlist.value.length < total.value }) + .catch(() => { + uni.showToast({ + icon: 'error', + title: '网络异常' + }) + }) .finally(() => { isLoading.value = false uni.hideLoading() @@ -126,6 +151,7 @@ function resetList() { // Search function handleSearch() { + hasMore.value = true queryParmas.value.pageNum = 1 queryParmas.value.pageSize = 10 searchlist.value = [] @@ -211,6 +237,13 @@ function handleSelecthouse() { } } } + .noData { + text-align: center; + color: rgba(0, 0, 0, 0.26); + font-size: larger; + padding-top: 50rpx; + letter-spacing: 10rpx; + } .action_btn { width: 670rpx; diff --git a/wuye-manager-uniapp/pageSubPack/instrument/replacement_record.vue b/wuye-manager-uniapp/pageSubPack/instrument/replacement_record.vue index aba8bc4..beb3292 100644 --- a/wuye-manager-uniapp/pageSubPack/instrument/replacement_record.vue +++ b/wuye-manager-uniapp/pageSubPack/instrument/replacement_record.vue @@ -17,16 +17,16 @@ - {{ item.title }} + {{ item.addressCn }} - 换新时间时间:{{ item.time }} + 换新时间时间:{{ item.createTime }} - 电表 - 水表 + 电表 + 水表 @@ -42,7 +42,10 @@ diff --git a/wuye-manager-uniapp/pageSubPack/ticket/repairMain.vue b/wuye-manager-uniapp/pageSubPack/ticket/repairMain.vue index 7cbf2d5..61de733 100644 --- a/wuye-manager-uniapp/pageSubPack/ticket/repairMain.vue +++ b/wuye-manager-uniapp/pageSubPack/ticket/repairMain.vue @@ -16,12 +16,15 @@ {{ data.desc }} - 2026/08/01 10:30:35 + {{ + repairInfo.updateTime + }} + 保修信息 @@ -36,19 +39,19 @@ 维修项目 - {{ repairInfo.repairProject }} + {{ repairInfo.maintenanceItemName }} 标题 - {{ repairInfo.title }} + {{ repairInfo.item }} 问题描述 - {{ repairInfo.descrtion }} + {{ repairInfo.problem }} @@ -60,14 +63,14 @@ 报修时间 - {{ repairInfo.time }} + {{ repairInfo.createTime }} 问题照片 - + - + 维修信息 姓名 - {{ repairInfo.repairUser.name }} + {{ repairInfo.repairName }} 状态 - {{ repairInfo.repairUser.status }} + {{ repairInfo.repairStatus === 0 ? '正常' : '异常' }} 角色 - {{ repairInfo.repairUser.role }} + {{ repairInfo.repairRoleName }} 手机号 - {{ repairInfo.repairUser.phone }} + {{ repairInfo.repairPhone }} 问题描述 - {{ repairInfo.repairUser.descrtion }} + + {{ repairInfo.repairDes }} + 问题照片 - + @@ -131,78 +140,120 @@ @@ -241,12 +292,12 @@ function handleRepairCompluted() { } .subtitle { font-weight: 400; - font-size: 24rpx; + font-size: 22rpx; line-height: 40rpx; } .subtime { font-weight: 400; - font-size: 24rpx; + font-size: 22rpx; color: #999999; line-height: 40rpx; } @@ -317,7 +368,7 @@ function handleRepairCompluted() { font-size: 28rpx; color: #222222; line-height: 36rpx; - width: 45%; + width: 35%; } .value { flex: 1; diff --git a/wuye-manager-uniapp/pages.json b/wuye-manager-uniapp/pages.json index 210f4e2..f41dc0f 100644 --- a/wuye-manager-uniapp/pages.json +++ b/wuye-manager-uniapp/pages.json @@ -71,8 +71,8 @@ "path": "notice-list", "style": { "navigationBarTitleText": "通知公告", - "enablePullDownRefresh": true, - "onReachBottomDistance": 100 + "enablePullDownRefresh": true, + "onReachBottomDistance": 100 } } ] diff --git a/wuye-manager-uniapp/pages/index/index.vue b/wuye-manager-uniapp/pages/index/index.vue index c4057d5..13b0024 100644 --- a/wuye-manager-uniapp/pages/index/index.vue +++ b/wuye-manager-uniapp/pages/index/index.vue @@ -124,6 +124,7 @@ import { ref } from 'vue' import { onLoad, onUnload } from '@dcloudio/uni-app' import { getCurrentVillage,getTodayInspection,getNewNoticeData,getBannarList} from '../../api/api.js' + // 列表数据状态 const current = ref(0) const currentCommunity = ref('请选择小区') @@ -134,17 +135,16 @@ const pendingCount = ref(0) //待巡检 const InspectedCount = ref(0) //已巡检 const statusBarHeight = ref(uni.getSystemInfoSync().statusBarHeight || 0) - // =======方法======= // 跳转小区 const navigateToPage = () => { - const curVillageId = uni.getStorageSync('currentVillage') - let villageId = '' - if(curVillageId){ - try{ - villageId = JSON.parse(curVillageId).villageId || JSON.parse(curVillageId).id || '' - }catch(e){} - } + const curVillageId = uni.getStorageSync('currentVillage') + let villageId = '' + if (curVillageId) { + try { + villageId = JSON.parse(curVillageId).villageId || JSON.parse(curVillageId).id || '' + } catch (e) {} + } uni.navigateTo({ url: `/pageSubPack/notice-list/select-community?villageId=${villageId}` }) @@ -199,14 +199,16 @@ const goToReport = () => { } // 获取当前小区 const currentVillageData = () => { - getCurrentVillage().then(res => { - const data = res.data - if (data) { - currentCommunity.value = data.villageName - uni.setStorageSync('currentVillage', JSON.stringify(data)) - getNoticeData() - } - }).catch(() => {}) + getCurrentVillage() + .then(res => { + const data = res.data + if (data) { + currentCommunity.value = data.villageName + uni.setStorageSync('currentVillage', JSON.stringify(data)) + getNoticeData() + } + }) + .catch(() => {}) } // 获取今日巡检数据 const getInspectionData = () =>{ @@ -217,24 +219,28 @@ const getInspectionData = () =>{ pendingCount.value = res.data.unfinishedTasks InspectedCount.value = res.data.completedTasks }else{ - allCount.value = 0 + allCount.value = 0 pendingCount.value = 0 InspectedCount.value = 0 } + }else{ + uni.showToast({ title: res.msg || '获取失败', icon: 'none' }) } - }).catch(err =>{ - uni.showToast({title:err.msg || '获取失败',icon:'none'}) - }) + }).catch(err => { + uni.showToast({ title: err.msg || '获取失败', icon: 'none' }) + }) } // 获取消息通知 const getNoticeData = () => { - getNewNoticeData().then(res => { - if (res.code === 200 && res.data) { - noticeText.value = res.data.notice || '' - }else{ - noticeText.value = '暂无公告' - } - }).catch(() => {}) + getNewNoticeData() + .then(res => { + if (res.code === 200 && res.data) { + noticeText.value = res.data.notice || '' + } else { + noticeText.value = '暂无公告' + } + }) + .catch(() => {}) } // 获取bannar图 function getbannarData(){ @@ -380,7 +386,6 @@ const clickItem = index => { } .inspectionClass { - // margin-top: 20rpx; background: linear-gradient(to right, #7b87fa, #4d5dfa); border-radius: 16rpx; box-sizing: border-box; @@ -406,10 +411,10 @@ const clickItem = index => { margin-right: 16rpx; .notice-icon { - width: 48rpx; - height: 48rpx; - margin-right: 15rpx; - } + width: 48rpx; + height: 48rpx; + margin-right: 15rpx; + } .notice-line { width: 1rpx; diff --git a/wuye-manager-uniapp/utils/time.js b/wuye-manager-uniapp/utils/time.js new file mode 100644 index 0000000..1487c00 --- /dev/null +++ b/wuye-manager-uniapp/utils/time.js @@ -0,0 +1,46 @@ +/** + * 日期格式化 + */ +export function parseTime(time, pattern) { + if (arguments.length === 0 || !time) { + return null; + } + const format = pattern || '{y}-{m}-{d} {h}:{i}:{s}'; + let date; + if (typeof time === 'object') { + date = time; + } else { + if (typeof time === 'string' && /^[0-9]+$/.test(time)) { + time = parseInt(time); + } else if (typeof time === 'string') { + time = time + .replace(new RegExp(/-/gm), '/') + .replace('T', ' ') + .replace(new RegExp(/\.[\d]{3}/gm), ''); + } + if (typeof time === 'number' && time.toString().length === 10) { + time = time * 1000; + } + date = new Date(time); + } + const formatObj = { + y: date.getFullYear(), + m: date.getMonth() + 1, + d: date.getDate(), + h: date.getHours(), + i: date.getMinutes(), + s: date.getSeconds(), + a: date.getDay() + }; + return format.replace(/{(y|m|d|h|i|s|a)+}/g, (result, key) => { + let value = formatObj[key]; + // Note: getDay() returns 0 on Sunday + if (key === 'a') { + return ['日', '一', '二', '三', '四', '五', '六'][value]; + } + if (result.length > 0 && value < 10) { + value = '0' + value; + } + return value || 0; + }); +}