fix: 修复表单数据加载与切换房屋逻辑

main
cr 2026-04-25 23:03:52 +08:00
parent 0ab1535f7f
commit 856b7224c1
5 changed files with 71 additions and 62 deletions

View File

@ -54,7 +54,7 @@
<view class="form-item">
<text class="form-label">与产权人关系</text>
<view class="form-value" @tap="showRelationPicker">
<text class="value-text placeholder-color">{{ state.form.relationType || '请输入' }}</text>
<text class="value-text placeholder-color">{{ state.form.relationType ? (state.relationList.find(item => item.value == state.form.relationType)?.label || '请输入') : '请输入' }}</text>
<image class="arrow-icon" src="/static/img/right-icon-black.png" mode="aspectFit" />
</view>
</view>
@ -95,7 +95,7 @@
<view class="form-item">
<text class="form-label">证件类型</text>
<view class="form-value" @tap="showIdTypePicker">
<text class="value-text placeholder-color">{{ state.form.idType || '请选择证件类型' }}</text>
<text class="value-text placeholder-color">{{ state.form.idType ? (state.idTypeList.find(item => item.value == state.form.idType)?.label || '请选择证件类型') : '请选择证件类型' }}</text>
<image class="arrow-icon" src="/static/img/right-icon-black.png" mode="aspectFit" />
</view>
</view>
@ -119,7 +119,7 @@
<view class="form-item">
<text class="form-label">性别</text>
<view class="form-value" @tap="showGenderPicker">
<text class="value-text placeholder-color">{{ state.form.sex === 1 ? '男' : state.form.sex === 2 ? '女' : '请选择' }}</text>
<text class="value-text placeholder-color">{{ state.form.sex ? (state.sexList.find(item => item.value == state.form.sex)?.label || '请选择') : '请选择' }}</text>
<image class="arrow-icon" src="/static/img/right-icon-black.png" mode="aspectFit" />
</view>
</view>
@ -187,6 +187,7 @@ import { onLoad } from '@dcloudio/uni-app';
import MemberHouseApi from '@/sheep/api/community/memberHouse';
import CommunityApi from '@/sheep/api/community/community';
import FileApi from '@/sheep/api/infra/file';
import DictApi from '@/sheep/api/system/dict';
import { tenantId } from '@/sheep/config';
import sheep from '@/sheep';
@ -216,11 +217,19 @@ const state = reactive({
houseTree: [], // ->->
attachmentUrl: '', // URL
facePhotoUrl: '', // URL
idTypeList: [], //
relationList: [], //
sexList: [], //
});
onLoad(async () => {
//
loadDict('comm_id_type', 'idTypeList');
loadDict('comm_relation_type', 'relationList');
loadDict('system_user_sex', 'sexList');
//
const { code, data } = await CommunityApi.getSimpleList();
const { code, data } = await CommunityApi.getSimpleList({ all: true });
if (code === 0 && data && data.length > 0) {
state.communityList = data;
// SHOPRO_TENANT_ID
@ -235,6 +244,14 @@ onLoad(async () => {
}
});
//
const loadDict = async (type, field) => {
const { code, data } = await DictApi.getDictDataListByType(type);
if (code === 0 && data) {
state[field] = data;
}
};
//
const loadHouseTree = async (communityId) => {
if (!communityId) return;
@ -284,7 +301,7 @@ const showHousePicker = () => {
const units = building.children || [];
if (!units.length) {
state.form.houseId = building.value;
state.form.buildingNo = building.label;
state.form.buildingNo = building.value;
state.form.unitNo = '';
state.form.roomNo = '';
return;
@ -299,8 +316,8 @@ const showHousePicker = () => {
const rooms = unit.children || [];
if (!rooms.length) {
state.form.houseId = unit.value;
state.form.buildingNo = building.label;
state.form.unitNo = unit.label;
state.form.buildingNo = building.value;
state.form.unitNo = unit.value;
state.form.roomNo = '';
return;
}
@ -310,9 +327,9 @@ const showHousePicker = () => {
success: (roomRes) => {
const room = rooms[roomRes.tapIndex];
state.form.houseId = room.value;
state.form.buildingNo = building.label;
state.form.unitNo = unit.label;
state.form.roomNo = room.label;
state.form.buildingNo = building.value;
state.form.unitNo = unit.value;
state.form.roomNo = room.value;
}
});
}
@ -323,32 +340,45 @@ const showHousePicker = () => {
//
const showRelationPicker = () => {
if (!state.relationList.length) {
uni.showToast({ title: '数据加载中', icon: 'none' });
return;
}
const itemList = state.relationList.map((item) => item.label);
uni.showActionSheet({
itemList: ['本人', '配偶', '父母', '子女', '其他'],
itemList,
success: (res) => {
const relations = ['本人', '配偶', '父母', '子女', '其他'];
state.form.relationType = relations[res.tapIndex];
state.form.relationType = state.relationList[res.tapIndex].value;
}
});
};
//
const showIdTypePicker = () => {
if (!state.idTypeList.length) {
uni.showToast({ title: '数据加载中', icon: 'none' });
return;
}
const itemList = state.idTypeList.map((item) => item.label);
uni.showActionSheet({
itemList: ['身份证', '护照', '军官证', '港澳通行证'],
itemList,
success: (res) => {
const types = ['身份证', '护照', '军官证', '港澳通行证'];
state.form.idType = types[res.tapIndex];
state.form.idType = state.idTypeList[res.tapIndex].value;
}
});
};
//
const showGenderPicker = () => {
if (!state.sexList.length) {
uni.showToast({ title: '数据加载中', icon: 'none' });
return;
}
const itemList = state.sexList.map((item) => item.label);
uni.showActionSheet({
itemList: ['男', '女'],
itemList,
success: (res) => {
state.form.sex = res.tapIndex === 0 ? 1 : 2;
state.form.sex = state.sexList[res.tapIndex].value;
}
});
};

View File

@ -25,7 +25,7 @@
<text class="house-name">{{ item.communityName }}</text>
<text :class="['status-tag', getStatusClass(item.status)]">{{ getStatusText(item.status) }}</text>
</view>
<text class="house-address">{{ item.address }}</text>
<text class="house-address">{{ item.ful1Address }}</text>
</view>
</view>

View File

@ -29,13 +29,7 @@
indicator-active-color="#FF7F69"
>
<swiper-item v-for="(item, index) in bannerList" :key="index" @tap="handleBannerTap(item)">
<view class="banner-content">
<view class="banner-text">
<text class="banner-title">{{ item.title }}</text>
<text class="banner-subtitle">{{ item.subtitle }}</text>
</view>
<image class="banner-icon" :src="item.icon" mode="aspectFit"></image>
</view>
<image class="banner-img" :src="item.icon" mode="aspectFill"></image>
</swiper-item>
</swiper>
</view>
@ -406,7 +400,6 @@ const handleBannerTap = (item) => {
.banner-card {
height: 298rpx;
margin: 0 24rpx 24rpx;
padding: 45.8rpx 38rpx;
background-color: #FFFFFF;
border-radius: 38rpx;
overflow: hidden;
@ -416,37 +409,9 @@ const handleBannerTap = (item) => {
width: 100%;
height: 100%;
.banner-content {
display: flex;
justify-content: space-between;
align-items: center;
padding: 32rpx;
.banner-img {
width: 100%;
height: 100%;
.banner-text {
flex: 1;
.banner-title {
display: block;
font-size: 44rpx;
font-weight: 600;
color: #333333;
margin-bottom: 12rpx;
font-family: 'PingFang SC', sans-serif;
}
.banner-subtitle {
display: block;
font-size: 24rpx;
color: #999999;
font-family: 'PingFang SC', sans-serif;
}
}
.banner-icon {
width: 160rpx;
height: 160rpx;
}
}
}
}

View File

@ -126,9 +126,22 @@ const selectHouse = async (item) => {
communityId: item.communityId,
});
if (switchRes.code === 0) {
//
const resData = switchRes.data || {};
if (resData.needRelogin) {
// token
await sheep.$store('user').setToken(resData.accessToken, resData.refreshToken);
} else {
//
await sheep.$store('user').getInfo();
}
uni.showToast({ title: '已切换至 ' + item.name, icon: 'none' });
//
setTimeout(() => {
uni.switchTab({ url: '/pages/index/index' });
}, 800);
}
};

View File

@ -2,10 +2,11 @@ import request from '@/sheep/request';
const CommunityApi = {
// 获取小区简单列表
getSimpleList: () => {
getSimpleList: (data) => {
return request({
url: '/community/community/simple-list',
method: 'GET',
data,
custom: {
showLoading: true,
auth: true,