修改新用户登入后的就用户的数据还在

This commit is contained in:
郑茂强 2019-02-14 15:56:17 +08:00
parent 55644ac246
commit 04efa389b3
13 changed files with 229 additions and 225 deletions

View File

@ -57,7 +57,10 @@ class GoodsTypeInteractionComp extends Component {
}) // 用递归来整理无限层次的数据 }) // 用递归来整理无限层次的数据
} else { } else {
console.log('商品分类请求没有成功', res) Taro.showToast({
title: res.data.err_msg,
icon: 'none'
})
} }
} }
) )

View File

@ -28,7 +28,7 @@ class ShopTypeInteractionComp extends Component {
method: 'POST', method: 'POST',
dataType: 'json', dataType: 'json',
data: { data: {
id: this.props.shopId id: this.props.shopId,
}, },
header: { header: {
'content-type': 'application/x-www-form-urlencoded', 'content-type': 'application/x-www-form-urlencoded',
@ -41,16 +41,21 @@ class ShopTypeInteractionComp extends Component {
// this.formatIndustryType(res.data.data) // this.formatIndustryType(res.data.data)
// this.formatIndustTypeInit(res.data.data) // this.formatIndustTypeInit(res.data.data)
if (res.data.err_msg === 'success') { if (res.data.err_msg === 'success') {
if(res.data.data===null){
return
}
console.log('店铺分类目录', res) console.log('店铺分类目录', res)
this.setState({ this.setState({
interactionMultiArray: this.recursionInteraction(res.data.data), interactionMultiArray: this.recursionInteraction(res.data.data),
initailMultiArray: this.recursionInitialized(res.data.data) initailMultiArray: this.recursionInitialized(res.data.data)
}, () => { }, () => {
// this.passDataToParent(this.state.initailMultiArray)
//返回初始选项在 在商品编辑页面 //返回初始选项在 在商品编辑页面
// if(this.props.shopTypeId){ if(this.props.shopTypeId){
// const foundData=this.findDataByShopTypeId(this.props.shopTypeId) const foundData=this.findDataByShopTypeId(this.props.shopTypeId)
// this.passDataToParent(foundData) this.passDataToParent(foundData)
// } }
// console.log('联动数据', this.state.interactionMultiArray) // console.log('联动数据', this.state.interactionMultiArray)
// console.log('初始化数据', this.state.initailMultiArray) // console.log('初始化数据', this.state.initailMultiArray)
@ -68,19 +73,20 @@ class ShopTypeInteractionComp extends Component {
}) })
} }
findDataByShopTypeId() { findDataByShopTypeId() {
console.log('id', this.props.shopTypeId) console.log('id', this.props.shopTypeId,this.state.initailMultiArray)
let result=''
this.state.initailMultiArray.forEach(items => { this.state.initailMultiArray.forEach(items => {
items.forEach(item => { items.forEach(item => {
if (item.id === this.props.shopTypeId) { if (item.id === this.props.shopTypeId) {
return item result =item
} }
}) })
}) })
return result
} }
// 递归整理无限层联动数据 // 递归整理无限层联动数据
recursionInteraction(data) { recursionInteraction(data) {
let parentArrayHolder = [] let parentArrayHolder = []
const keys = Object.keys(data) const keys = Object.keys(data)
for (let key of keys) { for (let key of keys) {
@ -148,16 +154,13 @@ class ShopTypeInteractionComp extends Component {
componentDidMount() { componentDidMount() {
this.getShopTypeList(this.props.url) this.getShopTypeList(this.props.url)
} }
// 当然父组件有新的props的 会从新渲染组件 // 当然父组件有新的props的 会从新渲染组件
componentWillReceiveProps(nextProps) { componentWillReceiveProps(nextProps) {
// if (nextProps.shopTypeId) {
// const foundData = this.findDataByShopTypeId(nextProps.shopTypeId)
// this.passDataToParent(foundData)
// }
} }
componentWillUnmount() { } componentWillUnmount() { }

View File

@ -109,7 +109,7 @@ class GoodsPublish extends Component {
}) })
} else if (this.state.isPublishAndAdd) { } else if (this.state.isPublishAndAdd) {
// 导航到发布页面 // 导航到发布页面
Taro.navigateTo({ Taro.reLaunch({
url: '/pages/goodsPublish/goodsPublish' url: '/pages/goodsPublish/goodsPublish'
}) })
} }
@ -180,12 +180,12 @@ class GoodsPublish extends Component {
'X-Requested-With': 'XMLHttpRequest' 'X-Requested-With': 'XMLHttpRequest'
}, },
success(response) { success(response) {
const responseMsg = JSON.parse(response.data).err_msg const responseData = JSON.parse(response.data)
if (responseMsg === 'success' || responseMsg === 'duplicate') { console.log('responseData',responseData)
const data = JSON.parse(response.data) if (responseData.err_code===0) {
const imagePath = URL.Base + data.file_path const imagePath = URL.Base + responseData.file_path
const newPickerImageUrl = that.state.pickerImageUrl.concat({ url: imagePath }) const newPickerImageUrl = that.state.pickerImageUrl.concat({ url: imagePath })
const newImageInfo = that.state.ImagesInfo.concat(data) const newImageInfo = that.state.ImagesInfo.concat(responseData)
that.setState({ pickerImageUrl: newPickerImageUrl, ImagesInfo: newImageInfo }, () => { that.setState({ pickerImageUrl: newPickerImageUrl, ImagesInfo: newImageInfo }, () => {
Taro.showToast({ Taro.showToast({
title: '上传成功', title: '上传成功',
@ -196,7 +196,7 @@ class GoodsPublish extends Component {
} else { } else {
Taro.showToast({ Taro.showToast({
title: responseMsg, title: responseData.err_msg,
icon: 'none', icon: 'none',
duration: 1500 duration: 1500
}) })

View File

@ -159,7 +159,7 @@ class GrabOrderPage extends Component {
} }
goToMyNeedsPage() { goToMyNeedsPage() {
Taro.switchTab({ Taro.switchTab({
url: '/pages/myNeedsPublish/myNeedsPublish' url: '/pages/myNeeds/myNeeds'
}) })
} }
goMyNeedEditPage() { goMyNeedEditPage() {
@ -200,7 +200,7 @@ class GrabOrderPage extends Component {
duration: 1500 duration: 1500
}) })
setTimeout(() => { setTimeout(() => {
Taro.switchTab({ Taro.reLaunch({
url: '/pages/myNeeds/myNeeds' url: '/pages/myNeeds/myNeeds'
}) })
}, 1500); }, 1500);

View File

@ -76,7 +76,7 @@ class Login extends Component {
} else { } else {
Taro.showToast({ Taro.showToast({
title: res.data.err_msg, title: res.data.msg,
icon: 'none', icon: 'none',
duration: 2000 duration: 2000
}) })

View File

@ -34,7 +34,6 @@ class MyDemandSupplyEdit extends Component {
isFormCompleted: false, isFormCompleted: false,
isConfirmWindow: false,// 删除提示框 isConfirmWindow: false,// 删除提示框
demandSupplyId: '',// 供求id demandSupplyId: '',// 供求id
isSave: false,//是否点击保存按钮
isSaveAndNew: false//是否点击保存新增按钮 isSaveAndNew: false//是否点击保存新增按钮
@ -128,24 +127,26 @@ class MyDemandSupplyEdit extends Component {
.then(res => { .then(res => {
console.log('上传供求', res) console.log('上传供求', res)
Taro.hideLoading() Taro.hideLoading()
if (res.data.err_msg === 'success') { if (res.data.err_code === 0) {
Taro.showToast({ Taro.showToast({
title: '保存成功', title: res.data.err_msg == 'success' ? '保存成功' : res.data.err_msg,
icon: 'success', icon: res.data.err_msg == 'success' ? 'success' : 'none',
duration: 1000 duration: 1000
}).then(() => { }).then(() => {
setTimeout(() => { setTimeout(() => {
if (this.state.isSave) { console.log('this.state.isSaveAndNew', this.state.isSaveAndNew)
Taro.navigateTo({ if (this.state.isSaveAndNew) {
url: '/pages/myDemandSupplyEdit/myDemandSupplyEdit?sdId=' + res.data.sd_id Taro.reLaunch({
})
} else if (this.state.isSaveAndNew) {
Taro.switchTab({
url: '/pages/supplyDemandPublish/supplyDemandPublish' url: '/pages/supplyDemandPublish/supplyDemandPublish'
}) })
} else {
// Taro.navigateTo({
// url: '/pages/myDemandSupplyEdit/myDemandSupplyEdit?sdId=' + res.data.sd_id
// })
} }
}, 1000); }, 1000);
}) })
} else { } else {
Taro.showToast({ Taro.showToast({
title: res.data.err_msg, title: res.data.err_msg,
@ -153,7 +154,6 @@ class MyDemandSupplyEdit extends Component {
duration: 1500 duration: 1500
}) })
} }
} }
) )
@ -280,7 +280,7 @@ class MyDemandSupplyEdit extends Component {
if (this.state.demandingSupplyCateSelected && this.state.title && this.state.contactName && this.state.contactNumber && this.state.content && this.state.demandingSupplyStateSelected) { if (this.state.demandingSupplyCateSelected && this.state.title && this.state.contactName && this.state.contactNumber && this.state.content && this.state.demandingSupplyStateSelected) {
Taro.showLoading({ title: '保存中' }).then(() => { Taro.showLoading({ title: '保存中' }).then(() => {
this.setState({ isSave: true }, () => { this.setState({ isSaveAndNew: false }, () => {
this.uploadDemSup({}) this.uploadDemSup({})
}) })
}) })

View File

@ -46,7 +46,6 @@ class MyGoodList extends Component {
isOpenOffStockModal: false,// 是否显示下架模态框 isOpenOffStockModal: false,// 是否显示下架模态框
isAddToList: false,// 是否下拉加载 如果是 就添加商品到我的商品列表 isAddToList: false,// 是否下拉加载 如果是 就添加商品到我的商品列表
isShowTopNav: false,// 是否显示返回顶部按钮 isShowTopNav: false,// 是否显示返回顶部按钮
loadMorePageIndex: 1,//上拉加载页面数
} }
} }
@ -87,23 +86,21 @@ class MyGoodList extends Component {
'X-Requested-With': 'XMLHttpRequest' 'X-Requested-With': 'XMLHttpRequest'
} }
}).then(res => { }).then(res => {
console.log('baobei', res) console.log('宝贝类目',res)
if (res.data.err_code != 10) {
const productCate = [{ name: '全部类目', id: '' }] const productCate = [{ name: '全部类目', id: '' }]
for (let item of res.data.goodsClass) { for (let item of res.data.goodsClass) {
productCate.push({ name: item.class_name, id: item.class_id }) productCate.push({ name: item.class_name, id: item.class_id })
} }
this.setState({ productCate: productCate }) this.setState({ productCate: productCate })
} else {
}).catch(err => {
Taro.showToast({ Taro.showToast({
title: '获取宝贝类目失败', title: res.data.err_msg,
icon: 'none', icon: 'none',
duration: 1500, duration: 1500,
}) })
}
}) })
} }
// 获取我的商品列表接口api // 获取我的商品列表接口api
@ -143,16 +140,15 @@ class MyGoodList extends Component {
'X-Requested-With': 'XMLHttpRequest' 'X-Requested-With': 'XMLHttpRequest'
} }
}).then(res => { }).then(res => {
if (res.statusCode === 200) {
console.log('我的商品列表', JSON.parse(res.data))
const data = JSON.parse(res.data) const data = JSON.parse(res.data)
Taro.hideLoading() if (data.err_code != 10) {
console.log('我的商品列表', JSON.parse(res.data))
if (data.goods.length) { Taro.hideLoading()
if (data.goodsCount != '0' && data.goods.length) {
data.goods.forEach(item => { data.goods.forEach(item => {
item.checked = false item.checked = false
}); });
if (this.state.isAddToList) { if (this.state.isAddToList) {
this.setState({ myGoodList: this.state.myGoodList.concat(data.goods) }, () => { this.setState({ myGoodList: this.state.myGoodList.concat(data.goods) }, () => {
this.setState({ isAddToList: false }) this.setState({ isAddToList: false })
@ -162,8 +158,13 @@ class MyGoodList extends Component {
myGoodList: data.goods, myGoodList: data.goods,
myGoodListTotal: data.goodsCount myGoodListTotal: data.goodsCount
}) })
} }
} else {
if (data.goods === null) {
this.setState({
myGoodList: [],
myGoodListTotal: data.goodsCount
})
} else { } else {
this.setState({ isAddToList: false }) this.setState({ isAddToList: false })
Taro.showToast({ Taro.showToast({
@ -171,8 +172,12 @@ class MyGoodList extends Component {
icon: 'none' icon: 'none'
}) })
} }
}
} else { } else {
console.log('我的商品列表获取失败') Taro.showToast({
title: data.err_msg,
icon: 'none'
})
} }
}) })
@ -252,21 +257,24 @@ class MyGoodList extends Component {
'X-Requested-With': 'XMLHttpRequest' 'X-Requested-With': 'XMLHttpRequest'
} }
}).then(res => { }).then(res => {
if (res.statusCode === 200) { let responseData = JSON.parse(res.data)
if (responseData.err_code === 0) {
this.setState({
isCheckAll: false,
currPageParam: 1,
}, () => {
this.getMyGoodListApi({})
Taro.showToast({ Taro.showToast({
title: '下架成功', title: '下架成功',
icon: 'success', icon: 'success',
duration: 1500 duration: 1500
}).then(() => {
this.setState({ isCheckAll: false })
this.getMyGoodListApi({})
}) })
})
} else { } else {
Taro.showToast({ Taro.showToast({
title: '下架失败', title: responseData.err_msg,
icon: 'none', icon: 'none',
duration: 1500 duration: 1500
}) })
@ -294,21 +302,19 @@ class MyGoodList extends Component {
'X-Requested-With': 'XMLHttpRequest' 'X-Requested-With': 'XMLHttpRequest'
} }
}).then(res => { }).then(res => {
if (res.statusCode === 200) { let responseData = JSON.parse(res.data)
console.log('商品删除返回', res) if (responseData.err_code === 0) {
Taro.showToast({ Taro.showToast({
title: '删除成功', title: '删除成功',
icon: 'success', icon: 'success',
duration: 1500 duration: 1500
}).then(() => { }).then(() => {
this.setState({ isCheckAll: false, currPageParam: 1 })
this.setState({ isCheckAll: false })
this.getMyGoodListApi({}) this.getMyGoodListApi({})
}) })
} else { } else {
Taro.showToast({ Taro.showToast({
title: '删除失败', title: responseData.err_msg,
icon: 'none', icon: 'none',
duration: 1500 duration: 1500
}) })
@ -316,6 +322,7 @@ class MyGoodList extends Component {
} }
}) })
} }
@ -521,7 +528,7 @@ class MyGoodList extends Component {
// 导航到商品发布页面 // 导航到商品发布页面
goToGoodsPublishPage() { goToGoodsPublishPage() {
Taro.navigateTo({ Taro.switchTab({
url: '/pages/goodsPublish/goodsPublish' url: '/pages/goodsPublish/goodsPublish'
}) })
} }
@ -580,7 +587,9 @@ class MyGoodList extends Component {
componentWillUnmount() { } componentWillUnmount() { }
componentDidShow() { } componentDidShow() {
}
componentDidHide() { } componentDidHide() { }
// 页面位置 // 页面位置
@ -776,13 +785,13 @@ class MyGoodList extends Component {
</View> </View>
</View> </View>
</View> </View>
{this.state.myGoodList.length ? <View className='mygoodlist-container'>
<View className='mygoodlist-container'>
{goodListElementArray} {goodListElementArray}
</View > </View > : <View className='no-more-title'> </View>}
{this.state.isShowTopNav ? <ScrollToTopComponent ></ScrollToTopComponent> : null} {this.state.isShowTopNav ? <ScrollToTopComponent ></ScrollToTopComponent> : null}
<CopyrightComponent></CopyrightComponent> <CopyrightComponent></CopyrightComponent>
</View> </View>
) )

View File

@ -90,7 +90,6 @@ class MyGoodsEdit extends Component {
class_id = "10103", class_id = "10103",
shop_class_id = "1930", shop_class_id = "1930",
goods_id = '123' }) { goods_id = '123' }) {
console.log('上传函数1~~~~')
// 上传图片的参数 // 上传图片的参数
const uploadProductGoodFileParams = [] const uploadProductGoodFileParams = []
if (this.state.ImagesInfo.length) { if (this.state.ImagesInfo.length) {
@ -115,7 +114,6 @@ class MyGoodsEdit extends Component {
} else { } else {
alert('图片为空') alert('图片为空')
} }
console.log('上传函数~~~~')
Taro.request({ Taro.request({
url: URL.UploadProduct, url: URL.UploadProduct,
@ -143,36 +141,37 @@ class MyGoodsEdit extends Component {
}) })
.then(res => { .then(res => {
Taro.hideLoading() Taro.hideLoading()
if (res.data.err_code === 0) {
Taro.showToast({ Taro.showToast({
title: '保存成功', title: '保存成功',
icon: 'success', icon: 'success',
duration: 1000 duration: 1500
}).then(() => { }).then(() => {
setTimeout(() => { setTimeout(() => {
if (this.state.isSaveButton) { if (this.state.isSaveButton) {
Taro.navigateTo({ // Taro.redirectTo({
url: '/pages/myGoodsEdit/myGoodsEdit?id=' + this.$router.params.id // url: '/pages/myGoodsEdit/myGoodsEdit?id=' + this.$router.params.id
}) // })
} else if (this.state.isSaveAndNewBUtton) { } else if (this.state.isSaveAndNewBUtton) {
Taro.navigateTo({ Taro.switchTab({
url: '/pages/goodsPublish/goodsPublish' url: '/pages/goodsPublish/goodsPublish'
}) })
} }
}, 1000); }, 1000);
}) })
} else {
console.log('上传商品', res)
}
)
.catch(error => {
Taro.hideLoading() Taro.hideLoading()
Taro.showToast({ Taro.showToast({
title: '保存失败', title: res.data.err_msg,
icon: 'none', icon: 'none',
duration: 1000 duration: 1500
})
}) })
} }
}
)
}
productNameChange(event) { productNameChange(event) {
this.setState({ this.setState({
productName: event productName: event
@ -335,6 +334,7 @@ class MyGoodsEdit extends Component {
this.setState({ shopTypeSelected: value }) this.setState({ shopTypeSelected: value })
} }
componentDidMount() { componentDidMount() {
this.getGoodsInfo() this.getGoodsInfo()
} }
@ -410,7 +410,7 @@ class MyGoodsEdit extends Component {
{/* 店铺分类 */} {/* 店铺分类 */}
<ShopTypeInteractionComp url={URL.GetShopCategoryList} <ShopTypeInteractionComp url={URL.GetShopCategoryList}
shopId={Taro.getStorageSync('shopInfo').shop_id} shopId={Taro.getStorageSync('shopInfo').shop_id}
// selectedValue={this.state.shopTypeSelected} selectedValue={this.state.shopTypeSelected}
onPassDataToChild={this.getDataFromShopChild.bind(this)} onPassDataToChild={this.getDataFromShopChild.bind(this)}
shopTypeId={this.state.shopTypeId} shopTypeId={this.state.shopTypeId}

View File

@ -34,7 +34,7 @@ class MyNeedsEdit extends Component {
pickerImageUrl: [], pickerImageUrl: [],
ImagesInfo: '', ImagesInfo: '',
isDeleteModal: false,// 删除提示框 isDeleteModal: false,// 删除提示框
isSave: false,//是否点击保存按钮
isSaveAndNew: false,//是否点击保存新增按钮 isSaveAndNew: false,//是否点击保存新增按钮
@ -59,6 +59,7 @@ class MyNeedsEdit extends Component {
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]
if (res.data.err_code === 0) {
let industryType = {} let industryType = {}
const classId = res.data.sdInfo.class_id const classId = res.data.sdInfo.class_id
for (let outter of res.data.supplyTree) { for (let outter of res.data.supplyTree) {
@ -81,9 +82,6 @@ class MyNeedsEdit extends Component {
industryType.name = '全部' industryType.name = '全部'
industryType.id = '-1' industryType.id = '-1'
} }
const needsType = this.state.needsType.filter(item => { const needsType = this.state.needsType.filter(item => {
return item.id === res.data.sdInfo.sd_type return item.id === res.data.sdInfo.sd_type
})[0] })[0]
@ -105,13 +103,15 @@ class MyNeedsEdit extends Component {
ImagesInfo: res.data.sdInfo.file_path, ImagesInfo: res.data.sdInfo.file_path,
}) })
Taro.hideLoading() Taro.hideLoading()
} } else {
Taro.showToast({
) title: res.data.err_msg,
.catch(error => { icon: 'none'
console.log('供求详情获取失败', error)
}) })
} }
}
)
}
@ -156,34 +156,33 @@ class MyNeedsEdit extends Component {
.then(res => { .then(res => {
console.log('上传需求', res) console.log('上传需求', res)
Taro.hideLoading() Taro.hideLoading()
if (res.data.err_msg === 'success') {
if (res.data.err_code === 0) {
Taro.showToast({ Taro.showToast({
title: '保存成功', title: res.data.err_msg === 'success' ? '保存成功' : res.data.err_msg,
icon: 'success', icon: res.data.err_msg === 'success' ? 'success' : 'none',
duration: 1500 duration: 1500
}).then(() => { }).then(() => {
setTimeout(() => { setTimeout(() => {
if (this.state.isSave) { console.log('this.state.isSaveAndNew', this.state.isSaveAndNew)
if (this.state.isSaveAndNew) {
Taro.navigateTo({ Taro.navigateTo({
url: '/pages/myNeedsEdit/myNeedsEdit?id=' + this.state.sd_id
})
} else if (this.state.isSaveAndNew) {
Taro.switchTab({
url: '/pages/myNeedsPublish/myNeedsPublish' url: '/pages/myNeedsPublish/myNeedsPublish'
}) })
} else {
// Taro.navigateTo({
// url: '/pages/myNeedsEdit/myNeedsEdit?id=' + this.state.sd_id
// })
} }
}, 1500); }, 1500);
}) })
} else { } else {
Taro.showToast({ Taro.showToast({
title: res.data.err_msg, title: '保存失败',
icon: 'none', icon: 'none',
duration: 1500 duration: 1500
}) })
} }
} }
) )
@ -259,9 +258,10 @@ class MyNeedsEdit extends Component {
duration: 1000 duration: 1000
}) })
setTimeout(() => { setTimeout(() => {
Taro.navigateTo({ Taro.reLaunch({
url: '/pages/myNeedsPublish/myNeedsPublish' url: '/pages/myNeeds/myNeeds'
}) })
}, 1000); }, 1000);
} else { } else {
Taro.showToast({ Taro.showToast({
@ -302,7 +302,7 @@ class MyNeedsEdit extends Component {
this.setState({ content: event.target.value }) this.setState({ content: event.target.value })
} }
goToMyNeedsPage() { goToMyNeedsPage() {
Taro.switchTab({ Taro.reLaunch({
url: '/pages/myNeeds/myNeeds' url: '/pages/myNeeds/myNeeds'
}) })
} }
@ -315,10 +315,9 @@ class MyNeedsEdit extends Component {
Taro.showLoading({ Taro.showLoading({
title: '保存中' title: '保存中'
}) })
this.setState({ isSave: true }, () => { this.setState({ isSaveAndNew: false }, () => {
this.uploadMyNeedsApi({}) this.uploadMyNeedsApi({})
}) })
} else { } else {
Taro.showToast({ Taro.showToast({
title: '请填写完表格', title: '请填写完表格',
@ -326,7 +325,6 @@ class MyNeedsEdit extends Component {
duration: 1500 duration: 1500
}) })
} }
} }
// 保存新增按钮 // 保存新增按钮
saveAndNewButton() { saveAndNewButton() {

View File

@ -32,11 +32,8 @@ class MyNeedsPublish extends Component {
content: '', content: '',
pickerImageUrl: [], // 上传的图片 pickerImageUrl: [], // 上传的图片
ImagesInfo: [],// 后台传回来的图片信息 ImagesInfo: [],// 后台传回来的图片信息
isPublish: false,//是否点击发布按钮
isPublishAndNew: false,//是否点击发布新增按钮 isPublishAndNew: false,//是否点击发布新增按钮
} }
} }
@ -64,7 +61,6 @@ class MyNeedsPublish extends Component {
action: 1, action: 1,
sdInfo: JSON.stringify({ sdInfo: JSON.stringify({
class_id: this.state.industryTypeSelected.id, class_id: this.state.industryTypeSelected.id,
sd_type: this.state.needsTypeSelected.id, sd_type: this.state.needsTypeSelected.id,
sd_title: this.state.title, sd_title: this.state.title,
user_name: this.state.contactName, user_name: this.state.contactName,
@ -91,16 +87,17 @@ class MyNeedsPublish extends Component {
duration: 1500 duration: 1500
}).then(() => { }).then(() => {
setTimeout(() => { setTimeout(() => {
if (this.state.isPublish) { if (this.state.isPublishAndNew) {
Taro.navigateTo({
url: '/pages/myNeedsEdit/myNeedsEdit?id=' + res.data.sd_id
})
} else if (this.state.isPublishAndNew) {
Taro.navigateTo({ Taro.navigateTo({
url: '/pages/myNeedsPublish/myNeedsPublish' url: '/pages/myNeedsPublish/myNeedsPublish'
}) })
} else {
Taro.navigateTo({
url: '/pages/myNeedsEdit/myNeedsEdit?id=' + res.data.sd_id
})
} }
}, 1500); }, 1500);
}) })
@ -184,8 +181,8 @@ class MyNeedsPublish extends Component {
contactNameChange(event) { contactNameChange(event) {
this.setState({ contactName: event }) this.setState({ contactName: event })
} }
contactNumberChange(event) { contactNumberChange(e) {
this.setState({ contactNumber: event }) this.setState({ contactNumber: e.detail.value })
} }
contactAddressChange(event) { contactAddressChange(event) {
this.setState({ contactAddress: event.target.value }) this.setState({ contactAddress: event.target.value })
@ -203,7 +200,7 @@ class MyNeedsPublish extends Component {
Taro.showLoading({ Taro.showLoading({
title: '发布中' title: '发布中'
}) })
this.setState({ isPublish: true }, () => { this.setState({ isPublishAndNew: false }, () => {
this.uploadMyNeedsApi({}) this.uploadMyNeedsApi({})
}) })
@ -241,7 +238,7 @@ class MyNeedsPublish extends Component {
} }
goToMyNeedsPage() { goToMyNeedsPage() {
Taro.switchTab({ Taro.reLaunch({
url: '/pages/myNeeds/myNeeds' url: '/pages/myNeeds/myNeeds'
}) })
} }

View File

@ -160,7 +160,7 @@ class MySupplyDemand extends Component {
// 新增我的供求 // 新增我的供求
addDemandSupply() { addDemandSupply() {
Taro.switchTab({ Taro.reLaunch({
url: '/pages/supplyDemandPublish/supplyDemandPublish' url: '/pages/supplyDemandPublish/supplyDemandPublish'
}) })
} }

View File

@ -30,8 +30,8 @@ class SupplyDemand extends Component {
content: '', content: '',
pickerImageUrl: [], // 上传的图片 pickerImageUrl: [], // 上传的图片
ImagesInfo: [],// 后台传回来的图片信息 ImagesInfo: [],// 后台传回来的图片信息
isPublish: false,//是否点击发布按钮 isPublishAndNew: false,//是否点击发布并新增按钮
isPublishAndNew: false,//是否点击发布新增按钮
} }
} }
@ -80,29 +80,28 @@ class SupplyDemand extends Component {
.then(res => { .then(res => {
console.log('上传供求', res) console.log('上传供求', res)
Taro.hideLoading() Taro.hideLoading()
if (res.data.err_msg === 'success') { if (res.data.err_code === 0) {
Taro.showToast({ Taro.showToast({
title: '上传成功', title: res.data.err_msg == 'success' ? '上传成功' : res.data.err_msg,
icon: 'success', icon: res.data.err_msg == 'success' ? 'success' : 'none',
duration: 1000 duration: 1000
}).then(() => { }).then(() => {
console.log('this.state.isPublishAndNew', this.state.isPublishAndNew)
setTimeout(() => { setTimeout(() => {
if (this.state.isPublish) { if (this.state.isPublishAndNew) {
Taro.reLaunch({
url: '/pages/supplyDemandPublish/supplyDemandPublish'
})
} else {
Taro.navigateTo({ Taro.navigateTo({
url: '/pages/myDemandSupplyEdit/myDemandSupplyEdit?sdId=' + res.data.sd_id url: '/pages/myDemandSupplyEdit/myDemandSupplyEdit?sdId=' + res.data.sd_id
}) })
} else if (this.state.isPublishAndNew) {
Taro.switchTab({
url: '/pages/supplyDemandPublish/supplyDemandPublish'
})
} }
}, 1000); }, 1000);
}) })
} else { } else {
Taro.showToast({ Taro.showToast({
title: '上传失败', title: res.data.err_msg,
icon: 'none', icon: 'none',
duration: 1500 duration: 1500
}) })
@ -206,7 +205,7 @@ class SupplyDemand extends Component {
if (this.state.demandingSupplyCateSelected && this.state.title && this.state.contactName && this.state.contactNumber && this.state.content && this.state.demandingSupplyStateSelected) { if (this.state.demandingSupplyCateSelected && this.state.title && this.state.contactName && this.state.contactNumber && this.state.content && this.state.demandingSupplyStateSelected) {
Taro.showLoading({ title: '发布中' }).then(() => { Taro.showLoading({ title: '发布中' }).then(() => {
this.setState({ isPublish: true }, () => { this.setState({ isPublishAndNew: false }, () => {
this.uploadDemSup({}) this.uploadDemSup({})
}) })
}) })
@ -270,12 +269,8 @@ class SupplyDemand extends Component {
componentDidHide() { } componentDidHide() { }
render() { render() {
return ( return (
<View className='supply-demand'> <View className='supply-demand'>
<View className='page-section'> <View className='page-section'>
<View> <View>
<Picker mode='selector' rangeKey='name' range={this.state.demandingSupplyCate} onChange={this.demandingSupplyCate.bind(this)}> <Picker mode='selector' rangeKey='name' range={this.state.demandingSupplyCate} onChange={this.demandingSupplyCate.bind(this)}>

View File

@ -117,7 +117,7 @@ class SupplyDemandView extends Component {
}) })
} }
goToSDPublishPage() { goToSDPublishPage() {
Taro.switchTab({ Taro.reLaunch({
url: '/pages/supplyDemandPublish/supplyDemandPublish',// 供求发布页面 url: '/pages/supplyDemandPublish/supplyDemandPublish',// 供求发布页面
}) })
} }
@ -129,10 +129,9 @@ class SupplyDemandView extends Component {
} }
goToMySDPage() { goToMySDPage() {
Taro.switchTab({ Taro.reLaunch({
url: '/pages/mySupplyDemand/mySupplyDemand',//我的供求页面 url: '/pages/mySupplyDemand/mySupplyDemand',//我的供求页面
}) })
} }
makeAPhoneCall(){ makeAPhoneCall(){
Taro.makePhoneCall({ Taro.makePhoneCall({