Kaynağa Gözat

feat:地址回显

jianghaili 7 ay önce
ebeveyn
işleme
aa92b2bad2
2 değiştirilmiş dosya ile 73 ekleme ve 80 silme
  1. 51 76
      package/jobIntention/addAddress.vue
  2. 22 4
      pages/my/jobPostingSecond.vue

+ 51 - 76
package/jobIntention/addAddress.vue

@@ -12,77 +12,52 @@
         <!-- 省/市/区三级联动选择器 -->
         <view class="form-item">
           <view class="item-label">所在省份 <text class="required">*</text></view>
-          <picker 
-            :range="provinces" 
-            :range-key="'name'"
-            v-model="provinceIndex" 
-            @change="onProvinceChange"
-          >
+          <picker :range="provinces" :range-key="'name'" v-model="provinceIndex" @change="onProvinceChange">
             <view class="picker-view">
               {{ provinceIndex !== null ? provinces[provinceIndex].name : '请选择省份' }}
             </view>
           </picker>
         </view>
-        
+
         <view class="form-item">
           <view class="item-label">所在城市 <text class="required">*</text></view>
-          <picker 
-            :range="cities" 
-            :range-key="'name'"
-            v-model="cityIndex" 
-            @change="onCityChange"
-            :disabled="provinceIndex === null"
-          >
+          <picker :range="cities" :range-key="'name'" v-model="cityIndex" @change="onCityChange"
+            :disabled="provinceIndex === null">
             <view class="picker-view">
               {{ cityIndex !== null && cities.length > 0 ? cities[cityIndex].name : '请先选择省份' }}
             </view>
           </picker>
         </view>
-        
+
         <view class="form-item">
           <view class="item-label">所在区域 <text class="required">*</text></view>
-          <picker 
-            :range="districts" 
-            :range-key="'name'"
-            v-model="districtIndex" 
-            @change="onDistrictChange"
-            :disabled="cityIndex === null || cities.length === 0"
-          >
+          <picker :range="districts" :range-key="'name'" v-model="districtIndex" @change="onDistrictChange"
+            :disabled="cityIndex === null || cities.length === 0">
             <view class="picker-view">
               {{ districtIndex !== null && districts.length > 0 ? districts[districtIndex].name : '请先选择城市' }}
             </view>
           </picker>
         </view>
-        
+
         <!-- 详细地址信息 -->
         <view class="form-item">
           <view class="item-label">街道/楼宇 <text class="required">*</text></view>
-          <u-input
-            placeholder="请输入街道或楼宇名称,例:科技园路1号"
-            v-model="address"
-            clearable
-            class="custom-input"
-          >
+          <u-input placeholder="请输入街道或楼宇名称,例:科技园路1号" v-model="address" clearable class="custom-input">
             <template #prefix>
               <u-icon name="map" size="36rpx" color="#999" marginRight="20rpx"></u-icon>
             </template>
           </u-input>
         </view>
-        
+
         <view class="form-item">
           <view class="item-label">楼层/单元室</view>
-          <u-input
-            placeholder="例:3层302室(选填)"
-            v-model="addressDetail"
-            clearable
-            class="custom-input"
-          >
+          <u-input placeholder="例:3层302室(选填)" v-model="addressDetail" clearable class="custom-input">
             <template #prefix>
               <u-icon name="home" size="36rpx" color="#999" marginRight="20rpx"></u-icon>
             </template>
           </u-input>
         </view>
-        
+
         <!-- 地图选点后显示经纬度(可选) -->
         <view class="location-info" v-if="latitude && longitude">
           <text>经纬度:{{ latitude }}, {{ longitude }}</text>
@@ -104,12 +79,12 @@ export default {
       provinces: [],       // 所有省份
       cities: [],          // 选中省份对应的城市
       districts: [],       // 选中城市对应的区域
-      
+
       // 选中索引
       provinceIndex: null, // 选中的省份索引
       cityIndex: null,     // 选中的城市索引
       districtIndex: null, // 选中的区域索引
-      
+
       // 地址信息
       address: "",        // 街道/楼宇(必填)
       addressDetail: '',  // 楼层/单元室(选填)
@@ -125,37 +100,36 @@ export default {
   //   this.provinces = addr;
   // },
   onLoad(options) {
-	 this.provinces = addr;
-    // 回显上一页传递的地址信息
-    if (options.address) this.address = decodeURIComponent(options.address);
-    if (options.addressDetail) this.addressDetail = decodeURIComponent(options.addressDetail);
-    if (options.latitude) this.latitude = options.latitude;
-    if (options.longitude) this.longitude = options.longitude;
-    
-    // 如果有省市区信息,进行回显
-    if (options.province && options.city && options.district) {
+    this.provinces = addr;
+    if (options.address) {
+      let address = JSON.parse(options.address);
+      console.log(address,'子地址')
+      // 回显上一页传递的地址信息
+      // this.address = decodeURIComponent(address.address);
+      // this.addressDetail = decodeURIComponent(address.addressDetail);
+      this.latitude = address.latitude;
+      this.longitude = address.longitude;
+      // 如果有省市区信息,进行回显
       this.setAddressValue(
-        decodeURIComponent(options.province),
-        decodeURIComponent(options.city),
-        decodeURIComponent(options.district)
+        decodeURIComponent(address.province),
+        decodeURIComponent(address.city),
+        decodeURIComponent(address.district)
       );
     }
-	
-
   },
   methods: {
     // 省份选择改变
     onProvinceChange(e) {
       const index = e.detail.value;
       this.provinceIndex = index;
-      
+
       // 重置城市和区域选择
       this.cityIndex = null;
       this.districtIndex = null;
-      
+
       // 加载对应省份的城市
       this.cities = this.provinces[index].children || [];
-      
+
       // 如果有城市数据,自动加载第一个城市的区域
       if (this.cities.length > 0) {
         this.districts = this.cities[0].children || [];
@@ -163,24 +137,24 @@ export default {
         this.districts = [];
       }
     },
-    
+
     // 城市选择改变
     onCityChange(e) {
       const index = e.detail.value;
       this.cityIndex = index;
-      
+
       // 重置区域选择
       this.districtIndex = null;
-      
+
       // 加载对应城市的区域
       this.districts = this.cities[index].children || [];
     },
-    
+
     // 区域选择改变
     onDistrictChange(e) {
       this.districtIndex = e.detail.value;
     },
-    
+
     // 根据省市区名称设置选择器值(用于回显)
     setAddressValue(provinceName, cityName, districtName) {
       // 查找省份索引
@@ -188,13 +162,13 @@ export default {
       if (provinceIndex !== -1) {
         this.provinceIndex = provinceIndex;
         this.cities = this.provinces[provinceIndex].children || [];
-        
+
         // 查找城市索引
         const cityIndex = this.cities.findIndex(item => item.name === cityName);
         if (cityIndex !== -1) {
           this.cityIndex = cityIndex;
           this.districts = this.cities[cityIndex].children || [];
-          
+
           // 查找区域索引
           const districtIndex = this.districts.findIndex(item => item.name === districtName);
           if (districtIndex !== -1) {
@@ -203,7 +177,7 @@ export default {
         }
       }
     },
-    
+
     // 打开地图选择地址
     openMapSelector() {
       uni.chooseLocation({
@@ -211,7 +185,7 @@ export default {
           this.address = res.name || res.address;
           this.latitude = res.latitude;
           this.longitude = res.longitude;
-          
+
           uni.showToast({
             title: '请确认并补充省/市/区信息',
             icon: 'none',
@@ -226,7 +200,7 @@ export default {
         }
       });
     },
-    
+
     // 确认地址并回传
     confirmAddress() {
       // 获取选中的省市区信息
@@ -303,16 +277,16 @@ picker:disabled .picker-view {
   bottom: 0;
   display: flex;
   flex-direction: column;
-  
+
   .roles-content {
     width: 100%;
     flex: 1;
     overflow-y: auto;
-    
+
     .content {
       padding: 40rpx;
       box-sizing: border-box;
-      
+
       .map-selector {
         display: flex;
         align-items: center;
@@ -324,27 +298,28 @@ picker:disabled .picker-view {
         font-size: 28rpx;
         cursor: pointer;
         transition: background-color 0.2s;
-        
+
         &:active {
           background-color: #e8ebf0;
         }
       }
-      
+
       .location-info {
         margin-top: 10rpx;
         font-size: 24rpx;
         color: #999;
         padding: 10rpx 0;
       }
-      
+
       .required {
-        color: #ff4d4f; /* 红色必填标记 */
+        color: #ff4d4f;
+        /* 红色必填标记 */
         font-size: 32rpx;
         margin-left: 4rpx;
       }
     }
   }
-  
+
   .submit-btn {
     margin: 60rpx 20rpx;
     height: 96rpx;
@@ -356,7 +331,7 @@ picker:disabled .picker-view {
     justify-content: center;
     align-items: center;
     transition: all 0.2s ease;
-    
+
     &:active {
       transform: scale(0.98);
       opacity: 0.9;
@@ -368,7 +343,7 @@ picker:disabled .picker-view {
   box-sizing: border-box;
   border: 2rpx solid #9ea1a8;
   border-radius: 100rpx;
-  padding: 8rpx 36rpx; 
+  padding: 8rpx 36rpx;
   height: 96rpx;
 }
 

+ 22 - 4
pages/my/jobPostingSecond.vue

@@ -339,6 +339,12 @@ export default {
 			this.welfareTag = workData.welfareTag;
 			this.positionTag = workData.positionTag ? workData.positionTag.split(',') : [];
 			this.address = workData.address;
+			this.stationName.fullText = workData.address, //地址
+				this.stationName.latitude = workData.lat
+			this.stationName.longitude = workData.lng;
+			this.stationName.province = workData.province;
+			this.stationName.city = workData.city;
+			this.stationName.district = workData.county;
 		}
 		this.fundListener = uni.$on("fundData", (data) => {
 			console.log("接收到的福利数据:", data);
@@ -349,7 +355,11 @@ export default {
 			this.positionTag = data.selectedTags; // 赋值给当前页面变量
 		});
 		this.fundListener = uni.$on("addressData", (data) => {
-			console.log("接收到的地址数据:", data);
+			this.address = data.fullText;
+			this.stationName = data;
+			this.stationName.fullText = data.fullText;
+			console.log("接收到的地址数据jhl:", data);
+
 			this.stationName = data; // 赋值给当前页面变量
 		});
 		if (options.companyId) {
@@ -430,7 +440,6 @@ export default {
 					this.stationName.city = res.data.city
 					this.stationName.district = res.data.county
 					this.salaryTimes = res.data.salaryTimes
-					console.log(this.stationName)
 				} else {
 					uni.showToast({
 						title: '数据有误',
@@ -517,11 +526,20 @@ export default {
 
 		// 跳转页面并接收参数(工作地址)
 		goAddAddress() {
+			let address = {
+				...this.stationName
+			}
 			uni.navigateTo({
-				url: "/package/jobIntention/addAddress",
+				url: "/package/jobIntention/addAddress?address=" + JSON.stringify(address),
 				events: {
 					addressData: (data) => {
-						this.stationName = data;
+						let value = {
+							...data
+						}
+						this.stationName = value;
+						this.stationName.fullText = value.fullText;
+						this.address = value.fullText;
+						console.log(value, '地址信息,哈哈哈')
 					},
 				},
 			});