对接在线报修接口

This commit is contained in:
zhouyanli
2026-04-29 17:39:55 +08:00
parent 46c9f6dacc
commit d183cb00c0
8 changed files with 356 additions and 143 deletions

View File

@@ -9,10 +9,10 @@
v-for="item in houseList"
:key="item.id"
>
<image src="http://47.104.199.163:9090/images/repair/house.png" style="width: 60rpx;height: 60rpx;"></image>
<image src="http://47.104.199.163:9090/images/repair/house.png" style="width: 48rpx;height: 48rpx;"></image>
<view class="house-name">
{{ item.community }}
<view class="house-detail">{{ item.address }}</view>
{{ item.villageName }}
<view class="house-detail">{{ item.houseType }}</view>
</view>
<uni-icons type="checkbox-filled" size="20" color="#007aff" v-if="selectedHouse.id === item.id"></uni-icons>
@@ -26,17 +26,49 @@
<script setup>
import { ref } from 'vue'
// import { uniShowToast, uniNavigateBack } from '@dcloudio/uni-app'
import { onLoad } from '@dcloudio/uni-app'
import { getHouseList } from '../api/api.js'
// 房屋列表数据
const houseList = ref([
{ id: 1, community: '桂花园(别墅)', address: '2号楼2幢' },
{ id: 2, community: '安泰翡翠城', address: '11号楼5单元1801' },
{ id: 3, community: '碧桂园新城·时代之光', address: '3号楼' }
])
const houseList = ref([])
// 选中的房屋
const selectedHouse = ref(houseList.value[0]) // 默认选中第一个
const selectedHouse = ref({})
// 分页参数
const pageNum = ref(1)
const pageSize = ref(10)
// 预传入的房屋ID从表单页带过来
const preSelectedHouseId = ref('')
// 获取房屋列表
const fetchHouseList = async () => {
try {
const res = await getHouseList({ pageNum: pageNum.value, pageSize: pageSize.value })
if (res.code === 200) {
const list = res.rows || []
houseList.value = list
if (houseList.value.length > 0) {
if (preSelectedHouseId.value) {
const found = houseList.value.find(item => String(item.id) === String(preSelectedHouseId.value))
selectedHouse.value = found || houseList.value[0]
} else {
selectedHouse.value = houseList.value[0]
}
}
}
} catch (e) {
uni.showToast({ title: '获取房屋列表失败', icon: 'none' })
}
}
onLoad((options) => {
if (options.houseId) {
preSelectedHouseId.value = options.houseId
}
fetchHouseList()
})
// 选择房屋
const selectHouse = (item) => {
@@ -52,7 +84,8 @@ const confirmSelect = () => {
// 把选中的房屋信息传给表单页通过uni.$emit
uni.$emit('selectHouse', {
name: `${selectedHouse.value.community} ${selectedHouse.value.address}`
id: selectedHouse.value.id,
name: `${selectedHouse.value.villageName} ${selectedHouse.value.houseType}`
})
// 返回上一页