diff --git a/src/app.js b/src/app.js index 8e116fe..62dc2b9 100644 --- a/src/app.js +++ b/src/app.js @@ -20,6 +20,7 @@ class App extends Component { pages: [ 'pages/index/index', 'pages/home/home', + 'pages/shop/shop', ], window: { backgroundTextStyle: 'light', diff --git a/src/component/bottomNav/bottomNav.js b/src/component/bottomNav/bottomNav.js new file mode 100644 index 0000000..c998cd9 --- /dev/null +++ b/src/component/bottomNav/bottomNav.js @@ -0,0 +1,67 @@ +import Taro, { Component } from '@tarojs/taro' +import { View} from '@tarojs/components' + +import { AtTabBar } from 'taro-ui' + +import './bottomNav.scss' + +class bottomNav extends Component { + + config = { + navigationBarTitleText: 'bottomNav' + } + constructor(){ + super(...arguments); + + this.state={ + current:0 + } + + } + handleClick(value){ + this.setState({ + current: value + }) + let path=this.props.otherData.menu[value].url + Taro.navigateTo({ + url: path, + }) + + } + + componentWillReceiveProps(nextProps) { + //console.log(this.props, nextProps) + } + + componentWillUnmount() { } + + componentDidShow() { } + + componentDidHide() { } + + render() { + + const otherDataElementsArray = this.props.otherData.menu? this.props.otherData.menu.map((item, index) => { + return { title: item.name, iconType: 'clock' } + }):null + return ( + + + + + ) +} +} + +export default bottomNav + diff --git a/src/component/bottomNav/bottomNav.scss b/src/component/bottomNav/bottomNav.scss new file mode 100644 index 0000000..e69de29 diff --git a/src/component/filteredShopComponent/filteredShopComponent.js b/src/component/filteredShopComponent/filteredShopComponent.js index 691465e..d993929 100644 --- a/src/component/filteredShopComponent/filteredShopComponent.js +++ b/src/component/filteredShopComponent/filteredShopComponent.js @@ -3,16 +3,21 @@ import { View, Button, Text,Image } from '@tarojs/components' import { AtIcon } from 'taro-ui' import './filteredShopComponent.scss' + +import URL from '../../serviceAPI.config' const hornIcon = require('../../icons/horn.png') const houseIcon = require('../../icons/house.png') - - - class recommondShop extends Component { config = { navigationBarTitleText: 'recommondShop' } + goToShop(value) { + + Taro.navigateTo({ + url: '/pages/shop/shop?id='+value.shop_id+'&name='+value.shop_name + }) + } componentWillReceiveProps(nextProps) { //console.log(this.props, nextProps) @@ -27,23 +32,22 @@ class recommondShop extends Component { render() { const title = this.props.shop.shop_name - const imgUrl = 'http://192.168.1.230/' + this.props.shop.goods[0].goods_url + const imgUrl = URL.Base + this.props.shop.goods[0].goods_url const price = this.props.shop.goods[0].goods_price const goods = this.props.shop.goods const ProductName = this.props.shop.goods[0].goods_name const address = this.props.shop.shop_address const distance = this.props.shop.distance const ads = this.props.shop.ads - // const consultText = this.props.shop.wx_open const voucherLeft = this.props.shop.left_nums const goodsElementsArray=goods.slice(1).map((item,index)=>{ return - + }) return ( - + @@ -56,7 +60,7 @@ class recommondShop extends Component { - + {goods.length !== 1 ? goodsElementsArray: diff --git a/src/component/filteredShopComponent/filteredShopComponent.scss b/src/component/filteredShopComponent/filteredShopComponent.scss index 726b63e..bdd3bc5 100644 --- a/src/component/filteredShopComponent/filteredShopComponent.scss +++ b/src/component/filteredShopComponent/filteredShopComponent.scss @@ -8,7 +8,7 @@ border-bottom:1px solid #F2F2F2; display: flex; .title{ - width: 50%; + width: 55%; color: #333; font-weight: bold; font-size: 30px; @@ -16,7 +16,7 @@ } .consult-voucher-button{ - width: 50%; + width: 45%; //margin-top: 20px ; margin-left: 200px; display: flex; diff --git a/src/index.html b/src/index.html index 0291a98..b9dc84d 100644 --- a/src/index.html +++ b/src/index.html @@ -8,6 +8,8 @@ + + Taro diff --git a/src/pages/home/home.js b/src/pages/home/home.js index f181b4b..d5a154f 100644 --- a/src/pages/home/home.js +++ b/src/pages/home/home.js @@ -1,10 +1,9 @@ import Taro, { Component } from '@tarojs/taro' import { View, Button, Text, Swiper, SwiperItem, Image } from '@tarojs/components' -import { AtButton } from 'taro-ui' +import { AtActivityIndicator } from 'taro-ui' import filteredShopComponent from '../../component/filteredShopComponent/filteredShopComponent' - -import { add, minus, asyncAdd } from '../../actions/counter' - +import bottomNav from '../../component/bottomNav/bottomNav' +import URL from '../../serviceAPI.config' import './home.scss' class Home extends Component { @@ -13,15 +12,22 @@ class Home extends Component { navigationBarTitleText: '首页' } constructor() { + super(...arguments); + this.state = { shopsDetails: '', ads: '', categories: '', demanding: '', + otherData:'' } } + componentWillMount(){ + + } componentDidMount() { + this.getShops() this.getHomeCategoriesInfo() } @@ -35,9 +41,10 @@ class Home extends Component { componentDidHide() { } +// 得到首页的信息 getHomeCategoriesInfo() { Taro.request({ - url: 'http://192.168.1.230/Shop-wxStore', + url: URL.ShopWxStore, }) .then(res => { console.log(res) @@ -45,14 +52,16 @@ class Home extends Component { ads: res.data.data.adsLb, categories: res.data.data.supplyClass, demanding: res.data.data.demand.supplys, + otherData:res.data.otherData }, () => { //console.log(this.state.demanding) }) }) } + // 得到所有商店的信息 getShops(parent_supply_class = 0, supply_class = '-1', supply_level = 1) { Taro.request({ - url: 'http://192.168.1.230/Shop-supplyShops', + url: URL.ShopSupplyShops, method: 'POST', dataType: 'json', data: { @@ -66,7 +75,8 @@ class Home extends Component { }) }, header: { - 'content-type': 'application/x-www-form-urlencoded' + 'content-type': 'application/x-www-form-urlencoded', + } }) .then(res => { @@ -84,8 +94,9 @@ class Home extends Component { this.getShops(item.parent_class_id, item.class_id, 2) } + render() { - const demandingElemensArray = this.state.demanding.map((item, index) => { + const demandingElemensArray = this.state.demanding?this.state.demanding.map((item, index) => { return < SwiperItem key={index} > @@ -105,39 +116,44 @@ class Home extends Component { - }) + }) :null - const adsImgElementsArray = this.state.ads.map((item, index) => { + const adsImgElementsArray = this.state.ads?this.state.ads.map((item, index) => { return - + - }) + }):null // 这里应该代码可以优化----- - const categoriesElementsArray1 = this.state.categories[0].map((item, index) => { + const categoriesElementsArray1 = this.state.categories?this.state.categories[0].map((item, index) => { return - + {item.class_name} - }) - const categoriesElementsArray2 = this.state.categories[1].map((item, index) => { + }):null + const categoriesElementsArray2 = this.state.categories?this.state.categories[1].map((item, index) => { return - + {item.class_name} - }) - const shopCollectionElementsArray = this.state.shopsDetails.map((item, index) => { + }):null + const shopCollectionElementsArray = this.state.shopsDetails?this.state.shopsDetails.map((item, index) => { return - }) - - const subCateElementsArray = this.state.subCate.map((item, index) => { + }):null + + const subCateElementsArray = this.state.subCate?this.state.subCate.map((item, index) => { return {item.class_name} - }) + }):null + + + return ( + {/* 第一行图片滚动条 */} + - {adsImgElementsArray} @@ -190,17 +205,7 @@ class Home extends Component { - - - {subCateElementsArray} - - + {/* 业主需求和行业推荐 */} @@ -226,16 +231,40 @@ class Home extends Component { + + + + {subCateElementsArray} + 行业推荐 + {shopCollectionElementsArray} + {this.state.shopsDetails.length !== 0 ? + 沒有更多了... + : < View className='title' > + 没有找到... + } + + + + + + + ) } diff --git a/src/pages/home/home.scss b/src/pages/home/home.scss index d8a3986..8559302 100644 --- a/src/pages/home/home.scss +++ b/src/pages/home/home.scss @@ -1,4 +1,5 @@ .home{ + overflow: hidden; .banner-img{ width: 100% } @@ -84,7 +85,19 @@ } .shop-box{ padding:0 20px; + .title{ + text-align: center; + color: #999; + font-size: 25px; + height: 180px + } } + .bottom-nav-box{ + .bottom-nav{ + height: 20px + } + } + } .second-banner{ diff --git a/src/pages/shop/shop.js b/src/pages/shop/shop.js new file mode 100644 index 0000000..7d11263 --- /dev/null +++ b/src/pages/shop/shop.js @@ -0,0 +1,132 @@ +import Taro, { Component } from '@tarojs/taro' +import { View, Button, Text, Swiper, SwiperItem, Image } from '@tarojs/components' +import { AtSearchBar, Picker } from 'taro-ui' +import URL from '../../serviceAPI.config' + +import './shop.scss' + +class Shop extends Component { + // 项目配置 + config = { + navigationBarTitleText: '店铺' + } + constructor() { + super(...arguments) + this.state = { + value: '', + shopId:'', + shopName:'' + } + } + onChange(value) { + this.setState({ + value: value + }) + } + onActionClick() { + console.log('开始搜索') + } + + getShopInfo() { + Taro.request({ + url: URL.GoodsSearch, + method:'POST', + dataType: 'json', + data:{ + goods: JSON.stringify({ + curr_page: 1, + page_count: 50, + shop_name: false, + shop_id: 1254, + config_id: 4, + shop_class_id: '', + order: 'g.browse_times desc', + currPage: 1, + goods_class_id: 10401 + }), + goodsRegion: JSON.stringify({}), + goodsSpec: JSON.stringify([]), + goodsParam: JSON.stringify([]), + goodsParamExt: JSON.stringify([]), + + }, + header: { + 'content-type': 'application/x-www-form-urlencoded', + 'X-Requested-With':'XMLHttpRequest' + } + }) + .then(res => { + console.log('res--',res) + + }) + } + componentWillMount() { + this.setState({ shopId: this.$router.params.id, shopName: this.$router.params.name}) // 输出 { id: 2, type: 'test' } + } + componentDidMount(){ + + this.getShopInfo() + } + + + + componentDidShow() { } + + componentDidHide() { } + + render() { + const shopName= this.state.shopName + console.log(shopName) + return ( + + + + + + + {shopName} + + + + + + 店铺全部分类 + + + + + + 首页 + + + + + + 店铺说明 + + + + + + + + + + + + + + + + + + ) + } +} + +export default Shop diff --git a/src/pages/shop/shop.scss b/src/pages/shop/shop.scss new file mode 100644 index 0000000..e9cbad8 --- /dev/null +++ b/src/pages/shop/shop.scss @@ -0,0 +1,30 @@ + +.banner-box{ + position: relative; + .shop-name{ + position: absolute; + top:100px; + left:60px; + font-size: 50px + } +} + +.nav-box{ + + background-color: black; + .nav{ + display: flex; + line-height: 55px; + .text{ + color:white; + font-size: 28px + } + .shop-cate{ + flex:1 + } + .home-link{ + flex:1 + } + } + +} \ No newline at end of file diff --git a/src/serviceAPI.config.js b/src/serviceAPI.config.js new file mode 100644 index 0000000..622334a --- /dev/null +++ b/src/serviceAPI.config.js @@ -0,0 +1,11 @@ + +const LOCALURL = "http://192.168.1.230/" +const URL = { + Base:LOCALURL, + ShopWxStore: LOCALURL + 'Shop-wxStore', //商城首页信息 + ShopSupplyShops: LOCALURL + 'Shop-supplyShops',// 商城店铺信息 + GoodsSearch: LOCALURL + 'GoodsSearch-search',// 店铺页面的信息 + +} + +module.exports = URL \ No newline at end of file