发布与编辑 按钮个数,联系电话长度,

This commit is contained in:
郑茂强 2019-01-17 08:52:30 +08:00
parent f0adffacc5
commit 156abaf917
36 changed files with 1992 additions and 1568 deletions

View File

@ -39,6 +39,7 @@ class bottomNav extends Component {
} }
componentWillReceiveProps(nextProps) { componentWillReceiveProps(nextProps) {
//console.log(this.props, nextProps) //console.log(this.props, nextProps)
} }

View File

@ -1,6 +1,6 @@
import Taro, { Component } from '@tarojs/taro' import Taro, { Component } from '@tarojs/taro'
import { View, Button, Text, Image } from '@tarojs/components' import { View, Button, Text, Image, Input } from '@tarojs/components'
import { AtIcon, AtModal, AtModalHeader, AtModalContent, AtModalAction, AtInput, AtNoticebar } from 'taro-ui' import { AtIcon, AtModal, AtModalHeader, AtModalContent, AtModalAction, AtNoticebar } from 'taro-ui'
import VoucherPosterComponent from './voucherPosterComponent/voucherPosterComponent' import VoucherPosterComponent from './voucherPosterComponent/voucherPosterComponent'
@ -11,8 +11,16 @@ const hornIcon = require('../../icons/horn.png')
const houseIcon = require('../../icons/house.png') const houseIcon = require('../../icons/house.png')
class recommondShop extends Component { 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 = { config = {
@ -26,10 +34,8 @@ class recommondShop extends Component {
consultTip: '', consultTip: '',
voucherResponseMsg: '', voucherResponseMsg: '',
voucherCanConsult: false, voucherCanConsult: false,
voucherName: this.props.userName, userName: Taro.getStorageSync('user_identity').username,
voucherPhone: this.props.userPhone, userPhone: Taro.getStorageSync('user_identity').userphone,
consultName: this.props.userName,
consultPhone: this.props.userPhone,
} }
} }
goToShop(value) { goToShop(value) {
@ -135,7 +141,7 @@ class recommondShop extends Component {
} }
voucherModalConfirm() { voucherModalConfirm() {
this.setState({ isOpenVoucher: false }) 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() { isOpenConsult() {
@ -147,19 +153,19 @@ class recommondShop extends Component {
} }
consultModalConfirm() { consultModalConfirm() {
this.setState({ isOpenConsult: false }) 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) { handleInputVcherPhone(value) {
this.setState({ voucherPhone: value }) this.setState({ userPhone: value })
} }
handleInputVcherName(value) { handleInputVcherName(value) {
this.setState({ voucherName: value }) this.setState({ userName: value })
} }
handleInputCsultName(value) { handleInputCsultName(value) {
this.setState({ consultName: value }) this.setState({ userName: value })
} }
handleInputCsultPhone(value) { handleInputCsultPhone(value) {
this.setState({ consultPhone: value }) this.setState({ userPhone: value })
} }
getDataFromChild(value) { getDataFromChild(value) {
console.log('从voucherposter件传回来的值', value) console.log('从voucherposter件传回来的值', value)
@ -179,84 +185,60 @@ class recommondShop extends Component {
componentDidHide() { } componentDidHide() { }
render() {
// console.log('店铺',this.props.shop)
const title = this.props.shop ? this.props.shop.shop_name : null render() {
const imgUrl = this.props.shop ? URL.Base + this.props.shop.goods[0].goods_url : null const title = this.props.shop.shop_name
const price = this.props.shop ? this.props.shop.goods[0].goods_price : null const imgUrl = URL.Base + this.props.shop.goods[0].goods_url
const goods = this.props.shop ? this.props.shop.goods : null const price = this.props.shop.goods[0].goods_price
const ProductName = this.props.shop ? this.props.shop.goods[0].goods_name : null const goods = this.props.shop.goods
const address = this.props.shop ? this.props.shop.shop_address : null const ProductName = this.props.shop.goods[0].goods_name
const distance = this.props.shop ? this.props.shop.distance : null const address = this.props.shop.shop_address
const ads = this.props.shop ? this.props.shop.ads : null const distance = this.props.shop.distance
const voucherLeft = this.props.shop ? this.props.shop.left_nums : null const ads = this.props.shop.ads
// const consultText = this.props.shop.wx_open 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 slicedGoods = goods !== null ? goods.slice(1) : null
const goodsElementsArray = goods !== null ? slicedGoods.map((item, index) => { const goodsElementsArray = goods !== null ? slicedGoods.map((item, index) => {
return <View className='goods-img-box' key={index}> return <View className='goods-img-box' key={index}>
<Image className='goods-img' onClick={this.goToShop.bind(this, this.props.shop)} mode='aspectFit' style='max-height: 100%; max-width: 100%;' src={URL.Base + item.goods_url} /> <Image className='goods-img' onClick={this.goToShop.bind(this, this.props.shop)}
mode='aspectFit' style='max-height: 100%; max-width: 100%;'
src={URL.Base + item.goods_url}
/>
</View> </View>
}) : null }) : null
// 优惠卷和咨询元素 // 优惠卷和咨询元素
// const voucherModalElement = <AtModal className='voucher-modal' isOpened={this.state.isOpenVoucher}>
// <AtModalHeader>优惠卷须知:</AtModalHeader>
// <AtModalContent>
// <AtNoticebar >
// <Text className='orange' > 提示:具体可以前往实体店进行领取优惠卷或通过电话进行咨询</Text>
// </AtNoticebar>
// <View className='voucher-left'>当前优惠卷{voucherLeft}张</View>
// <AtInput
// name='value'
// title='联系人:'
// type='text'
// value={this.state.voucherName}
// onChange={this.handleInputVcherName.bind(this)}
// />
// <AtInput
// border={false}
// name='value'
// title='联系电话:'
// type='number'
// value={this.state.voucherPhone}
// onChange={this.handleInputVcherPhone.bind(this)}
// />
// {!this.state.voucherCanConsult ? <View className='voucher-ResponseMsg'>{this.state.voucherResponseMsg}</View> : null}
// </AtModalContent>
// <AtModalAction> <Button onClick={this.voucherModalClose.bind(this)} >取消</Button> <Button className='orange' onClick={this.voucherModalConfirm.bind(this)}>确定</Button> </AtModalAction>
// </AtModal>
const consultModalElement = <AtModal isOpened={this.state.isOpenConsult}> const consultModalElement = <AtModal isOpened={this.state.isOpenConsult}>
<AtModalHeader>咨询</AtModalHeader> <AtModalHeader>咨询</AtModalHeader>
<AtModalContent> <AtModalContent>
<AtNoticebar > <AtNoticebar >
<Text className='orange' >提示:{this.state.consultTip}</Text> <Text >提示:{this.state.consultTip}</Text>
</AtNoticebar> </AtNoticebar>
<View className='input-box' style='display:flex; align-items:center; font-size:28rpx; margin:2% 2%'>
<View className='title'>
<AtInput <Text>联系人</Text>
name='value' </View>
title='联系人:' <Input name='value'
type='text' type='text'
value={this.state.consultName} value={this.state.userName}
onChange={this.handleInputCsultName.bind(this)} onInput={this.handleInputCsultName.bind(this)}
/> />
<AtInput
name='value' </View>
title='联系电话:' <View className='input-box' style='display:flex; align-items:center; font-size:28rpx; margin-left:2%'>
<View className='title'>
<Text>联系电话</Text>
</View>
<Input name='value'
type='number' type='number'
value={this.state.consultPhone} maxLength='11'
border={false} value={this.state.userPhone}
onChange={this.handleInputCsultPhone.bind(this)} onInput={this.handleInputCsultPhone.bind(this)}
/> />
</View>
</AtModalContent> </AtModalContent>
<AtModalAction> <Button onClick={this.consultModalClose.bind(this)} >取消</Button> <Button className='orange' onClick={this.consultModalConfirm.bind(this)}></Button> </AtModalAction> <AtModalAction> <Button onClick={this.consultModalClose.bind(this)} >取消</Button> <Button style='color:#FF7142' onClick={this.consultModalConfirm.bind(this)}></Button> </AtModalAction>
</AtModal> </AtModal>
@ -280,18 +262,14 @@ class recommondShop extends Component {
{voucherLeft ? <View className='button' onClick={this.isOpenVoucher.bind(this)} > {voucherLeft ? <View className='button' onClick={this.isOpenVoucher.bind(this)} >
<Button size='mini' className='button-blue-mini'> <Button size='mini' className='button-blue-mini'>
优惠卷</Button> 优惠卷</Button>
</View> : <View className='button blur' > </View> : <View className='button blur' onClick={this.isOpenVoucher.bind(this)} >
<Button size='mini' className='button-blue-mini'>优惠卷</Button> <Button size='mini' className='button-blue-mini'>优惠卷</Button>
</View>} </View>}
<View className='button contult-button' onClick={this.isOpenConsult.bind(this)} >
{isShowConsultButton ? <View className='button contult-button' onClick={this.isOpenConsult.bind(this)} >
<Button size='mini' className='button-blue-mini'> <Button size='mini' className='button-blue-mini'>
询价</Button> 询价</Button>
</View> </View> : null}
{/* {voucherLeft ? <Button onClick={this.isOpenVoucher.bind(this)} size='mini' className='button-orange' ></Button> : <Button disabled={true} size='mini' className='button-orange'></Button>}
<Button onClick={this.isOpenConsult.bind(this)} size='mini' className='button-orange'>询价</Button> */}
</View> </View>
</View> </View>

View File

@ -38,7 +38,7 @@ $linearBlue:linear-gradient(to right, #337ab7, #337ab7);
.button{ .button{
// margin-left:2%; // margin-left:2%;
text-align: center; text-align: center;
margin-left:25%; // margin-left:22%;
} }
.blur{ .blur{
opacity: 0.5; opacity: 0.5;
@ -67,11 +67,12 @@ $linearBlue:linear-gradient(to right, #337ab7, #337ab7);
margin-bottom:2%; margin-bottom:2%;
padding:0; padding:0;
} }
.consult-voucher-button{ .button-container{
flex:1; flex:1;
//margin-top: 20px ; //margin-top: 20px ;
margin-left: 50px; margin-left: 50px;
display: flex; display: flex;
justify-content: flex-end;
//vertical-align: middle; //vertical-align: middle;
.consult-button-text{ .consult-button-text{
@ -120,7 +121,7 @@ $linearBlue:linear-gradient(to right, #337ab7, #337ab7);
margin-top: 20px; margin-top: 20px;
.goods-img{ .goods-img{
border: 1px solid #ddd; border: 2px solid #ddd;
width: 90px; width: 90px;
height: 90px; height: 90px;
margin: 10px margin: 10px

View File

@ -1,5 +1,5 @@
import Taro, { Component } from '@tarojs/taro' 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 { AtIcon } from 'taro-ui'
import './voucherPosterComponent.scss' import './voucherPosterComponent.scss'
@ -43,24 +43,52 @@ class VoucherPoster extends Component {
}) })
.then(res => { .then(res => {
console.log('购买咨询请求成功', res) console.log('购买咨询请求成功', res)
if (res.statusCode === 200) {
Taro.showToast({ title: '领取成功', icon: 'success',duration:1500})
if (res.data.err_msg === 'success') {
Taro.showToast({
title: '领取成功',
icon: 'success',
duration: 1500
})
setTimeout(() => { setTimeout(() => {
this.passDataToParent() this.passDataToParent()
}, 1500); }, 1500);
} else { } else {
Taro.showToast({ title: res.data.err_msg, icon: 'none' }) Taro.showToast({
title: res.data.err_msg,
icon: 'none',
duration: 1500
})
} }
}).catch(err => { }).catch(err => {
console.log('购买咨询请求失败', err) console.log('购买咨询请求失败', err)
}) })
} }
// 确认键 // 确认键
voucherModalConfirm() { voucherModalConfirm() {
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 }) this.buyConsult({ user: this.state.voucherName, phone: this.state.voucherPhone })
}
} }
//名字输入 //名字输入
handleNameChange(value) { handleNameChange(value) {
@ -109,8 +137,14 @@ class VoucherPoster extends Component {
<View className='input-number ' > <View className='input-number ' >
<View className='title'> <Text>联系电话</Text></View> <View className='title'> <Text>联系电话</Text></View>
<Input class='input-info' type='text' value={this.state.voucherPhone} onInput={this.handleNumberChange.bind(this)} /> <Input class='input-info' type='text' maxLength='11' value={this.state.voucherPhone} onInput={this.handlePhoneChange.bind(this)} />
</View> </View>
<View>
</View>
<View className='tips'> <View className='tips'>
{this.props.voucherResponseMsg} {this.props.voucherResponseMsg}
</View> </View>

View File

@ -56,50 +56,28 @@ $linearOrange:linear-gradient(to right, #FF7142, #FF7142);
font-size: 50px; font-size: 50px;
} }
} }
.input-name{ // .input-name,.input-number{
margin-top:2%; // margin-top:2%;
margin-left:10%; // margin-left:10%;
overflow: hidden; // overflow: hidden;
width: 80%; // width: 80%;
border-radius:50rpx; // border-radius:50rpx;
background-color: white; // background-color: white;
display: flex;
height:80px; // height:80px;
font-size:25px; // font-size:25px;
.title{ // display:flex;
flex:1; // align-items:center;
margin-left:7%; // .title{
margin-top:4% // margin-left:7%;
} // }
.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{ .tips{
margin-left: 10%; margin-left: 10%;
@ -122,7 +100,6 @@ $linearOrange:linear-gradient(to right, #FF7142, #FF7142);
font-size: 28px; font-size: 28px;
background:$linearOrange; background:$linearOrange;
padding: 12rpx; 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 */ /* Add Animation */
@-webkit-keyframes animatetop { @-webkit-keyframes animatetop {

View File

@ -6,7 +6,7 @@
border-radius:50%; border-radius:50%;
text-align:center; text-align:center;
position:fixed; position:fixed;
bottom:8%; bottom:10%;
right:5%; right:5%;
font-size:25rpx; font-size:25rpx;
.box{ .box{

View File

@ -3,7 +3,6 @@ import { View, Image, Text } from '@tarojs/components'
import eyeIcon from '../../icons/eye.png' import eyeIcon from '../../icons/eye.png'
import cartIcon from '../../icons/cart.png' import cartIcon from '../../icons/cart.png'
import errorImg from '../../assets/img/errorimg.png'
import './shopItemComponent.scss' import './shopItemComponent.scss'

View File

@ -2,16 +2,16 @@ import Taro, { Component } from '@tarojs/taro'
import { View, Text, Image, Button } from '@tarojs/components' import { View, Text, Image, Button } from '@tarojs/components'
import { AtInput, Picker, AtIcon, AtModal, AtToast, AtModalHeader, AtModalContent, AtModalAction } from 'taro-ui' import { AtInput, Picker, AtIcon, AtModal, AtToast, AtModalHeader, AtModalContent, AtModalAction } from 'taro-ui'
import CopyrightComponent from '../../component/copyrightComponent/copyrightComponent' import CopyrightComponent from '../../component/copyrightComponent/copyrightComponent'
import ScrollToTopComponent from '../../component/scrollToTopComponent/scrollToTopComponent'
import InteractionComponent from '../../component/interactionComponent/interactionComponent' import InteractionComponent from '../../component/interactionComponent/interactionComponent'
import URL from '../../serviceAPI.config' import URL from '../../serviceAPI.config'
import './allDemanding.scss' import './allDemanding.scss'
import eyeIcon from '../../icons/eye.png' import eyeIcon from '../../icons/eye.png'
let loadMorePageIndex = 1 // 底部加载接口请求参数
class AllDemanding extends Component { class AllDemanding extends Component {
config = { config = {
@ -33,7 +33,8 @@ class AllDemanding extends Component {
grabOrderSuccess: '无法显示绑定后的字段',// 抢单成功返回字段 grabOrderSuccess: '无法显示绑定后的字段',// 抢单成功返回字段
currentPage: 1, currentPage: 1,
isAddToList: false,// / 请求业主需求的时候是否添加到旧列表里 isAddToList: false,// / 请求业主需求的时候是否添加到旧列表里
isShowTopNav: false,// 是否显示返回顶部按钮
loadMorePageIndex: 1
} }
} }
@ -74,7 +75,7 @@ class AllDemanding extends Component {
if (res.data.err_msg === 'success') { if (res.data.err_msg === 'success') {
if (res.data.supplys.length) { if (res.data.supplys.length) {
if (this.state.isAddToList) { 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 { } else {
this.setState({ supplys: res.data.supplys }) this.setState({ supplys: res.data.supplys })
} }
@ -219,15 +220,23 @@ class AllDemanding extends Component {
componentDidShow() { } componentDidShow() { }
componentDidHide() { } 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() { onReachBottom() {
Taro.showLoading({ Taro.showLoading({
title: '加载中' title: '加载中'
}) })
loadMorePageIndex += 1
this.setState({ isAddToList: true }, () => { this.setState({ isAddToList: true, loadMorePageIndex: this.state.loadMorePageIndex + 1 }, () => {
this.searchDemanding({ curr_page: loadMorePageIndex }) this.searchDemanding({ curr_page: this.state.loadMorePageIndex })
}) })
} }
@ -271,7 +280,7 @@ class AllDemanding extends Component {
{item.state_name === '在用' ? <View className='button' onClick={this.grabOrder.bind(this, item.sd_id)}> {item.state_name === '在用' ? <View className='button' onClick={this.grabOrder.bind(this, item.sd_id)}>
<Button size='mini' className='button-orange'>抢单</Button> <Button size='mini' className='button-orange'>抢单</Button>
</View> : <View className='button' > </View> : <View className='button' >
<Button size='mini' className='button-orange blur'> 已抢</Button> <Button size='mini' className='button-orange blur'> 已抢</Button>
</View> </View>
} }
</View> </View>
@ -354,7 +363,7 @@ class AllDemanding extends Component {
<View className='demanding-box'> <View className='demanding-box'>
{allDemandingElementArray} {allDemandingElementArray}
</View> </View>
{this.state.isShowTopNav ? <ScrollToTopComponent ></ScrollToTopComponent> : null}
<CopyrightComponent></CopyrightComponent> <CopyrightComponent></CopyrightComponent>
</View> </View>
) )

View File

@ -228,7 +228,7 @@ class Goods extends Component {
<View className='details-box'> <View className='details-box'>
{/* 大类 */} {/* 大类 */}
<AtTabs className='alltabs' animated={false} current={this.state.current} tabList={mainTabList} onClick={this.handleClick.bind(this)}> <AtTabs className='alltabs' animated={false} current={this.state.current} tabList={mainTabList} onClick={this.handleClick.bind(this)}>
<AtTabsPane current={this.state.current} index={0} > <AtTabsPane style='color:red' current={this.state.current} index={0} >
<View style='background-color: #FAFBFC;' > <View style='background-color: #FAFBFC;' >
<View className='description-title'>商品细节</View> <View className='description-title'>商品细节</View>
@ -290,6 +290,8 @@ class Goods extends Component {
</View> </View>
<CopyrightComponent></CopyrightComponent> <CopyrightComponent></CopyrightComponent>
<View className='gap' style='height:150rpx'>
</View>
<View className='shop-bottom-box' > <View className='shop-bottom-box' >
<View className='shop-bottom-nav'> <View className='shop-bottom-nav'>

View File

@ -31,6 +31,8 @@ class GoodsPublish extends Component {
ImagesInfo: [],// 后台传回来的图片信息 ImagesInfo: [],// 后台传回来的图片信息
shopCategoryList: [], shopCategoryList: [],
productCategoryList: [], productCategoryList: [],
isPublishAndAdd:false,// 是否点击发布新增按钮
isPublish:false, // 时候点击发布按钮
} }
} }
@ -104,10 +106,17 @@ class GoodsPublish extends Component {
duration: 1000 duration: 1000
}) })
setTimeout(() => { setTimeout(() => {
if(this.state.isPublish){
// 导航到编辑页面
Taro.navigateTo({ Taro.navigateTo({
url: '/pages/goods/goods?id=' + res.data.goods_id url: '/pages/myGoodsEdit/myGoodsEdit?id=' + res.data.goods_id
}) })
}else if(this.state.isPublishAndAdd){
// 导航到发布页面
Taro.navigateTo({
url: '/pages/goodsPublish/goodsPublish'
})
}
}, 1000); }, 1000);
} }
@ -167,7 +176,7 @@ class GoodsPublish extends Component {
filePath: files[files.length - 1].url, filePath: files[files.length - 1].url,
name: 'file', name: 'file',
formData: { formData: {
user: 'test'
}, },
header: { header: {
'content-type': 'multipart/form-data', 'content-type': 'multipart/form-data',
@ -175,6 +184,8 @@ class GoodsPublish extends Component {
'X-Requested-With': 'XMLHttpRequest' 'X-Requested-With': 'XMLHttpRequest'
}, },
success(response) { success(response) {
const responseMsg=JSON.parse(response.data).err_msg
if (responseMsg=== 'success'||responseMsg === 'duplicate') {
const data = JSON.parse(response.data) const data = JSON.parse(response.data)
const imagePath = URL.Base + data.file_path const imagePath = URL.Base + data.file_path
const newPickerImageUrl = that.state.pickerImageUrl.concat({ url: imagePath }) const newPickerImageUrl = that.state.pickerImageUrl.concat({ url: imagePath })
@ -186,6 +197,15 @@ class GoodsPublish extends Component {
duration: 2000 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 && if (this.state.productName &&
this.state.productPrice && this.state.productPrice &&
this.state.productUnit && this.state.productUnit &&
@ -209,7 +229,7 @@ class GoodsPublish extends Component {
this.state.goodsTypeSelected.id && this.state.goodsTypeSelected.id &&
this.state.shopTypeSelected.id) { this.state.shopTypeSelected.id) {
Taro.showLoading({ title: '发布中' }).then(() => { Taro.showLoading({ title: '发布中' }).then(() => {
setTimeout(() => { this.setState({isPublish:true},()=>{
this.uploadGoods({ this.uploadGoods({
goods_name: this.state.productName, goods_name: this.state.productName,
goods_price: this.state.productPrice, goods_price: this.state.productPrice,
@ -218,13 +238,44 @@ class GoodsPublish extends Component {
class_id: this.state.goodsTypeSelected.id, class_id: this.state.goodsTypeSelected.id,
shop_class_id: this.state.shopTypeSelected.id, shop_class_id: this.state.shopTypeSelected.id,
}) })
}, 1000)
})
}) })
} else { } else {
Taro.showToast({ title: '请填写完表格', icon: 'none' }) 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() { goToMyGoodListPage() {
Taro.navigateTo({ Taro.navigateTo({
@ -334,23 +385,24 @@ class GoodsPublish extends Component {
<Text className='require'></Text> <Text className='require'></Text>
<Text className='title'>商品简介:</Text> <Text className='title'>商品简介:</Text>
</View> </View>
<AtTextarea <AtTextarea
value={this.state.productDescript} value={this.state.productDescript}
onChange={this.productDescriptChange.bind(this)} onChange={this.productDescriptChange.bind(this)}
maxlength='200' maxlength='200'
placeholder='你的产品简介' placeholder='你的产品简介'
/> />
</View> </View>
</View> </View>
<View className='button-box' > <View className='button-box' >
<View className='button' > <View className='button' >
<Button size='mini' className='button-orange' onClick={this.onClickUploadGoods.bind(this)}>发布</Button> <Button size='mini' className='button-orange' onClick={this.publishButtonHandler.bind(this)}>发布</Button>
</View> </View>
{/* <View className='button'> {/* <View className='button'>
<Button type='primary' className='button-a' size='small' >发布并新增</Button> <Button type='primary' className='button-a' size='small' >发布并新增</Button>
</View> */} </View> */}
<View className='button' onClick={this.publishAndNewButton.bind(this)}>
<Button size='mini' className='button-green'>发布并新增</Button>
</View>
<View className='button' onClick={this.goToMyGoodListPage.bind(this)}> <View className='button' onClick={this.goToMyGoodListPage.bind(this)}>
<Button size='mini' className='button-green'>商品列表</Button> <Button size='mini' className='button-green'>商品列表</Button>
</View> </View>

View File

@ -77,17 +77,11 @@ $themeColor:#FF7142;
flex-wrap: nowrap; flex-wrap: nowrap;
flex-direction: row; flex-direction: row;
margin: 40px 0 0; margin: 40px 0 0;
padding: 0 120px; justify-content: space-around;
.button{ .button{
flex:1;
text-align: center; text-align: center;
.at-button--primary{ .button-orange, .button-dark-red,.button-green{
background-color:$themeColor; font-size:27rpx;
border:1PX solid $themeColor;
}
.button-a{
background-color:#5cb85c;
border:1PX solid #5cb85c;
} }
} }
} }

View File

@ -10,7 +10,7 @@ import URL from '../../serviceAPI.config'
import './home.scss' import './home.scss'
let loadMorePageIndex = 1 // 底部加载接口请求参数
class Home extends Component { class Home extends Component {
config = { config = {
@ -20,7 +20,7 @@ class Home extends Component {
constructor() { constructor() {
super(...arguments); super(...arguments);
this.state = { this.state = {
shopsDetails: [], // 推荐店铺的信息 shops: [], // 推荐店铺的信息
ads: [], //广告图片数组 ads: [], //广告图片数组
categories: [],// 大类 categories: [],// 大类
subCate: [], //小类 subCate: [], //小类
@ -30,7 +30,8 @@ class Home extends Component {
grabOrderId: '',//抢到订单的id grabOrderId: '',//抢到订单的id
userName: '',//用户名字 userName: '',//用户名字
userPhone: '',// 用户电话 userPhone: '',// 用户电话
isShowTopNav: false, isShowTopNav: false,// 是否显示返回顶部按钮
loadMorePageIndex: 1,//下拉加载页面数
} }
} }
@ -103,7 +104,7 @@ class Home extends Component {
Taro.hideLoading() Taro.hideLoading()
if (res.data.err_msg === 'success') { if (res.data.err_msg === 'success') {
if (res.data.shops.length) { 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 { } else {
Taro.showToast({ Taro.showToast({
title: '没有更多了', title: '没有更多了',
@ -151,7 +152,7 @@ class Home extends Component {
Taro.hideLoading() Taro.hideLoading()
if (res.data.err_msg === 'success') { if (res.data.err_msg === 'success') {
this.setState({ shopsDetails: res.data.shops }) this.setState({ shops: res.data.shops })
Taro.hideLoading() Taro.hideLoading()
} else { } else {
@ -336,6 +337,7 @@ class Home extends Component {
} }
componentDidMount() { componentDidMount() {
// 页面加载后 得到首页的基本信息和推荐店铺的信息 // 页面加载后 得到首页的基本信息和推荐店铺的信息
console.log('地址', this.$router)
Taro.showLoading({ title: '加载中' }) Taro.showLoading({ title: '加载中' })
this.login().then(() => { this.login().then(() => {
@ -363,9 +365,9 @@ class Home extends Component {
} }
// 页面位置 // 页面位置
onPageScroll(location) { onPageScroll(location) {
if (location.scrollTop <= 300&&this.state.isShowTopNav) { if (location.scrollTop <= 300 && this.state.isShowTopNav) {
this.setState({ isShowTopNav: false }) this.setState({ isShowTopNav: false })
} else if(location.scrollTop >300&&!this.state.isShowTopNav) { } else if (location.scrollTop > 300 && !this.state.isShowTopNav) {
this.setState({ isShowTopNav: true }) this.setState({ isShowTopNav: true })
} }
} }
@ -374,10 +376,9 @@ class Home extends Component {
Taro.showLoading({ Taro.showLoading({
title: '加载中' title: '加载中'
}) })
setTimeout(() => { this.setState({ loadMorePageIndex: this.state.loadMorePageIndex + 1 }, () => {
loadMorePageIndex += 1 this.getShops({ curr_page: this.state.loadMorePageIndex })
this.getShops({ curr_page: loadMorePageIndex }) })
}, 1000);
} }
@ -385,7 +386,6 @@ class Home extends Component {
render() { render() {
// 提示模态弹窗element // 提示模态弹窗element
const modalMessageGrabElement = <AtModal isOpened={this.state.isOpen}> const modalMessageGrabElement = <AtModal isOpened={this.state.isOpen}>
<AtModalHeader>提示</AtModalHeader> <AtModalHeader>提示</AtModalHeader>
@ -413,7 +413,7 @@ class Home extends Component {
</View> </View>
</View> </View>
<View className='item-button-box' onClick={this.grabOrderId.bind(this, item.sd_id)}> <View className='item-button-box' onClick={this.grabOrderId.bind(this, item.sd_id)}>
<Button className='item-button' > {item.state_name === '在用' ? '抢单' : '已抢'}</Button> <Button className='item-button' > {item.state_name === '在用' ? '抢单' : '已抢'}</Button>
</View> </View>
</View> </View>
</SwiperItem > </SwiperItem >
@ -439,10 +439,14 @@ class Home extends Component {
<View>{item.class_name}</View> <View>{item.class_name}</View>
</View> </View>
}) : null }) : null
const shopCollectionElementsArray = this.state.shopsDetails.length ? this.state.shopsDetails.map((item, index) => { const shopCollectionElementsArray = this.state.shops.map((item, index) => {
return <FilteredShopComponent shop={item} userName={this.state.userName} userPhone={this.state.userPhone} key={index}></FilteredShopComponent> return <FilteredShopComponent
}) : null shop={item}
userName={this.state.userName}
userPhone={this.state.userPhone}
key={index}
></FilteredShopComponent>
})
const subCateElementsArray = this.state.subCate.length ? this.state.subCate.map((item, index) => { const subCateElementsArray = this.state.subCate.length ? this.state.subCate.map((item, index) => {
return <SwiperItem key={index} onClick={this.onClickChildCate.bind(this, item)}> return <SwiperItem key={index} onClick={this.onClickChildCate.bind(this, item)}>
<View className='text'>{item.class_name}</View> <View className='text'>{item.class_name}</View>
@ -476,7 +480,7 @@ class Home extends Component {
{/* 第二行图片滚动条 */} {/* 第二行图片滚动条 */}
<View className='second-banner'> <View className='second-banner'>
<Swiper <Swiper
style='height:180px;' style='height:100%;'
className='swipper' className='swipper'
indicatorColor='#999' indicatorColor='#999'
indicatorActiveColor='#333' indicatorActiveColor='#333'

View File

@ -125,6 +125,8 @@ $themeColor: #FF7142;
} }
.second-banner{ .second-banner{
height:26vh;
.categories{ .categories{
display: flex; display: flex;
flex-wrap: wrap; flex-wrap: wrap;

View File

@ -1,7 +1,7 @@
import Taro, { Component } from '@tarojs/taro' 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 { AtInput, AtImagePicker, AtTextarea, Picker, AtModal, AtModalHeader, AtModalContent, AtModalAction } from 'taro-ui'
import CopyrightComponent from '../../component/copyrightComponent/copyrightComponent' import CopyrightComponent from '../../component/copyrightComponent/copyrightComponent'
import URL from '../../serviceAPI.config' import URL from '../../serviceAPI.config'
@ -14,7 +14,7 @@ import './myDemandSupplyEdit.scss'
class MyDemandSupplyEdit extends Component { class MyDemandSupplyEdit extends Component {
config = { config = {
navigationBarTitleText: '我的供求编辑' navigationBarTitleText: '供求编辑'
} }
constructor() { constructor() {
super(...arguments) super(...arguments)
@ -32,6 +32,10 @@ class MyDemandSupplyEdit extends Component {
ImagesInfo: [],// 后台传回来的图片信息 ImagesInfo: [],// 后台传回来的图片信息
isFormCompleted: false, isFormCompleted: false,
isConfirmWindow: false,// 删除提示框
demandSupplyId: '',// 供求id
isSave: false,//是否点击保存按钮
isSaveAndNew: false//是否点击保存新增按钮
} }
@ -57,6 +61,7 @@ class MyDemandSupplyEdit extends Component {
const selectedState = this.state.demandingSupplyState.filter(item => item.id == res.data.sdInfo.state)[0] const selectedState = this.state.demandingSupplyState.filter(item => item.id == res.data.sdInfo.state)[0]
const imageFile = res.data.sdInfo.file_path.map(item => { return { url: URL.Base + item.file_path } }) const imageFile = res.data.sdInfo.file_path.map(item => { return { url: URL.Base + item.file_path } })
this.setState({ this.setState({
demandSupplyId: res.data.sdInfo.sd_id,
demandingSupplyCateSelected: selectedType, demandingSupplyCateSelected: selectedType,
title: res.data.sdInfo.sd_title, title: res.data.sdInfo.sd_title,
contactName: res.data.sdInfo.user_name, 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 上传供求 的api
uploadDemSup({ sd_type = this.state.demandingSupplyCateSelected.id, uploadDemSup({ sd_type = this.state.demandingSupplyCateSelected.id,
@ -150,19 +127,25 @@ class MyDemandSupplyEdit extends Component {
}) })
.then(res => { .then(res => {
console.log('上传供求', res) console.log('上传供求', res)
Taro.hideLoading()
if (res.data.err_msg === 'success') { if (res.data.err_msg === 'success') {
Taro.showToast({ Taro.showToast({
title: '上传成功', title: '保存成功',
icon: 'success', icon: 'success',
duration: 1500 duration: 1000
}).then(() => { }).then(() => {
setTimeout(() => { setTimeout(() => {
if (this.state.isSave) {
Taro.navigateTo({ Taro.navigateTo({
url: '/pages/mySupplyDemand/mySupplyDemand' url: '/pages/myDemandSupplyEdit/myDemandSupplyEdit?sdId=' + res.data.sd_id
}) })
}, 1500); } else if (this.state.isSaveAndNew) {
Taro.navigateTo({
url: '/pages/supplyDemandPublish/supplyDemandPublish'
})
}
}, 1000);
}) })
} else { } else {
Taro.showToast({ Taro.showToast({
title: res.data.err_msg, 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 => { demandingSupplyCate = e => {
this.setState({ this.setState({
@ -248,11 +275,59 @@ class MyDemandSupplyEdit extends Component {
contentChange(event) { contentChange(event) {
this.setState({ content: event.target.value }) 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() { goToMyDemSupPage() {
Taro.navigateTo({ Taro.navigateTo({
url: '/pages/mySupplyDemand/mySupplyDemand' 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() { componentDidMount() {
@ -271,10 +346,18 @@ class MyDemandSupplyEdit extends Component {
componentDidHide() { } componentDidHide() { }
render() { render() {
// 提示模态弹窗element
const modalMessageConfirmElement = <AtModal isOpened={this.state.isConfirmWindow}>
<AtModalHeader>提示</AtModalHeader>
<AtModalContent>
确认删除{this.state.demandSupplyItemName}
</AtModalContent>
<AtModalAction> <Button onClick={this.handleWindowModCancel.bind(this)}>取消</Button> <Button className='orange' onClick={this.handleWindowConfirm.bind(this)}></Button> </AtModalAction>
</AtModal>
return ( return (
<View className='supply-demand'> <View className='supply-demand'>
{modalMessageConfirmElement}
<View className='page-section'> <View className='page-section'>
<View> <View>
@ -310,16 +393,18 @@ class MyDemandSupplyEdit extends Component {
onChange={this.contactNameChange.bind(this)} onChange={this.contactNameChange.bind(this)}
/> />
</View> </View>
<View className='input-box'> <View className='input-box' style='padding:24rpx 0;font-size:32rpx'>
<Text className='require'>*</Text> <View className='title' style='font-weight:bold;'>
<AtInput <Text style='color:red'>*</Text>
name='value' <Text>联系电话</Text>
title='联系电话:' </View>
<View style='margin-left:5%;'>
<Input name='value'
maxLength='11'
type='number' type='number'
value={this.state.contactNumber} value={this.state.contactNumber}
border={false} onInput={this.handleInputCsultName.bind(this)}
onChange={this.contactNumberChange.bind(this)} /></View>
/>
</View> </View>
<View className='demanding-box'> <View className='demanding-box'>
<View className='title-box'> <View className='title-box'>
@ -377,9 +462,12 @@ class MyDemandSupplyEdit extends Component {
</View> </View>
<View className='button-box'> <View className='button-box'>
<View className='button' onClick={this.uploadSupplyDemand.bind(this)}> <View className='button' onClick={this.saveButtonHandler.bind(this)}>
<Button size='mini' className='button-orange'>保存</Button> <Button size='mini' className='button-orange'>保存</Button>
</View> </View>
<View className='button' onClick={this.saveAndNewButton.bind(this)}>
<Button size='mini' className='button-green'>保存并新增</Button>
</View>
{/* <View className='button'> {/* <View className='button'>
<Button className='button-a' size='mini' className='button-orange'>保存并新增</Button> <Button className='button-a' size='mini' className='button-orange'>保存并新增</Button>
@ -387,6 +475,9 @@ class MyDemandSupplyEdit extends Component {
<View className='button' onClick={this.goToMyDemSupPage.bind(this)}> <View className='button' onClick={this.goToMyDemSupPage.bind(this)}>
<Button size='mini' className='button-green'>我的供求</Button> <Button size='mini' className='button-green'>我的供求</Button>
</View> </View>
<View className='button' onClick={this.deleteButtonHandler.bind(this)}>
<Button size='mini' className='button-dark-red'>删除</Button>
</View>
</View> </View>
<CopyrightComponent></CopyrightComponent> <CopyrightComponent></CopyrightComponent>

View File

@ -26,17 +26,11 @@ $themeColor:#FF7142;
flex-wrap: nowrap; flex-wrap: nowrap;
flex-direction: row; flex-direction: row;
margin: 40px 0 0; margin: 40px 0 0;
padding: 0 120px; justify-content: space-around;
.button{ .button{
flex:1;
text-align: center; text-align: center;
.at-button--primary{ .button-orange,.button-green,.button-dark-red{
background-color:$themeColor,; font-size: 27rpx
border:1PX solid $themeColor,;
}
.button-a{
background-color:#5cb85c;
border:1PX solid #5cb85c;
} }
} }
} }

View File

@ -2,12 +2,14 @@ import Taro, { Component } from '@tarojs/taro'
import { View, Radio, Button } from '@tarojs/components' import { View, Radio, Button } from '@tarojs/components'
import { AtInput, Text, AtIcon, Picker, Image, 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 CopyrightComponent from '../../component/copyrightComponent/copyrightComponent'
import ScrollToTopComponent from '../../component/scrollToTopComponent/scrollToTopComponent'
import URL from '../../serviceAPI.config' import URL from '../../serviceAPI.config'
import './myGoodList.scss' import './myGoodList.scss'
let loadMorePageIndex = 1 // 底部加载接口请求参数
class MyGoodList extends Component { class MyGoodList extends Component {
config = { config = {
navigationBarTitleText: '商品列表' navigationBarTitleText: '商品列表'
@ -33,19 +35,17 @@ class MyGoodList extends Component {
}, // 正反排序 }, // 正反排序
selectedFilterValue: 0, // selectedFilterValue: 0, //
myGoodList: [],// 保存后台返回的商品列表 myGoodList: [],// 保存后台返回的商品列表
myGoodListTotal: 0,// 后台的商品总数 myGoodListTotal: '0',// 后台的商品总数
currentPage: 1,
goodsStateParam: 1,//商品状态参数 goodsStateParam: 1,//商品状态参数
pageCountParam: 2,// 商品数量参数 pageCountParam: 10,// 商品数量参数
currPageParam: 1,// 当前页面 参数 currPageParam: 1,// 当前页面 参数
isCheckAll: false,// 是否checked isCheckAll: false,// 是否checked
goodsIdList: [],//商品Id 列表 goodsIdList: [],//商品Id 列表
isOpenDeleteModal: false,// 是否显示删除模态框 isOpenDeleteModal: false,// 是否显示删除模态框
isOpenOffStockModal: false,// 是否显示下架模态框 isOpenOffStockModal: false,// 是否显示下架模态框
isAddToList: false,// 是否下拉加载 如果是 就添加商品到我的商品列表 isAddToList: false,// 是否下拉加载 如果是 就添加商品到我的商品列表
isShowTopNav: false,// 是否显示返回顶部按钮
loadMorePageIndex: 1,//上拉加载页面数
} }
} }
@ -106,57 +106,7 @@ class MyGoodList extends Component {
} }
// 获取我的商品列表接口api // 获取我的商品列表接口api
getMyGoodListApi({ goodsState = this.state.goodsStateParam, pageCount = this.state.pageCountParam, currPage = this.state.currPageParam }) { getMyGoodListApi({
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({
goodsName = this.state.productName, goodsName = this.state.productName,
goodsSn = '', goodsSn = '',
goodsClass = this.state.productCateSelected.id, goodsClass = this.state.productCateSelected.id,
@ -168,12 +118,12 @@ class MyGoodList extends Component {
goodsState = this.state.goodsStateParam, goodsState = this.state.goodsStateParam,
pageCount = this.state.pageCountParam, pageCount = this.state.pageCountParam,
currPage = this.state.currPageParam, currPage = this.state.currPageParam,
order = '', }) { order = '',
}) {
Taro.request({ Taro.request({
url: URL.MyGoodList, url: URL.MyGoodList,
method: 'POST', method: 'POST',
dataType: 'json', dataType: 'json',
data: { data: {
goodsName: goodsName, goodsName: goodsName,
goodsSn: goodsSn, goodsSn: goodsSn,
@ -197,21 +147,94 @@ class MyGoodList extends Component {
if (res.statusCode === 200) { if (res.statusCode === 200) {
console.log('我的商品列表', JSON.parse(res.data)) console.log('我的商品列表', JSON.parse(res.data))
const data = JSON.parse(res.data) const data = JSON.parse(res.data)
const goodCount = Number(data.goodsCount)
this.setState({
myGoodList: data.goods,
myGoodListTotal: goodCount
})
Taro.hideLoading() 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 { } else {
console.log('我的商品列表获取失败') 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 // 商品列表下架API
changeGoodState({ goodsState = 0, goodsID = this.state.goodsIdList }) { changeGoodState({ goodsState = 0, goodsID = this.state.goodsIdList }) {
@ -306,8 +329,8 @@ class MyGoodList extends Component {
Taro.showLoading({ Taro.showLoading({
title: '加载中', title: '加载中',
}) })
this.setState({ currentPage: 1, isCheckAll: false }, () => { this.setState({ currPageParam: 1, isCheckAll: false,loadMorePageIndex:1 }, () => {
this.getGoodListResultApi({}) this.getMyGoodListApi({})
}) })
} }
@ -315,6 +338,9 @@ class MyGoodList extends Component {
// 清空搜索 // 清空搜索
emptyButtonHanlder() { emptyButtonHanlder() {
this.setState({ this.setState({
isCheckAll: false,
loadMorePageIndex:1,
currPageParam: 1,
productName: '', productName: '',
lowestPrice: '', lowestPrice: '',
heightestPrice: '', heightestPrice: '',
@ -323,10 +349,7 @@ class MyGoodList extends Component {
productId: '', productId: '',
productCateSelected: { id: '', name: '全部类目' }, productCateSelected: { id: '', name: '全部类目' },
}, () => { }, () => {
this.setState({ isCheckAll: false, currentPage: 1 }, () => {
this.getMyGoodListApi({}) this.getMyGoodListApi({})
})
Taro.showToast({ Taro.showToast({
title: '已清空', title: '已清空',
icon: 'success', icon: 'success',
@ -340,7 +363,7 @@ class MyGoodList extends Component {
this.setState({ selectedFilterValue: value }) this.setState({ selectedFilterValue: value })
if (value == 0) { if (value == 0) {
this.setState({ this.setState({
currentPage: 1, currPageParam: 1,
filterOptions: { filterOptions: {
filterPrice: !this.state.filterOptions.filterPrice, filterPrice: !this.state.filterOptions.filterPrice,
filterStock: false, 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) { if (value == 1) {
this.setState({ this.setState({
currentPage: 1, currPageParam: 1,
filterOptions: { filterOptions: {
filterPrice: false, filterPrice: false,
filterStock: !this.state.filterOptions.filterStock, filterStock: !this.state.filterOptions.filterStock,
@ -362,13 +385,13 @@ class MyGoodList extends Component {
filterPublishDate: false, 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) { if (value == 2) {
this.setState({ this.setState({
currentPage: 1, currPageParam: 1,
filterOptions: { filterOptions: {
filterPrice: false, filterPrice: false,
filterStock: 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) { if (value == 3) {
this.setState({ this.setState({
currentPage: 1, currPageParam: 1,
filterOptions: { filterOptions: {
filterPrice: false, filterPrice: false,
filterStock: 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() { checkAllHandler() {
if (this.state.myGoodList.length) { if (this.state.myGoodList.length) {
@ -536,6 +553,9 @@ class MyGoodList extends Component {
} }
componentDidMount() { componentDidMount() {
Taro.showLoading({
title: '加载中'
})
this.getMyGoodListApi({}) this.getMyGoodListApi({})
this.getBaoBeiCateList() this.getBaoBeiCateList()
} }
@ -548,16 +568,21 @@ class MyGoodList extends Component {
componentDidShow() { } componentDidShow() { }
componentDidHide() { } 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() { onReachBottom() {
Taro.showLoading({ Taro.showLoading({
title: '加载中' title: '加载中'
}) })
this.setState({ isAddToList: true, loadMorePageIndex: this.state.loadMorePageIndex + 1 }, () => {
loadMorePageIndex += 1 this.getMyGoodListApi({ currPage: this.state.loadMorePageIndex })
this.setState({ isAddToList: true }, () => {
this.getMyGoodListApi({ currPage: loadMorePageIndex })
}) })
@ -565,13 +590,15 @@ class MyGoodList extends Component {
render() { render() {
//等待接口数据 //等待接口数据
const goodListElementArray = this.state.myGoodList.map((item, index) => { const goodListElementArray = this.state.myGoodList.map((item, index) => {
return <View key={index} className='good-container'> return <View key={index} className='good-container'>
<View className='good-container-a'> <View className='good-container-a'>
<Radio className='radio' value={item.goods_id} checked={item.checked} onClick={this.handleCheckChange.bind(this, item.goods_id)} ></Radio> <Radio className='radio' value={item.goods_id} checked={item.checked} onClick={this.handleCheckChange.bind(this, item.goods_id)} ></Radio>
<View className='img-box' onClick={this.goToGoodspage.bind(this, item.goods_id)}> <View className='img-box' onClick={this.goToGoodspage.bind(this, item.goods_id)}>
<Image mode='aspectFit' className='img' style='height:50px;width:50px' src={URL.Base + item.goods_url} /> {/* <Image mode='aspectFit' className='img' style='height:50px;width:50px' src={URL.Base + item.goods_url} /> */}
<Image className='img' style='height:100%;width:100%' src={URL.Base + item.goods_url} />
</View> </View>
<View className='name-box' onClick={this.goToGoodspage.bind(this, item.goods_id)} >{item.goods_name}</View> <View className='name-box' onClick={this.goToGoodspage.bind(this, item.goods_id)} >{item.goods_name}</View>
<View className='price-box'>{item.goods_price}</View> <View className='price-box'>{item.goods_price}</View>
@ -711,10 +738,9 @@ class MyGoodList extends Component {
<Button className='button-dark-red' size='mini'> <Button className='button-dark-red' size='mini'>
<AtIcon value='trash' size='12' color='white'></AtIcon> <AtIcon value='trash' size='12' color='white'></AtIcon>
清空</Button> 清空条件</Button>
</View> </View>
</View> </View>
<View className='text'> <View className='text'>
<Text>出售中的宝贝{this.state.myGoodListTotal}条记录</Text> <Text>出售中的宝贝{this.state.myGoodListTotal}条记录</Text>
</View> </View>
@ -740,6 +766,7 @@ class MyGoodList extends Component {
<View className='mygoodlist-container'> <View className='mygoodlist-container'>
{goodListElementArray} {goodListElementArray}
</View > </View >
{this.state.isShowTopNav ? <ScrollToTopComponent ></ScrollToTopComponent> : null}
<CopyrightComponent></CopyrightComponent> <CopyrightComponent></CopyrightComponent>
</View> </View>

View File

@ -1,4 +1,7 @@
$themeColor:#FF7142; $themeColor:#FF7142;
.button-orange, .button-dark-red,.button-green{
font-size:28rpx;
}
.MyGoodList{ .MyGoodList{
padding: 10px 20px; padding: 10px 20px;
.filterbar-container{ .filterbar-container{
@ -52,6 +55,9 @@ $themeColor:#FF7142;
.button{ .button{
margin-left:2%; margin-left:2%;
text-align: center; text-align: center;
.button-dark-red,.button-blue{
font-size: 28rpx;
}
} }
} }
@ -101,18 +107,11 @@ $themeColor:#FF7142;
flex-wrap: nowrap; flex-wrap: nowrap;
flex-direction: row; flex-direction: row;
margin: 40px 0; margin: 40px 0;
padding: 0 120px;
.button{ .button{
flex:1; flex:1;
text-align: center; text-align: center;
.at-button--primary{ .button-orange, .button-dark-red,.button-green{
background-color:$themeColor; font-size:28rpx;
border:1PX solid $themeColor;
}
.button-a{
background-color:#5cb85c;
border:1PX solid #5cb85c;
} }
} }
} }
@ -142,21 +141,24 @@ $themeColor:#FF7142;
flex-direction: row; flex-direction: row;
font-size: 30px; font-size: 30px;
height: 200px; height: 200px;
line-height: 200px;
text-align: center; text-align: center;
color:#717592; color:#717592;
align-items:center;
.radio{ .radio{
margin-left: 10px; margin-left: 10px;
} }
.img-box{ .img-box{
flex:1; flex:1;
.img{ height:80%;
margin-top: 35%; width:100%;
} margin: 0 2%;
} }
.name-box{ .name-box{
flex:1; flex:2;
color: #0579c6 color: #0579c6
} }

View File

@ -6,8 +6,6 @@ import ShopTypeInteractionComp from '../../component/shopTypeInteractionComp/sho
import CopyrightComponent from '../../component/copyrightComponent/copyrightComponent' import CopyrightComponent from '../../component/copyrightComponent/copyrightComponent'
import URL from '../../serviceAPI.config' import URL from '../../serviceAPI.config'
import './myGoodsEdit.scss' import './myGoodsEdit.scss'
class MyGoodsEdit extends Component { class MyGoodsEdit extends Component {
@ -27,6 +25,8 @@ class MyGoodsEdit extends Component {
ImagesInfo: [],// 后台传回来的图片信息 ImagesInfo: [],// 后台传回来的图片信息
goodsTypeParam: '',//商品分类参数 goodsTypeParam: '',//商品分类参数
goodId: '',//商品id goodId: '',//商品id
isSaveButton: false,//是否点击了保存按钮
isSaveAndNewBUtton: false,// 是否点击了保存新增按钮
} }
} }
//获取商品信息api GetProductInfo //获取商品信息api GetProductInfo
@ -172,12 +172,20 @@ class MyGoodsEdit extends Component {
title: '保存成功', title: '保存成功',
icon: 'success', icon: 'success',
duration: 1000 duration: 1000
}) }).then(() => {
setTimeout(() => { setTimeout(() => {
if (this.state.isSaveButton) {
Taro.navigateTo({ Taro.navigateTo({
url: '/pages/goods/goods?id=' + this.$router.params.id url: '/pages/myGoodsEdit/myGoodsEdit?id=' + this.$router.params.id
}) })
} else if (this.state.isSaveAndNewBUtton) {
Taro.navigateTo({
url: '/pages/goodsPublish/goodsPublish'
})
}
}, 1000); }, 1000);
})
console.log('上传商品', res) console.log('上传商品', res)
} }
) )
@ -269,12 +277,18 @@ class MyGoodsEdit extends Component {
} }
} }
shopCategoryChanged(e) {
this.setState({
onClickUploadGoods() { 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) { if (this.state.productName && this.state.productPrice && this.state.productUnit && this.state.ImagesInfo.length && this.state.shopTypeSelected.id) {
Taro.showLoading({ title: '保存中' }).then(() => { Taro.showLoading({ title: '保存中' }).then(() => {
setTimeout(() => { this.setState({ isSaveButton: true }, () => {
this.uploadGoods({ this.uploadGoods({
goods_name: this.state.productName, goods_name: this.state.productName,
goods_price: this.state.productPrice, goods_price: this.state.productPrice,
@ -284,7 +298,8 @@ class MyGoodsEdit extends Component {
class_id: this.state.goodsTypeParam, class_id: this.state.goodsTypeParam,
goods_id: this.state.goodId, goods_id: this.state.goodId,
}) })
}, 1000);
})
}) })
} else { } else {
Taro.showToast({ Taro.showToast({
@ -295,11 +310,37 @@ class MyGoodsEdit extends Component {
} }
} }
shopCategoryChanged(e) { // 保存并新增按钮
this.setState({ saveAndNewButton() {
shopCategoryCheckedPicker: this.state.shopCategoryList[e.detail.value] if (this.state.productName && this.state.productPrice && this.state.productUnit && this.state.ImagesInfo.length && this.state.shopTypeSelected.id) {
}, () => { Taro.showLoading({ title: '保存中' }).then(() => {
console.log(this.state.shopCategoryCheckedPicker) 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() { goToMyGoodListPage() {
@ -406,18 +447,25 @@ class MyGoodsEdit extends Component {
/> />
</View> </View>
</View>
<View className='button-box' > <View className='button-box' >
<View className='button' > <View className='button' >
<Button size='mini' className='button-orange' onClick={this.onClickUploadGoods.bind(this)}>保存</Button> <Button size='mini' className='button-orange' onClick={this.saveButtonHandler.bind(this)}>保存</Button>
</View> </View>
{/* <View className='button'> {/* <View className='button'>
<Button className='button-a' size='mini' >发布并新增</Button> <Button className='button-a' size='mini' >发布并新增</Button>
</View> */} </View> */}
<View className='button' onClick={this.saveAndNewButton.bind(this)}>
<Button className='button-green' size='mini'>保存并新增</Button>
</View>
<View className='button' onClick={this.goToGoodsDetailPage.bind(this)}>
<Button className='button-green' size='mini'>商品详情</Button>
</View>
<View className='button' onClick={this.goToMyGoodListPage.bind(this)}> <View className='button' onClick={this.goToMyGoodListPage.bind(this)}>
<Button className='button-green' size='mini'>商品列表</Button> <Button className='button-green' size='mini'>商品列表</Button>
</View> </View>
</View> </View>
</View>
<CopyrightComponent></CopyrightComponent> <CopyrightComponent></CopyrightComponent>

View File

@ -77,17 +77,11 @@ $themeColor:#FF7142;
flex-wrap: nowrap; flex-wrap: nowrap;
flex-direction: row; flex-direction: row;
margin: 40px 0 0; margin: 40px 0 0;
padding: 0 120px; justify-content: space-around;
.button{ .button{
flex:1;
text-align: center; text-align: center;
.at-button--primary{ .button-orange,.button-green{
background-color:$themeColor; font-size: 27rpx
border:1PX solid $themeColor;
}
.button-a{
background-color:#5cb85c;
border:1PX solid #5cb85c;
} }
} }
} }

View File

@ -3,14 +3,13 @@ import Taro, { Component } from '@tarojs/taro'
import { View, Text, Button } from '@tarojs/components' import { View, Text, Button } from '@tarojs/components'
import { AtInput, Picker, AtIcon, AtModal, AtModalHeader, AtModalContent, AtModalAction } from 'taro-ui' import { AtInput, Picker, AtIcon, AtModal, AtModalHeader, AtModalContent, AtModalAction } from 'taro-ui'
import URL from '../../serviceAPI.config' import URL from '../../serviceAPI.config'
import ScrollToTopComponent from '../../component/scrollToTopComponent/scrollToTopComponent'
import InteractionComponent from '../../component/interactionComponent/interactionComponent' import InteractionComponent from '../../component/interactionComponent/interactionComponent'
import CopyrightComponent from '../../component/copyrightComponent/copyrightComponent' import CopyrightComponent from '../../component/copyrightComponent/copyrightComponent'
import './myNeeds.scss' import './myNeeds.scss'
let loadMorePageIndex = 1 // 底部加载接口请求参数
class MyNeeds extends Component { class MyNeeds extends Component {
@ -38,23 +37,24 @@ class MyNeeds extends Component {
totalNeeds: 0,// 我的需求数量 totalNeeds: 0,// 我的需求数量
currentPage: 1, currentPage: 1,
needsItem: '',// 确认框提示时 使用的供求名 needsItem: '',// 确认框提示时 使用的供求名
isDeleteModal:false, isDeleteModal:false,// 删除提示框
isAddToList: false,// 请求需求的时候是否添加到旧列表里 isAddToList: false,// 请求需求的时候是否添加到旧列表里
isShowTopNav: false,// 是否显示返回顶部按钮
loadMorePageIndex:1,// 上拉加载页面数
} }
} }
//请求我的需求列表 api GetMyNeedsList //请求我的需求列表 api GetMyNeedsList
getMyNeedsList({ curr_page = 1, getMyNeedsList({
page_count = 10, curr_page = this.state.currentPage,
sd_type = '4', page_count = this.state.pageCount,
sd_title = '', sd_type = this.state.needsTypeSelected.id,
update_dateL = '', sd_title = this.state.title,
update_dateU = '', update_dateL = this.state.startDateSel,
class_id = '', update_dateU = this.state.endDateSel,
state = '' class_id = this.state.industryTypeSelected.id,
state = this.state.needsStateSelected.id
}) { }) {
//由于后台返回的问题, 所有当state为空的时候不传state反之传state //由于后台返回的问题, 所有当state为空的时候不传state反之传state
const param=state?{param: JSON.stringify({ const param=state?{param: JSON.stringify({
@ -99,6 +99,7 @@ class MyNeeds extends Component {
}) })
}else{ }else{
this.setState({isAddToList:false})
this.setState({ this.setState({
allNeedsList: res.data.supplys || [], allNeedsList: res.data.supplys || [],
totalNeeds: Number(res.data.count) totalNeeds: Number(res.data.count)
@ -108,6 +109,7 @@ class MyNeeds extends Component {
}else{ }else{
this.setState({isAddToList:false})
Taro.showToast({ Taro.showToast({
title: '没有更多了', title: '没有更多了',
icon: 'none' icon: 'none'
@ -167,7 +169,7 @@ class MyNeeds extends Component {
// 搜索按钮 // 搜索按钮
onSearchButtonHandler() { onSearchButtonHandler() {
Taro.showLoading({ title: '加载中' }).then(() => { Taro.showLoading({ title: '加载中' }).then(() => {
setTimeout(() => { this.setState({ currentPage: 1,loadMorePageIndex:1 },()=>{
this.getMyNeedsList({ this.getMyNeedsList({
curr_page: this.state.currentPage, curr_page: this.state.currentPage,
page_count: this.state.pageCount, page_count: this.state.pageCount,
@ -178,8 +180,11 @@ class MyNeeds extends Component {
class_id: this.state.industryTypeSelected.id==='-1'?'':this.state.industryTypeSelected.id, class_id: this.state.industryTypeSelected.id==='-1'?'':this.state.industryTypeSelected.id,
state: this.state.needsStateSelected.id state: this.state.needsStateSelected.id
}) })
this.setState({ currentPage: 1 })
}, 1000); })
}) })
@ -192,12 +197,17 @@ class MyNeeds extends Component {
} }
//清空筛选项 //清空筛选项
emptyFilter(){ emptyFilter(){
this.setState({ this.setState({
title:'', title:'',
endDateSel:'', endDateSel:'',
startDateSel:'', startDateSel:'',
industryTypeSelected: { name: '全部', id: '' },
needsTypeSelected: { name: '业主需求', id: '4' },
needsStateSelected: { name: '全部', id: '' },
currentPage:1,
loadMorePageIndex:1,
},()=>{
this.getMyNeedsList({})
}) })
Taro.showToast({ Taro.showToast({
title:'已清空', title:'已清空',
@ -257,6 +267,9 @@ class MyNeeds extends Component {
componentDidMount() { componentDidMount() {
Taro.showLoading({
title:'加载中'
})
this.getMyNeedsList({}) this.getMyNeedsList({})
} }
@ -270,14 +283,22 @@ class MyNeeds extends Component {
componentDidHide() { } 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() { onReachBottom() {
Taro.showLoading({ Taro.showLoading({
title: '加载中' title: '加载中'
}) })
loadMorePageIndex += 1
this.setState({ isAddToList: true }, () => { this.setState({ isAddToList: true,loadMorePageIndex:this.state.loadMorePageIndex+1 }, () => {
this.getMyNeedsList({ curr_page: loadMorePageIndex }) this.getMyNeedsList({ curr_page: this.state.loadMorePageIndex })
}) })
} }
@ -314,7 +335,7 @@ class MyNeeds extends Component {
<View className='button' onClick={this.goToMyNeedsEditPage.bind(this, item.sd_id)}> <View className='button' onClick={this.goToMyNeedsEditPage.bind(this, item.sd_id)}>
<Button size='mini' className='button-orange button-no-margin'>编辑</Button> <Button size='mini' className='button-orange button-no-margin'>编辑</Button>
</View> </View>
<View className='button-a' onClick={this.deleteButton.bind(this, item)}> <View className='button' onClick={this.deleteButton.bind(this, item)}>
<Button size='mini' className='button-dark-red button-no-margin' >删除</Button> <Button size='mini' className='button-dark-red button-no-margin' >删除</Button>
</View> </View>
</View > : <View className='info-button-box'> </View > : <View className='info-button-box'>
@ -422,12 +443,11 @@ class MyNeeds extends Component {
<Text className='count'>{this.state.totalNeeds}</Text> <Text className='count'>{this.state.totalNeeds}</Text>
</View> </View>
{/* 我的需求信息 */} {/* 我的需求信息 */}
{this.state.totalNeeds != "0" ? <View className='info-box'> { <View className='info-box'>
{myNeedsListArrayElement} {myNeedsListArrayElement}
</View> : <View className='nomore' > </View>}
没有更多了....
</View >}
{this.state.isShowTopNav ? <ScrollToTopComponent ></ScrollToTopComponent> : null}
<CopyrightComponent ></CopyrightComponent> <CopyrightComponent ></CopyrightComponent>

View File

@ -1,4 +1,7 @@
$themeColor:#FF7142; $themeColor:#FF7142;
.button-orange, .button-dark-red,.button-green{
font-size:28rpx;
}
.myNeeds{ .myNeeds{
padding: 10px 20px; padding: 10px 20px;
font-size: 32rpx; font-size: 32rpx;
@ -83,15 +86,15 @@ $themeColor:#FF7142;
flex-wrap: nowrap; flex-wrap: nowrap;
flex-direction: row; flex-direction: row;
margin: 40px 0; margin: 40px 0;
padding: 0 120px; justify-content:space-around;
.button{ .button{
flex:1;
text-align: center; 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{ .pagination-box{
@ -107,6 +110,7 @@ $themeColor:#FF7142;
box-shadow: 0 8px 8px #ddd; box-shadow: 0 8px 8px #ddd;
padding: 10px; padding: 10px;
font-size: 25rpx; font-size: 25rpx;
padding-bottom:0px;
.box{ .box{
margin-top: 10px; margin-top: 10px;
@ -129,6 +133,9 @@ $themeColor:#FF7142;
// flex:1; // flex:1;
text-align: right; text-align: right;
margin:0 1% 0; margin:0 1% 0;
.button-orange,.button-green,.button-dark-red{
font-size: 27rpx
}
} }
} }

View File

@ -1,17 +1,13 @@
import Taro, { Component } from '@tarojs/taro' 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 { AtInput, AtImagePicker, AtTextarea, Picker, AtModal, AtModalHeader, AtModalContent, AtModalAction } from 'taro-ui'
import InteractionComponent from '../../component/interactionComponent/interactionComponent' import InteractionComponent from '../../component/interactionComponent/interactionComponent'
import CopyrightComponent from '../../component/copyrightComponent/copyrightComponent' import CopyrightComponent from '../../component/copyrightComponent/copyrightComponent'
import URL from '../../serviceAPI.config' import URL from '../../serviceAPI.config'
import './myNeedsEdit.scss' import './myNeedsEdit.scss'
class MyNeedsEdit extends Component { class MyNeedsEdit extends Component {
config = { config = {
@ -37,6 +33,11 @@ class MyNeedsEdit extends Component {
content: '',//描述 content: '',//描述
pickerImageUrl: [], pickerImageUrl: [],
ImagesInfo: '', ImagesInfo: '',
isDeleteModal: false,// 删除提示框
isSave: false,//是否点击保存按钮
isSaveAndNew: false,//是否点击保存新增按钮
} }
} }
//获取需求信息api //获取需求信息api
@ -76,9 +77,9 @@ class MyNeedsEdit extends Component {
break break
} }
} }
if(!Object.keys(industryType).length){ if (!Object.keys(industryType).length) {
industryType.name = '全部' industryType.name = '全部'
industryType.id ='' industryType.id = '-1'
} }
@ -95,8 +96,8 @@ class MyNeedsEdit extends Component {
industryTypeSelected: industryType, industryTypeSelected: industryType,
needsTypeSelected: needsType, needsTypeSelected: needsType,
title: res.data.sdInfo.sd_title, title: res.data.sdInfo.sd_title,
contactName:res.data.sdInfo.user_name, contactName: res.data.sdInfo.user_name,
contactNumber:res.data.sdInfo.user_phone, contactNumber: res.data.sdInfo.user_phone,
contactAddress: res.data.sdInfo.user_address, contactAddress: res.data.sdInfo.user_address,
content: res.data.sdInfo.sd_desc, content: res.data.sdInfo.sd_desc,
needsStateSelected: needsState, 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 上传需求 的api
uploadMyNeedsApi() { uploadMyNeedsApi() {
@ -169,17 +155,25 @@ class MyNeedsEdit extends Component {
}) })
.then(res => { .then(res => {
console.log('上传需求', res) console.log('上传需求', res)
Taro.hideLoading()
if (res.data.err_msg === 'success') { if (res.data.err_msg === 'success') {
Taro.showToast({ Taro.showToast({
title: '保存成功', title: '保存成功',
icon: 'success', icon: 'success',
duration: 1500 duration: 1500
}).then(() => { }).then(() => {
// setTimeout(() => { setTimeout(() => {
// Taro.navigateTo({ if (this.state.isSave) {
// // url: '/pages/mySupplyDemand/mySupplyDemand' Taro.navigateTo({
// }) url: '/pages/myNeedsEdit/myNeedsEdit?id=' + this.state.sd_id
// }, 1500); })
} else if (this.state.isSaveAndNew) {
Taro.navigateTo({
url: '/pages/myNeedsPublish/myNeedsPublish'
})
}
}, 1500);
}) })
} else { } 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 => { needsTypeChange = e => {
this.setState({ this.setState({
@ -272,6 +306,61 @@ class MyNeedsEdit extends Component {
url: '/pages/myNeeds/myNeeds' 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) { getDataFromChild(value) {
console.log('从子组件传回来的值', value) console.log('从子组件传回来的值', value)
@ -295,10 +384,17 @@ class MyNeedsEdit extends Component {
componentDidHide() { } componentDidHide() { }
render() { render() {
const deleteModalWindowElement = <AtModal isOpened={this.state.isDeleteModal}>
<AtModalHeader>提示</AtModalHeader>
<AtModalContent>
确认删除{this.state.needsItem.sd_title}
</AtModalContent>
<AtModalAction> <Button onClick={this.handleWindowModCancel.bind(this)}>取消</Button> <Button className='orange' onClick={this.handleWindowConfirm.bind(this)}></Button> </AtModalAction>
</AtModal>
return ( return (
<View className='supply-demand'> <View className='supply-demand'>
{deleteModalWindowElement}
{/* 行业分类 */} {/* 行业分类 */}
<InteractionComponent url={URL.GetIndustryTypeList} onPassDataToChild={this.getDataFromChild.bind(this)} selectedValue={this.state.industryTypeSelected} ></InteractionComponent> <InteractionComponent url={URL.GetIndustryTypeList} onPassDataToChild={this.getDataFromChild.bind(this)} selectedValue={this.state.industryTypeSelected} ></InteractionComponent>
@ -338,17 +434,20 @@ class MyNeedsEdit extends Component {
onChange={this.contactNameChange.bind(this)} onChange={this.contactNameChange.bind(this)}
/> />
</View> </View>
<View className='input-box'> <View className='input-box' style='padding:24rpx 0;font-size:32rpx'>
<Text className='require'>*</Text> <View className='title' style='font-weight:bold;'>
<AtInput <Text style='color:red'>*</Text>
name='value' <Text>联系电话</Text>
title='联系电话:' </View>
<View style='margin-left:5%;'>
<Input name='value'
maxLength='11'
type='number' type='number'
value={this.state.contactNumber} value={this.state.contactNumber}
border={false} onInput={this.contactNumberChange.bind(this)}
onChange={this.contactNumberChange.bind(this)} /></View>
/>
</View> </View>
<View className='demanding-box'> <View className='demanding-box'>
<View className='title-box'> <View className='title-box'>
<Text className='title'>联系地址:</Text> <Text className='title'>联系地址:</Text>
@ -405,16 +504,18 @@ class MyNeedsEdit extends Component {
</View> </View>
<View className='button-box'> <View className='button-box'>
<View className='button' onClick={this.uploadMyNeedsButton.bind(this)}> <View className='button' onClick={this.saveButtonHandler.bind(this)}>
<Button size='mini' className='button-orange'>保存</Button> <Button size='mini' className='button-orange'>保存</Button>
</View> </View>
{/* <View className='button'> <View className='button' onClick={this.saveAndNewButton.bind(this)}>
<Button size='mini' className='button-green'>保存并新增</Button>
<Button className='button-a' size='mini'>保存并新增</Button> </View>
</View> */}
<View className='button' onClick={this.goToMyNeedsPage.bind(this)}> <View className='button' onClick={this.goToMyNeedsPage.bind(this)}>
<Button className='button-green' size='mini'>我的需求</Button> <Button className='button-green' size='mini'>我的需求</Button>
</View> </View>
<View className='button' onClick={this.deleteButtonHandler.bind(this)}>
<Button className='button-dark-red' size='mini'>删除</Button>
</View>
</View> </View>
<CopyrightComponent></CopyrightComponent> <CopyrightComponent></CopyrightComponent>

View File

@ -26,21 +26,15 @@ $themeColor:#FF7142;
flex-wrap: nowrap; flex-wrap: nowrap;
flex-direction: row; flex-direction: row;
margin: 40px 0 0; margin: 40px 0 0;
padding: 0 120px; justify-content: space-around;
.button{ .button{
flex:1;
text-align: center; text-align: center;
.at-button--primary{ .button-orange,.button-green,.button-dark-red{
background-color:$themeColor,; font-size: 27rpx
border:1PX solid $themeColor,;
}
.button-a{
background-color:#5cb85c;
border:1PX solid #5cb85c;
} }
} }
} }
} }
.title-box{ .title-box{

View File

@ -1,6 +1,6 @@
import Taro, { Component } from '@tarojs/taro' 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 { AtInput, AtImagePicker, AtTextarea, Picker } from 'taro-ui'
import CopyrightComponent from '../../component/copyrightComponent/copyrightComponent' import CopyrightComponent from '../../component/copyrightComponent/copyrightComponent'
@ -32,6 +32,8 @@ class MyNeedsPublish extends Component {
content: '', content: '',
pickerImageUrl: [], // 上传的图片 pickerImageUrl: [], // 上传的图片
ImagesInfo: [],// 后台传回来的图片信息 ImagesInfo: [],// 后台传回来的图片信息
isPublish: false,//是否点击发布按钮
isPublishAndNew: false,//是否点击发布新增按钮
@ -39,24 +41,7 @@ class MyNeedsPublish extends Component {
} }
// 上传需求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 // uploadMyNeeds 上传供求 的api
@ -101,14 +86,21 @@ class MyNeedsPublish extends Component {
console.log('上传需求', res) console.log('上传需求', res)
if (res.data.err_msg === 'success') { if (res.data.err_msg === 'success') {
Taro.showToast({ Taro.showToast({
title: '上传成功', title: '发布成功',
icon: 'success', icon: 'success',
duration: 1500 duration: 1500
}).then(() => { }).then(() => {
setTimeout(() => { setTimeout(() => {
if (this.state.isPublish) {
Taro.navigateTo({ Taro.navigateTo({
url: '/pages/myNeeds/myNeeds' url: '/pages/myNeedsEdit/myNeedsEdit?id=' + res.data.sd_id
}) })
} else if (this.state.isPublishAndNew) {
Taro.navigateTo({
url: '/pages/myNeedsPublish/myNeedsPublish'
})
}
}, 1500); }, 1500);
}) })
@ -200,6 +192,53 @@ class MyNeedsPublish extends Component {
} }
contentChange(event) { contentChange(event) {
this.setState({ content: event.target.value }) 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() { goToMyNeedsPage() {
Taro.navigateTo({ Taro.navigateTo({
@ -272,17 +311,20 @@ class MyNeedsPublish extends Component {
onChange={this.contactNameChange.bind(this)} onChange={this.contactNameChange.bind(this)}
/> />
</View> </View>
<View className='input-box'> <View className='input-box' style='padding:24rpx 0;font-size:32rpx'>
<Text className='require'>*</Text> <View className='title' style='font-weight:bold;'>
<AtInput <Text style='color:red'>*</Text>
name='value' <Text>联系电话</Text>
title='联系电话:' </View>
<View style='margin-left:5%;'>
<Input name='value'
maxLength='11'
type='number' type='number'
value={this.state.contactNumber} value={this.state.contactNumber}
border={false} onInput={this.contactNumberChange.bind(this)}
onChange={this.contactNumberChange.bind(this)} /></View>
/>
</View> </View>
<View className='demanding-box'> <View className='demanding-box'>
<View className='title-box'> <View className='title-box'>
<Text className='title'>联系地址:</Text> <Text className='title'>联系地址:</Text>
@ -339,13 +381,13 @@ class MyNeedsPublish extends Component {
</View> </View>
<View className='button-box'> <View className='button-box'>
<View className='button' onClick={this.uploadMyNeedsButton.bind(this)}> <View className='button' onClick={this.publishButtonHandler.bind(this)}>
<Button size='mini'className='button-orange' >发布</Button> <Button size='mini' className='button-orange' >发布</Button>
</View> </View>
{/* <View className='button'>
<Button className='button-a' size='mini' >保存并新增</Button> <View className='button' onClick={this.publishAndNewButton.bind(this)}>
</View> */} <Button className='button-green' size='mini' >发布并新增</Button>
</View>
<View className='button' onClick={this.goToMyNeedsPage.bind(this)}> <View className='button' onClick={this.goToMyNeedsPage.bind(this)}>
<Button className='button-green' size='mini' >我的需求</Button> <Button className='button-green' size='mini' >我的需求</Button>
</View> </View>

View File

@ -26,17 +26,11 @@ $themeColor:#FF7142;
flex-wrap: nowrap; flex-wrap: nowrap;
flex-direction: row; flex-direction: row;
margin: 40px 0 0; margin: 40px 0 0;
padding: 0 120px; justify-content: space-around;
.button{ .button{
flex:1;
text-align: center; text-align: center;
.at-button--primary{ .button-orange,.button-green,.button-dark-red{
background-color:$themeColor,; font-size: 27rpx
border:1PX solid $themeColor,;
}
.button-a{
background-color:#5cb85c;
border:1PX solid #5cb85c;
} }
} }
} }

View File

@ -36,6 +36,7 @@ class SupplyDemandView extends Component {
content: '',//描述 content: '',//描述
pickerImageUrl: [], pickerImageUrl: [],
ImagesInfo: '', ImagesInfo: '',
isShowAllButtons:true// 是否显示所有按钮
} }
} }
//获取需求信息api //获取需求信息api
@ -58,6 +59,7 @@ class SupplyDemandView extends Component {
// const selectedType = this.state.demandingSupplyCate.filter(item => item.id == res.data.sdInfo.sd_type)[0] // 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] // const selectedState = this.state.needsState.filter(item => item.id == res.data.sdInfo.state)[0]
Taro.hideLoading() Taro.hideLoading()
if(res.data.err_msg==='success'){
let industryType = {} let industryType = {}
const classId = res.data.sdInfo.class_id const classId = res.data.sdInfo.class_id
for (let outter of res.data.supplyTree) { for (let outter of res.data.supplyTree) {
@ -101,6 +103,17 @@ class SupplyDemandView extends Component {
}) })
}else{
this.setState({
isShowAllButtons:false
})
Taro.showToast({
title:res.data.err_msg,
icon:'none'
})
}
} }
) )
@ -243,29 +256,40 @@ class SupplyDemandView extends Component {
</View>:null </View>:null
} }
<View className='button-box'> {this.state.isShowAllButtons? <View className='button-box'>
<View className='button' onClick={this.goMyNeedsPublishPage.bind(this)}> <View className='button' onClick={this.goMyNeedsPublishPage.bind(this)}>
<Button size='mini' className='button-green'> <Button size='mini' className='button-green'>
<AtIcon value='add' size='12' color='white'></AtIcon> <AtIcon value='add' size='12' color='white'></AtIcon>
新增</Button> 新增</Button>
</View> </View>
<View className='button' onClick={this.goToMyNeedsPage.bind(this)}> <View className='button' onClick={this.goToMyNeedsPage.bind(this)}>
<Button className='button' size='mini' className='button-green'> <Button size='mini' className='button-green'>
<AtIcon value='' size='12' color='white'></AtIcon> <AtIcon value='' size='12' color='white'></AtIcon>
我的需求</Button> 我的需求</Button>
</View> </View>
<View className='button' onClick={this.goMyNeedEditPage.bind(this)}> <View className='button' onClick={this.goMyNeedEditPage.bind(this)}>
<Button className='button' size='mini' className='button-orange'> <Button size='mini' className='button-orange'>
<AtIcon value='settings' size='12' color='white'></AtIcon> <AtIcon value='settings' size='12' color='white'></AtIcon>
修改</Button> 修改</Button>
</View> </View>
<View className='button' onClick={this.deleteButton.bind(this)}> <View className='button' onClick={this.deleteButton.bind(this)}>
<Button className='button-a' size='mini' className='button-dark-red'> <Button size='mini' className='button-dark-red'>
<AtIcon value='close' size='12' color='white'></AtIcon> <AtIcon value='trash' size='12' color='white'></AtIcon>
删除</Button> 删除</Button>
</View> </View>
</View>:<View className='button-box'>
<View className='button' onClick={this.goMyNeedsPublishPage.bind(this)}>
<Button size='mini' className='button-green'>
<AtIcon value='add' size='12' color='white'></AtIcon>
新增</Button>
</View> </View>
<View className='button' onClick={this.goToMyNeedsPage.bind(this)}>
<Button size='mini' className='button-green'>
<AtIcon value='' size='12' color='white'></AtIcon>
我的需求</Button>
</View>
</View>}
<CopyrightComponent></CopyrightComponent> <CopyrightComponent></CopyrightComponent>
</View> </View>

View File

@ -16,23 +16,14 @@ $themeColor:#FF7142;
flex-wrap: nowrap; flex-wrap: nowrap;
flex-direction: row; flex-direction: row;
margin: 40px 0 0; margin: 40px 0 0;
padding: 0 20px; justify-content: space-around;
.button{ .button{
flex:1;
text-align: center; text-align: center;
.button-green{ .button-orange,.button-green,.button-dark-red{
font-size: 25rpx; font-size: 27rpx
}
.button-orange{
font-size: 25rpx;
}
.button-dark-red{
font-size: 25rpx;
} }
} }
} }

View File

@ -2,13 +2,13 @@ import Taro, { Component } from '@tarojs/taro'
import { View, Text, Button } from '@tarojs/components' import { View, Text, Button } from '@tarojs/components'
import { AtInput, Picker, AtIcon, AtModal, AtModalHeader, AtModalContent, AtModalAction } from 'taro-ui' import { AtInput, Picker, AtIcon, AtModal, AtModalHeader, AtModalContent, AtModalAction } from 'taro-ui'
import URL from '../../serviceAPI.config' import URL from '../../serviceAPI.config'
import ScrollToTopComponent from '../../component/scrollToTopComponent/scrollToTopComponent'
import CopyrightComponent from '../../component/copyrightComponent/copyrightComponent' import CopyrightComponent from '../../component/copyrightComponent/copyrightComponent'
import './mySupplyDemand.scss' import './mySupplyDemand.scss'
let loadMorePageIndex = 1 // 底部加载接口请求参数
class MySupplyDemand extends Component { class MySupplyDemand extends Component {
@ -30,65 +30,25 @@ class MySupplyDemand extends Component {
demandSupplyItemName: '',// 确认框提示时 使用的供求名 demandSupplyItemName: '',// 确认框提示时 使用的供求名
demandSupplyId: '',// 删除我的供求时的供求id demandSupplyId: '',// 删除我的供求时的供求id
totalDemandSupply: 0,//所有供求 totalDemandSupply: 0,//所有供求
currentPage: 1 //当前页数 currentPage: 1,//当前页数
isShowTopNav: false,// 是否显示返回顶部按钮
loadMorePageIndex: 1,//上拉加载页面数
} }
} }
//获取我的供求列表API //获取我的供求列表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({ Taro.request({
url: URL.MySupplyDemand, url: URL.MySupplyDemand,
method: 'POST', method: 'POST',
dataType: 'json', 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: { data: {
param: JSON.stringify({ param: JSON.stringify({
curr_page: curr_page, curr_page: curr_page,
@ -101,25 +61,54 @@ class MySupplyDemand extends Component {
}) })
}, },
header: { header: {
'content-type': 'application/x-www-form-urlencoded',
'Cookie': 'PFWSSS=' + Taro.getStorageSync('session_id'), 'Cookie': 'PFWSSS=' + Taro.getStorageSync('session_id'),
'content-type': 'application/x-www-form-urlencoded',
'X-Requested-With': 'XMLHttpRequest' 'X-Requested-With': 'XMLHttpRequest'
} }
}) }).then(res => {
.then(res => {
//this.setState({ grabOrderSuccess: res.data.err_msg,isGrabOrderSuccess: true })
console.log('我的供求搜索结果', res)
Taro.hideLoading() Taro.hideLoading()
this.setState({ allDemandSupply: res.data.supplys || [], totalDemandSupply: res.data.count }) 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() { onSearchButtonHandler() {
Taro.showLoading({ title: '加载中' }) Taro.showLoading({ title: '加载中' })
this.setState({ currentPage: 1 }, () => { this.setState({ loadMorePageIndex:1 }, () => {
this.searchDemandSupply({}) this.getMySupplyDemand({curr_page:this.state.loadMorePageIndex})
}) })
} }
@ -167,9 +156,6 @@ class MySupplyDemand extends Component {
}) })
}) })
} }
//搜索我的供求
// 新增我的供求 // 新增我的供求
addDemandSupply() { addDemandSupply() {
@ -186,6 +172,8 @@ class MySupplyDemand extends Component {
startDateSel: '', startDateSel: '',
demandSupplyCateSelected: { name: '全部', id: '' }, demandSupplyCateSelected: { name: '全部', id: '' },
demandSupplyStatesSelected: { name: '全部', id: '' }, demandSupplyStatesSelected: { name: '全部', id: '' },
}, () => {
this.getMySupplyDemand({})
}) })
Taro.showToast({ Taro.showToast({
title: '已清空', title: '已清空',
@ -257,15 +245,7 @@ class MySupplyDemand extends Component {
url: '/pages/supplyDemandView/supplyDemandView?sdId=' + sdId 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) { componentWillReceiveProps(nextProps) {
@ -282,15 +262,22 @@ class MySupplyDemand extends Component {
componentDidShow() { } componentDidShow() { }
componentDidHide() { } 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() { onReachBottom() {
Taro.showLoading({ Taro.showLoading({
title: '加载中' title: '加载中'
}) })
loadMorePageIndex += 1
this.setState({ isAddToList: true }, () => { this.setState({ isAddToList: true, loadMorePageIndex: this.state.loadMorePageIndex + 1 }, () => {
this.getMySupplyDemand({ curr_page: loadMorePageIndex }) this.getMySupplyDemand({ curr_page: this.state.loadMorePageIndex })
}) })
} }
@ -339,9 +326,10 @@ class MySupplyDemand extends Component {
<Text className='info'>{item.update_date}</Text> <Text className='info'>{item.update_date}</Text>
</View> </View>
<View className='info-button-box'> <View className='info-button-box'>
<View className='button' onClick={this.goSupplyDemandView.bind(this, item.sd_id)}>
{item.state === '0' ? null : <View className='button' onClick={this.goSupplyDemandView.bind(this, item.sd_id)}>
<Button size='mini' className='button-orange button-no-margin'>查看</Button> <Button size='mini' className='button-orange button-no-margin'>查看</Button>
</View> </View>}
<View className='button' onClick={this.goToMyDSEditPage.bind(this, item.sd_id)} > <View className='button' onClick={this.goToMyDSEditPage.bind(this, item.sd_id)} >
<Button size='mini' className='button-orange button-no-margin'>编辑</Button> <Button size='mini' className='button-orange button-no-margin'>编辑</Button>
</View> </View>
@ -429,12 +417,12 @@ class MySupplyDemand extends Component {
搜索</Button> 搜索</Button>
</View> </View>
<View className='button' onClick={this.addDemandSupply.bind(this)}> <View className='button' onClick={this.addDemandSupply.bind(this)}>
<Button className='button-a' size='mini' className='button-green'> <Button className=' button-green' size='mini'>
<AtIcon value='add' size='12' color='white'></AtIcon> <AtIcon value='add' size='12' color='white'></AtIcon>
新增</Button> 新增</Button>
</View> </View>
<View className='button' onClick={this.emptyFilter.bind(this)}> <View className='button' onClick={this.emptyFilter.bind(this)}>
<Button className='button-b' size='mini' className='button-dark-red'> <Button size='mini' className='button-dark-red'>
<AtIcon value='trash' size='12' color='white'></AtIcon> <AtIcon value='trash' size='12' color='white'></AtIcon>
清空</Button> 清空</Button>
</View> </View>
@ -445,9 +433,7 @@ class MySupplyDemand extends Component {
{demandSupplyElementArray} {demandSupplyElementArray}
</View> </View>
{this.state.isShowTopNav ? <ScrollToTopComponent ></ScrollToTopComponent> : null}
<CopyrightComponent></CopyrightComponent> <CopyrightComponent></CopyrightComponent>
</View> </View>

View File

@ -1,4 +1,7 @@
$themeColor:#FF7142; $themeColor:#FF7142;
.button-orange, .button-dark-red,.button-green{
font-size:28rpx;
}
.mySupplyDemand{ .mySupplyDemand{
padding: 10px 20px; padding: 10px 20px;
@ -74,18 +77,17 @@ $themeColor:#FF7142;
flex-wrap: nowrap; flex-wrap: nowrap;
flex-direction: row; flex-direction: row;
margin: 40px 0; margin: 40px 0;
padding: 0 120px;
.button{ .button{
flex:1; flex:1;
text-align: center; text-align: center;
.button-orange,.button-green,.button-dark-red{
font-size: 27rpx
}
}
}
.button-orange, .button-dark-red,.button-green{
font-size:28rpx;
}
} }
.info-box{ .info-box{
font-size: 25rpx; font-size: 25rpx;
@ -112,6 +114,9 @@ $themeColor:#FF7142;
// flex:1; // flex:1;
text-align: center; text-align: center;
margin:1% 1% 0; margin:1% 1% 0;
.button-orange,.button-green,.button-dark-red{
font-size: 27rpx
}
} }

View File

@ -1,15 +1,15 @@
import Taro, { Component } from '@tarojs/taro' 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 { AtTag, AtIcon, } from 'taro-ui'
import URL from '../../serviceAPI.config' import URL from '../../serviceAPI.config'
import ScrollToTopComponent from '../../component/scrollToTopComponent/scrollToTopComponent'
import './shop.scss' import './shop.scss'
import ShopItem from '../../component/shopItemComponent/shopItemComponent' import ShopItem from '../../component/shopItemComponent/shopItemComponent'
import BottomNav from '../../component/bottomNav/bottomNav' import BottomNav from '../../component/bottomNav/bottomNav'
import CopyrightComponent from '../../component/copyrightComponent/copyrightComponent' import CopyrightComponent from '../../component/copyrightComponent/copyrightComponent'
let loadMorePageIndex = 1 // 底部加载接口请求参数
class Shop extends Component { class Shop extends Component {
// 项目配置 // 项目配置
@ -53,6 +53,9 @@ class Shop extends Component {
widthType: [],// 侧边宽度类型 widthType: [],// 侧边宽度类型
checkedFilterIdList: [],//已选的筛选id checkedFilterIdList: [],//已选的筛选id
isAddToList: false,// 请求店铺商品的时候是否添加到旧列表里 isAddToList: false,// 请求店铺商品的时候是否添加到旧列表里
loadMorePageIndex:1,//上拉加载页面数
isShowTopNav: false,// 是否显示返回顶部按钮
// 下面是函数的默认参数 // 下面是函数的默认参数
curr_page: 1, curr_page: 1,
page_count: 10, page_count: 10,
@ -65,6 +68,8 @@ class Shop extends Component {
goodsSpec: [], goodsSpec: [],
goodsParam: [], goodsParam: [],
goodsParamExt: [], goodsParamExt: [],
longitude: '',
latitude: ''
} }
} }
@ -142,7 +147,13 @@ class Shop extends Component {
// console.log('数据',data.goods_type) // console.log('数据',data.goods_type)
let goodTypeArray = [] let goodTypeArray = []
Object.keys(data.goods_type).forEach(key => { 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 formatedFilterOptions.goodType = goodTypeArray
} }
@ -151,11 +162,15 @@ class Shop extends Component {
let goodsParamArray = [] let goodsParamArray = []
Object.keys(data.goodsParam).forEach(key => { Object.keys(data.goodsParam).forEach(key => {
if (data.goodsParam[key]) {
const value = data.goodsParam[key] const value = data.goodsParam[key]
const subArray = value.param_value.map(item => { const subArray = value.param_value.map(item => {
return { id: value.param_id, name: item, checked: false } return { id: value.param_id, name: item, checked: false }
}) })
goodsParamArray.push({ [value.param_name]: subArray }) goodsParamArray.push({ [value.param_name]: subArray })
}
}); });
formatedFilterOptions.otherType = goodsParamArray formatedFilterOptions.otherType = goodsParamArray
} }
@ -190,6 +205,7 @@ class Shop extends Component {
shop_class_id = this.state.shop_class_id, shop_class_id = this.state.shop_class_id,
order = this.state.order, order = this.state.order,
goods_class_id = this.state.goods_class_id, goods_class_id = this.state.goods_class_id,
currPage = '', // 不知道为什么筛选的时候要加 加这个参数为1
goodsSpec = this.state.goodsSpec, goodsSpec = this.state.goodsSpec,
goodsParam = this.state.goodsParam, goodsParam = this.state.goodsParam,
goodsParamExt = this.state.goodsParamExt }) { goodsParamExt = this.state.goodsParamExt }) {
@ -207,6 +223,7 @@ class Shop extends Component {
shop_class_id: shop_class_id, shop_class_id: shop_class_id,
order: order, order: order,
goods_class_id: goods_class_id, goods_class_id: goods_class_id,
currPage: currPage
}), }),
goodsRegion: JSON.stringify({}), goodsRegion: JSON.stringify({}),
goodsSpec: JSON.stringify(goodsSpec), goodsSpec: JSON.stringify(goodsSpec),
@ -264,7 +281,9 @@ class Shop extends Component {
shopAddress: res.data.data.shop_address, shopAddress: res.data.data.shop_address,
contactName: res.data.userRes.name, contactName: res.data.userRes.name,
contactNumber: res.data.userRes.phone, 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) // console.log(this.state.shopDescriptionData)
}) })
@ -318,7 +337,6 @@ class Shop extends Component {
this.setState({ selectedFilterValue: value }) this.setState({ selectedFilterValue: value })
if (value == 0) { if (value == 0) {
this.setState({ this.setState({
currentPage: 1,
filterOptions: { filterOptions: {
all: true, all: true,
amount: false, amount: false,
@ -328,11 +346,11 @@ class Shop extends Component {
} }
} }
) )
this.goodsSearch({}) this.goodsSearch({ currPage: 1 })
} }
if (value == 1) { if (value == 1) {
this.setState({ this.setState({
currentPage: 1,
filterOptions: { filterOptions: {
all: false, all: false,
amount: !this.state.filterOptions.amount, amount: !this.state.filterOptions.amount,
@ -341,13 +359,13 @@ class Shop extends Component {
popularity: false 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) { if (value == 2) {
this.setState({ this.setState({
currentPage: 1,
filterOptions: { filterOptions: {
all: false, all: false,
amount: false, amount: false,
@ -356,7 +374,7 @@ class Shop extends Component {
popularity: false 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) { if (value == 3) {
this.setState({ this.setState({
currentPage: 1,
filterOptions: { filterOptions: {
all: false, all: false,
amount: false, amount: false,
@ -373,7 +391,7 @@ class Shop extends Component {
popularity: false 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) { if (value == 4) {
this.setState({ this.setState({
currentPage: 1,
filterOptions: { filterOptions: {
all: false, all: false,
amount: false, amount: false,
@ -390,7 +408,7 @@ class Shop extends Component {
popularity: !this.state.filterOptions.popularity 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 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) // console.log(this.state.mainType)
}) })
} }
@ -509,7 +528,7 @@ class Shop extends Component {
config_id: 4, config_id: 4,
shop_class_id: '', shop_class_id: '',
order: '', order: '',
currPage: 1, curr_page: 1,
goods_class_id: '', goods_class_id: '',
goodsSpec: [], goodsSpec: [],
goodsParam: [], goodsParam: [],
@ -533,9 +552,7 @@ class Shop extends Component {
} }
componentDidMount() { componentDidMount() {
Taro.showLoading({ title: '加载中' }) Taro.showLoading({ title: '加载中' })
console.log('this.$router.params.id', this.$router.params.id)
//页面加载之后 得到指定店铺的商品 和 筛选标签 //页面加载之后 得到指定店铺的商品 和 筛选标签
this.goodsSearch({ shop_id: this.$router.params.id }) // 加载店铺商品 this.goodsSearch({ shop_id: this.$router.params.id }) // 加载店铺商品
this.getSearchParams({})// 加载筛选项 this.getSearchParams({})// 加载筛选项
@ -553,15 +570,21 @@ class Shop extends Component {
Taro.showLoading({ Taro.showLoading({
title: '加载中' title: '加载中'
}) })
loadMorePageIndex += 1
this.setState({ isAddToList: true }, () => { this.setState({ isAddToList: true,loadMorePageIndex:this.state.loadMorePageIndex }, () => {
this.goodsSearch({ curr_page: 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() { render() {
const ShopItemElementsArray = this.state.shopItem.length ? this.state.shopItem.map((item, index) => { const ShopItemElementsArray = this.state.shopItem.length ? this.state.shopItem.map((item, index) => {
return <View key={index} className='shop-item' > return <View key={index} className='shop-item' >
<ShopItem item={item}></ShopItem> <ShopItem item={item}></ShopItem>
@ -712,6 +735,20 @@ class Shop extends Component {
<View className='img-box'> <Image mode='aspectFit' src={URL.Base + 'Public/images/shop/bg_banner.png'} style='max-width: 100%;max-height:100%;' /></View> <View className='img-box'> <Image mode='aspectFit' src={URL.Base + 'Public/images/shop/bg_banner.png'} style='max-width: 100%;max-height:100%;' /></View>
<View className='img-box'> <Image mode='aspectFit' src={URL.Base + 'Public/images/shop/bg_banner.png'} style='max-width: 100%;max-height:100%;' /></View> <View className='img-box'> <Image mode='aspectFit' src={URL.Base + 'Public/images/shop/bg_banner.png'} style='max-width: 100%;max-height:100%;' /></View>
</View> </View>
<Map
id="map"
longitude={this.state.longitude}
latitude={this.state.latitude}
scale="14"
controls="{{controls}}"
bindcontroltap="controltap"
markers="{{markers}}"
bindmarkertap="markertap"
polyline="{{polyline}}"
bindregionchange="regionchange"
show-location
style="width: 100%; height: 300px;"
></Map>
</View> </View>
const shopAllCateElementArray = this.state.shopAllInnerCate.map((item, index) => { const shopAllCateElementArray = this.state.shopAllInnerCate.map((item, index) => {
@ -749,8 +786,11 @@ class Shop extends Component {
</View> </View>
{/* 显示店铺首页或者店铺详情 */} {/* 显示店铺首页或者店铺详情 */}
{this.state.showShopHomePage ? shopHomepageElement : shopDescriptionElement} {this.state.showShopHomePage ? shopHomepageElement : shopDescriptionElement}
{this.state.isShowTopNav ? <ScrollToTopComponent ></ScrollToTopComponent> : null}
<CopyrightComponent></CopyrightComponent> <CopyrightComponent></CopyrightComponent>
<View className='gap' style='height:150rpx'>
</View>
<View className='bottom-nav-box'> <View className='bottom-nav-box'>
<BottomNav otherData={{ menu: [{ name: '首页' }, { name: '分类' }, { name: '购物车' }, { name: '教程软件' }, { name: '更多' }] }} /> <BottomNav otherData={{ menu: [{ name: '首页' }, { name: '分类' }, { name: '购物车' }, { name: '教程软件' }, { name: '更多' }] }} />
</View> </View>

View File

@ -1,6 +1,6 @@
import Taro, { Component } from '@tarojs/taro' 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 { AtInput, AtImagePicker, AtTextarea, Picker } from 'taro-ui'
import CopyrightComponent from '../../component/copyrightComponent/copyrightComponent' import CopyrightComponent from '../../component/copyrightComponent/copyrightComponent'
@ -30,25 +30,12 @@ class SupplyDemand extends Component {
content: '', content: '',
pickerImageUrl: [], // 上传的图片 pickerImageUrl: [], // 上传的图片
ImagesInfo: [],// 后台传回来的图片信息 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 上传供求 的api
uploadDemSup({ sd_type = this.state.demandingSupplyCateSelected.id, uploadDemSup({ sd_type = this.state.demandingSupplyCateSelected.id,
@ -92,17 +79,26 @@ class SupplyDemand extends Component {
}) })
.then(res => { .then(res => {
console.log('上传供求', res) console.log('上传供求', res)
Taro.hideLoading()
if (res.data.err_msg === 'success') { if (res.data.err_msg === 'success') {
Taro.showToast({ Taro.showToast({
title: '上传成功', title: '上传成功',
icon: 'success', icon: 'success',
duration: 1500 duration: 1000
}).then(() => { }).then(() => {
setTimeout(() => { setTimeout(() => {
if (this.state.isPublish) {
Taro.navigateTo({ Taro.navigateTo({
url: '/pages/mySupplyDemand/mySupplyDemand' url: '/pages/myDemandSupplyEdit/myDemandSupplyEdit?sdId=' + res.data.sd_id
}) })
}, 1500);
} else if (this.state.isPublishAndNew) {
Taro.navigateTo({
url: '/pages/supplyDemandPublish/supplyDemandPublish'
})
}
}, 1000);
}) })
} else { } else {
Taro.showToast({ Taro.showToast({
@ -126,6 +122,9 @@ class SupplyDemand extends Component {
url: URL.UploadDSPorductImage, url: URL.UploadDSPorductImage,
filePath: files[files.length - 1].url, filePath: files[files.length - 1].url,
name: 'file', name: 'file',
formData: {
'key': 'michael',
},
header: { header: {
'content-type': 'multipart/form-data; boundary=----WebKitFormBoundaryAWxeadaAVmRVQCiz', 'content-type': 'multipart/form-data; boundary=----WebKitFormBoundaryAWxeadaAVmRVQCiz',
'Cookie': 'PFWSSS=' + Taro.getStorageSync('session_id'), 'Cookie': 'PFWSSS=' + Taro.getStorageSync('session_id'),
@ -151,8 +150,8 @@ class SupplyDemand extends Component {
this.state.ImagesInfo.splice(index, 1) // 删除显示的图片 this.state.ImagesInfo.splice(index, 1) // 删除显示的图片
this.state.pickerImageUrl.splice(index, 1)// 删除图片param this.state.pickerImageUrl.splice(index, 1)// 删除图片param
that.setState({ that.setState({
pockerImageUrl:this.state.pickerImageUrl, pockerImageUrl: this.state.pickerImageUrl,
ImagesInfo:this.state.ImagesInfo, ImagesInfo: this.state.ImagesInfo,
}) })
Taro.showToast({ Taro.showToast({
title: '删除成功', title: '删除成功',
@ -189,6 +188,40 @@ class SupplyDemand extends Component {
contentChange(event) { contentChange(event) {
this.setState({ content: event.target.value }) 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() { goToMyDemSupPage() {
Taro.navigateTo({ Taro.navigateTo({
url: '/pages/mySupplyDemand/mySupplyDemand' url: '/pages/mySupplyDemand/mySupplyDemand'
@ -249,17 +282,20 @@ class SupplyDemand extends Component {
border={false} border={false}
/> />
</View> </View>
<View className='input-box'> <View className='input-box' style='padding:24rpx 0;font-size:32rpx'>
<Text className='require'>*</Text> <View className='title' style='font-weight:bold;'>
<AtInput <Text style='color:red'>*</Text>
name='value' <Text>联系电话</Text>
title='联系电话:' </View>
<View style='margin-left:5%;'>
<Input name='value'
maxLength='11'
type='number' type='number'
value={this.state.contactNumber} value={this.state.contactNumber}
onChange={this.contactNumberChange.bind(this)} onInput={this.contactNumberChange.bind(this)}
border={false} /></View>
/>
</View> </View>
<View className='demanding-box'> <View className='demanding-box'>
<View className='title-box'> <View className='title-box'>
<Text className='title'>联系地址:</Text> <Text className='title'>联系地址:</Text>
@ -316,13 +352,12 @@ class SupplyDemand extends Component {
</View> </View>
<View className='button-box'> <View className='button-box'>
<View className='button' onClick={this.uploadSupplyDemand.bind(this)}> <View className='button' onClick={this.publishButtonHandler.bind(this)}>
<Button size='mini' className='button-orange' >发布</Button> <Button size='mini' className='button-orange' >发布</Button>
</View> </View>
{/* <View className='button'> <View className='button' onClick={this.publishAndNewButton.bind(this)}>
<Button size='mini' className='button-green' >发布并新增</Button>
<Button size='mini' className='button-a' >发布并新增</Button> </View>
</View> */}
<View className='button' onClick={this.goToMyDemSupPage.bind(this)}> <View className='button' onClick={this.goToMyDemSupPage.bind(this)}>
<Button size='mini' className='button-green' >我的供求</Button> <Button size='mini' className='button-green' >我的供求</Button>
</View> </View>

View File

@ -26,17 +26,11 @@ $themeColor:#FF7142;
flex-wrap: nowrap; flex-wrap: nowrap;
flex-direction: row; flex-direction: row;
margin: 40px 0 0; margin: 40px 0 0;
padding: 0 120px;
.button{ .button{
flex:1; flex:1;
text-align: center; text-align: center;
.at-button--primary{ .button-orange,.button-green{
background-color:$themeColor,; font-size: 28rpx;
border:1PX solid $themeColor,;
}
.button-a{
background-color:#5cb85c;
border:1PX solid #5cb85c;
} }
} }
} }

View File

@ -221,7 +221,7 @@ class SupplyDemandView extends Component {
<View className='button-box'> <View className='button-box'>
<View className='button' onClick={this.goToSDPublishPage.bind(this)}> <View className='button' onClick={this.goToSDPublishPage.bind(this)}>
<Button className='button-green' size='mini'> <Button className='button-orange' size='mini'>
<AtIcon value='add' size='12' color='white'></AtIcon> <AtIcon value='add' size='12' color='white'></AtIcon>
新增</Button> 新增</Button>
</View> </View>
@ -231,13 +231,13 @@ class SupplyDemandView extends Component {
修改</Button> 修改</Button>
</View> </View>
<View className='button' onClick={this.goToMySDPage.bind(this)}> <View className='button' onClick={this.goToMySDPage.bind(this)}>
<Button className='button-green' size='mini'> <Button className='button-orange' size='mini'>
<AtIcon value='' size='12' color='white'></AtIcon> <AtIcon value='' size='12' color='white'></AtIcon>
我的供求</Button> 我的供求</Button>
</View> </View>
<View className='button' onClick={this.deleteButton.bind(this)}> <View className='button' onClick={this.deleteButton.bind(this)}>
<Button className='button-dark-red' size='mini'> <Button className='button-dark-red' size='mini'>
<AtIcon value='close' size='12' color='white'></AtIcon> <AtIcon value='trash' size='12' color='white'></AtIcon>
删除</Button> 删除</Button>
</View> </View>
</View> </View>

View File

@ -19,25 +19,13 @@ $themeColor:#FF7142;
flex-wrap: nowrap; flex-wrap: nowrap;
flex-direction: row; flex-direction: row;
margin: 40px 0 0; margin: 40px 0 0;
padding: 0 20px;
.button{ .button{
flex:1; flex:1;
text-align: center; text-align: center;
// margin:2%;
// justify-content:center;
.at-button--primary{ .button-orange,.button-green,.button-dark-red{
background-color:$themeColor; font-size: 27rpx
border:1PX solid $themeColor;
}
.button-g{
background-color:#5cb85c;
border:1PX solid #5cb85c;
}
.button-a{
background-color:#d9534f;
border:1PX solid #d9534f;
} }
} }
} }

File diff suppressed because it is too large Load Diff