增加设备保养

This commit is contained in:
2024-05-07 19:37:20 +08:00
parent 162ef0ef26
commit ef313b9399
18 changed files with 1116 additions and 257 deletions

View File

@ -1,5 +1,5 @@
import config from './envConfig.js';
import wf from './public.js'
import wf from './public.js';
const request = (url = '', data = {}, header = {
'Authorization': 'Bearer '+uni.getStorageSync('mes_token') ? 'Bearer '+uni.getStorageSync('mes_token') : '',
@ -61,13 +61,13 @@ const request = (url = '', data = {}, header = {
})
})
}
const postFuncLoading = (url = '', data = {}, header = {
const postFuncLoading = (url = '', data = {}, header = {
'Authorization': 'Bearer '+uni.getStorageSync('mes_token') ? 'Bearer '+uni.getStorageSync('mes_token') : '',
}) => {
uni.showLoading({
}) => {
uni.showLoading({
title: '加载中',
mask: true
})
})
return new Promise((resolve, reject) => {
uni.request({
url: config.dev.VITE_BASE_API + url, //接口地址:前缀+方法中传入的地址
@ -123,9 +123,34 @@ const request = (url = '', data = {}, header = {
}
})
})
}
}
const getOss = (url = '', data = {}, header = {
'content-type':'application/json; charset=UTF-8',
'Authorization':''
})=>{
return new Promise((resolve, reject) => {
uni.request({
url: config.dev.VITE_OSS_URL + url, //接口地址:前缀+方法中传入的地址
method: "POST",
dataType: "json",
data: data,
header: header,
success:(res)=>{
if(res.data.code == 200){
resolve(res.data);
}
},
fail:(err)=>{
reject(err);
}
})
})
}
export default {
request,
postFuncLoading
postFuncLoading,
getOss
};

View File

@ -2,11 +2,13 @@
const dev = {
ENV: "dev",
VITE_BASE_API: "https://api.dev.dwoodauto.com/mobile/v1",
VITE_OSS_URL: "https://cloud-wh-dev.dwood365.com/mobile/v1",
};
//正式环境
const pro = {
ENV: "pro",
VITE_BASE_API: "https://api.dev.dwoodauto.com",
VITE_OSS_URL: "https://wf-api.dwood168.com/wh-mobile/v1",
};
export default {
dev,

View File

@ -19,10 +19,34 @@ const toast = function(params){
// 0~9 对应小数转换
const numberToChineseLower = function(num) {
var chineseNums = ['零', '一', '二', '三', '四', '五', '六', '七', '八', '九'];
return num.toString().split('').map(function(digit) {
return chineseNums[parseInt(digit)];
}).join('');
const chineseMonths = {
'1': '一',
'2': '二',
'3': '',
'4': '四',
'5': '五',
'6': '六',
'7': '七',
'8': '八',
'9': '九',
'10': '十',
'11': '十一',
'12': '十二'
};
return chineseMonths[num] || '';
}
const getToday = function() {
let today = new Date();
let year = today.getFullYear();
let month = today.getMonth() + 1;
let day = today.getDate();
let formattedMonth = month < 10 ? '0' + month : month;
let formattedDay = day < 10 ? '0' + day : day;
// 返回格式化后的日期字符串,格式为 yyyy-mm-dd
return year + '-' + formattedMonth + '-' + formattedDay;
}
const getDatesOfWeek = function() {
@ -273,12 +297,116 @@ const getNextMonthWeekCount = function(date = null) {
return totalWeeks;
}
// 获取当前的日期
const getCurrentYearData = function() {
let today = new Date(); // 获取当前日期
let year = today.getFullYear(); // 获取年份
let yearData = []; // 存储当前年份的数据
// 循环遍历每个月份
for (let month = 0; month < 12; month++) {
let list = getCurrentMonthData(year,month+1);
let monthData = {
month: month + 1, // 月份从 1 开始
weeks: list, // 存储该月份的所有周数据
};
// 将该月份的数据添加到当前年份的数据中
yearData.push(monthData);
}
return yearData;
}
// 获取上一年的日期
const getPreviousYearData = function(date = null) {
let currentDate = new Date(date); // 获取指定日期或者当前日期
currentDate.setFullYear(currentDate.getFullYear() - 1); // 获取指定日期的上一年日期
let year = currentDate.getFullYear(); // 获取年份
let yearData = []; // 存储指定日期的上一年的数据
for (let month = 0; month < 12; month++) {
let list = getCurrentMonthData(year, month + 1);
let monthData = {
month: month + 1,
weeks: list,
};
yearData.push(monthData);
}
return yearData;
}
// 获取下一年的日期
const getNextYearData = function(date = null) {
let currentDate = new Date(date); // 获取指定日期或者当前日期
currentDate.setFullYear(currentDate.getFullYear() + 1); // 获取指定日期的上一年日期
let year = currentDate.getFullYear(); // 获取年份
let yearData = []; // 存储指定日期的上一年的数据
for (let month = 0; month < 12; month++) {
let list = getCurrentMonthData(year, month + 1);
let monthData = {
month: month + 1,
weeks: list,
};
yearData.push(monthData);
}
return yearData;
}
// 获取当前月的所有周
const getCurrentMonthData = function(year,month) {
const startDate = new Date(year, month - 1, 1);
const endDate = new Date(year, month, 0);
const startDateDayOfWeek = startDate.getDay(); // 获取本月第一天是周几
const totalDays = endDate.getDate(); // 获取本月总天数
let weeks = [];
let currentWeek = [];
let currentDate = new Date(startDate);
// 填充到本周开始
for (let i = 0; i < startDateDayOfWeek; i++) {
currentWeek.push(null);
}
while (currentDate <= endDate) {
let textMonth = month<10?'0'+month:month;
let textDate = currentDate.getDate()<10?'0'+currentDate.getDate():currentDate.getDate();
currentWeek.push({
date: year +'-'+ textMonth +'-'+ textDate,
name: ['一', '二', '三', '四', '五', '六','日'][currentDate.getDay()]
});
currentDate.setDate(currentDate.getDate() + 1);
// 当前周已满,开始新周
if (currentWeek.length === 7) {
weeks.push(currentWeek);
currentWeek = [];
}
}
// 处理最后不满一周的情况
if (currentWeek.length > 0) {
while (currentWeek.length < 7) {
currentWeek.push(null);
}
weeks.push(currentWeek);
}
return weeks;
}
export default {
setLoginData,
removeLoginData,
toast,
numberToChineseLower,
getToday,
getDatesOfWeek,
getPreviousWeekDatesWithDays,
getNextWeekDatesWithDays,
@ -286,5 +414,8 @@ export default {
getPreviousMonthGroupedByWeek,
getNextMonthGroupedByWeek,
getPreviousMonthWeekCount,
getNextMonthWeekCount,
getNextMonthWeekCount,
getCurrentYearData,
getPreviousYearData,
getNextYearData,
};