From 161862d12fc6d10567b18259885a0bc70d24c581 Mon Sep 17 00:00:00 2001 From: Maoqiang Zheng Date: Tue, 11 Dec 2018 17:34:06 +0800 Subject: [PATCH] =?UTF-8?q?=E6=89=80=E6=9C=89=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/app.js | 2 +- src/pages/allDemanding/allDemanding.js | 79 ++++++++------- src/pages/allDemanding/allDemanding.scss | 8 +- src/pages/goods/goods.js | 38 ++++--- src/pages/goods/goods.scss | 4 +- src/pages/goodsPublish/goodsPublish.js | 96 +++++++++++------- src/pages/goodsPublish/goodsPublish.scss | 3 + src/pages/home/home.js | 46 ++++----- src/pages/index/index.js | 4 +- src/pages/mySupplyDemand/mySupplyDemand.js | 87 +++++++++------- src/pages/shop/shop.js | 53 +++++----- .../supplyDemandPublish.js} | 99 +++++++++++-------- .../supplyDemandPublish.scss} | 0 13 files changed, 295 insertions(+), 224 deletions(-) rename src/pages/{supplyDemandPubish/supplyDemandPubish.js => supplyDemandPublish/supplyDemandPublish.js} (68%) rename src/pages/{supplyDemandPubish/supplyDemandPubish.scss => supplyDemandPublish/supplyDemandPublish.scss} (100%) diff --git a/src/app.js b/src/app.js index b411d8e..98fa62e 100644 --- a/src/app.js +++ b/src/app.js @@ -23,7 +23,7 @@ class App extends Component { 'pages/shop/shop', 'pages/goods/goods', 'pages/goodsPublish/goodsPublish', - 'pages/supplyDemandPubish/supplyDemandPubish', + 'pages/supplyDemandPublish/supplyDemandPublish', 'pages/mySupplyDemand/mySupplyDemand', 'pages/allDemanding/allDemanding', ], diff --git a/src/pages/allDemanding/allDemanding.js b/src/pages/allDemanding/allDemanding.js index ff0828b..936bf16 100644 --- a/src/pages/allDemanding/allDemanding.js +++ b/src/pages/allDemanding/allDemanding.js @@ -17,14 +17,14 @@ class AllDemanding extends Component { constructor() { super(...arguments) this.state = { - supplys:[], - isMore:'more', - selector: ['全部', '需求', '供应', '人才'], - selectorChecked: '全部', - selector1: ['全部', '上架', '下架'], - selectorChecked1: '全部', - dateSel: '2018-04-22', - + supplys:[], // 需求列表 + isMore:'more', // 上拉加载状态 + demandingState: [ '需求', '供应', '人才'], // 供求状态选择 + demandingStateSelected:'全部', // 当前供求状态 + industryCate: ['制定家具', '成品家具', '办公家具','设计'], // 行业分类状态选择 + industryCateSelected: '全部', // 当前行业分类状态 + startDateSel: '2018-04-22', + endDateSel: '2018-04-22', } } GetAllDemanding({ curr_page=1, page_count=20}) { @@ -52,6 +52,8 @@ class AllDemanding extends Component { } }) } + + // 向上拉升延迟一秒加载数据 handleLoadMore(){ this.setState({isMore:'loading'}) setTimeout(() => { @@ -59,17 +61,29 @@ class AllDemanding extends Component { this.GetAllDemanding({ curr_page: currentPage }) }, 1000); - } - onChange = e => { + // 改变需求选项 + changeDemandingState = e => { this.setState({ - selectorChecked: this.state.selector[e.detail.value] + demandingStateSelected: this.state.demandingState[e.detail.value] }) } - - onDateChange = e => { + // 改变行业类别选项 + changeIndustryCate = e => { this.setState({ - dateSel: e.detail.value + industryCateSelected: this.state.industryCate[e.detail.value] + }) + } + //改变开始日期 + onStartDateChange = e => { + this.setState({ + startDateSel: e.detail.value + }) + } +// 改变结束日期 + onEndDateChange = e => { + this.setState({ + endDateSel: e.detail.value }) } @@ -78,6 +92,7 @@ class AllDemanding extends Component { console.log(this.props, nextProps) } componentDidMount(){ + // 得到第一页需求数据 this.GetAllDemanding({}) } @@ -93,7 +108,8 @@ class AllDemanding extends Component { return - 业主:{item.user_name} + + 业主:{item.user_name} {item.class_name+' '} | @@ -112,9 +128,7 @@ class AllDemanding extends Component { 抢单 - - 没有数据 @@ -126,12 +140,12 @@ class AllDemanding extends Component { return ( - + {/* 供求状态选择 */} - + - *供求状态: {this.state.selectorChecked1} + *供求状态: {this.state.demandingStateSelected} @@ -149,39 +163,33 @@ class AllDemanding extends Component { onChange={this.handleChange.bind(this)} /> - - + {/* 开始和结束日期选择 */} - - + - *开始日期: {this.state.dateSel} + *开始日期: {this.state.startDateSel} - - + - *结束日期: {this.state.dateSel} + *结束日期: {this.state.endDateSel} - - + {/* 行业分类选择 */} - - + - *供求状态: {this.state.selectorChecked1} + *行业分类: {this.state.industryCateSelected} - @@ -193,7 +201,8 @@ class AllDemanding extends Component { 搜索 - + {/* 供求页面的数据加载 */} + {allDemandingElementArray} { this.setState({ selectorChecked: this.state.selector[e.detail.value] @@ -67,7 +68,7 @@ class Goods extends Component { render() { const mainTabList = [{ title: '宝贝详情' }, { title: '全部评价' }, { title: '猜你喜欢' }] - const subTabList = [{ title: '全部' }, { title: '好评' }, { title: '差评' }, { title: '公开' }, { title: '匿名' }] + // const subTabList = [{ title: '全部' }, { title: '好评' }, { title: '差评' }, { title: '公开' }, { title: '匿名' }] return ( @@ -121,12 +122,7 @@ class Goods extends Component { - {/* - 可选规格 - - - >点击 - */} + {/* 规格或者数量 */} @@ -139,14 +135,16 @@ class Goods extends Component { + {/* 详情和评论区 */} + {/* 大类 */} 商品细节: - { /*子标签Tab*/} + { /*子标签类*/} { + // 改变商品分类状态 + onChange(e){ this.setState({ selectorChecked: this.state.selector[e.detail.value] }) } - onChange(files) { + productNameChange(event){ this.setState({ - files + productName: event }) } + productPriceChange(event){ + this.setState({ + productPrice: event + }) + } + productUnitChange(event){ + this.setState({ + productUnit: event + }) + } + productDescriptChange(event){ + this.setState({ + productDescript: event.target.value + }) + } + // 上传图片 + onChangeImg(files,operationType) { + if (operationType === 'add') { + this.setState({ + files + }) + } + if (operationType === 'remove') { + this.state.files.splice(index, 1); + this.setState({ files: this.state.files }); + } + + } + // 图片上传失败 onFail(mes) { console.log(mes) } - onImageClick(index, file) { - console.log(index, file) + // 删除图片 + onImageClick(index) { + } componentWillReceiveProps(nextProps) { @@ -83,14 +118,11 @@ class GoodsPublish extends Component { return ( - - - - + *商品分类: {this.state.selectorChecked} @@ -104,11 +136,11 @@ class GoodsPublish extends Component { * @@ -116,10 +148,10 @@ class GoodsPublish extends Component { @@ -128,33 +160,28 @@ class GoodsPublish extends Component { name='value' title='商品单位:' type='text' - value={this.state.value} - onChange={this.handleChange.bind(this)} + value={this.state.productUnit} + onChange={this.productUnitChange.bind(this)} /> - + {/* 图片上传 */} - * 上传图片: - - - - - + {/* 店铺分类 */} * 店铺分类: @@ -209,12 +236,13 @@ class GoodsPublish extends Component { + 商品简介: diff --git a/src/pages/goodsPublish/goodsPublish.scss b/src/pages/goodsPublish/goodsPublish.scss index 99f59dc..0b5010f 100644 --- a/src/pages/goodsPublish/goodsPublish.scss +++ b/src/pages/goodsPublish/goodsPublish.scss @@ -8,6 +8,9 @@ .at-input__container{ color:black; font-weight: bold; + .at-input__input{ + font-weight: normal + } } .img-box{ margin-top:10Px; diff --git a/src/pages/home/home.js b/src/pages/home/home.js index eb62d9a..996e06a 100644 --- a/src/pages/home/home.js +++ b/src/pages/home/home.js @@ -13,29 +13,24 @@ class Home extends Component { } constructor() { super(...arguments); - this.state = { - shopsDetails: '', - ads: '', - categories: '', - subCate:[], - demanding: '', - otherData:'' + shopsDetails: [], // 推荐店铺的信息 + ads: [], //广告图片数组 + categories: [],// 大类 + subCate:[], //小类 + demanding: [],// 业主需求 + otherData:[] // 底部导航栏 } } componentWillMount(){ - } componentDidMount() { - + // 页面加载后 得到首页的基本信息和推荐店铺的信息 this.getShops() this.getHomeCategoriesInfo() } - componentWillReceiveProps(nextProps) { - //console.log(this.props, nextProps) - } - + componentWillUnmount() { } componentDidShow() { } @@ -48,18 +43,16 @@ class Home extends Component { url: URL.ShopWxStore, }) .then(res => { - console.log(res) + console.log('首页基本信息',res) this.setState({ 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: URL.ShopSupplyShops, @@ -81,19 +74,22 @@ class Home extends Component { } }) .then(res => { + console.log('所有店铺的信息', res) this.setState({ shopsDetails: res.data.shops }, () => { - // console.log('-----',res) }) } ) } + // 点击大类 onClickParentCate(item) { this.setState({ subCate: item.children }) this.getShops(item.parent_class_id, item.class_id) } + // 点击子类 onClickChildCate(item) { this.getShops(item.parent_class_id, item.class_id, 2) } + // 转到其他页面 goToAllDemandingPage(){ Taro.navigateTo({ url: '/pages/allDemanding/allDemanding' @@ -101,7 +97,7 @@ class Home extends Component { } render() { - const demandingElemensArray = this.state.demanding?this.state.demanding.map((item, index) => { + const demandingElemensArray = this.state.demanding.length?this.state.demanding.map((item, index) => { return < SwiperItem key={index} > @@ -123,26 +119,26 @@ class Home extends Component { }) :null - const adsImgElementsArray = this.state.ads?this.state.ads.map((item, index) => { + const adsImgElementsArray = this.state.ads.length?this.state.ads.map((item, index) => { return }):null // 这里应该代码可以优化----- - const categoriesElementsArray1 = this.state.categories?this.state.categories[0].map((item, index) => { + const categoriesElementsArray1 = this.state.categories[0].length?this.state.categories[0].map((item, index) => { return {item.class_name} }):null - const categoriesElementsArray2 = this.state.categories?this.state.categories[1].map((item, index) => { + const categoriesElementsArray2 = this.state.categories.length?this.state.categories[1].map((item, index) => { return {item.class_name} }):null - const shopCollectionElementsArray = this.state.shopsDetails?this.state.shopsDetails.map((item, index) => { + const shopCollectionElementsArray = this.state.shopsDetails.length?this.state.shopsDetails.map((item, index) => { return }):null @@ -153,7 +149,6 @@ class Home extends Component { }):null - console.log(this.state.subCate) return ( {/* 第一行图片滚动条 */} @@ -272,9 +267,6 @@ class Home extends Component { - - - diff --git a/src/pages/index/index.js b/src/pages/index/index.js index 4bb4943..7478476 100644 --- a/src/pages/index/index.js +++ b/src/pages/index/index.js @@ -1,5 +1,5 @@ import Taro, { Component } from '@tarojs/taro' -import { View, Button, Text } from '@tarojs/components' +import { View } from '@tarojs/components' import { connect } from '@tarojs/redux' import { add, minus, asyncAdd } from '../../actions/counter' @@ -30,7 +30,7 @@ class Index extends Component { Taro.navigateTo({ // url: '/pages/home/home' // url: '/pages/goodsPublish/goodsPublish' - url: '/pages/goods/goods' + url: '/pages/home/home' }) } componentWillReceiveProps (nextProps) { diff --git a/src/pages/mySupplyDemand/mySupplyDemand.js b/src/pages/mySupplyDemand/mySupplyDemand.js index 77d186a..2937063 100644 --- a/src/pages/mySupplyDemand/mySupplyDemand.js +++ b/src/pages/mySupplyDemand/mySupplyDemand.js @@ -1,5 +1,5 @@ import Taro, { Component } from '@tarojs/taro' -import { View, Button, Text } from '@tarojs/components' +import { View, Text } from '@tarojs/components' import { AtInput, AtButton, Picker,AtIcon } from 'taro-ui' import copyrightComponent from '../../component/copyrightComponent/copyrightComponent' @@ -18,27 +18,41 @@ class MySupplyDemand extends Component { constructor() { super(...arguments) this.state = { - selector: ['全部','需求', '供应', '人才'], - selectorChecked: '全部', - selector1: ['全部','上架', '下架'], - selectorChecked1: '全部', - dateSel: '2018-04-22', + demandSupplyCate: ['全部','需求', '供应', '人才'], + demandSupplyCateSelected: '全部', + demandSupplyState: ['全部','上架', '下架'], + demandSupplyStatesSelected: '全部', + title:'', + startDateSel: '2018-04-22', + endDateSel: '2018-04-22', } } - onChange = e => { + //修改供求类型 + demSupplyCateChange = e => { this.setState({ - selectorChecked: this.state.selector[e.detail.value] + demandSupplyCateSelected: this.state.demandSupplyCate[e.detail.value] }) } - onChange1 = e => { + // 修改供求状态 + demSupplyStateChange = e => { this.setState({ - selectorChecked1: this.state.selector1[e.detail.value] + demandSupplyStatesSelected: this.state.demandSupplyState[e.detail.value] }) } - onDateChange = e => { + titleChange(event){ + this.setState({title:event}) + } + // 修改开始日期 + onStartDateChange = e => { this.setState({ - dateSel: e.detail.value + startDateSel: e.detail.value + }) + } + // 修改结束日期 + onEndDateChange = e => { + this.setState({ + endDateSel: e.detail.value }) } @@ -58,32 +72,33 @@ class MySupplyDemand extends Component { return ( - + {/* 供求类型 */} - + - *供求类型: {this.state.selectorChecked} - - - - - - - - - - - - - *供求状态: {this.state.selectorChecked1} + *供求类型: {this.state.demandSupplyCateSelected} + + + + + + {/* 供求状态 */} + + + + + + + *供求状态: {this.state.demandSupplyStatesSelected} + {/* 供求标题 */} * + {/* 开始和结束日期 */} - - + - *开始日期: {this.state.dateSel} + *开始日期: {this.state.startDateSel} - + - *结束日期: {this.state.dateSel} + *结束日期: {this.state.endDateSel} - @@ -131,6 +145,7 @@ class MySupplyDemand extends Component { 一共20 条记录 + {/* 我的供求信息 */} diff --git a/src/pages/shop/shop.js b/src/pages/shop/shop.js index a890d5a..1122b6e 100644 --- a/src/pages/shop/shop.js +++ b/src/pages/shop/shop.js @@ -1,6 +1,6 @@ import Taro, { Component } from '@tarojs/taro' -import { View, Button, Text, Swiper, SwiperItem, Image } from '@tarojs/components' -import { AtSearchBar, AtTag, AtIcon ,AtSegmentedControl, AtTabBar, AtDrawer } from 'taro-ui' +import { View, Button, Text, Image } from '@tarojs/components' +import { AtSearchBar, AtTag, AtIcon } from 'taro-ui' import URL from '../../serviceAPI.config' import './shop.scss' @@ -16,15 +16,16 @@ class Shop extends Component { constructor() { super(...arguments) this.state = { - shopItem:'', - value: '', - shopId:'', - shopName:'', - FilterText:'', + isShopDetailsOn:false, // 是否显示店铺说明页面 + shopItem:'', // 所有商品 + value: '', // 搜索框的值 + shopId:'', // 店铺的id + shopName:'', // 店铺名 + FilterText:'', // 筛选的可选项 filterBar:['综合排序','销量','新品','价格','人气'], - selectedFilterValue:0, - isShowFilter:false, - 综合排序:true, + selectedFilterValue:0, //筛选项 + isShowFilter:false, //是否显示侧边筛选 + 综合排序:true, 销量:false, 新品:false, 价格:false, @@ -41,6 +42,7 @@ class Shop extends Component { } } + // 搜索栏值的改变方法 onChange(value) { this.setState({ @@ -49,7 +51,7 @@ class Shop extends Component { console.log(this.state.value) }) } - + // 搜索栏的方法 getSearchBarkeyWords(){ Taro.request({ url: URL.SearchBarKeyWords, @@ -64,10 +66,12 @@ class Shop extends Component { 'X-Requested-With': 'XMLHttpRequest' } }).then(res => { - console.log(res) + console.log('搜索栏的搜索结果',res) }) } + + // 得到筛选的标签 getSearchParams({shop_name = false, shop_id = 1305, shop_class_id = "", goods_class_id=0,class_filter=0}){ Taro.request({ url: URL.GetSearchParam, @@ -97,7 +101,7 @@ class Shop extends Component { }) } - // get goods info + // 得到所有的产品 goodsSearch({ curr_page = 1, page_count = 50, shop_name = false, shop_id = 1305, config_id = 4, shop_class_id = '', order = '', currPage = 1 }) { Taro.request({ url: URL.GoodsSearch, @@ -130,6 +134,7 @@ class Shop extends Component { this.setState({ shopItem:res.data}) }) } + // 产品排序 accendingDescending(value){ this.setState({selectedFilterValue:value}) if(value==0){ @@ -161,9 +166,11 @@ class Shop extends Component { } } + // 是否显示侧边筛选 showAndHideFilter(){ this.setState({ isShowFilter: !this.state.isShowFilter }) } + // 选择侧边筛选的标签 selectTag(value){ for(let item in this.state.cate){ if(value===item){ @@ -173,9 +180,7 @@ class Shop extends Component { [item]:!this.state.cate[item] } }),()=>{ - this.getSearchParams({ goods_class_id: value , class_filter :1}) - }) } } @@ -185,9 +190,10 @@ class Shop extends Component { this.setState({ shopId: this.$router.params.id, shopName: this.$router.params.name}) // 输出 { id: 2, type: 'test' } } componentDidMount(){ + //页面加载之后 得到指定店铺的商品 和 筛选标签 this.goodsSearch({}) - this.getSearchParams({}) - this.getSearchBarkeyWords() + this.getSearchParams({}) + // this.getSearchBarkeyWords() } componentDidShow() { } @@ -195,7 +201,7 @@ class Shop extends Component { componentDidHide() { } render() { - const shopName= this.state.shopName + // const shopName= this.state.shopName const ShopItemElementsArray =this.state.shopItem? this.state.shopItem.goods.map((item,index)=>{ return @@ -215,7 +221,7 @@ class Shop extends Component { // const widthness = this.state.FilterText ? this.state.FilterText.goodsParamExt[5].param_value[0] : null // filter 宽度选项 - // 分类 + // 侧边筛选的分类项 const goodsClassElementsArray = this.state.FilterText.goods_class ? this.state.FilterText.goods_class.map((item, index) => { @@ -227,7 +233,7 @@ class Shop extends Component { onClick={this.selectTag.bind(this, item.class_id)} >{item.class_name} }):null - // 商品类型 + // 侧边筛选的商品类型项 const goodsTypeKeyArray = this.state.FilterText.goods_type ? Object.keys(this.state.FilterText.goods_type):null const goodsTypeElementsArray = goodsTypeKeyArray ? goodsTypeKeyArray.map((key, index) => { let object = this.state.FilterText.goods_type @@ -239,7 +245,7 @@ class Shop extends Component { >{object[key].goods_type_ch_name} }):null - //--------- + // 侧边筛选的其他项 const goodsParamKeyArray = this.state.FilterText.goodsParam ? Object.keys(this.state.FilterText.goodsParam):null const goodsParamElementsArray = goodsParamKeyArray ? goodsParamKeyArray.map((key, index) => { let object = this.state.FilterText.goodsParam @@ -301,7 +307,7 @@ class Shop extends Component { - {/* sidebar 筛选 */} + {/* 侧边筛选 */} 分类 @@ -327,6 +333,7 @@ class Shop extends Component { + {/* 店铺的商品列表 */} {ShopItemElementsArray} @@ -335,9 +342,7 @@ class Shop extends Component { - - ) } diff --git a/src/pages/supplyDemandPubish/supplyDemandPubish.js b/src/pages/supplyDemandPublish/supplyDemandPublish.js similarity index 68% rename from src/pages/supplyDemandPubish/supplyDemandPubish.js rename to src/pages/supplyDemandPublish/supplyDemandPublish.js index 385b435..3dec5c1 100644 --- a/src/pages/supplyDemandPubish/supplyDemandPubish.js +++ b/src/pages/supplyDemandPublish/supplyDemandPublish.js @@ -7,7 +7,7 @@ import SearchBarComponent from '../../component/searchBarComponent/searchBarComp import copyrightComponent from '../../component/copyrightComponent/copyrightComponent' -import './supplyDemandPubish.scss' +import './supplyDemandPublish.scss' @@ -19,11 +19,16 @@ class SupplyDemand extends Component { constructor() { super(...arguments) this.state = { - selector: ['需求', '供应', '人才'], - selectorChecked: '需求', - selector1: ['上架', '下架'], - selectorChecked1: '上架', - addImg:true, + demandingSupplyCate: ['需求', '供应', '人才'], //供求类型选择 + demandingSupplyCateSelected: '需求',// 当前供求类型 + demandingSupplyState: ['上架', '下架'], // 状态选择 + demandingSupplyStateSelected: '上架',// 当前状态 + title:'', + contactName:'', + contactNumber:'', + contactAddress:'', + content:'', + addImg:true, // 是否支持添加图片 files: [{ url: 'https://jimczj.gitee.io/lazyrepay/aragaki1.jpeg', }, @@ -36,19 +41,36 @@ class SupplyDemand extends Component { } } - // onChange = e => { - // this.setState({ - // selectorChecked: this.state.selector[e.detail.value] - // }) - // } - onChange1 = e => { + // 修改供求类型 + demandingSupplyCate = e => { this.setState({ - selectorChecked1: this.state.selector1[e.detail.value] + demandingSupplyCateSelected: this.state.demandingSupplyCate[e.detail.value] }) } - + // 修改供求状态 + demSupplyStateChange = e => { + this.setState({ + demandingSupplyStateSelected: this.state.demandingSupplyState[e.detail.value] + }) + } + //改标题 + titleChange(event){ + this.setState({title:event}) + } + contactNameChange(event){ + this.setState({contactName:event}) + } + contactNumberChange(event){ + this.setState({contactNumber:event}) + } + contactAddressChange(event){ + this.setState({contactAddress:event.target.value}) + } + contentChange(event){ + this.setState({ content: event.target.value}) + } + // 添加图片 onChange(files, operationType,index) { - console.log(files, operationType,index) if (operationType==='add'){ this.setState({ files @@ -86,25 +108,23 @@ class SupplyDemand extends Component { - + - *供求类型: {this.state.selectorChecked} + *供求类型: {this.state.demandingSupplyCateSelected} - - * @@ -113,8 +133,8 @@ class SupplyDemand extends Component { name='value' title='联系人:' type='text' - value={this.state.value} - onChange={this.handleChange.bind(this)} + value={this.state.contactName} + onChange={this.contactNameChange.bind(this)} /> @@ -123,32 +143,32 @@ class SupplyDemand extends Component { name='value' title='联系电话:' type='number' - value={this.state.value} - onChange={this.handleChange.bind(this)} + value={this.state.contactNumber} + onChange={this.contactNumberChange.bind(this)} /> + + *联系地址: + - *需求内容: - - @@ -158,23 +178,22 @@ class SupplyDemand extends Component { - - + - *状态: {this.state.selectorChecked1} + *状态: {this.state.demandingSupplyStateSelected} diff --git a/src/pages/supplyDemandPubish/supplyDemandPubish.scss b/src/pages/supplyDemandPublish/supplyDemandPublish.scss similarity index 100% rename from src/pages/supplyDemandPubish/supplyDemandPubish.scss rename to src/pages/supplyDemandPublish/supplyDemandPublish.scss