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

View File

@ -29,13 +29,7 @@
indicator-active-color="#FF7F69" indicator-active-color="#FF7F69"
> >
<swiper-item v-for="(item, index) in bannerList" :key="index" @tap="handleBannerTap(item)"> <swiper-item v-for="(item, index) in bannerList" :key="index" @tap="handleBannerTap(item)">
<view class="banner-content"> <image class="banner-img" :src="item.icon" mode="aspectFill"></image>
<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>
</swiper-item> </swiper-item>
</swiper> </swiper>
</view> </view>
@ -406,47 +400,18 @@ const handleBannerTap = (item) => {
.banner-card { .banner-card {
height: 298rpx; height: 298rpx;
margin: 0 24rpx 24rpx; margin: 0 24rpx 24rpx;
padding: 45.8rpx 38rpx;
background-color: #FFFFFF; background-color: #FFFFFF;
border-radius: 38rpx; border-radius: 38rpx;
overflow: hidden; overflow: hidden;
box-shadow: 0 4rpx 16rpx rgba(0, 0, 0, 0.06); box-shadow: 0 4rpx 16rpx rgba(0, 0, 0, 0.06);
.banner-swiper { .banner-swiper {
width: 100%; width: 100%;
height: 100%; height: 100%;
.banner-content { .banner-img {
display: flex; width: 100%;
justify-content: space-between;
align-items: center;
padding: 32rpx;
height: 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, communityId: item.communityId,
}); });
if (switchRes.code === 0) { if (switchRes.code === 0) {
// const resData = switchRes.data || {};
await sheep.$store('user').getInfo();
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' }); 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 = { const CommunityApi = {
// 获取小区简单列表 // 获取小区简单列表
getSimpleList: () => { getSimpleList: (data) => {
return request({ return request({
url: '/community/community/simple-list', url: '/community/community/simple-list',
method: 'GET', method: 'GET',
data,
custom: { custom: {
showLoading: true, showLoading: true,
auth: true, auth: true,