增添续费时选择旧套餐
This commit is contained in:
parent
3ca6a20434
commit
fbd0b4d2f8
|
|
@ -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
|
||||
|
|
@ -84,12 +100,6 @@ export function renewDevice(data) {
|
|||
return request({
|
||||
url: '/app/order/renew',
|
||||
method: 'POST',
|
||||
data: {
|
||||
suitId: data.suitId,
|
||||
appId: data.appId,
|
||||
payAmount: data.payAmount,
|
||||
channelId: data.channelId,
|
||||
devId: data.devId,
|
||||
},
|
||||
data,
|
||||
})
|
||||
}
|
||||
|
|
|
|||
|
|
@ -35,9 +35,9 @@
|
|||
</view>
|
||||
|
||||
<!-- 套餐列表 -->
|
||||
<view v-else-if="packageList.length > 0" class="package-list">
|
||||
<view v-else-if="reconstructionPackageList.length > 0" class="package-list">
|
||||
<view
|
||||
v-for="(item, index) in packageList"
|
||||
v-for="(item, index) in reconstructionPackageList"
|
||||
:key="index"
|
||||
:class="{ active: selectedPackage && selectedPackage.id === item.id }"
|
||||
class="package-item"
|
||||
|
|
@ -87,8 +87,8 @@ export default {
|
|||
default: null,
|
||||
},
|
||||
packageList: {
|
||||
type: Array,
|
||||
default: () => [],
|
||||
type: Object,
|
||||
default: null,
|
||||
},
|
||||
loading: {
|
||||
type: Boolean,
|
||||
|
|
@ -108,6 +108,20 @@ export default {
|
|||
}
|
||||
},
|
||||
},
|
||||
computed: {
|
||||
reconstructionPackageList() {
|
||||
console.log('@@@', this.packageList)
|
||||
let list = this.packageList.list
|
||||
let oldItem = {
|
||||
amount: this.packageList.lastSuitAmount,
|
||||
name: this.packageList.lastSuitName + '(原套餐)',
|
||||
id: this.packageList.lastSuitId + 'a',
|
||||
}
|
||||
list = [oldItem, ...list]
|
||||
console.log('<UNK>', list)
|
||||
return list
|
||||
},
|
||||
},
|
||||
methods: {
|
||||
// 处理遮罩层点击
|
||||
handleOverlayClick() {
|
||||
|
|
|
|||
|
|
@ -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 {
|
||||
|
|
@ -70,7 +75,7 @@ export default {
|
|||
},
|
||||
data() {
|
||||
return {
|
||||
shihasExecuted: uni.getStorageSync('hasExecutedGoToRealName') || false,
|
||||
hasExecuted: uni.getStorageSync('hasExecutedGoToRealName') || false,
|
||||
|
||||
// 基础配置
|
||||
isRealName: false,
|
||||
|
|
@ -101,6 +106,7 @@ export default {
|
|||
packageList: [],
|
||||
packageLoading: false,
|
||||
selectedPackage: null,
|
||||
renewData: {},
|
||||
}
|
||||
},
|
||||
|
||||
|
|
@ -308,8 +314,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)
|
||||
|
|
@ -325,7 +332,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 || []
|
||||
|
|
@ -369,20 +376,37 @@ export default {
|
|||
}
|
||||
|
||||
try {
|
||||
const renewData = {
|
||||
suitId: this.selectedPackage.id,
|
||||
appId: '1', // 应用ID,根据实际情况调整
|
||||
payAmount: this.selectedPackage.price || this.selectedPackage.amount,
|
||||
channelId: '3', // 渠道ID,根据实际情况调整
|
||||
devId: this.selectedDevice.id,
|
||||
if (this.selectedPackage.id && this.selectedPackage.id.endsWith('a')) {
|
||||
this.renewData = {
|
||||
payAmount: this.packageList.lastSuitAmount,
|
||||
lastSuitDay: this.packageList.lastSuitDay,
|
||||
lastSuitId: this.packageList.lastSuitId,
|
||||
lastSuitName: this.packageList.lastSuitName,
|
||||
// suitId: this.selectedPackage.id,
|
||||
isLastSuit: true,
|
||||
appId: '1', // 应用ID,根据实际情况调整
|
||||
// payAmount: this.selectedPackage.price || this.selectedPackage.amount,
|
||||
channelId: '3', // 渠道ID,根据实际情况调整
|
||||
devId: this.selectedDevice.id,
|
||||
}
|
||||
console.log('ID以a结尾')
|
||||
} else {
|
||||
this.renewData = {
|
||||
suitId: this.selectedPackage.id,
|
||||
appId: '1', // 应用ID,根据实际情况调整
|
||||
payAmount: this.selectedPackage.price || this.selectedPackage.amount,
|
||||
channelId: '3', // 渠道ID,根据实际情况调整
|
||||
devId: this.selectedDevice.id,
|
||||
}
|
||||
console.log('ID不以a结尾')
|
||||
}
|
||||
|
||||
console.log('续费数据:', renewData)
|
||||
console.log('续费数据:', this.renewData)
|
||||
uni.showLoading({
|
||||
title: '正在生成续费订单',
|
||||
title: '生成续费订单中',
|
||||
mask: 'true',
|
||||
})
|
||||
const response = await renewDevice(renewData)
|
||||
const response = await renewDevice(this.renewData)
|
||||
uni.hideLoading()
|
||||
if (response.code === 200) {
|
||||
const data = response.data
|
||||
|
|
|
|||
|
|
@ -20,7 +20,7 @@ const ENV_CONFIG = {
|
|||
// 正式版
|
||||
// baseUrl: 'https://chu.chuangtewl.com/prod-api',
|
||||
// baseUrl: 'http://192.168.2.21:4601',
|
||||
baseUrl: 'http://192.168.2.21:4601',
|
||||
baseUrl: 'https://chu.chuangtewl.com/prod-api',
|
||||
appId: 1,
|
||||
},
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user