Prechádzať zdrojové kódy

首页价格展示修复、下单创建物流表、详情页图片显示问题

Csy817 6 rokov pred
rodič
commit
a05fa712ad

+ 10 - 0
src/app.css

@@ -104,4 +104,14 @@ a {
 .ant-message-notice-content {
     background: rgba(0,0,0,.7);
     color: white;
+}
+
+.am-flexbox {
+    overflow: visible;
+}
+
+.hide-extra-text {
+    white-space: nowrap;
+    overflow: hidden;
+    text-overflow: ellipsis;
 }

+ 13 - 3
src/pages/cart/all/detail/index.js

@@ -211,7 +211,17 @@ class CartDetail extends Component {
                 dataType: 'cartSelected'
             }
         })
-    } 
+    }
+
+    skipToProductDetail = (e,productId) => {
+        e.preventDefault()
+        this.props.history.push({
+            pathname: '/home/detail',
+            state: {
+                id:productId
+            }
+        })
+    }
 
     render() {
         let {cartList,isSelectAll,selectedCount,totalPrice} = this.state
@@ -230,10 +240,10 @@ class CartDetail extends Component {
                                                 onChange={(e)=>{this.changeCheckedStatus(e,index)}}
                                             />
                                         </div>
-                                        <div className="cart-list-image">
+                                        <div className="cart-list-image" onClick={(e)=>this.skipToProductDetail(e,item.product_id.id)}>
                                             <img src={item.product_id.img || "https://gw.alipayobjects.com/zos/rmsportal/nywPmnTAvTmLusPxHPSu.png"} alt="商品图片"/>
                                         </div>
-                                        <div className="cart-list-intro">
+                                        <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>

+ 14 - 3
src/pages/cart/all/edit/index.js

@@ -1,4 +1,5 @@
 import React, {Component} from 'react'
+import {withRouter} from 'react-router-dom'
 import {message} from 'antd'
 import {Checkbox, WhiteSpace, Modal, Toast} from 'antd-mobile'
 import classNames from 'classnames'
@@ -192,6 +193,16 @@ class CartEdit extends Component {
         })
     }
 
+    skipToProductDetail = (e,productId) => {
+        e.preventDefault()
+        this.props.history.push({
+            pathname: '/home/detail',
+            state: {
+                id:productId
+            }
+        })
+    }
+
     render() {
         let {cartList, isSelectAll, selectedCount} = this.state
         let listLength = cartList.length
@@ -216,10 +227,10 @@ class CartEdit extends Component {
                                                         onChange={(e)=>{this.changeCheckedStatus(e,index)}}
                                                     />
                                                 </div>
-                                                <div className="cart-list-image">
+                                                <div className="cart-list-image" onClick={(e)=>this.skipToProductDetail(e,item.product_id.id)}>
                                                     <img src={item.product_id.img || "https://gw.alipayobjects.com/zos/rmsportal/nywPmnTAvTmLusPxHPSu.png"} alt=""/>
                                                 </div>
-                                                <div className="cart-list-intro">
+                                                <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>
@@ -288,4 +299,4 @@ class CartEdit extends Component {
     }
 }
 
-export default CartEdit
+export default withRouter(CartEdit)

+ 22 - 5
src/pages/cart/orders/index.js

@@ -7,7 +7,7 @@ import gql from "graphql-tag"
 import moment from 'moment'
 
 import {user_default_address, create_order, create_order_product} from "../../../utils/gql"
-
+import {idGen} from "../../../utils/func"
 import './index.css'
 
 const Item = List.Item
@@ -87,15 +87,18 @@ class CartOrders extends Component {
         let user_id = "obR_j5GbxDfGlOolvSeTdZUwfpKA"
         let {totalCount, totalPrice, remark} = this.state
         let createdAt = moment().format('YYYY-MM-DD HH:mm:ss')
-        let {id:userAddress_id,telephone} = JSON.parse(sessionStorage.getItem('ordersAddress'))
+        let ordersAddress = JSON.parse(sessionStorage.getItem('ordersAddress'))
+        let {id:userAddress_id, telephone, username, province, city, area, address} = ordersAddress
+        let addressData = String(province + city + area + address)
         let tag = telephone ? telephone.replace(/[^0-9]/ig, "").slice(-4) : Math.random().toString(10).substr(2,4)
         const orderId = createdAt.replace(/[^0-9]/ig, "").substr(2) + tag
+        let orderLogisticsId = idGen('deliver')
 
         const orderContent = {
              remark,
              deliveryTime: "",
              updatedAt: "",
-             orderLogistics_id: "",
+             orderLogistics_id: orderLogisticsId,
              payTime: "",
              orderTotalPay: totalPrice,
              createdAt,
@@ -110,13 +113,27 @@ class CartOrders extends Component {
              deleteId:[]
         }
 
+        const orderLogistics = {
+            updatedAt: "",
+            logisticsFee: 0.0,
+            expressId: "",
+            createdAt,
+            order_id: orderId,
+            consigneeTel: telephone,
+            orderLogisticsId,
+            consignAddress: addressData,
+            LogisticsStatus: "0",
+            user_id,
+            consigneeName: username
+        }
+
         let type = this.props.history.location.state.dataType
         let shopping = JSON.parse(sessionStorage.getItem(type))
         if(type === 'cartSelected') orderContent.deleteId = shopping.map(item => item.id)
 
         // console.log('createOrder orderContent',orderContent)
 
-        let createOrder = create_order({variables:orderContent})
+        let createOrder = create_order({variables:{...orderContent, ...orderLogistics}})
 
         let createOrderProduct = shopping.map((item,index) => {
             let createdAt = moment().format('YYYY-MM-DD HH:mm:ss')
@@ -235,7 +252,7 @@ class CartOrders extends Component {
                                                         alt=""/>
                                                 </div>
                                                 <div className="cart-orders-intro">
-                                                    <div>{item.product_id.name}</div>
+                                                    <div className='hide-extra-text'>{item.product_id.name}</div>
                                                     <div>{item.specificationStock_id.color}  {item.specificationStock_id.size}</div>
                                                     <div>¥ {item.product_id.price}</div>
                                                 </div>

+ 10 - 1
src/pages/home/detail/index.css

@@ -16,7 +16,7 @@
 }
 
 .detail-img {
-    height: 80%;
+    width: 100%;
     background-size: cover;
     background-repeat: no-repeat;
     margin: 0 auto;
@@ -26,6 +26,11 @@
     font-size: 16px;
 }
 
+.detail-intro {
+    font-size: 12px;
+    color: #666666;
+}
+
 .detail-price span:first-child {
     color: #f44;
     font-size: 22px;
@@ -52,6 +57,10 @@
     background-color: white;
 }
 
+.detail-complicate-show-img {
+
+}
+
 .detail-footer {
     position: fixed;
     bottom: 0;

+ 11 - 6
src/pages/home/detail/index.js

@@ -30,9 +30,9 @@ class Detail extends Component {
 
     render() {
         let {id} = this.state
-        let contentHeight = window.innerHeight
+
         return (
-            <div className='detail-wrap' style={{height: contentHeight}}>
+            <div className='detail-wrap' >
                 <div className='detail-navbar-wrap navbar'>
                     <NavBar
                         mode="light"
@@ -101,16 +101,18 @@ class DetailRender extends Component {
 
     render() {
         let {data} = this.props
-        let {name, img, price, stock} = data.productbyid
+        let {name, intro, img, price, stock} = data.productbyid
         let {cartCount, openSelect, buttonType} = this.state
         // console.log('DetailRender openSelect',openSelect)
 
         return (
             <div className='detail-wrapper content-wrap'>
                 <div className='detail-simple-show'>
-                    <div className='detail-img' style={{backgroundImage: "url('"+ img + "')"}}/>
+                    {/*<div className='detail-img' style={{backgroundImage: "url('"+ img + "')"}}/>*/}
+                    <img className='detail-img' src={img} alt="商品图片"/>
                     <div className='detail-intro'>
                         <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>
@@ -120,7 +122,10 @@ class DetailRender extends Component {
                 </div>
                 <div className='detail-complicate-show'>
                     <div className='detail-padding detail-complicate-title'>商品信息</div>
-                    <div>通过商品详情图片展示</div>
+                    <div className='detail-complicate-show-img'>
+                        {/*通过商品详情图片展示*/}
+                        <img className='detail-img' src={img} alt="商品图片"/>
+                    </div>
                 </div>
                 <div className='detail-footer'>
                     <div className='detail-bottom'>
@@ -447,7 +452,7 @@ class Specification extends Component {
             spec: prevState.spec.map((item,index)=>{
                 if(index===i){
                     item.select=true
-                    console.log('select item',item)
+                    // console.log('select item',item)
                     this.props.changeState('selectSpec',item)
                 }else {
                     item.select=false

+ 0 - 1
src/pages/home/kind/index.js

@@ -117,7 +117,6 @@ class KindRender extends Component {
                                           id: product.id
                                       }
                                   })
-
                               }}
                               renderItem={dataItem => (
                                   <div key={dataItem.id} className='product-item'>

+ 1 - 0
src/pages/my/tools/address/index.js

@@ -106,6 +106,7 @@ class AddressRender extends Component {
     }
 
     changeOrdersAddress =(address) => {
+        console.log('address',address)
         sessionStorage.setItem('ordersAddress',JSON.stringify(address))
 
         this.props.history.go(-2)

+ 41 - 0
src/utils/gql.js

@@ -295,6 +295,7 @@ const orderProduct_by_props = `
 
 const create_order = `
     mutation createorder($deliveryTime: String, $remark: String, $updatedAt: String, $orderLogistics_id: ID, $payTime: String, $orderTotalPay: Float, $createdAt: String, $orderStatus: String, $userAddress_id: ID, $id: ID!, $orderShipFee: Float, $count: Int, $user_id: ID, $productTotalPay: Float, $orderPay_id: ID, 
+                         $logisticsFee: Float, $expressId: String, $order_id: ID, $consigneeTel: String, $orderLogisticsId: ID!, $consignAddress: String, $LogisticsStatus: String, $consigneeName: String
                          $deleteId: [String]) {
         createorder: create_order(deliveryTime: $deliveryTime remark: $remark updatedAt: $updatedAt orderLogistics_id: $orderLogistics_id payTime: $payTime orderTotalPay: $orderTotalPay createdAt: $createdAt orderStatus: $orderStatus userAddress_id: $userAddress_id id: $id orderShipFee: $orderShipFee count: $count user_id: $user_id productTotalPay: $productTotalPay orderPay_id: $orderPay_id) {
             result
@@ -343,6 +344,46 @@ const create_order = `
                 }
             } 
         }
+        createorderLogistics: create_orderLogistics(updatedAt: $updatedAt logisticsFee: $logisticsFee expressId: $expressId createdAt: $createdAt order_id: $order_id consigneeTel: $consigneeTel id: $id consignAddress: $consignAddress LogisticsStatus: $LogisticsStatus user_id: $user_id consigneeName: $consigneeName) {
+            result
+            orderLogistics {
+                updatedAt
+                logisticsFee
+                expressId
+                createdAt
+                order_id {
+                    deliveryTime
+                    remark
+                    updatedAt
+        
+                    payTime
+                    orderTotalPay
+                    createdAt
+                    orderStatus
+        
+                    id
+                    orderShipFee
+                    count
+        
+                    productTotalPay
+                }
+                consigneeTel
+                id
+                consignAddress
+                LogisticsStatus
+                user_id {
+                    email
+                    updatedAt
+                    password
+                    telephone
+                    username
+                    createdAt
+                    openid
+                    id
+                }
+                consigneeName
+            }
+        }
         delete_userCart(where: {
             id: {
                 _in: $deleteId