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

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 {
console.log('商品分类请求没有成功', res)
Taro.showToast({
title: res.data.err_msg,
icon: 'none'
})
}
}
)

View File

@ -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() { }

View File

@ -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: '上传成功',
@ -196,7 +196,7 @@ class GoodsPublish extends Component {
} else {
Taro.showToast({
title: responseMsg,
title: responseData.err_msg,
icon: 'none',
duration: 1500
})

View File

@ -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);

View File

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

View File

@ -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({})
})
})

View File

@ -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)
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 })
}).catch(err => {
} else {
Taro.showToast({
title: '获取宝贝类目失败',
title: res.data.err_msg,
icon: 'none',
duration: 1500,
})
}
})
}
// 获取我的商品列表接口api
@ -143,16 +140,15 @@ class MyGoodList extends Component {
'X-Requested-With': 'XMLHttpRequest'
}
}).then(res => {
if (res.statusCode === 200) {
console.log('我的商品列表', 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 => {
item.checked = false
});
if (this.state.isAddToList) {
this.setState({ myGoodList: this.state.myGoodList.concat(data.goods) }, () => {
this.setState({ isAddToList: false })
@ -162,8 +158,13 @@ class MyGoodList extends Component {
myGoodList: data.goods,
myGoodListTotal: data.goodsCount
})
}
} else {
if (data.goods === null) {
this.setState({
myGoodList: [],
myGoodListTotal: data.goodsCount
})
} else {
this.setState({ isAddToList: false })
Taro.showToast({
@ -171,8 +172,12 @@ class MyGoodList extends Component {
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) {
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
}).then(() => {
this.setState({ isCheckAll: false })
this.getMyGoodListApi({})
})
})
} 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 {
</View>
</View>
</View>
<View className='mygoodlist-container'>
{this.state.myGoodList.length ? <View className='mygoodlist-container'>
{goodListElementArray}
</View >
</View > : <View className='no-more-title'> </View>}
{this.state.isShowTopNav ? <ScrollToTopComponent ></ScrollToTopComponent> : null}
<CopyrightComponent></CopyrightComponent>
</View>
)

View File

@ -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,36 +141,37 @@ class MyGoodsEdit extends Component {
})
.then(res => {
Taro.hideLoading()
if (res.data.err_code === 0) {
Taro.showToast({
title: '保存成功',
icon: 'success',
duration: 1000
duration: 1500
}).then(() => {
setTimeout(() => {
if (this.state.isSaveButton) {
Taro.navigateTo({
url: '/pages/myGoodsEdit/myGoodsEdit?id=' + this.$router.params.id
})
// Taro.redirectTo({
// url: '/pages/myGoodsEdit/myGoodsEdit?id=' + this.$router.params.id
// })
} else if (this.state.isSaveAndNewBUtton) {
Taro.navigateTo({
Taro.switchTab({
url: '/pages/goodsPublish/goodsPublish'
})
}
}, 1000);
})
console.log('上传商品', res)
}
)
.catch(error => {
} else {
Taro.hideLoading()
Taro.showToast({
title: '保存失败',
title: res.data.err_msg,
icon: 'none',
duration: 1000
})
duration: 1500
})
}
}
)
}
productNameChange(event) {
this.setState({
productName: event
@ -335,6 +334,7 @@ class MyGoodsEdit extends Component {
this.setState({ shopTypeSelected: value })
}
componentDidMount() {
this.getGoodsInfo()
}
@ -410,7 +410,7 @@ class MyGoodsEdit extends Component {
{/* 店铺分类 */}
<ShopTypeInteractionComp url={URL.GetShopCategoryList}
shopId={Taro.getStorageSync('shopInfo').shop_id}
// selectedValue={this.state.shopTypeSelected}
selectedValue={this.state.shopTypeSelected}
onPassDataToChild={this.getDataFromShopChild.bind(this)}
shopTypeId={this.state.shopTypeId}

View File

@ -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, AtModal, AtModalHeader, AtModalContent, AtModalAction } from 'taro-ui'
import InteractionComponent from '../../component/interactionComponent/interactionComponent'
@ -34,7 +34,7 @@ class MyNeedsEdit extends Component {
pickerImageUrl: [],
ImagesInfo: '',
isDeleteModal: false,// 删除提示框
isSave: false,//是否点击保存按钮
isSaveAndNew: false,//是否点击保存新增按钮
@ -59,6 +59,7 @@ class MyNeedsEdit extends Component {
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]
if (res.data.err_code === 0) {
let industryType = {}
const classId = res.data.sdInfo.class_id
for (let outter of res.data.supplyTree) {
@ -81,9 +82,6 @@ class MyNeedsEdit extends Component {
industryType.name = '全部'
industryType.id = '-1'
}
const needsType = this.state.needsType.filter(item => {
return item.id === res.data.sdInfo.sd_type
})[0]
@ -105,13 +103,15 @@ class MyNeedsEdit extends Component {
ImagesInfo: res.data.sdInfo.file_path,
})
Taro.hideLoading()
}
)
.catch(error => {
console.log('供求详情获取失败', error)
} else {
Taro.showToast({
title: res.data.err_msg,
icon: 'none'
})
}
}
)
}
@ -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() {

View File

@ -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,16 +87,17 @@ class MyNeedsPublish extends Component {
duration: 1500
}).then(() => {
setTimeout(() => {
if (this.state.isPublish) {
Taro.navigateTo({
url: '/pages/myNeedsEdit/myNeedsEdit?id=' + res.data.sd_id
})
} else if (this.state.isPublishAndNew) {
if (this.state.isPublishAndNew) {
Taro.navigateTo({
url: '/pages/myNeedsPublish/myNeedsPublish'
})
} else {
Taro.navigateTo({
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'
})
}

View File

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

View File

@ -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 (
<View className='supply-demand'>
<View className='page-section'>
<View>
<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() {
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({