Browse Source

feat: address

suzigang 4 years ago
parent
commit
7773f3997c

+ 2 - 0
package.json

@@ -73,6 +73,7 @@
     "@tarojs/taro": "^3.3.0-alpha.8",
     "@types/jest": "^26.0.22",
     "@types/node": "^14.14.31",
+    "@types/pinyin": "^2.8.3",
     "@vitejs/plugin-legacy": "^1.4.0",
     "@vitejs/plugin-vue": "^1.2.2",
     "@vue/compiler-sfc": "^3.0.11",
@@ -89,6 +90,7 @@
     "husky": "^6.0.0",
     "jest": "^26.6.3",
     "lint-staged": "^10.5.0",
+    "pinyin": "^2.10.2",
     "prettier": "^2.0.0",
     "standard-version": "^9.3.0",
     "transliteration": "^2.2.0",

+ 14 - 5
src/packages/__VUE/address/demo.vue

@@ -128,13 +128,16 @@ export default createDemo({
         { id: 1, name: '北京' },
         { id: 2, name: '广西' },
         { id: 3, name: '江西' },
-        { id: 4, name: '四川' }
+        { id: 4, name: '四川' },
+        { id: 5, name: '浙江' }
       ],
       city: [
         { id: 7, name: '朝阳区' },
         { id: 8, name: '崇文区' },
         { id: 9, name: '昌平区' },
-        { id: 6, name: '石景山区' }
+        { id: 6, name: '石景山区' },
+        { id: 3, name: '八里庄街道' },
+        { id: 9, name: '北苑' }
       ],
       country: [
         { id: 3, name: '八里庄街道' },
@@ -166,7 +169,9 @@ export default createDemo({
         countyName: '通州区',
         provinceName: '北京市',
         selectedAddress: true,
-        townName: ''
+        townName: '',
+        name: '探探鱼',
+        phone: '182****1718'
       },
       {
         id: 2,
@@ -175,7 +180,9 @@ export default createDemo({
         countyName: '',
         provinceName: '钓鱼岛',
         selectedAddress: false,
-        townName: ''
+        townName: '',
+        name: '探探鱼',
+        phone: '182****1718'
       },
       {
         id: 3,
@@ -184,7 +191,9 @@ export default createDemo({
         countyName: '科创十一街18号院',
         provinceName: '北京市',
         selectedAddress: false,
-        townName: ''
+        townName: '',
+        name: '探探鱼',
+        phone: '182****1718'
       }
     ]);
 

+ 71 - 7
src/packages/__VUE/address/index.scss

@@ -61,20 +61,42 @@
 
     .region-con {
       display: block;
-      margin: 20px 20px 0;
+      margin: 20px 0 0;
+      position: relative;
       .region-group {
-        padding-top: 15px;
         height: 270px;
         overflow-y: auto;
 
         .region-item {
-          display: flex;
-          align-items: center;
-          margin-bottom: 20px;
           font-size: $font-size-1;
           color: #333;
-          &.active {
-            font-weight: bold;
+          &-code {
+            position: relative;
+            height: 35px;
+            line-height: 35px;
+            font-size: $font-size-2;
+            color: $title-color;
+            padding: 0 20px;
+            font-weight: 500;
+            &:after {
+              content: ' ';
+              width: 100%;
+              height: 1px;
+              position: absolute;
+              left: 0;
+              bottom: 0;
+              background-color: $help-color;
+            }
+          }
+          &-name {
+            display: flex;
+            align-items: center;
+            padding: 0 20px;
+            height: 30px;
+            line-height: 30px;
+            &.active {
+              font-weight: bold;
+            }
           }
 
           .region-item-icon {
@@ -82,6 +104,36 @@
           }
         }
       }
+      &-current-code {
+        position: absolute;
+        right: 60px;
+        top: 50%;
+        transform: translateY(-50%);
+        width: 45px;
+        height: 45px;
+        line-height: 45px;
+        border-radius: 50%;
+        background: $white;
+        box-shadow: 0 3px 3px 1px rgba(240, 240, 240, 1);
+        text-align: center;
+      }
+      &-codes-wrapper {
+        position: absolute;
+        right: 8px;
+        top: 50%;
+        transform: translateY(-50%);
+        padding: 15px 0;
+        background-color: #eeeff2;
+        border-radius: 6px;
+        text-align: center;
+        z-index: 10;
+      }
+      &-codes {
+        &-item {
+          padding: 3px;
+          font-size: $font-size-0;
+        }
+      }
     }
   }
 
@@ -97,6 +149,7 @@
 
       .exist-ul {
         .exist-item {
+          width: 100%;
           display: flex;
           align-items: center;
           margin-bottom: 20px;
@@ -107,8 +160,19 @@
             font-weight: bold;
           }
           .exist-item-icon {
+            width: 15px;
             margin-right: 9px;
           }
+          &-info {
+            flex: 1;
+            &-top {
+              display: flex;
+              justify-content: space-between;
+              margin-bottom: 10px;
+              color: #292929;
+              font-size: 14px;
+            }
+          }
           span {
             display: inline-block;
             flex: 1;

+ 184 - 44
src/packages/__VUE/address/index.taro.vue

@@ -44,7 +44,6 @@
           >
             <view>{{ getTabName(item, index) }}</view>
           </view-block>
-
           <view-block
             class="region-tab-line"
             ref="regionLine"
@@ -52,28 +51,60 @@
           ></view-block>
         </view-block>
 
-        <view-block class="region-con">
-          <ul class="region-group">
+        <view-block
+          class="region-con"
+          v-if="regionList[tabName[tabIndex]].length"
+        >
+          <ul class="region-group" ref="listview">
             <li
-              v-for="(item, index) in regionList[tabName[tabIndex]]"
-              :key="index"
               class="region-item"
-              :class="[
-                selectedRegion[tabName[tabIndex]].id == item.id ? 'active' : ''
-              ]"
-              @click="nextAreaList(item)"
+              v-for="item in regionList[tabName[tabIndex]]"
+              :key="item.title"
+              :ref="setListGroup"
             >
-              <nut-icon
-                class="region-item-icon"
-                type="self"
-                :name="selectedIcon"
-                color="#FA2C19"
-                size="13px"
-                v-if="selectedRegion[tabName[tabIndex]].id == item.id"
-              ></nut-icon
-              >{{ item.name }}
+              <div class="region-item-code">{{ item.title }}</div>
+              <div
+                class="region-item-name"
+                v-for="subitem in item.list"
+                :key="subitem.id"
+                :class="[
+                  selectedRegion[tabName[tabIndex]].id == subitem.id
+                    ? 'active'
+                    : ''
+                ]"
+                @click="nextAreaList(subitem)"
+              >
+                <nut-icon
+                  class="region-item-icon"
+                  type="self"
+                  :name="selectedIcon"
+                  color="#FA2C19"
+                  size="13px"
+                  v-if="selectedRegion[tabName[tabIndex]].id == subitem.id"
+                ></nut-icon>
+                {{ subitem.name }}
+              </div>
             </li>
           </ul>
+          <div class="region-con-current-code" v-show="scrollStart">{{
+            regionList[tabName[tabIndex]][currentIndex].title
+          }}</div>
+          <div
+            class="region-con-codes-wrapper"
+            @touchstart="touchStart"
+            @touchmove.stop.prevent="touchMove"
+            @touchend="touchEnd"
+          >
+            <div class="region-con-codes">
+              <div
+                class="region-con-codes-item"
+                :data-index="index"
+                v-for="(item, index) in regionList[tabName[tabIndex]]"
+                :key="item.title"
+                >{{ item.title }}</div
+              >
+            </div>
+          </div>
         </view-block>
       </view-block>
 
@@ -96,13 +127,23 @@
                 size="13px"
               ></nut-icon>
 
-              <view>{{
-                item.provinceName +
-                item.cityName +
-                item.countyName +
-                item.townName +
-                item.addressDetail
-              }}</view>
+              <div class="exist-item-info">
+                <div class="exist-item-info-top" v-if="item.name && item.phone">
+                  <div class="exist-item-info-name">{{ item.name }}</div>
+                  <div class="exist-item-info-phone">{{ item.phone }}</div>
+                </div>
+                <div class="exist-item-info-bottom">
+                  <view>
+                    {{
+                      item.provinceName +
+                      item.cityName +
+                      item.countyName +
+                      item.townName +
+                      item.addressDetail
+                    }}
+                  </view>
+                </div>
+              </div>
             </li>
           </ul>
         </div>
@@ -119,11 +160,21 @@
   </nut-popup>
 </template>
 <script lang="ts">
-import { reactive, ref, toRefs, watch, nextTick, computed } from 'vue';
+import {
+  reactive,
+  ref,
+  toRefs,
+  watch,
+  nextTick,
+  computed,
+  Ref,
+  onMounted
+} from 'vue';
 import { createComponent } from '../../utils/create';
 import Icon from '../icon/index.taro.vue';
 import Popup from '../popup/index.taro.vue';
 import Taro from '@tarojs/taro';
+import { transformData } from './transformData';
 
 const { create, componentName } = createComponent('address');
 
@@ -252,10 +303,10 @@ export default create({
     const tabName = ref(['province', 'city', 'country', 'town']);
 
     const regionList = reactive({
-      province: props.province,
-      city: props.city,
-      country: props.country,
-      town: props.town
+      province: transformData(props.province),
+      city: transformData(props.city),
+      country: transformData(props.country),
+      town: transformData(props.town)
     });
 
     const selectedRegion = reactive({
@@ -271,6 +322,20 @@ export default create({
 
     const lineDistance = ref(20);
 
+    const listview = ref(null);
+
+    const scrollState = reactive({
+      anchorIndex: 0,
+      listHeight: [] as number[],
+      listGroup: [] as HTMLLIElement[],
+      touchState: {
+        y1: 0,
+        y2: 0
+      },
+      scrollStart: false,
+      currentIndex: 0
+    });
+
     //获取已选地区列表名称
     const getTabName = (item: RegionData, index: number) => {
       if (item.name) return item.name;
@@ -293,13 +358,25 @@ export default create({
     const clickOverlay = () => {
       closeWay.value = 'mask';
     };
+    //重置滚动参数
+    const resetScrollState = () => {
+      scrollState.anchorIndex = 0;
+      scrollState.listHeight = [];
+      scrollState.listGroup = [];
+      scrollState.currentIndex = 0;
+      scrollState.scrollStart = false;
+      scrollState.touchState = {
+        y1: 0,
+        y2: 0
+      };
+    };
     // 移动下面的红线
     const lineAnimation = () => {
       setTimeout(() => {
         Taro.createSelectorQuery()
           .selectAll(`.${tabName.value[tabIndex.value]}`)
           .boundingClientRect((rects) => {
-            (rects as any).forEach((rect) => {
+            (rects as any).forEach((rect: any) => {
               if (rect.width > 0) lineDistance.value = rect.left;
             });
           })
@@ -323,9 +400,7 @@ export default create({
 
       if (tabIndex.value < 3) {
         tabIndex.value = tabIndex.value + 1;
-
         lineAnimation();
-
         // 切换下一个
         calBack.next = tabName.value[tabIndex.value];
         calBack.value = item as string;
@@ -333,6 +408,9 @@ export default create({
       } else {
         handClose();
       }
+
+      resetScrollState();
+      (listview.value as any).scrollTo(0, 0);
     };
     //切换地区Tab
     const changeRegionTab = (item: RegionData, key: number, index: number) => {
@@ -427,18 +505,75 @@ export default create({
       emit('switch-module', { type: privateType.value });
     };
 
+    const getData = (el: any, name: string, val?: string) => {
+      const prefix = 'data-';
+      if (val) {
+        return el.setAttribute(prefix + name, val);
+      }
+      return +el.getAttribute(prefix + name);
+    };
+
+    const setListGroup = (el: HTMLLIElement) => {
+      nextTick(() => {
+        if (!scrollState.listGroup.includes(el) && el != null) {
+          scrollState.listGroup.push(el);
+        }
+      });
+    };
+
+    const calculateHeight = () => {
+      let height = 0;
+      scrollState.listHeight.push(height);
+      for (let i = 0; i < scrollState.listGroup.length; i++) {
+        let item = scrollState.listGroup[i];
+        height += item.clientHeight;
+        scrollState.listHeight.push(height);
+      }
+    };
+
+    const scrollTo = (index: number) => {
+      if (!index && index !== 0) {
+        return;
+      }
+      if (!scrollState.listHeight.length) {
+        calculateHeight();
+      }
+      if (index < 0) index = 0;
+      if (index > scrollState.listHeight.length - 2)
+        index = scrollState.listHeight.length - 2;
+      scrollState.currentIndex = index;
+      (listview.value as any).scrollTo(0, scrollState.listHeight[index]);
+    };
+
+    const touchStart = (e: TouchEvent) => {
+      scrollState.scrollStart = true;
+      let index = getData(e.target, 'index');
+      let firstTouch = e.touches[0];
+      scrollState.touchState.y1 = firstTouch.pageY;
+      scrollState.anchorIndex = index;
+      scrollState.currentIndex = index;
+      scrollTo(index);
+    };
+
+    const touchMove = (e: TouchEvent) => {
+      let firstTouch = e.touches[0];
+      scrollState.touchState.y2 = firstTouch.pageY;
+      let delta =
+        ((scrollState.touchState.y2 - scrollState.touchState.y1) / 23) | 0;
+      scrollState.currentIndex = scrollState.anchorIndex + delta;
+      scrollTo(scrollState.currentIndex);
+    };
+
+    const touchEnd = (e: TouchEvent) => {
+      resetScrollState();
+    };
+
     watch(
       () => props.visible,
       (value) => {
         showPopup.value = value;
       }
     );
-    // watch(
-    //   () => props.type,
-    //   (value) => {
-    //     privateType.value = value;
-    //   }
-    // );
 
     watch(
       () => showPopup.value,
@@ -452,32 +587,31 @@ export default create({
     watch(
       () => props.province,
       (value) => {
-        regionList.province = value;
+        regionList.province = transformData(value);
       }
     );
     watch(
       () => props.city,
       (value) => {
-        regionList.city = value;
+        regionList.city = transformData(value);
       }
     );
     watch(
       () => props.country,
       (value) => {
-        regionList.country = value;
+        regionList.country = transformData(value);
       }
     );
     watch(
       () => props.town,
       (value) => {
-        regionList.town = value;
+        regionList.town = transformData(value);
       }
     );
 
     watch(
       () => props.existAddress,
       (value) => {
-        //  existAddress.value = value;
         value.forEach((item, index) => {
           if ((item as AddressList).selectedAddress) {
             selectedExistAddress = item as {};
@@ -506,6 +640,12 @@ export default create({
       selectedExist,
       clickOverlay,
       handClose,
+      touchStart,
+      touchMove,
+      touchEnd,
+      setListGroup,
+      listview,
+      ...toRefs(scrollState),
       ...toRefs(props),
       ...toRefs(tabItemRef)
     };

+ 170 - 42
src/packages/__VUE/address/index.vue

@@ -51,28 +51,57 @@
           ></view>
         </view>
 
-        <view class="region-con">
-          <ul class="region-group">
+        <view class="region-con" v-if="regionList[tabName[tabIndex]].length">
+          <ul class="region-group" ref="listview">
             <li
-              v-for="(item, index) in regionList[tabName[tabIndex]]"
-              :key="index"
               class="region-item"
-              :class="[
-                selectedRegion[tabName[tabIndex]].id == item.id ? 'active' : ''
-              ]"
-              @click="nextAreaList(item)"
+              v-for="item in regionList[tabName[tabIndex]]"
+              :key="item.title"
+              :ref="setListGroup"
             >
-              <nut-icon
-                class="region-item-icon"
-                type="self"
-                :name="selectedIcon"
-                color="#FA2C19"
-                size="13px"
-                v-if="selectedRegion[tabName[tabIndex]].id == item.id"
-              ></nut-icon
-              >{{ item.name }}
+              <div class="region-item-code">{{ item.title }}</div>
+              <div
+                class="region-item-name"
+                v-for="subitem in item.list"
+                :key="subitem.id"
+                :class="[
+                  selectedRegion[tabName[tabIndex]].id == subitem.id
+                    ? 'active'
+                    : ''
+                ]"
+                @click="nextAreaList(subitem)"
+              >
+                <nut-icon
+                  class="region-item-icon"
+                  type="self"
+                  :name="selectedIcon"
+                  color="#FA2C19"
+                  size="13px"
+                  v-if="selectedRegion[tabName[tabIndex]].id == subitem.id"
+                ></nut-icon>
+                {{ subitem.name }}
+              </div>
             </li>
           </ul>
+          <div class="region-con-current-code" v-show="scrollStart">{{
+            regionList[tabName[tabIndex]][currentIndex].title
+          }}</div>
+          <div
+            class="region-con-codes-wrapper"
+            @touchstart="touchStart"
+            @touchmove.stop.prevent="touchMove"
+            @touchend="touchEnd"
+          >
+            <div class="region-con-codes">
+              <div
+                class="region-con-codes-item"
+                :data-index="index"
+                v-for="(item, index) in regionList[tabName[tabIndex]]"
+                :key="item.title"
+                >{{ item.title }}</div
+              >
+            </div>
+          </div>
         </view>
       </view>
 
@@ -94,14 +123,23 @@
                 :color="item.selectedAddress ? '#FA2C19' : ''"
                 size="13px"
               ></nut-icon>
-
-              <view>{{
-                item.provinceName +
-                item.cityName +
-                item.countyName +
-                item.townName +
-                item.addressDetail
-              }}</view>
+              <div class="exist-item-info">
+                <div class="exist-item-info-top" v-if="item.name && item.phone">
+                  <div class="exist-item-info-name">{{ item.name }}</div>
+                  <div class="exist-item-info-phone">{{ item.phone }}</div>
+                </div>
+                <div class="exist-item-info-bottom">
+                  <view>
+                    {{
+                      item.provinceName +
+                      item.cityName +
+                      item.countyName +
+                      item.townName +
+                      item.addressDetail
+                    }}
+                  </view>
+                </div>
+              </div>
             </li>
           </ul>
         </div>
@@ -118,8 +156,9 @@
   </nut-popup>
 </template>
 <script lang="ts">
-import { reactive, ref, toRefs, watch, nextTick } from 'vue';
+import { reactive, ref, toRefs, watch, nextTick, Ref, onMounted } from 'vue';
 import { createComponent } from '../../utils/create';
+import { transformData } from './transformData';
 const { componentName, create } = createComponent('address');
 interface RegionData {
   name: string;
@@ -235,10 +274,10 @@ export default create({
     const tabName = ref(['province', 'city', 'country', 'town']);
 
     const regionList = reactive({
-      province: props.province,
-      city: props.city,
-      country: props.country,
-      town: props.town
+      province: transformData(props.province),
+      city: transformData(props.city),
+      country: transformData(props.country),
+      town: transformData(props.town)
     });
 
     const selectedRegion = reactive({
@@ -254,6 +293,20 @@ export default create({
 
     const lineDistance = ref(20);
 
+    const listview = ref(null);
+
+    const scrollState = reactive({
+      anchorIndex: 0,
+      listHeight: [] as number[],
+      listGroup: [] as HTMLLIElement[],
+      touchState: {
+        y1: 0,
+        y2: 0
+      },
+      scrollStart: false,
+      currentIndex: 0
+    });
+
     //获取已选地区列表名称
     const getTabName = (item: RegionData, index: number) => {
       if (item.name) return item.name;
@@ -276,6 +329,18 @@ export default create({
     const clickOverlay = () => {
       closeWay.value = 'mask';
     };
+    //重置滚动参数
+    const resetScrollState = () => {
+      scrollState.anchorIndex = 0;
+      scrollState.listHeight = [];
+      scrollState.listGroup = [];
+      scrollState.currentIndex = 0;
+      scrollState.scrollStart = false;
+      scrollState.touchState = {
+        y1: 0,
+        y2: 0
+      };
+    };
     // 移动下面的红线
     const lineAnimation = () => {
       const name = (tabItemRef as any)[tabName.value[tabIndex.value]];
@@ -283,7 +348,6 @@ export default create({
         if (name) {
           const distance = name.offsetLeft;
           lineDistance.value = distance;
-          console.log(name);
         }
       });
     };
@@ -314,6 +378,8 @@ export default create({
       } else {
         handClose();
       }
+      resetScrollState();
+      (listview.value as any).scrollTo(0, 0);
     };
     //切换地区Tab
     const changeRegionTab = (item: RegionData, key: number, index: number) => {
@@ -408,18 +474,75 @@ export default create({
       emit('switch-module', { type: privateType.value });
     };
 
+    const getData = (el: any, name: string, val?: string) => {
+      const prefix = 'data-';
+      if (val) {
+        return el.setAttribute(prefix + name, val);
+      }
+      return +el.getAttribute(prefix + name);
+    };
+
+    const setListGroup = (el: HTMLLIElement) => {
+      nextTick(() => {
+        if (!scrollState.listGroup.includes(el) && el != null) {
+          scrollState.listGroup.push(el);
+        }
+      });
+    };
+
+    const calculateHeight = () => {
+      let height = 0;
+      scrollState.listHeight.push(height);
+      for (let i = 0; i < scrollState.listGroup.length; i++) {
+        let item = scrollState.listGroup[i];
+        height += item.clientHeight;
+        scrollState.listHeight.push(height);
+      }
+    };
+
+    const scrollTo = (index: number) => {
+      if (!index && index !== 0) {
+        return;
+      }
+      if (!scrollState.listHeight.length) {
+        calculateHeight();
+      }
+      if (index < 0) index = 0;
+      if (index > scrollState.listHeight.length - 2)
+        index = scrollState.listHeight.length - 2;
+      scrollState.currentIndex = index;
+      (listview.value as any).scrollTo(0, scrollState.listHeight[index]);
+    };
+
+    const touchStart = (e: TouchEvent) => {
+      scrollState.scrollStart = true;
+      let index = getData(e.target, 'index');
+      let firstTouch = e.touches[0];
+      scrollState.touchState.y1 = firstTouch.pageY;
+      scrollState.anchorIndex = index;
+      scrollState.currentIndex = index;
+      scrollTo(index);
+    };
+
+    const touchMove = (e: TouchEvent) => {
+      let firstTouch = e.touches[0];
+      scrollState.touchState.y2 = firstTouch.pageY;
+      let delta =
+        ((scrollState.touchState.y2 - scrollState.touchState.y1) / 23) | 0;
+      scrollState.currentIndex = scrollState.anchorIndex + delta;
+      scrollTo(scrollState.currentIndex);
+    };
+
+    const touchEnd = (e: TouchEvent) => {
+      resetScrollState();
+    };
+
     watch(
       () => props.visible,
       (value) => {
         showPopup.value = value;
       }
     );
-    // watch(
-    //   () => props.type,
-    //   (value) => {
-    //     privateType.value = value;
-    //   }
-    // );
 
     watch(
       () => showPopup.value,
@@ -433,28 +556,27 @@ export default create({
     watch(
       () => props.province,
       (value) => {
-        regionList.province = value;
+        regionList.province = transformData(value);
       }
     );
     watch(
       () => props.city,
       (value) => {
-        regionList.city = value;
+        regionList.city = transformData(value);
       }
     );
     watch(
       () => props.country,
       (value) => {
-        regionList.country = value;
+        regionList.country = transformData(value);
       }
     );
     watch(
       () => props.town,
       (value) => {
-        regionList.town = value;
+        regionList.town = transformData(value);
       }
     );
-
     watch(
       () => props.existAddress,
       (value) => {
@@ -486,6 +608,12 @@ export default create({
       selectedExist,
       clickOverlay,
       handClose,
+      touchStart,
+      touchMove,
+      touchEnd,
+      setListGroup,
+      listview,
+      ...toRefs(scrollState),
       ...toRefs(props),
       ...toRefs(tabItemRef)
     };

+ 46 - 0
src/packages/__VUE/address/transformData.ts

@@ -0,0 +1,46 @@
+import pinyin from 'pinyin';
+
+interface Region {
+  title: string;
+  list: any[];
+}
+
+export const transformData = (regionData: any[]) => {
+  if (!Array.isArray(regionData)) throw new TypeError('params muse be array.');
+
+  if (!regionData.length) return [];
+
+  const newData: Region[] = [];
+
+  regionData = regionData.map((item: any) => {
+    if (!item.name) return new Error('the data must includes `name` props');
+    let code = pinyin(item.name);
+    return {
+      ...item,
+      firstCode: code[0][0].charAt(0).toUpperCase()
+    };
+  });
+
+  regionData = regionData.sort((a: any, b: any) => {
+    return a.firstCode.localeCompare(b.firstCode);
+  });
+
+  regionData.forEach((item: any) => {
+    const index = newData.findIndex(
+      (value: any) => value.title === item.firstCode
+    );
+    if (index <= -1) {
+      newData.push({
+        title: item.firstCode,
+        list: [].concat(item)
+      });
+    } else {
+      newData[index] = {
+        title: item.firstCode,
+        list: newData[index].list.concat(item)
+      };
+    }
+  });
+
+  return newData;
+};

+ 14 - 5
src/sites/mobile-taro/vue/src/business/pages/address/index.vue

@@ -127,13 +127,16 @@ export default {
         { id: 1, name: '北京' },
         { id: 2, name: '广西' },
         { id: 3, name: '江西' },
-        { id: 4, name: '四川' }
+        { id: 4, name: '四川' },
+        { id: 5, name: '浙江' }
       ],
       city: [
         { id: 7, name: '朝阳区' },
         { id: 8, name: '崇文区' },
         { id: 9, name: '昌平区' },
-        { id: 6, name: '石景山区' }
+        { id: 6, name: '石景山区' },
+        { id: 3, name: '八里庄街道' },
+        { id: 9, name: '北苑' }
       ],
       country: [
         { id: 3, name: '八里庄街道' },
@@ -165,7 +168,9 @@ export default {
         countyName: '通州区',
         provinceName: '北京市',
         selectedAddress: true,
-        townName: ''
+        townName: '',
+        name: '探探鱼',
+        phone: '182****1718'
       },
       {
         id: 2,
@@ -174,7 +179,9 @@ export default {
         countyName: '',
         provinceName: '钓鱼岛',
         selectedAddress: false,
-        townName: ''
+        townName: '',
+        name: '探探鱼',
+        phone: '182****1718'
       },
       {
         id: 3,
@@ -183,7 +190,9 @@ export default {
         countyName: '科创十一街18号院',
         provinceName: '北京市',
         selectedAddress: false,
-        townName: ''
+        townName: '',
+        name: '探探鱼',
+        phone: '182****1718'
       }
     ]);