Browse Source

始宁农业小程序:代码优化

panyong 2 years ago
parent
commit
72839a9cbb

+ 6 - 1
htmldev/shiningWxMini/pages/businessGoodsEdit/businessGoodsEdit.js

@@ -68,7 +68,8 @@ Page({
         name: '上架',
         value: 1
       }
-    ]
+    ],
+    productCheckStatus: 0 // 0未审核 1审核成功 2审核失败
   },
 
   /**
@@ -228,6 +229,10 @@ Page({
               }
             }
 
+            if (key === 'product_check_status') {
+              temp['productCheckStatus'] = value
+            }
+
             if (this.data.form.hasOwnProperty(key)) {
               temp[`form.${key}`] = value
             }

+ 1 - 1
htmldev/shiningWxMini/pages/businessGoodsEdit/businessGoodsEdit.wxml

@@ -177,7 +177,7 @@
         </view>
       </view>
 
-      <view class="form-item">
+      <view class="form-item" wx:if="{{productCheckStatus === 1}}">
         <label>
           <text>状 态</text>
         </label>

+ 19 - 15
htmldev/shiningWxMini/pages/businessGoodsManage/businessGoodsManage.js

@@ -171,7 +171,7 @@ Page({
           const tempList = list.map(item => {
             return {
               ...item,
-              ...that.getStatusTextAndColor(item.product_status)
+              ...that.getStatusTextAndColor(item.product_status, item.product_check_status)
             }
           })
           const _list = temp.isRefresh ? [].concat(tempList) : that.data.originScrollViewData[_tab].list.concat(tempList)
@@ -268,24 +268,28 @@ Page({
       booLock: false
     })
   },
-  getStatusTextAndColor(val) {
-    const arr = ['未上架', '已上架', '审核中', '审核未通过']
+  getStatusTextAndColor(productStatus, productCheckStatus) {
+    // product_check_status 0未审核 1审核成功 2审核失败
+    // product_status 0 未上架 1 上架
+
     let color = 'col-0'
-    switch (val) {
-      case 1:
-        color = 'col-2'
-        break
-      case 2:
-        color = 'col-1'
-        break
-      case 3:
-        color = 'col-3'
-        break
-      default:
+    let text = ''
+
+    if (productCheckStatus === 0) {
+      color = 'col-1'
+      text = '审核中'
+    } else if (productCheckStatus === 2) {
+      color = 'col-3'
+      text = '审核未通过'
+    } else if (productCheckStatus === 1 && productStatus === 1) {
+      color = 'col-2'
+      text = '已上架'
+    } else if (productCheckStatus === 1 && productStatus === 0) {
+      text = '未上架'
     }
 
     return {
-      product_status_text: arr[val] || '',
+      product_status_text: text,
       product_status_color: color
     }
   }

+ 6 - 3
htmldev/shiningWxMini/pages/businessHome/businessHome.js

@@ -31,7 +31,8 @@ Page({
     shopInfo: {},
     products: [],
     isFetchLock: false, // 接口调用加锁
-    isRefresh: false // 是否下拉刷新
+    isRefresh: false, // 是否下拉刷新
+    finished: false
   },
 
   /**
@@ -73,7 +74,8 @@ Page({
       return
     }
     this.setData({
-      isRefresh: true
+      isRefresh: true,
+      finished: false
     })
     this.fetchShopInfo()
   },
@@ -124,7 +126,8 @@ Page({
 
     this.setData({
       isFetchLock: false,
-      isRefresh: false
+      isRefresh: false,
+      finished: true
     })
 
     if (isRefresh) {

+ 5 - 0
htmldev/shiningWxMini/pages/businessHome/businessHome.wxml

@@ -66,6 +66,11 @@
         </view>
         <view class="price">产品价格:¥{{tools.fen2Yuan(item.product_price)}}</view>
       </view>
+      <!-- 无数据 -->
+      <view class="list-bitmap" wx:if="{{finished && products.length < 1}}">
+        <image src="../../image/common/bitmap.png"></image>
+        <text>暂无数据</text>
+      </view>
     </view>
   </view>
 </view>