我的需求编辑,查看

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 class='picker type'>
<View className='title-box'> <View className='title-box'>
<Text className='title'>行业分类</Text> <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>
</View> </View>
</Picker> </Picker>

View File

@ -10,9 +10,7 @@
margin-left: 20%; margin-left: 20%;
font-size: 32rpx font-size: 32rpx
} }
.date{
margin-left: 0%
}
.title-box{ .title-box{
line-height:100rpx; line-height:100rpx;
font-weight: bold; font-weight: bold;
@ -36,7 +34,6 @@
display: inline-block; display: inline-block;
margin-left: 10% margin-left: 10%
} }
} }
} }
} }

View File

@ -6,6 +6,7 @@ import { View, Text } from '@tarojs/components'
import { AtTabBar, Picker, AtButton } from 'taro-ui' import { AtTabBar, Picker, AtButton } from 'taro-ui'
import './shopTypeInteractionComp.scss' import './shopTypeInteractionComp.scss'
import { throws } from 'assert';
class ShopTypeInteractionComp extends Component { class ShopTypeInteractionComp extends Component {
@ -229,10 +230,9 @@ class ShopTypeInteractionComp extends Component {
<View className='title-box'> <View className='title-box'>
<Text className='require'>*</Text> <Text className='require'>*</Text>
<Text className='title'>店铺分类</Text> <Text className='title'>店铺分类</Text>
{ this.props.initialType?this.props.initialType.name: this.state.objectMultiArray.length ? <Text> <Text className='first-col'>
<Text className='second-col'> {this.state.objectMultiArray[1][this.state.multiIndex[1]].name}</Text></Text> : null} {this.props.selectedValue.name}
</Text>
</View> </View>
</View> </View>
</Picker> </Picker>

View File

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

View File

@ -25,8 +25,8 @@ class Home extends Component {
isOpen: false, // 抢单消息提示 isOpen: false, // 抢单消息提示
grabOrderId: '',//抢到订单的id grabOrderId: '',//抢到订单的id
isMore: 'noMore',// 加载更多店铺 isMore: 'noMore',// 加载更多店铺
userName:'',//用户名字 userName: '',//用户名字
userPhone:'',// 用户电话 userPhone: '',// 用户电话
} }
} }
@ -45,14 +45,23 @@ class Home extends Component {
}) })
.then(res => { .then(res => {
console.log('首页基本信息', res) console.log('首页基本信息', res)
this.setState({ if (res.data.err_msg === 'success') {
ads: res.data.data.adsLb, Taro.setStorageSync('user_identity', { username: res.data.otherData.userName, userphone: res.data.otherData.userPhone })
categories: res.data.data.supplyClass, this.setState({
demanding: res.data.data.demand.supplys, ads: res.data.data.adsLb,
otherData: res.data.otherData, categories: res.data.data.supplyClass,
userName:res.data.otherData.userName, demanding: res.data.data.demand.supplys,
userPhone:res.data.otherData.userPhone, 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 得到推荐商店的信息 // api 得到推荐商店的信息
@ -80,16 +89,27 @@ class Home extends Component {
.then(res => { .then(res => {
console.log('所有店铺的信息', res) console.log('所有店铺的信息', res)
Taro.hideLoading() Taro.hideLoading()
if (res.data.shops.length) { if (res.data.err_msg === 'success'){
this.setState({ shopsDetails: this.state.shopsDetails.concat(res.data.shops), isMore: 'more' }, () => { 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{
Taro.showToast({
title: res.data.err_msg,
icon: 'none',
duration: 1500
}) })
} else {
this.setState({ isMore: 'noMore' }, () => {
console.log('ismore?', this.state.isMore)
})
} }
} }
) )
} }
@ -98,6 +118,7 @@ class Home extends Component {
async login() { async login() {
Taro.login({ Taro.login({
success(res) { success(res) {
if (res.code) { if (res.code) {
// 发起网络请求 // 发起网络请求
// console.log('手机端微信code',res.code) // console.log('手机端微信code',res.code)
@ -113,11 +134,25 @@ class Home extends Component {
} }
}) })
.then(response => { .then(response => {
console.log('微信登入成功', response) if(response.data.err_msg==='success'){
//储存后台返回的session_id 到local Storage console.log('微信登入成功', response)
Taro.setStorageSync('session_id', response.data.session_id) Taro.showToast({
Taro.setStorageSync('shopInfo', response.data.shop_info) title:'登入成功',
Taro.setStorageSync('userInfo', response.data.user_info) 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 => { ).catch(err => {
@ -170,9 +205,9 @@ class Home extends Component {
}) })
.then(res => { .then(res => {
Taro.showToast({ Taro.showToast({
title: res.data.err_msg==='success'?'抢单成功':res.data.err_msg, title: res.data.err_msg === 'success' ? '抢单成功' : res.data.err_msg,
icon:'none', icon: 'none',
duration:1500 duration: 1500
}) })
console.log('抢单请求:', res) console.log('抢单请求:', res)
@ -227,10 +262,10 @@ class Home extends Component {
} }
// 导航去抢单页面 // 导航去抢单页面
goToGrabOrderPage(orderId){ goToGrabOrderPage(orderId) {
Taro.navigateTo({ Taro.navigateTo({
url:'/pages/grabOrderPage/grabOrderPage?orderId='+orderId url: '/pages/grabOrderPage/grabOrderPage?orderId=' + orderId
}) })
} }
componentDidMount() { componentDidMount() {
@ -282,19 +317,19 @@ class Home extends Component {
const demandingElemensArray = this.state.demanding.length ? this.state.demanding.map((item, index) => { const demandingElemensArray = this.state.demanding.length ? this.state.demanding.map((item, index) => {
return <SwiperItem key={index} > return <SwiperItem key={index} >
<View className='demanding-item' > <View className='demanding-item' >
<View onClick={this.goToGrabOrderPage.bind(this,item.sd_id)}> <View onClick={this.goToGrabOrderPage.bind(this, item.sd_id)}>
<View className='item-tag'> <View className='item-tag'>
<Text className='item-tag-text'> {item.class_name}</Text> <Text className='item-tag-text'> {item.class_name}</Text>
</View> </View>
<View className='item-title'> <View className='item-title'>
{item.sd_title} {item.sd_title}
</View> </View>
<View className='item-address'> <View className='item-address'>
{item.user_address || '无地址'} {item.user_address || '无地址'}
</View> </View>
<View className='item-name'> <View className='item-name'>
业主{item.user_name} 业主{item.user_name}
</View> </View>
</View> </View>
<View className='item-button-box' onClick={this.grabOrderId.bind(this, item.sd_id)}> <View className='item-button-box' onClick={this.grabOrderId.bind(this, item.sd_id)}>
<Button className='item-button' > {item.state_name === '在用' ? '抢单' : '已抢单'}</Button> <Button className='item-button' > {item.state_name === '在用' ? '抢单' : '已抢单'}</Button>

View File

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

View File

@ -33,9 +33,9 @@ class Index extends Component {
// url: '/pages/myDemandSupplyEdit/myDemandSupplyEdit' // url: '/pages/myDemandSupplyEdit/myDemandSupplyEdit'
// url: '/pages/mySupplyDemand/mySupplyDemand' // url: '/pages/mySupplyDemand/mySupplyDemand'
// url:'/pages/grabOrderPage/grabOrderPage' // url:'/pages/grabOrderPage/grabOrderPage'
// url:'/pages/home/home' url:'/pages/home/home'
// url:'/pages/myNeeds/myNeeds', // url:'/pages/myNeeds/myNeeds',
url:'/pages/myNeedsPublish/myNeedsPublish' //url:'/pages/myNeedsPublish/myNeedsPublish'
// url:'/pages/goodsPublish/goodsPublish' // url:'/pages/goodsPublish/goodsPublish'

View File

@ -16,7 +16,7 @@ class MyGoodsEdit extends Component {
constructor() { constructor() {
super(...arguments) super(...arguments)
this.state = { this.state = {
shopTypeSelected:'', shopTypeSelected:{name:'全部',id:''},
shopTypeList: {},//店铺分类列表 shopTypeList: {},//店铺分类列表
productName: '', productName: '',
productPrice: '', productPrice: '',
@ -271,7 +271,7 @@ class MyGoodsEdit extends Component {
onClickUploadGoods() { 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(() => { Taro.showLoading({ title: '保存中' }).then(() => {
setTimeout(() => { setTimeout(() => {
this.uploadGoods({ this.uploadGoods({
@ -380,7 +380,9 @@ class MyGoodsEdit extends Component {
</View> </View>
</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 className='description-box'>

View File

@ -12,6 +12,7 @@ import './myNeeds.scss'
class MyNeeds extends Component { class MyNeeds extends Component {
config = { config = {
navigationBarTitleText: '我的需求' navigationBarTitleText: '我的需求'
} }
@ -22,7 +23,7 @@ class MyNeeds extends Component {
startDateSel: '', startDateSel: '',
endDateSel: '', endDateSel: '',
industryType: '', industryType: '',
industryTypeSelected: { name: '', id: '' }, industryTypeSelected: { name: '全部', id: '-1' },
needsType: [{ name: '业主需求', id: '4' }, { name: '效果图', id: '5' }], needsType: [{ name: '业主需求', id: '4' }, { name: '效果图', id: '5' }],
needsTypeSelected: { name: '业主需求', id: '4' }, needsTypeSelected: { name: '业主需求', id: '4' },
needsState: [ needsState: [
@ -38,7 +39,6 @@ class MyNeeds extends Component {
currentPage: 1, currentPage: 1,
needsItem: '',// 确认框提示时 使用的供求名 needsItem: '',// 确认框提示时 使用的供求名
isDeleteModal:false, isDeleteModal:false,
IndustryTypeList:[]
} }
} }
@ -183,19 +183,18 @@ class MyNeeds extends Component {
needsStateSelected: this.state.needsState[e.detail.value] needsStateSelected: this.state.needsState[e.detail.value]
}) })
} }
goToMyNeedsViewPage() { goToMyNeedsViewPage(id) {
Taro.navigateTo({ Taro.navigateTo({
url: '/pages/myNeedsView/myNeedsView' url: '/pages/myNeedsView/myNeedsView?id='+id
}) })
} }
goToMyNeedsEditPage() { goToMyNeedsEditPage(id) {
Taro.navigateTo({ Taro.navigateTo({
url: '/pages/myNeedsEdit/myNeedsEdit' url: '/pages/myNeedsEdit/myNeedsEdit?id='+id
}) })
} }
deleteButton(item) { deleteButton(item) {
this.setState({isDeleteModal:true,needsItem:item}) this.setState({isDeleteModal:true,needsItem:item})
} }
handleWindowModCancel(){ handleWindowModCancel(){
this.setState({isDeleteModal:false}) this.setState({isDeleteModal:false})
@ -326,9 +325,8 @@ class MyNeeds extends Component {
</View> </View>
</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 className='page-section'>

View File

@ -20,33 +20,33 @@ class MyNeedsEdit extends Component {
constructor() { constructor() {
super(...arguments) super(...arguments)
this.state = { this.state = {
needsType: [{ name: '业主需求', id: '4' }, { name: '效果图', id: '5' }],// 需要从后台api 获取
industryTypeSelected: '',
needsType: [{ name: '业主需求', id: '4' }, { name: '效果图', id: '5' }],
needsTypeSelected: { name: '业主需求', id: '4' }, needsTypeSelected: { name: '业主需求', id: '4' },
needsState: [ needsState: [
{ name: '全部', id: '' }, { name: '作废', id: '0' },
{ name: '作废', id: '0' } { name: '在用', id: '1' },
, { name: '在用', id: '1' }, ],
{ name: '设计中', id: '2' }, needsStateSelected: { name: '全部', id: '' },
{ name: '已设计', id: '3' }],// 需要从后台api 获取
title: '', title: '',
industryTypeSelected:'', sd_id: '', //需求id
contactName: '', contactName: Taro.getStorageSync('user_identity').username,
contactNumber: '', contactNumber: Taro.getStorageSync('user_identity').userphone,
contactAddress: '', contactAddress: '',
content: '', content: '',//描述
pickerImageUrl: [], // 上传的图片 pickerImageUrl: [],
ImagesInfo: [],// 后台传回来的图片信息 ImagesInfo: '',
isFormCompleted: false,
} }
} }
//获取商品信息api GetProductInfo //获取需求信息api
getSupplyDemandInfo() { getMyNeedEditInfo() {
Taro.request({ Taro.request({
url: URL.GetSupplyDemandInfo, url: URL.EditMyNeeds,
method: 'GET', method: 'GET',
dataType: 'json', dataType: 'json',
data: { data: {
sdID: this.$router.params.sdId, demandId: this.$router.params.id,
}, },
header: { header: {
'content-type': 'application/x-www-form-urlencoded', 'content-type': 'application/x-www-form-urlencoded',
@ -55,18 +55,43 @@ class MyNeedsEdit extends Component {
} }
}) })
.then(res => { .then(res => {
console.log('供求详情获取成功', res) console.log('需求详情获取成功', res)
const selectedType = this.state.demandingSupplyCate.filter(item => item.id == res.data.sdInfo.sd_type)[0] // const selectedType = this.state.demandingSupplyCate.filter(item => item.id == res.data.sdInfo.sd_type)[0]
const selectedState = this.state.needsState.filter(item => item.id == res.data.sdInfo.state)[0] // const selectedState = this.state.needsState.filter(item => item.id == res.data.sdInfo.state)[0]
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 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({ this.setState({
demandingSupplyCateSelected: selectedType, sd_id: res.data.sdInfo.sd_id,
industryTypeSelected: industryType,
needsTypeSelected: needsType,
title: res.data.sdInfo.sd_title, title: res.data.sdInfo.sd_title,
contactName: res.data.sdInfo.user_name,
contactNumber: res.data.sdInfo.user_phone,
contactAddress: res.data.sdInfo.user_address, contactAddress: res.data.sdInfo.user_address,
content: res.data.sdInfo.sd_desc, content: res.data.sdInfo.sd_desc,
needsStateSelected: selectedState, needsStateSelected: needsState,
pickerImageUrl: imageFile, pickerImageUrl: imageFile,
ImagesInfo: res.data.sdInfo.file_path, ImagesInfo: res.data.sdInfo.file_path,
}) })
@ -79,44 +104,25 @@ class MyNeedsEdit extends Component {
}) })
} }
// 上传供求api // 上传需求按键
uploadSupplyDemand() { uploadMyNeedsButton() {
if (this.state.demandingSupplyCateSelected && this.state.title && this.state.contactName && this.state.contactNumber && this.state.content && this.state.needsStateSelected) { if (this.state.title &&
this.uploadDemSup({}) this.state.contactName
&& this.state.contactNumber
&& this.state.content && this.state.needsStateSelected) {
this.uploadMyNeedsApi({})
} else { } else {
this.setState({ uploadDemSupTextTip: '请填写完表格', isUploadDemSupSuccess: true }, () => { Taro.showToast({
setTimeout(() => { title: '请填写完表格',
this.setState({ isUploadDemSupSuccess: false }) icon: 'none',
}, 2000) 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 // uploadMyNeedsApi 上传需求 的api
uploadDemSup({ sd_type = this.state.demandingSupplyCateSelected.id, uploadMyNeedsApi() {
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 }) {
const file_path = []; const file_path = [];
this.state.ImagesInfo.forEach((item) => { this.state.ImagesInfo.forEach((item) => {
@ -128,21 +134,23 @@ class MyNeedsEdit extends Component {
}) })
}) })
Taro.request({ Taro.request({
url: URL.UploadSupplyDemand, url: URL.PublishMyNeed,
method: 'POST', method: 'POST',
dataType: 'json', dataType: 'json',
data: { data: {
action: 2, action: 2,
sdInfo: JSON.stringify({ sdInfo: JSON.stringify({
sd_id: this.$router.params.sdId, class_id: this.state.industryTypeSelected.id,
sd_type: sd_type, sd_id: this.state.sd_id,
sd_title: sd_title, sd_type: this.state.needsTypeSelected.id,
user_name: user_name, sd_title: this.state.title,
user_phone: user_phone, user_name: this.state.contactName,
user_address: user_address, user_phone: this.state.contactNumber,
sd_desc: sd_desc, user_address: this.state.contactAddress,
state: state, sd_desc: this.state.content,
file_path: file_path state: this.state.needsStateSelected.id,
file_path: file_path,
}) })
}, },
header: { header: {
@ -152,18 +160,18 @@ class MyNeedsEdit extends Component {
} }
}) })
.then(res => { .then(res => {
console.log('上传求', res) console.log('上传求', res)
if (res.data.err_msg === 'success') { if (res.data.err_msg === 'success') {
Taro.showToast({ Taro.showToast({
title: '上传成功', title: '保存成功',
icon: 'success', icon: 'success',
duration: 1500 duration: 1500
}).then(() => { }).then(() => {
setTimeout(() => { // setTimeout(() => {
Taro.navigateTo({ // Taro.navigateTo({
url: '/pages/mySupplyDemand/mySupplyDemand' // // url: '/pages/mySupplyDemand/mySupplyDemand'
}) // })
}, 1500); // }, 1500);
}) })
} else { } else {
@ -251,22 +259,22 @@ class MyNeedsEdit extends Component {
contentChange(event) { contentChange(event) {
this.setState({ content: event.target.value }) this.setState({ content: event.target.value })
} }
goToMyDemSupPage() { goToMyNeedsPage() {
Taro.navigateTo({ Taro.navigateTo({
url: '/pages/mySupplyDemand/mySupplyDemand' url: '/pages/myNeeds/myNeeds'
}) })
} }
getDataFromChild(value){ getDataFromChild(value) {
console.log('从子组件传回来的值',value) console.log('从子组件传回来的值', value)
this.setState({industryTypeSelected:value}) this.setState({ industryTypeSelected: value })
} }
componentDidMount() { componentDidMount() {
// console.log('this.$router.params.sdId',this.$router.params.sdId)
// Taro.showLoading({title:'加载中'}) Taro.showLoading({ title: '加载中' })
// this.getSupplyDemandInfo() this.getMyNeedEditInfo()
} }
componentWillReceiveProps(nextProps) { componentWillReceiveProps(nextProps) {
console.log(this.props, nextProps) console.log(this.props, nextProps)
@ -284,19 +292,8 @@ class MyNeedsEdit extends Component {
<View className='supply-demand'> <View className='supply-demand'>
{/* 行业分类 */} {/* 行业分类 */}
<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>
<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>
</View>
</Picker>
</View>
</View> */}
{/* 需求类型 */} {/* 需求类型 */}
<View className='page-section'> <View className='page-section'>
<View> <View>
@ -395,14 +392,14 @@ class MyNeedsEdit extends Component {
</View> </View>
<View className='button-box'> <View className='button-box'>
<View className='button' onClick={this.uploadSupplyDemand.bind(this)}> <View className='button' onClick={this.uploadMyNeedsButton.bind(this)}>
<AtButton type='primary' size='small'>保存</AtButton> <AtButton type='primary' size='small'>保存</AtButton>
</View> </View>
{/* <View className='button'> {/* <View className='button'>
<AtButton type='primary' className='button-a' size='small'>保存并新增</AtButton> <AtButton type='primary' className='button-a' size='small'>保存并新增</AtButton>
</View> */} </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> <AtButton type='primary' className='button-a' size='small'>我的需求</AtButton>
</View> </View>
</View> </View>

View File

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

View File

@ -32,20 +32,20 @@ class MyNeedsPublish extends Component {
content: '', content: '',
pickerImageUrl: [], // 上传的图片 pickerImageUrl: [], // 上传的图片
ImagesInfo: [],// 后台传回来的图片信息 ImagesInfo: [],// 后台传回来的图片信息
isFormCompleted: false,
} }
} }
// 上传求api // 上传求api
uploadMyNeeds() { uploadMyNeedsButton() {
if (this.state.title && if (this.state.title &&
this.state.contactName this.state.contactName
&& this.state.contactNumber && this.state.contactNumber
&& this.state.content && this.state.needsStateSelected) { && this.state.content && this.state.needsStateSelected) {
this.uploadMyNeeds({}) this.uploadMyNeedsApi({})
} else { } else {
Taro.showToast({ Taro.showToast({
title: '请填写完表格', title: '请填写完表格',
@ -60,7 +60,7 @@ class MyNeedsPublish extends Component {
// uploadMyNeeds 上传供求 的api // uploadMyNeeds 上传供求 的api
uploadMyNeeds() { uploadMyNeedsApi() {
const file_path = []; const file_path = [];
this.state.ImagesInfo.forEach((item) => { this.state.ImagesInfo.forEach((item) => {
@ -235,6 +235,7 @@ class MyNeedsPublish extends Component {
{/* 行业分类 */} {/* 行业分类 */}
<InteractionComponent url={URL.GetIndustryTypeList} <InteractionComponent url={URL.GetIndustryTypeList}
onPassDataToChild={this.getDataFromChild.bind(this)} onPassDataToChild={this.getDataFromChild.bind(this)}
selectedValue={this.state.industryTypeSelected}
></InteractionComponent> ></InteractionComponent>
{/* 需求类型 */} {/* 需求类型 */}
<View className='page-section'> <View className='page-section'>
@ -335,7 +336,7 @@ class MyNeedsPublish extends Component {
</View> </View>
<View className='button-box'> <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> <AtButton type='primary' size='small'>发布</AtButton>
</View> </View>
{/* <View className='button'> {/* <View className='button'>

View File

@ -1,7 +1,7 @@
import Taro, { Component } from '@tarojs/taro' import Taro, { Component } from '@tarojs/taro'
import { View, Text, Image } from '@tarojs/components' import { View, Text, Image,Button } from '@tarojs/components'
import { AtButton, AtIcon } from 'taro-ui' import { AtButton, AtIcon,AtModal,AtModalHeader, AtModalContent, AtModalAction } from 'taro-ui'
import URL from '../../serviceAPI.config' import URL from '../../serviceAPI.config'
import CopyrightComponent from '../../component/copyrightComponent/copyrightComponent' import CopyrightComponent from '../../component/copyrightComponent/copyrightComponent'
@ -13,31 +13,39 @@ import './myNeedsView.scss'
class SupplyDemandView extends Component { class SupplyDemandView extends Component {
config = { config = {
navigationBarTitleText: '求查看' navigationBarTitleText: '求查看'
} }
constructor() { constructor() {
super(...arguments) super(...arguments)
this.state = { 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: '', title: '',
browsing: '', browsing:'',
sd_id: '', //需求id
contactName: '', contactName: '',
contactNumber: '', contactNumber: '',
address: '', contactAddress: '',
content: '', content: '',//描述
images: [], pickerImageUrl: [],
ImagesInfo: '',
} }
} }
//获取商品信息api GetProductInfo //获取需求信息api
getSupplyDemandInfo() { getSingleMyNeedInfo() {
Taro.request({ Taro.request({
url: URL.GetSupplyDemandInfo, url: URL.ViewMyNeeds,//EditMyNeeds
method: 'GET', method: 'GET',
dataType: 'json', dataType: 'json',
data: { data: {
sdID: this.$router.params.sdId, demandId: this.$router.params.id,
}, },
header: { header: {
'content-type': 'application/x-www-form-urlencoded', 'content-type': 'application/x-www-form-urlencoded',
@ -46,52 +54,132 @@ class SupplyDemandView extends Component {
} }
}) })
.then(res => { .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 needsType = this.state.needsType.filter(item => {
const selectedType=this.state.demandingSupplyCate.filter(item=> item.id===res.data.sdInfo.sd_type)[0].name 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({ this.setState({
type: selectedType, sd_id:res.data.sdInfo.sd_id,
industryTypeSelected: industryType,
needsTypeSelected: needsType,
title: res.data.sdInfo.sd_title, title: res.data.sdInfo.sd_title,
browsing: res.data.sdInfo.browse_times, browsing: res.data.sdInfo.browse_times,
contactName: res.data.sdInfo.user_name, contactName: res.data.sdInfo.user_name,
contactNumber: res.data.sdInfo.user_phone, contactNumber: res.data.sdInfo.user_phone,
address: res.data.sdInfo.user_address, contactAddress: res.data.sdInfo.user_address,
content: res.data.sdInfo.sd_desc, 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 => { .catch(error => {
console.log('供求详情获取失败', 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({ Taro.navigateTo({
url: '/pages/supplyDemandPublish/supplyDemandPublish',// 供求发布页面 url: '/pages/myNeedsPublish/myNeedsPublish',
}) })
} }
goToSDEditPage() { goMyNeedEditPage() {
console.log('edit page') console.log('edit page')
// Taro.navigateTo({ console.log('id',this.state.sd_id)
// url: 'pages/supplyDemandPublish/supplyDemandPublish',// 供求发布页面
// })
}
goToMySDPage() {
Taro.navigateTo({ Taro.navigateTo({
url: '/pages/mySupplyDemand/mySupplyDemand',//我的供求页面 url: '/pages/myNeedsEdit/myNeedsEdit?id='+this.state.sd_id
}) })
} }
deleteSD() { goToMyNeedsPage() {
console.log('删除供求')
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() { componentDidMount() {
// Taro.showLoading({title:'加载中'}) Taro.showLoading({title:'加载中'})
// this.getSupplyDemandInfo() this.getSingleMyNeedInfo()
} }
componentWillReceiveProps(nextProps) { componentWillReceiveProps(nextProps) {
console.log(this.props, nextProps) console.log(this.props, nextProps)
@ -104,12 +192,24 @@ class SupplyDemandView extends Component {
componentDidHide() { } componentDidHide() { }
render() { render() {
const deleteModalWindowElement= <AtModal isOpened={this.state.isDeleteModal}>
<AtModalHeader>提示</AtModalHeader>
<AtModalContent>
确认删除{this.state.needsItem.sd_title}
</AtModalContent>
<AtModalAction> <Button onClick={this.handleWindowModCancel.bind(this)}>取消</Button> <Button className='orange' onClick={this.handleWindowConfirm.bind(this)}></Button> </AtModalAction>
</AtModal>
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 ( return (
<View className='SupplyDemandItemView'> <View className='SupplyDemandItemView'>
{/* 删除模态框 */}
{deleteModalWindowElement}
<View className='type box'> <View className='type box'>
<Text className='title'>行业分类</Text> <Text className='title'>行业分类</Text>
<Text className='content'>{this.state.type}</Text> <Text className='content'>{this.state.industryTypeSelected.name}</Text>
</View> </View>
<View className='needed-title box'> <View className='needed-title box'>
<Text className='title'>需求标题</Text> <Text className='title'>需求标题</Text>
@ -135,26 +235,32 @@ class SupplyDemandView extends Component {
<Text className='title'>业主需求内容</Text> <Text className='title'>业主需求内容</Text>
<Text className='content'>{this.state.content}</Text> <Text className='content'>{this.state.content}</Text>
</View> </View>
<View className='needed-image box'>
<Text className='title'>业主需求图片</Text>
<View className='img-box'>
{imageArrayElement}
</View>
</View>
<View className='button-box'> <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'> <AtButton type='primary' size='small'>
<AtIcon value='add' size='12' color='white'></AtIcon> <AtIcon value='add' size='12' color='white'></AtIcon>
新增</AtButton> 新增</AtButton>
</View> </View>
<View className='button' onClick={this.goToMySDPage.bind(this)}> <View className='button' onClick={this.goToMyNeedsPage.bind(this)}>
<AtButton type='primary' className='button' size='small'> <AtButton type='primary' className='button' size='small'>
<AtIcon value='' size='12' color='white'></AtIcon> <AtIcon value='' size='12' color='white'></AtIcon>
我的需求</AtButton> 我的需求</AtButton>
</View> </View>
<View className='button' onClick={this.goToSDEditPage.bind(this)}> <View className='button' onClick={this.goMyNeedEditPage.bind(this)}>
<AtButton type='primary' className='button' size='small'> <AtButton type='primary' className='button' size='small'>
<AtIcon value='settings' size='12' color='white'></AtIcon> <AtIcon value='settings' size='12' color='white'></AtIcon>
修改</AtButton> 修改</AtButton>
</View> </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'> <AtButton type='primary' className='button-a' size='small'>
<AtIcon value='close' size='12' color='white'></AtIcon> <AtIcon value='close' size='12' color='white'></AtIcon>
删除</AtButton> 删除</AtButton>

View File

@ -34,3 +34,9 @@ $themeColor:#FF7142;
} }
} }
} }
.img-box{
padding:20px;
.image{
font-size: 0px
}
}

View File

@ -1,6 +1,6 @@
import Taro, { Component } from '@tarojs/taro' import Taro, { Component } from '@tarojs/taro'
import { View, Button, Text, Image } from '@tarojs/components' import { View, Button, Text, Image } from '@tarojs/components'
import { AtTag, AtIcon, AtPagination, AtToast } from 'taro-ui' import { AtTag, AtIcon, AtPagination, } from 'taro-ui'
import URL from '../../serviceAPI.config' 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 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> </View>

View File

@ -56,7 +56,8 @@ const URL = {
GetMyNeedsList: LOCALURL + 'Supply-userDemandList',// 获取我的需求列表 GetMyNeedsList: LOCALURL + 'Supply-userDemandList',// 获取我的需求列表
GetIndustryTypeList: LOCALURL + 'shop-getIndustryClass',// 获取行业分类筛选列表 GetIndustryTypeList: LOCALURL + 'shop-getIndustryClass',// 获取行业分类筛选列表
DeleteMyNeeds: LOCALURL + 'Supply-deleteUserDemand',// 删除我的需求 DeleteMyNeeds: LOCALURL + 'Supply-deleteUserDemand',// 删除我的需求
EditMyNeeds: LOCALURL + 'Supply-ajaxUserDemand'// 需求编辑 EditMyNeeds: LOCALURL + 'Supply-ajaxUserDemand',// 需求编辑
ViewMyNeeds: LOCALURL + 'supply-userDemandDetail'// 需求详情
} }