2024-10-18 15:13:47 +08:00
|
|
|
import request from '@/utils/request';
|
2024-10-18 15:30:03 +08:00
|
|
|
import {
|
|
|
|
setStorageWithExpiry,
|
|
|
|
getStorageWithExpiry
|
|
|
|
} from '@/utils/auth'
|
2024-10-18 15:13:47 +08:00
|
|
|
|
2024-10-09 13:34:36 +08:00
|
|
|
function getWXStatusHeight() {
|
|
|
|
// #ifdef MP-WEIXIN
|
|
|
|
// 获取距上
|
|
|
|
const barTop = wx.getSystemInfoSync().statusBarHeight
|
|
|
|
// 获取胶囊按钮位置信息
|
|
|
|
const menuButtonInfo = wx.getMenuButtonBoundingClientRect()
|
|
|
|
// 获取导航栏高度
|
|
|
|
const barHeight = menuButtonInfo.height + (menuButtonInfo.top - barTop) * 2
|
|
|
|
let barWidth = menuButtonInfo.width
|
|
|
|
console.log('menuButtonInfo', menuButtonInfo)
|
|
|
|
let barLeftPosition = 375 - menuButtonInfo.right + menuButtonInfo.width
|
|
|
|
let menuButtonLeft = menuButtonInfo.left
|
|
|
|
let menuButtonRight = menuButtonInfo.right
|
|
|
|
return {
|
|
|
|
barHeight,
|
|
|
|
barTop,
|
|
|
|
barWidth,
|
|
|
|
barLeftPosition,
|
|
|
|
menuButtonLeft,
|
|
|
|
menuButtonRight
|
|
|
|
}
|
|
|
|
// #endif
|
|
|
|
}
|
|
|
|
|
2024-10-18 15:13:47 +08:00
|
|
|
/**
|
|
|
|
* 根据订单的状态获取订单的文字展示状态
|
2024-10-18 17:33:53 +08:00
|
|
|
* @param ticketsStatus 订单状态
|
|
|
|
* @param workStatus 维修工作状态
|
2024-10-18 15:13:47 +08:00
|
|
|
*/
|
2024-10-18 17:33:53 +08:00
|
|
|
function getOrderStatusText(ticketsStatus,workStatus){
|
2024-10-18 15:13:47 +08:00
|
|
|
let str = "";
|
2024-10-18 17:33:53 +08:00
|
|
|
if("04"==ticketsStatus){
|
2024-10-18 15:13:47 +08:00
|
|
|
//待派工
|
|
|
|
str = "待派工"
|
2024-10-18 17:33:53 +08:00
|
|
|
}else if("05"==ticketsStatus){
|
2024-10-18 15:13:47 +08:00
|
|
|
//维修中
|
|
|
|
str = "维修中"
|
2024-10-18 17:33:53 +08:00
|
|
|
}else if("01"==ticketsStatus){
|
2024-10-18 15:13:47 +08:00
|
|
|
//待结算
|
|
|
|
str = "待结算"
|
2024-10-18 17:33:53 +08:00
|
|
|
}else if("06"==ticketsStatus){
|
2024-10-18 15:13:47 +08:00
|
|
|
//挂单/记账
|
|
|
|
str = "挂单/记账"
|
2024-10-18 17:33:53 +08:00
|
|
|
}else if("02"==ticketsStatus){
|
2024-10-18 15:13:47 +08:00
|
|
|
//已结账
|
|
|
|
str = "已结账"
|
2024-10-18 17:33:53 +08:00
|
|
|
}else if("03"==ticketsStatus){
|
2024-10-18 15:13:47 +08:00
|
|
|
//已作废
|
|
|
|
str = "已作废"
|
|
|
|
}
|
|
|
|
return str;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* 查询字典可选值
|
|
|
|
* @param dictCode
|
|
|
|
*/
|
|
|
|
function getDictByCode(dictCode){
|
2024-10-18 15:30:03 +08:00
|
|
|
let dictArray = getStorageWithExpiry(dictCode);
|
|
|
|
if(null==dictArray){
|
|
|
|
request({
|
|
|
|
url: '/admin-api/system/dict-data/type',
|
|
|
|
method: 'get',
|
|
|
|
params:{type:dictCode}
|
|
|
|
}).then((res) => {
|
|
|
|
console.log(res)
|
|
|
|
if (res.code == 200) {
|
|
|
|
setStorageWithExpiry(dictCode,res.data,3600)
|
|
|
|
return res.data
|
|
|
|
}
|
|
|
|
})
|
|
|
|
}else{
|
|
|
|
return dictArray
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* 翻译字典
|
|
|
|
* @param dictCode
|
|
|
|
*/
|
|
|
|
function getDictTextByCodeAndValue(dictCode,value){
|
|
|
|
let dictArray = getStorageWithExpiry(dictCode);
|
|
|
|
if(null==dictArray){
|
2024-10-18 16:10:56 +08:00
|
|
|
dictArray = getDictByCode(dictCode)
|
2024-10-18 15:30:03 +08:00
|
|
|
}
|
2024-10-18 16:10:56 +08:00
|
|
|
let dictObj = dictArray.find(item=>item.value==value)
|
2024-10-18 15:30:03 +08:00
|
|
|
if(dictObj){
|
2024-10-18 16:10:56 +08:00
|
|
|
return dictObj.label
|
2024-10-18 15:30:03 +08:00
|
|
|
}else{
|
|
|
|
return "未知数据"
|
|
|
|
}
|
2024-10-18 15:13:47 +08:00
|
|
|
}
|
|
|
|
|
2024-10-17 18:05:11 +08:00
|
|
|
function formatTimestamp(timestamp) {
|
|
|
|
// 将时间戳转换为Date对象
|
|
|
|
const date = new Date(timestamp);
|
|
|
|
// 获取年月日时分秒
|
|
|
|
const year = date.getFullYear();
|
|
|
|
const month = (date.getMonth() + 1).toString().padStart(2, '0');
|
|
|
|
const day = date.getDate().toString().padStart(2, '0');
|
|
|
|
const hours = date.getHours().toString().padStart(2, '0');
|
|
|
|
const minutes = date.getMinutes().toString().padStart(2, '0');
|
|
|
|
const seconds = date.getSeconds().toString().padStart(2, '0');
|
|
|
|
// 组合成日期时间字符串
|
|
|
|
return `${year}-${month}-${day} ${hours}:${minutes}:${seconds}`;
|
|
|
|
}
|
|
|
|
|
2024-10-09 13:34:36 +08:00
|
|
|
export {
|
2024-10-18 15:13:47 +08:00
|
|
|
getWXStatusHeight,
|
|
|
|
formatTimestamp,
|
|
|
|
getOrderStatusText,
|
2024-10-18 15:30:03 +08:00
|
|
|
getDictByCode,
|
|
|
|
getDictTextByCodeAndValue
|
2024-10-17 18:05:11 +08:00
|
|
|
}
|