修改switchtab 后按键无效

This commit is contained in:
郑茂强 2019-02-13 18:05:21 +08:00
parent 0df437e7bc
commit 55644ac246
13 changed files with 209 additions and 72 deletions

View File

@ -2,7 +2,7 @@
"miniprogramRoot": "./dist", "miniprogramRoot": "./dist",
"projectname": "cf-wx-app", "projectname": "cf-wx-app",
"description": "cf-wx-app", "description": "cf-wx-app",
"appid": "touristappid", "appid": "wx424f6c9c24717e53",
"setting": { "setting": {
"urlCheck": true, "urlCheck": true,
"es6": false, "es6": false,

View File

@ -81,7 +81,7 @@ class App extends Component {
color: '#333', color: '#333',
selectedColor: '#333', selectedColor: '#333',
backgroundColor: '#fff', backgroundColor: '#fff',
borderStyle: '#ccc' borderStyle: 'black'
} }

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',
@ -46,6 +46,12 @@ class ShopTypeInteractionComp extends Component {
interactionMultiArray: this.recursionInteraction(res.data.data), interactionMultiArray: this.recursionInteraction(res.data.data),
initailMultiArray: this.recursionInitialized(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.interactionMultiArray)
// console.log('初始化数据', this.state.initailMultiArray) // console.log('初始化数据', this.state.initailMultiArray)
// console.log('index初始化', this.state.multiIndex) // console.log('index初始化', this.state.multiIndex)
@ -61,8 +67,16 @@ class ShopTypeInteractionComp extends Component {
console.log('店铺分类请求错误', error) 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) { recursionInteraction(data) {
@ -134,14 +148,16 @@ 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

@ -16,6 +16,7 @@ class GrabOrderPage extends Component {
constructor() { constructor() {
super(...arguments); super(...arguments);
this.state = { this.state = {
isShowRendering: false,
type: '', type: '',
title: '', title: '',
browsing: '', browsing: '',
@ -28,7 +29,9 @@ class GrabOrderPage extends Component {
grabOrderId: this.$router.params.orderId, grabOrderId: this.$router.params.orderId,
stateId: '', stateId: '',
stateName: '', stateName: '',
userId: '' userId: '',
renderingImage: [],
isDeleteModal: false
} }
} }
@ -60,8 +63,8 @@ class GrabOrderPage extends Component {
images: res.data.sdInfo.file_path, images: res.data.sdInfo.file_path,
stateId: res.data.sdInfo.state, stateId: res.data.sdInfo.state,
stateName: res.data.sdInfo.state_name, 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() { callPhoneNumber() {
Taro.makePhoneCall({ Taro.makePhoneCall({
phoneNumber: this.state.contactNumber phoneNumber: this.state.contactNumber
@ -144,9 +152,85 @@ class GrabOrderPage extends Component {
componentDidShow() { } componentDidShow() { }
componentDidHide() { } 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() { render() {
const localStoageUserId = Taro.getStorageSync('userInfo').user_id const localStoageUserId = Taro.getStorageSync('userInfo').user_id
// 显示效果图
const renderingElementArray = this.state.renderingImage.length ? this.state.renderingImage.map((item, index) => {
return <View className='image-wrapper' key={index}>
<Image src={URL.Base + item.file_path} style='max-width:100%; max-height:100%;' />
</View>
}) : null;
// 提示框
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>
let ButtonElement let ButtonElement
if (localStoageUserId === this.state.userId && this.state.stateId === '1') { if (localStoageUserId === this.state.userId && this.state.stateId === '1') {
ButtonElement = <View className='button-box'> ButtonElement = <View className='button-box'>
@ -219,6 +303,13 @@ class GrabOrderPage extends Component {
return ( return (
<View className='grabOrderPage'> <View className='grabOrderPage'>
{modalMessageGrabElement} {modalMessageGrabElement}
{deleteModalWindowElement}
{this.state.isShowRendering ? <View className='rendering-container'>
{renderingElementArray}
</View> : null}
{this.state.stateId === '3' && !this.state.isShowRendering ? <View className='button-box show-image-button'><View className='button' onClick={this.showImageButton.bind(this)}>
<Button className='button-orange'>查看效果图</Button>
</View></View> : null}
<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.type}</Text>

View File

@ -1,6 +1,17 @@
.grabOrderPage{ .grabOrderPage{
padding: 10px 20px; padding: 10px 20px;
font-size: 32rpx; 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{ .box{
margin-top: 35px; margin-top: 35px;
} }

View File

@ -69,7 +69,7 @@ class Login extends Component {
// Taro.navigateBack({ // Taro.navigateBack({
// delta: 1 // delta: 1
// }) // })
Taro.switchTab({ Taro.reLaunch({
url:'/pages/home/home' url:'/pages/home/home'
}) })
}, 1000); }, 1000);

View File

@ -140,7 +140,7 @@ class MyDemandSupplyEdit extends Component {
url: '/pages/myDemandSupplyEdit/myDemandSupplyEdit?sdId=' + res.data.sd_id url: '/pages/myDemandSupplyEdit/myDemandSupplyEdit?sdId=' + res.data.sd_id
}) })
} else if (this.state.isSaveAndNew) { } else if (this.state.isSaveAndNew) {
Taro.navigateTo({ Taro.switchTab({
url: '/pages/supplyDemandPublish/supplyDemandPublish' url: '/pages/supplyDemandPublish/supplyDemandPublish'
}) })
} }
@ -311,7 +311,7 @@ class MyDemandSupplyEdit extends Component {
} }
} }
goToMyDemSupPage() { goToMyDemSupPage() {
Taro.navigateTo({ Taro.switchTab({
url: '/pages/mySupplyDemand/mySupplyDemand' url: '/pages/mySupplyDemand/mySupplyDemand'
}) })
} }

View File

@ -10,12 +10,13 @@ import './myGoodsEdit.scss'
class MyGoodsEdit extends Component { class MyGoodsEdit extends Component {
config = { config = {
navigationBarTitleText: '商品编辑' navigationBarTitleText: '编辑商品'
} }
constructor() { constructor() {
super(...arguments) super(...arguments)
this.state = { this.state = {
shopTypeSelected: { name: '全部', id: '' }, shopTypeSelected: { name: '全部', id: '' },
shopTypeId:'',
shopTypeList: {},//店铺分类列表 shopTypeList: {},//店铺分类列表
productName: '', productName: '',
productPrice: '', productPrice: '',
@ -51,16 +52,16 @@ class MyGoodsEdit extends Component {
const imageFile = res.data.goodsFiles.map((item) => { const imageFile = res.data.goodsFiles.map((item) => {
return { url: URL.Base + item.files.file_path } return { url: URL.Base + item.files.file_path }
}) })
let shopTypeSelected // let shopTypeSelected
const shopTypeId = res.data.goods.shop_class_id // const shopTypeId = res.data.goods.shop_class_id
for (let key in this.state.shopTypeList) { // for (let key in this.state.shopTypeList) {
for (let item of this.state.shopTypeList[key].c) { // for (let item of this.state.shopTypeList[key].c) {
if (item.id === shopTypeId) { // if (item.id === shopTypeId) {
shopTypeSelected = { name: item.n, id: item.id } // shopTypeSelected = { name: item.n, id: item.id }
} // }
} // }
} // }
this.setState({ this.setState({
productName: res.data.goods.goods_name, productName: res.data.goods.goods_name,
productPrice: res.data.goods.goods_price, productPrice: res.data.goods.goods_price,
@ -68,7 +69,7 @@ class MyGoodsEdit extends Component {
productDescript: res.data.goods.goods_profiles, productDescript: res.data.goods.goods_profiles,
pickerImageUrl: imageFile, pickerImageUrl: imageFile,
ImagesInfo: res.data.goodsFiles, ImagesInfo: res.data.goodsFiles,
shopTypeSelected: shopTypeSelected, shopTypeId: res.data.goods.shop_class_id,
goodsTypeParam: res.data.goods.class_id, goodsTypeParam: res.data.goods.class_id,
goodId: res.data.goods.goods_id, goodId: res.data.goods.goods_id,
}) })
@ -89,7 +90,7 @@ 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) {
@ -114,6 +115,7 @@ class MyGoodsEdit extends Component {
} else { } else {
alert('图片为空') alert('图片为空')
} }
console.log('上传函数~~~~')
Taro.request({ Taro.request({
url: URL.UploadProduct, url: URL.UploadProduct,
@ -171,10 +173,6 @@ class MyGoodsEdit extends Component {
}) })
}) })
} }
productNameChange(event) { productNameChange(event) {
this.setState({ this.setState({
productName: event productName: event
@ -214,22 +212,32 @@ class MyGoodsEdit extends Component {
success(response) { success(response) {
const data = JSON.parse(response.data) const data = JSON.parse(response.data)
console.log('imagedata', data) if (data.err_code === 0) {
const imagePath = URL.Base + data.file_path console.log('imagedata', data)
const newPickerImageUrl = that.state.pickerImageUrl.concat({ url: imagePath }) const imagePath = URL.Base + data.file_path
const newImageInfo = that.state.ImagesInfo.concat(data) const newPickerImageUrl = that.state.pickerImageUrl.concat({ url: imagePath })
console.log('新添加后的图片列表', newImageInfo) const newImageInfo = that.state.ImagesInfo.concat(data)
console.log('新添加后的图片列表', newImageInfo)
that.setState({ that.setState({
pickerImageUrl: newPickerImageUrl, pickerImageUrl: newPickerImageUrl,
ImagesInfo: newImageInfo ImagesInfo: newImageInfo
}, () => { }, () => {
Taro.showToast({ Taro.showToast({
title: '上传成功', title: '上传成功',
icon: 'success', icon: 'success',
duration: 2000 duration: 2000
})
}) })
})
} else {
Taro.showToast({
title: data.err_msg,
icon: 'none',
duration: 1500
})
}
} }
}) })
} }
@ -328,6 +336,7 @@ class MyGoodsEdit extends Component {
} }
componentDidMount() { componentDidMount() {
this.getGoodsInfo()
} }
componentWillReceiveProps(nextProps) { componentWillReceiveProps(nextProps) {
@ -401,8 +410,10 @@ 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}
></ShopTypeInteractionComp> ></ShopTypeInteractionComp>
{/* 店铺分类结束 */} {/* 店铺分类结束 */}

View File

@ -168,7 +168,7 @@ class MyNeedsEdit extends Component {
url: '/pages/myNeedsEdit/myNeedsEdit?id=' + this.state.sd_id url: '/pages/myNeedsEdit/myNeedsEdit?id=' + this.state.sd_id
}) })
} else if (this.state.isSaveAndNew) { } else if (this.state.isSaveAndNew) {
Taro.navigateTo({ Taro.switchTab({
url: '/pages/myNeedsPublish/myNeedsPublish' url: '/pages/myNeedsPublish/myNeedsPublish'
}) })
} }
@ -302,7 +302,7 @@ class MyNeedsEdit extends Component {
this.setState({ content: event.target.value }) this.setState({ content: event.target.value })
} }
goToMyNeedsPage() { goToMyNeedsPage() {
Taro.navigateTo({ Taro.switchTab({
url: '/pages/myNeeds/myNeeds' url: '/pages/myNeeds/myNeeds'
}) })
} }

View File

@ -241,7 +241,7 @@ class MyNeedsPublish extends Component {
} }
goToMyNeedsPage() { goToMyNeedsPage() {
Taro.navigateTo({ Taro.switchTab({
url: '/pages/myNeeds/myNeeds' url: '/pages/myNeeds/myNeeds'
}) })
} }

View File

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

View File

@ -1,6 +1,6 @@
import Taro, { Component } from '@tarojs/taro' 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 { AtInput, AtImagePicker, AtTextarea, Picker } from 'taro-ui'
import CopyrightComponent from '../../component/copyrightComponent/copyrightComponent' import CopyrightComponent from '../../component/copyrightComponent/copyrightComponent'
@ -93,7 +93,7 @@ class SupplyDemand extends Component {
}) })
} else if (this.state.isPublishAndNew) { } else if (this.state.isPublishAndNew) {
Taro.navigateTo({ Taro.switchTab({
url: '/pages/supplyDemandPublish/supplyDemandPublish' url: '/pages/supplyDemandPublish/supplyDemandPublish'
}) })
} }
@ -131,18 +131,26 @@ class SupplyDemand extends Component {
'X-Requested-With': 'XMLHttpRequest' 'X-Requested-With': 'XMLHttpRequest'
}, },
success(response) { success(response) {
console.log('response', response)
const data = JSON.parse(response.data) const data = JSON.parse(response.data)
const imagePath = URL.Base + data.file_path if (data.err_code === 0) {
const newPickerImageUrl = that.state.pickerImageUrl.concat({ url: imagePath }) const imagePath = URL.Base + data.file_path
const newImageInfo = that.state.ImagesInfo.concat(data) 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) { 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 })
@ -235,19 +243,19 @@ class SupplyDemand extends Component {
LoginService() LoginService()
return return
} }
Taro.navigateTo({ Taro.switchTab({
url: '/pages/mySupplyDemand/mySupplyDemand' url: '/pages/mySupplyDemand/mySupplyDemand'
}) })
} }
componentWillMount(){ componentWillMount() {
} }
componentDidMount() { componentDidMount() {
} }
componentWillReceiveProps(nextProps) { componentWillReceiveProps(nextProps) {
// console.log(this.props, nextProps) // console.log(this.props, nextProps)
} }
componentWillUnmount() { } componentWillUnmount() { }
@ -257,12 +265,12 @@ class SupplyDemand extends Component {
LoginService() LoginService()
return return
} }
} }
componentDidHide() { } componentDidHide() { }
render() { render() {
return ( return (
<View className='supply-demand'> <View className='supply-demand'>
@ -314,7 +322,7 @@ class SupplyDemand extends Component {
onInput={this.contactNumberChange.bind(this)} onInput={this.contactNumberChange.bind(this)}
/></View> /></View>
</View> </View>
<View className='demanding-box'> <View className='demanding-box'>
<View className='title-box'> <View className='title-box'>
<Text className='title'>联系地址:</Text> <Text className='title'>联系地址:</Text>

View File

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