Ver Fonte

Merge branch 'master' of http://gogs.ioobot.com:6680/xy/ec-react

kulley há 6 anos atrás
pai
commit
ac17fd96d7

+ 5 - 2
src/pages/cart/all/detail/index.js

@@ -234,7 +234,7 @@ class CartDetail extends Component {
         cartList.forEach((item,index)=>{
             cartCount+=item.count
             if(item.checked===true){
-                totalPrice+=item.count*item.product_id.price
+                totalPrice+=item.count*(item.product_id.price*item.product_id.discountRate/100).toFixed(2)
                 selectedCount+=item.count
                 checkedCount++
             }
@@ -304,7 +304,10 @@ class CartDetail extends Component {
                                         <div className="cart-list-intro" onClick={(e)=>this.skipToProductDetail(e,item.product_id.id)}>
                                             <div>{item.product_id.name}</div>
                                             <div>{item.specificationStock_id.color}  {item.specificationStock_id.size}</div>
-                                            <div>¥ {item.product_id.price}</div>
+                                            <div className='product-item-price'>
+                                                <span>¥{(item.product_id.price*item.product_id.discountRate/100).toFixed(2)}</span>&nbsp;
+                                                <span>¥{(item.product_id.price).toFixed(2)}</span>
+                                            </div>
                                         </div>
                                         <div className="cart-list-count">
                                             <Mutation mutation={gql(update_userCart)}

+ 4 - 1
src/pages/cart/all/edit/index.js

@@ -299,7 +299,10 @@ class CartEdit extends Component {
                                                 <div className="cart-list-intro" onClick={(e)=>this.skipToProductDetail(e,item.product_id.id)}>
                                                     <div>{item.product_id.name}</div>
                                                     <div>{item.specificationStock_id.color}  {item.specificationStock_id.size}</div>
-                                                    <div>¥ {item.product_id.price}</div>
+                                                    <div className='product-item-price'>
+                                                        <span>¥{(item.product_id.price*item.product_id.discountRate/100).toFixed(2)}</span>&nbsp;
+                                                        <span>¥{(item.product_id.price).toFixed(2)}</span>
+                                                    </div>
                                                 </div>
                                                 <div className="cart-list-count">
                                                     <Mutation mutation={gql(update_userCart)}

+ 1 - 1
src/pages/home/all/index.js

@@ -144,7 +144,7 @@ class Recommend extends Component {
                               <div className='product-item-description'>
                                   <div className='product-item-name'>{dataItem.name}</div>
                                   <div className='product-item-price'>
-                                      <span>¥{dataItem.price}</span>&nbsp;
+                                      <span>¥{(dataItem.price*dataItem.discountRate/100).toFixed(2)}</span>&nbsp;
                                       <span>¥{dataItem.price}</span>
                                   </div>
                               </div>

+ 4 - 4
src/pages/home/detail/index.js

@@ -101,7 +101,7 @@ class DetailRender extends Component {
 
     render() {
         let {data} = this.props
-        let {name, intro, img, price, stock} = data.productbyid
+        let {name, intro, img, price, stock, discountRate} = data.productbyid
         let {cartCount, openSelect, buttonType} = this.state
         // console.log('DetailRender openSelect',openSelect)
 
@@ -114,8 +114,8 @@ class DetailRender extends Component {
                         <div className='detail-name detail-padding'>{name}</div>
                         <div className='detail-intro detail-padding'>{intro}</div>
                         <div className='detail-price detail-padding'>
-                            <span>¥{price}</span>&nbsp;&nbsp;
-                            <span>¥{price}</span>
+                            <span>¥{(price*discountRate/100).toFixed(2)}</span>&nbsp;&nbsp;
+                            <span>¥{price.toFixed(2)}</span>
                             <span className='detail-stock'>库存 {stock}</span>
                         </div>
                     </div>
@@ -275,7 +275,7 @@ class SelectModal extends Component {
             createdAt,
             updatedAt: ""
         }
-        console.log('cartContent',cartContent)
+        // console.log('cartContent',cartContent)
 
         this.props.changeDetailState('openSelect',false)
         create_userCart({variables:cartContent}).then((data)=>{

+ 8 - 2
src/utils/gql.js

@@ -67,6 +67,7 @@ const productbyprops = `
             price
             img
             stock
+            discountRate
         }
     }
 `
@@ -87,6 +88,7 @@ const productAndSpec_by_id = `
             price
             img
             stock
+            discountRate
         }
         
         spec: specificationStock_by_props(product_id: $id ) {
@@ -120,6 +122,7 @@ const create_userCart = `
                     price
                     img
                     stock
+                    discountRate
                 }
                 specificationStock_id {
                     id
@@ -151,6 +154,7 @@ const cart_by_userid = `
                 status
                 stock
                 unit
+                discountRate
             }
             specificationStock_id{
                 id
@@ -384,6 +388,7 @@ const orderProduct_by_props = `
                 price
                 img
                 stock
+                discountRate
             }
             productSize
             orderPay
@@ -616,8 +621,8 @@ const create_product = `
 `
 
 const update_product = `
-    mutation updateproduct($recommend: Int, $updatedAt: String, $where: product_filter, $unit: String, $name: String, $createdAt: String, $status: String, $id: ID, $intro: String, $price: Float, $category_id: ID, $img: String, $stock: Int) {
-        updateproduct: update_product(id: $id recommend: $recommend updatedAt: $updatedAt where: $where unit: $unit name: $name createdAt: $createdAt status: $status intro: $intro price: $price category_id: $category_id img: $img stock: $stock) {
+    mutation updateproduct($id: ID, $recommend: Int, $updatedAt: String, $where: product_filter, $unit: String, $name: String, $createdAt: String, $status: String, $intro: String, $discountRate: Float, $price: Float, $category_id: ID, $img: String, $stock: Int) {
+        updateproduct: update_product(id: $id recommend: $recommend updatedAt: $updatedAt where: $where unit: $unit name: $name createdAt: $createdAt status: $status intro: $intro discountRate: $discountRate price: $price category_id: $category_id img: $img stock: $stock) {
             result
             product {
                 recommend
@@ -628,6 +633,7 @@ const update_product = `
                 status
                 id
                 intro
+                discountRate
                 price
     
                 img