获取套餐逻辑修改
This commit is contained in:
parent
51cd769177
commit
8a2fed0609
|
|
@ -13,16 +13,32 @@ export function getDeviceTypes() {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 根据设备类型获取租赁套餐列表
|
* 根据设备id获取租赁套餐列表
|
||||||
* @param {string} typeId - 设备类型ID
|
* @param {string} typeId - 设备ids
|
||||||
* @returns {Promise} 返回租赁套餐列表数据
|
* @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({
|
return request({
|
||||||
url: '/app/suit/list',
|
url: '/app/suit/list',
|
||||||
method: 'GET',
|
method: 'GET',
|
||||||
params: {
|
params: {
|
||||||
typeId: typeId,
|
suitIds: suitIds,
|
||||||
},
|
},
|
||||||
loadingText: '加载套餐中...',
|
loadingText: '加载套餐中...',
|
||||||
})
|
})
|
||||||
|
|
|
||||||
|
|
@ -58,8 +58,7 @@ import RenewModal from '../../components/renew-modal/renew-modal.vue'
|
||||||
import { getNewAnnouncement } from '../../api/article/article.js'
|
import { getNewAnnouncement } from '../../api/article/article.js'
|
||||||
import { getBannerList } from '../../api/banner/banner.js'
|
import { getBannerList } from '../../api/banner/banner.js'
|
||||||
import { getDeviceList } from '../../api/device/device.js'
|
import { getDeviceList } from '../../api/device/device.js'
|
||||||
import { renewDevice, getPeriodPackages } from '../../api/lease/lease.js'
|
import { renewDevice, getPeriodPackages, getPeriodPackagesByTypeId } from '../../api/lease/lease.js'
|
||||||
import { sleep } from '../../uni_modules/uv-ui-tools/libs/function'
|
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
components: {
|
components: {
|
||||||
|
|
@ -209,7 +208,7 @@ export default {
|
||||||
powerStatus: device.powerStatus,
|
powerStatus: device.powerStatus,
|
||||||
iotExpireTime: device.iotExpireTime,
|
iotExpireTime: device.iotExpireTime,
|
||||||
// 保留原始数据用于API调用
|
// 保留原始数据用于API调用
|
||||||
typeId: device.typeId || device.deviceTypeId,
|
suitIds: device.suitIds || device.devicesuitIds,
|
||||||
originalData: device,
|
originalData: device,
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
@ -272,7 +271,8 @@ export default {
|
||||||
this.packageLoading = true
|
this.packageLoading = true
|
||||||
|
|
||||||
// 根据设备ID查询套餐
|
// 根据设备ID查询套餐
|
||||||
await this.fetchPackageList(equipment.id)
|
await this.fetchPackageList(this.selectedDevice.originalData.typeId)
|
||||||
|
console.log('设备类型id', this.selectedDevice.originalData.typeId)
|
||||||
this.showRenewModal = true
|
this.showRenewModal = true
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error('打开续费弹窗失败:', error)
|
console.error('打开续费弹窗失败:', error)
|
||||||
|
|
@ -286,18 +286,9 @@ export default {
|
||||||
// 获取套餐列表
|
// 获取套餐列表
|
||||||
async fetchPackageList(deviceId) {
|
async fetchPackageList(deviceId) {
|
||||||
try {
|
try {
|
||||||
// 根据设备ID获取设备类型ID
|
console.log('设备类型ID:', deviceId)
|
||||||
const device = this.equipmentList.find(d => d.id === deviceId)
|
|
||||||
if (!device) {
|
|
||||||
throw new Error('设备不存在')
|
|
||||||
}
|
|
||||||
|
|
||||||
// 使用设备的类型ID获取套餐
|
const response = await getPeriodPackagesByTypeId(deviceId)
|
||||||
const typeId =
|
|
||||||
device.typeId || device.originalData?.typeId || device.originalData?.deviceTypeId || '1'
|
|
||||||
console.log('设备类型ID:', typeId)
|
|
||||||
|
|
||||||
const response = await getPeriodPackages(typeId)
|
|
||||||
|
|
||||||
if (response.code === 200) {
|
if (response.code === 200) {
|
||||||
this.packageList = response.data || []
|
this.packageList = response.data || []
|
||||||
|
|
|
||||||
|
|
@ -124,8 +124,6 @@
|
||||||
</view>
|
</view>
|
||||||
</view>
|
</view>
|
||||||
</view>
|
</view>
|
||||||
|
|
||||||
<!-- 底部导航已由系统tabBar处理 -->
|
|
||||||
</view>
|
</view>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
|
|
@ -412,7 +410,7 @@ export default {
|
||||||
if (res.confirm) {
|
if (res.confirm) {
|
||||||
// 这里可以调用支付API
|
// 这里可以调用支付API
|
||||||
const response = await createLeaseOrder(this.formData)
|
const response = await createLeaseOrder(this.formData)
|
||||||
//"17318322273"
|
|
||||||
if (response.code === 200) {
|
if (response.code === 200) {
|
||||||
const data = response.data
|
const data = response.data
|
||||||
console.log(data)
|
console.log(data)
|
||||||
|
|
|
||||||
|
|
@ -18,18 +18,18 @@ import {
|
||||||
const ENV_CONFIG = {
|
const ENV_CONFIG = {
|
||||||
develop: {
|
develop: {
|
||||||
// 开发环境
|
// 开发环境
|
||||||
// baseUrl: 'http://192.168.2.13:4601',
|
// baseUrl: 'http://192.168.2.88:4601',
|
||||||
baseUrl: 'https://chu.chuangtewl.com/prod-api',
|
baseUrl: 'http://192.168.2.88:4601',
|
||||||
appId: 1,
|
appId: 1,
|
||||||
},
|
},
|
||||||
trial: {
|
trial: {
|
||||||
// 体验版
|
// 体验版
|
||||||
baseUrl: 'https://chu.chuangtewl.com/prod-api',
|
baseUrl: 'http://192.168.2.88:4601',
|
||||||
appId: 1,
|
appId: 1,
|
||||||
},
|
},
|
||||||
release: {
|
release: {
|
||||||
// 正式版
|
// 正式版
|
||||||
baseUrl: 'https://chu.chuangtewl.com/prod-api',
|
baseUrl: 'http://192.168.2.88:4601',
|
||||||
appId: 1,
|
appId: 1,
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user