Parcourir la source

切换门店的问题

wangn il y a 5 ans
Parent
commit
28969bc148
2 fichiers modifiés avec 52 ajouts et 11 suppressions
  1. 35 10
      hd/src/pages/layout/topbar/index.vue
  2. 17 1
      hd/src/service/common/index.js

+ 35 - 10
hd/src/pages/layout/topbar/index.vue

@@ -16,14 +16,10 @@
 				<span>{{ item.name }}</span>
 				<span>{{ item.name }}</span>
 			</el-menu-item>
 			</el-menu-item>
 		</el-menu> -->
 		</el-menu> -->
-    <el-dropdown class="user_top" trigger="click"> 
-		  <div  @click="chanceUser">23333&nbsp;<i class="el-icon-caret-bottom"></i></div>
+    <el-dropdown class="user_top" trigger="click" @command="shopCommand"> 
+		  <div>{{currentShop}}&nbsp;<i class="el-icon-caret-bottom"></i></div>
       <el-dropdown-menu slot="dropdown" class="popper-dropdown-menu-user">
       <el-dropdown-menu slot="dropdown" class="popper-dropdown-menu-user">
-        <el-dropdown-item>黄金糕</el-dropdown-item>
-        <el-dropdown-item>狮子头</el-dropdown-item>
-        <el-dropdown-item>螺蛳粉</el-dropdown-item>
-        <el-dropdown-item>双皮奶</el-dropdown-item>
-        <el-dropdown-item>蚵仔煎</el-dropdown-item>
+        <el-dropdown-item v-for="(item, index) in shopList" :key="index" :class="{'shopActive': item.id == userInfo.currentShopId}" :command="item">{{item.shopName}}</el-dropdown-item>
       </el-dropdown-menu>
       </el-dropdown-menu>
     </el-dropdown>
     </el-dropdown>
     <div class="flex1"></div>
     <div class="flex1"></div>
@@ -61,7 +57,8 @@ export default {
 	data() {
 	data() {
 		return {
 		return {
 			$projectName: this.$projectName,
 			$projectName: this.$projectName,
-			index: '0'
+			index: '0',
+      shopList: []
 		};
 		};
 	},
 	},
 
 
@@ -72,6 +69,7 @@ export default {
 		// 		this.SET_MENU_LIST(i);
 		// 		this.SET_MENU_LIST(i);
 		// 	}
 		// 	}
 		// });
 		// });
+    this.getAllShop()
 	},
 	},
 
 
 	computed: {
 	computed: {
@@ -81,7 +79,17 @@ export default {
 				return this.shopInfo.smallLogoUrl;
 				return this.shopInfo.smallLogoUrl;
 			}
 			}
 			return '';
 			return '';
-		}
+		},
+    currentShop() {
+      let str
+      this.shopList.map(ele => {
+        console.log(ele.id, this.userInfo.currentShopId)
+        if(ele.id == this.userInfo.currentShopId) {
+          str = ele.shopName
+        }
+      })
+      return str
+    }
 	},
 	},
 
 
 	methods: {
 	methods: {
@@ -109,7 +117,20 @@ export default {
 					});
 					});
 					break;
 					break;
 			}
 			}
-		}
+		},
+    shopCommand(item) {
+      console.log(item)
+      this.$service.common.toggleShop({shopId: item.id}).then(res => {
+        console.log('res', res)
+      }).catch(err => {})
+    },
+    // 获取门店
+    getAllShop() {
+      this.$service.common.shopAll().then(res => {
+        console.log(res)
+        this.shopList = res
+      }).catch(err => {})
+    }
 
 
 		// collapse() {
 		// collapse() {
 		// 	this.COLLAPSE_MENU(!this.menuCollapse);
 		// 	this.COLLAPSE_MENU(!this.menuCollapse);
@@ -267,5 +288,9 @@ export default {
 			margin-left: 10px;
 			margin-left: 10px;
 		}
 		}
 	}
 	}
+  .shopActive{
+    background-color: #ecf5ff!importnat;
+    color: #66b1ff!importnat;
+  }
 }
 }
 </style>
 </style>

+ 17 - 1
hd/src/service/common/index.js

@@ -229,11 +229,27 @@ export class CommonService extends BaseService {
 		});
 		});
 	}
 	}
 
 
-	updateStatus(params) {
+	updateStatus(params) {  
 		return this.request({
 		return this.request({
 			url: '/shop-admin/update-status',
 			url: '/shop-admin/update-status',
 			params
 			params
 		});
 		});
+  }
+  
+  // 获取门店列表  shop/toggle-shop
+  shopAll(params) {  
+		return this.request({
+			url: '/shop/all',
+			params
+		});
+  }
+  
+  // 切换门店
+  toggleShop(params) {  
+		return this.request({
+			url: '/shop/toggle-shop',
+			params
+		});
 	}
 	}
 }
 }