修改联动,登入新账号后的数据更新,优惠卷和咨询

This commit is contained in:
郑茂强 2019-02-21 17:06:08 +08:00
parent 0ba9766007
commit 5baa65e718
15 changed files with 547 additions and 181 deletions

View File

@ -32,10 +32,11 @@ class recommondShop extends Component {
isOpenVoucher: false, isOpenVoucher: false,
isOpenConsult: false, isOpenConsult: false,
consultTip: '', consultTip: '',
voucherResponseMsg: '', voucherResponseMsg: 'i am voucherResponseMsg',
voucherCanConsult: false,
userName: Taro.getStorageSync('user_identity').username || '', userName: Taro.getStorageSync('user_identity').username || '',
userPhone: Taro.getStorageSync('user_identity').userphone || '', userPhone: Taro.getStorageSync('user_identity').userphone || '',
canConsult: false
} }
} }
goToShop(value) { goToShop(value) {
@ -44,20 +45,28 @@ class recommondShop extends Component {
}) })
} }
// api 优惠卷请求 // api 优惠卷请求
getVoucherInfo({ user = "某某人", phone = "18950295811", shops = ["808"], source_type = 4, flag = false, source_class = "1", source_level = 1 }) { getVoucherInfo({ user = this.state.userName,
phone = this.state.userPhone,
shops = [this.props.shop.shop_id],
source_type = 4,
flag = false,
source_level = this.props.categoryLevel }) {
Taro.request({ Taro.request({
url: URL.GetVoucherInfo, url: URL.GetVoucherInfo,
method: 'POST', method: 'POST',
dataType: 'json', dataType: 'json',
data: { data: {
data: JSON.stringify({
user: user, user: user,
phone: phone, phone: phone,
shops: shops, shops: shops,
source_type: source_type, source_type: source_type,
flag: flag, flag: flag,
source_class: source_class,
source_level: source_level source_level: source_level
})
}, },
header: { header: {
'content-type': 'application/x-www-form-urlencoded', 'content-type': 'application/x-www-form-urlencoded',
'X-Requested-With': 'XMLHttpRequest', 'X-Requested-With': 'XMLHttpRequest',
@ -67,7 +76,7 @@ class recommondShop extends Component {
.then(res => { .then(res => {
this.setState({ this.setState({
voucherResponseMsg: res.data.tips, voucherResponseMsg: res.data.tips,
voucherCanConsult: res.data.canConsult canConsult: res.data.canConsult,
}) })
console.log('优惠卷请求', res) console.log('优惠卷请求', res)
}) })
@ -75,18 +84,27 @@ class recommondShop extends Component {
} }
// api 咨询信息 // api 咨询信息
getConsultInfo({ user = "某某人", phone = "18950295811", shops = ["1306"], source_type = "2", flag = false, source_level = 1 }) { getConsultInfo({
user = this.state.userName,
phone = this.state.userPhone,
shops = [this.props.shop.shop_id],
source_type = "2",
flag = false,
source_level = this.props.categoryLevel,
}) {
Taro.request({ Taro.request({
url: URL.GetConsultInfo, url: URL.GetConsultInfo,
method: 'POST', method: 'POST',
dataType: 'json', dataType: 'json',
data: { data: {
data: JSON.stringify({
user: user, user: user,
phone: phone, phone: phone,
shops: shops, shops: shops,
source_type: source_type, source_type: source_type,
flag: flag, flag: flag,
source_level: source_level source_level: source_level,
})
}, },
header: { header: {
'content-type': 'application/x-www-form-urlencoded', 'content-type': 'application/x-www-form-urlencoded',
@ -100,7 +118,12 @@ class recommondShop extends Component {
}) })
} }
// api 购买咨询 BuyConsult // api 购买咨询 BuyConsult
buyConsult({ user = "某某人", phone = "18950295811", shops = ["1306"], source_type = "2", source_level = 1, coupons_flag = 0 }) { buyConsult({ user = this.state.userName,
phone = this.state.userPhone,
shops = [this.props.shop.shop_id],
source_type = "2",
source_level = 1,
coupons_flag = 0 }) {
Taro.request({ Taro.request({
url: URL.BuyConsult, url: URL.BuyConsult,
method: 'POST', method: 'POST',
@ -123,7 +146,7 @@ class recommondShop extends Component {
}) })
.then(res => { .then(res => {
console.log('购买咨询请求成功', res) console.log('购买咨询请求成功', res)
if (res.statusCode === 200) { if (res.data.err_code === 0) {
Taro.showToast({ title: '咨询成功', icon: 'success' }) Taro.showToast({ title: '咨询成功', icon: 'success' })
} else { } else {
Taro.showToast({ title: res.data.err_msg, icon: 'none' }) Taro.showToast({ title: res.data.err_msg, icon: 'none' })
@ -140,28 +163,29 @@ class recommondShop extends Component {
isOpenConsult() { isOpenConsult() {
this.setState({ this.setState({
isOpenConsult: true, isOpenConsult: true,
userName: Taro.getStorageSync('user_identity').username,
userPhone: Taro.getStorageSync('user_identity').userphone, }, () => {
})
this.getConsultInfo({}) this.getConsultInfo({})
})
} }
consultModalClose() { consultModalClose() {
this.setState({ isOpenConsult: false }) this.setState({ isOpenConsult: false })
} }
consultModalConfirm() { consultModalConfirm() {
if(!this.state.userName){ if (!this.state.userName) {
Taro.showToast({ Taro.showToast({
title: '请填写姓名', title: '请填写姓名',
icon: 'none', icon: 'none',
}) })
}else if(!this.state.userPhone){ } else if (!this.state.userPhone) {
Taro.showToast({ Taro.showToast({
title: '请填写电话', title: '请填写电话',
icon: 'none', icon: 'none',
}) })
}else{ } else {
this.setState({ isOpenConsult: false }) this.setState({ isOpenConsult: false })
this.buyConsult({ user: this.state.userName, phone: this.state.userPhone }) this.buyConsult({ user: this.state.userName, phone: this.state.userPhone })
} }
@ -177,14 +201,21 @@ class recommondShop extends Component {
console.log('从voucherposter件传回来的值', value) console.log('从voucherposter件传回来的值', value)
this.setState({ isOpenVoucher: value }) this.setState({ isOpenVoucher: value })
} }
isOpenVoucher(){ isOpenVoucher() {
this.setState({isOpenVoucher:true})
this.setState({
isOpenVoucher: true,
userName: Taro.getStorageSync('user_identity').username,
userPhone: Taro.getStorageSync('user_identity').userphone
}, () => {
this.getVoucherInfo({})
})
} }
componentWillReceiveProps(nextProps) { componentWillReceiveProps(nextProps) {
//console.log(this.props, nextProps) //console.log(this.props, nextProps)
} }
componentDidMount() { componentDidMount() {
console.log('this.props', this.props)
} }
componentWillUnmount() { } componentWillUnmount() { }
@ -194,6 +225,7 @@ class recommondShop extends Component {
render() { render() {
const title = this.props.shop.shop_name const title = this.props.shop.shop_name
const imgUrl = URL.Base + this.props.shop.goods[0].goods_url const imgUrl = URL.Base + this.props.shop.goods[0].goods_url
const price = this.props.shop.goods[0].goods_price const price = this.props.shop.goods[0].goods_price
@ -250,17 +282,21 @@ class recommondShop extends Component {
<AtModalAction> <Button onClick={this.consultModalClose.bind(this)} >取消</Button> <Button style='color:#FF7142' onClick={this.consultModalConfirm.bind(this)}></Button> </AtModalAction> <AtModalAction> <Button onClick={this.consultModalClose.bind(this)} >取消</Button> <Button style='color:#FF7142' onClick={this.consultModalConfirm.bind(this)}></Button> </AtModalAction>
</AtModal> </AtModal>
// <AtModalAction> <Button onClick={this.consultModalClose.bind(this)} >取消</Button> {this.props.canConsult?<Button style='color:#FF7142' onClick={this.consultModalConfirm.bind(this)}>确定</Button>:<Text></Text>} </AtModalAction>
return ( return (
<View className='shop-list-box' > <View className='shop-list-box' >
{consultModalElement} {consultModalElement}
<VoucherPosterComponent <VoucherPosterComponent
userName={this.state.userName} name={this.state.userName}
userPhone={this.state.userPhone} phone={this.state.userPhone}
shopId={this.props.shop.shop_id}
canConsult={this.state.canConsult}
isVoucherPoster={this.state.isOpenVoucher} isVoucherPoster={this.state.isOpenVoucher}
onPassDataToChild={this.getDataFromChild.bind(this)} onPassDataToChild={this.getDataFromChild.bind(this)}
voucherLeft={this.props.shop.left_nums} voucherLeft={this.props.shop.left_nums}
voucherResponseMsg={this.state.voucherResponseMsg} voucherResponseMsg={this.state.voucherResponseMsg}
categoryLevel={this.props.categoryLevel}
></VoucherPosterComponent> ></VoucherPosterComponent>
<View className='header'> <View className='header'>

View File

@ -17,13 +17,20 @@ class VoucherPoster extends Component {
constructor() { constructor() {
super(...arguments); super(...arguments);
this.state = { this.state = {
voucherName: this.props.userName, voucherName: this.props.name,
voucherPhone: this.props.userPhone, voucherPhone: this.props.phone,
voucherPosterImage: 'background-image:url(' + URL.Base + '/Public/images/store/m_yhq.png);' voucherPosterImage: 'background-image:url(' + URL.Base + '/Public/images/store/m_yhq.png);'
} }
} }
// api 购买咨询 BuyConsult // api 购买咨询 BuyConsult
buyConsult({ user = "某某人", phone = "18950295811", shops = ["1306"], source_type = "2", source_level = 1, coupons_flag = 0 }) { buyConsult({
user = this.state.voucherName,
phone = this.state.voucherPhone,
shops = [this.props.shopId],
source_type = '4',
source_level = this.props.categoryLevel,
coupons_flag = '1' }) {
Taro.request({ Taro.request({
url: URL.BuyConsult, url: URL.BuyConsult,
method: 'POST', method: 'POST',
@ -46,7 +53,6 @@ class VoucherPoster extends Component {
}) })
.then(res => { .then(res => {
console.log('购买咨询请求成功', res) console.log('购买咨询请求成功', res)
if (res.data.err_code === 0) { if (res.data.err_code === 0) {
Taro.showToast({ Taro.showToast({
title: '领取成功', title: '领取成功',
@ -57,7 +63,7 @@ class VoucherPoster extends Component {
this.passDataToParent() this.passDataToParent()
}, 1500); }, 1500);
}else if (res.data.err_code === 88888) { } else if (res.data.err_code === 88888) {
loginExpired(res) loginExpired(res)
} else { } else {
Taro.showToast({ Taro.showToast({
@ -78,13 +84,13 @@ class VoucherPoster extends Component {
title: '请填写姓名', title: '请填写姓名',
icon: 'none', icon: 'none',
}) })
} else if (!this.state.voucherPhone) { } else if (this.state.voucherPhone.length !== 11) {
Taro.showToast({ Taro.showToast({
title: '请填电话号码', title: '请填正确的电话号码',
icon: 'none', icon: 'none',
}) })
} else { } else {
this.buyConsult({ user: this.state.voucherName, phone: this.state.voucherPhone }) this.buyConsult({})
} }
@ -101,10 +107,7 @@ class VoucherPoster extends Component {
this.props.onPassDataToChild(false) this.props.onPassDataToChild(false)
} }
componentWillReceiveProps(nextProps) { componentWillReceiveProps(nextProps) {
this.setState({
voucherName: nextProps.userName,
voucherPhone: nextProps.userPhone,
})
} }
componentDidMount() { componentDidMount() {
@ -118,6 +121,7 @@ class VoucherPoster extends Component {
componentDidHide() { } componentDidHide() { }
render() { render() {
console.log('i am poster')
return ( return (
<View className='voucherEventPopUpComponent'> <View className='voucherEventPopUpComponent'>
{/* <!-- The Modal --> */} {/* <!-- The Modal --> */}
@ -133,21 +137,16 @@ class VoucherPoster extends Component {
</View> </View>
<View className='input-name' > <View className='input-name' >
<View className='title'> <Text>联系人</Text></View> <View className='title'> <Text>联系人</Text></View>
<Input class='input-info' type='text' placeholder='请输入联系人' value={this.state.voucherName} onInput={this.handleNameChange.bind(this)} /> <Input class='input-info' type='text' placeholder='请输入联系人' value={this.props.name} onInput={this.handleNameChange.bind(this)} />
</View> </View>
<View className='input-number' > <View className='input-number' >
<View className='title'> <Text>联系电话</Text></View> <View className='title'> <Text>联系电话</Text></View>
<Input class='input-info' placeholder='请输入联系电话' type='text' maxLength='11' value={this.state.voucherPhone} onInput={this.handlePhoneChange.bind(this)} /> <Input class='input-info' placeholder='请输入联系电话' type='number' maxLength='11' value={this.props.phone} onInput={this.handlePhoneChange.bind(this)} />
</View> </View>
<View> <View>
</View> </View>
<View className='tips'> <View className='tips'>
{this.props.voucherResponseMsg} {this.props.canConsult ? '' : this.props.voucherResponseMsg}
</View> </View>
<View className='button' > <View className='button' >

View File

@ -44,13 +44,23 @@ class GoodsTypeInteractionComp extends Component {
console.log('商品分类目录', res) console.log('商品分类目录', res)
const recursionInteractionData=this.recursionInteraction(res.data.data) const recursionInteractionData=this.recursionInteraction(res.data.data)
maxDepth=0
initialDataArray=[]
this.recursionInitialized(res.data.data) // this.recursionInitialized(res.data.data) //
const depthInArray=this.recursionDepth(res.data.data)
console.log('depthInArray',depthInArray)
console.log('initialDataArray',initialDataArray)
for(let i=initialDataArray.length;i<depthInArray.length;i++){
initialDataArray.unshift([{name:'--',id:''}])
}
this.setState({ this.setState({
interactionMultiArray: recursionInteractionData, interactionMultiArray: recursionInteractionData,
multiIndex: this.recursionDepth(res.data.data), multiIndex: depthInArray,
initailMultiArray:initialDataArray.reverse() initailMultiArray:initialDataArray.reverse()
}, () => { }, () => {
initialDataArray=[]// 把全局变变量赋值给state之后初始化商品分类为空 不然第二次进去的时候会自动添加进去 // 把全局变变量赋值给state之后初始化商品分类为空 不然第二次进去的时候会自动添加进去
// console.log('联动数据', this.state.interactionMultiArray) // console.log('联动数据', this.state.interactionMultiArray)
// console.log('初始化数据', this.state.initailMultiArray) // console.log('初始化数据', this.state.initailMultiArray)
@ -107,7 +117,6 @@ class GoodsTypeInteractionComp extends Component {
for (let item of data) { for (let item of data) {
arrayTem.push({ name: item.class_name, id: item.class_id }) arrayTem.push({ name: item.class_name, id: item.class_id })
} }
} }
if(data[0].children.length){ if(data[0].children.length){
this.recursionInitialized(data[0].children) this.recursionInitialized(data[0].children)
@ -126,7 +135,7 @@ class GoodsTypeInteractionComp extends Component {
if (items.children) { if (items.children) {
arrayTem[arrayTem.length - 1].children = this.recursionInteraction(items.children) arrayTem[arrayTem.length - 1].children = this.recursionInteraction(items.children)
} else { } else {
arrayTem[arrayTem.length - 1].children = [{ name: '', id: '' }] arrayTem[arrayTem.length - 1].children = [{ name: '--', id: '' }]
} }
} }
return arrayTem // 返回联动数据 return arrayTem // 返回联动数据
@ -178,9 +187,6 @@ class GoodsTypeInteractionComp extends Component {
for (let index in data.multiArray[0]) { for (let index in data.multiArray[0]) {
const indexNumber = Number(index) const indexNumber = Number(index)
if (indexNumber === data.multiIndex[0]) { if (indexNumber === data.multiIndex[0]) {
// data.multiArray[1] = this.state.interactionMultiArray[indexNumber].children
// data.multiArray[2] = this.state.interactionMultiArray[indexNumber].children[0].children
// data.multiArray[3] = this.state.interactionMultiArray[indexNumber].children[0].children[0].children
data.multiArray[1] = this.state.interactionMultiArray[indexNumber].children data.multiArray[1] = this.state.interactionMultiArray[indexNumber].children
data.multiArray[2] = this.state.interactionMultiArray[indexNumber].children[data.multiIndex[1]].children data.multiArray[2] = this.state.interactionMultiArray[indexNumber].children[data.multiIndex[1]].children
data.multiArray[3] = this.state.interactionMultiArray[indexNumber].children[data.multiIndex[1]].children[data.multiIndex[2]].children data.multiArray[3] = this.state.interactionMultiArray[indexNumber].children[data.multiIndex[1]].children[data.multiIndex[2]].children

View File

@ -24,7 +24,7 @@
.first-col{ .first-col{
font-weight: normal; font-weight: normal;
margin-left: 2% margin-left: 10%
} }
.second-col{ .second-col{
font-weight: normal; font-weight: normal;

View File

@ -41,25 +41,23 @@ class Interaction extends Component {
} }
}).then(res => { }).then(res => {
if (res.data.err_code === 0) { if (res.data.err_code === 0) {
console.log('行业分类目录', res)
let initailMultiArray = this.recursionInitialized(res.data.data) let initailMultiArray = this.recursionInitialized(res.data.data)
initialDataArray[1].unshift({ name: '全部', id: '-1' }) // 默认 initailMultiArray[1].unshift({ name: '全部', id: '-1' })
initailMultiArray[0] = [{ name: '--', id: '' }]
console.log('initailMultiArray', initailMultiArray)
this.setState({ this.setState({
initailMultiArray: [initailMultiArray[1]], //initailMultiArray.reverse(), initailMultiArray: initailMultiArray.reverse(), //initailMultiArray.reverse(),
interactionMultiArray: [{ name: '全部', id: '-1', children: [{ name: '', id: '' }] }, ...this.recursionInteraction(res.data.data)], interactionMultiArray: [{ name: '全部', id: '-1', children: [{ name: '--', id: '' }] }, ...this.recursionInteraction(res.data.data)],
multiIndex: this.recursionDepth(res.data.data), multiIndex: this.recursionDepth(res.data.data),
}, () => { }, () => {
console.log('interactionMultiArray',this.state.interactionMultiArray) initialDataArray = []
initialDataArray = []// 把全局变变量赋值给state之后初始化商品分类为空 不然第二次进去的时候会自动添加进去 })
// console.log('联动数据', this.state.interactionMultiArray)
// console.log('初始化数据', this.state.initailMultiArray)
} else if (res.data.err_code === 88888) {
}) // 用递归来整理无限层次的数据 // loginExpired(res)
}else if (res.data.err_code === 88888) {
loginExpired(res)
} else { } else {
console.log('行业分类请求没有成功', res) console.log('行业分类请求没有成功', res)
} }
@ -75,9 +73,9 @@ class Interaction extends Component {
for (let items of data) { for (let items of data) {
arrayTem.push({ name: items.class_name, id: items.class_id }) arrayTem.push({ name: items.class_name, id: items.class_id })
if (items.child.length) { if (items.child.length) {
arrayTem[arrayTem.length - 1].children = [{ name: '可选', id: '' }, ...this.recursionInteraction(items.child)] arrayTem[arrayTem.length - 1].children = [{ name: '--', id: '' }, ...this.recursionInteraction(items.child)]
} else { } else {
arrayTem[arrayTem.length - 1].children = [{ name: '', id: '' }] arrayTem[arrayTem.length - 1].children = [{ name: '--', id: '' }]
} }
} }
return arrayTem // 返回联动数据 return arrayTem // 返回联动数据
@ -90,8 +88,10 @@ class Interaction extends Component {
if (data.length) { if (data.length) {
for (let item of data) { for (let item of data) {
arrayTem.push({ name: item.class_name, id: item.class_id }) arrayTem.push({ name: item.class_name, id: item.class_id })
if (data.indexOf(item) === 0) {
item.child.length ? childrenHolderArray.push(...item.child) : null item.child.length ? childrenHolderArray.push(...item.child) : null
} }
}
this.recursionInitialized(childrenHolderArray) this.recursionInitialized(childrenHolderArray)
} }
arrayTem.length ? initialDataArray.push(arrayTem) : null // 数组为空则不添加 arrayTem.length ? initialDataArray.push(arrayTem) : null // 数组为空则不添加
@ -124,7 +124,7 @@ class Interaction extends Component {
const indexNumber = Number(index) const indexNumber = Number(index)
if (indexNumber === data.multiIndex[0]) { if (indexNumber === data.multiIndex[0]) {
data.multiArray[1] = this.state.interactionMultiArray[indexNumber].children data.multiArray[1] = this.state.interactionMultiArray[indexNumber].children
console.log('datat',data) console.log('datat', data)
} }
} }
} }

View File

@ -391,7 +391,7 @@ class GoodsPublish extends Component {
<AtTextarea <AtTextarea
value={this.state.productDescript} value={this.state.productDescript}
onChange={this.productDescriptChange.bind(this)} onChange={this.productDescriptChange.bind(this)}
maxlength='200' maxlength='140'
placeholder='你的产品简介' placeholder='你的产品简介'
/> />
</View> </View>

View File

@ -189,7 +189,6 @@ class Home extends Component {
Taro.showLoading({ Taro.showLoading({
title: '加载中' title: '加载中'
}) })
console.log('item', item)
this.setState({ parentClass: item.class_id, childClass: item.class_id, supplyLevel: 1, subCate: item.children || [] }, () => { this.setState({ parentClass: item.class_id, childClass: item.class_id, supplyLevel: 1, subCate: item.children || [] }, () => {
this.getShops({}) this.getShops({})
}) })
@ -382,6 +381,8 @@ class Home extends Component {
return <FilteredShopComponent return <FilteredShopComponent
shop={item} shop={item}
key={index} key={index}
categoryLevel={this.state.supplyLevel}
classId={this.state.parentClass===this.state.childClass?this.state.parentClass:this.state.childClass}
></FilteredShopComponent> ></FilteredShopComponent>
}) : <View className='no-more-title top'> 没有更多了</View> }) : <View className='no-more-title top'> 没有更多了</View>
const subCateElementsArray = this.state.subCate.length ? this.state.subCate.map((item, index) => { const subCateElementsArray = this.state.subCate.length ? this.state.subCate.map((item, index) => {

View File

@ -412,7 +412,7 @@ class MyDemandSupplyEdit extends Component {
<AtTextarea <AtTextarea
value={this.state.contactAddress} value={this.state.contactAddress}
onChange={this.contactAddressChange.bind(this)} onChange={this.contactAddressChange.bind(this)}
maxlength='200' maxlength='140'
placeholder='联系地址' placeholder='联系地址'
/> />
</View> </View>
@ -423,7 +423,7 @@ class MyDemandSupplyEdit extends Component {
<AtTextarea <AtTextarea
value={this.state.content} value={this.state.content}
onChange={this.contentChange.bind(this)} onChange={this.contentChange.bind(this)}
maxlength='200' maxlength='140'
placeholder='' placeholder=''
/> />
</View> </View>

View File

@ -443,7 +443,7 @@ class MyGoodsEdit extends Component {
<AtTextarea <AtTextarea
value={this.state.productDescript} value={this.state.productDescript}
onChange={this.productDescriptChange.bind(this)} onChange={this.productDescriptChange.bind(this)}
maxlength='200' maxlength='140'
placeholder='你的产品简介' placeholder='你的产品简介'
/> />

View File

@ -105,31 +105,33 @@ class MyNeeds extends Component {
this.setState({ isAddToList: false }) this.setState({ isAddToList: false })
this.setState({ this.setState({
allNeedsList: res.data.supplys, allNeedsList: res.data.supplys,
totalNeeds:Number(res.data.count) totalNeeds: Number(res.data.count)
}) })
} }
} else { } else {
if(this.state.isAddToList){ if (this.state.isAddToList) {
this.setState({ isAddToList: false }) this.setState({ isAddToList: false })
Taro.showToast({ Taro.showToast({
title: '没有更多了', title: '没有更多了',
icon: 'none' icon: 'none'
}) })
}else{
this.setState({allNeedsList:[],totalNeeds:0})
}
}
} else { } else {
if(JSON.parse(res.data).err_code===88888){ this.setState({ allNeedsList: [], totalNeeds: 0 })
loginExpired(res) }
}
} else if (JSON.parse(res.data).err_code === 88888) {
const response={data:JSON.parse(res.data)}
loginExpired(response)
}
else {
}else{
Taro.showToast({ Taro.showToast({
title: res.data.err_msg, title: res.data.err_msg,
icon: 'none' icon: 'none'
}) })
}
} }
}) })
@ -163,7 +165,7 @@ class MyNeeds extends Component {
this.getMyNeedsList({ this.getMyNeedsList({
}) })
}, 1500); }, 1500);
}else if (res.data.err_code === 88888) { } else if (res.data.err_code === 88888) {
loginExpired(res) loginExpired(res)
} else { } else {
Taro.showToast({ Taro.showToast({
@ -454,7 +456,7 @@ class MyNeeds extends Component {
</View> </View>
{/* 我的需求信息 */} {/* 我的需求信息 */}
{<View className='info-box'> {<View className='info-box'>
{this.state.allNeedsList.length?myNeedsListArrayElement:<View className='no-more-title'>没有更多了</View>} {this.state.allNeedsList.length ? myNeedsListArrayElement : <View className='no-more-title'>没有更多了</View>}
</View>} </View>}
{this.state.isShowTopNav ? <ScrollToTopComponent ></ScrollToTopComponent> : null} {this.state.isShowTopNav ? <ScrollToTopComponent ></ScrollToTopComponent> : null}

View File

@ -462,7 +462,7 @@ class MyNeedsEdit extends Component {
<AtTextarea <AtTextarea
value={this.state.contactAddress} value={this.state.contactAddress}
onChange={this.contactAddressChange.bind(this)} onChange={this.contactAddressChange.bind(this)}
maxlength='200' maxlength='140'
placeholder='联系地址' placeholder='联系地址'
/> />
</View> </View>
@ -473,7 +473,7 @@ class MyNeedsEdit extends Component {
<AtTextarea <AtTextarea
value={this.state.content} value={this.state.content}
onChange={this.contentChange.bind(this)} onChange={this.contentChange.bind(this)}
maxlength='200' maxlength='140'
placeholder='' placeholder=''
/> />
</View> </View>

View File

@ -27,8 +27,8 @@ class MyNeedsPublish extends Component {
needsType: [{ name: '业主需求', id: '4' }, { name: '效果图', id: '5' }], needsType: [{ name: '业主需求', id: '4' }, { name: '效果图', id: '5' }],
needsTypeSelected: { name: '业主需求', id: '4' }, needsTypeSelected: { name: '业主需求', id: '4' },
title: '', title: '',
contactName: Taro.getStorageSync('user_identity').username, contactName: Taro.getStorageSync('user_identity').username||'',
contactNumber: Taro.getStorageSync('user_identity').userphone, contactNumber: Taro.getStorageSync('user_identity').userphone||'',
contactAddress: '', contactAddress: '',
content: '', content: '',
pickerImageUrl: [], // 上传的图片 pickerImageUrl: [], // 上传的图片
@ -337,7 +337,7 @@ class MyNeedsPublish extends Component {
<AtTextarea <AtTextarea
value={this.state.contactAddress} value={this.state.contactAddress}
onChange={this.contactAddressChange.bind(this)} onChange={this.contactAddressChange.bind(this)}
maxlength='200' maxlength='140'
placeholder='联系地址' placeholder='联系地址'
/> />
</View> </View>
@ -348,7 +348,7 @@ class MyNeedsPublish extends Component {
<AtTextarea <AtTextarea
value={this.state.content} value={this.state.content}
onChange={this.contentChange.bind(this)} onChange={this.contentChange.bind(this)}
maxlength='200' maxlength='140'
placeholder='' placeholder=''
/> />
</View> </View>

View File

@ -318,7 +318,7 @@ class Shop extends Component {
}) })
.then(res => { .then(res => {
Taro.hideLoading() Taro.hideLoading()
if (res.data.err_msg === 0) { if (res.data.err_code === 0) {
this.setState({ this.setState({
shopDescriptionData: res.data, shopDescriptionData: res.data,
shopName: res.data.data.shop_name, shopName: res.data.data.shop_name,

View File

@ -280,7 +280,8 @@ class SupplyDemand extends Component {
<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 className='picker'> <View className='picker'>
<View className='title-box'> <View className='title-box'>
<Text className='title'><Text className='require'>*</Text>:</Text> <Text className='selected'>{this.state.demandingSupplyCateSelected.name}</Text> <Text className='title'><Text className='require'>*</Text>:</Text>
<Text className='selected'>{this.state.demandingSupplyCateSelected.name}</Text>
</View> </View>
</View> </View>
@ -288,7 +289,8 @@ class SupplyDemand extends Component {
</View> </View>
</View> </View>
<View className='border-box'> <View className='border-box'>
<Text className='require'>*</Text><AtInput <Text className='require'>*</Text>
<AtInput
name='value' name='value'
title='需求标题:' title='需求标题:'
type='text' type='text'
@ -330,7 +332,7 @@ class SupplyDemand extends Component {
<AtTextarea <AtTextarea
value={this.state.contactAddress} value={this.state.contactAddress}
onChange={this.contactAddressChange.bind(this)} onChange={this.contactAddressChange.bind(this)}
maxlength='200' maxlength='140'
placeholder='联系地址' placeholder='联系地址'
/> />
</View> </View>
@ -341,7 +343,7 @@ class SupplyDemand extends Component {
<AtTextarea <AtTextarea
value={this.state.content} value={this.state.content}
onChange={this.contentChange.bind(this)} onChange={this.contentChange.bind(this)}
maxlength='200' maxlength='140'
placeholder='' placeholder=''
/> />
</View> </View>

View File

@ -19,52 +19,372 @@ bug 商品编辑 增加图片后 图片顺序乱了
等待后台--- 单个我的商品页面的图片顺序,单个我的需求页面的接口, 当个我哦的需求编辑页面的接口 等待后台--- 单个我的商品页面的图片顺序,单个我的需求页面的接口, 当个我哦的需求编辑页面的接口
import Taro, { Component } from '@tarojs/taro'
import { View, Text } from '@tarojs/components'
import { Picker } from 'taro-ui'
import './goodsTypeInteractionComp.scss'
import loginExpired from '../../util/loginExpired'
let maxDepth = 0
let initialDataArray = []
class GoodsTypeInteractionComp extends Component {
config = {
navigationBarTitleText: 'goodsTypeInteractionComp'
}
constructor() {
super(...arguments);
this.state = {
///---行业分类 开始
initailMultiArray: [[{ class_name: '选择商品分类', class_id: '' }], [], []], // 初始化底部数据
multiIndex: [0, 0, 0, 0],// 默认联动列数为4个并且每一列都是第一行
interactionMultiArray: [],// 联动
///---行业分类 结束
}
}
//商品目录请求api GetShopCategoryList
getProductCateList(url) {
Taro.request({
url: url,
method: 'POST',
dataType: 'json',
header: {
'content-type': 'application/x-www-form-urlencoded',
'Cookie': 'PFWSSS=' + Taro.getStorageSync('session_id'),
'X-Requested-With': 'XMLHttpRequest'
}
})
.then(res => {
if (res.data.err_code === 0) {
console.log('商品分类目录', res)
const recursionInteractionData=this.recursionInteraction(res.data.data)
this.recursionInitialized(res.data.data) //
console.log('initialDataArray',initialDataArray.reverse())
this.setState({
interactionMultiArray: recursionInteractionData,
multiIndex: this.recursionDepth(res.data.data),
initailMultiArray:initialDataArray.reverse()
}, () => {
initialDataArray=[]// 把全局变变量赋值给state之后初始化商品分类为空 不然第二次进去的时候会自动添加进去
// console.log('联动数据', this.state.interactionMultiArray)
// console.log('初始化数据', this.state.initailMultiArray)
}) // 用递归来整理无限层次的数据
// console.log('联动数据', this.recursionInteraction(res.data.data))
// console.log('初始数据', this.recursionInitialized(res.data.data).reverse())
}else if (res.data.err_code === 88888) {
loginExpired(res)
} else {
Taro.showToast({
title: res.data.err_msg,
icon: 'none'
})
}
}
)
.catch(error => {
console.log('商品分类请求错误', error)
})
}
//联动确认
bindMultiPickerChange(e) {
// 如果没有上商品 那就不执行
if(Taro.getStorageSync('shopInfo').shop_id){
this.setState({
multiIndex: e.detail.value.map(item => { if (item === null) { item = 0 } return item })
}, () => {
// console.log('picker发送选择改变携带值为', this.state.multiIndex)
this.returnResultToParent()
})
}
}
returnResultToParent() {
let selected = this.state.interactionMultiArray
for (let index of this.state.multiIndex) {
if (selected[index].children[0].id) {
selected = selected[index].children
} else {
this.props.onPassDataToChild(selected[index])
break
}
}
}
// 递归整理无限层初始数据,将整理好的数据赋值给initialDataArray
recursionInitialized(data) {
const arrayTem = []
if (data.length) {
for (let item of data) {
arrayTem.push({ name: item.class_name, id: item.class_id })
}
}
if(data[0].children.length){
this.recursionInitialized(data[0].children)
}
initialDataArray.push(arrayTem)
return arrayTem
}
// 递归整理无限层联动数据
recursionInteraction(data) {
let arrayTem = []
for (let items of data) {
arrayTem.push({ name: items.class_name, id: items.class_id })
if (items.children) {
arrayTem[arrayTem.length - 1].children = this.recursionInteraction(items.children)
} else {
arrayTem[arrayTem.length - 1].children = [{ name: '', id: '' }]
}
}
return arrayTem // 返回联动数据
// return arrayTem
}
// 递归整理无限层初始数据
// recursionInitialized(data) {
// const arrayTem = []
// const childrenHolderArray = []
// if (data.length) {
// for (let item of data) {
// arrayTem.push({ name: item.class_name, id: item.class_id })
// item.children ? childrenHolderArray.push(...item.children) : null
// }
// this.recursionInitialized(childrenHolderArray)
// }
// arrayTem.length ? initialDataArray.push(arrayTem) : null // 数组为空则不添加
// return initialDataArray
// }
// 递归整理无限层初始数据
recursionDepth(data) {
const arrayTem = []
const childrenHolderArray = []
if (data.length) {
for (let item of data) {
arrayTem.push({ name: item.class_name, id: item.class_id })
item.children ? childrenHolderArray.push(...item.children) : null
}
this.recursionDepth(childrenHolderArray)
maxDepth += 1
}
return new Array(maxDepth).fill(0)
}
// 触动联动筛选
bindMultiPickerCol(e) {
console.log('修改的列为', e.detail.column, ',值为', e.detail.value)
console.log(this.state.initailMultiArray)
const data = {
multiArray: this.state.initailMultiArray,
multiIndex: this.state.multiIndex
}
data.multiIndex[e.detail.column] = e.detail.value
if (e.detail.column == 0) {
for (let index in data.multiArray[0]) {
const indexNumber = Number(index)
if (indexNumber === data.multiIndex[0]) {
// data.multiArray[1] = this.state.interactionMultiArray[indexNumber].children
// data.multiArray[2] = this.state.interactionMultiArray[indexNumber].children[0].children
// data.multiArray[3] = this.state.interactionMultiArray[indexNumber].children[0].children[0].children
data.multiArray[1] = this.state.interactionMultiArray[indexNumber].children
data.multiArray[2] = this.state.interactionMultiArray[indexNumber].children[data.multiIndex[1]].children
data.multiArray[3] = this.state.interactionMultiArray[indexNumber].children[data.multiIndex[1]].children[data.multiIndex[2]].children
}
}
} else if (e.detail.column == 1) {
for (let index in data.multiArray[1]) {
const indexNumber = Number(index)
if (indexNumber === data.multiIndex[1]) {
data.multiArray[2] = this.state.interactionMultiArray[data.multiIndex[0]].children[indexNumber].children
}
}
}
else if (e.detail.column == 2) {
for (let index in data.multiArray[2]) {
const indexNumber = Number(index)
if (indexNumber === data.multiIndex[2]) {
data.multiArray[3] = this.state.interactionMultiArray[data.multiIndex[0]].children[data.multiIndex[1]].children[indexNumber].children
}
}
}
// switch (e.detail.column) {// 移动了第几列
// case 0:
// switch (data.multiIndex[0]) { // 第一个index 是多少
// case 0:
// data.multiArray[1] = this.state.interactionMultiArray[0].children
// data.multiArray[2]=this.state.interactionMultiArray[0].children[0].children
// break
// case 1:
// data.multiArray[1] = this.state.interactionMultiArray[1].children
// break
// case 2:
// data.multiArray[1] = this.state.interactionMultiArray[2].children
// break
// case 3:
// data.multiArray[1] = this.state.interactionMultiArray[3].children
// break
// case 4:
// data.multiArray[1] = this.state.interactionMultiArray[4].children
// break
// }
// data.multiIndex[1] = 0
// data.multiIndex[2] = 0
// data.multiIndex[3] = 0
// break
// case 1:
// switch (data.multiIndex[0]) {
// case 0:
// break
// case 1:
// switch (data.multiIndex[1]) {
// case 0:
// data.multiArray[2] = this.state.interactionMultiArray[1].children[0].children
// break
// case 1:
// data.multiArray[2] = this.state.interactionMultiArray[1].children[1].children
// break
// case 2:
// data.multiArray[2] = this.state.interactionMultiArray[1].children[2].children
// break
// case 3:
// data.multiArray[2] = this.state.interactionMultiArray[1].children[3].children ? this.state.interactionMultiArray[1].children[3].children : [{ class_name: '' }]
// break
// }
// break
// case 2:
// switch (data.multiIndex[1]) {
// case 0:
// data.multiArray[2] = this.state.interactionMultiArray[2].children[0].children
// break
// case 1:
// data.multiArray[2] = this.state.interactionMultiArray[2].children[1].children
// break
// case 2:
// data.multiArray[2] = this.state.interactionMultiArray[2].children[2].children
// break
// case 3:
// data.multiArray[2] = this.state.interactionMultiArray[2].children[3].children
// break
// case 4:
// data.multiArray[2] = this.state.interactionMultiArray[2].children[4].children
// break
// case 5:
// data.multiArray[2] = this.state.interactionMultiArray[2].children[5].children
// break
// }
// break
// case 3:
// switch (data.multiIndex[1]) {
// case 0:
// data.multiArray[2] = this.state.interactionMultiArray[3].children[0].children
// break
// case 1:
// data.multiArray[2] = this.state.interactionMultiArray[3].children[1].children
// break
// case 2:
// data.multiArray[2] = this.state.interactionMultiArray[3].children[2].children
// break
// case 3:
// data.multiArray[2] = this.state.interactionMultiArray[3].children[3].children
// break
// case 3:
// data.multiArray[2] = this.state.interactionMultiArray[3].children[3].children
// break
// }
// break
// case 4:
// switch (data.multiIndex[1]) {
// case 0:
// data.multiArray[2] = this.state.interactionMultiArray[4].children[0].children
// break
// case 1:
// data.multiArray[2] = this.state.interactionMultiArray[4].children[1].children
// break
// case 2:
// data.multiArray[2] = this.state.interactionMultiArray[4].children[2].children
// break
// }
// break
// }
// data.multiIndex[2] = 0
// data.multiIndex[3] = 0
// break
// }
this.setState({ multiIndex: data.multiIndex })
}
componentDidMount() {
if(Taro.getStorageSync('shopInfo').shop_id){
this.getProductCateList(this.props.url)
}else{
}
}
// 当然父组件有新的props的 会从新渲染组件
componentWillReceiveProps(nextProps) {
}
componentWillUnmount() { }
componentDidShow() { }
componentDidHide() { }
render() {
return (
<View class='page-section'>
<Picker
rangeKey='name'
mode='multiSelector'
onChange={this.bindMultiPickerChange.bind(this)}
onColumnchange={this.bindMultiPickerCol.bind(this)}
value={this.state.multiIndex}
range={this.state.initailMultiArray}
>
<View class='picker type'>
<View className='title-box'>
<Text className='require'>*</Text>
<Text className='title'>商品分类:</Text>
<Text className='first-col'>
{this.props.selectedValue.name}
</Text>
{/* {this.state.initailMultiArray[0].length?<Text className='first-col'> {this.state.initailMultiArray[0][this.state.multiIndex[0]].name}</Text>:null}
{this.state.initailMultiArray[1].length?<Text className='second-col'>{this.state.initailMultiArray[1][this.state.multiIndex[1]].name}</Text>:null}
{this.state.initailMultiArray[2].length?<Text className='third-col'>{this.state.initailMultiArray[2][this.state.multiIndex[2]].name}</Text>:null} */}
const selfAndAvailable = localStoageUserId === this.state.userId && this.state.stateId === '1' && <View className='button-box'>
<View className='button' onClick={this.goMyNeedsPublishPage.bind(this)}>
<Button size='mini' className='button-green'>
<AtIcon value='add' size='12' color='white'></AtIcon>
新增</Button>
</View> </View>
<View className='button' onClick={this.goToMyNeedsPage.bind(this)}>
<Button size='mini' className='button-green'>
<AtIcon value='' size='12' color='white'></AtIcon>
我的需求</Button>
</View> </View>
<View className='button' onClick={this.goMyNeedEditPage.bind(this)}> </Picker>
<Button size='mini' className='button-orange'>
<AtIcon value='settings' size='12' color='white'></AtIcon>
修改</Button>
</View> </View>
<View className='button' onClick={this.deleteButton.bind(this)}>
<Button size='mini' className='button-dark-red'>
<AtIcon value='trash' size='12' color='white'></AtIcon>
删除</Button>
</View>
</View>
const selfAndUnAvaialble = localStoageUserId === this.state.userId && this.state.stateId != '1' && <View className='button-box'> )
<View className='button' onClick={this.goMyNeedsPublishPage.bind(this)}> }
<Button size='mini' className='button-green'> }
<AtIcon value='add' size='12' color='white'></AtIcon>
新增</Button> export default GoodsTypeInteractionComp
</View>
<View className='button' onClick={this.goToMyNeedsPage.bind(this)}>
<Button size='mini' className='button-green'>
<AtIcon value='' size='12' color='white'></AtIcon>
我的需求</Button>
</View>
</View>
const Avaialble = this.state.stateId === '1' && <View className='button' onClick={this.grabButtonHandler.bind(this)}>
<Button size='mini' className='button-orange'>抢单</Button>
</View>
const Unavailable = this.state.stateId === '2' && <View className='button'>
<Button size='mini' className='button-orange blur'>{this.state.stateName}</Button>
</View>
const SoldOut = this.state.stateId === '3' && <View className='button'>
<Button size='mini' className='button-orange blur'>{this.state.stateName}</Button>
</View>
const ButtonElement = selfAndAvailable || selfAndUnAvaialble || Avaialble || Unavailable || SoldOut