From 9d3e12b88c3b5556a9b186e7afcc813236cc126a Mon Sep 17 00:00:00 2001
From: k94314517 <8417338+k94314517@user.noreply.gitee.com>
Date: 星期四, 01 八月 2024 18:26:41 +0800
Subject: [PATCH] Merge remote-tracking branch 'origin/master'

---
 wechat_jiaxuan/pages/design/design.js          |   43 ++-----------
 wechat_jiaxuan/components/areaSel/areaSel.js   |   74 ++++++++++++++++++++----
 wechat_jiaxuan/pages/design/design.wxml        |    2 
 wechat_jiaxuan/components/areaSel/areaSel.wxml |    4 
 wechat_jiaxuan/pages/index/index.js            |    1 
 5 files changed, 72 insertions(+), 52 deletions(-)

diff --git a/wechat_jiaxuan/components/areaSel/areaSel.js b/wechat_jiaxuan/components/areaSel/areaSel.js
index 0f5315e..a7c8613 100644
--- a/wechat_jiaxuan/components/areaSel/areaSel.js
+++ b/wechat_jiaxuan/components/areaSel/areaSel.js
@@ -1,3 +1,4 @@
+ 
 import { 
   getArea
 } from '../../api/index'
@@ -15,10 +16,12 @@
           // observer鐩戝惉value鐨勫彉鍖栵紝濡傛灉鏈夊�煎垯璋冪敤setLabel鏂规硶璁剧疆閫夋嫨鍣ㄧ殑label
           observer(selectedValues) {
               if (selectedValues && selectedValues.length) {
+                  this.resetValus(selectedValues)
+                  console.log("--------------------",this.data.value)
                   this.setLabel();
               }
           }
-      }
+      } 
   },
   data: {
       // label涓洪�夋嫨鍣ㄧ殑鏄剧ず鍊�
@@ -32,15 +35,16 @@
   },
   // attached鐢熷懡鍛ㄦ湡鍑芥暟锛屽湪缁勪欢瀹炰緥杩涘叆椤甸潰鑺傜偣鏍戞椂鎵ц
   attached() {
-    this.initData()
-      
+    this.initData()  
   },
+
   methods: {
     // wx.setStorageSync('addressList', tl)    
     initData(){
-      let list = wx.getStorageSync('addressList')
+    let list = wx.getStorageSync('addressList')
     if(list && list.length){ 
       this.setData({addressList: list})
+      this.resetValus(list)
       this.setLabel();
       if (!this.data.value.length) {
           this.initRange();
@@ -88,13 +92,58 @@
         }
         wx.setStorageSync('addressList', tl)
         this.setData({addressList: tl})
+        this.resetValus()
         this.setLabel();
         if (!this.data.value.length) {
             this.initRange();
-        }
-        console.log(this.data.addressList)
+        } 
       })
     }
+    },
+    resetValus(selectedValues){ 
+      selectedValues = selectedValues || this.data.value
+      let temVal = []
+      let tlable =''
+      if (selectedValues.length == 3) {  
+         var v1  = selectedValues[0]
+         var v2  = selectedValues[1]
+         var v3= selectedValues[2]
+        var t1,t2,t3;
+        this.data.addressList.forEach(item =>{ 
+          if(v1 && v1.length ==6 
+            &&v2 && v2.length ==6
+            &&v3  && v3.length ==6){  
+              if(item.value.indexOf(v1) == 0){
+                    t1 = item.value
+                    if(item.children){
+                      item.children.forEach(item2 =>{  
+                        if(item2.value.indexOf(v2) == 0){
+                            if(item2.children){
+                              item2.children.forEach(item3 =>{ 
+                                if(item3.value.indexOf(v3) == 0){
+                                    tlable = item.label +"-"+item2.label+'-'+item3.label
+                                    t1 = item.value 
+                                    t2 = item2.value 
+                                    t3 = item3.value
+                                    temVal = [t1,t2,t3] 
+                                    // this.value = temVal
+                                    // this.data.label=tlable
+                                    this.triggerEvent("change", {
+                                        value: temVal,
+                                        label:tlable
+                                    });
+                                    this.setData({value:temVal,label:tlable}) 
+                                    console.log("--------------------",this.data.value)
+                                }
+                              })
+                            }
+                        }
+                      })
+                    }
+              }
+            } 
+        }) 
+      }    
     },
       // getAddressItem鏂规硶鐢ㄤ簬灏嗗湴鍧�淇℃伅杞崲涓洪�夋嫨鍣ㄥ彲鐢ㄧ殑鏍煎紡
       getAddressItem(data) {
@@ -108,7 +157,7 @@
           return list.map((v) => this.getAddressItem(v));
       },
       // getAddressByCode鏂规硶鐢ㄤ簬鏍规嵁value鍊艰幏鍙栧湴鍧�淇℃伅鍙婂叾鍦ㄦ暟缁勪腑鐨勪笅鏍�
-      getAddressByCode(list = [], value) {
+      getAddressByCode(list = [], value) { 
           let index = list.findIndex(item => item.value === value);
           return [index, list[index] || {}];
       },
@@ -144,9 +193,7 @@
           });
           this.setData({
             label:label
-          });
-          console.log("label1", label)
-          console.log("label",this.data.label)
+          }); 
       },
       // columnChange鏂规硶涓洪�夋嫨鍣ㄧ殑columnchange浜嬩欢澶勭悊鍑芥暟锛岀敤浜庤缃畆ange鍜宲ickerValue
       columnChange(e) {
@@ -182,7 +229,7 @@
       setLabel() {
           let addressList = this.data.addressList;
           if (addressList && addressList.length) {
-              const [v1, v2, v3] = this.data.value;
+              const [v1, v2, v3] = this.data.value; 
               const [s1, {
                   label: t1,
                   children: l1
@@ -195,6 +242,7 @@
                   label: t3
               }] = this.getAddressByCode(l2, v3);
               const label = [t1, t2, t3].filter(v => v).join('-');
+ 
               const pickerValue = [s1, s2, s3];
               const range = this.openChildren(addressList, [s1, s2, s3]);
               if (label.length) {
@@ -204,9 +252,7 @@
                       pickerValue
                   });
               }
-          } else {
-           
-          }
+          }  
       },
       // initRange鏂规硶鐢ㄤ簬鍒濆鍖杛ange
       initRange() {
diff --git a/wechat_jiaxuan/components/areaSel/areaSel.wxml b/wechat_jiaxuan/components/areaSel/areaSel.wxml
index 2d832e7..e1317ae 100644
--- a/wechat_jiaxuan/components/areaSel/areaSel.wxml
+++ b/wechat_jiaxuan/components/areaSel/areaSel.wxml
@@ -1,8 +1,8 @@
 <picker mode="multiSelector" model:value="{{pickerValue}}" range-key="label" range="{{range}}" bindchange="onChange"
 	bindcolumnchange="columnChange">
-	<view>
+	<view style="width:400rpx;padding-left: 30rpx;white-space: nowrap;text-overflow: ellipsis; overflow:hidden;">
 		<!-- 濡傛灉宸茬粡閫夋嫨浜嗛�夐」锛屽垯鏄剧ず閫夐」鐨刲abel灞炴�э紝鍚﹀垯鏄剧ずplaceholder灞炴�с�� -->
-		<text wx:if="{{label}}"> {{ label }} </text>
+		<text  wx:if="{{label}}"> {{ label }} </text>
 		<text style="color: #999" wx:else> {{ placeholder }}</text>
 	</view>
 </picker>
\ No newline at end of file
diff --git a/wechat_jiaxuan/pages/design/design.js b/wechat_jiaxuan/pages/design/design.js
index b0d9c9b..55b3173 100644
--- a/wechat_jiaxuan/pages/design/design.js
+++ b/wechat_jiaxuan/pages/design/design.js
@@ -13,11 +13,11 @@
    */
   data: {
     name: '',
-    phone: '', 
-    
+    phone: '',  
     showAreaList: false,
     areaList: [],
     addr: {},
+    addrValues:[],
     fieldNames: {
       text: 'name',
       value: 'id',
@@ -44,8 +44,10 @@
           areaCode: res.result.ad_info.adcode + '00',
           areaName: res.result.ad_info.district,
         }
-        this.setData({ addr })
-
+        this.setData({ addr,addrValues:
+          [res.result.ad_info.adcode.slice(0,2) + '0000',
+          res.result.ad_info.adcode.slice(0,4) + '00',
+          res.result.ad_info.adcode]  })    
       }
     })
     const member =  wx.getStorageSync('member')
@@ -154,37 +156,8 @@
     // getArea({
     //   "level": "",
     //   "pid": ""
-    // }).then(res => {
-    //   var tl = []
-    //   if(res && res.data && res.data.length){
-    //       res.data.forEach(element => { 
-    //           let tc = []
-    //           if(element.children &&element.children.length){
-    //             element.children.forEach(c => { 
-    //               let ta = []
-    //               if(c.children &&c.children.length){
-    //                 c.children.forEach(a => { 
-    //                   ta.push({
-    //                     name: a.name,
-    //                     id: a.id 
-    //                   })
-    //                 })
-    //               }
-    //               tc.push({
-    //                 name: c.name,
-    //                 id: c.id,
-    //                 children:ta,
-    //               })
-    //             })
-    //           }
-    //           tl.push({
-    //             name: element.name,
-    //             id: element.id,
-    //             children: tc,
-    //           })
-    //       });
-    //   }
-    //   this.setData({areaList: tl})
+    // }).then(res => {  
+    //   this.setData({areaList: res.data})
     //   console.log(this.data.areaList)
     // })
     getDictData({
diff --git a/wechat_jiaxuan/pages/design/design.wxml b/wechat_jiaxuan/pages/design/design.wxml
index d01cfad..a607aad 100644
--- a/wechat_jiaxuan/pages/design/design.wxml
+++ b/wechat_jiaxuan/pages/design/design.wxml
@@ -18,7 +18,7 @@
           {{ addr.provinceName }}{{ addr.cityName }}{{ addr.areaName }}
         </view>
       </picker> -->
-      <areaSel  bindchange="regionChange" placeholder="璇烽�夋嫨鎵�鍦ㄥ尯鍩�" value="{{['210000000','210500000','210501000']}}"  /> 
+      <areaSel  bindchange="regionChange" placeholder="璇烽�夋嫨鎵�鍦ㄥ尯鍩�" value="{{ addrValues }}"  /> 
       <image class="arrow_right" src="../../static/icon/arrow_right.png" mode="widthFix"></image>
     </view> 
     <view class="btn" bindtap="onSubmit">绔嬪嵆鎶ュ悕</view>
diff --git a/wechat_jiaxuan/pages/index/index.js b/wechat_jiaxuan/pages/index/index.js
index 02195f8..68ca702 100644
--- a/wechat_jiaxuan/pages/index/index.js
+++ b/wechat_jiaxuan/pages/index/index.js
@@ -84,6 +84,7 @@
     })
   },
   onLoad(options) {
+    console.log(options)
     this.initDictData()
     this.initData()
   },

--
Gitblit v1.9.3