diff --git a/components/orderCard.vue b/components/orderCard.vue
index 03a5325..ca347ed 100644
--- a/components/orderCard.vue
+++ b/components/orderCard.vue
@@ -48,6 +48,10 @@
告知取车
+
+
+ 查看详情
+
@@ -88,6 +92,14 @@ export default {
url: '/pages-order/orderDetail/orderDetail?id=' + this.order.id
})
},
+ /**
+ * 查看详情
+ */
+ viewDetail() {
+ uni.navigateTo({
+ url: '/pages-order/orderDetail/orderDetail?id=' + this.order.id
+ })
+ },
/**
* 项目派工
*/
diff --git a/pages-home/home/home.vue b/pages-home/home/home.vue
index d6e1ac2..cb84110 100644
--- a/pages-home/home/home.vue
+++ b/pages-home/home/home.vue
@@ -132,7 +132,6 @@ export default {
}
this.orderList = []
this.getOrderList()
- getDictByCode("repair_tickets_status")
}
},
onShow() {
diff --git a/utils/auth.js b/utils/auth.js
index e17e8cc..c56e5bb 100644
--- a/utils/auth.js
+++ b/utils/auth.js
@@ -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; // 数据未过期,返回数据
+}
diff --git a/utils/utils.js b/utils/utils.js
index e79a992..4074893 100644
--- a/utils/utils.js
+++ b/utils/utils.js
@@ -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
}