duanqianwen 11 mēneši atpakaļ
vecāks
revīzija
c7fd360637

+ 12 - 2
src/api/client/goods.js

@@ -6,7 +6,7 @@ import request from '@/utils/request';
  */
 export function getGoodsList(data) {
   return request({
-    url: '/maintain/merchant/goodsList',
+    url: '/maintain/merchant/getMerchantGoodsList',
     method: 'post',
     data: data,
     headers: {
@@ -14,13 +14,23 @@ export function getGoodsList(data) {
     },
   });
 }
+export function getCategories(merchantId) {
+  return request({
+    url: '/maintain/merchant/getCategories',
+    method: 'post',
+    data: {type:1,merchantId},
+    headers: {
+      'content-type': 'application/json',
+    },
+  });
+}
+
 // 上架商品
 
 export function upGoods(goodsIds) {
   return request({
     url: `/maintain/merchant/list-goods/${goodsIds}`,
     method: 'PUT',
-    data: data,
     headers: {
       'content-type': 'application/x-www-form-urlencoded',
     },

+ 67 - 36
src/pageMerchant/storeModule/shopManage.vue

@@ -39,7 +39,7 @@
               icon="https://cdn.uviewui.com/uview/demo/empty/search.png" v-if="!tabbar.length&&search.length!=0">
 
             </u-empty>
-            <u-empty mode="list" text="暂无下架商品" iconColor="#dae2ef" width="100" height="100"
+            <u-empty mode="list" text="暂无商品" iconColor="#dae2ef" width="100" height="100"
               icon="https://cdn.uviewui.com/uview/demo/empty/list.png" v-else-if="!tabbar.length">
 
             </u-empty>
@@ -76,19 +76,19 @@
     <view class="u-menu-wrap" v-if="delete_type == 1">
       <scroll-view :scroll-top="scrollRightTop" scroll-y scroll-with-animation class="right-box" @scroll="rightScroll">
         <view class="page-view">
-          <view class="" style="margin-top: 40rpx;" v-if="!tabbar.length">
+          <view class="" style="margin-top: 40rpx;" v-if="!rightTabbar.length">
             <u-empty mode="search" iconColor="#dae2ef" width="100" height="100"
-              icon="https://cdn.uviewui.com/uview/demo/empty/search.png" v-if="!tabbar.length&&search.length!=0">
+              icon="https://cdn.uviewui.com/uview/demo/empty/search.png" v-if="!rightTabbar.length&&search.length!=0">
 
             </u-empty>
             <u-empty mode="list" text="暂无下架商品" iconColor="#dae2ef" width="100" height="100"
-              icon="https://cdn.uviewui.com/uview/demo/empty/list.png" v-else-if="!tabbar.length">
+              icon="https://cdn.uviewui.com/uview/demo/empty/list.png" v-else-if="!rightTabbar.length">
 
             </u-empty>
           </view>
           <view class="class-item2" :id="'item' + index" v-for="(item, index) in rightTabbar" :key="index">
-            <view class="item-box" >
-              <u-checkbox-group >
+            <view class="item-box">
+              <u-checkbox-group>
                 <u-checkbox v-model="item.checked" shape="circle" @change="checkeChange(item)"></u-checkbox>
               </u-checkbox-group>
               <view class="item-l">
@@ -121,12 +121,13 @@
 <script>
   import {
     getGoodsList,
-    upGoods
+    upGoods,
+    getCategories
   } from '@/api/client/goods.js'
   export default {
     data() {
       return {
-        checkboxValue1:[],
+        checkboxValue1: [],
         scrollTop: 0, //tab标题的滚动条位置
         oldScrollTop: 0, // tab标题的滚动条旧位置
         current: 0, // 预设当前项的值
@@ -311,7 +312,7 @@
         checked: false,
         search: '',
         delete_type: false,
-        rightTabbar:[]
+        rightTabbar: []
       };
     },
     /**
@@ -340,7 +341,8 @@
       this.getGoodsList()
     },
     methods: {
-      checkeChange(item){
+
+      checkeChange(item) {
         console.log(item.checked);
         item.checked = !item.checked
 
@@ -349,38 +351,67 @@
 
       },
       async upStore() {
-      console.log(this.rightTabbar)
-        const res = await upGoods()
+       const ids = this.rightTabbar.filter(obj=>obj.checked).map(item=>item.id)
+        const res = await upGoods(ids)
+        if(res.code=='OK'){
+          uni.showToast({
+            icon:'none',
+            title:'上架成功'
+          })
+          this.getGoodsList()
+        }else{
+          uni.showToast({
+            icon:'none',
+            title:'上架失败'
+          })
+        }
       },
 
-      async getGoodsList() {
-        const res = await getGoodsList({
-          merchantId: this.merchantId,
-          size: 100,
-          goodsName: this.search,
-          status: this.delete_type ? 'OFFLINE' : 'ONLINE'
-        })
-        console.log(res);
-        if (res.code == 'OK' && res.data.categories && res.data.goodsList) {
-          res.data.categories.forEach(obj => {
-            res.data.goodsList.forEach(item => {
-              if (obj.id == item.categoryId) {
-                obj.children.push(item )
+      getGoodsList() {
+
+
+        getCategories(this.merchantId).then(res => {
+          if (res.code == 'OK') {
+            console.log(res);
+            getGoodsList({
+              merchantId: this.merchantId,
+              size: 100,
+              goodsName: this.search,
+              status: this.delete_type ? 'OFFLINE' : 'ONLINE'
+            }).then(result => {
+
+              if (result.code == 'OK' && result.data && res.data) {
+                res.data.forEach(obj => {
+                  result.data.forEach(item => {
+                    if (obj.id == item.categoryId) {
+                      obj.children.push(item)
+                    }
+
+                  })
+                })
+                this.tabbar = res.data
+                this.rightTabbar = result.data.map(obj => {
+                  return {
+                    ...obj,
+                    checked: false
+                  }
+                })
+
+              } else {
+                this.tabbar = []
               }
 
-            })
-          })
 
-          this.tabbar = res.data.categories
-            res.data.categories.forEach(item=>{
-            item.children.forEach(obj=>{
-              this.rightTabbar.push({checked:false,...obj})
+
             })
-          })
+          } else {
+            this.tabbar = []
+          }
+        })
+
+
+
 
-        } else {
-          this.tabbar = []
-        }
 
       },
       getElRect(elClass, dataVal) {
@@ -527,7 +558,7 @@
         } else {
           this.delete_type = false;
         }
-        // this.getGoodsList()
+        this.getGoodsList()
       },
     },
   };

+ 0 - 1
src/pages/login/phoneLogin.vue

@@ -101,7 +101,6 @@ export default {
       // this.loading = true
       this.$store.dispatch('LoginBySmsCode', data)
         .then(() => {
-          debugger
           // this.$store.dispatch('SwitchIdentity','CUSTOMER')
           this.$Router.pushTab('/pages/client/tabBar/home/index');
           // this.loading = false;