Преглед на файлове

Merge remote-tracking branch 'origin/master'

Csy817 преди 6 години
родител
ревизия
2c5741d1dc

+ 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',
                 text: '半身裙',
-                id: 'skirts'
+                id: 'skirt'
             },
             {
                 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)}
                     />
                 </div>
-                <Query query={gql(productbyprops)} variables={{intro: id}}>
+                <Query query={gql(productbyprops)} variables={{category: id}}>
                     {
                         ({loading, error, data}) => {
                             if (loading) {
@@ -93,7 +93,6 @@ class KindRender extends Component {
                               columnNum={2}
                               hasLine={false}
                               onClick={(product) => {
-                                  console.log(1)
                                   this.props.history.push({
                                       pathname: '/home/detail',
                                       state: {

+ 1 - 1
src/pages/my/all/index.css

@@ -2,7 +2,7 @@
 }
 
 .avatar-area {
-    height: 20%;
+    height: 150px;
     /*background-image: linear-gradient(45deg, #ff9a9e 0%, #fad0c4 99%, #fad0c4 100%);*/
     background-image: linear-gradient(to top, #ffdcd2 0%, #ffdbd1 1%, #fd898c 100%);
     position: relative;

+ 39 - 2
src/pages/my/all/index.js

@@ -62,6 +62,24 @@ const memberIcon = [
     }
 ]
 
+const shopIcon = [
+    {
+        icon: 'https://ece-img-1254337200.cos.ap-chengdu.myqcloud.com/icon/shop.png',
+        text: '店铺展示',
+        id: 'shop'
+    },
+    {
+        icon: 'https://ece-img-1254337200.cos.ap-chengdu.myqcloud.com/icon/goods.png',
+        text: '商品管理',
+        id: 'goods'
+    },
+    {
+        icon: 'https://ece-img-1254337200.cos.ap-chengdu.myqcloud.com/icon/order.png',
+        text: '订单管理',
+        id: 'order'
+    }
+]
+
 class All extends Component {
     constructor(props) {
         super(props)
@@ -69,9 +87,8 @@ class All extends Component {
     }
 
     render() {
-        let contentHeight = window.innerHeight - 95
         return (
-            <div className='my-wrap all' style={{height: contentHeight}}>
+            <div className='my-wrap all'>
                 <div className='avatar-area'>
                     <div className='avatar'/>
                     <div className='nickname'>110</div>
@@ -141,6 +158,26 @@ class All extends Component {
                         />
                     </div>
                 </div>
+
+                <div className='my-card member-card'>
+                    <div className='card-title'>
+                        商家入口
+                    </div>
+                    <div className='card-icons'>
+                        <Grid data={shopIcon}
+                              columnNum={4}
+                              hasLine={false}
+                              onClick={(shop) => {
+                                  this.props.history.push({
+                                      pathname: '/my/shop',
+                                      state: {
+                                          page: shop.id
+                                      }
+                                  })
+                              }}
+                        />
+                    </div>
+                </div>
             </div>
         )
     }

+ 2 - 0
src/pages/my/index.js

@@ -4,6 +4,7 @@ import All from './all'
 import Order from './order'
 import Tools from './tools'
 import Member from './member'
+import Shop from './shop'
 import {Switch, Route} from 'react-router-dom'
 
 const My = () => (
@@ -14,6 +15,7 @@ const My = () => (
             <Route path="/my/order" component={Order}/>
             <Route path="/my/tools" component={Tools}/>
             <Route path="/my/member" component={Member}/>
+            <Route path="/my/shop" component={Shop}/>
         </Switch>
     </div>
 )

+ 1 - 1
src/pages/my/order/index.js

@@ -64,7 +64,7 @@ class Order extends Component {
                         }}
                     >{navTitle}</NavBar>
                 </div>
-                <Query query={gql(orderbyprops)} variables={{user_id: "obR_j5ILjLjFSuBjj_UymjQjMNZc", orderStatus}}>
+                <Query query={gql(orderbyprops)} variables={{user_id: "test", orderStatus}}>
                     {
                         ({loading, error, data}) => {
                             if (loading) {

+ 0 - 0
src/pages/my/shop/index.css


+ 28 - 0
src/pages/my/shop/index.js

@@ -0,0 +1,28 @@
+import React, {Component} from 'react'
+import './index.css'
+import {NavBar, Icon} from 'antd-mobile'
+import {withRouter} from 'react-router-dom'
+
+class Shop extends Component {
+    constructor(props) {
+        super(props)
+        this.state = {}
+    }
+
+    render() {
+        return (
+            <div className='shop-wrap'>
+                <div className='shop-navbar-wrap'>
+                    <NavBar
+                        className='shop-navbar'
+                        mode="light"
+                        icon={<Icon type="left"/>}
+                        onLeftClick={() => {this.props.history.push({pathname: '/my/all'})}}
+                    >店铺详情</NavBar>
+                </div>
+            </div>
+        )
+    }
+}
+
+export default withRouter(Shop)

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

@@ -1,3 +0,0 @@
-.add-address-button {
-    margin-top: 30px;
-}

+ 46 - 15
src/pages/my/tools/address/index.js

@@ -6,34 +6,44 @@ import {Icon, Row, Col} from 'antd'
 import {Query} from "react-apollo"
 import gql from "graphql-tag"
 import './index.css'
-import AddAddress from "./addaddress"
+import SingleAddress from "./singleaddress"
 
 class Address extends Component {
     constructor(props) {
         super(props)
         this.state = {
-            add: false
+            single: false,
+            addressID: '',
+            addressChoosed: {}
         }
     }
 
     changePage = (bool) => {
         this.setState({
-            add: bool
+            single: bool
+        })
+    }
+
+    changeAddress = (address) => {
+        this.setState({
+            addressID: address.id,
+            addressChoosed: address
         })
     }
 
     getDefaultAddress = (data) => (
-        data.find(data => data.default === '1')
+        data.find(data => data.default === 1)
     )
 
     getOtherAddress = (data) => {
-        let defaultAddressIndex = data.find(data => data.default === '1')
+        let defaultAddressIndex = data.find(data => data.default === 1)
         let dataCopy = [...data]
         dataCopy.splice(defaultAddressIndex, 1)
         return dataCopy
     }
 
     render() {
+        let {addressChoosed, addressID} = this.state
         return (
             <div>
                 <Query query={gql(userAddressbyprops)} variables={{user_id: "obR_j5GbxDfGlOolvSeTdZUwfpKA"}}>
@@ -55,10 +65,15 @@ class Address extends Component {
                             return (
                                 <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>
                             )
@@ -79,13 +94,12 @@ class AddressRender extends Component {
     }
 
     render() {
-        let {changePage, defaultAddress, otherAddress} = this.props
-        console.log(defaultAddress)
-        console.log(otherAddress)
+        let {changePage, changeAddress, defaultAddress, otherAddress} = this.props
         return (
             <div>
                 <div className='address-add' onClick={() => {
                     changePage(true)
+                    changeAddress({id: 'add'})
                 }}>
                     <Icon type="plus" style={{fontSize: 22, fontWeight: 800}}/>&nbsp;
                     添加新地址
@@ -101,7 +115,16 @@ class AddressRender extends Component {
                         <Row>
                             <Col span={20}
                                  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>
                     </div>
                 </div>
@@ -115,9 +138,17 @@ class AddressRender extends Component {
                                     <Col span={14} className='address-phone ellipsis'>{address.telephone}</Col>
                                 </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>
                             </div>
                         )

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

@@ -0,0 +1,7 @@
+.address-button-group {
+    margin-top: 30px;
+}
+
+.address-button {
+    margin-top: 5px;
+}

+ 85 - 46
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 React from "react"
 import {NavBar, Icon, InputItem, PickerView, TextareaItem} from 'antd-mobile'
-import { Button } from 'antd';
+import {Button} from 'antd'
 import './index.css'
 
 const provinceAll = [
@@ -18,17 +18,9 @@ const provinceAll = [
         value: '安徽省',
         children: [
             {
-                label: '合肥',
-                value: '合肥',
+                label: '合肥',
+                value: '合肥',
                 children: [
-                    {
-                        label: '包河区',
-                        value: '包河区',
-                    },
-                    {
-                        label: '庐阳区',
-                        value: '庐阳区',
-                    },
                     {
                         label: '蜀山区',
                         value: '蜀山区',
@@ -37,11 +29,19 @@ const provinceAll = [
                         label: '瑶海区',
                         value: '瑶海区',
                     },
+                    {
+                        label: '包河区',
+                        value: '包河区',
+                    },
+                    {
+                        label: '庐阳区',
+                        value: '庐阳区',
+                    }
                 ],
             },
             {
-                label: '芜湖',
-                value: '芜湖',
+                label: '芜湖',
+                value: '芜湖',
                 children: [
                     {
                         label: '镜湖区',
@@ -54,20 +54,20 @@ const provinceAll = [
                 ],
             },
             {
-                label: '六安',
-                value: '六安',
+                label: '六安',
+                value: '六安',
             },
             {
-                label: '淮南',
-                value: '淮南',
+                label: '淮南',
+                value: '淮南',
             },
             {
-                label: '马鞍山',
-                value: '马鞍山',
+                label: '马鞍山',
+                value: '马鞍山',
             },
             {
-                label: '黄山',
-                value: '黄山',
+                label: '黄山',
+                value: '黄山',
             }
         ]
     },
@@ -81,22 +81,29 @@ const provinceAll = [
     },
 ]
 
-class AddAddress extends Component {
+class SingleAddress extends Component {
     constructor(props) {
         super(props)
-        this.state = {
+        let state = {
             username: '',
             telephone: '',
             province: '安徽省',
             city: '合肥市',
-            area: '包河区',
-            address: ''
+            area: '蜀山区',
+            address: '',
+            id: ''
+        }
+        if (props.addressID === 'add') {
+            this.state = {...state}
+        } else {
+            let {province, city, area, address, telephone, username, id} = props.addressChoosed
+            this.state = {...state, province, city, area, address, telephone, username, id}
         }
     }
 
     render() {
         let {changePage} = this.props
-        let {username, telephone, province, city, area, address} = this.state
+        let {username, telephone, province, city, area, address, id} = this.state
         return (
             <div>
                 <div className='tools-addressadd-navbar-wrap'>
@@ -111,12 +118,12 @@ class AddAddress extends Component {
                 </div>
 
                 <div>
-                    <InputItem placeholder="输入姓名" labelNumber={5} onChange={(username) => {
+                    <InputItem placeholder="输入姓名" value={username} labelNumber={5} onChange={(username) => {
                         this.setState({username})
                     }}>
                         <div>联系人姓名</div>
                     </InputItem>
-                    <InputItem placeholder="输入号码" onChange={(telephone) => {
+                    <InputItem placeholder="输入号码" value={telephone} onChange={(telephone) => {
                         this.setState({telephone})
                     }}>
                         <div>手机号码</div>
@@ -127,50 +134,82 @@ class AddAddress extends Component {
                     />
                     <PickerView
                         data={provinceAll}
-                        value={[province, city, area ? area : '']}
-                        onChange={(area) => {
-                            this.setState({province: area[0], city: area[1], area: area[2]})
+                        value={[province, city ? city : '', area ? area : '']}
+                        onChange={(address) => {
+                            this.setState({province: address[0], city: address[1], area: address[2]})
                         }}
                     />
                     <TextareaItem
                         title="详细地址"
                         autoHeight
                         labelNumber={4}
+                        value={address}
                         onChange={(address) => {
                             this.setState({address})
                         }}
                     />
                 </div>
 
-                <AddAddressButton
-                    data = {{
-                        username,
-                        telephone,
-                        province,
-                        city,
-                        area,
-                        address
-                    }}
-                />
+                <div className='address-button-group'>
+                    <DefaultAndSaveButton
+                        data={{
+                            username,
+                            telephone,
+                            province,
+                            city,
+                            area,
+                            address,
+                            id
+                        }}
+                    />
+
+                    <SaveAddressButton
+                        data={{
+                            username,
+                            telephone,
+                            province,
+                            city,
+                            area,
+                            address,
+                            id
+                        }}
+                    />
+                </div>
+
             </div>
         )
     }
 }
 
-export default AddAddress
+export default SingleAddress
 
-class AddAddressButton extends Component {
+class DefaultAndSaveButton extends Component {
     constructor(props) {
         super(props)
-        this.state = {
+        this.state = {}
+    }
 
-        }
+    render() {
+        // let {data} = this.props
+        return (
+            <div className='address-button'>
+                <Button block size='large'>设为默认并保存</Button>
+            </div>
+        )
+    }
+}
+
+
+class SaveAddressButton extends Component {
+    constructor(props) {
+        super(props)
+        this.state = {}
     }
 
     render() {
         // let {data} = this.props
         return (
-            <div className='add-address-button'>
+            <div className='address-button'>
                 <Button type='primary' block size='large'>保存并使用</Button>
             </div>
         )