获取套餐逻辑修改
This commit is contained in:
parent
51cd769177
commit
bbca917e99
|
|
@ -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: '加载套餐中...',
|
||||
})
|
||||
|
|
|
|||
|
|
@ -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 || []
|
||||
|
|
|
|||
|
|
@ -124,8 +124,6 @@
|
|||
</view>
|
||||
</view>
|
||||
</view>
|
||||
|
||||
<!-- 底部导航已由系统tabBar处理 -->
|
||||
</view>
|
||||
</template>
|
||||
|
||||
|
|
@ -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)
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user