2019-03-14 17:19:08 +08:00
|
|
|
|
todo list:
|
|
|
|
|
首页:
|
|
|
|
|
商品发布页面:
|
|
|
|
|
|
|
|
|
|
供求发布页面
|
|
|
|
|
全部业主需求页面:
|
|
|
|
|
我的供求页面:
|
|
|
|
|
我的商品列表页面
|
|
|
|
|
商品编辑页面
|
|
|
|
|
|
|
|
|
|
我的需求列表页面:
|
|
|
|
|
接口问题:
|
|
|
|
|
优惠卷和询价
|
|
|
|
|
bug: 商品编辑 增加图片后 图片顺序乱了
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
等待后台--- 单个我的商品页面的图片顺序,单个我的需求页面的接口, 当个我哦的需求编辑页面的接口
|
2019-03-15 11:35:42 +08:00
|
|
|
|
<View className='details-box'>
|
2019-03-14 17:19:08 +08:00
|
|
|
|
|
2019-03-18 17:34:15 +08:00
|
|
|
|
// shop interaction
|
|
|
|
|
import Taro, { Component } from '@tarojs/taro'
|
|
|
|
|
import { View, Text,Picker } from '@tarojs/components'
|
2019-03-14 17:19:08 +08:00
|
|
|
|
|
|
|
|
|
|
2019-03-18 17:34:15 +08:00
|
|
|
|
import './shopTypeInteractionComp.scss'
|
|
|
|
|
import loginExpired from '../../util/loginExpired';
|
|
|
|
|
import { getGlobalStorage,setGlobalStorage } from '../../util/getSetStoage';
|
2019-03-14 17:19:08 +08:00
|
|
|
|
|
|
|
|
|
|
2019-03-18 17:34:15 +08:00
|
|
|
|
class ShopTypeInteractionComp extends Component {
|
|
|
|
|
|
|
|
|
|
config = {
|
|
|
|
|
navigationBarTitleText: 'shopTypeInteractionComp'
|
|
|
|
|
}
|
|
|
|
|
constructor() {
|
|
|
|
|
super(...arguments);
|
|
|
|
|
|
|
|
|
|
this.state = {
|
|
|
|
|
initailMultiArray: [[{}], [{ name: '选择店铺分类', id: '' }]],
|
|
|
|
|
multiIndex: [0, 0],
|
|
|
|
|
interactionMultiArray: [],// 联动数据
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
// 店铺分类筛选列表GetShopTypeList
|
|
|
|
|
getShopTypeList(url) {
|
|
|
|
|
Taro.request({
|
|
|
|
|
url: url,
|
|
|
|
|
method: 'POST',
|
|
|
|
|
dataType: 'json',
|
|
|
|
|
data: {
|
|
|
|
|
id: this.props.shopId,
|
|
|
|
|
},
|
|
|
|
|
header: {
|
|
|
|
|
'content-type': 'application/x-www-form-urlencoded',
|
|
|
|
|
'Cookie': 'PFWSSS=' + getGlobalStorage('session_id'),
|
|
|
|
|
'X-Requested-With': 'XMLHttpRequest'
|
2019-03-15 11:35:42 +08:00
|
|
|
|
}
|
2019-03-18 17:34:15 +08:00
|
|
|
|
})
|
|
|
|
|
.then(res => {
|
|
|
|
|
// console.log('店铺分类目录', res)
|
|
|
|
|
// this.formatIndustryType(res.data.data)
|
|
|
|
|
// this.formatIndustTypeInit(res.data.data)
|
|
|
|
|
if (res.data.err_code === 0) {
|
|
|
|
|
if (res.data.data === null) {
|
|
|
|
|
return
|
|
|
|
|
}
|
|
|
|
|
console.log('店铺分类目录', res)
|
|
|
|
|
if(!getGlobalStorage('shopTypeObject')){
|
|
|
|
|
setGlobalStorage('shopTypeObject',res.data.data)
|
|
|
|
|
}
|
|
|
|
|
this.setState({
|
|
|
|
|
interactionMultiArray: this.interactionData(res.data.data),
|
|
|
|
|
initailMultiArray: this.initializedData(res.data.data)[0],
|
|
|
|
|
}, () => {
|
|
|
|
|
|
|
|
|
|
console.log('state',this.state.initailMultiArray,this.state.interactionMultiArray)
|
|
|
|
|
// this.passDataToParent(this.state.initailMultiArray)
|
|
|
|
|
//返回初始选项在 在商品编辑页面
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// console.log('联动数据', this.state.interactionMultiArray)
|
|
|
|
|
// console.log('初始化数据', this.state.initailMultiArray)
|
|
|
|
|
// console.log('index初始化', this.state.multiIndex)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}) // 用递归来整理无限层次的数据
|
|
|
|
|
}else if (res.data.err_code === 88888) {
|
|
|
|
|
loginExpired(res)
|
|
|
|
|
} else {
|
|
|
|
|
console.log('店铺分类目录获取失败', res)
|
|
|
|
|
}
|
2019-03-15 11:35:42 +08:00
|
|
|
|
}
|
2019-03-18 17:34:15 +08:00
|
|
|
|
)
|
|
|
|
|
.catch(error => {
|
|
|
|
|
console.log('店铺分类请求错误', error)
|
|
|
|
|
})
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// 递归整理无限层联动数据
|
|
|
|
|
interactionData(data) {
|
|
|
|
|
let parentArrayHolder = []
|
|
|
|
|
const keys = Object.keys(data)
|
|
|
|
|
for (let key of keys) {
|
|
|
|
|
let childrenArrayHolder = []
|
|
|
|
|
let parent = { name: data[key].n, id: key }
|
|
|
|
|
parentArrayHolder.push(parent)
|
|
|
|
|
for (let childItem of data[key].c) {
|
|
|
|
|
let child = { name: childItem.n, id: childItem.id }
|
|
|
|
|
childrenArrayHolder.push(child)
|
2019-03-15 11:35:42 +08:00
|
|
|
|
}
|
2019-03-18 17:34:15 +08:00
|
|
|
|
parent.children = childrenArrayHolder
|
|
|
|
|
}
|
|
|
|
|
return parentArrayHolder
|
|
|
|
|
}
|
|
|
|
|
// 递归整理无限层初始数据
|
|
|
|
|
initializedData(data) {
|
|
|
|
|
let outter = []
|
|
|
|
|
let inner = []
|
|
|
|
|
const keys = Object.keys(data)
|
|
|
|
|
for (let key of keys) {
|
|
|
|
|
outter.push({ name: data[key].n, id: key })
|
|
|
|
|
for (let child of data[key].c) {
|
|
|
|
|
inner.push({ name: child.n, id: child.id })
|
2019-03-15 11:35:42 +08:00
|
|
|
|
}
|
2019-03-18 17:34:15 +08:00
|
|
|
|
}
|
|
|
|
|
return [outter, inner]
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// 触动联动筛选
|
|
|
|
|
bindMultiPickerCol(e) {
|
|
|
|
|
console.log('修改的列为', e.detail.column, ',值为', e.detail.value)
|
|
|
|
|
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
|
|
|
|
|
}
|
2019-03-15 11:35:42 +08:00
|
|
|
|
}
|
2019-03-18 17:34:15 +08:00
|
|
|
|
}
|
|
|
|
|
this.setState({ multiIndex: data.multiIndex })
|
|
|
|
|
}
|
|
|
|
|
bindMultiPickerChange(e) {
|
|
|
|
|
// console.log('picker发送选择改变,携带值为', e.detail.value)
|
|
|
|
|
if (getGlobalStorage('shopInfo').shop_id) {
|
|
|
|
|
this.setState({
|
|
|
|
|
multiIndex: e.detail.value,
|
|
|
|
|
}, () => {
|
|
|
|
|
//判断如果interactionMultiArray 的子类为空 那就取父类, 反之取子类
|
|
|
|
|
let industryTypeSelected
|
|
|
|
|
industryTypeSelected = this.state.interactionMultiArray[this.state.multiIndex[0]].children[this.state.multiIndex[1]]
|
|
|
|
|
this.passDataToParent(industryTypeSelected)
|
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//--------------------结束-行业分类picker
|
|
|
|
|
passDataToParent(industryTypeSelected) {
|
|
|
|
|
this.props.onPassDataToChild(industryTypeSelected)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
componentDidMount() {
|
|
|
|
|
this.getShopTypeList(this.props.url)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// 当然父组件有新的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>
|
|
|
|
|
</View>
|
|
|
|
|
</View>
|
|
|
|
|
</Picker>
|
|
|
|
|
</View>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
)
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
export default ShopTypeInteractionComp
|
2019-03-14 17:19:08 +08:00
|
|
|
|
|
|
|
|
|
|