Parcourir la source

店铺bug修改

caiyuqin il y a 2 mois
Parent
commit
7cd336a865
1 fichiers modifiés avec 23 ajouts et 67 suppressions
  1. 23 67
      pages/index/shop.vue

+ 23 - 67
pages/index/shop.vue

@@ -24,9 +24,9 @@
 								:disabled="true"></u-rate>
 							<span>{{shopData.grade}}分</span>
 						</view>
-						<span v-if="shopData.merchantStatus == 1">营业中</span>
-						<span v-if="shopData.merchantStatus == 3" style="color: #FF8024;">歇业中</span>
-						<span v-if="shopData.merchantStatus == 2" style="color: #999999;">门店关闭</span>
+						<span v-if="shopStatus == 1">营业中</span>
+						<span v-if="shopStatus == 5" style="color: #FF8024;">歇业中</span>
+						<span v-if="shopStatus == 2" style="color: #999999;">门店关闭</span>
 					</view>
 				</view>
 				<view class="address">
@@ -84,23 +84,19 @@
 		<view class="popup res" v-if="isSuccess">
 			<view class="content">
 				<view class="title">
-					<span v-show="shopStatus == 1">正常营业</span>
-					<span v-show="shopStatus == 3">门店歇业</span>
-					<span v-show="shopStatus == 2">关闭门店</span>
+					<span>{{btnList[currentIndex].name}}</span>
 				</view>
 				<view class="center">
 					<image src="/static/index/start.png" mode="" v-show="shopStatus == 1"></image>
 					<image src="/static/index/close.png" mode="" v-show="shopStatus == 2"></image>
-					<image src="/static/index/rest.png" mode="" v-show="shopStatus == 3"></image>
-					<span v-show="shopStatus == 1">恭喜发财,开业大吉!</span>
-					<span v-show="shopStatus == 2">当前门店关闭成功</span>
-					<span v-show="shopStatus == 3">当前门店已歇业</span>
+					<image src="/static/index/rest.png" mode="" v-show="shopStatus == 5"></image>
+					<span>{{btnList[currentIndex].tip}}</span>
 					<view class="error" v-show="shopStatus == 4">
 						当前门店还存在有效服务券<br />
 						暂时无法关闭门店
 					</view>
 				</view>
-				<view class="btn" :class="dynamicClass" @click="isSuccess = false">
+				<view class="btn" :class="btnList[currentIndex].class" @click="isSuccess = false">
 					确定
 				</view>
 			</view>
@@ -114,23 +110,32 @@
 			return {
 				btnList: [{
 						name: '正常营业',
+						type:1,
+						class:"start",
+						tip:"恭喜发财,开业大吉!"
+
 					},
 					{
 						name: '门店歇业',
+						type: 5,
+						class:"rest",
+						tip:"当前门店已歇业"
 					},
 					{
 						name: '关闭门店',
-					}
+						type:2,
+						class:"close",
+						tip:"当前门店关闭成功"
+					},
 				],
 				currentIndex: 0,
 				isPopup: false,
-				dynamicClass: 'start',
 				status: 3,
 				isSuccess: false,
 				count: 5,
 				shopData: {},
 				shopStatus: null,
-				id: ''
+				id: '',
 			}
 		},
 		methods: {
@@ -147,18 +152,17 @@
 			},
 			//切换状态
 			toggle(item, index) {
+        this.shopStatus=item.type
 				this.currentIndex = index
 			},
 			changeStatus() {
-				if (this.currentIndex == 0) {
-					let data = {
+				let data = {
 						id: this.id,
-						merchantStatus: 1
+						merchantStatus: this.shopStatus
 					}
 					this.$http.post("/merchant/localMerchantInfo/editStatus", data).then(res => {
 						if (res.data.code == 200) {
 							this.isPopup = false
-							this.getShopData()
 							this.isSuccess = true
 						}else {
               uni.showToast({
@@ -167,66 +171,18 @@
               })
             }
 					})
-				} else if (this.currentIndex == 1) {
-					let data = {
-						id: this.id,
-						merchantStatus: 3
-					}
-					this.$http.post("/merchant/localMerchantInfo/editStatus", data).then(res => {
-						if (res.data.code == 200) {
-							this.isPopup = false
-							this.getShopData()
-							this.isSuccess = true
-						}else {
-              uni.showToast({
-                icon: 'none',
-                title: res.data.message
-              })
-            }
-					})
-				} else if (this.currentIndex == 2) {
-					let data = {
-						id: this.id,
-						merchantStatus: 2
-					}
-					this.$http.post("/merchant/localMerchantInfo/editStatus", data).then(res => {
-						if (res.data.code == 200) {
-							this.isPopup = false
-							this.getShopData()
-							this.isSuccess = true
-						} else {
-							uni.showToast({
-								icon: 'none',
-								title: res.data.message
-							})
-						}
-					})
-				}
 			},
 			getShopData() {
 				this.$http.get("/merchant/localMerchantInfo/queryById?id=" + this.id).then(res => {
 					if (res.data.code == 200) {
 						this.shopData = res.data.result
 						this.shopStatus = res.data.result.merchantStatus
-						this.currentStatus()
+						this.currentIndex=this.btnList.findIndex(item => item.type == this.shopStatus);
 					}
 				})
 			},
-			currentStatus() {
-				if (this.shopStatus == 1) {
-					this.currentIndex = 0
-					this.dynamicClass = 'start'
-				} else if (this.shopStatus == 2) {
-					this.currentIndex = 2
-					this.dynamicClass = 'close'
-				} else if (this.shopStatus == 3) {
-					this.currentIndex = 1
-					this.dynamicClass = 'rest'
-				}
-			},
 			closePopup() {
 				this.isPopup = false
-				this.currentStatus()
 			}
 		},
 		mounted() {