diff --git a/src/component/goodsTypeInteractionComp/goodsTypeInteractionComp.js b/src/component/goodsTypeInteractionComp/goodsTypeInteractionComp.js index 8a75292..c621152 100644 --- a/src/component/goodsTypeInteractionComp/goodsTypeInteractionComp.js +++ b/src/component/goodsTypeInteractionComp/goodsTypeInteractionComp.js @@ -57,7 +57,10 @@ class GoodsTypeInteractionComp extends Component { }) // 用递归来整理无限层次的数据 } else { - console.log('商品分类请求没有成功', res) + Taro.showToast({ + title: res.data.err_msg, + icon: 'none' + }) } } ) diff --git a/src/component/shopTypeInteractionComp/shopTypeInteractionComp.js b/src/component/shopTypeInteractionComp/shopTypeInteractionComp.js index 927c66b..a15674e 100644 --- a/src/component/shopTypeInteractionComp/shopTypeInteractionComp.js +++ b/src/component/shopTypeInteractionComp/shopTypeInteractionComp.js @@ -28,7 +28,7 @@ class ShopTypeInteractionComp extends Component { method: 'POST', dataType: 'json', data: { - id: this.props.shopId + id: this.props.shopId, }, header: { 'content-type': 'application/x-www-form-urlencoded', @@ -41,16 +41,21 @@ class ShopTypeInteractionComp extends Component { // this.formatIndustryType(res.data.data) // this.formatIndustTypeInit(res.data.data) if (res.data.err_msg === 'success') { + if(res.data.data===null){ + return + } console.log('店铺分类目录', res) this.setState({ interactionMultiArray: this.recursionInteraction(res.data.data), initailMultiArray: this.recursionInitialized(res.data.data) }, () => { + + // this.passDataToParent(this.state.initailMultiArray) //返回初始选项在 在商品编辑页面 - // if(this.props.shopTypeId){ - // const foundData=this.findDataByShopTypeId(this.props.shopTypeId) - // this.passDataToParent(foundData) - // } + if(this.props.shopTypeId){ + const foundData=this.findDataByShopTypeId(this.props.shopTypeId) + this.passDataToParent(foundData) + } // console.log('联动数据', this.state.interactionMultiArray) // console.log('初始化数据', this.state.initailMultiArray) @@ -68,19 +73,20 @@ class ShopTypeInteractionComp extends Component { }) } findDataByShopTypeId() { - console.log('id', this.props.shopTypeId) + console.log('id', this.props.shopTypeId,this.state.initailMultiArray) + let result='' this.state.initailMultiArray.forEach(items => { items.forEach(item => { if (item.id === this.props.shopTypeId) { - return item + result =item } }) }) + return result } // 递归整理无限层联动数据 recursionInteraction(data) { - let parentArrayHolder = [] const keys = Object.keys(data) for (let key of keys) { @@ -148,16 +154,13 @@ class ShopTypeInteractionComp extends Component { componentDidMount() { - this.getShopTypeList(this.props.url) } // 当然父组件有新的props的 会从新渲染组件 componentWillReceiveProps(nextProps) { - // if (nextProps.shopTypeId) { - // const foundData = this.findDataByShopTypeId(nextProps.shopTypeId) - // this.passDataToParent(foundData) - // } + + } componentWillUnmount() { } diff --git a/src/pages/goodsPublish/goodsPublish.js b/src/pages/goodsPublish/goodsPublish.js index 41cf6da..e6cbf65 100644 --- a/src/pages/goodsPublish/goodsPublish.js +++ b/src/pages/goodsPublish/goodsPublish.js @@ -109,7 +109,7 @@ class GoodsPublish extends Component { }) } else if (this.state.isPublishAndAdd) { // 导航到发布页面 - Taro.navigateTo({ + Taro.reLaunch({ url: '/pages/goodsPublish/goodsPublish' }) } @@ -180,12 +180,12 @@ class GoodsPublish extends Component { 'X-Requested-With': 'XMLHttpRequest' }, success(response) { - const responseMsg = JSON.parse(response.data).err_msg - if (responseMsg === 'success' || responseMsg === 'duplicate') { - const data = JSON.parse(response.data) - const imagePath = URL.Base + data.file_path + const responseData = JSON.parse(response.data) + console.log('responseData',responseData) + if (responseData.err_code===0) { + const imagePath = URL.Base + responseData.file_path 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 }, () => { Taro.showToast({ title: '上传成功', @@ -193,15 +193,15 @@ class GoodsPublish extends Component { duration: 2000 }) }) - + } else { Taro.showToast({ - title: responseMsg, + title: responseData.err_msg, icon: 'none', duration: 1500 }) } - + } }) } diff --git a/src/pages/grabOrderPage/grabOrderPage.js b/src/pages/grabOrderPage/grabOrderPage.js index dae4500..153f262 100644 --- a/src/pages/grabOrderPage/grabOrderPage.js +++ b/src/pages/grabOrderPage/grabOrderPage.js @@ -159,7 +159,7 @@ class GrabOrderPage extends Component { } goToMyNeedsPage() { Taro.switchTab({ - url: '/pages/myNeedsPublish/myNeedsPublish' + url: '/pages/myNeeds/myNeeds' }) } goMyNeedEditPage() { @@ -200,7 +200,7 @@ class GrabOrderPage extends Component { duration: 1500 }) setTimeout(() => { - Taro.switchTab({ + Taro.reLaunch({ url: '/pages/myNeeds/myNeeds' }) }, 1500); diff --git a/src/pages/login/login.js b/src/pages/login/login.js index 227129c..7849a68 100644 --- a/src/pages/login/login.js +++ b/src/pages/login/login.js @@ -76,7 +76,7 @@ class Login extends Component { } else { Taro.showToast({ - title: res.data.err_msg, + title: res.data.msg, icon: 'none', duration: 2000 }) diff --git a/src/pages/myDemandSupplyEdit/myDemandSupplyEdit.js b/src/pages/myDemandSupplyEdit/myDemandSupplyEdit.js index 0ee144b..957ddfc 100644 --- a/src/pages/myDemandSupplyEdit/myDemandSupplyEdit.js +++ b/src/pages/myDemandSupplyEdit/myDemandSupplyEdit.js @@ -34,7 +34,6 @@ class MyDemandSupplyEdit extends Component { isFormCompleted: false, isConfirmWindow: false,// 删除提示框 demandSupplyId: '',// 供求id - isSave: false,//是否点击保存按钮 isSaveAndNew: false//是否点击保存新增按钮 @@ -128,24 +127,26 @@ class MyDemandSupplyEdit extends Component { .then(res => { console.log('上传供求', res) Taro.hideLoading() - if (res.data.err_msg === 'success') { + if (res.data.err_code === 0) { Taro.showToast({ - title: '保存成功', - icon: 'success', + title: res.data.err_msg == 'success' ? '保存成功' : res.data.err_msg, + icon: res.data.err_msg == 'success' ? 'success' : 'none', duration: 1000 }).then(() => { setTimeout(() => { - if (this.state.isSave) { - Taro.navigateTo({ - url: '/pages/myDemandSupplyEdit/myDemandSupplyEdit?sdId=' + res.data.sd_id - }) - } else if (this.state.isSaveAndNew) { - Taro.switchTab({ + console.log('this.state.isSaveAndNew', this.state.isSaveAndNew) + if (this.state.isSaveAndNew) { + Taro.reLaunch({ url: '/pages/supplyDemandPublish/supplyDemandPublish' }) + } else { + // Taro.navigateTo({ + // url: '/pages/myDemandSupplyEdit/myDemandSupplyEdit?sdId=' + res.data.sd_id + // }) } }, 1000); }) + } else { Taro.showToast({ title: res.data.err_msg, @@ -153,7 +154,6 @@ class MyDemandSupplyEdit extends Component { 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) { Taro.showLoading({ title: '保存中' }).then(() => { - this.setState({ isSave: true }, () => { + this.setState({ isSaveAndNew: false }, () => { this.uploadDemSup({}) }) }) @@ -395,7 +395,7 @@ class MyDemandSupplyEdit extends Component { - * + * 联系电话: diff --git a/src/pages/myGoodList/myGoodList.js b/src/pages/myGoodList/myGoodList.js index 4349a83..d13aefc 100644 --- a/src/pages/myGoodList/myGoodList.js +++ b/src/pages/myGoodList/myGoodList.js @@ -46,7 +46,6 @@ class MyGoodList extends Component { isOpenOffStockModal: false,// 是否显示下架模态框 isAddToList: false,// 是否下拉加载 如果是 就添加商品到我的商品列表 isShowTopNav: false,// 是否显示返回顶部按钮 - loadMorePageIndex: 1,//上拉加载页面数 } } @@ -87,23 +86,21 @@ class MyGoodList extends Component { 'X-Requested-With': 'XMLHttpRequest' } }).then(res => { - console.log('baobei', res) - const productCate = [{ name: '全部类目', id: '' }] - for (let item of res.data.goodsClass) { - productCate.push({ name: item.class_name, id: item.class_id }) + console.log('宝贝类目',res) + if (res.data.err_code != 10) { + const productCate = [{ name: '全部类目', id: '' }] + for (let item of res.data.goodsClass) { + productCate.push({ name: item.class_name, id: item.class_id }) + } + this.setState({ productCate: productCate }) + } else { + Taro.showToast({ + title: res.data.err_msg, + icon: 'none', + duration: 1500, + }) } - this.setState({ productCate: productCate }) - - }).catch(err => { - Taro.showToast({ - title: '获取宝贝类目失败', - icon: 'none', - duration: 1500, - - }) - }) - } // 获取我的商品列表接口api @@ -143,16 +140,15 @@ class MyGoodList extends Component { 'X-Requested-With': 'XMLHttpRequest' } }).then(res => { - if (res.statusCode === 200) { + const data = JSON.parse(res.data) + if (data.err_code != 10) { console.log('我的商品列表', JSON.parse(res.data)) - const data = JSON.parse(res.data) + Taro.hideLoading() - - if (data.goods.length) { + if (data.goodsCount != '0' && data.goods.length) { data.goods.forEach(item => { item.checked = false }); - if (this.state.isAddToList) { this.setState({ myGoodList: this.state.myGoodList.concat(data.goods) }, () => { this.setState({ isAddToList: false }) @@ -162,17 +158,26 @@ class MyGoodList extends Component { myGoodList: data.goods, myGoodListTotal: data.goodsCount }) - } } else { - this.setState({ isAddToList: false }) - Taro.showToast({ - title: '没有更多了', - icon: 'none' - }) + if (data.goods === null) { + this.setState({ + myGoodList: [], + myGoodListTotal: data.goodsCount + }) + } else { + this.setState({ isAddToList: false }) + Taro.showToast({ + title: '没有更多了', + icon: 'none' + }) + } } } else { - console.log('我的商品列表获取失败') + Taro.showToast({ + title: data.err_msg, + icon: 'none' + }) } }) @@ -252,21 +257,24 @@ class MyGoodList extends Component { 'X-Requested-With': 'XMLHttpRequest' } }).then(res => { - if (res.statusCode === 200) { - Taro.showToast({ - title: '下架成功', - icon: 'success', - duration: 1500 - }).then(() => { - this.setState({ isCheckAll: false }) + let responseData = JSON.parse(res.data) + if (responseData.err_code === 0) { + + this.setState({ + isCheckAll: false, + currPageParam: 1, + + }, () => { this.getMyGoodListApi({}) - + Taro.showToast({ + title: '下架成功', + icon: 'success', + duration: 1500 + }) }) - - } else { Taro.showToast({ - title: '下架失败', + title: responseData.err_msg, icon: 'none', duration: 1500 }) @@ -294,21 +302,19 @@ class MyGoodList extends Component { 'X-Requested-With': 'XMLHttpRequest' } }).then(res => { - if (res.statusCode === 200) { - console.log('商品删除返回', res) + let responseData = JSON.parse(res.data) + if (responseData.err_code === 0) { Taro.showToast({ title: '删除成功', icon: 'success', duration: 1500 }).then(() => { - - this.setState({ isCheckAll: false }) + this.setState({ isCheckAll: false, currPageParam: 1 }) this.getMyGoodListApi({}) - }) } else { Taro.showToast({ - title: '删除失败', + title: responseData.err_msg, icon: 'none', duration: 1500 }) @@ -316,6 +322,7 @@ class MyGoodList extends Component { } + }) } @@ -328,7 +335,7 @@ class MyGoodList extends Component { Taro.showLoading({ title: '加载中', }) - this.setState({ currPageParam: 1, isCheckAll: false,order:'' }, () => { + this.setState({ currPageParam: 1, isCheckAll: false, order: '' }, () => { this.getMyGoodListApi({}) }) } @@ -346,7 +353,7 @@ class MyGoodList extends Component { maximumSold: '', productId: '', productCateSelected: { id: '', name: '全部类目' }, - order:'', + order: '', }, () => { this.getMyGoodListApi({}) Taro.showToast({ @@ -521,7 +528,7 @@ class MyGoodList extends Component { // 导航到商品发布页面 goToGoodsPublishPage() { - Taro.navigateTo({ + Taro.switchTab({ url: '/pages/goodsPublish/goodsPublish' }) } @@ -580,7 +587,9 @@ class MyGoodList extends Component { componentWillUnmount() { } - componentDidShow() { } + componentDidShow() { + + } componentDidHide() { } // 页面位置 @@ -776,13 +785,13 @@ class MyGoodList extends Component { - - - + {this.state.myGoodList.length ? {goodListElementArray} - + : 没有更多了} {this.state.isShowTopNav ? : null} + + ) diff --git a/src/pages/myGoodsEdit/myGoodsEdit.js b/src/pages/myGoodsEdit/myGoodsEdit.js index 2dc0584..258471a 100644 --- a/src/pages/myGoodsEdit/myGoodsEdit.js +++ b/src/pages/myGoodsEdit/myGoodsEdit.js @@ -16,7 +16,7 @@ class MyGoodsEdit extends Component { super(...arguments) this.state = { shopTypeSelected: { name: '全部', id: '' }, - shopTypeId:'', + shopTypeId: '', shopTypeList: {},//店铺分类列表 productName: '', productPrice: '', @@ -90,7 +90,6 @@ class MyGoodsEdit extends Component { class_id = "10103", shop_class_id = "1930", goods_id = '123' }) { - console.log('上传函数1~~~~') // 上传图片的参数 const uploadProductGoodFileParams = [] if (this.state.ImagesInfo.length) { @@ -115,7 +114,6 @@ class MyGoodsEdit extends Component { } else { alert('图片为空') } - console.log('上传函数~~~~') Taro.request({ url: URL.UploadProduct, @@ -143,35 +141,36 @@ class MyGoodsEdit extends Component { }) .then(res => { Taro.hideLoading() - Taro.showToast({ - title: '保存成功', - icon: 'success', - duration: 1000 - }).then(() => { - setTimeout(() => { - if (this.state.isSaveButton) { - Taro.navigateTo({ - url: '/pages/myGoodsEdit/myGoodsEdit?id=' + this.$router.params.id - }) - } else if (this.state.isSaveAndNewBUtton) { - Taro.navigateTo({ - url: '/pages/goodsPublish/goodsPublish' - }) - } - }, 1000); - }) - - console.log('上传商品', res) + + if (res.data.err_code === 0) { + Taro.showToast({ + title: '保存成功', + icon: 'success', + duration: 1500 + }).then(() => { + setTimeout(() => { + if (this.state.isSaveButton) { + // Taro.redirectTo({ + // url: '/pages/myGoodsEdit/myGoodsEdit?id=' + this.$router.params.id + // }) + } else if (this.state.isSaveAndNewBUtton) { + Taro.switchTab({ + url: '/pages/goodsPublish/goodsPublish' + }) + } + }, 1000); + }) + } else { + Taro.hideLoading() + Taro.showToast({ + title: res.data.err_msg, + icon: 'none', + duration: 1500 + }) + } } ) - .catch(error => { - Taro.hideLoading() - Taro.showToast({ - title: '保存失败', - icon: 'none', - duration: 1000 - }) - }) + } productNameChange(event) { this.setState({ @@ -335,6 +334,7 @@ class MyGoodsEdit extends Component { this.setState({ shopTypeSelected: value }) } + componentDidMount() { this.getGoodsInfo() } @@ -410,7 +410,7 @@ class MyGoodsEdit extends Component { {/* 店铺分类 */} 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 (res.data.err_code === 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 + } } - if (outter.class_id === classId) { - industryType.name = outter.class_name - industryType.id = outter.class_id - break + if (!Object.keys(industryType).length) { + industryType.name = '全部' + industryType.id = '-1' } + 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({ + 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: needsState, + pickerImageUrl: imageFile, + ImagesInfo: res.data.sdInfo.file_path, + }) + Taro.hideLoading() + } else { + Taro.showToast({ + title: res.data.err_msg, + icon: 'none' + }) } - if (!Object.keys(industryType).length) { - industryType.name = '全部' - industryType.id = '-1' - } - - - - 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({ - 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: needsState, - pickerImageUrl: imageFile, - ImagesInfo: res.data.sdInfo.file_path, - }) - Taro.hideLoading() } - ) - .catch(error => { - console.log('供求详情获取失败', error) - }) } @@ -156,34 +156,33 @@ class MyNeedsEdit extends Component { .then(res => { console.log('上传需求', res) Taro.hideLoading() - if (res.data.err_msg === 'success') { + + if (res.data.err_code === 0) { Taro.showToast({ - title: '保存成功', - icon: 'success', + title: res.data.err_msg === 'success' ? '保存成功' : res.data.err_msg, + icon: res.data.err_msg === 'success' ? 'success' : 'none', duration: 1500 }).then(() => { setTimeout(() => { - if (this.state.isSave) { + console.log('this.state.isSaveAndNew', this.state.isSaveAndNew) + if (this.state.isSaveAndNew) { Taro.navigateTo({ - url: '/pages/myNeedsEdit/myNeedsEdit?id=' + this.state.sd_id - }) - } else if (this.state.isSaveAndNew) { - Taro.switchTab({ url: '/pages/myNeedsPublish/myNeedsPublish' }) + } else { + // Taro.navigateTo({ + // url: '/pages/myNeedsEdit/myNeedsEdit?id=' + this.state.sd_id + // }) } - }, 1500); }) - } else { Taro.showToast({ - title: res.data.err_msg, + title: '保存失败', icon: 'none', duration: 1500 }) } - } ) @@ -259,9 +258,10 @@ class MyNeedsEdit extends Component { duration: 1000 }) setTimeout(() => { - Taro.navigateTo({ - url: '/pages/myNeedsPublish/myNeedsPublish' + Taro.reLaunch({ + url: '/pages/myNeeds/myNeeds' }) + }, 1000); } else { Taro.showToast({ @@ -302,7 +302,7 @@ class MyNeedsEdit extends Component { this.setState({ content: event.target.value }) } goToMyNeedsPage() { - Taro.switchTab({ + Taro.reLaunch({ url: '/pages/myNeeds/myNeeds' }) } @@ -315,10 +315,9 @@ class MyNeedsEdit extends Component { Taro.showLoading({ title: '保存中' }) - this.setState({ isSave: true }, () => { + this.setState({ isSaveAndNew: false }, () => { this.uploadMyNeedsApi({}) }) - } else { Taro.showToast({ title: '请填写完表格', @@ -326,7 +325,6 @@ class MyNeedsEdit extends Component { duration: 1500 }) } - } // 保存新增按钮 saveAndNewButton() { @@ -447,7 +445,7 @@ class MyNeedsEdit extends Component { onInput={this.contactNumberChange.bind(this)} /> - + 联系地址: diff --git a/src/pages/myNeedsPublish/myNeedsPublish.js b/src/pages/myNeedsPublish/myNeedsPublish.js index 7c77081..75433d8 100644 --- a/src/pages/myNeedsPublish/myNeedsPublish.js +++ b/src/pages/myNeedsPublish/myNeedsPublish.js @@ -32,11 +32,8 @@ class MyNeedsPublish extends Component { content: '', pickerImageUrl: [], // 上传的图片 ImagesInfo: [],// 后台传回来的图片信息 - isPublish: false,//是否点击发布按钮 + isPublishAndNew: false,//是否点击发布新增按钮 - - - } } @@ -64,7 +61,6 @@ class MyNeedsPublish extends Component { action: 1, sdInfo: JSON.stringify({ class_id: this.state.industryTypeSelected.id, - sd_type: this.state.needsTypeSelected.id, sd_title: this.state.title, user_name: this.state.contactName, @@ -91,15 +87,16 @@ class MyNeedsPublish extends Component { duration: 1500 }).then(() => { setTimeout(() => { - if (this.state.isPublish) { + if (this.state.isPublishAndNew) { Taro.navigateTo({ - url: '/pages/myNeedsEdit/myNeedsEdit?id=' + res.data.sd_id + url: '/pages/myNeedsPublish/myNeedsPublish' }) - } else if (this.state.isPublishAndNew) { + } else { Taro.navigateTo({ - url: '/pages/myNeedsPublish/myNeedsPublish' + url: '/pages/myNeedsEdit/myNeedsEdit?id=' + res.data.sd_id }) - } + } + }, 1500); }) @@ -184,8 +181,8 @@ class MyNeedsPublish extends Component { contactNameChange(event) { this.setState({ contactName: event }) } - contactNumberChange(event) { - this.setState({ contactNumber: event }) + contactNumberChange(e) { + this.setState({ contactNumber: e.detail.value }) } contactAddressChange(event) { this.setState({ contactAddress: event.target.value }) @@ -203,7 +200,7 @@ class MyNeedsPublish extends Component { Taro.showLoading({ title: '发布中' }) - this.setState({ isPublish: true }, () => { + this.setState({ isPublishAndNew: false }, () => { this.uploadMyNeedsApi({}) }) @@ -241,7 +238,7 @@ class MyNeedsPublish extends Component { } goToMyNeedsPage() { - Taro.switchTab({ + Taro.reLaunch({ url: '/pages/myNeeds/myNeeds' }) } diff --git a/src/pages/mySupplyDemand/mySupplyDemand.js b/src/pages/mySupplyDemand/mySupplyDemand.js index 1aeec7b..709c1c9 100644 --- a/src/pages/mySupplyDemand/mySupplyDemand.js +++ b/src/pages/mySupplyDemand/mySupplyDemand.js @@ -160,7 +160,7 @@ class MySupplyDemand extends Component { // 新增我的供求 addDemandSupply() { - Taro.switchTab({ + Taro.reLaunch({ url: '/pages/supplyDemandPublish/supplyDemandPublish' }) } diff --git a/src/pages/supplyDemandPublish/supplyDemandPublish.js b/src/pages/supplyDemandPublish/supplyDemandPublish.js index 349dcc3..23233bd 100644 --- a/src/pages/supplyDemandPublish/supplyDemandPublish.js +++ b/src/pages/supplyDemandPublish/supplyDemandPublish.js @@ -30,8 +30,8 @@ class SupplyDemand extends Component { content: '', pickerImageUrl: [], // 上传的图片 ImagesInfo: [],// 后台传回来的图片信息 - isPublish: false,//是否点击发布按钮 - isPublishAndNew: false,//是否点击发布新增按钮 + isPublishAndNew: false,//是否点击发布并新增按钮 + } } @@ -80,29 +80,28 @@ class SupplyDemand extends Component { .then(res => { console.log('上传供求', res) Taro.hideLoading() - if (res.data.err_msg === 'success') { + if (res.data.err_code === 0) { Taro.showToast({ - title: '上传成功', - icon: 'success', + title: res.data.err_msg == 'success' ? '上传成功' : res.data.err_msg, + icon: res.data.err_msg == 'success' ? 'success' : 'none', duration: 1000 }).then(() => { + console.log('this.state.isPublishAndNew', this.state.isPublishAndNew) setTimeout(() => { - if (this.state.isPublish) { + if (this.state.isPublishAndNew) { + Taro.reLaunch({ + url: '/pages/supplyDemandPublish/supplyDemandPublish' + }) + } else { Taro.navigateTo({ url: '/pages/myDemandSupplyEdit/myDemandSupplyEdit?sdId=' + res.data.sd_id }) - - } else if (this.state.isPublishAndNew) { - Taro.switchTab({ - url: '/pages/supplyDemandPublish/supplyDemandPublish' - }) } - }, 1000); }) } else { Taro.showToast({ - title: '上传失败', + title: res.data.err_msg, icon: 'none', 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) { Taro.showLoading({ title: '发布中' }).then(() => { - this.setState({ isPublish: true }, () => { + this.setState({ isPublishAndNew: false }, () => { this.uploadDemSup({}) }) }) @@ -270,12 +269,8 @@ class SupplyDemand extends Component { componentDidHide() { } render() { - - return ( - - diff --git a/src/pages/supplyDemandView/supplyDemandView.js b/src/pages/supplyDemandView/supplyDemandView.js index 1bca4a2..4ea1b7f 100644 --- a/src/pages/supplyDemandView/supplyDemandView.js +++ b/src/pages/supplyDemandView/supplyDemandView.js @@ -117,7 +117,7 @@ class SupplyDemandView extends Component { }) } goToSDPublishPage() { - Taro.switchTab({ + Taro.reLaunch({ url: '/pages/supplyDemandPublish/supplyDemandPublish',// 供求发布页面 }) } @@ -129,10 +129,9 @@ class SupplyDemandView extends Component { } goToMySDPage() { - Taro.switchTab({ + Taro.reLaunch({ url: '/pages/mySupplyDemand/mySupplyDemand',//我的供求页面 }) - } makeAPhoneCall(){ Taro.makePhoneCall({