Csy817 6 жил өмнө
parent
commit
a3e74d91f5

+ 4 - 2
src/configs/url.js

@@ -1,5 +1,7 @@
-// const graphqlFC = 'https://ec.ioobot.cn/graphql';            // old schema fc mongodb
-const graphqlFC = 'http://ecenhance.ioobot.cn/graphql';      // new schema fc mongodb
+// const graphqlEndpoint = 'http://ecenhance.ioobot.cn/graphql';            // old schema fc mongodb
+const graphqlEndpoint = 'http://ecommerce.ioobot.cn/graphql';
+const graphqlFC = window.location.hostname !== 'localhost' ? window.location.origin+'/graphql' : graphqlEndpoint;
+
 // const graphqlFC = 'http://ecommerce.ioobot.cn/graphql';      // new schema server mongodb
 const storeFile = 'http://deploy.ioobot.cn/api/store-file';
 

+ 47 - 87
src/pages/home/all/index.js

@@ -4,7 +4,7 @@ import {Query} from "react-apollo"
 import gql from "graphql-tag"
 import {Grid, Carousel, WhiteSpace, ActivityIndicator} from 'antd-mobile'
 import Logo from '../../../components/logo'
-import {category_by_props, productbyprops} from "../../../utils/gql"
+import {slideshow_by_props, category_by_props, productbyprops} from "../../../utils/gql"
 import './index.css'
 
 class All extends Component {
@@ -28,29 +28,6 @@ class All extends Component {
             "sort_by": {"order": "asc"}
         }
 
-        const demo = [
-            {
-                icon: 'https://green-1258802564.cos.ap-beijing.myqcloud.com/plant.png',
-                text: '松柏',
-                id: 'more'
-            },
-            {
-                icon: 'https://green-1258802564.cos.ap-beijing.myqcloud.com/plant.png',
-                text: '花果',
-                id: 'more'
-            },
-            {
-                icon: 'https://green-1258802564.cos.ap-beijing.myqcloud.com/plant.png',
-                text: '杂木',
-                id: 'more'
-            },
-            {
-                icon: 'https://green-1258802564.cos.ap-beijing.myqcloud.com/plant.png',
-                text: '藤本',
-                id: 'more'
-            }
-        ]
-
         const more = {
             icon: 'https://ece-img-1254337200.cos.ap-chengdu.myqcloud.com/icon/more.png',
             text: '更多',
@@ -59,31 +36,52 @@ class All extends Component {
 
         return (
             <div>
-                <Carousel
-                    autoplay={true}
-                    infinite
-                    style={{minHeight: 200}}
-                >
-                    {this.state.data.map(val => (
-                        <a
-                            key={val}
-                            href="http://www.alipay.com"
-                            style={{
-                                display: 'inline-block',
-                                width: '100%',
-                                height: 'auto',
-                                maxHeight: '200px',
-                                overflow: 'hidden'
-                            }}
-                        >
-                            <img
-                                src={val}
-                                alt=""
-                                style={{width: '100%', verticalAlign: 'top'}}
-                            />
-                        </a>
-                    ))}
-                </Carousel>
+				<Query query={gql(slideshow_by_props)} >
+					{
+						({loading, error, data}) => {
+							if (loading) {
+								return (
+									<div className="loading-center">
+										<ActivityIndicator text="加载中..." size="large"/>
+									</div>
+								)
+							}
+							if (error) {
+								return 'error!'
+							}
+
+							let slideshow = data.slideshowbyprops || []
+
+							return (
+								<Carousel
+									autoplay={true}
+									infinite
+									style={{minHeight: 200}}
+								>
+									{slideshow.map(val => (
+										<a
+											key={val.id}
+											href="http://www.alipay.com"
+											style={{
+												display: 'inline-block',
+												width: '100%',
+												height: 'auto',
+												maxHeight: '200px',
+												overflow: 'hidden'
+											}}
+										>
+											<img
+												src={val.img}
+												alt=""
+												style={{width: '100%', verticalAlign: 'top'}}
+											/>
+										</a>
+									))}
+								</Carousel>
+							)
+						}
+					}
+				</Query>
                 <Query query={gql(category_by_props)} variables={categoryFilter}>
                     {
                         ({loading, error, data}) => {
@@ -101,14 +99,9 @@ class All extends Component {
                             let categoryList = data.categorybyprops
                             let dataList = categoryList.concat(more)
 
-                            let demoDataList = demo.concat(more)
-
                             return (
                                 <Grid
                                     data={dataList}
-                                    dataOther={demoDataList}
-                                    // data={demoDataList}
-                                    // dataOther={dataList}
                                     hasLine={false}
                                     onClick={(kind) => {
                                         this.props.history.push({
@@ -160,44 +153,11 @@ class Recommend extends Component {
 
     render() {
         let {data} = this.props
-        let demoData = [
-            {
-                id: '1',
-                name: '北欧仿真植物装饰龟背竹绿植盆栽旅人蕉假树天堂鸟室内网红大型',
-                price: 100,
-                discountRate: 80,
-                img: 'https://green-1258802564.cos.ap-beijing.myqcloud.com/pfzd1.jpeg'
-            },
-            {
-                id: '2',
-                name: '北欧仿真植物装饰龟背竹绿植盆栽旅人蕉假树天堂鸟室内网红大型',
-                price: 200,
-                discountRate: 80,
-                img: 'https://green-1258802564.cos.ap-beijing.myqcloud.com/pfzd2.jpg'
-            },
-            {
-                id: '3',
-                name: '北欧仿真植物装饰龟背竹绿植盆栽旅人蕉假树天堂鸟室内网红大型',
-                price: 300,
-                discountRate: 80,
-                img: 'https://green-1258802564.cos.ap-beijing.myqcloud.com/pfzd1.jpeg'
-            },
-            {
-                id: '4',
-                name: '北欧仿真植物装饰龟背竹绿植盆栽旅人蕉假树天堂鸟室内网红大型',
-                price: 200,
-                discountRate: 80,
-                img: 'https://green-1258802564.cos.ap-beijing.myqcloud.com/pfzd2.jpg'
-            }
-        ]
         return (
             <div className='guess-wrapper'>
                 <div className='guess-title'>- 店长推荐 -</div>
                 <Grid
                     data={data}
-                    demoData={demoData}
-                    // data={demoData}
-                    // demoData={data}
                     columnNum={2}
                     hasLine={false}
                     onClick={(recommend) => {

+ 13 - 1
src/utils/gql.js

@@ -866,6 +866,17 @@ const delete_product_by_id = `
     }
 `
 
+const slideshow_by_props = `
+    query slideshowbyprops($updatedAt: String, $where: slideshow_filter, $sort_by: slideshow_sort_by, $limit: Int, $order_by: OrderBy, $name: String, $createdAt: String, $filter: Filter, $status: Int, $img: String, $skip: Int) {
+    slideshowbyprops: slideshow_by_props(updatedAt: $updatedAt where: $where sort_by: $sort_by limit: $limit order_by: $order_by name: $name createdAt: $createdAt filter: $filter status: $status img: $img skip: $skip) {
+        id
+        name
+        img
+        status
+    }
+  }
+`
+
 export {
     create_user,
     find_user_by_openid,
@@ -902,5 +913,6 @@ export {
     update_shop,
     create_product,
     update_product,
-    delete_product_by_id
+    delete_product_by_id,
+	slideshow_by_props
 }