diff --git a/src/component/interactionComponent/interactionComponent.js b/src/component/interactionComponent/interactionComponent.js index 9400ef9..35651b3 100644 --- a/src/component/interactionComponent/interactionComponent.js +++ b/src/component/interactionComponent/interactionComponent.js @@ -209,8 +209,10 @@ class Interaction extends Component { 行业分类: - {this.state.objectMultiArray[0] ? {this.state.objectMultiArray[0][this.state.multiIndex[0]].name} : null} - {this.state.objectMultiArray[1] ? {this.state.objectMultiArray[1][this.state.multiIndex[1]].name} : null} + + {this.props.selectedValue.name} + {/* {this.state.objectMultiArray[0] ? {this.state.objectMultiArray[0][this.state.multiIndex[0]].name} : null} + {this.state.objectMultiArray[1] ? {this.state.objectMultiArray[1][this.state.multiIndex[1]].name} : null} */} diff --git a/src/component/interactionComponent/interactionComponent.scss b/src/component/interactionComponent/interactionComponent.scss index 48488cb..3d7081f 100644 --- a/src/component/interactionComponent/interactionComponent.scss +++ b/src/component/interactionComponent/interactionComponent.scss @@ -10,9 +10,7 @@ margin-left: 20%; font-size: 32rpx } - .date{ - margin-left: 0% - } + .title-box{ line-height:100rpx; font-weight: bold; @@ -36,7 +34,6 @@ display: inline-block; margin-left: 10% } - } } } \ No newline at end of file diff --git a/src/component/shopTypeInteractionComp/shopTypeInteractionComp.js b/src/component/shopTypeInteractionComp/shopTypeInteractionComp.js index ec65749..2a5a189 100644 --- a/src/component/shopTypeInteractionComp/shopTypeInteractionComp.js +++ b/src/component/shopTypeInteractionComp/shopTypeInteractionComp.js @@ -6,6 +6,7 @@ import { View, Text } from '@tarojs/components' import { AtTabBar, Picker, AtButton } from 'taro-ui' import './shopTypeInteractionComp.scss' +import { throws } from 'assert'; class ShopTypeInteractionComp extends Component { @@ -229,10 +230,9 @@ class ShopTypeInteractionComp extends Component { * 店铺分类: - { this.props.initialType?this.props.initialType.name: this.state.objectMultiArray.length ? - {this.state.objectMultiArray[1][this.state.multiIndex[1]].name} : null} - - + + {this.props.selectedValue.name} + diff --git a/src/pages/goodsPublish/goodsPublish.js b/src/pages/goodsPublish/goodsPublish.js index d0b98bb..d63fe71 100644 --- a/src/pages/goodsPublish/goodsPublish.js +++ b/src/pages/goodsPublish/goodsPublish.js @@ -21,7 +21,6 @@ class GoodsPublish extends Component { this.state = { objectMultiArray: [ ], - multiIndex: [0, 0, 0], shopTypeSelected: { name: '选择店铺类型', id: '' },//已选的店铺分类 goodsTypeSelected: { name: '选择商品分类', id: '' },// 已选的商品分类 productName: '', diff --git a/src/pages/home/home.js b/src/pages/home/home.js index cdc81de..781646b 100644 --- a/src/pages/home/home.js +++ b/src/pages/home/home.js @@ -25,8 +25,8 @@ class Home extends Component { isOpen: false, // 抢单消息提示 grabOrderId: '',//抢到订单的id isMore: 'noMore',// 加载更多店铺 - userName:'',//用户名字 - userPhone:'',// 用户电话 + userName: '',//用户名字 + userPhone: '',// 用户电话 } } @@ -36,7 +36,7 @@ class Home extends Component { //api得到首页的信息 getHomeCategoriesInfo() { - + Taro.request({ url: URL.ShopWxStore, header: { @@ -45,14 +45,23 @@ class Home extends Component { }) .then(res => { console.log('首页基本信息', res) - this.setState({ - ads: res.data.data.adsLb, - categories: res.data.data.supplyClass, - demanding: res.data.data.demand.supplys, - otherData: res.data.otherData, - userName:res.data.otherData.userName, - userPhone:res.data.otherData.userPhone, - }) + if (res.data.err_msg === 'success') { + Taro.setStorageSync('user_identity', { username: res.data.otherData.userName, userphone: res.data.otherData.userPhone }) + this.setState({ + ads: res.data.data.adsLb, + categories: res.data.data.supplyClass, + demanding: res.data.data.demand.supplys, + otherData: res.data.otherData, + userName: res.data.otherData.userName, + userPhone: res.data.otherData.userPhone, + }) + } else { + Taro.showToast({ + title: res.data.err_msg, + icon: 'none', + duration: 1500 + }) + } }) } // api 得到推荐商店的信息 @@ -80,15 +89,26 @@ class Home extends Component { .then(res => { console.log('所有店铺的信息', res) Taro.hideLoading() - if (res.data.shops.length) { - this.setState({ shopsDetails: this.state.shopsDetails.concat(res.data.shops), isMore: 'more' }, () => { - }) + if (res.data.err_msg === 'success'){ + 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) + }) + } - } else { - this.setState({ isMore: 'noMore' }, () => { - console.log('ismore?', this.state.isMore) + }else{ + Taro.showToast({ + title: res.data.err_msg, + icon: 'none', + duration: 1500 }) + } + } ) @@ -98,6 +118,7 @@ class Home extends Component { async login() { Taro.login({ success(res) { + if (res.code) { // 发起网络请求 // console.log('手机端微信code:',res.code) @@ -113,12 +134,26 @@ class Home extends Component { } }) .then(response => { - console.log('微信登入成功', response) - //储存后台返回的session_id 到local Storage - Taro.setStorageSync('session_id', response.data.session_id) - Taro.setStorageSync('shopInfo', response.data.shop_info) - Taro.setStorageSync('userInfo', response.data.user_info) + if(response.data.err_msg==='success'){ + console.log('微信登入成功', response) + Taro.showToast({ + title:'登入成功', + icon:'success', + duration:1500 + }) + //储存后台返回的session_id 到local Storage + Taro.setStorageSync('session_id', response.data.session_id) + Taro.setStorageSync('shopInfo', response.data.shop_info) + Taro.setStorageSync('userInfo', response.data.user_info) + }else{ + Taro.showToast({ + title:'登入失败'+response.data.err_msg, + icon:'none', + duration:1500 + }) + } + } ).catch(err => { console.log('登入微信失败', err) @@ -170,11 +205,11 @@ class Home extends Component { }) .then(res => { Taro.showToast({ - title: res.data.err_msg==='success'?'抢单成功':res.data.err_msg, - icon:'none', - duration:1500 + title: res.data.err_msg === 'success' ? '抢单成功' : res.data.err_msg, + icon: 'none', + duration: 1500 }) - + console.log('抢单请求:', res) }) @@ -227,10 +262,10 @@ class Home extends Component { } // 导航去抢单页面 - goToGrabOrderPage(orderId){ + goToGrabOrderPage(orderId) { Taro.navigateTo({ - - url:'/pages/grabOrderPage/grabOrderPage?orderId='+orderId + + url: '/pages/grabOrderPage/grabOrderPage?orderId=' + orderId }) } componentDidMount() { @@ -277,24 +312,24 @@ class Home extends Component { - + const demandingElemensArray = this.state.demanding.length ? this.state.demanding.map((item, index) => { return - - - {item.class_name} - - - {item.sd_title} - - - {item.user_address || '无地址'} - - - 业主:{item.user_name} - + + + {item.class_name} + + + {item.sd_title} + + + {item.user_address || '无地址'} + + + 业主:{item.user_name} + @@ -335,7 +370,7 @@ class Home extends Component { return ( - + {/* 获取微信用户的信息 */} {/* 获取微信用户的信息 */} diff --git a/src/pages/home/home.scss b/src/pages/home/home.scss index 6a8ad19..d586c8f 100644 --- a/src/pages/home/home.scss +++ b/src/pages/home/home.scss @@ -65,7 +65,7 @@ $themeColor: #FF7142; } } .item-title{ - font-size: 50px; + font-size: 40px; min-height: 21px; clear: both; color: $themeColor; diff --git a/src/pages/index/index.js b/src/pages/index/index.js index cd42d6e..7bbf80f 100644 --- a/src/pages/index/index.js +++ b/src/pages/index/index.js @@ -33,9 +33,9 @@ class Index extends Component { // url: '/pages/myDemandSupplyEdit/myDemandSupplyEdit' // url: '/pages/mySupplyDemand/mySupplyDemand' // url:'/pages/grabOrderPage/grabOrderPage' - // url:'/pages/home/home' - // url:'/pages/myNeeds/myNeeds', - url:'/pages/myNeedsPublish/myNeedsPublish' + url:'/pages/home/home' + // url:'/pages/myNeeds/myNeeds', + //url:'/pages/myNeedsPublish/myNeedsPublish' // url:'/pages/goodsPublish/goodsPublish' diff --git a/src/pages/myGoodsEdit/myGoodsEdit.js b/src/pages/myGoodsEdit/myGoodsEdit.js index 349024e..9e4dd51 100644 --- a/src/pages/myGoodsEdit/myGoodsEdit.js +++ b/src/pages/myGoodsEdit/myGoodsEdit.js @@ -16,7 +16,7 @@ class MyGoodsEdit extends Component { constructor() { super(...arguments) this.state = { - shopTypeSelected:'', + shopTypeSelected:{name:'全部',id:''}, shopTypeList: {},//店铺分类列表 productName: '', productPrice: '', @@ -271,7 +271,7 @@ class MyGoodsEdit extends Component { onClickUploadGoods() { - if (this.state.productName && this.state.productPrice && this.state.productUnit && this.state.ImagesInfo.length && this.state.shopCategoryCheckedPicker.id) { + if (this.state.productName && this.state.productPrice && this.state.productUnit && this.state.ImagesInfo.length && this.state.shopTypeSelected.id) { Taro.showLoading({ title: '保存中' }).then(() => { setTimeout(() => { this.uploadGoods({ @@ -380,7 +380,9 @@ class MyGoodsEdit extends Component { {/* 店铺分类 */} - + {/* 店铺分类结束 */} diff --git a/src/pages/myNeeds/myNeeds.js b/src/pages/myNeeds/myNeeds.js index e018e49..bc351c7 100644 --- a/src/pages/myNeeds/myNeeds.js +++ b/src/pages/myNeeds/myNeeds.js @@ -12,6 +12,7 @@ import './myNeeds.scss' class MyNeeds extends Component { + config = { navigationBarTitleText: '我的需求' } @@ -22,7 +23,7 @@ class MyNeeds extends Component { startDateSel: '', endDateSel: '', industryType: '', - industryTypeSelected: { name: '', id: '' }, + industryTypeSelected: { name: '全部', id: '-1' }, needsType: [{ name: '业主需求', id: '4' }, { name: '效果图', id: '5' }], needsTypeSelected: { name: '业主需求', id: '4' }, needsState: [ @@ -38,7 +39,6 @@ class MyNeeds extends Component { currentPage: 1, needsItem: '',// 确认框提示时 使用的供求名 isDeleteModal:false, - IndustryTypeList:[] } } @@ -183,19 +183,18 @@ class MyNeeds extends Component { needsStateSelected: this.state.needsState[e.detail.value] }) } - goToMyNeedsViewPage() { + goToMyNeedsViewPage(id) { Taro.navigateTo({ - url: '/pages/myNeedsView/myNeedsView' + url: '/pages/myNeedsView/myNeedsView?id='+id }) } - goToMyNeedsEditPage() { + goToMyNeedsEditPage(id) { Taro.navigateTo({ - url: '/pages/myNeedsEdit/myNeedsEdit' + url: '/pages/myNeedsEdit/myNeedsEdit?id='+id }) } deleteButton(item) { this.setState({isDeleteModal:true,needsItem:item}) - } handleWindowModCancel(){ this.setState({isDeleteModal:false}) @@ -326,9 +325,8 @@ class MyNeeds extends Component { - {/* 行业分类 */} {/* 行业分类开始 */} - + {/* 行业分类结束 */} {/* 需求类型 */} diff --git a/src/pages/myNeedsEdit/myNeedsEdit.js b/src/pages/myNeedsEdit/myNeedsEdit.js index 973ff24..65b5cb6 100644 --- a/src/pages/myNeedsEdit/myNeedsEdit.js +++ b/src/pages/myNeedsEdit/myNeedsEdit.js @@ -20,33 +20,33 @@ class MyNeedsEdit extends Component { constructor() { super(...arguments) this.state = { - needsType: [{ name: '业主需求', id: '4' }, { name: '效果图', id: '5' }],// 需要从后台api 获取 + + industryTypeSelected: '', + needsType: [{ name: '业主需求', id: '4' }, { name: '效果图', id: '5' }], needsTypeSelected: { name: '业主需求', id: '4' }, needsState: [ - { name: '全部', id: '' }, - { name: '作废', id: '0' } - , { name: '在用', id: '1' }, - { name: '设计中', id: '2' }, - { name: '已设计', id: '3' }],// 需要从后台api 获取 + { name: '作废', id: '0' }, + { name: '在用', id: '1' }, + ], + needsStateSelected: { name: '全部', id: '' }, title: '', - industryTypeSelected:'', - contactName: '', - contactNumber: '', + sd_id: '', //需求id + contactName: Taro.getStorageSync('user_identity').username, + contactNumber: Taro.getStorageSync('user_identity').userphone, contactAddress: '', - content: '', - pickerImageUrl: [], // 上传的图片 - ImagesInfo: [],// 后台传回来的图片信息 - isFormCompleted: false, + content: '',//描述 + pickerImageUrl: [], + ImagesInfo: '', } } - //获取商品信息api GetProductInfo - getSupplyDemandInfo() { + //获取需求信息api + getMyNeedEditInfo() { Taro.request({ - url: URL.GetSupplyDemandInfo, + url: URL.EditMyNeeds, method: 'GET', dataType: 'json', data: { - sdID: this.$router.params.sdId, + demandId: this.$router.params.id, }, header: { 'content-type': 'application/x-www-form-urlencoded', @@ -55,18 +55,43 @@ class MyNeedsEdit extends Component { } }) .then(res => { - console.log('供求详情获取成功', res) - const selectedType = this.state.demandingSupplyCate.filter(item => item.id == res.data.sdInfo.sd_type)[0] - const selectedState = this.state.needsState.filter(item => item.id == res.data.sdInfo.state)[0] + console.log('需求详情获取成功', res) + // const selectedType = this.state.demandingSupplyCate.filter(item => item.id == res.data.sdInfo.sd_type)[0] + // const selectedState = this.state.needsState.filter(item => item.id == res.data.sdInfo.state)[0] + let industryType = {} + const classId = res.data.sdInfo.class_id + for (let outter of res.data.supplyTree) { + if (outter.children) { + for (let inner of outter.children) { + if (inner.class_id === classId) { + industryType.name = inner.class_name + industryType.id = inner.class_id + break + } + } + } + if (outter.class_id === classId) { + industryType.name = outter.class_name + industryType.id = outter.class_id + break + } + } + + const needsType = this.state.needsType.filter(item => { + return item.id === res.data.sdInfo.sd_type + })[0] const imageFile = res.data.sdInfo.file_path.map(item => { return { url: URL.Base + item.file_path } }) + const needsState = this.state.needsState.filter(item => { + return item.id === res.data.sdInfo.state + })[0] this.setState({ - demandingSupplyCateSelected: selectedType, + sd_id: res.data.sdInfo.sd_id, + industryTypeSelected: industryType, + needsTypeSelected: needsType, 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, - needsStateSelected: selectedState, + needsStateSelected: needsState, pickerImageUrl: imageFile, ImagesInfo: res.data.sdInfo.file_path, }) @@ -79,44 +104,25 @@ class MyNeedsEdit extends Component { }) } - // 上传供求api - uploadSupplyDemand() { - if (this.state.demandingSupplyCateSelected && this.state.title && this.state.contactName && this.state.contactNumber && this.state.content && this.state.needsStateSelected) { - this.uploadDemSup({}) + // 上传需求按键 + uploadMyNeedsButton() { + if (this.state.title && + this.state.contactName + && this.state.contactNumber + && this.state.content && this.state.needsStateSelected) { + this.uploadMyNeedsApi({}) } else { - this.setState({ uploadDemSupTextTip: '请填写完表格', isUploadDemSupSuccess: true }, () => { - setTimeout(() => { - this.setState({ isUploadDemSupSuccess: false }) - }, 2000) + Taro.showToast({ + title: '请填写完表格', + icon: 'none', + duration: 1500 }) } - // Taro.request({ - // url: URL.UploadSupplyDemand, - // method: 'POST', - // dataType: 'json', - // data: { - // action: 1, - // sdInfo: JSON.stringify({ "sd_type": "2", "sd_title": "534523", "user_name": "杨夕兵", "user_phone": "18950295811", "user_address": "2342", "sd_desc": "42342", "state": "1", "file_path": [{ "file_name": "bg3.jpg", "file_size": "212678", "file_path": "Uploads/supply/user_27/201812/38bf91f30d215bbefb2686f2401217a6.jpg", "thumb_path": "Uploads/supply/user_27/201812/thumb/38bf91f30d215bbefb2686f2401217a6_200X200.jpg" }] }) - // }, - // header: { - // 'content-type': 'application/x-www-form-urlencoded', - // } - // }) - // .then(res => { - // console.log('上传供求', res) - // } - // ) } - // uploadDemSup 上传供求 的api - uploadDemSup({ sd_type = this.state.demandingSupplyCateSelected.id, - 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.needsStateSelected.id }) { + // uploadMyNeedsApi 上传需求 的api + uploadMyNeedsApi() { const file_path = []; this.state.ImagesInfo.forEach((item) => { @@ -128,21 +134,23 @@ class MyNeedsEdit extends Component { }) }) Taro.request({ - url: URL.UploadSupplyDemand, + url: URL.PublishMyNeed, 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 + class_id: this.state.industryTypeSelected.id, + sd_id: this.state.sd_id, + sd_type: this.state.needsTypeSelected.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.needsStateSelected.id, + file_path: file_path, + }) }, header: { @@ -152,18 +160,18 @@ class MyNeedsEdit extends Component { } }) .then(res => { - console.log('上传供求', res) + console.log('上传需求', res) if (res.data.err_msg === 'success') { Taro.showToast({ - title: '上传成功', + title: '保存成功', icon: 'success', duration: 1500 }).then(() => { - setTimeout(() => { - Taro.navigateTo({ - url: '/pages/mySupplyDemand/mySupplyDemand' - }) - }, 1500); + // setTimeout(() => { + // Taro.navigateTo({ + // // url: '/pages/mySupplyDemand/mySupplyDemand' + // }) + // }, 1500); }) } else { @@ -251,22 +259,22 @@ class MyNeedsEdit extends Component { contentChange(event) { this.setState({ content: event.target.value }) } - goToMyDemSupPage() { + goToMyNeedsPage() { Taro.navigateTo({ - url: '/pages/mySupplyDemand/mySupplyDemand' + url: '/pages/myNeeds/myNeeds' }) } - getDataFromChild(value){ - console.log('从子组件传回来的值',value) - this.setState({industryTypeSelected:value}) + getDataFromChild(value) { + console.log('从子组件传回来的值', value) + this.setState({ industryTypeSelected: value }) } componentDidMount() { - // console.log('this.$router.params.sdId',this.$router.params.sdId) - // Taro.showLoading({title:'加载中'}) - // this.getSupplyDemandInfo() + + Taro.showLoading({ title: '加载中' }) + this.getMyNeedEditInfo() } componentWillReceiveProps(nextProps) { console.log(this.props, nextProps) @@ -284,19 +292,8 @@ class MyNeedsEdit extends Component { {/* 行业分类 */} - - {/* - - - - - *行业分类: {this.state.demandingSupplyCateSelected.name} - + - - - - */} {/* 需求类型 */} @@ -395,14 +392,14 @@ class MyNeedsEdit extends Component { - + 保存 {/* 保存并新增 */} - + 我的需求 diff --git a/src/pages/myNeedsEdit/myNeedsEdit.scss b/src/pages/myNeedsEdit/myNeedsEdit.scss index cf285ad..c0cc8ab 100644 --- a/src/pages/myNeedsEdit/myNeedsEdit.scss +++ b/src/pages/myNeedsEdit/myNeedsEdit.scss @@ -66,7 +66,7 @@ $themeColor:#FF7142; } .selected{ display: inline-block; - margin-left: 20%; + margin-left: 17%; font-size: 32rpx } .input-box{ diff --git a/src/pages/myNeedsPublish/myNeedsPublish.js b/src/pages/myNeedsPublish/myNeedsPublish.js index 72138de..a98819d 100644 --- a/src/pages/myNeedsPublish/myNeedsPublish.js +++ b/src/pages/myNeedsPublish/myNeedsPublish.js @@ -32,20 +32,20 @@ class MyNeedsPublish extends Component { content: '', pickerImageUrl: [], // 上传的图片 ImagesInfo: [],// 后台传回来的图片信息 - isFormCompleted: false, + } } - // 上传供求api - uploadMyNeeds() { + // 上传需求api + uploadMyNeedsButton() { if (this.state.title && this.state.contactName && this.state.contactNumber && this.state.content && this.state.needsStateSelected) { - this.uploadMyNeeds({}) + this.uploadMyNeedsApi({}) } else { Taro.showToast({ title: '请填写完表格', @@ -60,7 +60,7 @@ class MyNeedsPublish extends Component { // uploadMyNeeds 上传供求 的api - uploadMyNeeds() { + uploadMyNeedsApi() { const file_path = []; this.state.ImagesInfo.forEach((item) => { @@ -235,6 +235,7 @@ class MyNeedsPublish extends Component { {/* 行业分类 */} {/* 需求类型 */} @@ -335,7 +336,7 @@ class MyNeedsPublish extends Component { - + 发布 {/* diff --git a/src/pages/myNeedsView/myNeedsView.js b/src/pages/myNeedsView/myNeedsView.js index e9c4839..cda47bb 100644 --- a/src/pages/myNeedsView/myNeedsView.js +++ b/src/pages/myNeedsView/myNeedsView.js @@ -1,7 +1,7 @@ import Taro, { Component } from '@tarojs/taro' -import { View, Text, Image } from '@tarojs/components' -import { AtButton, AtIcon } from 'taro-ui' +import { View, Text, Image,Button } from '@tarojs/components' +import { AtButton, AtIcon,AtModal,AtModalHeader, AtModalContent, AtModalAction } from 'taro-ui' import URL from '../../serviceAPI.config' import CopyrightComponent from '../../component/copyrightComponent/copyrightComponent' @@ -13,31 +13,39 @@ import './myNeedsView.scss' class SupplyDemandView extends Component { config = { - navigationBarTitleText: '供求查看' + navigationBarTitleText: '需求查看' } - constructor() { super(...arguments) this.state = { - demandingSupplyCate: [{name:'需求',id:'1'}, {name:'供求',id:'2'}, {name:'人才',id:'3'}], //供求类型选择 - type: '', + + industryTypeSelected: '', + needsType: [{ name: '业主需求', id: '4' }, { name: '效果图', id: '5' }], + needsTypeSelected: { name: '业主需求', id: '4' }, + needsState: [ + { name: '作废', id: '0' }, + { name: '在用', id: '1' }, + ], + needsStateSelected: { name: '全部', id: '' }, title: '', - browsing: '', + browsing:'', + sd_id: '', //需求id contactName: '', contactNumber: '', - address: '', - content: '', - images: [], + contactAddress: '', + content: '',//描述 + pickerImageUrl: [], + ImagesInfo: '', } } - //获取商品信息api GetProductInfo - getSupplyDemandInfo() { + //获取需求信息api + getSingleMyNeedInfo() { Taro.request({ - url: URL.GetSupplyDemandInfo, + url: URL.ViewMyNeeds,//EditMyNeeds method: 'GET', dataType: 'json', data: { - sdID: this.$router.params.sdId, + demandId: this.$router.params.id, }, header: { 'content-type': 'application/x-www-form-urlencoded', @@ -46,52 +54,132 @@ class SupplyDemandView extends Component { } }) .then(res => { - console.log('供求详情获取成功', res) + console.log('需求详情获取成功', res) + // const selectedType = this.state.demandingSupplyCate.filter(item => item.id == res.data.sdInfo.sd_type)[0] + // const selectedState = this.state.needsState.filter(item => item.id == res.data.sdInfo.state)[0] + Taro.hideLoading() + let industryType={} + const classId = res.data.sdInfo.class_id + for (let outter of res.data.supplyTree) { + if (outter.children) { + for (let inner of outter.children) { + if (inner.class_id === classId) { + industryType.name = inner.class_name + industryType.id = inner.class_id + break + } + } + } + if (outter.class_id === classId) { + industryType.name = outter.class_name + industryType.id = outter.class_id + break + } + } - - const selectedType=this.state.demandingSupplyCate.filter(item=> item.id===res.data.sdInfo.sd_type)[0].name + const needsType = this.state.needsType.filter(item => { + return item.id === res.data.sdInfo.sd_type + })[0] + const imageFile = res.data.sdInfo.file_path.map(item => { return { url: URL.Base + item.file_path } }) + const needsState = this.state.needsState.filter(item => { + return item.id === res.data.sdInfo.state + })[0] this.setState({ - type: selectedType, + sd_id:res.data.sdInfo.sd_id, + industryTypeSelected: industryType, + needsTypeSelected: needsType, title: res.data.sdInfo.sd_title, browsing: res.data.sdInfo.browse_times, contactName: res.data.sdInfo.user_name, contactNumber: res.data.sdInfo.user_phone, - address: res.data.sdInfo.user_address, + contactAddress: res.data.sdInfo.user_address, content: res.data.sdInfo.sd_desc, - images: res.data.sdInfo.file_path, + needsStateSelected: needsState, + pickerImageUrl: imageFile, + ImagesInfo: res.data.sdInfo.file_path, + isDeleteModal:false, + }) - Taro.hideLoading() + } + ) .catch(error => { console.log('供求详情获取失败', error) }) } - goToSDPublishPage() { + //删除我的需求 api DeleteMyNeeds + deleteMyNeeds({ demandId = 10 }) { + Taro.request({ + url: URL.DeleteMyNeeds, + method: 'POST', + dataType: 'json', + data: { + + demandId: demandId + + }, + header: { + 'Cookie': 'PFWSSS=' + Taro.getStorageSync('session_id'), + 'content-type': 'application/x-www-form-urlencoded', + 'X-Requested-With': 'XMLHttpRequest' + } + }).then(res => { + console.log('删除我的列表', res) + if (res.data.err_msg === "success") { + Taro.showToast({ + title: '删除成功', + icon: 'success', + duration: 1500 + }) + setTimeout(() => { + this.goToMyNeedsPage() + }, 1500); + } else { + Taro.showToast({ + title: res.data.err_msg, + icon: 'none', + duration: 1500 + }) + } + }) + + } + + goMyNeedsPublishPage() { Taro.navigateTo({ - url: '/pages/supplyDemandPublish/supplyDemandPublish',// 供求发布页面 + url: '/pages/myNeedsPublish/myNeedsPublish', }) } - goToSDEditPage() { + goMyNeedEditPage() { console.log('edit page') - // Taro.navigateTo({ - // url: 'pages/supplyDemandPublish/supplyDemandPublish',// 供求发布页面 - // }) - - } - goToMySDPage() { + console.log('id',this.state.sd_id) Taro.navigateTo({ - url: '/pages/mySupplyDemand/mySupplyDemand',//我的供求页面 + url: '/pages/myNeedsEdit/myNeedsEdit?id='+this.state.sd_id }) } - deleteSD() { - console.log('删除供求') + goToMyNeedsPage() { + + Taro.navigateTo({ + url: '/pages/myNeeds/myNeeds' + }) + + } + deleteButton() { + this.setState({isDeleteModal:true}) + } + handleWindowModCancel(){ + this.setState({isDeleteModal:false}) + } + handleWindowConfirm(){ + this.setState({isDeleteModal:false}) + this.deleteMyNeeds({ demandId: this.state.sd_id }) } componentDidMount() { - // Taro.showLoading({title:'加载中'}) - // this.getSupplyDemandInfo() + Taro.showLoading({title:'加载中'}) + this.getSingleMyNeedInfo() } componentWillReceiveProps(nextProps) { console.log(this.props, nextProps) @@ -104,12 +192,24 @@ class SupplyDemandView extends Component { componentDidHide() { } render() { + const deleteModalWindowElement= + 提示 + + 确认删除{this.state.needsItem.sd_title}? + + + + const imageArrayElement=this.state.ImagesInfo.map((item,index)=>{ + return + }) return ( + {/* 删除模态框 */} + {deleteModalWindowElement} 行业分类: - {this.state.type} + {this.state.industryTypeSelected.name} 需求标题: @@ -135,26 +235,32 @@ class SupplyDemandView extends Component { 业主需求内容: {this.state.content} + + 业主需求图片: + + {imageArrayElement} + + - + 新增 - + 我的需求 - + 修改 - + 删除 diff --git a/src/pages/myNeedsView/myNeedsView.scss b/src/pages/myNeedsView/myNeedsView.scss index 8896bfc..7600cfc 100644 --- a/src/pages/myNeedsView/myNeedsView.scss +++ b/src/pages/myNeedsView/myNeedsView.scss @@ -33,4 +33,10 @@ $themeColor:#FF7142; border:1PX solid #d9534f; } } -} \ No newline at end of file +} +.img-box{ + padding:20px; + .image{ + font-size: 0px + } +} diff --git a/src/pages/shop/shop.js b/src/pages/shop/shop.js index f411fbd..4930fce 100644 --- a/src/pages/shop/shop.js +++ b/src/pages/shop/shop.js @@ -1,6 +1,6 @@ import Taro, { Component } from '@tarojs/taro' import { View, Button, Text, Image } from '@tarojs/components' -import { AtTag, AtIcon, AtPagination, AtToast } from 'taro-ui' +import { AtTag, AtIcon, AtPagination, } from 'taro-ui' import URL from '../../serviceAPI.config' @@ -697,7 +697,6 @@ class Shop extends Component { - diff --git a/src/serviceAPI.config.js b/src/serviceAPI.config.js index dfed008..ac24665 100644 --- a/src/serviceAPI.config.js +++ b/src/serviceAPI.config.js @@ -56,7 +56,8 @@ const URL = { GetMyNeedsList: LOCALURL + 'Supply-userDemandList',// 获取我的需求列表 GetIndustryTypeList: LOCALURL + 'shop-getIndustryClass',// 获取行业分类筛选列表 DeleteMyNeeds: LOCALURL + 'Supply-deleteUserDemand',// 删除我的需求 - EditMyNeeds: LOCALURL + 'Supply-ajaxUserDemand'// 需求编辑 + EditMyNeeds: LOCALURL + 'Supply-ajaxUserDemand',// 需求编辑 + ViewMyNeeds: LOCALURL + 'supply-userDemandDetail'// 需求详情 }