瀏覽代碼

代码优化

Funny 3 年之前
父節點
當前提交
2dc48563c0
共有 5 個文件被更改,包括 44 次插入58 次删除
  1. 17 3
      src/components/manualCreate.vue
  2. 1 0
      src/components/set.vue
  3. 12 25
      src/components/shopAccount.vue
  4. 13 29
      src/components/shopInfo.vue
  5. 1 1
      src/views/home.vue

+ 17 - 3
src/components/manualCreate.vue

@@ -116,9 +116,12 @@
 
       <!-- 选择门店 -->
       <el-dialog v-loading="loading" element-loading-text="拼命加载中" :title="sendType === 1 && addressType !== 2  ? '选择门店' : '常用地址'" :visible.sync="showChooseShop" width="600px" center>
-        <el-input placeholder="请输入姓名/手机号/地址" v-model="searchKey" @keydown.enter.native="seachEnterFun" clearable>
-          <el-button size="medium" type="primary" @click.stop="getData" slot="append" icon="el-icon-search"></el-button>
-        </el-input>
+        <div class="shop-top">
+          <div v-if="sendType === 0 || addressType === 2" class="management-address">地址管理</div>
+          <el-input size="small" placeholder="请输入姓名/手机号/地址" v-model="searchKey" @keydown.enter.native="seachEnterFun" clearable>
+            <el-button type="primary" @click.stop="getData" slot="append" icon="el-icon-search"></el-button>
+          </el-input>
+        </div>
         <div class="shop-list">
           <div @dblclick="chooseShop" @click="curIdx = index" :class=" curIdx === index ? 'shop-item active' : 'shop-item'" v-for="(shop,index) in addressList" :key="index">
             <div class="name">{{shop.name}}</div>
@@ -664,6 +667,17 @@ export default {
       margin-left: 20px;
     }
   }
+  .shop-top {
+    display: flex;
+    align-items: center;
+    margin-bottom: 10px;
+    .management-address {
+      flex-shrink: 0;
+      color: #fc7200;
+      margin-right: 15px;
+      cursor: pointer;
+    }
+  }
   .shop-list {
     height: 60vh;
     overflow: scroll;

+ 1 - 0
src/components/set.vue

@@ -29,6 +29,7 @@ export default {
       tab_list: [
         { name: "自动接单/语音设置", index: 0 },
         { name: "推荐/屏蔽运力", index: 1 },
+        { name: "常用地址", index: 2 },
       ],
       tab_ac: 0,
       activeName: "voiceSetting",

+ 12 - 25
src/components/shopAccount.vue

@@ -2,8 +2,8 @@
   <div class="shopInfo">
     <el-row class="order_tab">
       <el-col :span="15">
-        <div class="tab_list">
-          <div class="tab_item" @click="changeTabs(i)" :class="{'tab_item_ac':tab_ac==i?true:false}" v-for="(item,i) in tab_list" :key="i">
+        <div class="tabList">
+          <div class="tab_item" @click="changeTabs(i)" :class="{'tab_item_ac':tabNum==i?true:false}" v-for="(item,i) in tabList" :key="i">
             <span>{{item.name}}</span>
             <div class="tab_line"></div>
           </div>
@@ -34,13 +34,13 @@ export default {
   data() {
     return {
       activeName: "wallet",
-      tab_list: [
-        { name: "我的钱包", index: 0 },
-        { name: "优惠券", index: 1 },
-        { name: "充值明细", index: 2 },
-        { name: "消费明细", index: 3 },
+      tabList: [
+        { name: "我的钱包", index: 0,activeName: "wallet" },
+        { name: "优惠券", index: 1,activeName: "coupon" },
+        { name: "充值明细", index: 2,activeName: "recharge" },
+        { name: "消费明细", index: 3,activeName: "consumption" },
       ],
-      tab_ac: 0,
+      tabNum: 0,
       renderComponent: true,
     };
   },
@@ -54,25 +54,12 @@ export default {
       });
     },
     changeTabs(i) {
-      if (i === this.tab_ac) {
+      if (i === this.tabNum) {
         this.forceRerender();
         return;
       }
-      this.tab_ac = i;
-      switch (i) {
-        case 0:
-          this.activeName = "wallet";
-          break;
-        case 1:
-          this.activeName = "coupon";
-          break;
-        case 2:
-          this.activeName = "recharge";
-          break;
-        case 3:
-          this.activeName = "consumption";
-          break;
-      }
+      this.tabNum = i;
+     this.activeName = this.tabList[i].activeName;
     },
   },
   mounted() {},
@@ -87,7 +74,7 @@ export default {
     height: 74px;
     background: #fff;
 
-    .tab_list {
+    .tabList {
       width: 100%;
       height: 74px;
       padding-top: 20px;

+ 13 - 29
src/components/shopInfo.vue

@@ -2,8 +2,8 @@
   <div class="shopInfo">
     <el-row class="order_tab">
       <el-col :span="24">
-        <div class="tab_list">
-          <div class="tab_item" @click="changeTabs(i)" :class="{'tab_item_ac':tab_ac==i?true:false}" v-for="(item,i) in tab_list" :key="i">
+        <div class="tabList">
+          <div class="tab_item" @click="changeTabs(i)" :class="{'tab_item_ac':tabNum==i?true:false}" v-for="(item,i) in tabList" :key="i">
             <span>{{item.name}}</span>
             <div class="tab_line"></div>
           </div>
@@ -37,13 +37,13 @@ export default {
   data() {
     return {
       activeName: "shopList",
-      tab_list: [
-        { name: "门店列表", index: 0 },
-        { name: "绑定外卖平台", index: 1 },
-        { name: "绑定配送平台", index: 2 },
-        { name: "绑定打印机", index: 3 },
+      tabList: [
+        { name: "门店列表", index: 0, activeName: "shopList" },
+        { name: "绑定外卖平台", index: 1, activeName: "storeList" },
+        { name: "绑定配送平台", index: 2, activeName: "deliveryList" },
+        { name: "绑定打印机", index: 3, activeName: "printerList" },
       ],
-      tab_ac: 0,
+      tabNum: 0,
       renderComponent: true,
     };
   },
@@ -51,7 +51,7 @@ export default {
     bus.$on("goPrinter", () => {
       this.changeTabs(3);
     });
-    let i = this.$route.query.tab_ac;
+    let i = this.$route.query.tabNum;
     if (i) {
       this.changeTabs(Number(i));
     }
@@ -67,28 +67,12 @@ export default {
       });
     },
     changeTabs(i) {
-      if (i === this.tab_ac) {
+      if (i === this.tabNum) {
         this.forceRerender();
         return;
       }
-      this.tab_ac = i;
-      switch (i) {
-        case 0:
-          this.activeName = "shopList";
-          break;
-        case 1:
-          this.activeName = "storeList";
-          break;
-        case 2:
-          this.activeName = "deliveryList";
-          break;
-        case 3:
-          this.activeName = "printerList";
-          break;
-        default:
-          this.activeName = "shopList";
-          break;
-      }
+      this.tabNum = i;
+      this.activeName = this.tabList[i].activeName;
     },
   },
   mounted() {},
@@ -103,7 +87,7 @@ export default {
     height: 74px;
     background: #fff;
 
-    .tab_list {
+    .tabList {
       width: 100%;
       height: 74px;
       padding-top: 20px;

+ 1 - 1
src/views/home.vue

@@ -51,7 +51,7 @@ export default {
       this.$router.push({
         path: "/shopInfo/shopInfos",
         query: {
-          tab_ac: 3,
+          tabNum: 3,
         },
       });
       if(this.$route.name === 'shopInfos'){