From a023cdc3679a9ea35b5f5c3c9bf138d9db76767a Mon Sep 17 00:00:00 2001
From: WindowBird <13870814+windows-bird@user.noreply.gitee.com>
Date: Sat, 13 Sep 2025 08:35:13 +0800
Subject: [PATCH] =?UTF-8?q?=E5=B7=B2=E6=94=B9=E7=BB=AD=E7=A7=9F=E6=8E=A5?=
=?UTF-8?q?=E5=8F=A3?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
api/lease/lease.js | 20 ++++++++++++++++++--
components/renew-modal/renew-modal.vue | 11 ++---------
pages/index/index.vue | 14 ++++++++++----
3 files changed, 30 insertions(+), 15 deletions(-)
diff --git a/api/lease/lease.js b/api/lease/lease.js
index 8449d89..7c1a3ea 100644
--- a/api/lease/lease.js
+++ b/api/lease/lease.js
@@ -13,8 +13,8 @@ export function getDeviceTypes() {
}
/**
- * 根据设备id获取租赁套餐列表
- * @param {string} typeId - 设备ids
+ * 根据设备类型id获取租赁套餐列表
+ * @param {string} typeId - 设备类型id
* @returns {Promise} 返回租赁套餐列表数据
*/
export function getPeriodPackagesByTypeId(typeId) {
@@ -28,6 +28,22 @@ export function getPeriodPackagesByTypeId(typeId) {
})
}
+/**
+ * 根据设备id获取租赁套餐列表
+ * @param {string} devId - 设备id
+ * @returns {Promise} 返回租赁套餐列表数据
+ */
+export function getPeriodPackagesByDevId(devId) {
+ return request({
+ url: '/app/suit/listByDevId',
+ method: 'GET',
+ params: {
+ devId: devId,
+ },
+ loadingText: '加载套餐中...',
+ })
+}
+
/**
* 根据套餐ids获取租赁套餐列表
* @param {string} suitIds - 套餐ids
diff --git a/components/renew-modal/renew-modal.vue b/components/renew-modal/renew-modal.vue
index 9a95793..3715369 100644
--- a/components/renew-modal/renew-modal.vue
+++ b/components/renew-modal/renew-modal.vue
@@ -19,7 +19,7 @@
{{ getStatusText(device.status) }}
- 到期时间: {{ formatTime(device.endTime) }}
+ 到期时间: {{ uni.$uv.date(device.endTime) }}
@@ -45,7 +45,7 @@
>
{{ item.name || `套餐${index + 1}` }}
- {{ item.description || item.period || '暂无描述' }}
+
¥
@@ -147,13 +147,6 @@ export default {
}
return statusMap[status] || '未知状态'
},
-
- // 格式化时间
- formatTime(timeStr) {
- if (!timeStr) return ''
- const date = new Date(timeStr)
- return `${date.getFullYear()}-${String(date.getMonth() + 1).padStart(2, '0')}-${String(date.getDate()).padStart(2, '0')}`
- },
},
}
diff --git a/pages/index/index.vue b/pages/index/index.vue
index 5aae8e6..6d30733 100644
--- a/pages/index/index.vue
+++ b/pages/index/index.vue
@@ -58,7 +58,12 @@ import RenewModal from '../../components/renew-modal/renew-modal.vue'
import { getNewAnnouncement } from '../../api/article/article.js'
import { getBannerList } from '../../api/banner/banner.js'
import { getDeviceList } from '../../api/device/device.js'
-import { renewDevice, getPeriodPackages, getPeriodPackagesByTypeId } from '../../api/lease/lease.js'
+import {
+ renewDevice,
+ getPeriodPackages,
+ getPeriodPackagesByTypeId,
+ getPeriodPackagesByDevId,
+} from '../../api/lease/lease.js'
import { getIsRealName } from '../../api'
export default {
@@ -293,8 +298,9 @@ export default {
this.packageLoading = true
// 根据设备ID查询套餐
- await this.fetchPackageList(this.selectedDevice.originalData.typeId)
- console.log('设备类型id', this.selectedDevice.originalData.typeId)
+ console.log('设备信息originalData', this.selectedDevice.originalData)
+ await this.fetchPackageList(this.selectedDevice.originalData.id)
+ console.log('设备id', this.selectedDevice.originalData.id)
this.showRenewModal = true
} catch (error) {
console.error('打开续费弹窗失败:', error)
@@ -310,7 +316,7 @@ export default {
try {
console.log('设备类型ID:', deviceId)
- const response = await getPeriodPackagesByTypeId(deviceId)
+ const response = await getPeriodPackagesByDevId(deviceId)
if (response.code === 200) {
this.packageList = response.data || []