This commit is contained in:
Vinjor 2024-10-18 15:30:03 +08:00
parent 92a46a6b30
commit 15fa8c27ce
4 changed files with 80 additions and 12 deletions

View File

@ -48,6 +48,10 @@
<view @click="gotoDetail" v-else-if="order.ticketsStatus == '06'" class="btn qc">
告知取车
</view>
<view @click="gotoDetail" v-else class="btn pg">
<!-- 在什么都不能操作的情况下可以查看详情-->
查看详情
</view>
</view>
</view>
</view>
@ -87,6 +91,14 @@ export default {
uni.navigateTo({
url: '/pages-order/orderDetail/orderDetail?id=' + this.order.id
})
},
/**
* 查看详情
*/
viewDetail() {
uni.navigateTo({
url: '/pages-order/orderDetail/orderDetail?id=' + this.order.id
})
}
}
}

View File

@ -132,7 +132,6 @@ export default {
}
this.orderList = []
this.getOrderList()
getDictByCode("repair_tickets_status")
}
},
onShow() {

View File

@ -77,3 +77,32 @@ export function removeStrData(keyStr) {
return uni.removeStorageSync(keyStr)
}
// 设置本地存储,并设置一个过期时间(单位为秒)
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; // 数据未过期,返回数据
}

View File

@ -1,4 +1,8 @@
import request from '@/utils/request';
import {
setStorageWithExpiry,
getStorageWithExpiry
} from '@/utils/auth'
function getWXStatusHeight() {
// #ifdef MP-WEIXIN
@ -57,16 +61,39 @@ function getOrderStatusText(orderInfo){
* @param dictCode
*/
function getDictByCode(dictCode){
request({
url: '/admin-api/system/dict-data/type',
method: 'get',
params:{type:dictCode}
}).then((res) => {
console.log(res)
if (res.code == 200) {
return res.data
}
})
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){
dictArray = this.getDictByCode(dictCode)
}
let dictObj = dictArray.find(item=>item.dictValue==value)
if(dictObj){
return dictObj.dictLabel
}else{
return "未知数据"
}
}
function formatTimestamp(timestamp) {
@ -87,5 +114,6 @@ export {
getWXStatusHeight,
formatTimestamp,
getOrderStatusText,
getDictByCode
getDictByCode,
getDictTextByCodeAndValue
}