From 0b6b6f6bbc4764ecb72f5f07cd37a63c697c20f4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=AE=B8=E5=85=81=E6=9E=9E?= <3422692813@qq.com> Date: Thu, 3 Apr 2025 16:47:39 +0800 Subject: [PATCH 1/3] =?UTF-8?q?=E6=9B=B4=E6=96=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../appointment/assets/style/index.rpx.scss | 1 - newPages/appointment/index.vue | 179 ++++++- newPages/appointmentAdd/index.vue | 473 ++++++++++-------- .../assets/style/index.rpx.scss | 5 +- newPages/appointmentDetail/index.vue | 164 ++++-- newPages/evaluate/index.vue | 41 +- newPages/evaluateAdd/index.vue | 164 ++++-- utils/auth.js | 30 ++ utils/request.js | 14 +- utils/utils.js | 59 +++ 10 files changed, 751 insertions(+), 379 deletions(-) create mode 100644 utils/utils.js diff --git a/newPages/appointment/assets/style/index.rpx.scss b/newPages/appointment/assets/style/index.rpx.scss index a4f182d..56402c7 100644 --- a/newPages/appointment/assets/style/index.rpx.scss +++ b/newPages/appointment/assets/style/index.rpx.scss @@ -92,7 +92,6 @@ .box_4 { background-color: rgba(255, 255, 255, 1); border-radius: 8px; - height: 242rpx; width: 686rpx; margin: 16rpx 0 0 32rpx; .group_5 { diff --git a/newPages/appointment/index.vue b/newPages/appointment/index.vue index 5377d3e..80e3a0a 100644 --- a/newPages/appointment/index.vue +++ b/newPages/appointment/index.vue @@ -1,16 +1,18 @@ @@ -125,10 +235,12 @@ export default { // 新增样式 .content-box { - margin-top: 88rpx; /* 根据头部高度调整 */ + margin-top: 88rpx; + /* 根据头部高度调整 */ padding: 20rpx; overflow-y: auto; - height: calc(100vh - 88rpx); /* 确保内容区域高度正确 */ + height: calc(100vh - 88rpx); + /* 确保内容区域高度正确 */ } .header { @@ -137,8 +249,31 @@ export default { box-sizing: border-box; padding-top: 88px; } -.bottom_{ + +.bottom_ { position: fixed; bottom: 0; } + +.ytg { + background-color: #cfe2ff; + border-radius: 4px; + height: 40rpx; + margin-top: 22rpx; + width: 96rpx; + + .text_5 { + width: 72rpx; + height: 24rpx; + overflow-wrap: break-word; + color: rgba(4, 78, 242, 1); + font-size: 24rpx; + font-family: PingFang SC-Regular; + font-weight: NaN; + text-align: left; + white-space: nowrap; + line-height: 24rpx; + margin: 8rpx 0 0 12rpx; + } +} diff --git a/newPages/appointmentAdd/index.vue b/newPages/appointmentAdd/index.vue index fce9f27..d35fa4a 100644 --- a/newPages/appointmentAdd/index.vue +++ b/newPages/appointmentAdd/index.vue @@ -1,213 +1,278 @@ diff --git a/newPages/appointmentDetail/assets/style/index.rpx.scss b/newPages/appointmentDetail/assets/style/index.rpx.scss index 9712ca6..acae042 100644 --- a/newPages/appointmentDetail/assets/style/index.rpx.scss +++ b/newPages/appointmentDetail/assets/style/index.rpx.scss @@ -91,7 +91,6 @@ background-color: rgba(255, 255, 255, 1); border-radius: 8px; width: 686rpx; - height: 834rpx; margin: 20rpx 0 0 32rpx; .section_4 { background-image: linear-gradient( @@ -256,8 +255,7 @@ } .text-wrapper_5 { width: 646rpx; - height: 28rpx; - margin: 100rpx 0 0 20rpx; + margin: 20rpx 0 0 20rpx; .text_12 { width: 168rpx; height: 28rpx; @@ -271,7 +269,6 @@ line-height: 28rpx; } .text_13 { - width: 56rpx; height: 28rpx; overflow-wrap: break-word; color: rgba(51, 51, 51, 1); diff --git a/newPages/appointmentDetail/index.vue b/newPages/appointmentDetail/index.vue index fdbe691..fa5d61a 100644 --- a/newPages/appointmentDetail/index.vue +++ b/newPages/appointmentDetail/index.vue @@ -1,99 +1,155 @@ diff --git a/newPages/evaluate/index.vue b/newPages/evaluate/index.vue index a8931ba..a20f939 100644 --- a/newPages/evaluate/index.vue +++ b/newPages/evaluate/index.vue @@ -1,41 +1,11 @@ diff --git a/utils/auth.js b/utils/auth.js index 76bbe18..8b53862 100644 --- a/utils/auth.js +++ b/utils/auth.js @@ -29,3 +29,33 @@ export function setLocalUserInfo(userinfo){ export function getLocalUserInfo() { return uni.getStorageSync(userInfo) } + +// 设置本地存储,并设置一个过期时间(单位为秒) +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/request.js b/utils/request.js index c72076d..50c8ed1 100644 --- a/utils/request.js +++ b/utils/request.js @@ -32,13 +32,13 @@ const request = config => { // 设置租户 const isTanantId = (config.headers || {}).isTanantId === false config.header = config.header || {} - if (!config.hasOwnProperty("tenantIdFlag")) { - //请求设置了不需要租户,不拼接,,走进这里的是没设置不需要租户的 - if (getTenantId() && !isTanantId) { - config.header['tenant-id'] = getTenantId() - } - config.header['tenant-id'] = 180 - } + // if (!config.hasOwnProperty("tenantIdFlag")) { + // //请求设置了不需要租户,不拼接,,走进这里的是没设置不需要租户的 + // if (getTenantId() && !isTanantId) { + // config.header['tenant-id'] = getTenantId() + // } + // config.header['tenant-id'] = 180 + // } console.log(config.header, 424242); return new Promise((resolve, reject) => { uni.request({ diff --git a/utils/utils.js b/utils/utils.js new file mode 100644 index 0000000..53833e5 --- /dev/null +++ b/utils/utils.js @@ -0,0 +1,59 @@ +import request from "./request"; +import { + setStorageWithExpiry, + getStorageWithExpiry +} from './auth' + +export async function getDictDataByType(type) { + let data = getStorageWithExpiry(type); + if (data === null || data === undefined) { + try { + const response = await request({ + url: '/app-api/system/dict-data/type', + method: 'get', + params: {type} + }); + data = response.data; + setStorageWithExpiry(type, data, 3600); // 存储数据并设置过期时间 + } catch (error) { + console.error("请求字典数据时出现了异常:", error); + throw error; // 确保错误能够被外部捕获 + } + } + return data; +} + +export 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 function formatDateChinese(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 function formatDateTimeToMinute(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'); + // 组合成日期时间字符串(格式:yyyy-MM-dd hh:mm) + return `${year}-${month}-${day} ${hours}:${minutes}`; +} + From fb65aee3d0b816dfee41cb6a558d71e2de6647e3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=AE=B8=E5=85=81=E6=9E=9E?= <3422692813@qq.com> Date: Thu, 3 Apr 2025 17:33:17 +0800 Subject: [PATCH 2/3] =?UTF-8?q?=E6=9B=B4=E6=96=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- newPages/appointmentAdd/index.vue | 1 + newPages/appointmentDetail/index.vue | 54 ++++++++++++++++++---------- 2 files changed, 37 insertions(+), 18 deletions(-) diff --git a/newPages/appointmentAdd/index.vue b/newPages/appointmentAdd/index.vue index d35fa4a..b110f29 100644 --- a/newPages/appointmentAdd/index.vue +++ b/newPages/appointmentAdd/index.vue @@ -249,6 +249,7 @@ duration: 2000 }) setTimeout(() => { + uni.$emit('refresh'); uni.navigateBack() }, 2000) }) diff --git a/newPages/appointmentDetail/index.vue b/newPages/appointmentDetail/index.vue index fa5d61a..fe379a0 100644 --- a/newPages/appointmentDetail/index.vue +++ b/newPages/appointmentDetail/index.vue @@ -37,7 +37,7 @@ 累计训练时长 - {{ appointmentInfo.allDriveTime }}分钟 + {{ appointmentInfo.allDriveTime }}分钟 训练地址 @@ -81,30 +81,48 @@ export default { console.log(this.appointmentInfo) if (options.type === 'train') { this.isTrain = true - }else { + } else { this.isTrain = false } console.log(this.isTrain) }, methods: { - getAllTrainTime() { - request({ - url: '/app-api/process/getAllByCourseId', - method: 'GET', - params: { - courseId: this.appointmentInfo.courseId - }, - tenantIdFlag: false - }).then(res => { - console.log('获取所有训练时间', res) - const data = res.data.find(item => {item.subject == this.appointmentInfo.subject}) - if (!data.allDriveTime) { - this.appointmentInfo.allDriveTime = data.allDriveTime - }else { - this.appointmentInfo.allDriveTime = '0' + async getAllTrainTime() { + try { + const res = await request({ + url: "/app-api/process/getAllByCourseId", + method: "GET", + params: { + courseId: this.appointmentInfo.courseId, + }, + tenantIdFlag: false, + }); + + console.log("获取所有训练时间", res); + console.log("当前科目:", this.appointmentInfo.subject); + + // 确保 appointmentInfo.subject 已有值 + if (!this.appointmentInfo.subject) { + console.warn("appointmentInfo.subject 为空,等待赋值..."); + await new Promise((resolve) => setTimeout(resolve, 100)); } - }) + const data = res.data.find( + (item) => item.subject == this.appointmentInfo.subject + ); + + console.log("匹配的训练时间数据:", data); + + this.appointmentInfo.allDriveTime = data ? data.trainTime || "0" : "0"; + + console.log( + "this.appointmentInfo.allDriveTime", + this.appointmentInfo.allDriveTime + ); + } catch (error) { + console.error("获取训练时间失败:", error); + } } + } }; From bf199e27374d82d6b6a0b14dbd4a4a14b113209d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=AE=B8=E5=85=81=E6=9E=9E?= <3422692813@qq.com> Date: Thu, 3 Apr 2025 18:08:29 +0800 Subject: [PATCH 3/3] =?UTF-8?q?=E6=9B=B4=E6=96=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- newPages/appointment/index.vue | 4 ++-- newPages/evaluate/index.vue | 26 ++++++++++++++++++++++++-- 2 files changed, 26 insertions(+), 4 deletions(-) diff --git a/newPages/appointment/index.vue b/newPages/appointment/index.vue index 80e3a0a..26f652a 100644 --- a/newPages/appointment/index.vue +++ b/newPages/appointment/index.vue @@ -12,7 +12,7 @@ refresher-enabled @refresherrefresh="onRefresherrefresh" :refresher-triggered="isTriggered"> - + {{ item.reservDay }} @@ -41,7 +41,7 @@ - + {{ item.trainDay }} diff --git a/newPages/evaluate/index.vue b/newPages/evaluate/index.vue index a20f939..0d8950d 100644 --- a/newPages/evaluate/index.vue +++ b/newPages/evaluate/index.vue @@ -46,6 +46,8 @@