1
This commit is contained in:
parent
4d63d694f3
commit
bb59d93494
@ -1,8 +1,8 @@
|
||||
// 应用全局配置
|
||||
module.exports = {
|
||||
// baseUrl: 'https://www.nuoyunr.com',
|
||||
baseUrl: 'http://192.168.1.17:48080',
|
||||
// baseUrl: "http://localhost:48080",
|
||||
// baseUrl: 'http://192.168.1.17:48080',
|
||||
baseUrl: "http://192.168.1.4:48080",
|
||||
imagesUrl: 'http://shequ.0315e.com/static/images/pages/',
|
||||
baseImageUrl: 'https://www.nuoyunr.com/minio/',
|
||||
wsUrl: 'wss://www.nuoyunr.com',
|
||||
|
File diff suppressed because it is too large
Load Diff
BIN
static/icons/bottom.png
Normal file
BIN
static/icons/bottom.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 699 B |
BIN
static/icons/date.png
Normal file
BIN
static/icons/date.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 1.8 KiB |
BIN
static/icons/orderIng.png
Normal file
BIN
static/icons/orderIng.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 3.7 KiB |
@ -60,3 +60,34 @@ export function getJSONData(keyStr) {
|
||||
export function setJSONData(keyStr,dataObj) {
|
||||
return uni.setStorageSync(keyStr, JSON.stringify(dataObj))
|
||||
}
|
||||
|
||||
// 设置本地存储,并设置一个过期时间(单位为秒)
|
||||
export function setStorageWithExpiry(key, value, ttl) {
|
||||
const now = new Date();
|
||||
// 计算过期时间
|
||||
const item = {
|
||||
value: value,
|
||||
expiry: now.getTime() + ttl * 1000,
|
||||
};
|
||||
// 将数据对象转换为字符串存储
|
||||
uni.setStorageSync(key, JSON.stringify(item));
|
||||
}
|
||||
|
||||
// 获取本地存储的数据,检查是否过期
|
||||
export function getStorageWithExpiry(key) {
|
||||
// 从本地存储获取数据
|
||||
const itemStr = uni.getStorageSync(key);
|
||||
if (!itemStr) {
|
||||
return null; // 未找到数据
|
||||
}
|
||||
const item = JSON.parse(itemStr);
|
||||
const now = new Date();
|
||||
// 检查项目是否过期
|
||||
if (now.getTime() > item.expiry) {
|
||||
// 如果过期,从存储中移除该项
|
||||
uni.removeStorageSync(key);
|
||||
return null;
|
||||
}
|
||||
return item.value; // 数据未过期,返回数据
|
||||
}
|
||||
|
||||
|
135
utils/utils.js
135
utils/utils.js
@ -1,3 +1,9 @@
|
||||
import request from '@/utils/request';
|
||||
import {
|
||||
setStorageWithExpiry,
|
||||
getStorageWithExpiry
|
||||
} from '@/utils/auth'
|
||||
|
||||
function getWXStatusHeight() {
|
||||
// #ifdef MP-WEIXIN
|
||||
// 获取距上
|
||||
@ -22,6 +28,135 @@ function getWXStatusHeight() {
|
||||
// #endif
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据订单的状态获取订单的文字展示状态
|
||||
* @param ticketsStatus 订单状态
|
||||
* @param workStatus 维修工作状态
|
||||
*/
|
||||
function getOrderStatusText(ticketsStatus,workStatus){
|
||||
let str = "";
|
||||
if("04"==ticketsStatus){
|
||||
//待派工
|
||||
str = "待派工"
|
||||
}else if("05"==ticketsStatus){
|
||||
//维修中
|
||||
str = "维修中"
|
||||
}else if("01"==ticketsStatus){
|
||||
//待结算
|
||||
str = "待结算"
|
||||
}else if("06"==ticketsStatus){
|
||||
//挂单/记账
|
||||
str = "挂单/记账"
|
||||
}else if("02"==ticketsStatus){
|
||||
//已结账
|
||||
str = "已结账"
|
||||
}else if("03"==ticketsStatus){
|
||||
//已作废
|
||||
str = "已作废"
|
||||
}
|
||||
return str;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 查询字典可选值
|
||||
* @param dictCode
|
||||
*/
|
||||
function getDictByCode(dictCode){
|
||||
let dictArray = getStorageWithExpiry(dictCode);
|
||||
if(null==dictArray || undefined==dictArray){
|
||||
request({
|
||||
url: '/app-api/system/dict-data/type',
|
||||
method: 'get',
|
||||
tenantIdFlag:false,
|
||||
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
|
||||
*/
|
||||
async function getDictTextByCodeAndValue(dictCode,value){
|
||||
return new Promise((resolve, reject) => {
|
||||
let dictArray = getStorageWithExpiry(dictCode);
|
||||
console.log(dictCode, 'dictCode')
|
||||
console.log(value, 'value')
|
||||
if (null == dictArray || undefined == dictArray) {
|
||||
request({
|
||||
url: '/app-api/system/dict-data/type',
|
||||
method: 'get',
|
||||
tenantIdFlag: false,
|
||||
params: {type: dictCode}
|
||||
}).then((res) => {
|
||||
console.log(res, 98)
|
||||
console.log(res, 98)
|
||||
if (res.code == 200) {
|
||||
setStorageWithExpiry(dictCode, res.data, 3600)
|
||||
dictArray = res.data
|
||||
let dictObj = dictArray.find(item => item.value == value)
|
||||
console.log(dictObj, "dictObj")
|
||||
if (dictObj) {
|
||||
resolve(dictObj.label);
|
||||
// return dictObj.label
|
||||
} else {
|
||||
resolve("未知数据")
|
||||
}
|
||||
}
|
||||
})
|
||||
} else {
|
||||
let dictObj = dictArray.find(item => item.value == value)
|
||||
console.log(dictObj, "dictObj")
|
||||
if (dictObj) {
|
||||
resolve(dictObj.label);
|
||||
} else {
|
||||
resolve("未知数据")
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
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}`;
|
||||
}
|
||||
|
||||
function formatDate(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');
|
||||
// 组合成日期时间字符串
|
||||
return `${year}-${month}-${day}`;
|
||||
}
|
||||
|
||||
|
||||
|
||||
export {
|
||||
getWXStatusHeight,
|
||||
getOrderStatusText,
|
||||
getDictByCode,
|
||||
getDictTextByCodeAndValue,
|
||||
formatTimestamp,
|
||||
formatDate,
|
||||
}
|
Loading…
Reference in New Issue
Block a user