2 次代码提交 d8b3372450 ... 4c0bdafba1

作者 SHA1 备注 提交日期
  徐鹏 4c0bdafba1 购物车清空功后清空总金额 2 年之前
  徐鹏 9b59107091 购物车清空功能增加,订单编辑商品序号显示方式跳转为顺序显示,序号显示左边 2 年之前

+ 6 - 1
app/containers/order/OrderEdit.js

@@ -1428,6 +1428,11 @@ class OrderEdit extends Component {
           </View>
           {/* 商品行 */}
           <View style={{ flexDirection: 'row' }}>
+            <View style={{ marginLeft: 10}}>
+              <Text style={{ fontSize: 13, lineHeight: 18, color: '#333' }}>
+                {(indexParent + 1)}
+              </Text>
+            </View>
             <Image
               source={{ uri: ImageBaseUrl + item.goodsImg } || png}
               style={{ width: 80, height: 80 }}
@@ -1435,7 +1440,7 @@ class OrderEdit extends Component {
             <View style={{ marginLeft: 10, flex: 1 }}>
               <View style={{flexDirection:'row'}}>
                 <Text style={{ fontSize: 13, lineHeight: 18, color: '#333',width:'90%' }}>
-                  {item.rowNum}--{item.goodsDisplayName}
+                  {item.goodsDisplayName}
                 </Text>
                 <TouchableOpacity onPress={() =>this.deleteGoodsFn(indexParent)}>
                   <Image 

+ 11 - 9
app/containers/shoppingcart/ShoppingCart.js

@@ -62,19 +62,21 @@ class ShoppingCart extends Component {
       Toast.hide(this.toast)
     }
     if (editData && editData.length > 0) {
-      if (this.checkStockNum(editData).length > 0) {
-        let lessStockName = this.checkStockNum(editData).join()
-        this.toast = Toast.show(
-          `您所选的商品: ${lessStockName}\n库存不足,请重新选择!`,
-          { position: toastHeight }
-        )
-      } else {
+      // if (this.checkStockNum(editData).length > 0) {
+      //   let lessStockName = this.checkStockNum(editData).join()
+      //   this.toast = Toast.show(
+      //     `您所选的商品: ${lessStockName}\n库存不足,请重新选择!`,
+      //     { position: toastHeight }
+      //   )
+      // } else {
         // 测试时 如果没有价格 加个 editData[0].salePrice =100
-
+        let index = 1;
         for (data of editData) {
           cartIds.push(data.id)
           delete data.isChecked
           data.id = null
+          data.rowNum = index * 10 + ""
+          index++
           data.promPrice = data.salePrice
           data.dealPrice = data.salePrice
           data.isGift = 0
@@ -124,7 +126,7 @@ class ShoppingCart extends Component {
             },
           })
         )
-      }
+      // }
     } else {
       this.toast = Toast.show('请选择商品再结算!', { position: toastHeight })
     }

+ 30 - 1
app/containers/shoppingcart/ShoppingCartHome.js

@@ -160,6 +160,21 @@ class ShoppingCartHome extends Component {
     }
   }
 
+  // 情况购物车
+  async clearCart() {
+    await this.props.dispatch(
+      createAction('shoppingcart/emptyCart')({
+        params: {
+          customer: CUSTOMERINFO.id
+        },
+      })
+    )
+    this.setState({
+      edited: !this.state.edited,
+      Amount: 0
+    })
+  }  
+
   render() {
     const { appTheme, ShopList, TotalNum } = this.props
     return (
@@ -230,7 +245,7 @@ class ShoppingCartHome extends Component {
                     color: "#666"
                   }}
                 >
-                  编辑
+                  {this.state.edited ? '完成' : '编辑'}
                 </Text>
               </TouchableOpacity>
             ) : null}
@@ -436,6 +451,20 @@ class ShoppingCartHome extends Component {
           </View>
           {this.state.edited ? (
             <TouchableOpacity
+              onPress={
+                async () => {
+                  if (this.toast) {
+                    Toast.hide(this.toast)
+                  }
+                  if (!this.state.Loading) {
+                    this.clearCart()
+                  } else {
+                    this.toast = Toast.show('购物车为空!', {
+                      position: toastHeight,
+                    })
+                  }
+                }
+              }            
               style={{
                 flex: 3,
                 justifyContent: 'center',

+ 25 - 0
app/models/shoppingcart/ShoppingCart.js

@@ -135,6 +135,31 @@ export default {
       }
     },
 
+    //清空购物车
+    *emptyCart(action, { call, put }) {
+      try {
+        yield call(() => {
+            authService.clearShopCart(action.payload)
+          }
+        )
+        yield put(
+          createAction('getShopListReducer')({
+            isDelete: true,
+            edited: false,
+            ShopList: [],
+            TotalNum: 0,
+            Amount: 0
+          })
+        )
+      } catch (error) {
+        console.log(
+          error,
+          '-----error的完整信息' + '\n' + error.response.data.message,
+          '-----相关错误信息'
+        )
+      }
+    },
+
     // 删除购物车商品行
     *deleteShop(action, { call, put }) {
       // console.log(action, 112938);