diff --git a/.idea/workspace.xml b/.idea/workspace.xml
index 7ed9d5a..57c96f7 100644
--- a/.idea/workspace.xml
+++ b/.idea/workspace.xml
@@ -4,8 +4,8 @@
-
-
+
+
@@ -75,7 +75,7 @@
-
+
@@ -117,7 +117,23 @@
1770982645978
-
+
+
+ 1775221374761
+
+
+
+ 1775221374761
+
+
+
+ 1775222388851
+
+
+
+ 1775222388851
+
+
@@ -129,6 +145,8 @@
-
+
+
+
\ No newline at end of file
diff --git a/sub_pages/house/add.vue b/sub_pages/house/add.vue
index f7134da..34851b1 100644
--- a/sub_pages/house/add.vue
+++ b/sub_pages/house/add.vue
@@ -254,7 +254,7 @@
-
+
@@ -308,13 +308,16 @@
avatarUrl: '',
// 临时图片 (用于上传)
tempFile: null,
- // 表单数据
- form: {
- houseTitle: '',
- area: '',
- status: 10,
- address: ''
- },
+ // 表单数据
+ form: {
+ houseTitle: '',
+ province: '',
+ city: '',
+ region: '',
+ area: '',
+ status: 10,
+ address: ''
+ },
fileList1: [],
fileList2: [],
loading: false,
@@ -537,6 +540,9 @@
app.form.videoUrl = app.fileList2[0] ? app.fileList2[0].url : null
app.form.monthlyRent = app.monthlyRent
const saveOrUpdate = app.selectId > 0 ? updateHouseInfo : addHouseInfo;
+ // 调试:打印提交的数据
+ console.log('提交表单数据:', JSON.stringify(app.form, null, 2));
+ console.log('province:', app.form.province, 'city:', app.form.city, 'area:', app.form.area);
saveOrUpdate(app.form).then(result => {
app.$toast('保存成功')
setTimeout(() => {
@@ -647,12 +653,23 @@
},
//地址选择成功
chooseSuccess(e) {
+ console.log('chooseSuccess 收到数据:', JSON.stringify(e));
const data = e.value
+ if (!data || data.length < 2) {
+ console.error('地区数据不完整:', data);
+ return;
+ }
this.form.province = data[0].label
this.form.city = data[1].label
- this.form.region = data[2].label
- this.form.area = `${data[0].label} ${data[1].label} ${data[2].label}`
- console.log("this.form.area: ", this.form.area);
+ // 根据选择层级保存数据
+ if (data.length >= 3 && data[2]) {
+ this.form.region = data[2].label
+ this.form.area = `${data[0].label} ${data[1].label} ${data[2].label}`
+ } else {
+ this.form.region = ''
+ this.form.area = `${data[0].label} ${data[1].label}`
+ }
+ console.log('地区选择完成 - province:', this.form.province, 'city:', this.form.city, 'area:', this.form.area);
},
changeHandler(e) {
console.log("e: ", e);
diff --git a/uni_modules/liu-customize-sel/components/liu-customize-sel/liu-customize-sel.vue b/uni_modules/liu-customize-sel/components/liu-customize-sel/liu-customize-sel.vue
index eeac0d2..f6b640a 100644
--- a/uni_modules/liu-customize-sel/components/liu-customize-sel/liu-customize-sel.vue
+++ b/uni_modules/liu-customize-sel/components/liu-customize-sel/liu-customize-sel.vue
@@ -8,7 +8,7 @@
确定
-
+
{{ checkArr[e] ? checkArr[e].label : i.title }}
@@ -41,6 +41,11 @@
import noData from '../../static/noData.png'
export default {
props: {
+ //选择层级:2=省市,3=省市县区(默认)
+ level: {
+ type: Number,
+ default: 3,
+ },
//是否开启动画
animation: {
type: Boolean,
@@ -59,8 +64,18 @@
},
computed: {
confirmClass() {
- return this.checkArr.length == this.tabList.length ? 'sel-top-right-check' : 'sel-top-right';
+ return this.checkArr.length >= this.level ? 'sel-top-right-check' : 'sel-top-right';
},
+ tabListComputed() {
+ const list = [
+ { title: '选择所在省', id: 0 },
+ { title: '选择所在市', id: 1 }
+ ];
+ if (this.level >= 3) {
+ list.push({ title: '选择所在区', id: 2 });
+ }
+ return list;
+ }
},
data() {
return {
@@ -71,18 +86,10 @@
tabId: 0, //计算当前顶部滑块id
checkArr: [],
id: 0, //通tabId,他们2的区别是,id先赋值,tabId在数据请求成功后才会赋值
- tabList: [{
- title: '选择所在省',
- id: 0,
- },
- {
- title: '选择所在市',
- id: 1,
- },
- {
- title: '选择所在县',
- id: 2,
- }
+ tabList: [
+ { title: '选择所在省', id: 0 },
+ { title: '选择所在市', id: 1 },
+ { title: '选择所在区', id: 2 }
],
};
},
@@ -106,8 +113,11 @@
this.isShow = false;
},
async check(index) {
+ console.log('check called - id:', this.id, 'level:', this.level, 'tabList.length:', this.tabList.length);
this.$set(this.checkArr, this.id, this.checkBox[this.id][index]);
+ console.log('after set checkArr:', JSON.stringify(this.checkArr));
if (this.id < this.tabList.length - 1) this.id = this.id + 1;
+ console.log('next id:', this.id);
await this.getData(); //同步请求
if (this.tabId < this.tabList.length - 1) this.tabId = this.tabId + 1;
},
@@ -119,20 +129,29 @@
this.checkArr = this.checkArr.splice(0, e);
},
- getResult(event) {
- if (event == 'confirm') {
- if (this.checkArr.length != this.tabList.length) return;
- let result = this.checkArr;
- this.$emit('change', {
- value: result
- });
+ getResult(event) {
+ if (event == 'confirm') {
+ // 检查是否选择了所有必要的级别
+ console.log('getResult confirm:', {
+ checkArrLength: this.checkArr.length,
+ level: this.level,
+ checkArr: this.checkArr
+ });
+ if (this.checkArr.length < this.level) {
+ console.warn('选择不完整,无法确认');
+ return;
}
- this.close();
- },
+ let result = this.checkArr;
+ this.$emit('change', {
+ value: result
+ });
+ }
+ this.close();
+ },
async getData() {
// 加载数据
- if (this.checkArr.length == this.tabList.length) return;
+ if (this.checkArr.length >= this.level) return;
uni.showLoading({ title: '加载中...' });