From 156abaf917d024f9079cb40c6d6268269b65b72b Mon Sep 17 00:00:00 2001 From: Maoqiang Zheng Date: Thu, 17 Jan 2019 08:52:30 +0800 Subject: [PATCH] =?UTF-8?q?=E5=8F=91=E5=B8=83=E4=B8=8E=E7=BC=96=E8=BE=91?= =?UTF-8?q?=20=E6=8C=89=E9=92=AE=E4=B8=AA=E6=95=B0=EF=BC=8C=E8=81=94?= =?UTF-8?q?=E7=B3=BB=E7=94=B5=E8=AF=9D=E9=95=BF=E5=BA=A6=EF=BC=8C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/component/bottomNav/bottomNav.js | 3 +- .../filteredShopComponent.js | 146 +- .../filteredShopComponent.scss | 7 +- .../voucherPosterComponent.js | 58 +- .../voucherPosterComponent.scss | 65 +- .../scrollToTopComponent.scss | 2 +- .../shopItemComponent/shopItemComponent.js | 1 - src/pages/allDemanding/allDemanding.js | 27 +- src/pages/goods/goods.js | 6 +- src/pages/goodsPublish/goodsPublish.js | 96 +- src/pages/goodsPublish/goodsPublish.scss | 12 +- src/pages/home/home.js | 40 +- src/pages/home/home.scss | 2 + src/pages/index/index.js | 2 +- .../myDemandSupplyEdit/myDemandSupplyEdit.js | 197 ++- .../myDemandSupplyEdit.scss | 12 +- src/pages/myGoodList/myGoodList.js | 223 +-- src/pages/myGoodList/myGoodList.scss | 30 +- src/pages/myGoodsEdit/myGoodsEdit.js | 158 +- src/pages/myGoodsEdit/myGoodsEdit.scss | 12 +- src/pages/myNeeds/myNeeds.js | 74 +- src/pages/myNeeds/myNeeds.scss | 21 +- src/pages/myNeedsEdit/myNeedsEdit.js | 207 ++- src/pages/myNeedsEdit/myNeedsEdit.scss | 14 +- src/pages/myNeedsPublish/myNeedsPublish.js | 124 +- src/pages/myNeedsPublish/myNeedsPublish.scss | 12 +- src/pages/myNeedsView/myNeedsView.js | 126 +- src/pages/myNeedsView/myNeedsView.scss | 17 +- src/pages/mySupplyDemand/mySupplyDemand.js | 156 +- src/pages/mySupplyDemand/mySupplyDemand.scss | 17 +- src/pages/shop/shop.js | 100 +- .../supplyDemandPublish.js | 135 +- .../supplyDemandPublish.scss | 12 +- .../supplyDemandView/supplyDemandView.js | 6 +- .../supplyDemandView/supplyDemandView.scss | 18 +- src/todo list.txt | 1422 ++++++++--------- 36 files changed, 1992 insertions(+), 1568 deletions(-) diff --git a/src/component/bottomNav/bottomNav.js b/src/component/bottomNav/bottomNav.js index 639155a..89d1b16 100644 --- a/src/component/bottomNav/bottomNav.js +++ b/src/component/bottomNav/bottomNav.js @@ -37,6 +37,7 @@ class bottomNav extends Component { }) } + componentWillReceiveProps(nextProps) { @@ -50,7 +51,7 @@ class bottomNav extends Component { componentDidHide() { } render() { - + const otherDataElementsArray = this.state.otherData.map((item) => { return { title: item.name, iconType: 'clock' } }) diff --git a/src/component/filteredShopComponent/filteredShopComponent.js b/src/component/filteredShopComponent/filteredShopComponent.js index 9662587..6e84df1 100644 --- a/src/component/filteredShopComponent/filteredShopComponent.js +++ b/src/component/filteredShopComponent/filteredShopComponent.js @@ -1,6 +1,6 @@ import Taro, { Component } from '@tarojs/taro' -import { View, Button, Text, Image } from '@tarojs/components' -import { AtIcon, AtModal, AtModalHeader, AtModalContent, AtModalAction, AtInput, AtNoticebar } from 'taro-ui' +import { View, Button, Text, Image, Input } from '@tarojs/components' +import { AtIcon, AtModal, AtModalHeader, AtModalContent, AtModalAction, AtNoticebar } from 'taro-ui' import VoucherPosterComponent from './voucherPosterComponent/voucherPosterComponent' @@ -11,8 +11,16 @@ const hornIcon = require('../../icons/horn.png') const houseIcon = require('../../icons/house.png') class recommondShop extends Component { - static options = { - addGlobalClass: true + + static defaultProps = { + shop: { + shop_name: 'kobe', + goods: [{ goods_url: 'www.kobe.com', goods_price: '999', goods_name: 'kobe' }], + shop_address: 'kobe road', + distance: '247km', + ads: 'Have you ever seen Los Angels sun dawn in 4 AM in the morning?', + left_nums: '999' + } } config = { @@ -26,10 +34,8 @@ class recommondShop extends Component { consultTip: '', voucherResponseMsg: '', voucherCanConsult: false, - voucherName: this.props.userName, - voucherPhone: this.props.userPhone, - consultName: this.props.userName, - consultPhone: this.props.userPhone, + userName: Taro.getStorageSync('user_identity').username, + userPhone: Taro.getStorageSync('user_identity').userphone, } } goToShop(value) { @@ -135,7 +141,7 @@ class recommondShop extends Component { } voucherModalConfirm() { this.setState({ isOpenVoucher: false }) - this.buyConsult({ user: this.state.voucherName, phone: this.state.voucherPhone }) + this.buyConsult({ user: this.state.userName, phone: this.state.userPhone }) } // 咨询弹框。取消。确认 isOpenConsult() { @@ -147,19 +153,19 @@ class recommondShop extends Component { } consultModalConfirm() { this.setState({ isOpenConsult: false }) - this.buyConsult({ user: this.state.consultName, phone: this.state.consultPhone }) + this.buyConsult({ user: this.state.userName, phone: this.state.userPhone }) } handleInputVcherPhone(value) { - this.setState({ voucherPhone: value }) + this.setState({ userPhone: value }) } handleInputVcherName(value) { - this.setState({ voucherName: value }) + this.setState({ userName: value }) } handleInputCsultName(value) { - this.setState({ consultName: value }) + this.setState({ userName: value }) } handleInputCsultPhone(value) { - this.setState({ consultPhone: value }) + this.setState({ userPhone: value }) } getDataFromChild(value) { console.log('从voucherposter件传回来的值', value) @@ -179,84 +185,60 @@ class recommondShop extends Component { componentDidHide() { } - render() { - // console.log('店铺',this.props.shop) - const title = this.props.shop ? this.props.shop.shop_name : null - const imgUrl = this.props.shop ? URL.Base + this.props.shop.goods[0].goods_url : null - const price = this.props.shop ? this.props.shop.goods[0].goods_price : null - const goods = this.props.shop ? this.props.shop.goods : null - const ProductName = this.props.shop ? this.props.shop.goods[0].goods_name : null - const address = this.props.shop ? this.props.shop.shop_address : null - const distance = this.props.shop ? this.props.shop.distance : null - const ads = this.props.shop ? this.props.shop.ads : null - const voucherLeft = this.props.shop ? this.props.shop.left_nums : null - // const consultText = this.props.shop.wx_open + render() { + const title = this.props.shop.shop_name + 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 voucherLeft = this.props.shop.left_nums // 优惠卷是否为灰色 + const isShowConsultButton = this.props.shop.wx_open === '0' ? false : true // 优惠卷是否为灰色 const slicedGoods = goods !== null ? goods.slice(1) : null const goodsElementsArray = goods !== null ? slicedGoods.map((item, index) => { return - + }) : null // 优惠卷和咨询元素 - // const voucherModalElement = - // 优惠卷须知: - // - // - // 提示:具体可以前往实体店进行领取优惠卷或通过电话进行咨询 - // - // 当前优惠卷{voucherLeft}张 - // - // - // {!this.state.voucherCanConsult ? {this.state.voucherResponseMsg} : null} - - // - // - // - - - const consultModalElement = 咨询 - 提示:{this.state.consultTip} + 提示:{this.state.consultTip} + + + 联系人: + + - - - + + + + 联系电话: + + + - + @@ -280,18 +262,14 @@ class recommondShop extends Component { {voucherLeft ? - : + : } - + + {isShowConsultButton ? - - - - {/* {voucherLeft ? : } - - */} + : null} diff --git a/src/component/filteredShopComponent/filteredShopComponent.scss b/src/component/filteredShopComponent/filteredShopComponent.scss index 1d88faa..84fc1da 100644 --- a/src/component/filteredShopComponent/filteredShopComponent.scss +++ b/src/component/filteredShopComponent/filteredShopComponent.scss @@ -38,7 +38,7 @@ $linearBlue:linear-gradient(to right, #337ab7, #337ab7); .button{ // margin-left:2%; text-align: center; - margin-left:25%; + // margin-left:22%; } .blur{ opacity: 0.5; @@ -67,11 +67,12 @@ $linearBlue:linear-gradient(to right, #337ab7, #337ab7); margin-bottom:2%; padding:0; } - .consult-voucher-button{ + .button-container{ flex:1; //margin-top: 20px ; margin-left: 50px; display: flex; + justify-content: flex-end; //vertical-align: middle; .consult-button-text{ @@ -120,7 +121,7 @@ $linearBlue:linear-gradient(to right, #337ab7, #337ab7); margin-top: 20px; .goods-img{ - border: 1px solid #ddd; + border: 2px solid #ddd; width: 90px; height: 90px; margin: 10px diff --git a/src/component/filteredShopComponent/voucherPosterComponent/voucherPosterComponent.js b/src/component/filteredShopComponent/voucherPosterComponent/voucherPosterComponent.js index d441fa8..536c190 100644 --- a/src/component/filteredShopComponent/voucherPosterComponent/voucherPosterComponent.js +++ b/src/component/filteredShopComponent/voucherPosterComponent/voucherPosterComponent.js @@ -1,5 +1,5 @@ import Taro, { Component } from '@tarojs/taro' -import { View, Input, Image, Text, Button } from '@tarojs/components' +import { View, Input, Text, Button } from '@tarojs/components' import { AtIcon } from 'taro-ui' import './voucherPosterComponent.scss' @@ -43,24 +43,52 @@ class VoucherPoster extends Component { }) .then(res => { console.log('购买咨询请求成功', res) - if (res.statusCode === 200) { - Taro.showToast({ title: '领取成功', icon: 'success',duration:1500}) - - setTimeout(() => { - this.passDataToParent() - }, 1500); - + + if (res.data.err_msg === 'success') { + Taro.showToast({ + title: '领取成功', + icon: 'success', + duration: 1500 + }) + setTimeout(() => { + this.passDataToParent() + }, 1500); + } else { - Taro.showToast({ title: res.data.err_msg, icon: 'none' }) + Taro.showToast({ + title: res.data.err_msg, + icon: 'none', + duration: 1500 + }) } + + + + + + }).catch(err => { console.log('购买咨询请求失败', err) }) } // 确认键 voucherModalConfirm() { - this.buyConsult({ user: this.state.voucherName, phone: this.state.voucherPhone }) + if (!this.state.voucherName) { + Taro.showToast({ + title: '请填写姓名', + icon: 'fail', + }) + } else if (!this.state.voucherPhone) { + Taro.showToast({ + title: '请填写电话号码', + icon: 'fail', + }) + } else { + this.buyConsult({ user: this.state.voucherName, phone: this.state.voucherPhone }) + + } + } //名字输入 handleNameChange(value) { @@ -68,7 +96,7 @@ class VoucherPoster extends Component { } //号码输入 handlePhoneChange(value) { - this.setState({ voucherPhone: value.detail.value }) + this.setState({ voucherPhone: value.detail.value }) } passDataToParent() { this.props.onPassDataToChild(false) @@ -109,8 +137,14 @@ class VoucherPoster extends Component { 联系电话: - + + + + + + + {this.props.voucherResponseMsg} diff --git a/src/component/filteredShopComponent/voucherPosterComponent/voucherPosterComponent.scss b/src/component/filteredShopComponent/voucherPosterComponent/voucherPosterComponent.scss index d3ff9fe..ed40f27 100644 --- a/src/component/filteredShopComponent/voucherPosterComponent/voucherPosterComponent.scss +++ b/src/component/filteredShopComponent/voucherPosterComponent/voucherPosterComponent.scss @@ -56,50 +56,28 @@ $linearOrange:linear-gradient(to right, #FF7142, #FF7142); font-size: 50px; } } - .input-name{ - margin-top:2%; - margin-left:10%; + // .input-name,.input-number{ + // margin-top:2%; + // margin-left:10%; - overflow: hidden; - width: 80%; + // overflow: hidden; + // width: 80%; + + // border-radius:50rpx; + // background-color: white; + + // height:80px; + // font-size:25px; + // display:flex; + // align-items:center; + // .title{ + // margin-left:7%; + // } - border-radius:50rpx; - background-color: white; - display: flex; - height:80px; - font-size:25px; - .title{ - flex:1; - margin-left:7%; - margin-top:4% - } - .input-info{ - flex:2; - margin-top:3.5% - } - } - .input-number{ - margin-top:2%; - margin-left:10%; - overflow: hidden; - width: 80%; - border-radius:50rpx; - background-color: white; - display: flex; - height:80px; - font-size:25px; - .title{ - flex:1; - margin-left:7%; - margin-top:4% - } - .input-info{ - flex:2; - margin-top:3.5% - } - - } + // } + + .tips{ margin-left: 10%; @@ -122,7 +100,6 @@ $linearOrange:linear-gradient(to right, #FF7142, #FF7142); font-size: 28px; background:$linearOrange; padding: 12rpx; - // margin:20px auto } } @@ -146,6 +123,10 @@ $linearOrange:linear-gradient(to right, #FF7142, #FF7142); }} + .input-box{ + display: flex; + align-items: center; +} /* Add Animation */ @-webkit-keyframes animatetop { diff --git a/src/component/scrollToTopComponent/scrollToTopComponent.scss b/src/component/scrollToTopComponent/scrollToTopComponent.scss index 855d3d2..238460d 100644 --- a/src/component/scrollToTopComponent/scrollToTopComponent.scss +++ b/src/component/scrollToTopComponent/scrollToTopComponent.scss @@ -6,7 +6,7 @@ border-radius:50%; text-align:center; position:fixed; - bottom:8%; + bottom:10%; right:5%; font-size:25rpx; .box{ diff --git a/src/component/shopItemComponent/shopItemComponent.js b/src/component/shopItemComponent/shopItemComponent.js index f6a021b..df6530f 100644 --- a/src/component/shopItemComponent/shopItemComponent.js +++ b/src/component/shopItemComponent/shopItemComponent.js @@ -3,7 +3,6 @@ import { View, Image, Text } from '@tarojs/components' import eyeIcon from '../../icons/eye.png' import cartIcon from '../../icons/cart.png' -import errorImg from '../../assets/img/errorimg.png' import './shopItemComponent.scss' diff --git a/src/pages/allDemanding/allDemanding.js b/src/pages/allDemanding/allDemanding.js index 8d3a70d..d6eccd0 100644 --- a/src/pages/allDemanding/allDemanding.js +++ b/src/pages/allDemanding/allDemanding.js @@ -2,16 +2,16 @@ import Taro, { Component } from '@tarojs/taro' import { View, Text, Image, Button } from '@tarojs/components' import { AtInput, Picker, AtIcon, AtModal, AtToast, AtModalHeader, AtModalContent, AtModalAction } from 'taro-ui' import CopyrightComponent from '../../component/copyrightComponent/copyrightComponent' +import ScrollToTopComponent from '../../component/scrollToTopComponent/scrollToTopComponent' import InteractionComponent from '../../component/interactionComponent/interactionComponent' import URL from '../../serviceAPI.config' import './allDemanding.scss' - import eyeIcon from '../../icons/eye.png' -let loadMorePageIndex = 1 // 底部加载接口请求参数 + class AllDemanding extends Component { config = { @@ -33,7 +33,8 @@ class AllDemanding extends Component { grabOrderSuccess: '无法显示绑定后的字段',// 抢单成功返回字段 currentPage: 1, isAddToList: false,// / 请求业主需求的时候是否添加到旧列表里 - + isShowTopNav: false,// 是否显示返回顶部按钮 + loadMorePageIndex: 1 } } @@ -74,7 +75,7 @@ class AllDemanding extends Component { if (res.data.err_msg === 'success') { if (res.data.supplys.length) { if (this.state.isAddToList) { - this.setState({ supplys: this.state.supplys.concat(res.data.supplys) }) + this.setState({ supplys: this.state.supplys.concat(res.data.supplys),isAddToList:false }) } else { this.setState({ supplys: res.data.supplys }) } @@ -219,15 +220,23 @@ class AllDemanding extends Component { componentDidShow() { } componentDidHide() { } + // 页面位置 + onPageScroll(location) { + if (location.scrollTop <= 300 && this.state.isShowTopNav) { + this.setState({ isShowTopNav: false }) + } else if (location.scrollTop > 300 && !this.state.isShowTopNav) { + this.setState({ isShowTopNav: true }) + } + } // 底部加载 onReachBottom() { Taro.showLoading({ title: '加载中' }) - loadMorePageIndex += 1 - this.setState({ isAddToList: true }, () => { - this.searchDemanding({ curr_page: loadMorePageIndex }) + + this.setState({ isAddToList: true, loadMorePageIndex: this.state.loadMorePageIndex + 1 }, () => { + this.searchDemanding({ curr_page: this.state.loadMorePageIndex }) }) } @@ -271,7 +280,7 @@ class AllDemanding extends Component { {item.state_name === '在用' ? : - + } @@ -354,7 +363,7 @@ class AllDemanding extends Component { {allDemandingElementArray} - + {this.state.isShowTopNav ? : null} ) diff --git a/src/pages/goods/goods.js b/src/pages/goods/goods.js index ebfade6..e3c415a 100644 --- a/src/pages/goods/goods.js +++ b/src/pages/goods/goods.js @@ -227,8 +227,8 @@ class Goods extends Component { {/* 详情和评论区 */} {/* 大类 */} - - + + 商品细节: @@ -290,6 +290,8 @@ class Goods extends Component { + + diff --git a/src/pages/goodsPublish/goodsPublish.js b/src/pages/goodsPublish/goodsPublish.js index 3585a2e..e19eb0a 100644 --- a/src/pages/goodsPublish/goodsPublish.js +++ b/src/pages/goodsPublish/goodsPublish.js @@ -31,6 +31,8 @@ class GoodsPublish extends Component { ImagesInfo: [],// 后台传回来的图片信息 shopCategoryList: [], productCategoryList: [], + isPublishAndAdd:false,// 是否点击发布新增按钮 + isPublish:false, // 时候点击发布按钮 } } @@ -104,10 +106,17 @@ class GoodsPublish extends Component { duration: 1000 }) setTimeout(() => { - - Taro.navigateTo({ - url: '/pages/goods/goods?id=' + res.data.goods_id - }) + if(this.state.isPublish){ + // 导航到编辑页面 + Taro.navigateTo({ + url: '/pages/myGoodsEdit/myGoodsEdit?id=' + res.data.goods_id + }) + }else if(this.state.isPublishAndAdd){ + // 导航到发布页面 + Taro.navigateTo({ + url: '/pages/goodsPublish/goodsPublish' + }) + } }, 1000); } @@ -167,7 +176,7 @@ class GoodsPublish extends Component { filePath: files[files.length - 1].url, name: 'file', formData: { - user: 'test' + }, header: { 'content-type': 'multipart/form-data', @@ -175,17 +184,28 @@ class GoodsPublish extends Component { 'X-Requested-With': 'XMLHttpRequest' }, success(response) { - const data = JSON.parse(response.data) - const imagePath = URL.Base + data.file_path - const newPickerImageUrl = that.state.pickerImageUrl.concat({ url: imagePath }) - const newImageInfo = that.state.ImagesInfo.concat(data) - that.setState({ pickerImageUrl: newPickerImageUrl, ImagesInfo: newImageInfo }, () => { - Taro.showToast({ - title: '上传成功', - icon: 'success', - duration: 2000 + const responseMsg=JSON.parse(response.data).err_msg + if (responseMsg=== 'success'||responseMsg === 'duplicate') { + const data = JSON.parse(response.data) + const imagePath = URL.Base + data.file_path + const newPickerImageUrl = that.state.pickerImageUrl.concat({ url: imagePath }) + const newImageInfo = that.state.ImagesInfo.concat(data) + that.setState({ pickerImageUrl: newPickerImageUrl, ImagesInfo: newImageInfo }, () => { + Taro.showToast({ + title: '上传成功', + icon: 'success', + duration: 2000 + }) }) - }) + + } else { + Taro.showToast({ + title: responseMsg, + icon: 'none', + duration: 1500 + }) + } + } }) } @@ -201,7 +221,7 @@ class GoodsPublish extends Component { } } - onClickUploadGoods() { + publishButtonHandler() { if (this.state.productName && this.state.productPrice && this.state.productUnit && @@ -209,7 +229,7 @@ class GoodsPublish extends Component { this.state.goodsTypeSelected.id && this.state.shopTypeSelected.id) { Taro.showLoading({ title: '发布中' }).then(() => { - setTimeout(() => { + this.setState({isPublish:true},()=>{ this.uploadGoods({ goods_name: this.state.productName, goods_price: this.state.productPrice, @@ -218,13 +238,44 @@ class GoodsPublish extends Component { class_id: this.state.goodsTypeSelected.id, shop_class_id: this.state.shopTypeSelected.id, }) - }, 1000) + + }) + + }) } else { Taro.showToast({ title: '请填写完表格', icon: 'none' }) } } + publishAndNewButton() { + if (this.state.productName && + this.state.productPrice && + this.state.productUnit && + this.state.ImagesInfo.length && + this.state.goodsTypeSelected.id && + this.state.shopTypeSelected.id) { + Taro.showLoading({ title: '发布中' }).then(() => { + this.setState({isPublishAndAdd:true},()=>{ + this.uploadGoods({ + goods_name: this.state.productName, + goods_price: this.state.productPrice, + goods_unit: this.state.productUnit, + goods_profiles: this.state.productDescript, + class_id: this.state.goodsTypeSelected.id, + shop_class_id: this.state.shopTypeSelected.id, + }) + + }) + + + }) + + } else { + Taro.showToast({ title: '请填写完表格', icon: 'none' }) + } + } + goToMyGoodListPage() { Taro.navigateTo({ @@ -261,7 +312,7 @@ class GoodsPublish extends Component { return ( - + {/* 商品分类开始 */} 商品简介: - - - + {/* */} + + + diff --git a/src/pages/goodsPublish/goodsPublish.scss b/src/pages/goodsPublish/goodsPublish.scss index 00474d8..c669bd8 100644 --- a/src/pages/goodsPublish/goodsPublish.scss +++ b/src/pages/goodsPublish/goodsPublish.scss @@ -77,17 +77,11 @@ $themeColor:#FF7142; flex-wrap: nowrap; flex-direction: row; margin: 40px 0 0; - padding: 0 120px; + justify-content: space-around; .button{ - flex:1; text-align: center; - .at-button--primary{ - background-color:$themeColor; - border:1PX solid $themeColor; - } - .button-a{ - background-color:#5cb85c; - border:1PX solid #5cb85c; + .button-orange, .button-dark-red,.button-green{ + font-size:27rpx; } } } diff --git a/src/pages/home/home.js b/src/pages/home/home.js index 297daa7..8c3635e 100644 --- a/src/pages/home/home.js +++ b/src/pages/home/home.js @@ -10,7 +10,7 @@ import URL from '../../serviceAPI.config' import './home.scss' -let loadMorePageIndex = 1 // 底部加载接口请求参数 + class Home extends Component { config = { @@ -20,7 +20,7 @@ class Home extends Component { constructor() { super(...arguments); this.state = { - shopsDetails: [], // 推荐店铺的信息 + shops: [], // 推荐店铺的信息 ads: [], //广告图片数组 categories: [],// 大类 subCate: [], //小类 @@ -30,7 +30,8 @@ class Home extends Component { grabOrderId: '',//抢到订单的id userName: '',//用户名字 userPhone: '',// 用户电话 - isShowTopNav: false, + isShowTopNav: false,// 是否显示返回顶部按钮 + loadMorePageIndex: 1,//下拉加载页面数 } } @@ -103,7 +104,7 @@ class Home extends Component { Taro.hideLoading() if (res.data.err_msg === 'success') { if (res.data.shops.length) { - this.setState({ shopsDetails: this.state.shopsDetails.concat(res.data.shops) }) + this.setState({ shops: this.state.shops.concat(res.data.shops) }) } else { Taro.showToast({ title: '没有更多了', @@ -151,7 +152,7 @@ class Home extends Component { Taro.hideLoading() if (res.data.err_msg === 'success') { - this.setState({ shopsDetails: res.data.shops }) + this.setState({ shops: res.data.shops }) Taro.hideLoading() } else { @@ -336,6 +337,7 @@ class Home extends Component { } componentDidMount() { // 页面加载后 得到首页的基本信息和推荐店铺的信息 + console.log('地址', this.$router) Taro.showLoading({ title: '加载中' }) this.login().then(() => { @@ -363,9 +365,9 @@ class Home extends Component { } // 页面位置 onPageScroll(location) { - if (location.scrollTop <= 300&&this.state.isShowTopNav) { + if (location.scrollTop <= 300 && this.state.isShowTopNav) { this.setState({ isShowTopNav: false }) - } else if(location.scrollTop >300&&!this.state.isShowTopNav) { + } else if (location.scrollTop > 300 && !this.state.isShowTopNav) { this.setState({ isShowTopNav: true }) } } @@ -374,10 +376,9 @@ class Home extends Component { Taro.showLoading({ title: '加载中' }) - setTimeout(() => { - loadMorePageIndex += 1 - this.getShops({ curr_page: loadMorePageIndex }) - }, 1000); + this.setState({ loadMorePageIndex: this.state.loadMorePageIndex + 1 }, () => { + this.getShops({ curr_page: this.state.loadMorePageIndex }) + }) } @@ -385,7 +386,6 @@ class Home extends Component { render() { - // 提示模态弹窗element const modalMessageGrabElement = 提示 @@ -413,7 +413,7 @@ class Home extends Component { - + @@ -439,10 +439,14 @@ class Home extends Component { {item.class_name} }) : null - const shopCollectionElementsArray = this.state.shopsDetails.length ? this.state.shopsDetails.map((item, index) => { - return - }) : null - + const shopCollectionElementsArray = this.state.shops.map((item, index) => { + return + }) const subCateElementsArray = this.state.subCate.length ? this.state.subCate.map((item, index) => { return {item.class_name} @@ -476,7 +480,7 @@ class Home extends Component { {/* 第二行图片滚动条 */} item.id == res.data.sdInfo.state)[0] const imageFile = res.data.sdInfo.file_path.map(item => { return { url: URL.Base + item.file_path } }) this.setState({ + demandSupplyId: res.data.sdInfo.sd_id, demandingSupplyCateSelected: selectedType, title: res.data.sdInfo.sd_title, contactName: res.data.sdInfo.user_name, @@ -76,35 +81,7 @@ class MyDemandSupplyEdit extends Component { }) } - // 上传供求api - uploadSupplyDemand() { - if (this.state.demandingSupplyCateSelected && this.state.title && this.state.contactName && this.state.contactNumber && this.state.content && this.state.demandingSupplyStateSelected) { - this.uploadDemSup({}) - } else { - this.setState({ uploadDemSupTextTip: '请填写完表格', isUploadDemSupSuccess: true }, () => { - setTimeout(() => { - this.setState({ isUploadDemSupSuccess: false }) - }, 2000) - }) - } - // Taro.request({ - // url: URL.UploadSupplyDemand, - // method: 'POST', - // dataType: 'json', - // data: { - // action: 1, - // sdInfo: JSON.stringify({ "sd_type": "2", "sd_title": "534523", "user_name": "杨夕兵", "user_phone": "18950295811", "user_address": "2342", "sd_desc": "42342", "state": "1", "file_path": [{ "file_name": "bg3.jpg", "file_size": "212678", "file_path": "Uploads/supply/user_27/201812/38bf91f30d215bbefb2686f2401217a6.jpg", "thumb_path": "Uploads/supply/user_27/201812/thumb/38bf91f30d215bbefb2686f2401217a6_200X200.jpg" }] }) - // }, - // header: { - // 'content-type': 'application/x-www-form-urlencoded', - // } - // }) - // .then(res => { - // console.log('上传供求', res) - // } - // ) - } // uploadDemSup 上传供求 的api uploadDemSup({ sd_type = this.state.demandingSupplyCateSelected.id, @@ -150,19 +127,25 @@ class MyDemandSupplyEdit extends Component { }) .then(res => { console.log('上传供求', res) + Taro.hideLoading() if (res.data.err_msg === 'success') { Taro.showToast({ - title: '上传成功', + title: '保存成功', icon: 'success', - duration: 1500 + duration: 1000 }).then(() => { setTimeout(() => { - Taro.navigateTo({ - url: '/pages/mySupplyDemand/mySupplyDemand' - }) - }, 1500); + if (this.state.isSave) { + Taro.navigateTo({ + url: '/pages/myDemandSupplyEdit/myDemandSupplyEdit?sdId=' + res.data.sd_id + }) + } else if (this.state.isSaveAndNew) { + Taro.navigateTo({ + url: '/pages/supplyDemandPublish/supplyDemandPublish' + }) + } + }, 1000); }) - } else { Taro.showToast({ title: res.data.err_msg, @@ -220,6 +203,50 @@ class MyDemandSupplyEdit extends Component { }) } } + // 删除我的供求api + onDelete({ sdID = 0 }) { + Taro.request({ + url: URL.DeleteDemandSupply, + method: 'POST', + dataType: 'json', + data: { + sdID: sdID + }, + header: { + 'content-type': 'application/x-www-form-urlencoded', + 'Cookie': 'PFWSSS=' + Taro.getStorageSync('session_id'), + 'X-Requested-With': 'XMLHttpRequest' + } + }) + .then(res => { + if (res.data.err_msg == 'success') { + Taro.showToast({ + title: '删除成功' + }).then(() => { + setTimeout(() => { + Taro.navigateTo({ + url: '/pages/supplyDemandPublish/supplyDemandPublish' + }) + }, 1500); + }) + + } else { + + Taro.showToast({ + title: res.data.err_msg, + icon: 'none' + }) + } + } + ) + .catch(error => { + + Taro.showToast({ + title: '删除失败', + icon: 'none' + }) + }) + } // 修改供求类型 demandingSupplyCate = e => { this.setState({ @@ -248,11 +275,59 @@ class MyDemandSupplyEdit extends Component { contentChange(event) { this.setState({ content: event.target.value }) } + // 上传供求api + saveButtonHandler() { + if (this.state.demandingSupplyCateSelected && this.state.title && this.state.contactName && this.state.contactNumber && this.state.content && this.state.demandingSupplyStateSelected) { + + Taro.showLoading({ title: '保存中' }).then(() => { + this.setState({ isSave: true }, () => { + this.uploadDemSup({}) + }) + }) + + } else { + Taro.showToast({ + title: '请填写完表格', + icon: 'none', + duration: 1500 + }) + } + + } + // 上传供求api + saveAndNewButton() { + if (this.state.demandingSupplyCateSelected && this.state.title && this.state.contactName && this.state.contactNumber && this.state.content && this.state.demandingSupplyStateSelected) { + Taro.showLoading({ title: '保存中' }).then(() => { + this.setState({ isSaveAndNew: true }, () => { + this.uploadDemSup({}) + }) + }) + } else { + Taro.showToast({ + title: '请填写完表格', + icon: 'none', + duration: 1500 + }) + } + } goToMyDemSupPage() { Taro.navigateTo({ url: '/pages/mySupplyDemand/mySupplyDemand' }) } + deleteButtonHandler() { + this.setState({ isConfirmWindow: true }) + } + handleWindowModClose() { + this.setState({ isConfirmWindow: false }) + } + handleWindowModCancel() { + this.setState({ isConfirmWindow: false }) + } + handleWindowConfirm() { + this.setState({ isConfirmWindow: false }) + this.onDelete({ sdID: this.state.demandSupplyId }) + } componentDidMount() { @@ -271,10 +346,18 @@ class MyDemandSupplyEdit extends Component { componentDidHide() { } render() { + // 提示模态弹窗element + const modalMessageConfirmElement = + 提示 + + 确认删除{this.state.demandSupplyItemName}? + + + return ( - + {modalMessageConfirmElement} @@ -296,7 +379,7 @@ class MyDemandSupplyEdit extends Component { value={this.state.title} border={false} onChange={this.titleChange.bind(this)} - + /> @@ -310,16 +393,18 @@ class MyDemandSupplyEdit extends Component { onChange={this.contactNameChange.bind(this)} /> - - * - + + + * + 联系电话: + + + @@ -377,15 +462,21 @@ class MyDemandSupplyEdit extends Component { - - + + + + + {/* */} - + + + + diff --git a/src/pages/myDemandSupplyEdit/myDemandSupplyEdit.scss b/src/pages/myDemandSupplyEdit/myDemandSupplyEdit.scss index 9a97cbf..53a4702 100644 --- a/src/pages/myDemandSupplyEdit/myDemandSupplyEdit.scss +++ b/src/pages/myDemandSupplyEdit/myDemandSupplyEdit.scss @@ -26,17 +26,11 @@ $themeColor:#FF7142; flex-wrap: nowrap; flex-direction: row; margin: 40px 0 0; - padding: 0 120px; + justify-content: space-around; .button{ - flex:1; text-align: center; - .at-button--primary{ - background-color:$themeColor,; - border:1PX solid $themeColor,; - } - .button-a{ - background-color:#5cb85c; - border:1PX solid #5cb85c; + .button-orange,.button-green,.button-dark-red{ + font-size: 27rpx } } } diff --git a/src/pages/myGoodList/myGoodList.js b/src/pages/myGoodList/myGoodList.js index 54d7ce8..518210e 100644 --- a/src/pages/myGoodList/myGoodList.js +++ b/src/pages/myGoodList/myGoodList.js @@ -2,12 +2,14 @@ import Taro, { Component } from '@tarojs/taro' import { View, Radio, Button } from '@tarojs/components' import { AtInput, Text, AtIcon, Picker, Image, AtModal, AtModalHeader, AtModalContent, AtModalAction } from 'taro-ui' import CopyrightComponent from '../../component/copyrightComponent/copyrightComponent' +import ScrollToTopComponent from '../../component/scrollToTopComponent/scrollToTopComponent' + import URL from '../../serviceAPI.config' import './myGoodList.scss' -let loadMorePageIndex = 1 // 底部加载接口请求参数 + class MyGoodList extends Component { config = { navigationBarTitleText: '商品列表' @@ -33,19 +35,17 @@ class MyGoodList extends Component { }, // 正反排序 selectedFilterValue: 0, // myGoodList: [],// 保存后台返回的商品列表 - myGoodListTotal: 0,// 后台的商品总数 - currentPage: 1, + myGoodListTotal: '0',// 后台的商品总数 goodsStateParam: 1,//商品状态参数 - pageCountParam: 2,// 商品数量参数 + pageCountParam: 10,// 商品数量参数 currPageParam: 1,// 当前页面 参数 isCheckAll: false,// 是否checked goodsIdList: [],//商品Id 列表 isOpenDeleteModal: false,// 是否显示删除模态框 isOpenOffStockModal: false,// 是否显示下架模态框 isAddToList: false,// 是否下拉加载 如果是 就添加商品到我的商品列表 - - - + isShowTopNav: false,// 是否显示返回顶部按钮 + loadMorePageIndex: 1,//上拉加载页面数 } } @@ -106,57 +106,7 @@ class MyGoodList extends Component { } // 获取我的商品列表接口api - getMyGoodListApi({ goodsState = this.state.goodsStateParam, pageCount = this.state.pageCountParam, currPage = this.state.currPageParam }) { - Taro.request({ - url: URL.MyGoodList, - method: 'POST', - dataType: 'json', - - data: { - goodsState: goodsState, - pageCount: pageCount, - currPage: currPage - }, - header: { - 'Cookie': 'PFWSSS=' + Taro.getStorageSync('session_id'), - 'content-type': 'application/x-www-form-urlencoded', - 'X-Requested-With': 'XMLHttpRequest' - } - }).then(res => { - if (res.statusCode === 200) { - console.log('我的商品列表', JSON.parse(res.data)) - const data = JSON.parse(res.data) - Taro.hideLoading() - if (data.goods.length) { - data.goods.forEach(item => { - item.checked = false - }); - const goodCount = Number(data.goodsCount) - if (this.state.isAddToList) { - this.setState({ myGoodList: this.state.myGoodList.concat(data.goods) }, () => { - this.setState({ isAddToList: false }) - }) - } else { - this.setState({ - myGoodList: data.goods, - myGoodListTotal: goodCount - }) - - } - } else { - Taro.showToast({ - title: '没有更多了', - icon: 'none' - }) - } - } else { - console.log('我的商品列表获取失败') - } - }) - - } - // 获取搜索结果api - getGoodListResultApi({ + getMyGoodListApi({ goodsName = this.state.productName, goodsSn = '', goodsClass = this.state.productCateSelected.id, @@ -168,12 +118,12 @@ class MyGoodList extends Component { goodsState = this.state.goodsStateParam, pageCount = this.state.pageCountParam, currPage = this.state.currPageParam, - order = '', }) { + order = '', + }) { Taro.request({ url: URL.MyGoodList, method: 'POST', dataType: 'json', - data: { goodsName: goodsName, goodsSn: goodsSn, @@ -197,21 +147,94 @@ class MyGoodList extends Component { if (res.statusCode === 200) { console.log('我的商品列表', JSON.parse(res.data)) const data = JSON.parse(res.data) - const goodCount = Number(data.goodsCount) - this.setState({ - myGoodList: data.goods, - myGoodListTotal: goodCount - }) Taro.hideLoading() + if (data.goods.length) { + data.goods.forEach(item => { + item.checked = false + }); + + if (this.state.isAddToList) { + this.setState({ myGoodList: this.state.myGoodList.concat(data.goods) }, () => { + this.setState({ isAddToList: false }) + }) + } else { + this.setState({ + myGoodList: data.goods, + myGoodListTotal: data.goodsCount + }) + + } + } else { + this.setState({ isAddToList: false }) + Taro.showToast({ + title: '没有更多了', + icon: 'none' + }) + } } else { console.log('我的商品列表获取失败') } - - }) } + // 获取搜索结果api + // getMyGoodListApi({ + // goodsName = this.state.productName, + // goodsSn = '', + // goodsClass = this.state.productCateSelected.id, + // goodsPriceL = this.state.lowestPrice, + // goodsPriceU = this.state.heightestPrice, + // goodsSalesL = this.state.minimumSold, + // goodsSalesU = this.state.maximumSold, + // shopClassID = this.state.productId, + // goodsState = this.state.goodsStateParam, + // pageCount = this.state.pageCountParam, + // currPage = this.state.currPageParam, + // order = '', }) { + // Taro.request({ + // url: URL.MyGoodList, + // method: 'POST', + // dataType: 'json', + + // data: { + // goodsName: goodsName, + // goodsSn: goodsSn, + // goodsClass: goodsClass, + // goodsPriceL: goodsPriceL, + // goodsPriceU: goodsPriceU, + // goodsSalesL: goodsSalesL, + // goodsSalesU: goodsSalesU, + // shopClassID: shopClassID, + // goodsState: goodsState, + // pageCount: pageCount, + // currPage: currPage, + // order: order + // }, + // header: { + // 'Cookie': 'PFWSSS=' + Taro.getStorageSync('session_id'), + // 'content-type': 'application/x-www-form-urlencoded', + // 'X-Requested-With': 'XMLHttpRequest' + // } + // }).then(res => { + // if (res.statusCode === 200) { + // console.log('我的商品列表', JSON.parse(res.data)) + // const data = JSON.parse(res.data) + // const goodCount = Number(data.goodsCount) + // this.setState({ + // myGoodList: data.goods, + // myGoodListTotal: goodCount + // }) + // Taro.hideLoading() + + // } else { + // console.log('我的商品列表获取失败') + // } + + + // }) + + // } // 商品列表下架API changeGoodState({ goodsState = 0, goodsID = this.state.goodsIdList }) { @@ -306,8 +329,8 @@ class MyGoodList extends Component { Taro.showLoading({ title: '加载中', }) - this.setState({ currentPage: 1, isCheckAll: false }, () => { - this.getGoodListResultApi({}) + this.setState({ currPageParam: 1, isCheckAll: false,loadMorePageIndex:1 }, () => { + this.getMyGoodListApi({}) }) } @@ -315,6 +338,9 @@ class MyGoodList extends Component { // 清空搜索 emptyButtonHanlder() { this.setState({ + isCheckAll: false, + loadMorePageIndex:1, + currPageParam: 1, productName: '', lowestPrice: '', heightestPrice: '', @@ -323,10 +349,7 @@ class MyGoodList extends Component { productId: '', productCateSelected: { id: '', name: '全部类目' }, }, () => { - - this.setState({ isCheckAll: false, currentPage: 1 }, () => { - this.getMyGoodListApi({}) - }) + this.getMyGoodListApi({}) Taro.showToast({ title: '已清空', icon: 'success', @@ -340,7 +363,7 @@ class MyGoodList extends Component { this.setState({ selectedFilterValue: value }) if (value == 0) { this.setState({ - currentPage: 1, + currPageParam: 1, filterOptions: { filterPrice: !this.state.filterOptions.filterPrice, filterStock: false, @@ -349,12 +372,12 @@ class MyGoodList extends Component { } } ) - this.state.filterOptions.filterPrice ? this.getGoodListResultApi({ order: "goods_price desc" }) : this.getGoodListResultApi({ order: "goods_price" }) + this.state.filterOptions.filterPrice ? this.getMyGoodListApi({ order: "goods_price desc" }) : this.getMyGoodListApi({ order: "goods_price" }) } if (value == 1) { this.setState({ - currentPage: 1, + currPageParam: 1, filterOptions: { filterPrice: false, filterStock: !this.state.filterOptions.filterStock, @@ -362,13 +385,13 @@ class MyGoodList extends Component { filterPublishDate: false, } }, () => { - this.state.filterOptions.filterStock ? this.getGoodListResultApi({ order: "goods_stock desc" }) : this.getGoodListResultApi({ order: "goods_stock" }) + this.state.filterOptions.filterStock ? this.getMyGoodListApi({ order: "goods_stock desc" }) : this.getMyGoodListApi({ order: "goods_stock" }) } ) } if (value == 2) { this.setState({ - currentPage: 1, + currPageParam: 1, filterOptions: { filterPrice: false, filterStock: false, @@ -377,7 +400,7 @@ class MyGoodList extends Component { } }, () => { - this.state.filterOptions.filterSold ? this.getGoodListResultApi({ order: "sales_volume desc" }) : this.getGoodListResultApi({ order: "sales_volume" }) + this.state.filterOptions.filterSold ? this.getMyGoodListApi({ order: "sales_volume desc" }) : this.getMyGoodListApi({ order: "sales_volume" }) } ) @@ -385,7 +408,7 @@ class MyGoodList extends Component { } if (value == 3) { this.setState({ - currentPage: 1, + currPageParam: 1, filterOptions: { filterPrice: false, filterStock: false, @@ -394,19 +417,13 @@ class MyGoodList extends Component { } }, () => { - this.state.filterOptions.filterPublishDate ? this.getGoodListResultApi({ order: "update_date desc" }) : this.getGoodListResultApi({ order: "update_date" }) + this.state.filterOptions.filterPublishDate ? this.getMyGoodListApi({ order: "update_date desc" }) : this.getMyGoodListApi({ order: "update_date" }) } ) } } - // 翻页导航 - paginationNav(type) { - this.setState({ currentPage: type.current, isCheckAll: false }, () => { - this.getMyGoodListApi({ currPage: this.state.currentPage }) - }) - } // 商品全部选择 checkAllHandler() { if (this.state.myGoodList.length) { @@ -536,6 +553,9 @@ class MyGoodList extends Component { } componentDidMount() { + Taro.showLoading({ + title: '加载中' + }) this.getMyGoodListApi({}) this.getBaoBeiCateList() } @@ -548,16 +568,21 @@ class MyGoodList extends Component { componentDidShow() { } componentDidHide() { } - + // 页面位置 + onPageScroll(location) { + if (location.scrollTop <= 300 && this.state.isShowTopNav) { + this.setState({ isShowTopNav: false }) + } else if (location.scrollTop > 300 && !this.state.isShowTopNav) { + this.setState({ isShowTopNav: true }) + } + } // 底部加载 onReachBottom() { Taro.showLoading({ title: '加载中' }) - - loadMorePageIndex += 1 - this.setState({ isAddToList: true }, () => { - this.getMyGoodListApi({ currPage: loadMorePageIndex }) + this.setState({ isAddToList: true, loadMorePageIndex: this.state.loadMorePageIndex + 1 }, () => { + this.getMyGoodListApi({ currPage: this.state.loadMorePageIndex }) }) @@ -565,13 +590,15 @@ class MyGoodList extends Component { render() { + //等待接口数据 const goodListElementArray = this.state.myGoodList.map((item, index) => { return - + {/* */} + {item.goods_name} ¥{item.goods_price} @@ -704,17 +731,16 @@ class MyGoodList extends Component { + + + 清空条件 - 出售中的宝贝{this.state.myGoodListTotal}条记录 @@ -740,6 +766,7 @@ class MyGoodList extends Component { {goodListElementArray} + {this.state.isShowTopNav ? : null} diff --git a/src/pages/myGoodList/myGoodList.scss b/src/pages/myGoodList/myGoodList.scss index 53d95e5..caeefbb 100644 --- a/src/pages/myGoodList/myGoodList.scss +++ b/src/pages/myGoodList/myGoodList.scss @@ -1,4 +1,7 @@ $themeColor:#FF7142; +.button-orange, .button-dark-red,.button-green{ + font-size:28rpx; +} .MyGoodList{ padding: 10px 20px; .filterbar-container{ @@ -52,6 +55,9 @@ $themeColor:#FF7142; .button{ margin-left:2%; text-align: center; + .button-dark-red,.button-blue{ + font-size: 28rpx; + } } } @@ -101,18 +107,11 @@ $themeColor:#FF7142; flex-wrap: nowrap; flex-direction: row; margin: 40px 0; - padding: 0 120px; .button{ flex:1; text-align: center; - .at-button--primary{ - background-color:$themeColor; - border:1PX solid $themeColor; - } - .button-a{ - - background-color:#5cb85c; - border:1PX solid #5cb85c; + .button-orange, .button-dark-red,.button-green{ + font-size:28rpx; } } } @@ -142,21 +141,24 @@ $themeColor:#FF7142; flex-direction: row; font-size: 30px; height: 200px; - line-height: 200px; text-align: center; color:#717592; + align-items:center; + .radio{ margin-left: 10px; } .img-box{ flex:1; - .img{ - margin-top: 35%; - } + height:80%; + width:100%; + margin: 0 2%; + + } .name-box{ - flex:1; + flex:2; color: #0579c6 } diff --git a/src/pages/myGoodsEdit/myGoodsEdit.js b/src/pages/myGoodsEdit/myGoodsEdit.js index b208e73..bcb2d5a 100644 --- a/src/pages/myGoodsEdit/myGoodsEdit.js +++ b/src/pages/myGoodsEdit/myGoodsEdit.js @@ -6,8 +6,6 @@ import ShopTypeInteractionComp from '../../component/shopTypeInteractionComp/sho import CopyrightComponent from '../../component/copyrightComponent/copyrightComponent' import URL from '../../serviceAPI.config' - - import './myGoodsEdit.scss' class MyGoodsEdit extends Component { @@ -27,6 +25,8 @@ class MyGoodsEdit extends Component { ImagesInfo: [],// 后台传回来的图片信息 goodsTypeParam: '',//商品分类参数 goodId: '',//商品id + isSaveButton: false,//是否点击了保存按钮 + isSaveAndNewBUtton: false,// 是否点击了保存新增按钮 } } //获取商品信息api GetProductInfo @@ -172,12 +172,20 @@ class MyGoodsEdit extends Component { title: '保存成功', icon: 'success', duration: 1000 + }).then(() => { + setTimeout(() => { + if (this.state.isSaveButton) { + Taro.navigateTo({ + url: '/pages/myGoodsEdit/myGoodsEdit?id=' + this.$router.params.id + }) + } else if (this.state.isSaveAndNewBUtton) { + Taro.navigateTo({ + url: '/pages/goodsPublish/goodsPublish' + }) + } + }, 1000); }) - setTimeout(() => { - Taro.navigateTo({ - url: '/pages/goods/goods?id=' + this.$router.params.id - }) - }, 1000); + console.log('上传商品', res) } ) @@ -269,12 +277,18 @@ class MyGoodsEdit extends Component { } } - - - onClickUploadGoods() { + shopCategoryChanged(e) { + this.setState({ + shopCategoryCheckedPicker: this.state.shopCategoryList[e.detail.value] + }, () => { + console.log(this.state.shopCategoryCheckedPicker) + }) + } + // 保存按钮 + saveButtonHandler() { if (this.state.productName && this.state.productPrice && this.state.productUnit && this.state.ImagesInfo.length && this.state.shopTypeSelected.id) { Taro.showLoading({ title: '保存中' }).then(() => { - setTimeout(() => { + this.setState({ isSaveButton: true }, () => { this.uploadGoods({ goods_name: this.state.productName, goods_price: this.state.productPrice, @@ -284,7 +298,8 @@ class MyGoodsEdit extends Component { class_id: this.state.goodsTypeParam, goods_id: this.state.goodId, }) - }, 1000); + + }) }) } else { Taro.showToast({ @@ -295,11 +310,37 @@ class MyGoodsEdit extends Component { } } - shopCategoryChanged(e) { - this.setState({ - shopCategoryCheckedPicker: this.state.shopCategoryList[e.detail.value] - }, () => { - console.log(this.state.shopCategoryCheckedPicker) + // 保存并新增按钮 + saveAndNewButton() { + if (this.state.productName && this.state.productPrice && this.state.productUnit && this.state.ImagesInfo.length && this.state.shopTypeSelected.id) { + Taro.showLoading({ title: '保存中' }).then(() => { + this.setState({ isSaveAndNewBUtton: true }, () => { + this.uploadGoods({ + goods_name: this.state.productName, + goods_price: this.state.productPrice, + goods_unit: this.state.productUnit, + goods_profiles: this.state.productDescript, + shop_class_id: this.state.shopTypeSelected.id, + class_id: this.state.goodsTypeParam, + goods_id: this.state.goodId, + }) + + }) + + }) + } else { + Taro.showToast({ + title: '请填写完表格', + icon: 'none', + duration: 2000 + }) + + } + } + + goToGoodsDetailPage() { + Taro.navigateTo({ + url: '/pages/goods/goods?id=' + this.$router.params.id }) } goToMyGoodListPage() { @@ -336,12 +377,12 @@ class MyGoodsEdit extends Component { * @@ -349,24 +390,24 @@ class MyGoodsEdit extends Component { * * {/* 图片上传 */} @@ -377,18 +418,18 @@ class MyGoodsEdit extends Component { {/* 店铺分类 */} {/* 店铺分类结束 */} @@ -399,27 +440,34 @@ class MyGoodsEdit extends Component { - - - - - - {/* + + + + + {/* */} - - + + + + + + + + + + diff --git a/src/pages/myGoodsEdit/myGoodsEdit.scss b/src/pages/myGoodsEdit/myGoodsEdit.scss index d7de9fa..ad00561 100644 --- a/src/pages/myGoodsEdit/myGoodsEdit.scss +++ b/src/pages/myGoodsEdit/myGoodsEdit.scss @@ -77,17 +77,11 @@ $themeColor:#FF7142; flex-wrap: nowrap; flex-direction: row; margin: 40px 0 0; - padding: 0 120px; + justify-content: space-around; .button{ - flex:1; text-align: center; - .at-button--primary{ - background-color:$themeColor; - border:1PX solid $themeColor; - } - .button-a{ - background-color:#5cb85c; - border:1PX solid #5cb85c; + .button-orange,.button-green{ + font-size: 27rpx } } } diff --git a/src/pages/myNeeds/myNeeds.js b/src/pages/myNeeds/myNeeds.js index 0b9ff1f..9754daf 100644 --- a/src/pages/myNeeds/myNeeds.js +++ b/src/pages/myNeeds/myNeeds.js @@ -3,14 +3,13 @@ import Taro, { Component } from '@tarojs/taro' import { View, Text, Button } from '@tarojs/components' import { AtInput, Picker, AtIcon, AtModal, AtModalHeader, AtModalContent, AtModalAction } from 'taro-ui' import URL from '../../serviceAPI.config' - +import ScrollToTopComponent from '../../component/scrollToTopComponent/scrollToTopComponent' import InteractionComponent from '../../component/interactionComponent/interactionComponent' import CopyrightComponent from '../../component/copyrightComponent/copyrightComponent' import './myNeeds.scss' -let loadMorePageIndex = 1 // 底部加载接口请求参数 class MyNeeds extends Component { @@ -38,23 +37,24 @@ class MyNeeds extends Component { totalNeeds: 0,// 我的需求数量 currentPage: 1, needsItem: '',// 确认框提示时 使用的供求名 - isDeleteModal:false, + isDeleteModal:false,// 删除提示框 isAddToList: false,// 请求需求的时候是否添加到旧列表里 - - + isShowTopNav: false,// 是否显示返回顶部按钮 + loadMorePageIndex:1,// 上拉加载页面数 } } //请求我的需求列表 api GetMyNeedsList - getMyNeedsList({ curr_page = 1, - page_count = 10, - sd_type = '4', - sd_title = '', - update_dateL = '', - update_dateU = '', - class_id = '', - state = '' + getMyNeedsList({ + curr_page = this.state.currentPage, + page_count = this.state.pageCount, + sd_type = this.state.needsTypeSelected.id, + sd_title = this.state.title, + update_dateL = this.state.startDateSel, + update_dateU = this.state.endDateSel, + class_id = this.state.industryTypeSelected.id, + state = this.state.needsStateSelected.id }) { //由于后台返回的问题, 所有当state为空的时候不传state,反之传state const param=state?{param: JSON.stringify({ @@ -99,6 +99,7 @@ class MyNeeds extends Component { }) }else{ + this.setState({isAddToList:false}) this.setState({ allNeedsList: res.data.supplys || [], totalNeeds: Number(res.data.count) @@ -108,6 +109,7 @@ class MyNeeds extends Component { }else{ + this.setState({isAddToList:false}) Taro.showToast({ title: '没有更多了', icon: 'none' @@ -167,7 +169,7 @@ class MyNeeds extends Component { // 搜索按钮 onSearchButtonHandler() { Taro.showLoading({ title: '加载中' }).then(() => { - setTimeout(() => { + this.setState({ currentPage: 1,loadMorePageIndex:1 },()=>{ this.getMyNeedsList({ curr_page: this.state.currentPage, page_count: this.state.pageCount, @@ -178,8 +180,11 @@ class MyNeeds extends Component { class_id: this.state.industryTypeSelected.id==='-1'?'':this.state.industryTypeSelected.id, state: this.state.needsStateSelected.id }) - this.setState({ currentPage: 1 }) - }, 1000); + + }) + + + }) @@ -192,12 +197,17 @@ class MyNeeds extends Component { } //清空筛选项 emptyFilter(){ - this.setState({ title:'', endDateSel:'', startDateSel:'', - + industryTypeSelected: { name: '全部', id: '' }, + needsTypeSelected: { name: '业主需求', id: '4' }, + needsStateSelected: { name: '全部', id: '' }, + currentPage:1, + loadMorePageIndex:1, + },()=>{ + this.getMyNeedsList({}) }) Taro.showToast({ title:'已清空', @@ -257,6 +267,9 @@ class MyNeeds extends Component { componentDidMount() { + Taro.showLoading({ + title:'加载中' + }) this.getMyNeedsList({}) } @@ -270,14 +283,22 @@ class MyNeeds extends Component { componentDidHide() { } + // 页面位置 + onPageScroll(location) { + if (location.scrollTop <= 300 && this.state.isShowTopNav) { + this.setState({ isShowTopNav: false }) + } else if (location.scrollTop > 300 && !this.state.isShowTopNav) { + this.setState({ isShowTopNav: true }) + } +} // 底部加载 onReachBottom() { Taro.showLoading({ title: '加载中' }) - loadMorePageIndex += 1 - this.setState({ isAddToList: true }, () => { - this.getMyNeedsList({ curr_page: loadMorePageIndex }) + + this.setState({ isAddToList: true,loadMorePageIndex:this.state.loadMorePageIndex+1 }, () => { + this.getMyNeedsList({ curr_page: this.state.loadMorePageIndex }) }) } @@ -314,7 +335,7 @@ class MyNeeds extends Component { - + : @@ -422,13 +443,12 @@ class MyNeeds extends Component { 共{this.state.totalNeeds} 条记录 {/* 我的需求信息 */} - {this.state.totalNeeds != "0" ? + { {myNeedsListArrayElement} - : - 没有更多了.... - } + } + + {this.state.isShowTopNav ? : null} - diff --git a/src/pages/myNeeds/myNeeds.scss b/src/pages/myNeeds/myNeeds.scss index 1a97fd7..72bda28 100644 --- a/src/pages/myNeeds/myNeeds.scss +++ b/src/pages/myNeeds/myNeeds.scss @@ -1,4 +1,7 @@ $themeColor:#FF7142; +.button-orange, .button-dark-red,.button-green{ + font-size:28rpx; +} .myNeeds{ padding: 10px 20px; font-size: 32rpx; @@ -83,15 +86,15 @@ $themeColor:#FF7142; flex-wrap: nowrap; flex-direction: row; margin: 40px 0; - padding: 0 120px; - + justify-content:space-around; .button{ - flex:1; + text-align: center; + .button-orange,.button-green,.button-dark-red{ + font-size: 27rpx + } } - .button-orange, .button-dark-red,.button-green{ - font-size:28rpx; - } + } .pagination-box{ @@ -107,7 +110,8 @@ $themeColor:#FF7142; box-shadow: 0 8px 8px #ddd; padding: 10px; font-size: 25rpx; - + padding-bottom:0px; + .box{ margin-top: 10px; @@ -129,6 +133,9 @@ $themeColor:#FF7142; // flex:1; text-align: right; margin:0 1% 0; + .button-orange,.button-green,.button-dark-red{ + font-size: 27rpx + } } } diff --git a/src/pages/myNeedsEdit/myNeedsEdit.js b/src/pages/myNeedsEdit/myNeedsEdit.js index 824f55a..9b74f56 100644 --- a/src/pages/myNeedsEdit/myNeedsEdit.js +++ b/src/pages/myNeedsEdit/myNeedsEdit.js @@ -1,17 +1,13 @@ import Taro, { Component } from '@tarojs/taro' -import { View, Text,Button } from '@tarojs/components' -import { AtInput, AtImagePicker, AtTextarea, Picker } from 'taro-ui' +import { View, Text, Button,Input } from '@tarojs/components' +import { AtInput, AtImagePicker, AtTextarea, Picker, AtModal, AtModalHeader, AtModalContent, AtModalAction } from 'taro-ui' import InteractionComponent from '../../component/interactionComponent/interactionComponent' import CopyrightComponent from '../../component/copyrightComponent/copyrightComponent' import URL from '../../serviceAPI.config' - - import './myNeedsEdit.scss' - - class MyNeedsEdit extends Component { config = { @@ -20,7 +16,7 @@ class MyNeedsEdit extends Component { constructor() { super(...arguments) this.state = { - + industryTypeSelected: '', needsType: [{ name: '业主需求', id: '4' }, { name: '效果图', id: '5' }], needsTypeSelected: { name: '业主需求', id: '4' }, @@ -37,6 +33,11 @@ class MyNeedsEdit extends Component { content: '',//描述 pickerImageUrl: [], ImagesInfo: '', + isDeleteModal: false,// 删除提示框 + isSave: false,//是否点击保存按钮 + isSaveAndNew: false,//是否点击保存新增按钮 + + } } //获取需求信息api @@ -76,12 +77,12 @@ class MyNeedsEdit extends Component { break } } - if(!Object.keys(industryType).length){ + if (!Object.keys(industryType).length) { industryType.name = '全部' - industryType.id ='' + industryType.id = '-1' } - - + + const needsType = this.state.needsType.filter(item => { return item.id === res.data.sdInfo.sd_type @@ -95,8 +96,8 @@ class MyNeedsEdit extends Component { industryTypeSelected: industryType, needsTypeSelected: needsType, title: res.data.sdInfo.sd_title, - contactName:res.data.sdInfo.user_name, - contactNumber:res.data.sdInfo.user_phone, + contactName: res.data.sdInfo.user_name, + contactNumber: res.data.sdInfo.user_phone, contactAddress: res.data.sdInfo.user_address, content: res.data.sdInfo.sd_desc, needsStateSelected: needsState, @@ -112,22 +113,7 @@ class MyNeedsEdit extends Component { }) } - // 上传需求按键 - uploadMyNeedsButton() { - if (this.state.title && - this.state.contactName - && this.state.contactNumber - && this.state.content && this.state.needsStateSelected) { - this.uploadMyNeedsApi({}) - } else { - Taro.showToast({ - title: '请填写完表格', - icon: 'none', - duration: 1500 - }) - } - } // uploadMyNeedsApi 上传需求 的api uploadMyNeedsApi() { @@ -169,17 +155,25 @@ class MyNeedsEdit extends Component { }) .then(res => { console.log('上传需求', res) + Taro.hideLoading() if (res.data.err_msg === 'success') { Taro.showToast({ title: '保存成功', icon: 'success', duration: 1500 }).then(() => { - // setTimeout(() => { - // Taro.navigateTo({ - // // url: '/pages/mySupplyDemand/mySupplyDemand' - // }) - // }, 1500); + setTimeout(() => { + if (this.state.isSave) { + Taro.navigateTo({ + url: '/pages/myNeedsEdit/myNeedsEdit?id=' + this.state.sd_id + }) + } else if (this.state.isSaveAndNew) { + Taro.navigateTo({ + url: '/pages/myNeedsPublish/myNeedsPublish' + }) + } + + }, 1500); }) } else { @@ -239,6 +233,46 @@ class MyNeedsEdit extends Component { }) } } + + //删除我的需求 api DeleteMyNeeds + deleteMyNeeds({ demandId = 10 }) { + Taro.request({ + url: URL.DeleteMyNeeds, + method: 'POST', + dataType: 'json', + data: { + + demandId: demandId + + }, + header: { + 'Cookie': 'PFWSSS=' + Taro.getStorageSync('session_id'), + 'content-type': 'application/x-www-form-urlencoded', + 'X-Requested-With': 'XMLHttpRequest' + } + }).then(res => { + console.log('删除我的列表', res) + if (res.data.err_msg === "success") { + Taro.showToast({ + title: '删除成功', + icon: 'success', + duration: 1000 + }) + setTimeout(() => { + Taro.navigateTo({ + url: '/pages/myNeedsPublish/myNeedsPublish' + }) + }, 1000); + } else { + Taro.showToast({ + title: res.data.err_msg, + icon: 'none', + duration: 1500 + }) + } + }) + + } // 修改需求类型 needsTypeChange = e => { this.setState({ @@ -272,6 +306,61 @@ class MyNeedsEdit extends Component { url: '/pages/myNeeds/myNeeds' }) } + // 保存需求按钮 + saveButtonHandler() { + if (this.state.title && + this.state.contactName + && this.state.contactNumber + && this.state.content && this.state.needsStateSelected) { + Taro.showLoading({ + title: '保存中' + }) + this.setState({ isSave: true }, () => { + this.uploadMyNeedsApi({}) + }) + + } else { + Taro.showToast({ + title: '请填写完表格', + icon: 'none', + duration: 1500 + }) + } + + } + // 保存新增按钮 + saveAndNewButton() { + if (this.state.title && + this.state.contactName + && this.state.contactNumber + && this.state.content && this.state.needsStateSelected) { + Taro.showLoading({ + title: '保存中' + }) + this.setState({ isSaveAndNew: true }, () => { + this.uploadMyNeedsApi({}) + }) + } else { + Taro.showToast({ + title: '请填写完表格', + icon: 'none', + duration: 1500 + }) + } + + } + + deleteButtonHandler() { + this.setState({ isDeleteModal: true }) + } + + handleWindowModCancel() { + this.setState({ isDeleteModal: false }) + } + handleWindowConfirm() { + this.setState({ isDeleteModal: false }) + this.deleteMyNeeds({ demandId: this.state.sd_id }) + } getDataFromChild(value) { console.log('从子组件传回来的值', value) @@ -295,10 +384,17 @@ class MyNeedsEdit extends Component { componentDidHide() { } render() { + const deleteModalWindowElement = + 提示 + + 确认删除{this.state.needsItem.sd_title}? + + + return ( - + {deleteModalWindowElement} {/* 行业分类 */} @@ -323,9 +419,9 @@ class MyNeedsEdit extends Component { value={this.state.title} border={false} onChange={this.titleChange.bind(this)} - + /> - + * @@ -338,17 +434,20 @@ class MyNeedsEdit extends Component { onChange={this.contactNameChange.bind(this)} /> - - * - + + + * + 联系电话: + + + + 联系地址: @@ -405,15 +504,17 @@ class MyNeedsEdit extends Component { - - + + + + + - {/* - - - */} - + + + + diff --git a/src/pages/myNeedsEdit/myNeedsEdit.scss b/src/pages/myNeedsEdit/myNeedsEdit.scss index ddcaa43..5434177 100644 --- a/src/pages/myNeedsEdit/myNeedsEdit.scss +++ b/src/pages/myNeedsEdit/myNeedsEdit.scss @@ -26,21 +26,15 @@ $themeColor:#FF7142; flex-wrap: nowrap; flex-direction: row; margin: 40px 0 0; - padding: 0 120px; + justify-content: space-around; .button{ - flex:1; + text-align: center; - .at-button--primary{ - background-color:$themeColor,; - border:1PX solid $themeColor,; - } - .button-a{ - background-color:#5cb85c; - border:1PX solid #5cb85c; + .button-orange,.button-green,.button-dark-red{ + font-size: 27rpx } } } - } .title-box{ diff --git a/src/pages/myNeedsPublish/myNeedsPublish.js b/src/pages/myNeedsPublish/myNeedsPublish.js index 7949d81..42c7507 100644 --- a/src/pages/myNeedsPublish/myNeedsPublish.js +++ b/src/pages/myNeedsPublish/myNeedsPublish.js @@ -1,7 +1,7 @@ import Taro, { Component } from '@tarojs/taro' -import { View, Text ,Button} from '@tarojs/components' -import { AtInput, AtImagePicker, AtTextarea, Picker } from 'taro-ui' +import { View, Text, Button,Input } from '@tarojs/components' +import { AtInput, AtImagePicker, AtTextarea, Picker } from 'taro-ui' import CopyrightComponent from '../../component/copyrightComponent/copyrightComponent' import URL from '../../serviceAPI.config' @@ -32,31 +32,16 @@ class MyNeedsPublish extends Component { content: '', pickerImageUrl: [], // 上传的图片 ImagesInfo: [],// 后台传回来的图片信息 - + isPublish: false,//是否点击发布按钮 + isPublishAndNew: false,//是否点击发布新增按钮 + } } - // 上传需求api - uploadMyNeedsButton() { - if (this.state.title && - this.state.contactName - && this.state.contactNumber - && this.state.content && this.state.needsStateSelected) { - this.uploadMyNeedsApi({}) - } else { - Taro.showToast({ - title: '请填写完表格', - icon: 'none', - duration: 1500 - }) - } - - - } // uploadMyNeeds 上传供求 的api @@ -101,14 +86,21 @@ class MyNeedsPublish extends Component { console.log('上传需求', res) if (res.data.err_msg === 'success') { Taro.showToast({ - title: '上传成功', + title: '发布成功', icon: 'success', duration: 1500 }).then(() => { setTimeout(() => { - Taro.navigateTo({ - url: '/pages/myNeeds/myNeeds' - }) + if (this.state.isPublish) { + Taro.navigateTo({ + url: '/pages/myNeedsEdit/myNeedsEdit?id=' + res.data.sd_id + }) + } else if (this.state.isPublishAndNew) { + Taro.navigateTo({ + url: '/pages/myNeedsPublish/myNeedsPublish' + }) + } + }, 1500); }) @@ -200,6 +192,53 @@ class MyNeedsPublish extends Component { } contentChange(event) { this.setState({ content: event.target.value }) + } + // 发布按钮 + publishButtonHandler() { + if (this.state.title && + this.state.contactName + && this.state.contactNumber + && this.state.content && this.state.needsStateSelected) { + + Taro.showLoading({ + title: '发布中' + }) + this.setState({ isPublish: true }, () => { + this.uploadMyNeedsApi({}) + }) + + } else { + Taro.showToast({ + title: '请填写完表格', + icon: 'none', + duration: 1500 + }) + } + + + } + // 发布新增按钮 + publishAndNewButton() { + if (this.state.title && + this.state.contactName + && this.state.contactNumber + && this.state.content && this.state.needsStateSelected) { + + Taro.showLoading({ + title: '发布中' + }) + this.setState({ isPublishAndNew: true }, () => { + this.uploadMyNeedsApi({}) + }) + } else { + Taro.showToast({ + title: '请填写完表格', + icon: 'none', + duration: 1500 + }) + } + + } goToMyNeedsPage() { Taro.navigateTo({ @@ -258,7 +297,7 @@ class MyNeedsPublish extends Component { value={this.state.title} border={false} onChange={this.titleChange.bind(this)} - + /> @@ -272,17 +311,20 @@ class MyNeedsPublish extends Component { onChange={this.contactNameChange.bind(this)} /> - - * - + + + * + 联系电话: + + + + 联系地址: @@ -339,15 +381,15 @@ class MyNeedsPublish extends Component { - - + + - {/* - - */} + + + - + diff --git a/src/pages/myNeedsPublish/myNeedsPublish.scss b/src/pages/myNeedsPublish/myNeedsPublish.scss index b4b9da8..12d119c 100644 --- a/src/pages/myNeedsPublish/myNeedsPublish.scss +++ b/src/pages/myNeedsPublish/myNeedsPublish.scss @@ -26,17 +26,11 @@ $themeColor:#FF7142; flex-wrap: nowrap; flex-direction: row; margin: 40px 0 0; - padding: 0 120px; + justify-content: space-around; .button{ - flex:1; text-align: center; - .at-button--primary{ - background-color:$themeColor,; - border:1PX solid $themeColor,; - } - .button-a{ - background-color:#5cb85c; - border:1PX solid #5cb85c; + .button-orange,.button-green,.button-dark-red{ + font-size: 27rpx } } } diff --git a/src/pages/myNeedsView/myNeedsView.js b/src/pages/myNeedsView/myNeedsView.js index 9534692..1a87e72 100644 --- a/src/pages/myNeedsView/myNeedsView.js +++ b/src/pages/myNeedsView/myNeedsView.js @@ -36,6 +36,7 @@ class SupplyDemandView extends Component { content: '',//描述 pickerImageUrl: [], ImagesInfo: '', + isShowAllButtons:true// 是否显示所有按钮 } } //获取需求信息api @@ -58,48 +59,60 @@ class SupplyDemandView extends Component { // const selectedType = this.state.demandingSupplyCate.filter(item => item.id == res.data.sdInfo.sd_type)[0] // const selectedState = this.state.needsState.filter(item => item.id == res.data.sdInfo.state)[0] Taro.hideLoading() - let industryType = {} - const classId = res.data.sdInfo.class_id - for (let outter of res.data.supplyTree) { - if (outter.children) { - for (let inner of outter.children) { - if (inner.class_id === classId) { - industryType.name = inner.class_name - industryType.id = inner.class_id - break + if(res.data.err_msg==='success'){ + let industryType = {} + const classId = res.data.sdInfo.class_id + for (let outter of res.data.supplyTree) { + if (outter.children) { + for (let inner of outter.children) { + if (inner.class_id === classId) { + industryType.name = inner.class_name + industryType.id = inner.class_id + break + } } } + if (outter.class_id === classId) { + industryType.name = outter.class_name + industryType.id = outter.class_id + break + } } - if (outter.class_id === classId) { - industryType.name = outter.class_name - industryType.id = outter.class_id - break - } + + const needsType = this.state.needsType.filter(item => { + return item.id === res.data.sdInfo.sd_type + })[0] + const imageFile = res.data.sdInfo.file_path.map(item => { return { url: URL.Base + item.file_path } }) + const needsState = this.state.needsState.filter(item => { + return item.id === res.data.sdInfo.state + })[0] + this.setState({ + sd_id: res.data.sdInfo.sd_id, + industryTypeSelected: industryType, + needsTypeSelected: needsType, + title: res.data.sdInfo.sd_title, + browsing: res.data.sdInfo.browse_times, + contactName: res.data.sdInfo.user_name, + contactNumber: res.data.sdInfo.user_phone, + contactAddress: res.data.sdInfo.user_address, + content: res.data.sdInfo.sd_desc, + needsStateSelected: needsState, + pickerImageUrl: imageFile, + ImagesInfo: res.data.sdInfo.file_path, + isDeleteModal: false, + + }) + + }else{ + this.setState({ + isShowAllButtons:false + }) + Taro.showToast({ + title:res.data.err_msg, + icon:'none' + }) } - - const needsType = this.state.needsType.filter(item => { - return item.id === res.data.sdInfo.sd_type - })[0] - const imageFile = res.data.sdInfo.file_path.map(item => { return { url: URL.Base + item.file_path } }) - const needsState = this.state.needsState.filter(item => { - return item.id === res.data.sdInfo.state - })[0] - this.setState({ - sd_id: res.data.sdInfo.sd_id, - industryTypeSelected: industryType, - needsTypeSelected: needsType, - title: res.data.sdInfo.sd_title, - browsing: res.data.sdInfo.browse_times, - contactName: res.data.sdInfo.user_name, - contactNumber: res.data.sdInfo.user_phone, - contactAddress: res.data.sdInfo.user_address, - content: res.data.sdInfo.sd_desc, - needsStateSelected: needsState, - pickerImageUrl: imageFile, - ImagesInfo: res.data.sdInfo.file_path, - isDeleteModal: false, - - }) + } @@ -243,29 +256,40 @@ class SupplyDemandView extends Component { :null } - + {this.state.isShowAllButtons? - - - - - - - - + + + + + + + : + + + + + + + } diff --git a/src/pages/myNeedsView/myNeedsView.scss b/src/pages/myNeedsView/myNeedsView.scss index c3eab0d..bd465af 100644 --- a/src/pages/myNeedsView/myNeedsView.scss +++ b/src/pages/myNeedsView/myNeedsView.scss @@ -16,23 +16,14 @@ $themeColor:#FF7142; flex-wrap: nowrap; flex-direction: row; margin: 40px 0 0; - padding: 0 20px; + justify-content: space-around; .button{ - flex:1; + text-align: center; - .button-green{ - font-size: 25rpx; - - } - .button-orange{ - font-size: 25rpx; - - } - .button-dark-red{ - font-size: 25rpx; - + .button-orange,.button-green,.button-dark-red{ + font-size: 27rpx } } } diff --git a/src/pages/mySupplyDemand/mySupplyDemand.js b/src/pages/mySupplyDemand/mySupplyDemand.js index 9be69cd..24bd82d 100644 --- a/src/pages/mySupplyDemand/mySupplyDemand.js +++ b/src/pages/mySupplyDemand/mySupplyDemand.js @@ -2,13 +2,13 @@ import Taro, { Component } from '@tarojs/taro' import { View, Text, Button } from '@tarojs/components' import { AtInput, Picker, AtIcon, AtModal, AtModalHeader, AtModalContent, AtModalAction } from 'taro-ui' import URL from '../../serviceAPI.config' +import ScrollToTopComponent from '../../component/scrollToTopComponent/scrollToTopComponent' import CopyrightComponent from '../../component/copyrightComponent/copyrightComponent' import './mySupplyDemand.scss' -let loadMorePageIndex = 1 // 底部加载接口请求参数 class MySupplyDemand extends Component { @@ -30,65 +30,25 @@ class MySupplyDemand extends Component { demandSupplyItemName: '',// 确认框提示时 使用的供求名 demandSupplyId: '',// 删除我的供求时的供求id totalDemandSupply: 0,//所有供求 - currentPage: 1 //当前页数 + currentPage: 1,//当前页数 + isShowTopNav: false,// 是否显示返回顶部按钮 + loadMorePageIndex: 1,//上拉加载页面数 } } //获取我的供求列表API - getMySupplyDemand({ curr_page = 1, page_count = 10 }) { + getMySupplyDemand({ + curr_page = 1, page_count = 10, + sd_type = this.state.demandSupplyCateSelected.id, + state = this.state.demandSupplyStatesSelected.id, + sd_title = this.state.title, + update_dateL = this.state.startDateSel, + update_dateU = this.state.endDateSel + }) { Taro.request({ url: URL.MySupplyDemand, method: 'POST', dataType: 'json', - data: { - param: JSON.stringify({ - curr_page: curr_page, - page_count: page_count - }) - }, - header: { - 'Cookie': 'PFWSSS=' + Taro.getStorageSync('session_id'), - 'content-type': 'application/x-www-form-urlencoded', - 'X-Requested-With': 'XMLHttpRequest' - } - }).then(res => { - Taro.hideLoading() - console.log('我的供求列表', res) - if (res.data.err_msg === "success") { - // 判断是否有res.data.supplys , 如果没有就是空数组[] - if (res.data.supplys.length) { - if (this.state.isAddToList) { - this.setState({ allDemandSupply: this.state.allDemandSupply.concat(res.data.supplys) }, () => { - this.setState({ isAddToList: false }) - }) - } else { - this.setState({ allDemandSupply: res.data.supplys || [], totalDemandSupply: res.data.count }) - } - } else { - Taro.showToast({ - title: '没有更多了', - icon: 'none' - }) - } - - } else { - Taro.showToast({ - title: res.data.err_msg, - icon: 'none', - duration: 1500 - }) - } - }) - - } - //搜索我的供求api - searchDemandSupply({ curr_page = 1, page_count = 20, - sd_type = this.state.demandSupplyCateSelected.id, - state = this.state.demandSupplyStatesSelected.id, sd_title = this.state.title, update_dateL = this.state.startDateSel, update_dateU = this.state.endDateSel }) { - Taro.request({ - url: URL.SearchDemandSupply, - method: 'POST', - dataType: 'json', data: { param: JSON.stringify({ curr_page: curr_page, @@ -101,25 +61,54 @@ class MySupplyDemand extends Component { }) }, header: { - 'content-type': 'application/x-www-form-urlencoded', 'Cookie': 'PFWSSS=' + Taro.getStorageSync('session_id'), + 'content-type': 'application/x-www-form-urlencoded', 'X-Requested-With': 'XMLHttpRequest' } - }) - .then(res => { - //this.setState({ grabOrderSuccess: res.data.err_msg,isGrabOrderSuccess: true }) - console.log('我的供求搜索结果', res) - Taro.hideLoading() - this.setState({ allDemandSupply: res.data.supplys || [], totalDemandSupply: res.data.count }) + }).then(res => { + Taro.hideLoading() + console.log('我的供求列表', res) + if (res.data.err_msg === "success") { + if (this.state.isAddToList) { + if (res.data.supplys.length&&res.data.count!=='0') { + this.setState({ allDemandSupply: this.state.allDemandSupply.concat(res.data.supplys) }, () => { + this.setState({ isAddToList: false }) + }) + } else { + this.setState({ isAddToList: false }) + Taro.showToast({ + title: '没有更多了', + icon: 'none' + }) + } + } else { + if (res.data.count!=='0') { + this.setState({ allDemandSupply: res.data.supplys, totalDemandSupply: res.data.count }) + } else { + this.setState({ allDemandSupply: [], totalDemandSupply: res.data.count }) + Taro.showToast({ + title: '没有找到相关信息', + icon: 'none' + }) + } + } - }) + } else { + Taro.showToast({ + title: res.data.err_msg, + icon: 'none', + duration: 1500 + }) + } + }) } + onSearchButtonHandler() { Taro.showLoading({ title: '加载中' }) - this.setState({ currentPage: 1 }, () => { - this.searchDemandSupply({}) + this.setState({ loadMorePageIndex:1 }, () => { + this.getMySupplyDemand({curr_page:this.state.loadMorePageIndex}) }) } @@ -167,10 +156,7 @@ class MySupplyDemand extends Component { }) }) } - //搜索我的供求 - - - + // 新增我的供求 addDemandSupply() { Taro.navigateTo({ @@ -186,6 +172,8 @@ class MySupplyDemand extends Component { startDateSel: '', demandSupplyCateSelected: { name: '全部', id: '' }, demandSupplyStatesSelected: { name: '全部', id: '' }, + }, () => { + this.getMySupplyDemand({}) }) Taro.showToast({ title: '已清空', @@ -257,15 +245,7 @@ class MySupplyDemand extends Component { url: '/pages/supplyDemandView/supplyDemandView?sdId=' + sdId }) } - // 翻页导航 - paginationNav(type) { - Taro.showLoading({ title: '加载中' }) - this.setState({ currentPage: type.current, }, () => { - this.getMySupplyDemand({ curr_page: this.state.currentPage }) - }) - - } componentWillReceiveProps(nextProps) { @@ -282,15 +262,22 @@ class MySupplyDemand extends Component { componentDidShow() { } componentDidHide() { } - + // 页面位置 + onPageScroll(location) { + if (location.scrollTop <= 300 && this.state.isShowTopNav) { + this.setState({ isShowTopNav: false }) + } else if (location.scrollTop > 300 && !this.state.isShowTopNav) { + this.setState({ isShowTopNav: true }) + } + } // 底部加载 onReachBottom() { Taro.showLoading({ title: '加载中' }) - loadMorePageIndex += 1 - this.setState({ isAddToList: true }, () => { - this.getMySupplyDemand({ curr_page: loadMorePageIndex }) + + this.setState({ isAddToList: true, loadMorePageIndex: this.state.loadMorePageIndex + 1 }, () => { + this.getMySupplyDemand({ curr_page: this.state.loadMorePageIndex }) }) } @@ -339,9 +326,10 @@ class MySupplyDemand extends Component { {item.update_date} - + + {item.state === '0' ? null : - + } @@ -429,12 +417,12 @@ class MySupplyDemand extends Component { 搜索 - - @@ -444,10 +432,8 @@ class MySupplyDemand extends Component { {demandSupplyElementArray} - - - + {this.state.isShowTopNav ? : null} diff --git a/src/pages/mySupplyDemand/mySupplyDemand.scss b/src/pages/mySupplyDemand/mySupplyDemand.scss index 9b952fa..1153160 100644 --- a/src/pages/mySupplyDemand/mySupplyDemand.scss +++ b/src/pages/mySupplyDemand/mySupplyDemand.scss @@ -1,4 +1,7 @@ $themeColor:#FF7142; +.button-orange, .button-dark-red,.button-green{ + font-size:28rpx; +} .mySupplyDemand{ padding: 10px 20px; @@ -74,18 +77,17 @@ $themeColor:#FF7142; flex-wrap: nowrap; flex-direction: row; margin: 40px 0; - padding: 0 120px; + .button{ flex:1; text-align: center; - - } - .button-orange, .button-dark-red,.button-green{ - font-size:28rpx; + .button-orange,.button-green,.button-dark-red{ + font-size: 27rpx + } } + } - .info-box{ font-size: 25rpx; @@ -112,6 +114,9 @@ $themeColor:#FF7142; // flex:1; text-align: center; margin:1% 1% 0; + .button-orange,.button-green,.button-dark-red{ + font-size: 27rpx + } } diff --git a/src/pages/shop/shop.js b/src/pages/shop/shop.js index 49a7c23..768da65 100644 --- a/src/pages/shop/shop.js +++ b/src/pages/shop/shop.js @@ -1,15 +1,15 @@ import Taro, { Component } from '@tarojs/taro' -import { View, Button, Text, Image } from '@tarojs/components' +import { View, Button, Text, Image, Map } from '@tarojs/components' import { AtTag, AtIcon, } from 'taro-ui' import URL from '../../serviceAPI.config' +import ScrollToTopComponent from '../../component/scrollToTopComponent/scrollToTopComponent' import './shop.scss' import ShopItem from '../../component/shopItemComponent/shopItemComponent' import BottomNav from '../../component/bottomNav/bottomNav' import CopyrightComponent from '../../component/copyrightComponent/copyrightComponent' -let loadMorePageIndex = 1 // 底部加载接口请求参数 class Shop extends Component { // 项目配置 @@ -53,6 +53,9 @@ class Shop extends Component { widthType: [],// 侧边宽度类型 checkedFilterIdList: [],//已选的筛选id isAddToList: false,// 请求店铺商品的时候是否添加到旧列表里 + loadMorePageIndex:1,//上拉加载页面数 + isShowTopNav: false,// 是否显示返回顶部按钮 + // 下面是函数的默认参数 curr_page: 1, page_count: 10, @@ -65,6 +68,8 @@ class Shop extends Component { goodsSpec: [], goodsParam: [], goodsParamExt: [], + longitude: '', + latitude: '' } } @@ -142,7 +147,13 @@ class Shop extends Component { // console.log('数据',data.goods_type) let goodTypeArray = [] Object.keys(data.goods_type).forEach(key => { - goodTypeArray.push({ id: data.goods_type[key].goods_type_id, name: data.goods_type[key].goods_type_ch_name, checked: false }) + if (data.goods_type[key]) { + goodTypeArray.push({ + id: data.goods_type[key].goods_type_id, + name: data.goods_type[key].goods_type_ch_name, + checked: false + }) + } }); formatedFilterOptions.goodType = goodTypeArray } @@ -151,11 +162,15 @@ class Shop extends Component { let goodsParamArray = [] Object.keys(data.goodsParam).forEach(key => { - const value = data.goodsParam[key] - const subArray = value.param_value.map(item => { - return { id: value.param_id, name: item, checked: false } - }) - goodsParamArray.push({ [value.param_name]: subArray }) + if (data.goodsParam[key]) { + const value = data.goodsParam[key] + const subArray = value.param_value.map(item => { + return { id: value.param_id, name: item, checked: false } + }) + goodsParamArray.push({ [value.param_name]: subArray }) + + } + }); formatedFilterOptions.otherType = goodsParamArray } @@ -190,6 +205,7 @@ class Shop extends Component { shop_class_id = this.state.shop_class_id, order = this.state.order, goods_class_id = this.state.goods_class_id, + currPage = '', // 不知道为什么筛选的时候要加 加这个参数为1 goodsSpec = this.state.goodsSpec, goodsParam = this.state.goodsParam, goodsParamExt = this.state.goodsParamExt }) { @@ -207,6 +223,7 @@ class Shop extends Component { shop_class_id: shop_class_id, order: order, goods_class_id: goods_class_id, + currPage: currPage }), goodsRegion: JSON.stringify({}), goodsSpec: JSON.stringify(goodsSpec), @@ -264,7 +281,9 @@ class Shop extends Component { shopAddress: res.data.data.shop_address, contactName: res.data.userRes.name, contactNumber: res.data.userRes.phone, - shopDescription: res.data.data.shop_desc + shopDescription: res.data.data.shop_desc, + latitude: res.data.data.shop_map.split(',')[0], + longitude: res.data.data.shop_map.split(',')[1] }, () => { // console.log(this.state.shopDescriptionData) }) @@ -318,7 +337,6 @@ class Shop extends Component { this.setState({ selectedFilterValue: value }) if (value == 0) { this.setState({ - currentPage: 1, filterOptions: { all: true, amount: false, @@ -328,11 +346,11 @@ class Shop extends Component { } } ) - this.goodsSearch({}) + this.goodsSearch({ currPage: 1 }) } if (value == 1) { this.setState({ - currentPage: 1, + filterOptions: { all: false, amount: !this.state.filterOptions.amount, @@ -341,13 +359,13 @@ class Shop extends Component { popularity: false } }, () => { - this.state.filterOptions.amount ? this.goodsSearch({ order: "g.sales_volume desc" }) : this.goodsSearch({ order: "g.sales_volume" }) + this.state.filterOptions.amount ? this.goodsSearch({ currPage: 1, order: "g.sales_volume desc" }) : this.goodsSearch({ currPage: 1, order: "g.sales_volume" }) } ) } if (value == 2) { this.setState({ - currentPage: 1, + filterOptions: { all: false, amount: false, @@ -356,7 +374,7 @@ class Shop extends Component { popularity: false } }, () => { - this.state.filterOptions.newProduct ? this.goodsSearch({ order: "g.create_date desc" }) : this.goodsSearch({ order: "g.create_date" }) + this.state.filterOptions.newProduct ? this.goodsSearch({ currPage: 1, order: "g.create_date desc" }) : this.goodsSearch({ currPage: 1, order: "g.create_date" }) } ) @@ -364,7 +382,7 @@ class Shop extends Component { if (value == 3) { this.setState({ - currentPage: 1, + filterOptions: { all: false, amount: false, @@ -373,7 +391,7 @@ class Shop extends Component { popularity: false } }, () => { - this.state.filterOptions.price ? this.goodsSearch({ order: "g.goods_price desc" }) : this.goodsSearch({ order: "g.goods_price" }) + this.state.filterOptions.price ? this.goodsSearch({ currPage: 1, order: "g.goods_price desc" }) : this.goodsSearch({ currPage: 1, order: "g.goods_price" }) } ) @@ -381,7 +399,7 @@ class Shop extends Component { if (value == 4) { this.setState({ - currentPage: 1, + filterOptions: { all: false, amount: false, @@ -390,7 +408,7 @@ class Shop extends Component { popularity: !this.state.filterOptions.popularity } }, () => { - this.state.filterOptions.popularity ? this.goodsSearch({ order: "g.browse_times desc", }) : this.goodsSearch({ order: "g.browse_times" }) + this.state.filterOptions.popularity ? this.goodsSearch({ currPage: 1, order: "g.browse_times desc", }) : this.goodsSearch({ currPage: 1, order: "g.browse_times" }) } ) @@ -464,7 +482,8 @@ class Shop extends Component { } return item }) - this.setState({ mainType: newMainType, goodType: newGoodType, widthType: newWidthType, otherType: newOtherType }, () => { + + this.setState({ mainType: newMainType, loadMorePageIndex:1,goodType: newGoodType, widthType: newWidthType, otherType: newOtherType }, () => { // console.log(this.state.mainType) }) } @@ -509,7 +528,7 @@ class Shop extends Component { config_id: 4, shop_class_id: '', order: '', - currPage: 1, + curr_page: 1, goods_class_id: '', goodsSpec: [], goodsParam: [], @@ -533,9 +552,7 @@ class Shop extends Component { } componentDidMount() { - Taro.showLoading({ title: '加载中' }) - console.log('this.$router.params.id', this.$router.params.id) //页面加载之后 得到指定店铺的商品 和 筛选标签 this.goodsSearch({ shop_id: this.$router.params.id }) // 加载店铺商品 this.getSearchParams({})// 加载筛选项 @@ -553,15 +570,21 @@ class Shop extends Component { Taro.showLoading({ title: '加载中' }) - loadMorePageIndex += 1 - this.setState({ isAddToList: true }, () => { - this.goodsSearch({ curr_page: loadMorePageIndex }) + + this.setState({ isAddToList: true,loadMorePageIndex:this.state.loadMorePageIndex }, () => { + this.goodsSearch({ curr_page: this.state.loadMorePageIndex }) }) } - + // 页面位置 + onPageScroll(location) { + if (location.scrollTop <= 300 && this.state.isShowTopNav) { + this.setState({ isShowTopNav: false }) + } else if (location.scrollTop > 300 && !this.state.isShowTopNav) { + this.setState({ isShowTopNav: true }) + } + } render() { - const ShopItemElementsArray = this.state.shopItem.length ? this.state.shopItem.map((item, index) => { return @@ -703,7 +726,7 @@ class Shop extends Component { 店铺介绍: {this.state.shopDescription} - + @@ -712,6 +735,20 @@ class Shop extends Component { + const shopAllCateElementArray = this.state.shopAllInnerCate.map((item, index) => { @@ -749,8 +786,11 @@ class Shop extends Component { {/* 显示店铺首页或者店铺详情 */} {this.state.showShopHomePage ? shopHomepageElement : shopDescriptionElement} + {this.state.isShowTopNav ? : null} - + + + diff --git a/src/pages/supplyDemandPublish/supplyDemandPublish.js b/src/pages/supplyDemandPublish/supplyDemandPublish.js index f2fd650..f0c4266 100644 --- a/src/pages/supplyDemandPublish/supplyDemandPublish.js +++ b/src/pages/supplyDemandPublish/supplyDemandPublish.js @@ -1,6 +1,6 @@ import Taro, { Component } from '@tarojs/taro' -import { View, Text,Button } from '@tarojs/components' +import { View, Text, Button,Input } from '@tarojs/components' import { AtInput, AtImagePicker, AtTextarea, Picker } from 'taro-ui' import CopyrightComponent from '../../component/copyrightComponent/copyrightComponent' @@ -30,26 +30,13 @@ class SupplyDemand extends Component { content: '', pickerImageUrl: [], // 上传的图片 ImagesInfo: [],// 后台传回来的图片信息 + isPublish: false,//是否点击发布按钮 + isPublishAndNew: false,//是否点击发布新增按钮 } } - // 上传供求api - uploadSupplyDemand() { - console.log(this.state.ImagesInfo) - if (this.state.demandingSupplyCateSelected && this.state.title && this.state.contactName && this.state.contactNumber && this.state.content && this.state.demandingSupplyStateSelected) { - this.uploadDemSup({}) - } else { - Taro.showToast({ - title:'请填写完表格', - icon:'none', - duration:1500 - }) - - } - } - // 这个需要写一个uploadDemSup 上传供求 的api uploadDemSup({ sd_type = this.state.demandingSupplyCateSelected.id, sd_title = this.state.title, @@ -92,17 +79,26 @@ class SupplyDemand extends Component { }) .then(res => { console.log('上传供求', res) + Taro.hideLoading() if (res.data.err_msg === 'success') { Taro.showToast({ title: '上传成功', icon: 'success', - duration: 1500 + duration: 1000 }).then(() => { setTimeout(() => { - Taro.navigateTo({ - url: '/pages/mySupplyDemand/mySupplyDemand' - }) - }, 1500); + if (this.state.isPublish) { + Taro.navigateTo({ + url: '/pages/myDemandSupplyEdit/myDemandSupplyEdit?sdId=' + res.data.sd_id + }) + + } else if (this.state.isPublishAndNew) { + Taro.navigateTo({ + url: '/pages/supplyDemandPublish/supplyDemandPublish' + }) + } + + }, 1000); }) } else { Taro.showToast({ @@ -126,6 +122,9 @@ class SupplyDemand extends Component { url: URL.UploadDSPorductImage, filePath: files[files.length - 1].url, name: 'file', + formData: { + 'key': 'michael', + }, header: { 'content-type': 'multipart/form-data; boundary=----WebKitFormBoundaryAWxeadaAVmRVQCiz', 'Cookie': 'PFWSSS=' + Taro.getStorageSync('session_id'), @@ -143,23 +142,23 @@ class SupplyDemand extends Component { title: '上传成功', icon: 'success', duration: 1500 - }) + }) } }) } if (operationType === 'remove') { this.state.ImagesInfo.splice(index, 1) // 删除显示的图片 this.state.pickerImageUrl.splice(index, 1)// 删除图片param - that.setState({ - pockerImageUrl:this.state.pickerImageUrl, - ImagesInfo:this.state.ImagesInfo, - }) - Taro.showToast({ - title: '删除成功', - icon: 'success', - duration: 1500 - }) - } + that.setState({ + pockerImageUrl: this.state.pickerImageUrl, + ImagesInfo: this.state.ImagesInfo, + }) + Taro.showToast({ + title: '删除成功', + icon: 'success', + duration: 1500 + }) + } } // 修改供求类型 demandingSupplyCate = e => { @@ -189,6 +188,40 @@ class SupplyDemand extends Component { contentChange(event) { this.setState({ content: event.target.value }) } + + // 上传供求api + publishButtonHandler() { + if (this.state.demandingSupplyCateSelected && this.state.title && this.state.contactName && this.state.contactNumber && this.state.content && this.state.demandingSupplyStateSelected) { + + Taro.showLoading({ title: '发布中' }).then(() => { + this.setState({ isPublish: true }, () => { + this.uploadDemSup({}) + }) + }) + } else { + Taro.showToast({ + title: '请填写完表格', + icon: 'none', + duration: 1500 + }) + } + } + publishAndNewButton() { + if (this.state.demandingSupplyCateSelected && this.state.title && this.state.contactName && this.state.contactNumber && this.state.content && this.state.demandingSupplyStateSelected) { + + Taro.showLoading({ title: '发布中' }).then(() => { + this.setState({ isPublishAndNew: true }, () => { + this.uploadDemSup({}) + }) + }) + } else { + Taro.showToast({ + title: '请填写完表格', + icon: 'none', + duration: 1500 + }) + } + } goToMyDemSupPage() { Taro.navigateTo({ url: '/pages/mySupplyDemand/mySupplyDemand' @@ -197,7 +230,7 @@ class SupplyDemand extends Component { componentDidMount() { - + } componentWillReceiveProps(nextProps) { console.log(this.props, nextProps) @@ -210,11 +243,11 @@ class SupplyDemand extends Component { componentDidHide() { } render() { - + return ( - + @@ -249,17 +282,20 @@ class SupplyDemand extends Component { border={false} /> - - * - + + + * + 联系电话: + + + + 联系地址: @@ -316,13 +352,12 @@ class SupplyDemand extends Component { - + - {/* - - - */} + + + diff --git a/src/pages/supplyDemandPublish/supplyDemandPublish.scss b/src/pages/supplyDemandPublish/supplyDemandPublish.scss index 6ebc29d..d8b3fb8 100644 --- a/src/pages/supplyDemandPublish/supplyDemandPublish.scss +++ b/src/pages/supplyDemandPublish/supplyDemandPublish.scss @@ -26,18 +26,12 @@ $themeColor:#FF7142; flex-wrap: nowrap; flex-direction: row; margin: 40px 0 0; - padding: 0 120px; .button{ flex:1; text-align: center; - .at-button--primary{ - background-color:$themeColor,; - border:1PX solid $themeColor,; - } - .button-a{ - background-color:#5cb85c; - border:1PX solid #5cb85c; - } + .button-orange,.button-green{ + font-size: 28rpx; + } } } diff --git a/src/pages/supplyDemandView/supplyDemandView.js b/src/pages/supplyDemandView/supplyDemandView.js index 31c28b8..9a24db4 100644 --- a/src/pages/supplyDemandView/supplyDemandView.js +++ b/src/pages/supplyDemandView/supplyDemandView.js @@ -221,7 +221,7 @@ class SupplyDemandView extends Component { - @@ -231,13 +231,13 @@ class SupplyDemandView extends Component { 修改 - diff --git a/src/pages/supplyDemandView/supplyDemandView.scss b/src/pages/supplyDemandView/supplyDemandView.scss index c204053..79884fa 100644 --- a/src/pages/supplyDemandView/supplyDemandView.scss +++ b/src/pages/supplyDemandView/supplyDemandView.scss @@ -19,25 +19,13 @@ $themeColor:#FF7142; flex-wrap: nowrap; flex-direction: row; margin: 40px 0 0; - padding: 0 20px; - + .button{ flex:1; text-align: center; - // margin:2%; - // justify-content:center; - .at-button--primary{ - background-color:$themeColor; - border:1PX solid $themeColor; - } - .button-g{ - background-color:#5cb85c; - border:1PX solid #5cb85c; - } - .button-a{ - background-color:#d9534f; - border:1PX solid #d9534f; + .button-orange,.button-green,.button-dark-red{ + font-size: 27rpx } } } diff --git a/src/todo list.txt b/src/todo list.txt index e7eb4e3..acaeb20 100644 --- a/src/todo list.txt +++ b/src/todo list.txt @@ -20,770 +20,760 @@ bug: 商品编辑 增加图片后 图片顺序乱了 import Taro, { Component } from '@tarojs/taro' import { View, Radio, Button } from '@tarojs/components' -import { AtInput, Text, AtIcon, Picker, Image, AtPagination, AtModal, AtModalHeader, AtModalContent, AtModalAction } from 'taro-ui' +import { AtInput, Text, AtIcon, Picker, Image, AtModal, AtModalHeader, AtModalContent, AtModalAction } from 'taro-ui' import CopyrightComponent from '../../component/copyrightComponent/copyrightComponent' +import ScrollToTopComponent from '../../component/scrollToTopComponent/scrollToTopComponent' + import URL from '../../serviceAPI.config' -import Taro, { Component } from '@tarojs/taro' -import { View, Button, Text, Image } from '@tarojs/components' -import { AtTag, AtIcon, AtPagination, } from 'taro-ui' -import URL from '../../serviceAPI.config' +import './myGoodList.scss' -import './shop.scss' -import ShopItem from '../../component/shopItemComponent/shopItemComponent' -import BottomNav from '../../component/bottomNav/bottomNav' -import CopyrightComponent from '../../component/copyrightComponent/copyrightComponent' -import ShopDescription from '../shopDescription/shopDescription'; - -let currentPage = 1 - -class Shop extends Component { - // 项目配置 - config = { - navigationBarTitleText: '店铺' +class MyGoodList extends Component { + config = { + navigationBarTitleText: '商品列表' + } + constructor() { + super(...arguments) + this.state = { + productName: '', + lowestPrice: '', + heightestPrice: '', + minimumSold: '', + maximumSold: '', + productId: '', + productCate: [], //宝贝类目 + productCateSelected: { id: '', name: '全部类目' },// 已选宝贝类目 + filterBar: ['filterPrice', 'filterStock', 'filterSold', 'filterPublishDate',], //筛选选项 + filterBarKeys: { filterPrice: '价格', filterStock: '库存', filterSold: '总销量', filterPublishDate: '发布时间' }, // 筛选选项对应值 + filterOptions: { + filterPrice: false, + filterStock: false, + filterSold: false, + filterPublishDate: false, + }, // 正反排序 + selectedFilterValue: 0, // + myGoodList: [],// 保存后台返回的商品列表 + myGoodListTotal: '0',// 后台的商品总数 + currentPage: 1, + goodsStateParam: 1,//商品状态参数 + pageCountParam: 2,// 商品数量参数 + currPageParam: 1,// 当前页面 参数 + isCheckAll: false,// 是否checked + goodsIdList: [],//商品Id 列表 + isOpenDeleteModal: false,// 是否显示删除模态框 + isOpenOffStockModal: false,// 是否显示下架模态框 + isAddToList: false,// 是否下拉加载 如果是 就添加商品到我的商品列表 + isShowTopNav: false,// 是否显示返回顶部按钮 + loadMorePageIndex: 1,//上拉加载页面数 } - constructor() { - super(...arguments) - this.state = { - isShopDetailsOn: false, // 是否显示店铺说明页面 - shopItem: [], // 所有商品 - value: '', // 搜索框的值 - shopId: '', // 店铺的id - shopName: '', // 店铺名 - FilterText: '', // 筛选的可选项 - filterBar: ['all', 'amount', 'newProduct', 'price', 'popularity'], //筛选选项 - filterBarKeys: { all: '综合排序', amount: '销量', newProduct: '新品', price: '价格', popularity: '人气' }, // 筛选选项对应值 - selectedFilterValue: 0, //筛选项 - isShowFilter: false, //是否显示侧边筛选 - showShopHomePage: true,// 是否显示首页页面 - shopDescriptionData: '',// 店铺详情信息 - shopName: '',//店铺名称 - shopAddress: '',//店铺地址 - contactName: '',//联系人 - contactNumber: '',//联系电话 - shopDescription: '',//店铺简介 - filterOptions: { - all: true, - amount: false, - newProduct: false, - price: false, - popularity: false, - }, - filterCondition: '',// 筛选条件 - total: 0,// 信息条数 - currentPage: 1,// 当前页 - isShowShopAllCate: false, - shopAllInnerCate: '',// 店铺内部分类 - isBlurWindow: false, - mainType: [],// 侧边筛选分类 - goodType: [],//侧边商品类型 - otherType: [],//侧边其他类型 - widthType: [],// 侧边宽度类型 - checkedFilterIdList: [],//已选的筛选id - isAddToList:false,// 请求店铺商品的时候是否添加到旧列表里 - // 下面是函数的默认参数 - curr_page: 1, - page_count: 10, - shop_name: false, - shop_id: this.$router.params.id, - config_id: 4, - shop_class_id: '', - order: '', - currPage: 1, - goods_class_id: '', - goodsSpec: [], - goodsParam: [], - goodsParamExt: [], - - } - } - - // api 得到筛选的标签请求 - getSearchParams({ - shop_name = this.state.shop_name, - shop_id = this.state.shop_id, - shop_class_id = this.state.shop_class_id, - goods_class_id = this.state.goods_class_id, - class_filter = this.state.class_filter, - goods_type = this.state.goods_type, - goodsSpec = this.state.goodsSpec, - goodsParam = this.state.goodsParam, - goodsParamExt = this.state.goodsParamExt }) { - Taro.request({ - url: URL.GetSearchParam, - method: 'POST', - dataType: 'json', - data: { - goods: JSON.stringify({ - shop_name: shop_name, - shop_id: shop_id, - shop_class_id: shop_class_id, - goods_class_id: goods_class_id, - class_filter: class_filter, - goods_type: goods_type, - - }), - goodsSpec: JSON.stringify(goodsSpec), - goodsParam: JSON.stringify(goodsParam), - goodsParamExt: JSON.stringify(goodsParamExt), - - }, - header: { - 'content-type': 'application/x-www-form-urlencoded', - 'X-Requested-With': 'XMLHttpRequest' - } - }) - .then(res => { - if (res.statusCode === 200) { - console.log('筛选项目成功', res) - Taro.hideLoading() - this.formatFilterData(res.data).then(data => { - this.setState({ - sideFilterdata: data, - mainType: data.mainType || [], - goodType: data.goodType || [], - otherType: data.otherType || [], - widthType: data.widthType || [], - }) - console.log('formated data', data) - }) - } else { - console.log('筛选项目获取失败') - } + } + productNameChange(event) { + this.setState({ productName: event }) + } + productIdChange(event) { + this.setState({ productId: event }) + } + lowestPriceChange(event) { + this.setState({ lowestPrice: event }) + } + heightestPriceChange(event) { + this.setState({ heightestPrice: event }) + } + minimumSoldChange(event) { + this.setState({ minimumSold: event }) + } + maximumSoldChange(event) { + this.setState({ maximumSold: event }) + } + productCateChange = e => { + this.setState({ + productCateSelected: this.state.productCate[e.detail.value] + }) + } + //获取宝贝类目搜索列表接口api + getBaoBeiCateList() { + Taro.request({ + url: URL.BaoBeiCateList, + method: 'POST', + dataType: 'json', + header: { + 'Cookie': 'PFWSSS=' + Taro.getStorageSync('session_id'), + 'content-type': 'application/x-www-form-urlencoded', + 'X-Requested-With': 'XMLHttpRequest' + } + }).then(res => { + console.log('baobei', res) + const productCate = [{ name: '全部类目', id: '' }] + for (let item of res.data.goodsClass) { + productCate.push({ name: item.class_name, id: item.class_id }) + } + this.setState({ productCate: productCate }) + + }).catch(err => { + Taro.showToast({ + title: '获取宝贝类目失败', + icon: 'none', + duration: 1500, + + }) + + }) + + } + + // 获取我的商品列表接口api + getMyGoodListApi({ + goodsState = this.state.goodsStateParam, + pageCount = this.state.pageCountParam, + currPage = this.state.currPageParam }) { + Taro.request({ + url: URL.MyGoodList, + method: 'POST', + dataType: 'json', + + data: { + goodsState: goodsState, + pageCount: pageCount, + currPage: currPage + }, + header: { + 'Cookie': 'PFWSSS=' + Taro.getStorageSync('session_id'), + 'content-type': 'application/x-www-form-urlencoded', + 'X-Requested-With': 'XMLHttpRequest' + } + }).then(res => { + if (res.statusCode === 200) { + console.log('我的商品列表', JSON.parse(res.data)) + const data = JSON.parse(res.data) + Taro.hideLoading() + + if (data.goods.length) { + data.goods.forEach(item => { + item.checked = false + }); + + if (this.state.isAddToList) { + this.setState({ myGoodList: this.state.myGoodList.concat(data.goods) }, () => { + this.setState({ isAddToList: false }) }) - } - - async formatFilterData(data) { - const formatedFilterOptions = {} - //侧边筛选分类 - if (data.goods_class) { - let typeArray = [] - data.goods_class.forEach(item => { - typeArray.push({ id: item.class_id, name: item.class_name, checked: false }) - }); - formatedFilterOptions.mainType = typeArray - } - //侧边筛选商品类型 - if (data.goods_type) { - // console.log('数据',data.goods_type) - let goodTypeArray = [] - Object.keys(data.goods_type).forEach(key => { - goodTypeArray.push({ id: data.goods_type[key].goods_type_id, name: data.goods_type[key].goods_type_ch_name, checked: false }) - }); - formatedFilterOptions.goodType = goodTypeArray - } - //侧边筛选其他类型 - if (data.goodsParam) { - let goodsParamArray = [] - - Object.keys(data.goodsParam).forEach(key => { - const value = data.goodsParam[key] - const subArray = value.param_value.map(item => { - return { id: value.param_id, name: item, checked: false } - }) - goodsParamArray.push({ [value.param_name]: subArray }) - }); - formatedFilterOptions.otherType = goodsParamArray - } - //侧边筛选宽度类型 - if (data.goodsParamExt) { - let goodsParamExtArray = [] - Object.keys(data.goodsParamExt).forEach(key => { - const value = data.goodsParamExt[key] - const keyId = value.param_id - Object.keys(value.param_value).forEach(item => { - const name = value.param_value[item].value_desc - const value1 = value.param_value[item] - - goodsParamExtArray.push({ name: name, value: value1, checked: false, id: keyId }) - }); - }); - formatedFilterOptions.widthType = goodsParamExtArray - - } - - return formatedFilterOptions - } - - - // api 得到所有的产品请求 - goodsSearch({ - curr_page = this.state.curr_page, - page_count = this.state.page_count, - shop_name = this.state.shop_name, - shop_id = this.state.shop_id, - config_id = this.state.config_id, - shop_class_id = this.state.shop_class_id, - order = this.state.order, - goods_class_id = this.state.goods_class_id, - goodsSpec = this.state.goodsSpec, - goodsParam = this.state.goodsParam, - goodsParamExt = this.state.goodsParamExt }) { - Taro.request({ - url: URL.GoodsSearch, - method: 'POST', - dataType: 'json', - data: { - goods: JSON.stringify({ - curr_page: curr_page, - page_count: page_count, - shop_name: shop_name, - shop_id: shop_id, - config_id: config_id, - shop_class_id: shop_class_id, - order: order, - goods_class_id: goods_class_id, - }), - goodsRegion: JSON.stringify({}), - goodsSpec: JSON.stringify(goodsSpec), - goodsParam: JSON.stringify(goodsParam), - goodsParamExt: JSON.stringify(goodsParamExt), - }, - header: { - 'content-type': 'application/x-www-form-urlencoded', - 'X-Requested-With': 'XMLHttpRequest' - } - }) - .then(res => { - console.log('searchGood', res) - Taro.hideLoading() - this.setState({ shopItem: res.data.goods, total: res.data.goodsCount, filterCondition: order }, () => { - - }) - + } else { + this.setState({ + myGoodList: data.goods, + myGoodListTotal: data.goodsCount }) - } - // api 得到店铺详情请求 - getShopDescription({ shopID = 808 }) { - Taro.request({ - url: URL.ShopDescription, - method: 'POST', - dataType: 'json', - data: { - shopID: shopID, - }, - header: { - 'content-type': 'application/x-www-form-urlencoded', - } - }) - .then(res => { - Taro.hideLoading() - - this.setState({ - shopDescriptionData: res.data, - shopName: res.data.data.shop_name, - shopAddress: res.data.data.shop_address, - contactName: res.data.userRes.name, - contactNumber: res.data.userRes.phone, - shopDescription: res.data.data.shop_desc - }, () => { - // console.log(this.state.shopDescriptionData) - }) - - } - ) - } - // api 获取店铺内的店铺分类请求 GetShopCategoryList - getShopInnerCate({ id = 808 }) { - Taro.request({ - url: URL.GetShopCategoryList, - method: 'POST', - dataType: 'json', - data: { - id: id, - }, - header: { - 'content-type': 'application/x-www-form-urlencoded', - 'X-Requested-With': 'XMLHttpRequest' - } - }) - .then(res => { - if (res.statusCode === 200) { - Taro.hideLoading() - - const originalData = res.data.data - const sortedData = [] - for (let item in originalData) { - let each = originalData[item] - each['id'] = item - sortedData.push(each) - } - // console.log('sorteddata', sortedData) - this.setState({ shopAllInnerCate: sortedData }) - - } else { - console.log('获取店铺内部分类失败') - } - - - } - ) - } - - - - - // 产品排序 - accendingDescending(value) { - Taro.showLoading({ title: '加载中' }) - this.setState({ selectedFilterValue: value }) - if (value == 0) { - this.setState({ - currentPage: 1, - filterOptions: { - all: true, - amount: false, - newProduct: false, - price: false, - popularity: false - } - } - ) - this.goodsSearch({}) + } + } else { + Taro.showToast({ + title: '没有更多了', + icon: 'none' + }) } - if (value == 1) { - this.setState({ - currentPage: 1, - filterOptions: { - all: false, - amount: !this.state.filterOptions.amount, - newProduct: false, - price: false, - popularity: false - } - }, () => { - this.state.filterOptions.amount ? this.goodsSearch({ order: "g.sales_volume desc" }) : this.goodsSearch({ order: "g.sales_volume" }) - } - ) - } - if (value == 2) { - this.setState({ - currentPage: 1, - filterOptions: { - all: false, - amount: false, - newProduct: !this.state.filterOptions.newProduct, - price: false, - popularity: false - } - }, () => { - this.state.filterOptions.newProduct ? this.goodsSearch({ order: "g.create_date desc" }) : this.goodsSearch({ order: "g.create_date" }) - } - ) + } else { + console.log('我的商品列表获取失败') + } + }) - } - if (value == 3) { + } + // 获取搜索结果api + getGoodListResultApi({ + goodsName = this.state.productName, + goodsSn = '', + goodsClass = this.state.productCateSelected.id, + goodsPriceL = this.state.lowestPrice, + goodsPriceU = this.state.heightestPrice, + goodsSalesL = this.state.minimumSold, + goodsSalesU = this.state.maximumSold, + shopClassID = this.state.productId, + goodsState = this.state.goodsStateParam, + pageCount = this.state.pageCountParam, + currPage = this.state.currPageParam, + order = '', }) { + Taro.request({ + url: URL.MyGoodList, + method: 'POST', + dataType: 'json', - this.setState({ - currentPage: 1, - filterOptions: { - all: false, - amount: false, - newProduct: false, - price: !this.state.filterOptions.price, - popularity: false - } - }, () => { - this.state.filterOptions.price ? this.goodsSearch({ order: "g.goods_price desc" }) : this.goodsSearch({ order: "g.goods_price" }) - } - ) - - } - if (value == 4) { - - this.setState({ - currentPage: 1, - filterOptions: { - all: false, - amount: false, - newProduct: false, - price: false, - popularity: !this.state.filterOptions.popularity - } - }, () => { - this.state.filterOptions.popularity ? this.goodsSearch({ order: "g.browse_times desc", }) : this.goodsSearch({ order: "g.browse_times" }) - - } - ) - - } - } - // 是否显示侧边筛选 - showAndHideFilter() { - this.setState({ isShowFilter: !this.state.isShowFilter }) - } - // 选择侧边筛选的标签 - selectTag(name) { - const id = name.name - Taro.showLoading({ title: '加载中' }) - // 处理分类筛选项 - const newMainType = this.state.mainType.map((item) => { - if (item.id === id) { - item.checked = !item.checked - setTimeout(() => { - this.setState({ goods_class_id: id, checkedFilterIdList: this.state.checkedFilterIdList.concat([item]) }, () => { - this.getSearchParams({ goods_class_id: this.state.goods_class_id }) - this.goodsSearch({ goods_class_id: this.state.goods_class_id }) - }) - }, 1000); - } - return item - }) - // 处理商品类型筛选项 - const newGoodType = this.state.goodType.map((item) => { - if (item.id === id) { - item.checked = !item.checked - - setTimeout(() => { - this.setState({ goods_type: id, checkedFilterIdList: this.state.checkedFilterIdList.concat([item]) }, () => { - this.getSearchParams({ goods_type: this.state.goods_type }) - this.goodsSearch({ goods_type: this.state.goods_type }) - }) - - }, 1000); - } - return item - }) - // 处理其他筛选项 - const newOtherType = this.state.otherType.map(item => { - const value = Object.values(item)[0] - for (let each in value) { - if (value[each].name === id) { - value[each].checked = !value[each].checked - - setTimeout(() => { - - this.setState({ checkedFilterIdList: this.state.checkedFilterIdList.concat(value[each]), goodsParam: [{ param_id: value[each].name.id, param_value: value[each].name }] }, () => { - this.getSearchParams({ goodsParam: this.state.goodsParam }) - this.goodsSearch({ goodsParam: this.state.goodsParam }) - }) - }, 1000); - } - } - return item - }) - // 处理宽度筛选项 - const newWidthType = this.state.widthType.map((item) => { - if (item.name === id) { - item.checked = !item.checked - setTimeout(() => { - this.setState({ checkedFilterIdList: this.state.checkedFilterIdList.concat(item), goodsParamExt: [{ param_id: item.id, param_ext: [item.value] }] }, () => { - this.getSearchParams({ goodsParamExt: this.state.goodsParamExt }) - this.goodsSearch({ goodsParamExt: this.state.goodsParamExt }) - }) - }, 1000); - } - return item - }) - this.setState({ mainType: newMainType, goodType: newGoodType, widthType: newWidthType, otherType: newOtherType }, () => { - // console.log(this.state.mainType) - }) - } - - handleOnPageChange(value) { - Taro.showLoading({ title: '加载中' }) - this.goodsSearch({ curr_page: value.current, order: this.state.filterCondition }) - } - showHomePage() { - this.setState({ showShopHomePage: true }) - } - showDescriptionPage() { - this.setState({ showShopHomePage: false }) - } - isShowShopAllCate() { - this.setState({ isShowShopAllCate: !this.state.isShowShopAllCate, isBlurWindow: true }) - - } - handleShopInnerCate(id) { - - Taro.showLoading({ title: '加载中' }) + data: { + goodsName: goodsName, + goodsSn: goodsSn, + goodsClass: goodsClass, + goodsPriceL: goodsPriceL, + goodsPriceU: goodsPriceU, + goodsSalesL: goodsSalesL, + goodsSalesU: goodsSalesU, + shopClassID: shopClassID, + goodsState: goodsState, + pageCount: pageCount, + currPage: currPage, + order: order + }, + header: { + 'Cookie': 'PFWSSS=' + Taro.getStorageSync('session_id'), + 'content-type': 'application/x-www-form-urlencoded', + 'X-Requested-With': 'XMLHttpRequest' + } + }).then(res => { + if (res.statusCode === 200) { + console.log('我的商品列表', JSON.parse(res.data)) + const data = JSON.parse(res.data) + const goodCount = Number(data.goodsCount) this.setState({ - isShowShopAllCate: false, isBlurWindow: false + myGoodList: data.goods, + myGoodListTotal: goodCount }) - this.goodsSearch({ shop_class_id: id, shop_id: this.$router.params.id }) + Taro.hideLoading() - } - // 确认筛选 - submitFilter() { - this.setState({ isShowFilter: false }) - } + } else { + console.log('我的商品列表获取失败') + } - //重置按键筛选 - resetFilterList() { - Taro.showLoading({ title: '加载中' }) - this.setState({ - checkedFilterIdList: [], curr_page: 1, - page_count: 10, - shop_name: false, - shop_id: 1305, - config_id: 4, - shop_class_id: '', - order: '', - currPage: 1, - goods_class_id: '', - goodsSpec: [], - goodsParam: [], - goodsParamExt: [], - }, () => { - this.getSearchParams({}) - this.goodsSearch({}) + }) + + } + + // 商品列表下架API + changeGoodState({ goodsState = 0, goodsID = this.state.goodsIdList }) { + Taro.request({ + url: URL.ChangeGoodState, + method: 'POST', + dataType: 'json', + + data: { + goodsState: goodsState, + goodsID: JSON.stringify(goodsID) + }, + header: { + 'Cookie': 'PFWSSS=' + Taro.getStorageSync('session_id'), + 'content-type': 'application/x-www-form-urlencoded', + 'X-Requested-With': 'XMLHttpRequest' + } + }).then(res => { + if (res.statusCode === 200) { + Taro.showToast({ + title: '下架成功', + icon: 'success', + duration: 1500 + }).then(() => { + this.setState({ isCheckAll: false }) + this.getMyGoodListApi({}) + }) - } - - // 关闭背景window - closeBgWindow() { - this.setState({ - isShowShopAllCate: false, isBlurWindow: false + } else { + Taro.showToast({ + title: '下架失败', + icon: 'none', + duration: 1500 }) - } + this.setState({ isCheckAll: false }) + } - componentWillMount() { + + }) + + } + // 商品列表删除api + deleteGood({ goodsState = 1, goodsID = this.state.goodsIdList }) { + Taro.request({ + url: URL.DeleteGood, + method: 'POST', + dataType: 'json', + + data: { + goodsState: goodsState, + goodsID: JSON.stringify(goodsID) + }, + header: { + 'Cookie': 'PFWSSS=' + Taro.getStorageSync('session_id'), + 'content-type': 'application/x-www-form-urlencoded', + 'X-Requested-With': 'XMLHttpRequest' + } + }).then(res => { + if (res.statusCode === 200) { + console.log('商品删除返回', res) + Taro.showToast({ + title: '删除成功', + icon: 'success', + duration: 1500 + }).then(() => { + + this.setState({ isCheckAll: false }) + this.getMyGoodListApi({}) + + }) + } else { + Taro.showToast({ + title: '删除失败', + icon: 'none', + duration: 1500 + }) + this.setState({ isCheckAll: false }) + } + + + }) + + } + + + + + // 搜索 + searchButtonHandler() { + Taro.showLoading({ + title: '加载中', + }) + this.setState({ currentPage: 1, isCheckAll: false }, () => { + this.getGoodListResultApi({}) + }) + } + + + // 清空搜索 + emptyButtonHanlder() { + this.setState({ + productName: '', + lowestPrice: '', + heightestPrice: '', + minimumSold: '', + maximumSold: '', + productId: '', + productCateSelected: { id: '', name: '全部类目' }, + }, () => { + + this.setState({ isCheckAll: false, currentPage: 1 }, () => { + this.getMyGoodListApi({}) + }) + Taro.showToast({ + title: '已清空', + icon: 'success', + duration: 1000 + }) + }) + + } + // 产品排序 + accendingDescending(value) { + this.setState({ selectedFilterValue: value }) + if (value == 0) { + this.setState({ + currentPage: 1, + filterOptions: { + filterPrice: !this.state.filterOptions.filterPrice, + filterStock: false, + filterSold: false, + filterPublishDate: false, + } + } + ) + this.state.filterOptions.filterPrice ? this.getGoodListResultApi({ order: "goods_price desc" }) : this.getGoodListResultApi({ order: "goods_price" }) } - componentDidMount() { - - Taro.showLoading({ title: '加载中' }) - console.log('this.$router.params.id', this.$router.params.id) - //页面加载之后 得到指定店铺的商品 和 筛选标签 - this.goodsSearch({ shop_id: this.$router.params.id }) // 加载店铺商品 - this.getSearchParams({})// 加载筛选项 - this.getShopDescription({ shopID: this.$router.params.id }) // 加载店铺说明 - // this.getSearchBarkeyWords() - this.getShopInnerCate({ id: this.$router.params.id }) + if (value == 1) { + this.setState({ + currentPage: 1, + filterOptions: { + filterPrice: false, + filterStock: !this.state.filterOptions.filterStock, + filterSold: false, + filterPublishDate: false, + } + }, () => { + this.state.filterOptions.filterStock ? this.getGoodListResultApi({ order: "goods_stock desc" }) : this.getGoodListResultApi({ order: "goods_stock" }) + } + ) } + if (value == 2) { + this.setState({ + currentPage: 1, + filterOptions: { + filterPrice: false, + filterStock: false, + filterSold: !this.state.filterOptions.filterSold, + filterPublishDate: false, - componentDidShow() { } + } + }, () => { + this.state.filterOptions.filterSold ? this.getGoodListResultApi({ order: "sales_volume desc" }) : this.getGoodListResultApi({ order: "sales_volume" }) + } - componentDidHide() { } + ) - // 底部加载 + } + if (value == 3) { + this.setState({ + currentPage: 1, + filterOptions: { + filterPrice: false, + filterStock: false, + filterSold: false, + filterPublishDate: !this.state.filterOptions.filterPublishDate, + + } + }, () => { + this.state.filterOptions.filterPublishDate ? this.getGoodListResultApi({ order: "update_date desc" }) : this.getGoodListResultApi({ order: "update_date" }) + } + ) + } + } + + + // 商品全部选择 + checkAllHandler() { + if (this.state.myGoodList.length) { + const newMyGoodList = this.state.myGoodList.map((item) => { + item.checked = !this.state.isCheckAll + return item + }) + this.setState({ isCheckAll: !this.state.isCheckAll, myGoodList: newMyGoodList }, () => { + console.log('全选列表', this.state.myGoodList) + }) + } + else { + this.setState({ + isCheckAll: true + }, () => { + this.setState({ isCheckAll: false }) + }) + Taro.showToast({ + title: '全选无效', + icon: 'none', + duration: 1500 + }).then(() => { + + }) + + } + } + + + // 单个商品选择 + handleCheckChange(Id) { + //如果goodid 一样的那么checked 就取反 + const newMyGoodList = this.state.myGoodList.map((item) => { + if (item.goods_id === Id) { + item.checked = !item.checked + } + return item + }) + this.setState({ myGoodList: newMyGoodList }) + } + // 删除商品 + deleteGoodsHandler() { + const checkedGoodsId = [] + this.state.myGoodList.forEach(item => { + if (item.checked) { + checkedGoodsId.push(item.goods_id) + } + }); + checkedGoodsId.length ? this.setState({ isOpenDeleteModal: true }) : Taro.showToast({ + title: '请选择要删除的商品', + icon: 'none', + duration: 1500 + }) + // // this.deleteGood({ goodsID: checkedGoodsId }) + + + + } + // 改变商品状态 + offStockGoodHandler() { + const checkedGoodsId = [] + this.state.myGoodList.forEach(item => { + if (item.checked) { + checkedGoodsId.push(item.goods_id) + } + }); + //this.changeGoodState({ goodsID: checkedGoodsId }) + checkedGoodsId.length ? this.setState({ isOpenOffStockModal: true }) : Taro.showToast({ + title: '请选择要下架的商品', + icon: 'none', + duration: 1500 + }) + } + // 导航到商品编辑页面myGoodsEdit + goToGoodEditPage(goodId) { + Taro.navigateTo({ + url: '/pages/myGoodsEdit/myGoodsEdit?id=' + goodId + }) + } + // 导航到商品发布页面 + + goToGoodsPublishPage() { + Taro.navigateTo({ + url: '/pages/goodsPublish/goodsPublish' + }) + } + goToGoodspage(goodId) { + Taro.navigateTo({ + url: '/pages/goods/goods?id=' + goodId + }) + } + + DeleteConfirm() { + this.setState({ + isOpenDeleteModal: false + }) + const checkedGoodsId = [] + this.state.myGoodList.forEach(item => { + if (item.checked) { + checkedGoodsId.push(item.goods_id) + } + }); + this.deleteGood({ goodsID: checkedGoodsId }) + } + deleteModalClose() { + this.setState({ + isOpenDeleteModal: false + }) + } + OffStockConfirm() { + + this.setState({ + isOpenOffStockModal: false + }) + const checkedGoodsId = [] + this.state.myGoodList.forEach(item => { + if (item.checked) { + checkedGoodsId.push(item.goods_id) + } + }); + this.changeGoodState({ goodsID: checkedGoodsId }) + } + offStockModalClose() { + this.setState({ + isOpenOffStockModal: false + }) + } + + componentDidMount() { + Taro.showLoading({ + title: '加载中' + }) + this.getMyGoodListApi({}) + this.getBaoBeiCateList() + } + componentWillReceiveProps(nextProps) { + console.log(this.props, nextProps) + } + + componentWillUnmount() { } + + componentDidShow() { } + + componentDidHide() { } + // 页面位置 + onPageScroll(location) { + if (location.scrollTop <= 300 && this.state.isShowTopNav) { + this.setState({ isShowTopNav: false }) + } else if (location.scrollTop > 300 && !this.state.isShowTopNav) { + this.setState({ isShowTopNav: true }) + } + } + // 底部加载 onReachBottom() { Taro.showLoading({ title: '加载中' }) - - currentPage += 1 - this.setState({ isAddToList: true }, () => { - this.goodsSearch({ curr_Page: currentPage }) + this.setState({ isAddToList: true, loadMorePageIndex: this.state.loadMorePageIndex + 1 }, () => { + this.getMyGoodListApi({ currPage: this.state.loadMorePageIndex }) }) } - render() { - - const ShopItemElementsArray = this.state.shopItem.length ? this.state.shopItem.map((item, index) => { - return - - - }) : null - - const filterElementsArray = this.state.filterBar.map((item, index) => { - let isTure = this.state.filterOptions[item] - - return - - {this.state.filterBarKeys[item]} - - {index !== 0 && index !== 5 && (isTure ? : )} - - }) - // 侧边已选项 - const checkedFilterElementsArray = this.state.checkedFilterIdList.map((item, index) => { - return {item.name} - }) + render() { + //等待接口数据 + const goodListElementArray = this.state.myGoodList.map((item, index) => { + return + + + + {/* */} + + + {item.goods_name} + ¥{item.goods_price} + {item.sales_volume} - // 侧边筛选的分类项 - const goodsClassElementsArray = this.state.mainType.map((item, index) => { - return {item.name} - }) - // 侧边筛选的商品类型项 - const goodsTypeElementsArray = this.state.goodType.map((item, index) => { - return {item.name} - }) - - // 侧边筛选的其他项 - const goodsParamElementsArray = this.state.otherType.map((item, index) => { - let titleKey = Object.keys(item)[0] - let values = item[titleKey] - return {titleKey} - {values.map((subItem, subIndex) => { - let name = subItem.name - let isCheck = subItem.checked - return - {name} - - })} - - }) - - // 侧边筛选宽度选项 - const widthnessElementsArray = this.state.widthType.map((item, index) => { - return {item.name} - }) - // 店铺页面/店铺主页 - const shopHomepageElement = - - {filterElementsArray} - - - 筛选 - - - - - - - {/* 侧边筛选 */} - - - {this.state.checkedFilterIdList.length ? 已选择 : null} - {checkedFilterElementsArray} - {this.state.mainType.length ? 分类 : null} - {goodsClassElementsArray} - {this.state.goodType.length ? 商品类型 : null} - {goodsTypeElementsArray} - {goodsParamElementsArray} - {this.state.widthType.length ? 宽度 : null} - {widthnessElementsArray} - - - - - - - - - - - {/* 店铺的商品列表 */} - - {ShopItemElementsArray} - - {/* - - - - */} - - // 店铺详情 - const shopDescriptionElement = - - - - - {this.state.shopName} - - - {this.state.shopAddress} - - - 联系人:{this.state.contactName} - 联系电话:{this.state.contactNumber} - - - - - - 店铺简介 - - - 店铺介绍: - {this.state.shopDescription} - - - - - - - - - const shopAllCateElementArray = this.state.shopAllInnerCate.map((item, index) => { - return {item.n} - }) - return ( - + + + + + }) + // 筛选项目排序element + const filterElementsArray = this.state.filterBar.map((item, index) => { + let isTure = this.state.filterOptions[item] - - - - {this.state.shopName} - - - - - - 店铺全部分类 - - - - - {shopAllCateElementArray} - - - 首页 - - - - - 店铺说明 - - - - - {/* 显示店铺首页或者店铺详情 */} - {this.state.showShopHomePage ? shopHomepageElement : shopDescriptionElement} - + return + + {this.state.filterBarKeys[item]} + + {isTure ? : } + + }) + // 删除提示模态弹窗element + const modalMessageDeleteElement = + 提示 + + 确定要删除已选商品? + + + + // 下架提示模态弹窗element + const modalMessageOffStockElement = + 提示 + + 确定要下架已选商品? + + + + + return ( + + {/* 删除模态提示框 */} + {modalMessageDeleteElement} + {/* 下架模态框提示 */} + {modalMessageOffStockElement} + + + + + + + + + + + + + + + + + + + + + 宝贝类目: + + {this.state.productCateSelected.name} + - - - - ) - } + + + + + + + + + + + + + + + 出售中的宝贝{this.state.myGoodListTotal}条记录 + + + + {filterElementsArray} + + + + 全选 + + + + + + + + + + + + {goodListElementArray} + + {this.state.isShowTopNav ? : null} + + + + ) + } } -export default Shop +export default MyGoodList