From 55644ac2460de0e197236377b009f02321506d4f Mon Sep 17 00:00:00 2001 From: Maoqiang Zheng Date: Wed, 13 Feb 2019 18:05:21 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9switchtab=20=E5=90=8E?= =?UTF-8?q?=E6=8C=89=E9=94=AE=E6=97=A0=E6=95=88?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- project.config.json | 2 +- src/app.js | 2 +- .../shopTypeInteractionComp.js | 28 ++++-- src/pages/grabOrderPage/grabOrderPage.js | 97 ++++++++++++++++++- src/pages/grabOrderPage/grabOrderPage.scss | 11 +++ src/pages/login/login.js | 2 +- .../myDemandSupplyEdit/myDemandSupplyEdit.js | 4 +- src/pages/myGoodsEdit/myGoodsEdit.js | 73 ++++++++------ src/pages/myNeedsEdit/myNeedsEdit.js | 4 +- src/pages/myNeedsPublish/myNeedsPublish.js | 2 +- src/pages/mySupplyDemand/mySupplyDemand.js | 2 +- .../supplyDemandPublish.js | 50 ++++++---- .../supplyDemandView/supplyDemandView.js | 4 +- 13 files changed, 209 insertions(+), 72 deletions(-) diff --git a/project.config.json b/project.config.json index 9cc5472..4b2d9de 100644 --- a/project.config.json +++ b/project.config.json @@ -2,7 +2,7 @@ "miniprogramRoot": "./dist", "projectname": "cf-wx-app", "description": "cf-wx-app", - "appid": "touristappid", + "appid": "wx424f6c9c24717e53", "setting": { "urlCheck": true, "es6": false, diff --git a/src/app.js b/src/app.js index f655443..96898aa 100644 --- a/src/app.js +++ b/src/app.js @@ -81,7 +81,7 @@ class App extends Component { color: '#333', selectedColor: '#333', backgroundColor: '#fff', - borderStyle: '#ccc' + borderStyle: 'black' } diff --git a/src/component/shopTypeInteractionComp/shopTypeInteractionComp.js b/src/component/shopTypeInteractionComp/shopTypeInteractionComp.js index 875f982..927c66b 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', @@ -46,6 +46,12 @@ class ShopTypeInteractionComp extends Component { interactionMultiArray: this.recursionInteraction(res.data.data), initailMultiArray: this.recursionInitialized(res.data.data) }, () => { + //返回初始选项在 在商品编辑页面 + // if(this.props.shopTypeId){ + // const foundData=this.findDataByShopTypeId(this.props.shopTypeId) + // this.passDataToParent(foundData) + // } + // console.log('联动数据', this.state.interactionMultiArray) // console.log('初始化数据', this.state.initailMultiArray) // console.log('index初始化', this.state.multiIndex) @@ -61,8 +67,16 @@ class ShopTypeInteractionComp extends Component { console.log('店铺分类请求错误', error) }) } - - + findDataByShopTypeId() { + console.log('id', this.props.shopTypeId) + this.state.initailMultiArray.forEach(items => { + items.forEach(item => { + if (item.id === this.props.shopTypeId) { + return item + } + }) + }) + } // 递归整理无限层联动数据 recursionInteraction(data) { @@ -134,14 +148,16 @@ class ShopTypeInteractionComp extends Component { componentDidMount() { - - this.getShopTypeList(this.props.url) + 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/grabOrderPage/grabOrderPage.js b/src/pages/grabOrderPage/grabOrderPage.js index 44ff40d..dae4500 100644 --- a/src/pages/grabOrderPage/grabOrderPage.js +++ b/src/pages/grabOrderPage/grabOrderPage.js @@ -16,6 +16,7 @@ class GrabOrderPage extends Component { constructor() { super(...arguments); this.state = { + isShowRendering: false, type: '', title: '', browsing: '', @@ -28,7 +29,9 @@ class GrabOrderPage extends Component { grabOrderId: this.$router.params.orderId, stateId: '', stateName: '', - userId: '' + userId: '', + renderingImage: [], + isDeleteModal: false } } @@ -60,8 +63,8 @@ class GrabOrderPage extends Component { images: res.data.sdInfo.file_path, stateId: res.data.sdInfo.state, stateName: res.data.sdInfo.state_name, - userId: res.data.sdInfo.user_id - + userId: res.data.sdInfo.user_id, + renderingImage: res.data.sdInfo.render_pics || [] }) } ) @@ -111,6 +114,11 @@ class GrabOrderPage extends Component { }) } + showImageButton() { + this.setState({ + isShowRendering: true + }) + } callPhoneNumber() { Taro.makePhoneCall({ phoneNumber: this.state.contactNumber @@ -144,9 +152,85 @@ class GrabOrderPage extends Component { componentDidShow() { } componentDidHide() { } + goMyNeedsPublishPage() { + Taro.navigateTo({ + url: '/pages/myNeedsPublish/myNeedsPublish' + }) + } + goToMyNeedsPage() { + Taro.switchTab({ + url: '/pages/myNeedsPublish/myNeedsPublish' + }) + } + goMyNeedEditPage() { + let id = this.$router.params.orderId + Taro.navigateTo({ + url: '/pages/myNeedsEdit/myNeedsEdit?id=' + id + }) + } + deleteButton() { + this.setState({ isDeleteModal: true }) + } + handleWindowModCancel() { + this.setState({ isDeleteModal: false }) + } + handleWindowConfirm() { + this.setState({ isDeleteModal: false }) + this.deleteMyNeeds({ demandId: this.$router.params.orderId }) + } + deleteMyNeeds({ demandId }) { + 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 => { + + if (res.data.err_msg === "success") { + Taro.showToast({ + title: '删除成功', + icon: 'success', + duration: 1500 + }) + setTimeout(() => { + Taro.switchTab({ + url: '/pages/myNeeds/myNeeds' + }) + }, 1500); + } else { + Taro.showToast({ + title: res.data.err_msg, + icon: 'none', + duration: 1500 + }) + } + }) + + } render() { const localStoageUserId = Taro.getStorageSync('userInfo').user_id + // 显示效果图 + const renderingElementArray = this.state.renderingImage.length ? this.state.renderingImage.map((item, index) => { + return + + + }) : null; + // 提示框 + const deleteModalWindowElement = + 提示 + + 确认删除{this.state.needsItem.sd_title}? + + + let ButtonElement if (localStoageUserId === this.state.userId && this.state.stateId === '1') { ButtonElement = @@ -219,6 +303,13 @@ class GrabOrderPage extends Component { return ( {modalMessageGrabElement} + {deleteModalWindowElement} + {this.state.isShowRendering ? + {renderingElementArray} + : null} + {this.state.stateId === '3' && !this.state.isShowRendering ? + + : null} 行业分类: {this.state.type} diff --git a/src/pages/grabOrderPage/grabOrderPage.scss b/src/pages/grabOrderPage/grabOrderPage.scss index 499f07a..b7c1ce6 100644 --- a/src/pages/grabOrderPage/grabOrderPage.scss +++ b/src/pages/grabOrderPage/grabOrderPage.scss @@ -1,6 +1,17 @@ .grabOrderPage{ padding: 10px 20px; font-size: 32rpx; + .rendering-container{ + display: flex; + flex-wrap: wrap; + flex-direction: row; + border: 4rpx solid #ddd; + .image-wrapper{ + width: 30%; + height: 200px; + margin:1.3%; + } + } .box{ margin-top: 35px; } diff --git a/src/pages/login/login.js b/src/pages/login/login.js index 865fb9b..227129c 100644 --- a/src/pages/login/login.js +++ b/src/pages/login/login.js @@ -69,7 +69,7 @@ class Login extends Component { // Taro.navigateBack({ // delta: 1 // }) - Taro.switchTab({ + Taro.reLaunch({ url:'/pages/home/home' }) }, 1000); diff --git a/src/pages/myDemandSupplyEdit/myDemandSupplyEdit.js b/src/pages/myDemandSupplyEdit/myDemandSupplyEdit.js index aa663b5..0ee144b 100644 --- a/src/pages/myDemandSupplyEdit/myDemandSupplyEdit.js +++ b/src/pages/myDemandSupplyEdit/myDemandSupplyEdit.js @@ -140,7 +140,7 @@ class MyDemandSupplyEdit extends Component { url: '/pages/myDemandSupplyEdit/myDemandSupplyEdit?sdId=' + res.data.sd_id }) } else if (this.state.isSaveAndNew) { - Taro.navigateTo({ + Taro.switchTab({ url: '/pages/supplyDemandPublish/supplyDemandPublish' }) } @@ -311,7 +311,7 @@ class MyDemandSupplyEdit extends Component { } } goToMyDemSupPage() { - Taro.navigateTo({ + Taro.switchTab({ url: '/pages/mySupplyDemand/mySupplyDemand' }) } diff --git a/src/pages/myGoodsEdit/myGoodsEdit.js b/src/pages/myGoodsEdit/myGoodsEdit.js index 2a7eec6..2dc0584 100644 --- a/src/pages/myGoodsEdit/myGoodsEdit.js +++ b/src/pages/myGoodsEdit/myGoodsEdit.js @@ -10,12 +10,13 @@ import './myGoodsEdit.scss' class MyGoodsEdit extends Component { config = { - navigationBarTitleText: '商品编辑' + navigationBarTitleText: '编辑商品' } constructor() { super(...arguments) this.state = { shopTypeSelected: { name: '全部', id: '' }, + shopTypeId:'', shopTypeList: {},//店铺分类列表 productName: '', productPrice: '', @@ -51,16 +52,16 @@ class MyGoodsEdit extends Component { const imageFile = res.data.goodsFiles.map((item) => { return { url: URL.Base + item.files.file_path } }) - let shopTypeSelected + // let shopTypeSelected - const shopTypeId = res.data.goods.shop_class_id - for (let key in this.state.shopTypeList) { - for (let item of this.state.shopTypeList[key].c) { - if (item.id === shopTypeId) { - shopTypeSelected = { name: item.n, id: item.id } - } - } - } + // const shopTypeId = res.data.goods.shop_class_id + // for (let key in this.state.shopTypeList) { + // for (let item of this.state.shopTypeList[key].c) { + // if (item.id === shopTypeId) { + // shopTypeSelected = { name: item.n, id: item.id } + // } + // } + // } this.setState({ productName: res.data.goods.goods_name, productPrice: res.data.goods.goods_price, @@ -68,7 +69,7 @@ class MyGoodsEdit extends Component { productDescript: res.data.goods.goods_profiles, pickerImageUrl: imageFile, ImagesInfo: res.data.goodsFiles, - shopTypeSelected: shopTypeSelected, + shopTypeId: res.data.goods.shop_class_id, goodsTypeParam: res.data.goods.class_id, goodId: res.data.goods.goods_id, }) @@ -89,7 +90,7 @@ class MyGoodsEdit extends Component { class_id = "10103", shop_class_id = "1930", goods_id = '123' }) { - + console.log('上传函数1~~~~') // 上传图片的参数 const uploadProductGoodFileParams = [] if (this.state.ImagesInfo.length) { @@ -114,6 +115,7 @@ class MyGoodsEdit extends Component { } else { alert('图片为空') } + console.log('上传函数~~~~') Taro.request({ url: URL.UploadProduct, @@ -171,10 +173,6 @@ class MyGoodsEdit extends Component { }) }) } - - - - productNameChange(event) { this.setState({ productName: event @@ -214,22 +212,32 @@ class MyGoodsEdit extends Component { success(response) { const data = JSON.parse(response.data) - console.log('imagedata', data) - const imagePath = URL.Base + data.file_path - const newPickerImageUrl = that.state.pickerImageUrl.concat({ url: imagePath }) - const newImageInfo = that.state.ImagesInfo.concat(data) - console.log('新添加后的图片列表', newImageInfo) + if (data.err_code === 0) { + console.log('imagedata', data) + const imagePath = URL.Base + data.file_path + const newPickerImageUrl = that.state.pickerImageUrl.concat({ url: imagePath }) + const newImageInfo = that.state.ImagesInfo.concat(data) + console.log('新添加后的图片列表', newImageInfo) - that.setState({ - pickerImageUrl: newPickerImageUrl, - ImagesInfo: newImageInfo - }, () => { - Taro.showToast({ - title: '上传成功', - icon: 'success', - duration: 2000 + that.setState({ + pickerImageUrl: newPickerImageUrl, + ImagesInfo: newImageInfo + }, () => { + Taro.showToast({ + title: '上传成功', + icon: 'success', + duration: 2000 + }) }) - }) + + } else { + Taro.showToast({ + title: data.err_msg, + icon: 'none', + duration: 1500 + }) + } + } }) } @@ -328,6 +336,7 @@ class MyGoodsEdit extends Component { } componentDidMount() { + this.getGoodsInfo() } componentWillReceiveProps(nextProps) { @@ -401,8 +410,10 @@ class MyGoodsEdit extends Component { {/* 店铺分类 */} {/* 店铺分类结束 */} diff --git a/src/pages/myNeedsEdit/myNeedsEdit.js b/src/pages/myNeedsEdit/myNeedsEdit.js index 9b74f56..2b6c380 100644 --- a/src/pages/myNeedsEdit/myNeedsEdit.js +++ b/src/pages/myNeedsEdit/myNeedsEdit.js @@ -168,7 +168,7 @@ class MyNeedsEdit extends Component { url: '/pages/myNeedsEdit/myNeedsEdit?id=' + this.state.sd_id }) } else if (this.state.isSaveAndNew) { - Taro.navigateTo({ + Taro.switchTab({ url: '/pages/myNeedsPublish/myNeedsPublish' }) } @@ -302,7 +302,7 @@ class MyNeedsEdit extends Component { this.setState({ content: event.target.value }) } goToMyNeedsPage() { - Taro.navigateTo({ + Taro.switchTab({ url: '/pages/myNeeds/myNeeds' }) } diff --git a/src/pages/myNeedsPublish/myNeedsPublish.js b/src/pages/myNeedsPublish/myNeedsPublish.js index 42c7507..7c77081 100644 --- a/src/pages/myNeedsPublish/myNeedsPublish.js +++ b/src/pages/myNeedsPublish/myNeedsPublish.js @@ -241,7 +241,7 @@ class MyNeedsPublish extends Component { } goToMyNeedsPage() { - Taro.navigateTo({ + Taro.switchTab({ url: '/pages/myNeeds/myNeeds' }) } diff --git a/src/pages/mySupplyDemand/mySupplyDemand.js b/src/pages/mySupplyDemand/mySupplyDemand.js index bfac3af..1aeec7b 100644 --- a/src/pages/mySupplyDemand/mySupplyDemand.js +++ b/src/pages/mySupplyDemand/mySupplyDemand.js @@ -160,7 +160,7 @@ class MySupplyDemand extends Component { // 新增我的供求 addDemandSupply() { - Taro.navigateTo({ + Taro.switchTab({ url: '/pages/supplyDemandPublish/supplyDemandPublish' }) } diff --git a/src/pages/supplyDemandPublish/supplyDemandPublish.js b/src/pages/supplyDemandPublish/supplyDemandPublish.js index 19617e6..349dcc3 100644 --- a/src/pages/supplyDemandPublish/supplyDemandPublish.js +++ b/src/pages/supplyDemandPublish/supplyDemandPublish.js @@ -1,6 +1,6 @@ import Taro, { Component } from '@tarojs/taro' -import { View, Text, Button,Input } from '@tarojs/components' +import { View, Text, Button, Input } from '@tarojs/components' import { AtInput, AtImagePicker, AtTextarea, Picker } from 'taro-ui' import CopyrightComponent from '../../component/copyrightComponent/copyrightComponent' @@ -93,7 +93,7 @@ class SupplyDemand extends Component { }) } else if (this.state.isPublishAndNew) { - Taro.navigateTo({ + Taro.switchTab({ url: '/pages/supplyDemandPublish/supplyDemandPublish' }) } @@ -131,18 +131,26 @@ class SupplyDemand extends Component { 'X-Requested-With': 'XMLHttpRequest' }, success(response) { + console.log('response', response) const data = JSON.parse(response.data) - const imagePath = URL.Base + data.file_path - const newPickerImageUrl = that.state.pickerImageUrl.concat({ url: imagePath }) - const newImageInfo = that.state.ImagesInfo.concat(data) + if (data.err_code === 0) { + const imagePath = URL.Base + data.file_path + const newPickerImageUrl = that.state.pickerImageUrl.concat({ url: imagePath }) + const newImageInfo = that.state.ImagesInfo.concat(data) + that.setState({ pickerImageUrl: newPickerImageUrl, ImagesInfo: newImageInfo }) + Taro.showToast({ + title: '上传成功', + icon: 'success', + duration: 1500 + }) + } else { + Taro.showToast({ + title: data.err_msg, + icon: 'none', + duration: 1500 + }) + } - - that.setState({ pickerImageUrl: newPickerImageUrl, ImagesInfo: newImageInfo }) - Taro.showToast({ - title: '上传成功', - icon: 'success', - duration: 1500 - }) } }) } @@ -179,8 +187,8 @@ class SupplyDemand 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 }) @@ -235,19 +243,19 @@ class SupplyDemand extends Component { LoginService() return } - Taro.navigateTo({ + Taro.switchTab({ url: '/pages/mySupplyDemand/mySupplyDemand' }) } - componentWillMount(){ - + componentWillMount() { + } componentDidMount() { } componentWillReceiveProps(nextProps) { - // console.log(this.props, nextProps) + // console.log(this.props, nextProps) } componentWillUnmount() { } @@ -257,12 +265,12 @@ class SupplyDemand extends Component { LoginService() return } - } + } componentDidHide() { } render() { - + return ( @@ -314,7 +322,7 @@ class SupplyDemand extends Component { onInput={this.contactNumberChange.bind(this)} /> - + 联系地址: diff --git a/src/pages/supplyDemandView/supplyDemandView.js b/src/pages/supplyDemandView/supplyDemandView.js index 9a24db4..1bca4a2 100644 --- a/src/pages/supplyDemandView/supplyDemandView.js +++ b/src/pages/supplyDemandView/supplyDemandView.js @@ -117,7 +117,7 @@ class SupplyDemandView extends Component { }) } goToSDPublishPage() { - Taro.navigateTo({ + Taro.switchTab({ url: '/pages/supplyDemandPublish/supplyDemandPublish',// 供求发布页面 }) } @@ -129,7 +129,7 @@ class SupplyDemandView extends Component { } goToMySDPage() { - Taro.navigateTo({ + Taro.switchTab({ url: '/pages/mySupplyDemand/mySupplyDemand',//我的供求页面 })