kulley 6 лет назад
Родитель
Сommit
a7e0557609

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

@@ -34,7 +34,7 @@ class All extends Component {
             {
             {
                 icon: 'https://ece-img-1254337200.cos.ap-chengdu.myqcloud.com/icon/skirts.png',
                 icon: 'https://ece-img-1254337200.cos.ap-chengdu.myqcloud.com/icon/skirts.png',
                 text: '半身裙',
                 text: '半身裙',
-                id: 'skirts'
+                id: 'skirt'
             },
             },
             {
             {
                 icon: 'https://ece-img-1254337200.cos.ap-chengdu.myqcloud.com/icon/sweater.png',
                 icon: 'https://ece-img-1254337200.cos.ap-chengdu.myqcloud.com/icon/sweater.png',

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

@@ -46,7 +46,7 @@ class Kind extends Component {
                         onSearch={value => console.log(value)}
                         onSearch={value => console.log(value)}
                     />
                     />
                 </div>
                 </div>
-                <Query query={gql(productbyprops)} variables={{intro: id}}>
+                <Query query={gql(productbyprops)} variables={{category: id}}>
                     {
                     {
                         ({loading, error, data}) => {
                         ({loading, error, data}) => {
                             if (loading) {
                             if (loading) {
@@ -93,7 +93,6 @@ class KindRender extends Component {
                               columnNum={2}
                               columnNum={2}
                               hasLine={false}
                               hasLine={false}
                               onClick={(product) => {
                               onClick={(product) => {
-                                  console.log(1)
                                   this.props.history.push({
                                   this.props.history.push({
                                       pathname: '/home/detail',
                                       pathname: '/home/detail',
                                       state: {
                                       state: {

+ 43 - 13
src/pages/my/tools/address/index.js

@@ -6,19 +6,28 @@ import {Icon, Row, Col} from 'antd'
 import {Query} from "react-apollo"
 import {Query} from "react-apollo"
 import gql from "graphql-tag"
 import gql from "graphql-tag"
 import './index.css'
 import './index.css'
-import AddAddress from "./addaddress"
+import SingleAddress from "./singleaddress"
 
 
 class Address extends Component {
 class Address extends Component {
     constructor(props) {
     constructor(props) {
         super(props)
         super(props)
         this.state = {
         this.state = {
-            add: false
+            single: false,
+            addressID: 'add',
+            addressChoosed: {id: 'add'}
         }
         }
     }
     }
 
 
     changePage = (bool) => {
     changePage = (bool) => {
         this.setState({
         this.setState({
-            add: bool
+            single: bool
+        })
+    }
+
+    changeAddress = (address) => {
+        this.setState({
+            addressID: address.id,
+            addressChoosed: address
         })
         })
     }
     }
 
 
@@ -34,6 +43,7 @@ class Address extends Component {
     }
     }
 
 
     render() {
     render() {
+        let {addressChoosed, addressID} = this.state
         return (
         return (
             <div>
             <div>
                 <Query query={gql(userAddressbyprops)} variables={{user_id: "obR_j5GbxDfGlOolvSeTdZUwfpKA"}}>
                 <Query query={gql(userAddressbyprops)} variables={{user_id: "obR_j5GbxDfGlOolvSeTdZUwfpKA"}}>
@@ -55,10 +65,15 @@ class Address extends Component {
                             return (
                             return (
                                 <div>
                                 <div>
                                     {
                                     {
-                                        this.state.add ?
-                                            <AddAddress changePage={this.changePage}/>
+                                        this.state.single ?
+                                            <SingleAddress addressID={addressID} addressChoosed={addressChoosed} changePage={this.changePage}/>
                                             :
                                             :
-                                            <AddressRender defaultAddress={this.getDefaultAddress(data)} otherAddress={this.getOtherAddress(data)} changePage={this.changePage}/>
+                                            <AddressRender
+                                                defaultAddress={this.getDefaultAddress(data)}
+                                                otherAddress={this.getOtherAddress(data)}
+                                                changePage={this.changePage}
+                                                changeAddress={this.changeAddress}
+                                            />
                                     }
                                     }
                                 </div>
                                 </div>
                             )
                             )
@@ -79,9 +94,7 @@ class AddressRender extends Component {
     }
     }
 
 
     render() {
     render() {
-        let {changePage, defaultAddress, otherAddress} = this.props
-        console.log(defaultAddress)
-        console.log(otherAddress)
+        let {changePage, changeAddress, defaultAddress, otherAddress} = this.props
         return (
         return (
             <div>
             <div>
                 <div className='address-add' onClick={() => {
                 <div className='address-add' onClick={() => {
@@ -101,7 +114,16 @@ class AddressRender extends Component {
                         <Row>
                         <Row>
                             <Col span={20}
                             <Col span={20}
                                  className='address-address'>{defaultAddress.province + defaultAddress.city + defaultAddress.area + defaultAddress.address}</Col>
                                  className='address-address'>{defaultAddress.province + defaultAddress.city + defaultAddress.area + defaultAddress.address}</Col>
-                            <Col span={2} offset={2}><Icon type="edit" style={{fontSize: 14}}/></Col>
+                            <Col span={2} offset={2}>
+                                <Icon
+                                    type="edit"
+                                    style={{fontSize: 14}}
+                                    onClick={()=>{
+                                        changePage(true)
+                                        changeAddress(defaultAddress)
+                                    }}
+                                />
+                            </Col>
                         </Row>
                         </Row>
                     </div>
                     </div>
                 </div>
                 </div>
@@ -115,9 +137,17 @@ class AddressRender extends Component {
                                     <Col span={14} className='address-phone ellipsis'>{address.telephone}</Col>
                                     <Col span={14} className='address-phone ellipsis'>{address.telephone}</Col>
                                 </Row>
                                 </Row>
                                 <Row>
                                 <Row>
-                                    <Col span={20}
-                                         className='address-address'>{address.province + address.city + address.area + address.address}</Col>
-                                    <Col span={2} offset={2}><Icon type="edit" style={{fontSize: 14}}/></Col>
+                                    <Col span={20} className='address-address'>{address.province + address.city + address.area + address.address}</Col>
+                                    <Col span={2} offset={2}>
+                                        <Icon
+                                            type="edit"
+                                            style={{fontSize: 14}}
+                                            onClick={()=>{
+                                                changePage(true)
+                                                changeAddress(address)
+                                            }}
+                                        />
+                                    </Col>
                                 </Row>
                                 </Row>
                             </div>
                             </div>
                         )
                         )

+ 0 - 0
src/pages/my/tools/address/addaddress/index.css → src/pages/my/tools/address/singleaddress/index.css


+ 9 - 9
src/pages/my/tools/address/addaddress/index.js → src/pages/my/tools/address/singleaddress/index.js

@@ -1,7 +1,7 @@
 import {Component} from "react"
 import {Component} from "react"
 import React from "react"
 import React from "react"
 import {NavBar, Icon, InputItem, PickerView, TextareaItem} from 'antd-mobile'
 import {NavBar, Icon, InputItem, PickerView, TextareaItem} from 'antd-mobile'
-import { Button } from 'antd';
+import {Button} from 'antd'
 import './index.css'
 import './index.css'
 
 
 const provinceAll = [
 const provinceAll = [
@@ -81,7 +81,7 @@ const provinceAll = [
     },
     },
 ]
 ]
 
 
-class AddAddress extends Component {
+class SingleAddress extends Component {
     constructor(props) {
     constructor(props) {
         super(props)
         super(props)
         this.state = {
         this.state = {
@@ -95,8 +95,10 @@ class AddAddress extends Component {
     }
     }
 
 
     render() {
     render() {
-        let {changePage} = this.props
+        let {changePage, addressID, addressChoosed} = this.props
         let {username, telephone, province, city, area, address} = this.state
         let {username, telephone, province, city, area, address} = this.state
+        console.log('id', addressID)
+        console.log('address', addressChoosed)
         return (
         return (
             <div>
             <div>
                 <div className='tools-addressadd-navbar-wrap'>
                 <div className='tools-addressadd-navbar-wrap'>
@@ -127,7 +129,7 @@ class AddAddress extends Component {
                     />
                     />
                     <PickerView
                     <PickerView
                         data={provinceAll}
                         data={provinceAll}
-                        value={[province, city, area ? area : '']}
+                        value={[province, city ? city : '', area ? area : '']}
                         onChange={(area) => {
                         onChange={(area) => {
                             this.setState({province: area[0], city: area[1], area: area[2]})
                             this.setState({province: area[0], city: area[1], area: area[2]})
                         }}
                         }}
@@ -143,7 +145,7 @@ class AddAddress extends Component {
                 </div>
                 </div>
 
 
                 <AddAddressButton
                 <AddAddressButton
-                    data = {{
+                    data={{
                         username,
                         username,
                         telephone,
                         telephone,
                         province,
                         province,
@@ -157,14 +159,12 @@ class AddAddress extends Component {
     }
     }
 }
 }
 
 
-export default AddAddress
+export default SingleAddress
 
 
 class AddAddressButton extends Component {
 class AddAddressButton extends Component {
     constructor(props) {
     constructor(props) {
         super(props)
         super(props)
-        this.state = {
-
-        }
+        this.state = {}
     }
     }
 
 
     render() {
     render() {