From 8a2fed06096e3811a4ed9bdf5e82ccd5144e3c3b Mon Sep 17 00:00:00 2001 From: WindowBird <13870814+windows-bird@user.noreply.gitee.com> Date: Mon, 8 Sep 2025 11:55:10 +0800 Subject: [PATCH] =?UTF-8?q?=E8=8E=B7=E5=8F=96=E5=A5=97=E9=A4=90=E9=80=BB?= =?UTF-8?q?=E8=BE=91=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- api/lease/lease.js | 24 ++++++++++++++++++++---- pages/index/index.vue | 21 ++++++--------------- pages/lease/lease.vue | 4 +--- utils/request.js | 8 ++++---- 4 files changed, 31 insertions(+), 26 deletions(-) diff --git a/api/lease/lease.js b/api/lease/lease.js index 0a4331a..197ca7c 100644 --- a/api/lease/lease.js +++ b/api/lease/lease.js @@ -13,16 +13,32 @@ export function getDeviceTypes() { } /** - * 根据设备类型获取租赁套餐列表 - * @param {string} typeId - 设备类型ID + * 根据设备id获取租赁套餐列表 + * @param {string} typeId - 设备ids * @returns {Promise} 返回租赁套餐列表数据 */ -export function getPeriodPackages(typeId) { +export function getPeriodPackagesByTypeId(typeId) { + return request({ + url: '/app/suit/listByType', + method: 'GET', + params: { + typeId: typeId, + }, + loadingText: '加载套餐中...', + }) +} + +/** + * 根据套餐ids获取租赁套餐列表 + * @param {string} suitIds - 套餐ids + * @returns {Promise} 返回租赁套餐列表数据 + */ +export function getPeriodPackages(suitIds) { return request({ url: '/app/suit/list', method: 'GET', params: { - typeId: typeId, + suitIds: suitIds, }, loadingText: '加载套餐中...', }) diff --git a/pages/index/index.vue b/pages/index/index.vue index b07bcb3..5f02f60 100644 --- a/pages/index/index.vue +++ b/pages/index/index.vue @@ -58,8 +58,7 @@ 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 } from '../../api/lease/lease.js' -import { sleep } from '../../uni_modules/uv-ui-tools/libs/function' +import { renewDevice, getPeriodPackages, getPeriodPackagesByTypeId } from '../../api/lease/lease.js' export default { components: { @@ -209,7 +208,7 @@ export default { powerStatus: device.powerStatus, iotExpireTime: device.iotExpireTime, // 保留原始数据用于API调用 - typeId: device.typeId || device.deviceTypeId, + suitIds: device.suitIds || device.devicesuitIds, originalData: device, } }) @@ -272,7 +271,8 @@ export default { this.packageLoading = true // 根据设备ID查询套餐 - await this.fetchPackageList(equipment.id) + await this.fetchPackageList(this.selectedDevice.originalData.typeId) + console.log('设备类型id', this.selectedDevice.originalData.typeId) this.showRenewModal = true } catch (error) { console.error('打开续费弹窗失败:', error) @@ -286,18 +286,9 @@ export default { // 获取套餐列表 async fetchPackageList(deviceId) { try { - // 根据设备ID获取设备类型ID - const device = this.equipmentList.find(d => d.id === deviceId) - if (!device) { - throw new Error('设备不存在') - } + console.log('设备类型ID:', deviceId) - // 使用设备的类型ID获取套餐 - const typeId = - device.typeId || device.originalData?.typeId || device.originalData?.deviceTypeId || '1' - console.log('设备类型ID:', typeId) - - const response = await getPeriodPackages(typeId) + const response = await getPeriodPackagesByTypeId(deviceId) if (response.code === 200) { this.packageList = response.data || [] diff --git a/pages/lease/lease.vue b/pages/lease/lease.vue index b92232f..e0ffd2b 100644 --- a/pages/lease/lease.vue +++ b/pages/lease/lease.vue @@ -124,8 +124,6 @@ - - @@ -412,7 +410,7 @@ export default { if (res.confirm) { // 这里可以调用支付API const response = await createLeaseOrder(this.formData) - //"17318322273" + if (response.code === 200) { const data = response.data console.log(data) diff --git a/utils/request.js b/utils/request.js index 04f7469..22fdbc7 100644 --- a/utils/request.js +++ b/utils/request.js @@ -18,18 +18,18 @@ import { const ENV_CONFIG = { develop: { // 开发环境 - // baseUrl: 'http://192.168.2.13:4601', - baseUrl: 'https://chu.chuangtewl.com/prod-api', + // baseUrl: 'http://192.168.2.88:4601', + baseUrl: 'http://192.168.2.88:4601', appId: 1, }, trial: { // 体验版 - baseUrl: 'https://chu.chuangtewl.com/prod-api', + baseUrl: 'http://192.168.2.88:4601', appId: 1, }, release: { // 正式版 - baseUrl: 'https://chu.chuangtewl.com/prod-api', + baseUrl: 'http://192.168.2.88:4601', appId: 1, }, }