fix: 修复表单数据加载与切换房屋逻辑
parent
0ab1535f7f
commit
856b7224c1
|
|
@ -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;
|
||||
}
|
||||
});
|
||||
};
|
||||
|
|
|
|||
|
|
@ -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>
|
||||
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -126,9 +126,22 @@ const selectHouse = async (item) => {
|
|||
communityId: item.communityId,
|
||||
});
|
||||
if (switchRes.code === 0) {
|
||||
// 切换成功后刷新用户信息
|
||||
await sheep.$store('user').getInfo();
|
||||
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);
|
||||
}
|
||||
};
|
||||
|
||||
|
|
|
|||
|
|
@ -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,
|
||||
|
|
|
|||
Loading…
Reference in New Issue