Csy817 6 éve
szülő
commit
68b5b2089b

+ 1 - 1
src/configs/url.js

@@ -3,7 +3,7 @@ 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';
+const storeFile = `${window.location.protocol}//deploy.ioobot.cn/api/store-file`;
 
 export {graphqlFC, storeFile}
 

+ 8 - 13
src/pages/home/all/index.js

@@ -4,20 +4,13 @@ import {Query} from "react-apollo"
 import gql from "graphql-tag"
 import {Grid, Carousel, WhiteSpace, ActivityIndicator} from 'antd-mobile'
 import Logo from '../../../components/logo'
-import {slideshow_by_props, category_by_props, productbyprops} from "../../../utils/gql"
+import {category_by_props, productbyprops, slideshow_by_shop} from "../../../utils/gql"
 import './index.css'
 
 class All extends Component {
     constructor(props) {
         super(props)
         this.state = {
-            data: [
-                'https://ece-img-1254337200.cos.ap-chengdu.myqcloud.com/ecslider1.jpg',
-                'https://zos.alipayobjects.com/rmsportal/AiyWuByWklrrUDlFignR.png',
-                'https://zos.alipayobjects.com/rmsportal/TekJlZRVCjLFexlOCuWn.png',
-                // 'https://green-1258802564.cos.ap-beijing.myqcloud.com/shop.jpg',
-                'https://zos.alipayobjects.com/rmsportal/IJOtIlfsYdTyaDTRVrLI.png'
-            ]
         }
     }
 
@@ -36,7 +29,7 @@ class All extends Component {
 
         return (
             <div>
-				<Query query={gql(slideshow_by_props)} >
+				<Query query={gql(slideshow_by_shop)} >
 					{
 						({loading, error, data}) => {
 							if (loading) {
@@ -50,7 +43,9 @@ class All extends Component {
 								return 'error!'
 							}
 
-							let slideshow = data.slideshowbyprops || []
+							console.log("slideshow_by_shop data",data)
+							// let slideshow = data.slideshowbyprops || []
+							let slideshow = data.slideshowbyshop[0].slideshow || []
 
 							return (
 								<Carousel
@@ -60,7 +55,7 @@ class All extends Component {
 								>
 									{slideshow.map(val => (
 										<a
-											key={val.id}
+											key={val}
 											href="http://www.alipay.com"
 											style={{
 												display: 'inline-block',
@@ -71,7 +66,7 @@ class All extends Component {
 											}}
 										>
 											<img
-												src={val.img}
+												src={val}
 												alt=""
 												style={{width: '100%', verticalAlign: 'top'}}
 											/>
@@ -186,4 +181,4 @@ class Recommend extends Component {
     }
 }
 
-export default withRouter(All)
+export default withRouter(All)

+ 6 - 3
src/pages/my/manage/goods/index.js

@@ -35,6 +35,7 @@ import moment from 'moment'
 import {storeFile} from "../../../../configs/url"
 import axios from 'axios'
 import classNames from 'classnames'
+import {getCookie} from "../../../../utils/cookie"
 
 const Item = List.Item
 const categoryFilterRefetch = {
@@ -438,14 +439,15 @@ class AddGoods extends Component {
 
     onChange = (id) => (files, operationType) => {
         let imgDatas = []
+			  let openid = getCookie("openid")
 
-        files.forEach((file, index) => {
+			files.forEach((file, index) => {
             let base64Cont = files[index].url.split(',')[1]
             let imgType = files[index].file.type.split('/')[1]
             let imgNewName = `good_id_${id}.${imgType}`
 
             const imgData = {
-                'file-name': `e-commerce/images/${imgNewName}`,
+							  'file-name': `e-commerce/images/${openid}/img/${imgNewName}`,
                 'bucket': 'case',
                 'cont': base64Cont,
                 'public': true,
@@ -502,6 +504,7 @@ class AddGoods extends Component {
                             <div>
                                 <List className="my-add-goods-list">
                                     <InputItem onChange={(e) => {
+                                    	console.log("my-add-goods-list e",e)
                                         this.setState({name: e})
                                     }} value={name} placeholder="请输入名称">名称</InputItem>
                                     <Query query={gql(category_by_props)} variables={categoryFilter}>
@@ -879,4 +882,4 @@ class AddSpecStock extends Component {
     }
 }
 
-export default withRouter(Goods)
+export default withRouter(Goods)

+ 24 - 8
src/pages/my/manage/shop/index.js

@@ -1,14 +1,15 @@
 import React, {Component} from 'react'
 import './index.css'
-import {NavBar, Icon} from 'antd-mobile'
+import {NavBar, Icon, ActivityIndicator, List, ImagePicker, InputItem, Button} from 'antd-mobile'
+import {message} from 'antd'
 import {withRouter} from 'react-router-dom'
-import {ActivityIndicator, List, ImagePicker, InputItem, Button} from 'antd-mobile'
 import axios from 'axios'
 import {Query, Mutation} from "react-apollo"
 import gql from "graphql-tag"
 import {shop_by_props, create_shop, update_shop} from "../../../../utils/gql"
 import {storeFile} from "../../../../configs/url"
 import moment from 'moment'
+import {getCookie} from "../../../../utils/cookie"
 
 const Item = List.Item
 
@@ -99,9 +100,10 @@ class ShopRender extends Component {
     }
 
     onChange = (files, operationType) => {
-        console.log("files", files, "operationType", operationType)
+        // console.log("files", files, "operationType", operationType)
 
         let imgDatas = []
+			  let openid = getCookie("openid")
         let {shopID} = this.state
 
         files.forEach((file, index) => {
@@ -110,7 +112,7 @@ class ShopRender extends Component {
             let imgNewName = `slideshow_${index}_shopID_${shopID}.${imgType}`
 
             const imgData = {
-                'file-name': `e-commerce/images/${imgNewName}`,
+                'file-name': `e-commerce/images/${openid}/slideshow/${imgNewName}`,
                 'bucket': 'case',
                 'cont': base64Cont,
                 'public': true,
@@ -124,7 +126,7 @@ class ShopRender extends Component {
             files
         })
 
-        console.log(imgDatas, 'imgDatas')
+        // console.log(imgDatas, 'imgDatas')
     }
 
     onReset = () => {
@@ -257,10 +259,24 @@ class UpdateShopButton extends Component {
                                     let slideshow = imgDatas.length === 1 ? prefix + imgDatas[0]['file-name'] : imgDatas.map((imgData, index) => (
                                         prefix + imgDatas[index]['file-name']
                                     ))
-                                    updatestore({variables: {...varObj, slideshow}})
+                                    updatestore({variables: {...varObj, slideshow}}).then((data)=>{
+																			// console.log("updatestore1 data",data)
+																			if(data.data && data.data.updateshop.result === "ok"){
+                                    		message.success('更新成功')
+																			}else {
+																				message.success('更新失败,请稍后重试')
+																			}
+																		})
                                 })
                             } else {
-                                updatestore({variables: varObj})
+                                updatestore({variables: varObj}).then((data)=>{
+																	// console.log("updatestore1 data",data)
+																	if(data.data && data.data.updateshop.result === "ok"){
+																		message.success('更新成功')
+																	}else {
+																		message.success('更新失败,请稍后重试')
+																	}
+																})
                             }
                         }}>更新</Button>
                     )
@@ -333,4 +349,4 @@ class CreateShopButton extends Component {
     }
 }
 
-export default withRouter(Shop)
+export default withRouter(Shop)

+ 11 - 2
src/utils/gql.js

@@ -877,6 +877,14 @@ const slideshow_by_props = `
   }
 `
 
+const slideshow_by_shop = `
+    query slideshowbyshop {
+        slideshowbyshop: shop_by_props {
+            slideshow
+        }
+    }
+`
+
 export {
     create_user,
     find_user_by_openid,
@@ -914,5 +922,6 @@ export {
     create_product,
     update_product,
     delete_product_by_id,
-	slideshow_by_props
-}
+	  slideshow_by_props,
+	  slideshow_by_shop
+}