Explorar o código

feat 个人用户门店管理弹出提示

Funny %!s(int64=3) %!d(string=hai) anos
pai
achega
ac91a48605

+ 9 - 7
src/components/shopAccount.vue

@@ -10,7 +10,6 @@
         </div>
       </el-col>
     </el-row>
-
     <el-row class="content">
       <component v-if="renderComponent" :is="activeName"></component>
     </el-row>
@@ -18,6 +17,7 @@
 </template>
 
 <script>
+import merchantAdd from "./merchantAdd.vue";
 import wallet from "./accountCompoents/wallet.vue";
 import coupon from "./accountCompoents/coupon.vue";
 import recharge from "./accountCompoents/recharge.vue";
@@ -35,15 +35,18 @@ export default {
     return {
       activeName: "wallet",
       tabList: [
-        { name: "我的钱包", index: 0,activeName: "wallet" },
-        { name: "优惠券", index: 1,activeName: "coupon" },
-        { name: "充值明细", index: 2,activeName: "recharge" },
-        { name: "消费明细", index: 3,activeName: "consumption" },
+        { name: "我的钱包", index: 0, activeName: "wallet" },
+        { name: "优惠券", index: 1, activeName: "coupon" },
+        { name: "充值明细", index: 2, activeName: "recharge" },
+        { name: "消费明细", index: 3, activeName: "consumption" },
       ],
       tabNum: 0,
       renderComponent: true,
     };
   },
+  created() {
+    this.changeTabs(0);
+  },
   methods: {
     forceRerender() {
       // 从 DOM 中删除 my-component 组件
@@ -59,10 +62,9 @@ export default {
         return;
       }
       this.tabNum = i;
-     this.activeName = this.tabList[i].activeName;
+      this.activeName = this.tabList[i].activeName;
     },
   },
-  mounted() {},
 };
 </script>
 

+ 11 - 4
src/components/shopCompoents/bindDelivery.vue

@@ -1,6 +1,6 @@
 <template>
   <div>
-    <div class="take-out-list">
+    <div v-if="deliveryList.length" class="take-out-list">
       <div class="item" v-for="(v, index) in deliveryList" :key="index">
         <div class="item-top">
           <div class="top-left">
@@ -37,6 +37,7 @@
         <div v-if="v.bindStatus === 3" class="respect">{{ v.authMsg }}</div>
       </div>
     </div>
+    <el-empty v-else description="暂无绑定配送平台!"></el-empty>
     <!-- UU跑腿 -->
     <el-dialog :title="title" :visible.sync="centerDialogVisible" width="40%" center>
       <el-form v-if="title === 'UU跑腿绑定'" :model="UUData" ref="UUData" label-width="80px" class="demo-ruleForm">
@@ -145,8 +146,10 @@ export default {
     },
   },
   created() {
-    this.getDeliveryList();
-    this.explainDelivery();
+    if (this.memberType !== 1) {
+      this.getDeliveryList();
+      this.explainDelivery();
+    }
   },
   // 1->达达
   // 2->蜂鸟即配
@@ -263,7 +266,11 @@ export default {
       } else {
         bindDelivery(params).then((res) => {
           if (res.code === 200) {
-            this.jumpUrl = res.data;
+            if (res.data) {
+              this.jumpUrl = res.data;
+            } else {
+              this.getDeliveryList();
+            }
           } else {
             this.$message({
               type: "error",

+ 35 - 37
src/components/shopCompoents/bindPrinter.vue

@@ -3,7 +3,7 @@
     <div class="store-list">
       <div class="store-list-item" @click="curIdx = index" :class=" index == curIdx ? 'active' : '' " v-for="(item, index) in shopList" :key="index">{{ item.name }}</div>
     </div>
-    <div class="header">
+    <div class="header" v-if="shopList.length">
       <div class="left">
         <div class="line">
           <div class="b_line"></div>
@@ -16,41 +16,42 @@
       </div>
     </div>
     <template v-if="printerList.length">
-      <div  class="take-out-list" v-for="(v,i) in printerList" :key="i">
-      <div class="item">
-        <div class="item-top">
-          <div class="name">{{v.name}}</div>
-        </div>
-        <div class="item-bottom">
-          <div class="left">
-            <div class="l-l">
-              <img :src="v.img" class="l-l-img" />
-            </div>
-            <div class="take-out-name">
-              <div class="take-out-name-bot">
-                <span :class="['status'+v.onlineStatus,'status']"> 打印机{{v.onlineStatus === 1 ? '在线' : v.onlineStatus === 2 ? '异常' : '离线'}}</span>
+      <div class="take-out-list" v-for="(v,i) in printerList" :key="i">
+        <div class="item">
+          <div class="item-top">
+            <div class="name">{{v.name}}</div>
+          </div>
+          <div class="item-bottom">
+            <div class="left">
+              <div class="l-l">
+                <img :src="v.img" class="l-l-img" />
               </div>
-              <div>打印机名称:{{v.deviceName}}</div>
-              <div>打印机编号:{{v.deviceSn}}</div>
-              <div class="take-out-name-bot">打印机KEY:{{v.deviceSecret}}</div>
-              <div class="print-num">
-                <div>客户联:X{{v.printCustomerCount}}</div>
-                <div>商家联:X{{v.printMerchantCount}}</div>
-                <div>厨房联:X{{v.printKitchenCount}}</div>
+              <div class="take-out-name">
+                <div class="take-out-name-bot">
+                  <span :class="['status'+v.onlineStatus,'status']"> 打印机{{v.onlineStatus === 1 ? '在线' : v.onlineStatus === 2 ? '异常' : '离线'}}</span>
+                </div>
+                <div>打印机名称:{{v.deviceName}}</div>
+                <div>打印机编号:{{v.deviceSn}}</div>
+                <div class="take-out-name-bot">打印机KEY:{{v.deviceSecret}}</div>
+                <div class="print-num">
+                  <div>客户联:X{{v.printCustomerCount}}</div>
+                  <div>商家联:X{{v.printMerchantCount}}</div>
+                  <div>厨房联:X{{v.printKitchenCount}}</div>
+                </div>
               </div>
             </div>
-          </div>
-          <div class="right">
-            <el-button @click="addPrinter(2,v)" size="small">编&nbsp;辑</el-button>
-            <el-button type="danger" @click="deletePrinter(v)" size="small">删&nbsp;除</el-button>
+            <div class="right">
+              <el-button @click="addPrinter(2,v)" size="small">编&nbsp;辑</el-button>
+              <el-button type="danger" @click="deletePrinter(v)" size="small">删&nbsp;除</el-button>
+            </div>
           </div>
         </div>
       </div>
-    </div>
     </template>
-    <div class="empty-img" v-else>
+    <el-empty v-else description="暂无绑定打印机!"></el-empty>
+    <!-- <div class="empty-img" v-else>
       <img src="../../../static/image/printer.png" />
-    </div>
+    </div> -->
     <printer-add @shopDeviceList="shopDeviceList(curIdx)" ref="printerAdd" :devices="deviceList"></printer-add>
   </div>
 </template>
@@ -74,11 +75,12 @@ export default {
     return {
       shopList: [],
       curIdx: -1,
-      loading: true,
+      loading: false,
       printerList: [],
       showVisible: false,
       title: "添加打印机",
       deviceList: [],
+      memberType: this.$store.state.userInfo.memberType
     };
   },
   watch: {
@@ -87,8 +89,10 @@ export default {
     },
   },
   created() {
-    this.getShopList();
-    this.getDeviceList();
+    if (this.memberType !== 1) {
+      this.getShopList();
+      this.getDeviceList();
+    }
   },
   methods: {
     deletePrinter(v) {
@@ -319,12 +323,6 @@ export default {
       }
     }
   }
-  .empty-img {
-    display: flex;
-    align-items: center;
-    justify-content: center;
-    background: #f9fafb;
-  }
   .category_box {
     display: flex;
     flex-wrap: wrap;

+ 25 - 17
src/components/shopCompoents/bindTakeOut.vue

@@ -3,7 +3,7 @@
     <div class="store-list">
       <div class="store-list-item" @click="curIdx = index" :class=" index === curIdx ? 'active' : '' " v-for="(item, index) in shopList" :key="index">{{ item.name }}</div>
     </div>
-    <div class="take-out-list">
+    <div v-if="takeOutList.length" class="take-out-list">
       <div class="item" v-for="(v,index) in takeOutList" :key="index">
         <div class="item-top">
           <div class="top-left">
@@ -33,6 +33,7 @@
         </div>
       </div>
     </div>
+    <el-empty v-else description="暂无绑定外卖平台!"></el-empty>
     <el-dialog title="绑定美团外卖" :visible.sync="centerDialogVisible" width="520px" center>
       <div class="bind">
         <div v-if="!showMT" @click="showMT = true" class="more">更多授权方式</div>
@@ -70,7 +71,7 @@ export default {
       curIdx: -1,
       jumpUrl: "",
       fullscreenLoading: false,
-      loading: true,
+      loading: false,
       centerDialogVisible: false,
       showMT: false,
       mtBindType: 1,
@@ -103,23 +104,30 @@ export default {
     },
   },
   created() {
-    getShopList().then((res) => {
-      this.loading = true;
-      getShopList().then((res) => {
-        if (res.code === 200) {
-          this.shopList = res.data;
-          this.curIdx = 0;
-        } else {
-          this.$message({
-            type: "error",
-            message: res.msg,
-          });
-        }
-        this.loading = false;
-      });
-    });
+    let memberType = this.$store.state.userInfo.memberType;
+    if (memberType !== 1) {
+      this.getShopList();
+    }
   },
   methods: {
+    getShopList() {
+      getShopList().then((res) => {
+        this.loading = true;
+        getShopList().then((res) => {
+          if (res.code === 200) {
+            this.shopList = res.data;
+            this.curIdx = 0;
+          } else {
+            this.$message({
+              type: "error",
+              message: res.msg,
+            });
+          }
+          this.loading = false;
+        });
+      });
+      F;
+    },
     getBindTakeOutList(index) {
       getBindTakeOutList({ shopId: this.shopList[index].id }).then((res) => {
         if (res.code === 200) {

+ 3 - 2
src/components/shopCompoents/shopList.vue

@@ -1,6 +1,6 @@
 <template>
   <div class="shopList">
-    <div class="header">
+    <div class="header" v-if="shopList.length">
       <div class="left">
         <div class="line">
           <div class="b_line"></div>
@@ -12,7 +12,7 @@
         <el-button class="btn" v-if="$store.state.userInfo.memberType === 2" @click.stop="addShop(1)">新增门店</el-button>
       </div>
     </div>
-    <el-table v-loading="loading" element-loading-text="数据加载中" :data="shopList" stripe header-row-class-name="table_h" style="width: 100%; margin-top: 10px">
+    <el-table v-if="shopList.length" v-loading="loading" element-loading-text="数据加载中" :data="shopList" stripe header-row-class-name="table_h" style="width: 100%; margin-top: 10px">
       <el-table-column prop="code" label="门店编号" width="170"></el-table-column>
       <el-table-column prop="name" label="门店名称" width="172" align="center"></el-table-column>
       <el-table-column prop="address" label="门店地址" width="321" align="center"></el-table-column>
@@ -32,6 +32,7 @@
         </template>
       </el-table-column>
     </el-table>
+    <el-empty v-else description="暂无门店数据!"></el-empty>
     <shop-add @getData="getData" ref="shopAdd" :products="productList"></shop-add>
   </div>
 </template>

+ 42 - 2
src/components/shopInfo.vue

@@ -16,18 +16,23 @@
         <component v-if="renderComponent" :is="activeName"></component>
       </el-col>
     </el-row>
+    <merchant-add ref="merchantAdd" :products="productList"></merchant-add>
+
   </div>
 </template>
 
 <script>
+import merchantAdd from "./merchantAdd.vue";
 import shopList from "./shopCompoents/shopList";
 import storeList from "./shopCompoents/bindTakeOut.vue";
 import deliveryList from "./shopCompoents/bindDelivery.vue";
 import printerList from "./shopCompoents/bindPrinter.vue";
 import bus from "../common/bus.js";
+import { getProductList } from "../api/shop.js";
 export default {
   name: "HelloWorld",
   components: {
+    merchantAdd,
     shopList,
     storeList,
     deliveryList,
@@ -45,17 +50,29 @@ export default {
       ],
       tabNum: 0,
       renderComponent: true,
+      productList: [],
+      memberType: this.$store.state.userInfo.memberType,
     };
   },
   created() {
+    this.getProductList();
     bus.$on("goPrinter", () => {
       this.changeTabs(3);
     });
-    let i = this.$route.query.tabNum;
+    let i = this.$route.params.tabNum;
     if (i) {
       this.changeTabs(Number(i));
     }
   },
+  beforeRouteEnter(to, from, next) {
+    next((vm) => {
+      if (from.name) {
+        vm.$nextTick(() => {
+          vm.changeTabs(0);
+        });
+      }
+    });
+  },
   mounted() {},
   methods: {
     forceRerender() {
@@ -67,6 +84,18 @@ export default {
       });
     },
     changeTabs(i) {
+      if (this.memberType === 1) {
+        this.$confirm("您当前还不是商户,请先申请成为商户!", "提示", {
+          confirmButtonText: "成为商户",
+          cancelButtonText: "取消",
+          type: "warning",
+          center: true,
+        })
+          .then(() => {
+            this.$refs.merchantAdd.init(0);
+          })
+          .catch(() => {});
+      }
       if (i === this.tabNum) {
         this.forceRerender();
         return;
@@ -74,8 +103,19 @@ export default {
       this.tabNum = i;
       this.activeName = this.tabList[i].activeName;
     },
+    getProductList() {
+      getProductList().then((res) => {
+        if (res.code === 200) {
+          this.productList = res.data;
+        } else {
+          this.$message({
+            type: "error",
+            message: res.msg,
+          });
+        }
+      });
+    },
   },
-  mounted() {},
 };
 </script>
 

+ 4 - 3
src/views/home.vue

@@ -38,7 +38,7 @@ export default {
     return {
       audio: null,
       productList: [],
-      memberType: this.$store.state.userInfo.memberType
+      memberType: this.$store.state.userInfo.memberType,
     };
   },
   computed: {
@@ -63,11 +63,12 @@ export default {
         .then(() => {
           this.$refs.merchantAdd.init(0);
         })
+        .catch(() => {});
     }
   },
 
   methods: {
-    showMerchant(){
+    showMerchant() {
       this.$refs.merchantAdd.init(0);
     },
     getProductList() {
@@ -85,7 +86,7 @@ export default {
     goPrinter() {
       this.$router.push({
         path: "/shopInfo/shopInfos",
-        query: {
+        params: {
           tabNum: 3,
         },
       });