From 0352507b0ef01d25b3ef1f625ab99e44560a3aa9 Mon Sep 17 00:00:00 2001 From: xiaofajia <1665375861@qq.com> Date: Thu, 12 Dec 2024 18:51:08 +0800 Subject: [PATCH] =?UTF-8?q?=E7=AE=A1=E7=90=86=E7=AB=AF=E5=A2=9E=E5=8A=A0?= =?UTF-8?q?=E4=BB=BB=E5=8A=A1=E5=88=97=E8=A1=A899%?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .hbuilderx/launch.json | 4 + config.js | 3 +- pages.json | 7 + pages/index/TodayTable.vue | 282 +++++++++++++++++++++++++++++++++++++ pages/index/synthesis.vue | 8 +- utils/auth.js | 31 ++++ utils/utils.js | 23 +++ 7 files changed, 355 insertions(+), 3 deletions(-) create mode 100644 pages/index/TodayTable.vue create mode 100644 utils/utils.js diff --git a/.hbuilderx/launch.json b/.hbuilderx/launch.json index 81f13f4..ee5be77 100644 --- a/.hbuilderx/launch.json +++ b/.hbuilderx/launch.json @@ -2,6 +2,10 @@ // launchtype项可配置值为local或remote, local代表前端连本地云函数,remote代表前端连云端云函数 "version": "0.0", "configurations": [{ + "app-plus" : + { + "launchtype" : "local" + }, "default" : { "launchtype" : "local" diff --git a/config.js b/config.js index 90b7fd2..0705968 100644 --- a/config.js +++ b/config.js @@ -1,7 +1,8 @@ // 应用全局配置 module.exports = { // baseUrl: 'https://www.nuoyunr.com/admin-api', - baseUrl: 'http://127.0.0.1:48080/admin-api', + // baseUrl: 'http://127.0.0.1:48080/admin-api', + baseUrl: 'http://wcw8ax.natappfree.cc/admin-api', imagesUrl: 'http://www.nuoyunr.com/lananRsc', baseImageUrl: 'https://www.nuoyunr.com/minio', wsUrl: 'ws://127.0.0.1:48080', diff --git a/pages.json b/pages.json index 6d20e3b..4dd0086 100644 --- a/pages.json +++ b/pages.json @@ -380,6 +380,13 @@ "enablePullDownRefresh": true, "navigationStyle": "custom" } + }, + { + "path": "pages/index/TodayTable", + "style": { + "navigationBarTitleText": "当日订单", + "navigationStyle": "custom" + } } ], "globalStyle": { diff --git a/pages/index/TodayTable.vue b/pages/index/TodayTable.vue new file mode 100644 index 0000000..e116ebc --- /dev/null +++ b/pages/index/TodayTable.vue @@ -0,0 +1,282 @@ + + + + + diff --git a/pages/index/synthesis.vue b/pages/index/synthesis.vue index 3772639..c6f581f 100644 --- a/pages/index/synthesis.vue +++ b/pages/index/synthesis.vue @@ -21,7 +21,7 @@ - + 当日订单 {{threenum.todayOrderNum}} @@ -187,7 +187,6 @@ this.baseUrl = this.$baseUrl let times = new Date() this.timeday = this.timeWeekFormat(times) - }, onShow() { this.getAppointAndPickNum() @@ -200,6 +199,11 @@ tabBar, }, methods: { + ToToday(){ + uni.navigateTo({ + url: '/pages/index/TodayTable' + }) + }, goshowMenu() { uni.navigateTo({ url: '/pages/manage/manage' diff --git a/utils/auth.js b/utils/auth.js index 7191f87..4a583f1 100644 --- a/utils/auth.js +++ b/utils/auth.js @@ -29,3 +29,34 @@ export function hasRole(roleCode) { } return false } + +// 设置本地存储,并设置一个过期时间(单位为秒) +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 new file mode 100644 index 0000000..d0d4475 --- /dev/null +++ b/utils/utils.js @@ -0,0 +1,23 @@ +import request from "./request"; +import { + setStorageWithExpiry, + getStorageWithExpiry +} from './auth' + +export function getDictDataByType(type) { + let data = getStorageWithExpiry(type) + if (data === null || data === undefined) { + request({ + url: '/system/dict-data/type', + method: 'get', + params: {type: type} + }).then(res => { + setStorageWithExpiry(type, res.data, 3600) + return res.data + }).catch(() => { + console.log("出现了异常") + }) + } else { + return data + } +}