链接大部分api

This commit is contained in:
郑茂强 2018-12-29 17:15:59 +08:00
parent 6084030925
commit 8930358a6d
15 changed files with 679 additions and 437 deletions

View File

@ -29,6 +29,7 @@ class App extends Component {
'pages/allDemanding/allDemanding',// 所有供求页面
'pages/myGoodList/myGoodList',// 我的商品列表页面
'pages/myDemandSupplyEdit/myDemandSupplyEdit',// 我的供求编辑页面
'pages/supplyDemandView/supplyDemandView',// 查看单个供求页面
// 'pages/shopDescription/shopDescription',
],
window: {

View File

@ -1,6 +1,6 @@
import Taro, { Component } from '@tarojs/taro'
import { View, Button, Text, Image } from '@tarojs/components'
import { AtIcon, AtModal, AtModalHeader, AtModalContent, AtModalAction, AtInput, AtToast, AtNoticebar } from 'taro-ui'
import { AtIcon, AtModal, AtModalHeader, AtModalContent, AtModalAction, AtInput, AtNoticebar } from 'taro-ui'
import './filteredShopComponent.scss'
@ -23,11 +23,12 @@ class recommondShop extends Component {
isOpenVouhcer: false,
isOpenConsult: false,
consultTip: '',
isToast: false,
consultResponseMsg: '',
voucherResponseMsg: '',
voucherCanConsult: false,
voucherName:this.props.userName,
voucherPhone:this.props.userPhone,
consultName:this.props.userName,
consultPhone:this.props.userPhone,
}
}
goToShop(value) {
@ -91,7 +92,6 @@ class recommondShop extends Component {
}
// api 购买咨询 BuyConsult
buyConsult({ user = "杨夕兵", phone = "18950295811", shops = ["1306"], source_type = "2", source_level = 1, coupons_flag = 0 }) {
Taro.request({
url: URL.BuyConsult,
method: 'POST',
@ -112,25 +112,15 @@ class recommondShop extends Component {
}
})
.then(res => {
console.log('购买咨询请求', res)
if (res.err_code === 0 && res.err_msg === "success") {
this.setState({ consultResponseMsg: '成功' }, () => {
this.setState({ isToast: true })
})
// 延迟3秒 后将toast 关掉
setTimeout(() => {
this.setState({ isToast: false })
}, 3000);
console.log('购买咨询请求成功', res)
if (res.statusCode === 200) {
Taro.showToast({ title: res.data.err_msg,icon:'success' })
} else {
this.setState({ consultResponseMsg: res.data.err_msg }, () => {
this.setState({ isToast: true })
})
setTimeout(() => {
this.setState({ isToast: false })
}, 3000);
Taro.showToast({ title: res.data.err_msg,icon:'none' })
}
}).catch(err=>{
console.log('购买咨询请求失败', err)
})
}
@ -144,7 +134,7 @@ class recommondShop extends Component {
}
voucherModalConfirm() {
this.setState({ isOpenVouhcer: false })
this.buyConsult({})
this.buyConsult({user:this.state.voucherName,phone:this.state.voucherPhone})
}
// 咨询弹框。取消。确认
isOpenConsult() {
@ -156,9 +146,20 @@ class recommondShop extends Component {
}
consultModalConfirm() {
this.setState({ isOpenConsult: false })
this.buyConsult({})
this.buyConsult({user:this.state.consultName,phone:this.state.consultPhone})
}
handleInputVcherPhone(value){
this.setState({voucherPhone:value})
}
handleInputVcherName(value){
this.setState({voucherName:value})
}
handleInputCsultName(value){
this.setState({consultName:value})
}
handleInputCsultPhone(value){
this.setState({consultPhone:value})
}
componentWillReceiveProps(nextProps) {
@ -201,18 +202,20 @@ class recommondShop extends Component {
</AtNoticebar>
<View className='voucher-left'>当前优惠卷{voucherLeft}</View>
<AtInput
name='value'
title='联系人:'
type='text'
placeholder='123'
name='value'
title='联系人:'
type='text'
value={this.state.voucherName}
onChange={this.handleInputVcherName.bind(this)}
/>
<AtInput
border={false}
name='value'
title='联系电话:'
type='number'
placeholder='需求标题'
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}
@ -229,36 +232,30 @@ class recommondShop extends Component {
<AtInput
name='value'
title='联系人:'
type='text'
placeholder='123'
name='value'
title='联系人:'
type='text'
value={this.state.consultName}
onChange={this.handleInputCsultName.bind(this)}
/>
<AtInput
name='value'
title='联系电话:'
type='number'
placeholder='需求标题'
border={false}
name='value'
title='联系电话:'
type='number'
value={this.state.consultPhone}
border={false}
onChange={this.handleInputCsultPhone.bind(this)}
/>
</AtModalContent>
<AtModalAction> <Button onClick={this.consultModalClose.bind(this)} >取消</Button> <Button className='orange' onClick={this.consultModalConfirm.bind(this)}></Button> </AtModalAction>
</AtModal>
// 请提示元素
const toast = <AtToast
isOpened={this.state.isToast}
text={this.state.consultResponseMsg}
// iconSize={iconSize}
// iconType={iconType}
// iconColor={iconColor}
// isHiddenIcon={isHiddenIcon}
></AtToast>
return (
<View className='shop-list-box' >
{voucherModalElement}
{consultModalElement}
{toast}
<View className='header'>
<View className='title'>
<Image src={ads !== 0 ? hornIcon : houseIcon} style='width:12px; height:12px; vertical-align: middle;' />

View File

@ -1,6 +1,6 @@
import Taro, { Component } from '@tarojs/taro'
import { View, Text, Image,Button } from '@tarojs/components'
import { AtInput, AtButton, Picker, AtIcon, AtLoadMore, AtModal, AtToast,AtModalHeader ,AtModalContent ,AtModalAction } from 'taro-ui'
import { View, Text, Image, Button } from '@tarojs/components'
import { AtInput, AtButton, Picker, AtIcon, AtLoadMore, AtModal, AtToast, AtModalHeader, AtModalContent, AtModalAction } from 'taro-ui'
import CopyrightComponent from '../../component/copyrightComponent/copyrightComponent'
import URL from '../../serviceAPI.config'
@ -18,13 +18,14 @@ class AllDemanding extends Component {
super(...arguments)
this.state = {
supplys: [], // 需求列表
isMore: 'more', // 上拉加载状态
demandingState: ['全部', '在用', '已抢单', '已抢光'], // 供求状态选择
demandingStateSelected: '全部', // 当前供求状态
isMore: 'more', // 加载状态
demandingState: [{ name: '全部', id: '' }, { name: '在用', id: '1' }, { name: '已抢单', id: '2' }, { name: '已抢光', id: '3' },], // 供求状态选择
demandingStateSelected: { name: '全部', id: '' }, // 当前供求状态
industryCate: ['全部', '制定家具', '成品家具', '办公家具', '设计'], // 行业分类状态选择
industryCateSelected: '全部', // 当前行业分类状态
startDateSel: '2018-04-22',
endDateSel: '2018-04-22',
startDateSel: '',
endDateSel: '',
classId: '',
isOpenedGrabModal: false,
grabOrderId: '',//抢到订单的id
isGrabOrderSuccess: false,// 是否显示轻提示
@ -32,7 +33,15 @@ class AllDemanding extends Component {
}
}
GetAllDemanding({ curr_page = 1, page_count = 20 }) {
//加载更多业主需求函数
loadMoreDemanding(
{ curr_page = 1, page_count = 20,
state = this.state.demandingStateSelected.id,
update_dateL = this.state.startDateSel,
update_dateU = this.state.endDateSel,
class_id = this.state.classId
}
) {
Taro.request({
url: URL.GetAllDemanding,
method: 'POST',
@ -40,7 +49,11 @@ class AllDemanding extends Component {
data: {
param: JSON.stringify({
curr_page: curr_page,
page_count: page_count
page_count: page_count,
state: state,
update_dateL: update_dateL,
update_dateU: update_dateU,
class_id: class_id
}),
},
header: {
@ -50,21 +63,53 @@ class AllDemanding extends Component {
})
.then(res => {
if (res.data.supplys.length) {
const newSupplys = this.state.supplys.concat(res.data.supplys)
this.setState({ supplys: newSupplys, isMore: 'more' })
Taro.hideLoading()
this.setState({ supplys: this.state.supplys.concat(res.data.supplys), isMore: 'more' })
} else {
this.setState({ isMore: 'noMore' })
}
})
}
// 搜索业主需求函数
searchDemanding({ curr_page = 1, page_count = 20,
state = this.state.demandingStateSelected.id,
update_dateL = this.state.startDateSel,
update_dateU = this.state.endDateSel,
class_id = this.state.classId
}) {
Taro.request({
url: URL.GetAllDemanding,
method: 'POST',
dataType: 'json',
data: {
param: JSON.stringify({
curr_page: curr_page,
page_count: page_count,
state: state,
update_dateL: update_dateL,
update_dateU: update_dateU,
class_id: class_id
}),
},
header: {
'content-type': 'application/x-www-form-urlencoded',
'X-Requested-With': 'XMLHttpRequest'
}
})
.then(res => {
Taro.hideLoading()
this.setState({ supplys: res.data.supplys })
})
}
// 向上拉升延迟一秒加载数据
handleLoadMore() {
this.setState({ isMore: 'loading' })
setTimeout(() => {
currentPage += 1
this.GetAllDemanding({ curr_page: currentPage })
this.loadMoreDemanding({ curr_page: currentPage })
}, 1000);
}
// 改变需求选项
@ -83,7 +128,7 @@ class AllDemanding extends Component {
onStartDateChange = e => {
this.setState({
startDateSel: e.detail.value,
})
}
// 改变结束日期
@ -134,13 +179,26 @@ class AllDemanding extends Component {
this.GrabDemand({ demandId: this.state.grabOrderId })
}
searchHanlder() {
Taro.showLoading({ title: '加载中' }).then(() => {
setTimeout(() => {
this.searchDemanding({})
}, 1000);
})
}
componentWillReceiveProps(nextProps) {
console.log(this.props, nextProps)
}
componentDidMount() {
// 得到第一页需求数据
this.GetAllDemanding({})
Taro.showLoading({ title: '加载中' }).then(() => {
this.searchDemanding({})
})
}
@ -152,20 +210,20 @@ class AllDemanding extends Component {
render() {
// 提示模态弹窗element
const modalMessageGrabElement=<AtModal isOpened={this.state.isOpenedGrabModal}>
<AtModalHeader>提示</AtModalHeader>
<AtModalContent>
确认抢单
const modalMessageGrabElement = <AtModal isOpened={this.state.isOpenedGrabModal}>
<AtModalHeader>提示</AtModalHeader>
<AtModalContent>
确认抢单
</AtModalContent>
<AtModalAction> <Button onClick={this.handleGrabModalCancel.bind(this)}>取消</Button> <Button className='orange' onClick={this.handleGrabConfirm.bind(this)}></Button> </AtModalAction>
</AtModal>
<AtModalAction> <Button onClick={this.handleGrabModalCancel.bind(this)}>取消</Button> <Button className='orange' onClick={this.handleGrabConfirm.bind(this)}></Button> </AtModalAction>
</AtModal>
// 抢单返回轻提示
const grabOrderSuccessElement = <AtToast
isOpened={this.state.isGrabOrderSuccess}
text={this.state.grabOrderSuccess}
duration={2000}
isOpened={this.state.isGrabOrderSuccess}
text={this.state.grabOrderSuccess}
duration={2000}
></AtToast>
const allDemandingElementArray = this.state.supplys ? this.state.supplys.map((item, index) => {
return <View className='demanding-info' key={index}>
@ -207,26 +265,26 @@ class AllDemanding extends Component {
<View className='page-section'>
{/* 供求状态选择 */}
<View>
<Picker mode='selector' range={this.state.demandingState} onChange={this.changeDemandingState}>
<Picker mode='selector' rangeKey='name' range={this.state.demandingState} onChange={this.changeDemandingState}>
<View className='picker'>
<View className='title-box'>
<Text className='title'> <Text className='require'>*</Text>:</Text> <Text className='selected'>{this.state.demandingStateSelected}</Text>
<Text className='title'> <Text className='require'>*</Text>:</Text> <Text className='selected'>{this.state.demandingStateSelected.name}</Text>
</View>
</View>
</Picker>
</View>
</View>
<View className='input-box'>
<Text className='require'>*</Text>
<AtInput
name='value'
title='需求标题:'
type='text'
placeholder='需求标题'
value={this.state.value}
onChange={this.handleChange.bind(this)}
name='value'
title='需求标题:'
type='text'
placeholder='需求标题'
value={this.state.value}
onChange={this.handleChange.bind(this)}
/>
</View>
{/* 开始和结束日期选择 */}
@ -260,7 +318,7 @@ class AllDemanding extends Component {
</Picker>
</View>
</View>
<View className='button-box'>
<View className='button-box' onClick={this.searchHanlder.bind(this)}>
<View className='button'>
<AtButton type='primary' size='small'>
<AtIcon value='search' size='12' color='white'></AtIcon>
@ -272,10 +330,10 @@ class AllDemanding extends Component {
{allDemandingElementArray}
</View>
<AtLoadMore
onClick={this.handleLoadMore.bind(this)}
status={this.state.isMore}
loadingText='加载中'
noMoreText='没有更多了'
onClick={this.handleLoadMore.bind(this)}
status={this.state.isMore}
loadingText='加载中'
noMoreText='没有更多了'
/>
<CopyrightComponent></CopyrightComponent>
</View>

View File

@ -105,7 +105,10 @@ class GoodsPublish extends Component {
}
// 发布商品api
uploadGoods({ goods_name = "test2", goods_price = "1.00", goods_unit = "1", goods_profiles = "test2", class_id = "10103", shop_class_id = "1930" }) {
uploadGoods({ goods_name = "test2", goods_price = "1.00",
goods_unit = "1", goods_profiles = "test2",
class_id = "10103",
shop_class_id = "1930" }) {
// 上传图片的参数
const uploadProductGoodFileParams = []
@ -155,22 +158,26 @@ class GoodsPublish extends Component {
}
})
.then(res => {
this.setState({ uploadProductTextTip: '发布成功', isUploadProductSuccess: true }, () => {
setTimeout(() => {
this.setState({ isUploadProductSuccess: false })
Taro.navigateTo({
url: '/pages/goodsPublish/goodsPublish'
})
}, 2000)
Taro.hideLoading()
Taro.showToast({
title: '发布成功',
icon: 'success',
duration: 1000
})
setTimeout(() => {
Taro.navigateTo({
url: '/pages/goods/goods?id=5cf3Ptn5wKQdyPpwsSe2nDKnN4QDFdz8moPTf+QIOm788Q'// 虚拟地址
})
}, 1000);
console.log('上传商品', res)
}
)
.catch(error => {
this.setState({ uploadProductTextTip: '发布失败', isUploadProductSuccess: true }, () => {
setTimeout(() => {
this.setState({ isUploadProductSuccess: false })
}, 2000)
Taro.hideLoading()
Taro.showToast({
title: '保存失败',
icon: 'none',
duration: 1000
})
})
}
@ -247,10 +254,12 @@ class GoodsPublish extends Component {
const imagePath = URL.Base + data.file_path
const newPickerImageUrl = that.state.pickerImageUrl.concat({ url: imagePath })
const newImageInfo = that.state.ImagesInfo.concat(data)
that.setState({ pickerImageUrl: newPickerImageUrl, isUploadImageSuccess: true, uploadImageTextTip: '图片上传成功', ImagesInfo: newImageInfo }, () => {
setTimeout(() => {
that.setState({ isUploadImageSuccess: false })
}, 2000)
that.setState({ pickerImageUrl: newPickerImageUrl, ImagesInfo: newImageInfo }, () => {
Taro.showToast({
title: '上传成功',
icon: 'success',
duration: 2000
})
})
}
})
@ -258,10 +267,10 @@ class GoodsPublish extends Component {
if (operationType === 'remove') {
this.state.pickerImageUrl.splice(index, 1);
this.setState({ files: this.state.pickerImageUrl });
that.setState({ isUploadImageSuccess: true, uploadImageTextTip: '删除成功' }, () => {
setTimeout(() => {
that.setState({ isUploadImageSuccess: false })
}, 2000)
Taro.showToast({
title: '删除成功',
icon: 'success',
duration: 2000
})
}
}
@ -274,20 +283,21 @@ class GoodsPublish extends Component {
}
onClickUploadGoods() {
if (this.state.productName && this.state.productPrice && this.state.productUnit && this.state.ImagesInfo.length && this.state.shopCategoryCheckedPicker.id) {
this.uploadGoods({
goods_name: this.state.productName,
goods_price: this.state.productPrice,
goods_unit: this.state.productUnit,
goods_profiles: this.state.productDescript,
class_id: "10103",
shop_class_id: this.state.shopCategoryCheckedPicker,
})
} else {
this.setState({ uploadProductTextTip: '请填写完表格', isUploadProductSuccess: true }, () => {
Taro.showLoading({ title: '发布中' }).then(() => {
setTimeout(() => {
this.setState({ isUploadProductSuccess: false })
}, 2000)
})
this.uploadGoods({
goods_name: this.state.productName,
goods_price: this.state.productPrice,
goods_unit: this.state.productUnit,
goods_profiles: this.state.productDescript,
class_id: "10103",// to be continue
shop_class_id: this.state.shopCategoryCheckedPicker.id,
})
},1000)})
} else {
Taro.showToast({title:'请填写完表格',icon:'none'})
}
}
shopCategoryChanged(e) {
@ -444,20 +454,11 @@ class GoodsPublish extends Component {
}
render() {
const imageUploadSuccess = <AtToast
isOpened={this.state.isUploadImageSuccess}
text={this.state.uploadImageTextTip}
duration={2000}
></AtToast>
const productUploadSuccess = <AtToast
isOpened={this.state.isUploadProductSuccess}
text={this.state.uploadProductTextTip}
duration={2000}
></AtToast>
return (
<View className='goods-publish'>
{imageUploadSuccess}
{productUploadSuccess}
<View className='goods-category'>
<View className='page-section'>

View File

@ -1,11 +1,12 @@
import Taro, { Component } from '@tarojs/taro'
import { View, Button, Text, Swiper, SwiperItem, Image, } from '@tarojs/components'
import { AtModal, AtButton, AtToast,AtModalHeader ,AtModalContent,AtModalAction} from 'taro-ui'
import { AtModal, AtButton, AtToast, AtModalHeader, AtModalContent, AtModalAction, AtLoadMore } from 'taro-ui'
import FilteredShopComponent from '../../component/filteredShopComponent/filteredShopComponent'
import BottomNav from '../../component/bottomNav/bottomNav'
import URL from '../../serviceAPI.config'
import './home.scss'
let currentPage = 1
class Home extends Component {
config = {
@ -25,7 +26,10 @@ class Home extends Component {
grabOrderId: '',//抢到订单的id
isGrabOrderSuccess: false,// 是否显示轻提示
grabOrderSuccess: '',// 抢单成功返回字段
isMore: 'noMore',// 加载更多店铺
userName:'',//用户名字
userPhone:'',// 用户电话
}
}
@ -36,6 +40,9 @@ class Home extends Component {
getHomeCategoriesInfo() {
Taro.request({
url: URL.ShopWxStore,
header: {
'Cookie': 'PFWSSS=' + Taro.getStorageSync('session_id'),
}
})
.then(res => {
console.log('首页基本信息', res)
@ -43,41 +50,53 @@ class Home extends Component {
ads: res.data.data.adsLb,
categories: res.data.data.supplyClass,
demanding: res.data.data.demand.supplys,
otherData: res.data.otherData
otherData: res.data.otherData,
userName:res.data.otherData.userName,
userPhone:res.data.otherData.userPhone,
})
})
}
// api 得到推荐商店的信息
getShops(parent_supply_class = 0, supply_class = '-1', supply_level = 1) {
getShops({ parent_supply_class = 0, supply_class = '-1', supply_level = 1, curr_page = 1,
page_count = 20, action = "2" }) {
Taro.request({
url: URL.ShopSupplyShops,
method: 'POST',
dataType: 'json',
data: {
param: JSON.stringify({
curr_page: 1,
page_count: 20,
curr_page: curr_page,
page_count: page_count,
parent_supply_class: parent_supply_class, //父级class id
supply_class: supply_class,// 子级class id
supply_level: supply_level,// 层级
action: "2"
action: action
})
},
header: {
'content-type': 'application/x-www-form-urlencoded',
'Cookie': 'PFWSSS=' + Taro.getStorageSync('session_id'),
}
})
.then(res => {
console.log('所有店铺的信息', res)
Taro.hideLoading()
this.setState({ shopsDetails: res.data.shops }, () => {
})
if (res.data.shops.length) {
this.setState({ shopsDetails: this.state.shopsDetails.concat(res.data.shops), isMore: 'more' }, () => {
})
} else {
this.setState({ isMore: 'noMore' }, () => {
console.log('ismore?', this.state.isMore)
})
}
}
)
}
// 登入api
login() {
// 异步函数登入api
async login() {
Taro.login({
success(res) {
if (res.code) {
@ -102,7 +121,10 @@ class Home extends Component {
Taro.setStorageSync('userInfo', response.data.user_info)
}
)
).catch(err => {
console.log('登入微信失败', err)
})
}
else {
console.log('登录失败!' + res.errMsg)
@ -148,7 +170,7 @@ class Home extends Component {
}
})
.then(res => {
this.setState({ grabOrderSuccess: res.data.err_msg,isGrabOrderSuccess: true }, () => {
this.setState({ grabOrderSuccess: res.data.err_msg, isGrabOrderSuccess: true }, () => {
setTimeout(() => {
this.setState({ isGrabOrderSuccess: false })
}, 2000)
@ -160,12 +182,18 @@ class Home extends Component {
}
// 点击大类icon
onClickParentCate(item) {
const parentClass = item.parent_class_id
const childClass = item.class_id
this.setState({ subCate: item.children })
this.getShops(item.parent_class_id, item.class_id)
this.getShops({ parent_supply_class: parentClass, supply_class: childClass })
this.getShops({ parent_supply_class: parentClass, supply_class: childClass })
}
// 点击子类
onClickChildCate(item) {
this.getShops(item.parent_class_id, item.class_id, 2)
const parentClass = item.parent_class_id
const childClass = item.class_id
// this.getShops(item.parent_class_id, item.class_id, 2)
this.getShops({ parent_supply_class: parentClass, supply_class: childClass, supply_level: 2 })
}
// 转到其他页面
goToAllDemandingPage() {
@ -188,13 +216,23 @@ class Home extends Component {
// 确认抢单之后
this.GrabDemand({ demandId: this.state.grabOrderId })
}
// 向上拉升延迟一秒加载数据
handleLoadMore() {
this.setState({ isMore: 'loading' })
setTimeout(() => {
currentPage += 1
this.getShops({ curr_page: currentPage })
}, 1000);
}
componentDidMount() {
// 页面加载后 得到首页的基本信息和推荐店铺的信息
Taro.showLoading({ title: '加载中' })
this.getShops()
this.getHomeCategoriesInfo()
this.login()
this.login().then(() => {
this.getShops({})
this.getHomeCategoriesInfo()
}).catch(err => console.log('微信登入失败:', err))
}
@ -219,22 +257,22 @@ class Home extends Component {
render() {
// 提示模态弹窗element
const modalMessageGrabElement=<AtModal isOpened={this.state.isOpen}>
<AtModalHeader>提示</AtModalHeader>
<AtModalContent>
确认抢单
// 提示模态弹窗element
const modalMessageGrabElement = <AtModal isOpened={this.state.isOpen}>
<AtModalHeader>提示</AtModalHeader>
<AtModalContent>
确认抢单
</AtModalContent>
<AtModalAction> <Button onClick={this.handleGrabModalCancel.bind(this)}>取消</Button> <Button className='orange' onClick={this.handleGrabConfirm.bind(this)}></Button> </AtModalAction>
</AtModal>
<AtModalAction> <Button onClick={this.handleGrabModalCancel.bind(this)}>取消</Button> <Button className='orange' onClick={this.handleGrabConfirm.bind(this)}></Button> </AtModalAction>
</AtModal>
// 抢单返回轻提示
const grabOrderSuccessElement = <AtToast
isOpened={this.state.isGrabOrderSuccess}
text={this.state.grabOrderSuccess}
text={this.state.grabOrderSuccess}
duration={2000}
></AtToast>
@ -256,7 +294,7 @@ class Home extends Component {
业主{item.user_name}
</View>
<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>
</SwiperItem >
@ -282,7 +320,7 @@ class Home extends Component {
</View>
}) : null
const shopCollectionElementsArray = this.state.shopsDetails.length ? this.state.shopsDetails.map((item, index) => {
return <FilteredShopComponent shop={item} key={index}></FilteredShopComponent>
return <FilteredShopComponent shop={item} userName={this.state.userName} userPhone={this.state.userPhone} key={index}></FilteredShopComponent>
}) : null
const subCateElementsArray = this.state.subCate.length ? this.state.subCate.map((item, index) => {
@ -406,11 +444,14 @@ class Home extends Component {
<View className='shop-box'>
{shopCollectionElementsArray}
{this.state.shopsDetails.length !== 0 ? <View className='title'>
沒有更多了...
</View> :<View className='title' >
没有找到...
</View >}
<AtLoadMore
onClick={this.handleLoadMore.bind(this)}
status={this.state.isMore}
loadingText='加载中'
noMoreText='没有更多了'
/>
</View>
<View className='gap'>

View File

@ -30,9 +30,9 @@ class Index extends Component {
componentDidMount(){
Taro.navigateTo({
// url: '/pages/goodsPublish/goodsPublish'
url: '/pages/home/home'
//url: '/pages/goodsPublish/goodsPublish'
// url: '/pages/myDemandSupplyEdit/myDemandSupplyEdit'
// url: '/pages/home/home'
url: '/pages/mySupplyDemand/mySupplyDemand'
// url:'/pages/supplyDemandPublish/supplyDemandPublish'
})
}

View File

@ -1,6 +1,6 @@
import Taro, { Component } from '@tarojs/taro'
import { View, Radio, } from '@tarojs/components'
import { AtInput, Text, AtButton, AtIcon, Picker, Image, AtPagination,AtToast } from 'taro-ui'
import { View, Radio, } from '@tarojs/components'
import { AtInput, Text, AtButton, AtIcon, Picker, Image, AtPagination, AtToast } from 'taro-ui'
import CopyrightComponent from '../../component/copyrightComponent/copyrightComponent'
import URL from '../../serviceAPI.config'
@ -22,8 +22,8 @@ class MyGoodList extends Component {
minimumSold: '',
maximumSold: '',
productId: '',
productCate: ['全部类目', '衣柜', '人工服务', '开料机', '书柜', '橱柜', '更衣室'],
productCateSelected: '全部类目',
productCate: [], //宝贝类目
productCateSelected: { class_Id: '', class_name: '全部类目' },// 已选宝贝类目
filterBar: ['filterPrice', 'filterStock', 'filterSold', 'filterPublishDate',], //筛选选项
filterBarKeys: { filterPrice: '价格', filterStock: '库存', filterSold: '总销量', filterPublishDate: '发布时间' }, // 筛选选项对应值
filterOptions: {
@ -39,10 +39,10 @@ class MyGoodList extends Component {
goodsStateParam: 1,//商品状态参数
pageCountParam: 10,// 商品数量参数
currPageParam: 1,// 当前页面 参数
isCheckAll:false,// 是否checked
goodsIdList:[],//商品Id 列表
isToast:false,// 是否显示轻提示
toastText:''// 轻提示字段
isCheckAll: false,// 是否checked
goodsIdList: [],//商品Id 列表
isToast: false,// 是否显示轻提示
toastText: ''// 轻提示字段
}
@ -72,6 +72,28 @@ class MyGoodList extends Component {
productCateSelected: this.state.productCate[e.detail.value]
})
}
//获取宝贝类目搜索列表接口api
getBaoBeiCateList() {
Taro.request({
url: URL.BaoBeiCateList,
method: 'POST',
dataType: 'json',
header: {
'Cookie': 'PFWSSS=' + Taro.getStorageSync('session_id'),
'content-type': 'application/x-www-form-urlencoded',
'X-Requested-With': 'XMLHttpRequest'
}
}).then(res => {
console.log('baobei', res)
this.setState({ productCate: res.data.goodsClass })
}).catch(err => {
console.log('获取宝贝类目失败', err)
})
}
// 获取我的商品列表接口api
getMyGoodListApi({ goodsState = this.state.goodsStateParam, pageCount = this.state.pageCountParam, currPage = this.state.currPageParam }) {
Taro.request({
@ -91,10 +113,10 @@ class MyGoodList extends Component {
}
}).then(res => {
if (res.statusCode === 200) {
console.log('我的商品列表', JSON.parse(res.data))
console.log('我的商品列表', JSON.parse(res.data))
const data = JSON.parse(res.data)
data.goods.forEach(item => {
item.checked=false
item.checked = false
});
const goodCount = Number(data.goodsCount)
this.setState({
@ -111,7 +133,20 @@ class MyGoodList extends Component {
}
// 获取搜索结果api
getGoodListResultApi({ goodsName = this.state.productName, goodsSn = '', goodsClass = '', 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 = '', }) {
getGoodListResultApi({
goodsName = this.state.productName,
goodsSn = '',
goodsClass = this.state.productCateSelected.class_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',
@ -156,7 +191,7 @@ class MyGoodList extends Component {
}
// 商品列表下架API
changeGoodState({goodsState=0,goodsID= this.state.goodsIdList }) {
changeGoodState({ goodsState = 0, goodsID = this.state.goodsIdList }) {
Taro.request({
url: URL.ChangeGoodState,
method: 'POST',
@ -164,7 +199,7 @@ class MyGoodList extends Component {
data: {
goodsState: goodsState,
goodsID:JSON.stringify(goodsID)
goodsID: JSON.stringify(goodsID)
},
header: {
'Cookie': 'PFWSSS=' + Taro.getStorageSync('session_id'),
@ -173,15 +208,15 @@ class MyGoodList extends Component {
}
}).then(res => {
if (res.statusCode === 200) {
console.log('商品状态返回', res)
this.setState({isToast:true,toastText:'下架成功'},()=>{
console.log('商品状态返回', res)
this.setState({ isToast: true, toastText: '下架成功' }, () => {
setTimeout(() => {
this.setState({isToast:false})
this.setState({ isToast: false })
this.getMyGoodListApi({})// 从新获取商品列表数据
}, 2000);
})
} else {
console.log('我的商品列表获取失败')
}
@ -191,7 +226,7 @@ class MyGoodList extends Component {
}
// 商品列表删除api
deleteGood({goodsState=1,goodsID= this.state.goodsIdList }) {
deleteGood({ goodsState = 1, goodsID = this.state.goodsIdList }) {
Taro.request({
url: URL.DeleteGood,
method: 'POST',
@ -199,7 +234,7 @@ class MyGoodList extends Component {
data: {
goodsState: goodsState,
goodsID:JSON.stringify(goodsID)
goodsID: JSON.stringify(goodsID)
},
header: {
'Cookie': 'PFWSSS=' + Taro.getStorageSync('session_id'),
@ -208,16 +243,16 @@ class MyGoodList extends Component {
}
}).then(res => {
if (res.statusCode === 200) {
console.log('商品删除返回', res)
this.setState({isToast:true,toastText:'删除成功'},()=>{
console.log('商品删除返回', res)
this.setState({ isToast: true, toastText: '删除成功' }, () => {
setTimeout(() => {
this.setState({isToast:false})
this.setState({ isToast: false })
this.getMyGoodListApi({})// 从新获取商品列表数据
}, 2000);
})
} else {
console.log('我的商品列表获取失败')
}
@ -247,7 +282,7 @@ class MyGoodList extends Component {
minimumSold: '',
maximumSold: '',
productId: '',
productCateSelected: '全部类目',
productCateSelected: { class_Id: '', class_name: '全部类目' },
})
}
// 产品排序
@ -312,81 +347,83 @@ class MyGoodList extends Component {
this.state.filterOptions.filterPublishDate ? this.getGoodListResultApi({ order: "update_date desc" }) : this.getGoodListResultApi({ order: "update_date" })
}
)
}
}
// 翻页导航
paginationNav(type) {
this.setState({ currentPage: type.current,isCheckAll:false }, () => {
this.setState({ currentPage: type.current, isCheckAll: false }, () => {
this.getMyGoodListApi({ currPage: this.state.currentPage })
})
}
// 商品全部选择
checkAllHandler(){
const newMyGoodList=this.state.myGoodList.map((item)=>{
item.checked=!this.state.isCheckAll
checkAllHandler() {
const newMyGoodList = this.state.myGoodList.map((item) => {
item.checked = !this.state.isCheckAll
return item
})
this.setState({isCheckAll:!this.state.isCheckAll,myGoodList:newMyGoodList})
})
this.setState({ isCheckAll: !this.state.isCheckAll, myGoodList: newMyGoodList })
}
// 单个商品选择
handleCheckChange(Id) {
//如果goodid 一样的那么checked 就取反
const newMyGoodList=this.state.myGoodList.map((item)=>{
if(item.goods_id===Id){
item.checked=!item.checked
}
return item
const newMyGoodList = this.state.myGoodList.map((item) => {
if (item.goods_id === Id) {
item.checked = !item.checked
}
return item
})
this.setState({myGoodList:newMyGoodList})
this.setState({ myGoodList: newMyGoodList })
}
// 删除商品
deleteGoodsHandler(){
const checkedGoodsId=[]
// 删除商品
deleteGoodsHandler() {
const checkedGoodsId = []
this.state.myGoodList.forEach(item => {
if(item.checked){
if (item.checked) {
checkedGoodsId.push(item.goods_id)
}
});
checkedGoodsId.length?this.deleteGood({goodsID:checkedGoodsId}):this.setState({isToast:true,toastText:'请选择要删除的商品'},()=>{
checkedGoodsId.length ? this.deleteGood({ goodsID: checkedGoodsId }) : this.setState({ isToast: true, toastText: '请选择要删除的商品' }, () => {
setTimeout(() => {
this.setState({isToast:false})
this.setState({ isToast: false })
}, 2000);
})
}
// 改变商品状态
offStockGoodHandler(){
const checkedGoodsId=[]
this.state.myGoodList.forEach(item => {
if(item.checked){
checkedGoodsId.push(item.goods_id)
}
});
checkedGoodsId.length?this.changeGoodState({goodsID:checkedGoodsId}):this.setState({isToast:true,toastText:'请选择要下架的商品'},()=>{
setTimeout(() => {
this.setState({isToast:false})
}, 2000);
// 改变商品状态
offStockGoodHandler() {
const checkedGoodsId = []
this.state.myGoodList.forEach(item => {
if (item.checked) {
checkedGoodsId.push(item.goods_id)
}
});
checkedGoodsId.length ? this.changeGoodState({ goodsID: checkedGoodsId }) : this.setState({ isToast: true, toastText: '请选择要下架的商品' }, () => {
setTimeout(() => {
this.setState({ isToast: false })
}, 2000);
})
}
// 导航到商品编辑页面myGoodsEdit
goToGoodEditPage(goodId) {
Taro.navigateTo({
url: '/pages/myGoodsEdit/myGoodsEdit?id=' + goodId
})
}
// 导航到商品编辑页面myGoodsEdit
goToGoodEditPage(){
Taro.navigateTo({
url: '/pages/myGoodsEdit/myGoodsEdit'
}
goToGoodspage(goodId){
Taro.navigateTo({
url: '/pages/goods/goods?id='+goodId// 虚拟地址
})
}
}
componentDidMount() {
this.getMyGoodListApi({})
this.getBaoBeiCateList()
}
componentWillReceiveProps(nextProps) {
console.log(this.props, nextProps)
@ -400,24 +437,24 @@ class MyGoodList extends Component {
render() {
// 轻提示
const toastElement=<AtToast
isOpened={this.state.isToast}
text={this.state.toastText}
></AtToast>
const toastElement = <AtToast
isOpened={this.state.isToast}
text={this.state.toastText}
></AtToast>
//等待接口数据 <Radio className='radio-list__radio' value={item.value} checked={item.checked}>{item.text}</Radio>
const goodListElementArray = this.state.myGoodList.map((item, index) => {
return <View key={index} className='good-container'>
<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>
{/* onClick={this.handleCheckChange.bind(this,item.goods_id)} */}
<View className='img-box'>
<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} />
</View>
<View className='name-box'>{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='quantity-box'>{item.sales_volume}</View>
<View className='button-box1' onClick={this.goToGoodEditPage.bind(this)}>
<View className='button-box1' onClick={this.goToGoodEditPage.bind(this,item.goods_id)}>
<AtButton type='primary' className='button-a' size='small'>
编辑商品</AtButton>
</View>
@ -438,7 +475,7 @@ class MyGoodList extends Component {
return (
<View className='MyGoodList'>
{toastElement}
{toastElement}
<View className='border-box'>
<AtInput
name='value'
@ -496,12 +533,12 @@ class MyGoodList extends Component {
/>
</View>
<View className='page-section'>
<Picker mode='selector' range={this.state.productCate} onChange={this.productCateChange.bind(this)}>
<Picker mode='selector' rangeKey='class_name' range={this.state.productCate} onChange={this.productCateChange.bind(this)}>
<View className='picker'>
<View className='title-box'>
<Text className='title'>宝贝类目:</Text>
<Text className='selected'>{this.state.productCateSelected}</Text>
<Text className='selected'>{this.state.productCateSelected.class_name}</Text>
</View>
</View>
@ -525,11 +562,11 @@ class MyGoodList extends Component {
</View>
<View className='filterbar-container'>
<View className='filter-bar'>
{filterElementsArray}
{filterElementsArray}
</View>
<View className='sub-filter'>
<Radio className='radio' checked={this.state.isCheckAll} onClick={this.checkAllHandler.bind(this)}>全选</Radio>
<Radio className='radio' checked={this.state.isCheckAll} onClick={this.checkAllHandler.bind(this)}>全选</Radio>
<View className='button' onClick={this.deleteGoodsHandler.bind(this)}>
<AtButton type='primary' size='small'>
删除</AtButton>
@ -546,8 +583,8 @@ class MyGoodList extends Component {
<View className='mygoodlist-container'>
{/* <RadioGroup onChange={this.handleCheckChange.bind(this)}> */}
{goodListElementArray}
{/* </RadioGroup> */}
{goodListElementArray}
{/* </RadioGroup> */}
</View>

View File

@ -1,4 +1,4 @@
import Taro, { Component } from '@tarojs/taro'
import Taro, { Component, UpdateManager } from '@tarojs/taro'
import { View, Text, Radio, RadioGroup, Label } from '@tarojs/components'
import { AtInput, AtImagePicker, AtTextarea, AtButton, Picker, AtToast } from 'taro-ui'
@ -14,26 +14,63 @@ class MyGoodsEdit extends Component {
constructor() {
super(...arguments)
this.state = {
shopCategoryPicker: [], // 店铺分类选项
shopCategoryCheckedPicker: { name: '选择店铺类型' },
shopCategoryCheckedPicker: { name: '选择店铺类型', id: '' },
productName: '',
productPrice: '',
productUnit: '',
productDescript: '',
pickerImageUrl: [], // 上传的图片
ImagesInfo: [],// 后台传回来的图片信息
shopCategoryList: [],
isToast:false,
toastText:'',
}
}
//获取商品信息api GetProductInfo
getGoodsInfo() {
Taro.request({
url: URL.GetProductInfo,
method: 'GET',
dataType: 'json',
data: {
// goodsID: 'c610femn1j8fHUOM5gvh6VxW03O5mBDgNcAJGGFmvFX3Zw'
goodsID: this.$router.params.id,
},
header: {
'content-type': 'application/x-www-form-urlencoded',
'Cookie': 'PFWSSS=' + Taro.getStorageSync('session_id'),
'X-Requested-With': 'XMLHttpRequest'
}
})
.then(res => {
console.log('商品详情获取成功', res)
const imageFile = res.data.goodsFiles.map((item) => {
return { url: URL.Base + item.files.file_path }
})
const selectedShopCateId=res.data.goods.shop_class_id
const selectedShopCate=this.state.shopCategoryPicker.filter(item=>{
return item.id===selectedShopCateId
})
console.log('abc',selectedShopCate)
this.setState({
productName: res.data.goods.goods_name,
productPrice: res.data.goods.goods_price,
productUnit: res.data.goods.goods_unit,
productDescript: res.data.goods.goods_profiles,
shopCategoryCheckedPicker:selectedShopCate[0],
pickerImageUrl: imageFile
})
}
)
.catch(error => {
console.log('商品详情获取失败', error)
})
}
// 店铺分类目录请求 api
getShopCateList() {
async getShopCateList() {
Taro.request({
url: URL.GetShopCategoryList,
method: 'POST',
@ -61,6 +98,7 @@ class MyGoodsEdit extends Component {
}
this.setState({ shopCategoryPicker: shopCategory })
console.log('店铺分类目录', res)
return
}
}
)
@ -120,29 +158,34 @@ class MyGoodsEdit extends Component {
}
})
.then(res => {
this.setState({ toastText: '发布成功', isToast: true }, () => {
setTimeout(() => {
this.setState({ isToast: false })
Taro.navigateTo({
url: '/pages/goods/goods?id=5cf3Ptn5wKQdyPpwsSe2nDKnN4QDFdz8moPTf+QIOm788Q'// 虚拟地址
})
}, 2000)
Taro.hideLoading()
Taro.showToast({
title: '保存成功',
icon: 'success',
duration: 1000
})
setTimeout(() => {
Taro.navigateTo({
url: '/pages/goods/goods?id=5cf3Ptn5wKQdyPpwsSe2nDKnN4QDFdz8moPTf+QIOm788Q'// 虚拟地址
})
}, 1000);
console.log('上传商品', res)
}
)
.catch(error => {
this.setState({ toastText: '发布失败', isToast: true }, () => {
setTimeout(() => {
this.setState({ isToast: false })
}, 2000)
Taro.hideLoading()
Taro.showToast({
title: '保存失败',
icon: 'none',
duration: 1000
})
})
}
productNameChange(event) {
this.setState({
productName: event
@ -184,10 +227,12 @@ class MyGoodsEdit extends Component {
const imagePath = URL.Base + data.file_path
const newPickerImageUrl = that.state.pickerImageUrl.concat({ url: imagePath })
const newImageInfo = that.state.ImagesInfo.concat(data)
that.setState({ pickerImageUrl: newPickerImageUrl, isToast: true, toastText: '图片上传成功', ImagesInfo: newImageInfo }, () => {
setTimeout(() => {
that.setState({ isToast: false })
}, 2000)
that.setState({ pickerImageUrl: newPickerImageUrl, ImagesInfo: newImageInfo }, () => {
Taro.showToast({
title: '上传成功',
icon: 'success',
duration: 2000
})
})
}
})
@ -195,11 +240,13 @@ class MyGoodsEdit extends Component {
if (operationType === 'remove') {
this.state.pickerImageUrl.splice(index, 1);
this.setState({ files: this.state.pickerImageUrl });
that.setState({ isToast: true, toastText: '删除成功' }, () => {
setTimeout(() => {
that.setState({ isToast: false })
}, 2000)
Taro.showToast({
title: '删除成功',
icon: 'success',
duration: 2000
})
}
}
// 图片上传失败
@ -211,20 +258,24 @@ class MyGoodsEdit extends Component {
}
onClickUploadGoods() {
if (this.state.productName && this.state.productPrice && this.state.productUnit && this.state.ImagesInfo.length && this.state.shopCategoryCheckedPicker.id) {
this.uploadGoods({
goods_name: this.state.productName,
goods_price: this.state.productPrice,
goods_unit: this.state.productUnit,
goods_profiles: this.state.productDescript,
class_id: "10103",
shop_class_id: this.state.shopCategoryCheckedPicker,
Taro.showLoading({ title: '保存中' }).then(() => {
setTimeout(() => {
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.shopCategoryCheckedPicker,
})
}, 1000);
})
} else {
this.setState({ toastText: '请填写完表格', isToast: true }, () => {
setTimeout(() => {
this.setState({ isToast: false })
}, 2000)
Taro.showToast({
title: '请填写完表格',
icon: 'none',
duration: 2000
})
}
}
shopCategoryChanged(e) {
@ -234,16 +285,19 @@ class MyGoodsEdit extends Component {
console.log(this.state.shopCategoryCheckedPicker)
})
}
goToMyGoodListPage(){
goToMyGoodListPage() {
Taro.navigateTo({
url: '/pages/myGoodList/myGoodList'
})
url: '/pages/myGoodList/myGoodList'
})
}
componentDidMount() {
this.getShopCateList()
this.getShopCateList().then(() => {
this.getGoodsInfo()
})
}
componentWillReceiveProps(nextProps) {
@ -255,56 +309,46 @@ class MyGoodsEdit extends Component {
componentDidHide() { }
render() {
const imageUploadSuccess = <AtToast
isOpened={this.state.isToast}
text={this.state.toastText}
duration={2000}
></AtToast>
const productUploadSuccess = <AtToast
isOpened={this.state.isToast}
text={this.state.toastText}
duration={2000}
></AtToast>
return (
<View className='goods-publish'>
{imageUploadSuccess}
{productUploadSuccess}
<View className='goods-category'>
<View className='input-box'>
<Text className='require'>*</Text>
<AtInput
name='productName'
title='商品名称:'
type='text'
value={this.state.productName}
onChange={this.productNameChange.bind(this)}
name='productName'
title='商品名称:'
type='text'
value={this.state.productName}
onChange={this.productNameChange.bind(this)}
/>
</View>
<View className='input-box'>
<Text className='require'>*</Text>
<AtInput
name='productPrice'
title='商品价格:'
type='number'
placeholder='¥'
value={this.state.productPrice}
onChange={this.productPriceChange.bind(this)}
name='productPrice'
title='商品价格:'
type='number'
placeholder='¥'
value={this.state.productPrice}
onChange={this.productPriceChange.bind(this)}
/>
</View>
<View className='input-box'>
<Text className='require'>*</Text>
<AtInput
name='productUnit'
title='商品单位:'
type='text'
value={this.state.productUnit}
onChange={this.productUnitChange.bind(this)}
name='productUnit'
title='商品单位:'
type='text'
value={this.state.productUnit}
onChange={this.productUnitChange.bind(this)}
/>
</View>
{/* 图片上传 */}
@ -315,11 +359,11 @@ class MyGoodsEdit extends Component {
</View>
<View className='img-container'>
<AtImagePicker
multiple
files={this.state.pickerImageUrl}
onChange={this.onChangeImg.bind(this)}
onFail={this.onFail.bind(this)}
onImageClick={this.onImageClick.bind(this)}
multiple
files={this.state.pickerImageUrl}
onChange={this.onChangeImg.bind(this)}
onFail={this.onFail.bind(this)}
onImageClick={this.onImageClick.bind(this)}
/>
</View>
</View>
@ -346,10 +390,10 @@ class MyGoodsEdit extends Component {
</View>
<AtTextarea
value={this.state.productDescript}
onChange={this.productDescriptChange.bind(this)}
maxlength='200'
placeholder='你的产品简介'
value={this.state.productDescript}
onChange={this.productDescriptChange.bind(this)}
maxlength='200'
placeholder='你的产品简介'
/>
</View>

View File

@ -1,9 +1,9 @@
import Taro, { Component } from '@tarojs/taro'
import { View, Text, Button } from '@tarojs/components'
import { AtInput, AtButton, Picker, AtIcon, AtModal, AtToast, AtModalHeader, AtModalContent, AtModalAction } from 'taro-ui'
import { AtInput, AtButton, Picker, AtIcon, AtModal, AtModalHeader, AtModalContent, AtModalAction } from 'taro-ui'
import URL from '../../serviceAPI.config'
import copyrightComponent from '../../component/copyrightComponent/copyrightComponent'
import CopyrightComponent from '../../component/copyrightComponent/copyrightComponent'
import './mySupplyDemand.scss'
@ -17,17 +17,16 @@ class MySupplyDemand extends Component {
constructor() {
super(...arguments)
this.state = {
demandSupplyCate: ['全部', '需求', '供应', '人才'],
demandSupplyCateSelected: '全部',
demandSupplyState: ['全部', '上架', '下架'],
demandSupplyStatesSelected: '全部',
demandSupplyCate: [{ name: '全部', id: '' }, { name: '需求', id: '1' }, { name: '供应', id: '2' }, { name: '人才', id: '3' },],
demandSupplyCateSelected: { name: '全部', id: '' },
demandSupplyState: [{ name: '全部', id: '' }, { name: '上架', id: '1' }, { name: '下架', id: '0' }],
demandSupplyStatesSelected: { name: '全部', id: '' },
title: '',
startDateSel: '',
endDateSel: '',
allDemandSupply: [],
totalDemandSupply: '',
isToast: false,// 是否显示轻提示
toastContent: '', // 轻提示内容
isConfirmWindow: false, // 是否显示确认弹窗
demandSupplyItemName: '',// 确认框提示时 使用的供求名
demandSupplyId: '',// 删除我的供求时的供求id
@ -56,13 +55,16 @@ class MySupplyDemand extends Component {
}).then(res => {
if (res.data.err_msg === "success") {
// 判断是否有res.data.supplys 如果没有就是空数组[]
this.setState({ allDemandSupply: res.data.supplys ? res.data.supplys : [], totalDemandSupply: res.data.count })
Taro.hideLoading()
this.setState({ allDemandSupply: res.data.supplys || [], totalDemandSupply: res.data.count })
}
})
}
//搜索我的供求api
searchDemandSupply({ curr_page = 1, page_count = 20, sd_type = "2", state = "1", sd_title = this.state.title, update_dateL = this.state.startDateSel, update_dateU = this.state.endDateSel }) {
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',
@ -87,11 +89,20 @@ class MySupplyDemand extends Component {
.then(res => {
//this.setState({ grabOrderSuccess: res.data.err_msg,isGrabOrderSuccess: true })
console.log('我的供求搜索结果', res)
this.setState({ allDemandSupply: res.data.supplys, totalDemandSupply: res.data.count })
Taro.hideLoading()
this.setState({ allDemandSupply: res.data.supplys || [], totalDemandSupply: res.data.count })
})
}
onSearchButtonHandler(){
Taro.showLoading({title:'加载中'}) .then(() => {
setTimeout(() => {
this.searchDemandSupply({})
}, 1000);
})
}
// 删除我的供求api
@ -112,28 +123,28 @@ class MySupplyDemand extends Component {
.then(res => {
if (res.data.err_msg == 'success') {
console.log('删除成功')
this.setState({ toastContent: '删除成功', isToast: true }, () => {
setTimeout(() => {
this.setState({ isToast: false })
this.getMySupplyDemand({})
}, 2000)
Taro.showToast({
title: '删除成功'
}).then(() => {
this.getMySupplyDemand({})
})
} else {
this.setState({ toastContent: res.data.err_msg, isToast: true }, () => {
setTimeout(() => {
this.setState({ isToast: false })
}, 2000)
} else {
Taro.showToast({
title: res.data.err_msg,
icon: 'none'
})
}
}
)
.catch(error => {
this.setState({ toastContent: '删除失败', isToast: true }, () => {
setTimeout(() => {
this.setState({ isToast: false })
}, 2000)
Taro.showToast({
title: '删除失败',
icon: 'none'
})
})
}
@ -153,6 +164,8 @@ class MySupplyDemand extends Component {
demSupplyCateChange = e => {
this.setState({
demandSupplyCateSelected: this.state.demandSupplyCate[e.detail.value]
}, () => {
console.log(this.state.demandSupplyCateSelected)
})
}
// 修改供求状态
@ -198,14 +211,18 @@ class MySupplyDemand extends Component {
// 编辑我的供求
// 跳转到我的供求编辑页面
goToMyDSEditPage(){
goToMyDSEditPage() {
Taro.navigateTo({
url: '/pages/myDemandSupplyEdit/myDemandSupplyEdit'
})
url: '/pages/myDemandSupplyEdit/myDemandSupplyEdit'
})
}
// 转到供求查看页面
goToSupplyDemandPage(){
Taro.navigateTo({
url: '/pages/supplyDemandView/supplyDemandView'
})
}
//查看我的供求
componentWillReceiveProps(nextProps) {
@ -213,7 +230,14 @@ class MySupplyDemand extends Component {
}
componentDidMount() {
this.getMySupplyDemand({})
Taro.showLoading({title:'加载中'}) .then(() => {
this.getMySupplyDemand({})
})
}
componentWillUnmount() { }
@ -232,12 +256,7 @@ class MySupplyDemand extends Component {
</AtModalContent>
<AtModalAction> <Button onClick={this.handleWindowModCancel.bind(this)}>取消</Button> <Button className='orange' onClick={this.handleWindowConfirm.bind(this)}></Button> </AtModalAction>
</AtModal>
// 轻提示
const toastElement = <AtToast
isOpened={this.state.isToast}
text={this.state.toastContent}
duration={2000}
></AtToast>
const demandSupplyElementArray = this.state.allDemandSupply.length ? this.state.allDemandSupply.map((item, index) => {
return <View key={index} className='info-container'>
<View className='type'>
@ -265,10 +284,10 @@ class MySupplyDemand extends Component {
<Text className='info'>{item.update_date}</Text>
</View>
<View className='info-button-box'>
<View className='button'>
<View className='button' onClick={this.goToSupplyDemandPage.bind(this)}>
<AtButton type='primary' size='small'>查看</AtButton>
</View>
<View className='button'onClick={this.goToMyDSEditPage.bind(this)} >
<View className='button' onClick={this.goToMyDSEditPage.bind(this)} >
<AtButton type='primary' size='small'>编辑</AtButton>
</View>
<View className='button' onClick={this.handleOnDelete.bind(this, item.sd_id, item.sd_title)}>
@ -285,18 +304,17 @@ class MySupplyDemand extends Component {
<View className='mySupplyDemand'>
{/* 是否删除供求确认框 */}
{modalMessageConfirmElement}
{/* 轻提示 */}
{toastElement}
{/* 供求类型 */}
<View className='page-section'>
<View>
<Picker mode='selector' range={this.state.demandSupplyCate} onChange={this.demSupplyCateChange.bind(this)}>
<Picker mode='selector' rangeKey='name' range={this.state.demandSupplyCate} onChange={this.demSupplyCateChange.bind(this)}>
<View className='picker'>
<View className='title-box'>
<Text className='title'><Text className='require'>*</Text>:</Text> <Text className='selected'>{this.state.demandSupplyCateSelected}</Text>
<Text className='title'><Text className='require'>*</Text>:</Text> <Text className='selected'>{this.state.demandSupplyCateSelected.name}</Text>
</View>
</View>
</Picker>
@ -306,10 +324,10 @@ class MySupplyDemand extends Component {
<View className='page-section'>
<View>
<Picker mode='selector' range={this.state.demandSupplyState} onChange={this.demSupplyStateChange.bind(this)}>
<Picker mode='selector' rangeKey='name' range={this.state.demandSupplyState} onChange={this.demSupplyStateChange.bind(this)}>
<View className='picker'>
<View className='title-box'>
<Text className='title'> <Text className='require'>*</Text>:</Text> <Text className='selected'>{this.state.demandSupplyStatesSelected}</Text>
<Text className='title'> <Text className='require'>*</Text>:</Text> <Text className='selected'>{this.state.demandSupplyStatesSelected.name}</Text>
</View>
</View>
@ -320,12 +338,12 @@ class MySupplyDemand extends Component {
<View className='input-box'>
<Text className='require'>*</Text>
<AtInput
name='value'
title='供求标题:'
placeholder='供求标题·'
type='text'
value={this.state.title}
onChange={this.titleChange.bind(this)}
name='value'
title='供求标题:'
placeholder='供求标题·'
type='text'
value={this.state.title}
onChange={this.titleChange.bind(this)}
/>
</View>
{/* 开始和结束日期 */}
@ -351,7 +369,7 @@ class MySupplyDemand extends Component {
</View>
<View className='button-box'>
<View className='button' onClick={this.searchDemandSupply.bind(this)}>
<View className='button' onClick={this.onSearchButtonHandler.bind(this)}>
<AtButton type='primary' size='small'>
<AtIcon value='search' size='12' color='white'></AtIcon>
搜索</AtButton>
@ -370,7 +388,7 @@ class MySupplyDemand extends Component {
<copyrightComponent></copyrightComponent>
<CopyrightComponent></CopyrightComponent>
</View>
)

View File

@ -27,7 +27,7 @@ class Shop extends Component {
filterBar: ['all', 'amount', 'newProduct', 'price', 'popularity'], //筛选选项
filterBarKeys: { all: '综合排序', amount: '销量', newProduct: '新品', price: '价格', popularity: '人气' }, // 筛选选项对应值
selectedFilterValue: 0, //筛选项
isShowFilter: true, //是否显示侧边筛选
isShowFilter: false, //是否显示侧边筛选
showShopHomePage: true,// 是否显示首页页面
shopDescriptionData: '',// 店铺详情信息
shopName: '',//店铺名称
@ -54,7 +54,7 @@ class Shop extends Component {
otherType: [],//侧边其他类型
widthType: [],// 侧边宽度类型
checkedFilterIdList: [],//已选的筛选id
isLoading: false,
// 下面是函数的默认参数
curr_page: 1,
page_count: 10,
@ -110,17 +110,14 @@ class Shop extends Component {
.then(res => {
if (res.statusCode === 200) {
console.log('筛选项目成功', res)
Taro.hideLoading()
this.formatFilterData(res.data).then(data => {
this.setState({
sideFilterdata: data,
mainType: data.mainType || [],
goodType: data.goodType || [],
otherType: data.otherType || [],
widthType: data.widthType || [],
isLoading: false
})
console.log('formated data', data)
})
@ -226,7 +223,8 @@ class Shop extends Component {
}
})
.then(res => {
this.setState({ shopItem: res.data.goods, total: res.data.goodsCount, filterCondition: order, isLoading: false }, () => {
Taro.hideLoading()
this.setState({ shopItem: res.data.goods, total: res.data.goodsCount, filterCondition: order }, () => {
})
@ -247,6 +245,8 @@ class Shop extends Component {
}
})
.then(res => {
Taro.hideLoading()
this.setState({
shopDescriptionData: res.data,
shopName: res.data.data.shop_name,
@ -277,6 +277,8 @@ class Shop extends Component {
})
.then(res => {
if (res.statusCode === 200) {
Taro.hideLoading()
const originalData = res.data.data
const sortedData = []
for (let item in originalData) {
@ -301,6 +303,7 @@ class Shop extends Component {
// 产品排序
accendingDescending(value) {
Taro.showLoading({ title: '加载中' })
this.setState({ selectedFilterValue: value })
if (value == 0) {
this.setState({
@ -390,8 +393,7 @@ class Shop extends Component {
// 选择侧边筛选的标签
selectTag(name) {
const id = name.name
console.log('clicked ID', id)
this.setState({ isLoading: true })
Taro.showLoading({ title: '加载中' })
// 处理分类筛选项
const newMainType = this.state.mainType.map((item) => {
if (item.id === id) {
@ -428,6 +430,7 @@ class Shop extends Component {
value[each].checked = !value[each].checked
setTimeout(() => {
this.setState({ checkedFilterIdList: this.state.checkedFilterIdList.concat(value[each]), goodsParam: [{ param_id: value[each].name.id, param_value: value[each].name }] }, () => {
this.getSearchParams({ goodsParam: this.state.goodsParam })
this.goodsSearch({ goodsParam: this.state.goodsParam })
@ -456,6 +459,7 @@ class Shop extends Component {
}
handleOnPageChange(value) {
Taro.showLoading({ title: '加载中' })
this.setState({ currentPage: value.current })
this.goodsSearch({ curr_page: value.current, order: this.state.filterCondition })
}
@ -470,6 +474,8 @@ class Shop extends Component {
}
handleShopInnerCate(id) {
Taro.showLoading({ title: '加载中' })
this.setState({
isShowShopAllCate: false, isBlurWindow: false
})
@ -483,6 +489,8 @@ class Shop extends Component {
//重置按键筛选
resetFilterList() {
Taro.showLoading({ title: '加载中' })
this.setState({
checkedFilterIdList: [], curr_page: 1,
page_count: 10,
@ -515,6 +523,9 @@ class Shop extends Component {
}
componentDidMount() {
Taro.showLoading({ title: '加载中' })
//页面加载之后 得到指定店铺的商品 和 筛选标签
this.goodsSearch({ shop_id: this.$router.params.id }) // 加载店铺商品
this.getSearchParams({})// 加载筛选项
@ -528,11 +539,7 @@ class Shop extends Component {
componentDidHide() { }
render() {
const loadingElement = <AtToast
isOpened={this.state.isLoading}
status='loading'
text='加载中'
></AtToast>
const ShopItemElementsArray = this.state.shopItem.length ? this.state.shopItem.map((item, index) => {
return <View key={index} className='shop-item' >
<ShopItem item={item}></ShopItem>
@ -699,7 +706,7 @@ class Shop extends Component {
})
return (
<View className='shop' >
{loadingElement}
<View onClick={this.state.closeBgWindow.bind(this)} className={this.state.isBlurWindow ? 'show-blur' : ''}></View>
<View className='banner-box'>
<Image src={URL.Base + 'Public/visual_editing/img/ksh_bg.jpg'} mode='scaleToFill' style='width: 100%;height:120px; ' />

View File

@ -19,10 +19,10 @@ class SupplyDemand extends Component {
constructor() {
super(...arguments)
this.state = {
demandingSupplyCate: ['需求', '供应', '人才'], //供求类型选择
demandingSupplyCateSelected: '需求',// 当前供求类型
demandingSupplyState: ['上架', '下架'], // 状态选择
demandingSupplyStateSelected: '上架',// 当前状态
demandingSupplyCate: [{name:'需求',id:1}, {name:'供应',id:2}, {name:'人才',id:3}], //供求类型选择
demandingSupplyCateSelected: {name:'需求',id:1},// 当前供求类型
demandingSupplyState: [{name:'上架',id:1}, {name:'下架',id:0}], // 状态选择
demandingSupplyStateSelected: {name:'上架',id:1},// 当前状态
title: '',
contactName: '',
contactNumber: '',
@ -44,13 +44,13 @@ class SupplyDemand extends Component {
console.log(this.state.ImagesInfo)
if (this.state.demandingSupplyCateSelected && this.state.title && this.state.contactName && this.state.contactNumber && this.state.contactAddress && this.state.content && this.state.demandingSupplyStateSelected) {
this.uploadDemSup({
sd_type:"2",
sd_type:this.state.demandingSupplyCateSelected,
sd_title:this.state.title,
user_name:this.state.contactName,
user_phone:this.state.contactNumber,
user_address:this.state.contactAddress,
sd_desc:this.state.content,
state:"1"})
state:this.state.demandingSupplyStateSelected})
} else {
this.setState({ uploadDemSupTextTip: '请填写完表格', isUploadDemSupSuccess: true }, () => {
setTimeout(() => {
@ -223,10 +223,10 @@ class SupplyDemand extends Component {
<View className='page-section'>
<View>
<Picker mode='selector' range={this.state.demandingSupplyCate} onChange={this.demandingSupplyCate.bind(this)}>
<Picker mode='selector' rangeKey='name' range={this.state.demandingSupplyCate} onChange={this.demandingSupplyCate.bind(this)}>
<View className='picker'>
<View className='title-box'>
<Text className='title'><Text className='require'>*</Text>:</Text> <Text className='selected'>{this.state.demandingSupplyCateSelected}</Text>
<Text className='title'><Text className='require'>*</Text>:</Text> <Text className='selected'>{this.state.demandingSupplyCateSelected.name}</Text>
</View>
</View>
@ -306,10 +306,10 @@ class SupplyDemand extends Component {
<View className='page-section'>
<View>
<Picker mode='selector' range={this.state.demandingSupplyState} onChange={this.demSupplyStateChange}>
<Picker mode='selector' rangeKey='name' range={this.state.demandingSupplyState} onChange={this.demSupplyStateChange}>
<View className='picker'>
<View className='title-box'>
<Text className='title'> <Text className='require'>*</Text>:</Text> <Text className='selected'>{this.state.demandingSupplyStateSelected}</Text>
<Text className='title'> <Text className='require'>*</Text>:</Text> <Text className='selected'>{this.state.demandingSupplyStateSelected.name}</Text>
</View>
</View>

View File

@ -0,0 +1,38 @@
//supplyDemandItemView
import Taro, { Component } from '@tarojs/taro'
import { View } from '@tarojs/components'
import './supplyDemandView.scss'
class SupplyDemandView extends Component {
config = {
navigationBarTitleText: '单独供求'
}
componentDidMount(){
}
componentWillReceiveProps (nextProps) {
console.log(this.props, nextProps)
}
componentWillUnmount () { }
componentDidShow () { }
componentDidHide () { }
render () {
return (
<View className='SupplyDemandItemView'>
单独供求
</View>
)
}
}
export default SupplyDemandView

View File

@ -36,11 +36,19 @@ const URL = {
// 商品列表的api 接口 GoodsList-goodsDelete
DeleteGood: LOCALURL + 'GoodsList-goodsDelete',// 删除商品列表接口
ChangeGoodState: LOCALURL + 'GoodsList-setGoodsState',// 改变商品列表状态 (下架)
BaoBeiCateList: LOCALURL + 'GoodsList-wxSales',// 获取宝贝类目列表
// 我的供求页面接口Supply-myList
SearchDemandSupply: LOCALURL + 'Supply-myList',// 搜索我的供求接口
DeleteDemandSupply: LOCALURL + 'Supply-delete',// 删除我的供求接口
// 商品编辑页面 Goods-wxEditPhoneDeploy
GetProductInfo: LOCALURL + 'Goods-wxEditPhoneDeploy',// 获取商品信息
}
module.exports = URL

View File

@ -1,35 +1,27 @@
todo list
首页:
优惠卷和询价接口
联系人和联系电话 改动?
店铺页面:
侧边筛选
商品发布页面:
商品分类三级联动 // 有bug
店铺分类选项 二级联动// 需要修改
商品价格无法设定为数字 // 有bug
供求发布页面
等待后台- 供求类型 和供求状态
联系电话无法设置为数字 // 有bug type=password 可以
全部业主需求页面:
供求状态和行业分类--等待后台接口--搜索
行业分类--等待后台接口--搜索 二级联动--
我的供求页面:
搜索接口--等待后台
我的供求查看页面
我的供求编辑页面--等待后台接口数据
我的商品列表页面
等待后台的搜索- 宝贝类目
商品价格无法设定为数字 // 有bug
商品编辑页面
等待后台api
店铺分类--二级联动
alldemanding
接口问题:
优惠卷和询价