Parcourir la source

上下架状态bug

ltx529596 il y a 4 ans
Parent
commit
1528692d67
2 fichiers modifiés avec 30 ajouts et 20 suppressions
  1. 29 19
      src/pages/shop/shop.vue
  2. 1 1
      src/utils/request/request.js

+ 29 - 19
src/pages/shop/shop.vue

@@ -67,6 +67,7 @@
       </view>
     </view>
     <view style="height: 192upx;"></view>
+    <!-- 审核 -->
     <view class="order-content" v-if="isactive === 1">
       <view class="order-list" v-for="(item, index) in shoplist" :key="index">
         <view class="order-title">
@@ -99,6 +100,7 @@
         </view>
       </view>
     </view>
+    <!-- 已上架 -->
     <view class="order-content" v-if="isactive === 2">
       <view class="order-list" v-for="(item, index) in shoplist" :key="index">
         <view class="order-title">
@@ -131,6 +133,7 @@
         </view>
       </view>
     </view>
+    <!-- 已下架 -->
     <view class="order-content" v-if="isactive === 3">
       <view class="order-list" v-for="(item, index) in shoplist" :key="index">
         <view class="order-title">
@@ -143,23 +146,17 @@
           <view class="center">
             <view class="shop-detail door">所属店铺:{{ item.shopName }}</view>
             <view class="shop-detail type">类型:{{ item.typeName }}</view>
-            <view class="shop-detail putaway"
-              >上下架状态:{{ item.upDown | putaway }}</view
-            >
-            <view class="shop-detail status"
-              >状态:{{ item.status | state }}</view
-            >
+            <view class="shop-detail putaway">上下架状态:{{ item.upDown | putaway }}</view>
+            <view class="shop-detail status">状态:{{ item.status | state }}</view>
           </view>
 
-          <view class="right"
-            >¥<text class="price">{{ item.price }}</text></view
-          >
+          <view class="right">¥<text class="price">{{ item.price }}</text></view>
         </view>
         <view class="operate">
           <view class="btn stick" id="one" @tap="sticktop($event)">置顶</view>
-          <view class="btn sold" @tap="shopPutUp">上架</view>
+          <view class="btn sold" @tap="shopPutUp(item.id)">上架</view>
           <view class="btn compile" @tap="topage">编辑</view>
-          <view class="btn delete">删除</view>
+          <view class="btn delete" @tap="deleteshop(item.id)">删除</view>
         </view>
       </view>
     </view>
@@ -244,6 +241,12 @@ export default {
     addShop() {
       this.$mRouter.push({ route: '/pages/shop/shopdetail' });
     },
+    // 删除商品
+    async deleteshop (id) {
+      await this.$http.delete('/goods/del/'+id).then(async (res)=>{
+        console.log(res);
+      })
+    },
     // 根据名字搜索
     searchByname() {
       this.more = 'loading';
@@ -323,9 +326,7 @@ export default {
       } else {
         delete this.params.upDown;
       }
-
       await this.$http.get('/goods/list', this.params).then((res) => {
-        console.log(res);
         if (res.data.list.length > 0) {
           this.shoplist = res.data.list;
           console.log(this.shoplist);
@@ -367,18 +368,24 @@ export default {
     },
     // 下架
     shopPutDown(id) {
-      console.log(this.params.upDown);
       this.changeShopStatus(id,this.params.upDown)
     },
     // 上架
-    shopPutUp() {
-      console.log(2);
+    shopPutUp(id) {
+      this.changeShopStatus(id,this.params.upDown)
     },
     // 修改商品状态
     async changeShopStatus(ids,upordown,state) {
+      let upstate = 0
+      if (upordown === '1') {
+        upstate = 0        
+      } else {
+        upstate = 1
+      }
+
       let data = {
         id: ids,
-        upDown: upordown,
+        upDown: upstate,
         status: state
       }
       if (state) {
@@ -386,8 +393,11 @@ export default {
       } else {
         delete data.status
       }
-      await this.$http.post('/goods/changeStatusOrUpDown',data).then( async(res)=>{
-        console.log(res);
+      await this.$http.postBody('/goods/changeStatusOrUpDown',data).then( async(res)=>{
+        if (res.code === 200 && res.msg === 'OK') {
+          this.getTicketShopList()
+          this.$mHelper.toast('操作成功')
+        }
       })
     }
   },

+ 1 - 1
src/utils/request/request.js

@@ -192,7 +192,7 @@ export default class Request {
     })
   }
 
-  postP (url, params = {}) {
+  postBody (url, params = {}) {
     const options = {};
     options.params = params;
     return this.request({