我的需求编辑,查看

This commit is contained in:
郑茂强 2019-01-08 17:33:52 +08:00
parent 6847b89697
commit 8f34d1416f
16 changed files with 360 additions and 217 deletions

View File

@ -209,8 +209,10 @@ class Interaction extends Component {
<View class='picker type'>
<View className='title-box'>
<Text className='title'>行业分类</Text>
{this.state.objectMultiArray[0] ? <Text className='first-col'> {this.state.objectMultiArray[0][this.state.multiIndex[0]].name}</Text> : null}
{this.state.objectMultiArray[1] ? <Text className='second-col'> {this.state.objectMultiArray[1][this.state.multiIndex[1]].name}</Text> : null}
<Text className='first-col'> {this.props.selectedValue.name}</Text>
{/* {this.state.objectMultiArray[0] ? <Text className='first-col'> {this.state.objectMultiArray[0][this.state.multiIndex[0]].name}</Text> : null}
{this.state.objectMultiArray[1] ? <Text className='second-col'> {this.state.objectMultiArray[1][this.state.multiIndex[1]].name}</Text> : null} */}
</View>
</View>
</Picker>

View File

@ -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%
}
}
}
}

View File

@ -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 {
<View className='title-box'>
<Text className='require'>*</Text>
<Text className='title'>店铺分类</Text>
{ this.props.initialType?this.props.initialType.name: this.state.objectMultiArray.length ? <Text>
<Text className='second-col'> {this.state.objectMultiArray[1][this.state.multiIndex[1]].name}</Text></Text> : null}
<Text className='first-col'>
{this.props.selectedValue.name}
</Text>
</View>
</View>
</Picker>

View File

@ -21,7 +21,6 @@ class GoodsPublish extends Component {
this.state = {
objectMultiArray: [
],
multiIndex: [0, 0, 0],
shopTypeSelected: { name: '选择店铺类型', id: '' },//已选的店铺分类
goodsTypeSelected: { name: '选择商品分类', id: '' },// 已选的商品分类
productName: '',

View File

@ -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 <SwiperItem key={index} >
<View className='demanding-item' >
<View onClick={this.goToGrabOrderPage.bind(this,item.sd_id)}>
<View className='item-tag'>
<Text className='item-tag-text'> {item.class_name}</Text>
</View>
<View className='item-title'>
{item.sd_title}
</View>
<View className='item-address'>
{item.user_address || '无地址'}
</View>
<View className='item-name'>
业主{item.user_name}
</View>
<View onClick={this.goToGrabOrderPage.bind(this, item.sd_id)}>
<View className='item-tag'>
<Text className='item-tag-text'> {item.class_name}</Text>
</View>
<View className='item-title'>
{item.sd_title}
</View>
<View className='item-address'>
{item.user_address || '无地址'}
</View>
<View className='item-name'>
业主{item.user_name}
</View>
</View>
<View className='item-button-box' onClick={this.grabOrderId.bind(this, item.sd_id)}>
<Button className='item-button' > {item.state_name === '在用' ? '抢单' : '已抢单'}</Button>
@ -335,7 +370,7 @@ class Home extends Component {
return (
<View className='home'>
{/* 获取微信用户的信息 */}
{/* <AtButton open-type='getUserInfo' lang='zh_CN' type='primary' size='normal' onGetUserInfo={this.onGotUserInfo.bind(this)}>获取微信用户的信息</AtButton> */}

View File

@ -65,7 +65,7 @@ $themeColor: #FF7142;
}
}
.item-title{
font-size: 50px;
font-size: 40px;
min-height: 21px;
clear: both;
color: $themeColor;

View File

@ -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'

View File

@ -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 {
</View>
</View>
{/* 店铺分类 */}
<ShopTypeInteractionComp url={URL.GetShopCategoryList} initialType={this.state.shopTypeSelected} onPassDataToChild={this.getDataFromShopChild.bind(this)}></ShopTypeInteractionComp>
<ShopTypeInteractionComp url={URL.GetShopCategoryList}
selectedValue={this.state.shopTypeSelected}
onPassDataToChild={this.getDataFromShopChild.bind(this)}></ShopTypeInteractionComp>
{/* 店铺分类结束 */}
<View className='description-box'>

View File

@ -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 {
</View>
</View>
{/* 行业分类 */}
{/* 行业分类开始 */}
<InteractionComponent url={URL.GetIndustryTypeList} onPassDataToChild={this.getDataFromChild.bind(this)}></InteractionComponent>
<InteractionComponent url={URL.GetIndustryTypeList} onPassDataToChild={this.getDataFromChild.bind(this)} selectedValue={this.state.industryTypeSelected}></InteractionComponent>
{/* 行业分类结束 */}
{/* 需求类型 */}
<View className='page-section'>

View File

@ -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 {
<View className='supply-demand'>
{/* 行业分类 */}
<InteractionComponent url={URL.GetIndustryTypeList} onPassDataToChild={this.getDataFromChild.bind(this)}></InteractionComponent>
{/* <View className='page-section'>
<View>
<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.name}</Text>
</View>
<InteractionComponent url={URL.GetIndustryTypeList} onPassDataToChild={this.getDataFromChild.bind(this)} selectedValue={this.state.industryTypeSelected} ></InteractionComponent>
</View>
</Picker>
</View>
</View> */}
{/* 需求类型 */}
<View className='page-section'>
<View>
@ -395,14 +392,14 @@ class MyNeedsEdit extends Component {
</View>
<View className='button-box'>
<View className='button' onClick={this.uploadSupplyDemand.bind(this)}>
<View className='button' onClick={this.uploadMyNeedsButton.bind(this)}>
<AtButton type='primary' size='small'>保存</AtButton>
</View>
{/* <View className='button'>
<AtButton type='primary' className='button-a' size='small'>保存并新增</AtButton>
</View> */}
<View className='button' onClick={this.goToMyDemSupPage.bind(this)}>
<View className='button' onClick={this.goToMyNeedsPage.bind(this)}>
<AtButton type='primary' className='button-a' size='small'>我的需求</AtButton>
</View>
</View>

View File

@ -66,7 +66,7 @@ $themeColor:#FF7142;
}
.selected{
display: inline-block;
margin-left: 20%;
margin-left: 17%;
font-size: 32rpx
}
.input-box{

View File

@ -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 {
{/* 行业分类 */}
<InteractionComponent url={URL.GetIndustryTypeList}
onPassDataToChild={this.getDataFromChild.bind(this)}
selectedValue={this.state.industryTypeSelected}
></InteractionComponent>
{/* 需求类型 */}
<View className='page-section'>
@ -335,7 +336,7 @@ class MyNeedsPublish extends Component {
</View>
<View className='button-box'>
<View className='button' onClick={this.uploadMyNeeds.bind(this)}>
<View className='button' onClick={this.uploadMyNeedsButton.bind(this)}>
<AtButton type='primary' size='small'>发布</AtButton>
</View>
{/* <View className='button'>

View File

@ -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= <AtModal isOpened={this.state.isDeleteModal}>
<AtModalHeader>提示</AtModalHeader>
<AtModalContent>
确认删除{this.state.needsItem.sd_title}
</AtModalContent>
<AtModalAction> <Button onClick={this.handleWindowModCancel.bind(this)}>取消</Button> <Button className='orange' onClick={this.handleWindowConfirm.bind(this)}></Button> </AtModalAction>
</AtModal>
const imageArrayElement=this.state.ImagesInfo.map((item,index)=>{
return <Image key={index} className='image' mode='widthFix' src={URL.Base + item.file_path} style='max-width: 100%; max-height:100%;' />
})
return (
<View className='SupplyDemandItemView'>
{/* 删除模态框 */}
{deleteModalWindowElement}
<View className='type box'>
<Text className='title'>行业分类</Text>
<Text className='content'>{this.state.type}</Text>
<Text className='content'>{this.state.industryTypeSelected.name}</Text>
</View>
<View className='needed-title box'>
<Text className='title'>需求标题</Text>
@ -135,26 +235,32 @@ class SupplyDemandView extends Component {
<Text className='title'>业主需求内容</Text>
<Text className='content'>{this.state.content}</Text>
</View>
<View className='needed-image box'>
<Text className='title'>业主需求图片</Text>
<View className='img-box'>
{imageArrayElement}
</View>
</View>
<View className='button-box'>
<View className='button' onClick={this.goToSDPublishPage.bind(this)}>
<View className='button' onClick={this.goMyNeedsPublishPage.bind(this)}>
<AtButton type='primary' size='small'>
<AtIcon value='add' size='12' color='white'></AtIcon>
新增</AtButton>
</View>
<View className='button' onClick={this.goToMySDPage.bind(this)}>
<View className='button' onClick={this.goToMyNeedsPage.bind(this)}>
<AtButton type='primary' className='button' size='small'>
<AtIcon value='' size='12' color='white'></AtIcon>
我的需求</AtButton>
</View>
<View className='button' onClick={this.goToSDEditPage.bind(this)}>
<View className='button' onClick={this.goMyNeedEditPage.bind(this)}>
<AtButton type='primary' className='button' size='small'>
<AtIcon value='settings' size='12' color='white'></AtIcon>
修改</AtButton>
</View>
<View className='button' onClick={this.deleteSD.bind(this)}>
<View className='button' onClick={this.deleteButton.bind(this)}>
<AtButton type='primary' className='button-a' size='small'>
<AtIcon value='close' size='12' color='white'></AtIcon>
删除</AtButton>

View File

@ -33,4 +33,10 @@ $themeColor:#FF7142;
border:1PX solid #d9534f;
}
}
}
}
.img-box{
padding:20px;
.image{
font-size: 0px
}
}

View File

@ -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 {
<View className='img-box'> <Image mode='aspectFit' src={URL.Base + 'Public/images/shop/bg_banner.png'} style='max-width: 100%; max-height:100%;' /></View>
<View className='img-box'> <Image mode='aspectFit' src={URL.Base + 'Public/images/shop/bg_banner.png'} style='max-width: 100%;max-height:100%;' /></View>
<View className='img-box'> <Image mode='aspectFit' src={URL.Base + 'Public/images/shop/bg_banner.png'} style='max-width: 100%;max-height:100%;' /></View>
</View>
</View>

View File

@ -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'// 需求详情
}