diff --git a/src/app.js b/src/app.js index b5dab47..b9b33a2 100644 --- a/src/app.js +++ b/src/app.js @@ -30,6 +30,7 @@ class App extends Component { 'pages/myGoodList/myGoodList',// 我的商品列表页面 'pages/myDemandSupplyEdit/myDemandSupplyEdit',// 我的供求编辑页面 'pages/supplyDemandView/supplyDemandView',// 查看单个供求页面 + 'pages/grabOrderPage/grabOrderPage',// 抢单页面 // 'pages/shopDescription/shopDescription', ], window: { diff --git a/src/pages/goodsPublish/goodsPublish.js b/src/pages/goodsPublish/goodsPublish.js index 52edb23..20e8188 100644 --- a/src/pages/goodsPublish/goodsPublish.js +++ b/src/pages/goodsPublish/goodsPublish.js @@ -165,10 +165,12 @@ class GoodsPublish extends Component { duration: 1000 }) setTimeout(() => { - Taro.navigateTo({ - url: '/pages/goods/goods?id=5cf3Ptn5wKQdyPpwsSe2nDKnN4QDFdz8moPTf+QIOm788Q'// 虚拟地址 - }) + + Taro.navigateTo({ + url: '/pages/goods/goods?id='+res.data.goods_id + }) }, 1000); + console.log('上传商品', res) } ) @@ -290,7 +292,7 @@ class GoodsPublish extends Component { goods_price: this.state.productPrice, goods_unit: this.state.productUnit, goods_profiles: this.state.productDescript, - class_id: "10103",// to be continue + class_id: "10103",// to be continue //商品分类的选项 shop_class_id: this.state.shopCategoryCheckedPicker.id, }) },1000)}) diff --git a/src/pages/grabOrderPage/grabOrderPage.js b/src/pages/grabOrderPage/grabOrderPage.js new file mode 100644 index 0000000..ea27870 --- /dev/null +++ b/src/pages/grabOrderPage/grabOrderPage.js @@ -0,0 +1,75 @@ +//grabOrderPage +import Taro, { Component } from '@tarojs/taro' +import { View, Text } from '@tarojs/components' +import { AtButton, AtIcon } from 'taro-ui' + +import CopyrightComponent from '../../component/copyrightComponent/copyrightComponent' + + +import './grabOrderPage.scss' + + +class GrabOrderPage extends Component { + config = { + navigationBarTitleText: '抢单页面' + } + + componentDidMount() { + + } + componentWillReceiveProps(nextProps) { + console.log(this.props, nextProps) + } + + componentWillUnmount() { } + + componentDidShow() { } + + componentDidHide() { } + + render() { + return ( + + + 行业分类: + {this.state.type} + + + 业主需求标题: + {this.state.title} + + + 浏览量: + {this.state.browsing} + + + 联系人: + {this.state.contactName} + + + 联系电话: + {this.state.contactNumber} + + + 联系地址: + {this.state.address} + + + 业主需求内容: + {this.state.content} + + + + + + 抢单 + + + + + + ) + } +} + +export default GrabOrderPage diff --git a/src/pages/grabOrderPage/grabOrderPage.scss b/src/pages/grabOrderPage/grabOrderPage.scss new file mode 100644 index 0000000..5ef7af1 --- /dev/null +++ b/src/pages/grabOrderPage/grabOrderPage.scss @@ -0,0 +1,31 @@ +.grabOrderPage{ + padding: 10px 20px; + font-size: 32rpx; + .box{ + margin-top: 35px; + } + .title{ + font-weight: bold + } + +} +.button-box{ + display: flex; + flex-wrap: nowrap; + flex-direction: row; + margin: 80px 0; + padding: 0 20px; + + .button{ + flex:1; + text-align: center; + // margin:2%; + // justify-content:center; + + .at-button--primary{ + background-color:#FF7142; + border:1PX solid #FF7142; + } + + }} + \ No newline at end of file diff --git a/src/pages/home/home.js b/src/pages/home/home.js index fa99ab5..5fd4fcf 100644 --- a/src/pages/home/home.js +++ b/src/pages/home/home.js @@ -24,8 +24,7 @@ class Home extends Component { otherData: [], // 底部导航栏 isOpen: false, // 抢单消息提示 grabOrderId: '',//抢到订单的id - isGrabOrderSuccess: false,// 是否显示轻提示 - grabOrderSuccess: '',// 抢单成功返回字段 + isMore: 'noMore',// 加载更多店铺 userName:'',//用户名字 userPhone:'',// 用户电话 @@ -170,11 +169,12 @@ class Home extends Component { } }) .then(res => { - this.setState({ grabOrderSuccess: res.data.err_msg, isGrabOrderSuccess: true }, () => { - setTimeout(() => { - this.setState({ isGrabOrderSuccess: false }) - }, 2000) + Taro.showToast({ + title: res.data.err_msg, + icon:'none', + duration:1500 }) + console.log('抢单请求:', res) }) @@ -225,6 +225,14 @@ class Home extends Component { }, 1000); } + + // 导航去抢单页面 + goToGrabOrderPage(){ + Taro.navigateTo({ + + url:'/pages/grabOrderPage/grabOrderPage' + }) + } componentDidMount() { // 页面加载后 得到首页的基本信息和推荐店铺的信息 Taro.showLoading({ title: '加载中' }) @@ -269,18 +277,12 @@ class Home extends Component { - // 抢单返回轻提示 - const grabOrderSuccessElement = - - + const demandingElemensArray = this.state.demanding.length ? this.state.demanding.map((item, index) => { return - + + {item.class_name} @@ -293,6 +295,7 @@ class Home extends Component { 业主:{item.user_name} + @@ -332,8 +335,7 @@ class Home extends Component { return ( - {/* 抢单成功预付轻提示 */} - {grabOrderSuccessElement} + {/* 获取微信用户的信息 */} {/* 获取微信用户的信息 */} diff --git a/src/pages/index/index.js b/src/pages/index/index.js index 5422cc4..18b7d28 100644 --- a/src/pages/index/index.js +++ b/src/pages/index/index.js @@ -32,8 +32,9 @@ class Index extends Component { // url: '/pages/goodsPublish/goodsPublish' //url: '/pages/goodsPublish/goodsPublish' // url: '/pages/myDemandSupplyEdit/myDemandSupplyEdit' - url: '/pages/mySupplyDemand/mySupplyDemand' - // url:'/pages/supplyDemandPublish/supplyDemandPublish' + // url: '/pages/mySupplyDemand/mySupplyDemand' + // url:'/pages/grabOrderPage/grabOrderPage' + url:'/pages/home/home' }) } componentWillReceiveProps (nextProps) { diff --git a/src/pages/myDemandSupplyEdit/myDemandSupplyEdit.js b/src/pages/myDemandSupplyEdit/myDemandSupplyEdit.js index 119ffaf..fb1c9b9 100644 --- a/src/pages/myDemandSupplyEdit/myDemandSupplyEdit.js +++ b/src/pages/myDemandSupplyEdit/myDemandSupplyEdit.js @@ -19,10 +19,10 @@ class MyDemandSupplyEdit 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: '', @@ -38,10 +38,49 @@ class MyDemandSupplyEdit extends Component { } } + //获取商品信息api GetProductInfo + getSupplyDemandInfo() { + Taro.request({ + url: URL.GetSupplyDemandInfo, + method: 'GET', + dataType: 'json', + data: { + sdID: this.$router.params.sdId, + }, + header: { + 'content-type': 'application/x-www-form-urlencoded', + 'Cookie': 'PFWSSS=' + Taro.getStorageSync('session_id'), + 'X-Requested-With': 'XMLHttpRequest' + } + }) + .then(res => { + console.log('供求详情获取成功', res) + const selectedType = this.state.demandingSupplyCate.filter(item => item.id == res.data.sdInfo.sd_type)[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 } }) + this.setState({ + demandingSupplyCateSelected: selectedType, + title: res.data.sdInfo.sd_title, + contactName: res.data.sdInfo.user_name, + contactNumber: res.data.sdInfo.user_phone, + contactAddress: res.data.sdInfo.user_address, + content: res.data.sdInfo.sd_desc, + demandingSupplyStateSelected: selectedState, + pickerImageUrl: imageFile, + ImagesInfo:res.data.sdInfo.file_path, + }) + Taro.hideLoading() + } + + ) + .catch(error => { + console.log('供求详情获取失败', error) + }) + } // 上传供求api uploadSupplyDemand() { - if (this.state.demandingSupplyCateSelected && this.state.title && this.state.contactName && this.state.contactNumber && this.state.contactAddress && this.state.content && this.state.demandingSupplyStateSelected) { + 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 }, () => { @@ -69,8 +108,75 @@ class MyDemandSupplyEdit extends Component { // ) } - // 这个需要写一个uploadDemSup 上传供求 的api + // uploadDemSup 上传供求 的api + uploadDemSup({ sd_type = this.state.demandingSupplyCateSelected.id, + 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 = this.state.demandingSupplyStateSelected.id }) { + const file_path = []; + this.state.ImagesInfo.forEach((item) => { + file_path.push({ + file_name: item.file_name, + file_size: item.file_size, + file_path: item.file_path, + thumb_path: item.thumb_path + }) + }) + Taro.request({ + url: URL.UploadSupplyDemand, + method: 'POST', + dataType: 'json', + data: { + action: 2, + sdInfo: JSON.stringify({ + sd_id:this.$router.params.sdId, + sd_type: sd_type, + sd_title: sd_title, + user_name: user_name, + user_phone: user_phone, + user_address: user_address, + sd_desc: sd_desc, + state: state, + file_path: file_path + }) + }, + header: { + 'content-type': 'application/x-www-form-urlencoded', + 'Cookie': 'PFWSSS=' + Taro.getStorageSync('session_id'), + 'X-Requested-With': 'XMLHttpRequest' + } + }) + .then(res => { + console.log('上传供求', res) + if (res.data.err_msg === 'success') { + Taro.showToast({ + title: '上传成功', + icon: 'success', + duration: 1500 + }).then(()=>{ + setTimeout(() => { + Taro.navigateTo({ + url: '/pages/mySupplyDemand/mySupplyDemand' + }) + }, 1500); + }) + + } else { + Taro.showToast({ + title: res.data.err_msg, + icon: 'none', + duration: 1500 + }) + } + + } + ) + + } // 上传图片 onChangeImg(files, operationType, index) { @@ -90,22 +196,30 @@ class MyDemandSupplyEdit 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: 1500 + }) } }) } 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) - }) + this.state.ImagesInfo.splice(index, 1) // 删除显示的图片 + this.state.pickerImageUrl.splice(index, 1)// 删除图片param + that.setState({ + pockerImageUrl:this.state.pickerImageUrl, + ImagesInfo:this.state.ImagesInfo, + }) + Taro.showToast({ + title: '删除成功', + icon: 'success', + duration: 1500 + }) } } // 修改供求类型 @@ -136,15 +250,17 @@ class MyDemandSupplyEdit extends Component { contentChange(event) { this.setState({ content: event.target.value }) } - goToMyDemSupPage(){ + goToMyDemSupPage() { Taro.navigateTo({ - url: '/pages/mySupplyDemand/mySupplyDemand' - }) + url: '/pages/mySupplyDemand/mySupplyDemand' + }) } componentDidMount() { - // this.uploadSupplyDemand() + // console.log('this.$router.params.sdId',this.$router.params.sdId) + Taro.showLoading({title:'加载中'}) + this.getSupplyDemandInfo() } componentWillReceiveProps(nextProps) { console.log(this.props, nextProps) @@ -158,14 +274,14 @@ class MyDemandSupplyEdit extends Component { render() { const imageUploadSuccessElement = const demandSupplyUploadSuccessElement = return ( @@ -173,13 +289,13 @@ class MyDemandSupplyEdit extends Component { {imageUploadSuccessElement} {/* 商品发布模态框 */} {demandSupplyUploadSuccessElement} - + - + - *供求类型: {this.state.demandingSupplyCateSelected} + *供求类型: {this.state.demandingSupplyCateSelected.name} @@ -188,31 +304,31 @@ class MyDemandSupplyEdit extends Component { * * * @@ -221,10 +337,10 @@ class MyDemandSupplyEdit extends Component { @@ -232,10 +348,10 @@ class MyDemandSupplyEdit extends Component { *需求内容: @@ -246,12 +362,12 @@ class MyDemandSupplyEdit extends Component { @@ -259,10 +375,10 @@ class MyDemandSupplyEdit extends Component { - + - *状态: {this.state.demandingSupplyStateSelected} + *状态: {this.state.demandingSupplyStateSelected.name} diff --git a/src/pages/myGoodList/myGoodList.js b/src/pages/myGoodList/myGoodList.js index b85b437..6b20449 100644 --- a/src/pages/myGoodList/myGoodList.js +++ b/src/pages/myGoodList/myGoodList.js @@ -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 { AtInput, Text, AtButton, AtIcon, Picker, Image, AtPagination, } from 'taro-ui' import CopyrightComponent from '../../component/copyrightComponent/copyrightComponent' import URL from '../../serviceAPI.config' @@ -41,8 +41,7 @@ class MyGoodList extends Component { currPageParam: 1,// 当前页面 参数 isCheckAll: false,// 是否checked goodsIdList: [],//商品Id 列表 - isToast: false,// 是否显示轻提示 - toastText: ''// 轻提示字段 + } @@ -208,17 +207,25 @@ class MyGoodList extends Component { } }).then(res => { if (res.statusCode === 200) { - console.log('商品状态返回', res) - this.setState({ isToast: true, toastText: '下架成功' }, () => { + Taro.showToast({ + title:'下架成功', + icon:'success', + duration:1500 + }).then(()=>{ setTimeout(() => { - this.setState({ isToast: false }) - this.getMyGoodListApi({})// 从新获取商品列表数据 - }, 2000); + this.setState({isCheckAll:false}) + this.getMyGoodListApi({}) + }, 1500); }) } else { - console.log('我的商品列表获取失败') + Taro.showToast({ + title:'下架失败', + icon:'none', + duration:1500 + }) + this.setState({isCheckAll:false}) } @@ -244,17 +251,26 @@ class MyGoodList extends Component { }).then(res => { if (res.statusCode === 200) { console.log('商品删除返回', res) - this.setState({ isToast: true, toastText: '删除成功' }, () => { + Taro.showToast({ + title:'删除成功', + icon:'success', + duration:1500 + }).then(()=>{ setTimeout(() => { - this.setState({ isToast: false }) - this.getMyGoodListApi({})// 从新获取商品列表数据 - }, 2000); + this.setState({isCheckAll:false}) + this.getMyGoodListApi({}) + }, 1500); }) - - + + } else { - console.log('我的商品列表获取失败') + Taro.showToast({ + title:'删除失败', + icon:'none', + duration:1500 + }) + this.setState({isCheckAll:false}) } @@ -381,16 +397,18 @@ class MyGoodList extends Component { } // 删除商品 deleteGoodsHandler() { + const checkedGoodsId = [] this.state.myGoodList.forEach(item => { if (item.checked) { checkedGoodsId.push(item.goods_id) } }); - checkedGoodsId.length ? this.deleteGood({ goodsID: checkedGoodsId }) : this.setState({ isToast: true, toastText: '请选择要删除的商品' }, () => { - setTimeout(() => { - this.setState({ isToast: false }) - }, 2000); + + checkedGoodsId.length ? this.deleteGood({ goodsID: checkedGoodsId }) : Taro.showToast({ + title:'请选择要删除的商品', + icon:'none', + duration:1500 }) } @@ -416,7 +434,7 @@ class MyGoodList extends Component { } goToGoodspage(goodId){ Taro.navigateTo({ - url: '/pages/goods/goods?id='+goodId// 虚拟地址 + url: '/pages/goods/goods?id='+goodId }) } @@ -436,12 +454,7 @@ class MyGoodList extends Component { componentDidHide() { } render() { - // 轻提示 - const toastElement = - + //等待接口数据 {item.text} const goodListElementArray = this.state.myGoodList.map((item, index) => { @@ -475,7 +488,7 @@ class MyGoodList extends Component { return ( - {toastElement} + { 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 + const shopTypeId = res.data.goods.shop_class_id + const shopTypeName = this.state.shopCategoryList.filter(item => { + return item.id === shopTypeId }) - 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 + pickerImageUrl: imageFile, + ImagesInfo: res.data.goodsFiles, + shopCategoryCheckedPicker: shopTypeName[0], + goodsTypeParam: res.data.goods.class_id, + goodId: res.data.goods.goods_id, }) } ) @@ -86,7 +91,7 @@ class MyGoodsEdit extends Component { }) .then(res => { if (res.data.err_msg === 'success') { - this.setState({ shopCategoryList: res.data.data }) + const shopCategoryInfo = res.data.data const shopCategory = [] // 处理后台返回的店铺分类信息 @@ -96,7 +101,9 @@ class MyGoodsEdit extends Component { shopCategory.push({ id: children[child].id, name: children[child].n }) } } - this.setState({ shopCategoryPicker: shopCategory }) + this.setState({ shopCategoryList: shopCategory }, () => { + + }) console.log('店铺分类目录', res) return } @@ -108,7 +115,13 @@ class MyGoodsEdit 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", + goods_id = '123' }) { // 上传图片的参数 const uploadProductGoodFileParams = [] @@ -140,14 +153,15 @@ class MyGoodsEdit extends Component { dataType: 'json', data: { deployType: 1, - action: 1, + action: 2, goods: JSON.stringify({ goods_name: goods_name, goods_price: goods_price, goods_unit: goods_unit, goods_profiles: goods_profiles, class_id: class_id, - shop_class_id: shop_class_id + shop_class_id: shop_class_id, + goods_id: goods_id, }), goodsFiles: JSON.stringify(uploadProductGoodFileParams) }, @@ -166,10 +180,9 @@ class MyGoodsEdit extends Component { }) setTimeout(() => { Taro.navigateTo({ - url: '/pages/goods/goods?id=5cf3Ptn5wKQdyPpwsSe2nDKnN4QDFdz8moPTf+QIOm788Q'// 虚拟地址 + url: '/pages/goods/goods?id='+this.$router.params.id }) }, 1000); - console.log('上传商品', res) } ) @@ -223,11 +236,16 @@ class MyGoodsEdit extends Component { 'X-Requested-With': 'XMLHttpRequest' }, success(response) { + const data = JSON.parse(response.data) const imagePath = URL.Base + data.file_path const newPickerImageUrl = that.state.pickerImageUrl.concat({ url: imagePath }) const newImageInfo = that.state.ImagesInfo.concat(data) - that.setState({ pickerImageUrl: newPickerImageUrl, ImagesInfo: newImageInfo }, () => { + + that.setState({ + pickerImageUrl: newPickerImageUrl, + ImagesInfo: newImageInfo + }, () => { Taro.showToast({ title: '上传成功', icon: 'success', @@ -238,8 +256,13 @@ class MyGoodsEdit extends Component { }) } if (operationType === 'remove') { - this.state.pickerImageUrl.splice(index, 1); - this.setState({ files: this.state.pickerImageUrl }); + this.state.pickerImageUrl.splice(index, 1);// 删除图片param + this.state.ImagesInfo.splice(index, 1) // 删除显示的图片 + + this.setState({ + pickerImageUrl: this.state.pickerImageUrl, + ImagesInfo: this.state.ImagesInfo + }); Taro.showToast({ title: '删除成功', @@ -253,9 +276,7 @@ class MyGoodsEdit extends Component { onFail(mes) { console.log(mes) } - // 删除图片 - onImageClick(index) { - } + onClickUploadGoods() { if (this.state.productName && this.state.productPrice && this.state.productUnit && this.state.ImagesInfo.length && this.state.shopCategoryCheckedPicker.id) { Taro.showLoading({ title: '保存中' }).then(() => { @@ -265,7 +286,9 @@ class MyGoodsEdit extends Component { goods_price: this.state.productPrice, goods_unit: this.state.productUnit, goods_profiles: this.state.productDescript, - shop_class_id: this.state.shopCategoryCheckedPicker, + shop_class_id: this.state.shopCategoryCheckedPicker.id, + class_id: this.state.goodsTypeParam, + goods_id: this.state.goodId, }) }, 1000); }) @@ -280,7 +303,7 @@ class MyGoodsEdit extends Component { } shopCategoryChanged(e) { this.setState({ - shopCategoryCheckedPicker: this.state.shopCategoryPicker[e.detail.value] + shopCategoryCheckedPicker: this.state.shopCategoryList[e.detail.value] }, () => { console.log(this.state.shopCategoryCheckedPicker) }) @@ -296,6 +319,7 @@ class MyGoodsEdit extends Component { this.getShopCateList().then(() => { this.getGoodsInfo() + }) } @@ -315,40 +339,36 @@ class MyGoodsEdit extends Component { return ( - - - - * * * {/* 图片上传 */} @@ -359,18 +379,18 @@ class MyGoodsEdit extends Component { {/* 店铺分类 */} - + * 店铺分类: @@ -390,10 +410,10 @@ class MyGoodsEdit extends Component { diff --git a/src/pages/mySupplyDemand/mySupplyDemand.js b/src/pages/mySupplyDemand/mySupplyDemand.js index 46f046d..dedd263 100644 --- a/src/pages/mySupplyDemand/mySupplyDemand.js +++ b/src/pages/mySupplyDemand/mySupplyDemand.js @@ -1,6 +1,6 @@ import Taro, { Component } from '@tarojs/taro' import { View, Text, Button } from '@tarojs/components' -import { AtInput, AtButton, Picker, AtIcon, AtModal, AtModalHeader, AtModalContent, AtModalAction } from 'taro-ui' +import { AtInput, AtButton, Picker, AtIcon, AtModal, AtModalHeader, AtModalContent, AtModalAction,AtPagination } from 'taro-ui' import URL from '../../serviceAPI.config' import CopyrightComponent from '../../component/copyrightComponent/copyrightComponent' @@ -25,17 +25,17 @@ class MySupplyDemand extends Component { startDateSel: '', endDateSel: '', allDemandSupply: [], - totalDemandSupply: '', - isConfirmWindow: false, // 是否显示确认弹窗 demandSupplyItemName: '',// 确认框提示时 使用的供求名 demandSupplyId: '',// 删除我的供求时的供求id + totalDemandSupply:'',//所有供求 + currentPage:1 //当前页数 } } //获取我的供求API - getMySupplyDemand({ curr_page = 1, page_count = 20 }) { + getMySupplyDemand({ curr_page = 1, page_count = 10 }) { Taro.request({ url: URL.MySupplyDemand, method: 'POST', @@ -95,14 +95,15 @@ class MySupplyDemand extends Component { }) } - onSearchButtonHandler(){ - Taro.showLoading({title:'加载中'}) .then(() => { + onSearchButtonHandler() { + Taro.showLoading({ title: '加载中' }).then(() => { setTimeout(() => { this.searchDemandSupply({}) + this.setState({currentPage:1}) }, 1000); }) - + } // 删除我的供求api @@ -211,33 +212,36 @@ class MySupplyDemand extends Component { // 编辑我的供求 // 跳转到我的供求编辑页面 - goToMyDSEditPage() { + goToMyDSEditPage(sdId) { Taro.navigateTo({ - url: '/pages/myDemandSupplyEdit/myDemandSupplyEdit' + url: '/pages/myDemandSupplyEdit/myDemandSupplyEdit?sdId=' + sdId }) } // 转到供求查看页面 - goToSupplyDemandPage(){ + goToSupplyDemandPage(sdId) { Taro.navigateTo({ - url: '/pages/supplyDemandView/supplyDemandView' - }) + url: '/pages/supplyDemandView/supplyDemandView?sdId=' + sdId + // url: '/pages/goods/goods?sdId='+goodId// 虚拟地址 + }) } + // 翻页导航 + paginationNav(type) { + this.setState({ currentPage: type.current, }, () => { + this. getMySupplyDemand({ curr_page :this.state.currentPage}) + }) - //查看我的供求 + } + + componentWillReceiveProps(nextProps) { console.log(this.props, nextProps) } componentDidMount() { - - - Taro.showLoading({title:'加载中'}) .then(() => { - - this.getMySupplyDemand({}) - - - }) + Taro.showLoading({ title: '加载中' }).then(() => { + this.getMySupplyDemand({}) + }) } componentWillUnmount() { } @@ -256,9 +260,14 @@ class MySupplyDemand extends Component { - + + const demandSupplyElementArray = this.state.allDemandSupply.length ? this.state.allDemandSupply.map((item, index) => { - return + const SDState=this.state.demandSupplyState.filter(stateItem=>{ + return stateItem.id==item.state + })[0].name + + return 需求类型: {item.type_name} @@ -277,17 +286,17 @@ class MySupplyDemand extends Component { 需求状态: - {item.state} + {SDState} 更新时间: {item.update_date} - + 查看 - + 编辑 @@ -304,7 +313,7 @@ class MySupplyDemand extends Component { {/* 是否删除供求确认框 */} {modalMessageConfirmElement} - + @@ -385,6 +394,16 @@ class MySupplyDemand extends Component { {demandSupplyElementArray} + + + + + diff --git a/src/pages/mySupplyDemand/mySupplyDemand.scss b/src/pages/mySupplyDemand/mySupplyDemand.scss index 9786ffc..e90ca1f 100644 --- a/src/pages/mySupplyDemand/mySupplyDemand.scss +++ b/src/pages/mySupplyDemand/mySupplyDemand.scss @@ -132,4 +132,7 @@ $themeColor:#FF7142; text-align: center; font-size: 35px; +} +.pagination-box{ + margin: 50px 0; } \ No newline at end of file diff --git a/src/pages/supplyDemandPublish/supplyDemandPublish.js b/src/pages/supplyDemandPublish/supplyDemandPublish.js index cc7f33f..854c875 100644 --- a/src/pages/supplyDemandPublish/supplyDemandPublish.js +++ b/src/pages/supplyDemandPublish/supplyDemandPublish.js @@ -19,10 +19,10 @@ class SupplyDemand extends Component { constructor() { super(...arguments) this.state = { - 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},// 当前状态 + 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: '', @@ -30,50 +30,47 @@ class SupplyDemand extends Component { content: '', pickerImageUrl: [], // 上传的图片 ImagesInfo: [],// 后台传回来的图片信息 - isUploadImageSuccess: false, - uploadImageTextTip: '', + isFormCompleted: false, - isUploadDemSupSuccess: false, - uploadDemSupTextTip: '', - + } } // 上传供求api uploadSupplyDemand() { 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: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:this.state.demandingSupplyStateSelected}) + 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.showToast({ + title:'请填写完表格', + icon:'none', + duration:1500 }) + } - + } // 这个需要写一个uploadDemSup 上传供求 的api - uploadDemSup({sd_type="2",sd_title="第4方",user_name="郑燕彬",user_phone="13509302402",user_address="",sd_desc="但是发射点",state="1"}){ - const file_path=[]; - this.state.ImagesInfo.forEach((item)=>{ - file_path.push({ - file_name: item.file_name, - file_size: item.file_size, - file_path: item.file_path, - thumb_path:item.thumb_path - }) + uploadDemSup({ sd_type = this.state.demandingSupplyCateSelected.id, + 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 = this.state.demandingSupplyStateSelected.id }) { + const file_path = []; + this.state.ImagesInfo.forEach((item) => { + file_path.push({ + file_name: item.file_name, + file_size: item.file_size, + file_path: item.file_path, + thumb_path: item.thumb_path }) - Taro.request({ + }) + Taro.request({ url: URL.UploadSupplyDemand, method: 'POST', dataType: 'json', @@ -82,12 +79,13 @@ class SupplyDemand extends Component { sdInfo: JSON.stringify({ sd_type: sd_type, sd_title: sd_title, - user_name: user_name, + user_name: user_name, user_phone: user_phone, user_address: user_address, sd_desc: sd_desc, - state: state, - file_path:file_path}) + state: state, + file_path: file_path + }) }, header: { 'content-type': 'application/x-www-form-urlencoded', @@ -97,18 +95,24 @@ class SupplyDemand extends Component { }) .then(res => { console.log('上传供求', res) - if(res.data.err_msg==='success'){ - console.log(11111) - this.setState({ uploadDemSupTextTip: '上传成功', isUploadDemSupSuccess: true }, () => { + if (res.data.err_msg === 'success') { + Taro.showToast({ + title: '上传成功', + icon: 'success', + duration: 1500 + }).then(() => { setTimeout(() => { - this.setState({ isUploadDemSupSuccess: false }) Taro.navigateTo({ - url: '/pages/mySupplyDemand/mySupplyDemand' - }) - }, 2000) + url: '/pages/mySupplyDemand/mySupplyDemand' + }) + }, 1500); + }) + } else { + Taro.showToast({ + title: '上传失败', + icon: 'none', + duration: 1500 }) - }else{ - console.log('上传供求失败') } } @@ -125,7 +129,6 @@ class SupplyDemand extends Component { url: URL.UploadDSPorductImage, filePath: files[files.length - 1].url, name: 'file', - header: { 'content-type': 'multipart/form-data; boundary=----WebKitFormBoundaryAWxeadaAVmRVQCiz', 'Cookie': 'PFWSSS=' + Taro.getStorageSync('session_id'), @@ -136,23 +139,30 @@ class SupplyDemand 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: 1500 + }) } }) } 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) - }) - } + this.state.ImagesInfo.splice(index, 1) // 删除显示的图片 + this.state.pickerImageUrl.splice(index, 1)// 删除图片param + that.setState({ + pockerImageUrl:this.state.pickerImageUrl, + ImagesInfo:this.state.ImagesInfo, + }) + Taro.showToast({ + title: '删除成功', + icon: 'success', + duration: 1500 + }) + } } // 修改供求类型 demandingSupplyCate = e => { @@ -182,10 +192,10 @@ class SupplyDemand extends Component { contentChange(event) { this.setState({ content: event.target.value }) } - goToMyDemSupPage(){ + goToMyDemSupPage() { Taro.navigateTo({ - url: '/pages/mySupplyDemand/mySupplyDemand' - }) + url: '/pages/mySupplyDemand/mySupplyDemand' + }) } @@ -203,24 +213,12 @@ class SupplyDemand extends Component { componentDidHide() { } render() { - const imageUploadSuccessElement = - const demandSupplyUploadSuccessElement = + return ( - {/* 图片上传模态框 */} - {imageUploadSuccessElement} - {/* 商品发布模态框 */} - {demandSupplyUploadSuccessElement} - + + @@ -235,43 +233,43 @@ class SupplyDemand extends Component { * * * - *联系地址: + 联系地址: @@ -279,10 +277,10 @@ class SupplyDemand extends Component { *需求内容: @@ -293,12 +291,12 @@ class SupplyDemand extends Component { diff --git a/src/pages/supplyDemandView/supplyDemandView.js b/src/pages/supplyDemandView/supplyDemandView.js index a1cdf54..f021617 100644 --- a/src/pages/supplyDemandView/supplyDemandView.js +++ b/src/pages/supplyDemandView/supplyDemandView.js @@ -1,7 +1,10 @@ -//supplyDemandItemView import Taro, { Component } from '@tarojs/taro' -import { View } from '@tarojs/components' +import { View, Text, Image } from '@tarojs/components' +import { AtButton, AtIcon } from 'taro-ui' + +import URL from '../../serviceAPI.config' +import CopyrightComponent from '../../component/copyrightComponent/copyrightComponent' import './supplyDemandView.scss' @@ -9,28 +12,169 @@ import './supplyDemandView.scss' class SupplyDemandView extends Component { - config = { - navigationBarTitleText: '单独供求' + config = { + navigationBarTitleText: '供求查看' } - componentDidMount(){ - + constructor() { + super(...arguments) + this.state = { + demandingSupplyCate: [{name:'需求',id:'1'}, {name:'供求',id:'2'}, {name:'人才',id:'3'}], //供求类型选择 + type: '', + title: '', + browsing: '', + contactName: '', + contactNumber: '', + address: '', + content: '', + images: [], + } } - componentWillReceiveProps (nextProps) { + //获取商品信息api GetProductInfo + getSupplyDemandInfo() { + Taro.request({ + url: URL.GetSupplyDemandInfo, + method: 'GET', + dataType: 'json', + data: { + sdID: this.$router.params.sdId, + }, + header: { + 'content-type': 'application/x-www-form-urlencoded', + 'Cookie': 'PFWSSS=' + Taro.getStorageSync('session_id'), + 'X-Requested-With': 'XMLHttpRequest' + } + }) + .then(res => { + console.log('供求详情获取成功', res) + + + const selectedType=this.state.demandingSupplyCate.filter(item=> item.id===res.data.sdInfo.sd_type)[0].name + this.setState({ + type: selectedType, + title: res.data.sdInfo.sd_title, + browsing: res.data.sdInfo.browse_times, + contactName: res.data.sdInfo.user_name, + contactNumber: res.data.sdInfo.user_phone, + address: res.data.sdInfo.user_address, + content: res.data.sdInfo.sd_desc, + images: res.data.sdInfo.file_path, + }) + Taro.hideLoading() + } + ) + .catch(error => { + console.log('供求详情获取失败', error) + }) + } + goToSDPublishPage() { + Taro.navigateTo({ + url: '/pages/supplyDemandPublish/supplyDemandPublish',// 供求发布页面 + }) + } + goToSDEditPage() { + console.log('edit page') + // Taro.navigateTo({ + // url: 'pages/supplyDemandPublish/supplyDemandPublish',// 供求发布页面 + // }) + + } + goToMySDPage() { + Taro.navigateTo({ + url: '/pages/mySupplyDemand/mySupplyDemand',//我的供求页面 + }) + + } + deleteSD() { + console.log('删除供求') + } + + componentDidMount() { + Taro.showLoading({title:'加载中'}) + this.getSupplyDemandInfo() + } + componentWillReceiveProps(nextProps) { console.log(this.props, nextProps) } - componentWillUnmount () { } + componentWillUnmount() { } - componentDidShow () { } + componentDidShow() { } - componentDidHide () { } + componentDidHide() { } - render () { + render() { + const imageElementArray = this.state.images.map((item, index) => { + return + + + }) return ( - 单独供求 + + 供求类型: + {this.state.type} + + + 需求标题: + {this.state.title} + + + 浏览量: + {this.state.browsing} + + + 联系人: + {this.state.contactName} + + + 联系电话: + {this.state.contactNumber} + + + 联系地址: + {this.state.address} + + + 需求内容: + {this.state.content} + + + 需求图片: + + {imageElementArray} + + + + + + + + 新增 + + + + + 修改 + + + + + 我的供求 + + + + + 删除 + + + + + + ) } } diff --git a/src/pages/supplyDemandView/supplyDemandView.scss b/src/pages/supplyDemandView/supplyDemandView.scss index e69de29..8896bfc 100644 --- a/src/pages/supplyDemandView/supplyDemandView.scss +++ b/src/pages/supplyDemandView/supplyDemandView.scss @@ -0,0 +1,36 @@ +$themeColor:#FF7142; + +.SupplyDemandItemView{ + padding: 10px 20px; + font-size: 32rpx; + .box{ + margin-top: 35px; + } + .title{ + font-weight: bold + } + +} +.button-box{ + display: flex; + flex-wrap: nowrap; + flex-direction: row; + margin: 40px 0; + padding: 0 20px; + + .button{ + flex:1; + text-align: center; + // margin:2%; + // justify-content:center; + + .at-button--primary{ + background-color:$themeColor; + border:1PX solid $themeColor; + } + .button-a{ + background-color:#d9534f; + border:1PX solid #d9534f; + } + } +} \ No newline at end of file diff --git a/src/serviceAPI.config.js b/src/serviceAPI.config.js index 168084e..2bcfc0d 100644 --- a/src/serviceAPI.config.js +++ b/src/serviceAPI.config.js @@ -43,9 +43,10 @@ const URL = { // 我的供求页面接口Supply-myList SearchDemandSupply: LOCALURL + 'Supply-myList',// 搜索我的供求接口 DeleteDemandSupply: LOCALURL + 'Supply-delete',// 删除我的供求接口 + GetSupplyDemandInfo: LOCALURL + 'Supply-wxEditDeploy',// 获取单个供求信息 // 商品编辑页面 Goods-wxEditPhoneDeploy - GetProductInfo: LOCALURL + 'Goods-wxEditPhoneDeploy',// 获取商品信息 + GetProductInfo: LOCALURL + 'Goods-wxEditPhoneDeploy',// 获取单个商品信息 diff --git a/src/todo list.txt b/src/todo list.txt index 4112740..3824ff9 100644 --- a/src/todo list.txt +++ b/src/todo list.txt @@ -11,8 +11,7 @@ todo list: 行业分类--等待后台接口--搜索 二级联动-- 我的供求页面: - 我的供求查看页面 - 我的供求编辑页面--等待后台接口数据 + 我的商品列表页面 商品价格无法设定为数字 // 有bug @@ -20,8 +19,10 @@ todo list: 商品编辑页面 店铺分类--二级联动 - 接口问题: 优惠卷和询价 + +bug: 商品编辑 增加图片后 图片顺序乱了 + 我的商品 删除提示 \ No newline at end of file