diff --git a/src/component/filteredShopComponent/voucherPosterComponent/voucherPosterComponent.js b/src/component/filteredShopComponent/voucherPosterComponent/voucherPosterComponent.js index 536c190..56c99df 100644 --- a/src/component/filteredShopComponent/voucherPosterComponent/voucherPosterComponent.js +++ b/src/component/filteredShopComponent/voucherPosterComponent/voucherPosterComponent.js @@ -122,19 +122,18 @@ class VoucherPoster extends Component { - + - + 当前优惠卷{this.props.voucherLeft} - - + 联系人: - + 联系电话: @@ -149,10 +148,10 @@ class VoucherPoster extends Component { {this.props.voucherResponseMsg} - + - + 领取须知: diff --git a/src/component/filteredShopComponent/voucherPosterComponent/voucherPosterComponent.scss b/src/component/filteredShopComponent/voucherPosterComponent/voucherPosterComponent.scss index ed40f27..8f24fcf 100644 --- a/src/component/filteredShopComponent/voucherPosterComponent/voucherPosterComponent.scss +++ b/src/component/filteredShopComponent/voucherPosterComponent/voucherPosterComponent.scss @@ -56,26 +56,26 @@ $linearOrange:linear-gradient(to right, #FF7142, #FF7142); font-size: 50px; } } - // .input-name,.input-number{ - // margin-top:2%; - // margin-left:10%; + .input-name,.input-number{ + margin-top:2%; + margin-left:10%; - // overflow: hidden; - // width: 80%; + overflow: hidden; + width: 80%; - // border-radius:50rpx; - // background-color: white; + border-radius:50rpx; + background-color: white; - // height:80px; - // font-size:25px; - // display:flex; - // align-items:center; - // .title{ - // margin-left:7%; - // } + height:80px; + font-size:25px; + display:flex; + align-items:center; + .title{ + margin-left:7%; + } - // } + } .tips{ diff --git a/src/component/goodsTypeInteractionComp/goodsTypeInteractionComp.js b/src/component/goodsTypeInteractionComp/goodsTypeInteractionComp.js index 793ed60..4cde673 100644 --- a/src/component/goodsTypeInteractionComp/goodsTypeInteractionComp.js +++ b/src/component/goodsTypeInteractionComp/goodsTypeInteractionComp.js @@ -7,6 +7,7 @@ import { Picker } from 'taro-ui' import './goodsTypeInteractionComp.scss' + class GoodsTypeInteractionComp extends Component { config = { @@ -17,9 +18,10 @@ class GoodsTypeInteractionComp extends Component { this.state = { ///---行业分类 开始 - objectMultiArray: [[{name:'选择商品分类',id:''}],[],[]], - multiIndex: [0, 0, 0], + objectMultiArray: [[{ class_name: '选择商品分类', class_id: '' }], [], []], + multiIndex: [0, 0, 0, 0], formatInWindow: [], + ///---行业分类 结束 } @@ -39,8 +41,15 @@ class GoodsTypeInteractionComp extends Component { .then(res => { if (res.data.err_msg === 'success') { console.log('商品分类目录', res) - this.formatIndustryType(res.data.data) + // this.formatIndustryType(res.data.data) this.formatIndustTypeInit(res.data.data) + this.setState({ + formatInWindow: this.recursion(res.data.data).multiObject, + DataDepth:this.recursion(res.data.data).depth },()=>{ + console.log('depth',this.state.DataDepth) + }) // 用递归来整理无限层次的数据 + // console.log(this.recursion(res.data.data)) + // this.setState({objectMultiArray:res.data.data}) } else { console.log('商品分类请求没有成功', res) } @@ -50,6 +59,9 @@ class GoodsTypeInteractionComp extends Component { console.log('商品分类请求错误', error) }) } + + + // 第一种formate 用于底部弹层滚动时的数据 formatIndustryType(data) { const newIndustryType = [] @@ -62,7 +74,15 @@ class GoodsTypeInteractionComp extends Component { outterObject.children.push(middleObject) if (middler.children) { for (let inner of middler.children) { - middleObject.children.push({ name: inner.class_name, id: inner.class_id }) + const innerObject = { name: inner.class_name, id: inner.class_id, children: [] } + middleObject.children.push(innerObject) + if (inner.children) { + for (let final of inner.children) { + innerObject.children.push({ name: final.class_name, id: final.class_id }) + } + } else { + innerObject.children.push({ name: '', id: '' }) + } } } else { middleObject.children.push({ name: '', id: '' }) @@ -76,7 +96,6 @@ class GoodsTypeInteractionComp extends Component { } else { console.log('店铺分类数据问题') } - this.setState({ formatInWindow: newIndustryType }, () => { console.log('滚动时的数据', this.state.formatInWindow) }) @@ -100,10 +119,9 @@ class GoodsTypeInteractionComp extends Component { } } // 这里不能加入secondArray,和thirdArray 会有bug - this.setState({ objectMultiArray: [firstArray, [{ name: '', id: '' }], [{ name: '', id: '' }]] }, () => { + this.setState({ objectMultiArray: [firstArray, secondArray, thirdArray] }, () => { console.log('初始化数据', this.state.objectMultiArray) }) - } //--- 三级联动-------------- bindMultiPickerChange(e) { @@ -112,10 +130,6 @@ class GoodsTypeInteractionComp extends Component { multiIndex: e.detail.value }, () => { this.returnResultToParent() - - - - }) } returnResultToParent() { @@ -123,7 +137,6 @@ class GoodsTypeInteractionComp extends Component { let outter = this.state.formatInWindow[this.state.multiIndex[0]] let middler = outter.children[this.state.multiIndex[1]] let inner = middler.children[this.state.multiIndex[2]] - if (outter.id) { result = outter if (middler.id) { @@ -131,11 +144,34 @@ class GoodsTypeInteractionComp extends Component { if (inner.id) { result = inner } - } + } } - this.passDataToParent(result) } + + // 递归整理无限层数据 + recursion(data) { + let arrayTem = [] + let depth=0 + const depthArray=[] + for (let items of data) { + arrayTem.push({ name: items.class_name, id: items.class_id }) + if (items.children) { + arrayTem[arrayTem.length - 1].children = this.recursion(items.children) + depth+=1 + } else { + + depthArray.push(depth) + arrayTem[arrayTem.length - 1].children = [{ name: '', id: '' }] + } + } + return {multiObject:arrayTem,depth:depthArray} + } + + + + + bindMultiPickerCol(e) { console.log('修改的列为', e.detail.column, ',值为', e.detail.value) const data = { @@ -143,110 +179,144 @@ class GoodsTypeInteractionComp extends Component { multiIndex: this.state.multiIndex } data.multiIndex[e.detail.column] = e.detail.value - switch (e.detail.column) { - case 0: - switch (data.multiIndex[0]) { - case 0: - data.multiArray[1] = this.state.formatInWindow[0].children - data.multiArray[2] = this.state.formatInWindow[0].children - break - case 1: - data.multiArray[1] = this.state.formatInWindow[1].children - break - case 2: - data.multiArray[1] = this.state.formatInWindow[2].children - break - case 3: - data.multiArray[1] = this.state.formatInWindow[3].children - break - case 4: - data.multiArray[1] = this.state.formatInWindow[4].children - break + + + 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.formatInWindow[indexNumber].children + data.multiArray[2] = this.state.formatInWindow[indexNumber].children[0].children + data.multiArray[3] = this.state.formatInWindow[indexNumber].children[0].children[0].children } - data.multiIndex[1] = 0 - data.multiIndex[2] = 0 - break - case 1: - switch (data.multiIndex[0]) { - case 0: - - break - case 1: - switch (data.multiIndex[1]) { - case 0: - data.multiArray[2] = this.state.formatInWindow[1].children[0].children - break - case 1: - data.multiArray[2] = this.state.formatInWindow[1].children[1].children - break - case 2: - data.multiArray[2] = this.state.formatInWindow[1].children[2].children - break - case 3: - data.multiArray[2] = this.state.formatInWindow[1].children[3].children ? this.state.formatInWindow[1].children[3].children : [{ class_name: '' }] - break - } - break - case 2: - switch (data.multiIndex[1]) { - case 0: - data.multiArray[2] = this.state.formatInWindow[2].children[0].children - break - case 1: - data.multiArray[2] = this.state.formatInWindow[2].children[1].children - break - case 2: - data.multiArray[2] = this.state.formatInWindow[2].children[2].children - break - case 3: - data.multiArray[2] = this.state.formatInWindow[2].children[3].children - break - case 4: - data.multiArray[2] = this.state.formatInWindow[2].children[4].children - break - case 5: - data.multiArray[2] = this.state.formatInWindow[2].children[5].children - break - } - break - case 3: - switch (data.multiIndex[1]) { - case 0: - data.multiArray[2] = this.state.formatInWindow[3].children[0].children - break - case 1: - data.multiArray[2] = this.state.formatInWindow[3].children[1].children - break - case 2: - data.multiArray[2] = this.state.formatInWindow[3].children[2].children - break - case 3: - data.multiArray[2] = this.state.formatInWindow[3].children[3].children - break - case 3: - data.multiArray[2] = this.state.formatInWindow[3].children[3].children - break - } - break - case 4: - switch (data.multiIndex[1]) { - case 0: - data.multiArray[2] = this.state.formatInWindow[4].children[0].children - break - case 1: - data.multiArray[2] = this.state.formatInWindow[4].children[1].children - break - case 2: - data.multiArray[2] = this.state.formatInWindow[4].children[2].children - break - - } - break - + } + } 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.formatInWindow[data.multiIndex[0]].children[indexNumber].children + data.multiArray[3] = this.state.formatInWindow[data.multiIndex[0]].children[indexNumber].children[0].children } - data.multiIndex[2] = 0 - break + } } + 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.formatInWindow[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.formatInWindow[0].children + // data.multiArray[2]=this.state.formatInWindow[0].children[0].children + // break + // case 1: + // data.multiArray[1] = this.state.formatInWindow[1].children + // break + // case 2: + // data.multiArray[1] = this.state.formatInWindow[2].children + // break + // case 3: + // data.multiArray[1] = this.state.formatInWindow[3].children + // break + // case 4: + // data.multiArray[1] = this.state.formatInWindow[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.formatInWindow[1].children[0].children + // break + // case 1: + // data.multiArray[2] = this.state.formatInWindow[1].children[1].children + // break + // case 2: + // data.multiArray[2] = this.state.formatInWindow[1].children[2].children + // break + // case 3: + // data.multiArray[2] = this.state.formatInWindow[1].children[3].children ? this.state.formatInWindow[1].children[3].children : [{ class_name: '' }] + // break + // } + // break + // case 2: + // switch (data.multiIndex[1]) { + // case 0: + // data.multiArray[2] = this.state.formatInWindow[2].children[0].children + // break + // case 1: + // data.multiArray[2] = this.state.formatInWindow[2].children[1].children + // break + // case 2: + // data.multiArray[2] = this.state.formatInWindow[2].children[2].children + // break + // case 3: + // data.multiArray[2] = this.state.formatInWindow[2].children[3].children + // break + // case 4: + // data.multiArray[2] = this.state.formatInWindow[2].children[4].children + // break + // case 5: + // data.multiArray[2] = this.state.formatInWindow[2].children[5].children + // break + // } + // break + // case 3: + // switch (data.multiIndex[1]) { + // case 0: + // data.multiArray[2] = this.state.formatInWindow[3].children[0].children + // break + // case 1: + // data.multiArray[2] = this.state.formatInWindow[3].children[1].children + // break + // case 2: + // data.multiArray[2] = this.state.formatInWindow[3].children[2].children + // break + // case 3: + // data.multiArray[2] = this.state.formatInWindow[3].children[3].children + // break + // case 3: + // data.multiArray[2] = this.state.formatInWindow[3].children[3].children + // break + // } + // break + // case 4: + // switch (data.multiIndex[1]) { + // case 0: + // data.multiArray[2] = this.state.formatInWindow[4].children[0].children + // break + // case 1: + // data.multiArray[2] = this.state.formatInWindow[4].children[1].children + // break + // case 2: + // data.multiArray[2] = this.state.formatInWindow[4].children[2].children + // break + + // } + // break + + // } + // data.multiIndex[2] = 0 + // data.multiIndex[3] = 0 + // break + // } this.setState({ multiIndex: data.multiIndex }) } @@ -286,13 +356,13 @@ class GoodsTypeInteractionComp extends Component { * 商品分类: - {this.props.selectedValue.name} + {this.props.selectedValue.name} - - {/* {this.state.objectMultiArray[0].length? {this.state.objectMultiArray[0][this.state.multiIndex[0]].name}:null} + + {/* {this.state.objectMultiArray[0].length? {this.state.objectMultiArray[0][this.state.multiIndex[0]].name}:null} {this.state.objectMultiArray[1].length?{this.state.objectMultiArray[1][this.state.multiIndex[1]].name}:null} {this.state.objectMultiArray[2].length?{this.state.objectMultiArray[2][this.state.multiIndex[2]].name}:null} */} - + diff --git a/src/pages/allDemanding/allDemanding.js b/src/pages/allDemanding/allDemanding.js index d6eccd0..52e2198 100644 --- a/src/pages/allDemanding/allDemanding.js +++ b/src/pages/allDemanding/allDemanding.js @@ -75,7 +75,7 @@ class AllDemanding extends Component { if (res.data.err_msg === 'success') { if (res.data.supplys.length) { if (this.state.isAddToList) { - this.setState({ supplys: this.state.supplys.concat(res.data.supplys),isAddToList:false }) + this.setState({ supplys: this.state.supplys.concat(res.data.supplys), isAddToList: false }) } else { this.setState({ supplys: res.data.supplys }) } @@ -258,6 +258,7 @@ class AllDemanding extends Component { text={this.state.grabOrderSuccess} duration={2000} > + const allDemandingElementArray = this.state.supplys ? this.state.supplys.map((item, index) => { return @@ -277,12 +278,13 @@ class AllDemanding extends Component { {item.sd_title} {item.sd_desc} - {item.state_name === '在用' ? + {item.state === '1' ? - : - - - } + : null || item.state === '2' ? + + : null || item.state === '3' ? + + : null} diff --git a/src/pages/goodsPublish/goodsPublish.js b/src/pages/goodsPublish/goodsPublish.js index e19eb0a..222d102 100644 --- a/src/pages/goodsPublish/goodsPublish.js +++ b/src/pages/goodsPublish/goodsPublish.js @@ -1,6 +1,6 @@ import Taro, { Component } from '@tarojs/taro' import { View, Text, Button } from '@tarojs/components' -import { AtInput, AtImagePicker, AtTextarea, AtForm } from 'taro-ui' +import { AtInput, AtImagePicker, AtTextarea, } from 'taro-ui' import CopyrightComponent from '../../component/copyrightComponent/copyrightComponent' @@ -36,11 +36,6 @@ class GoodsPublish extends Component { } } - - - - - // 发布商品api uploadGoods({ goods_name = "test2", goods_price = "1.00", diff --git a/src/pages/grabOrderPage/grabOrderPage.js b/src/pages/grabOrderPage/grabOrderPage.js index d18705e..d0f35c7 100644 --- a/src/pages/grabOrderPage/grabOrderPage.js +++ b/src/pages/grabOrderPage/grabOrderPage.js @@ -26,7 +26,9 @@ class GrabOrderPage extends Component { address: '', content: '', isOpen: false, // 抢单消息提示 - grabOrderId:this.$router.params.orderId + grabOrderId: this.$router.params.orderId, + stateId:'', + stateName:'' } } @@ -55,6 +57,8 @@ class GrabOrderPage extends Component { contactNumber: res.data.sdInfo.user_phone, address: res.data.sdInfo.user_address, content: res.data.sdInfo.sd_desc, + stateId:res.data.sdInfo.state, + stateName:res.data.sdInfo.state_name, }) } @@ -79,26 +83,26 @@ class GrabOrderPage extends Component { } }) .then(res => { - if(res.data.err_msg === 'success'){ + if (res.data.err_msg === 'success') { Taro.showToast({ - title: '抢单成功' , + title: '抢单成功', icon: 'success', duration: 1500 }) - setTimeout(() => { - Taro.navigateTo({ - url:'/pages/home/home' - }) - }, 1500); + setTimeout(() => { + Taro.navigateTo({ + url: '/pages/home/home' + }) + }, 1500); - }else{ + } else { Taro.showToast({ - title: res.data.err_msg , + title: res.data.err_msg, icon: 'none', duration: 1500 }) } - + console.log('抢单请求:', res) @@ -112,7 +116,7 @@ class GrabOrderPage extends Component { } grabButtonHandler() { this.setState({ isOpen: true }) - } + } handleGrabModalClose() { this.setState({ isOpen: false }) } @@ -126,7 +130,7 @@ class GrabOrderPage extends Component { } componentDidMount() { - + this.getGrabOrderInfo() } componentWillReceiveProps(nextProps) { @@ -140,12 +144,13 @@ class GrabOrderPage extends Component { componentDidHide() { } render() { + // 提示模态弹窗element const modalMessageGrabElement = 提示 确认抢单? - + @@ -180,13 +185,20 @@ class GrabOrderPage extends Component { 业主需求内容: {this.state.content} - - + + {/* - - + */} + {this.state.stateId === '1' ? + + : null || this.state.stateId === '2' ? + + : null || this.state.stateId === '3' ? + + : null} + diff --git a/src/pages/grabOrderPage/grabOrderPage.scss b/src/pages/grabOrderPage/grabOrderPage.scss index 9a07c19..ee693b8 100644 --- a/src/pages/grabOrderPage/grabOrderPage.scss +++ b/src/pages/grabOrderPage/grabOrderPage.scss @@ -14,23 +14,13 @@ } } -.button-box{ - display: flex; - flex-wrap: nowrap; - flex-direction: row; - margin: 80px 0; - padding: 0 20px; - + .button{ - flex:1; + margin-top: 20%; text-align: center; // margin:2%; // justify-content:center; - .at-button--primary{ - background-color:#FF7142; - border:1PX solid #FF7142; - } - }} + } \ No newline at end of file diff --git a/src/pages/home/home.js b/src/pages/home/home.js index 8c3635e..c8968ee 100644 --- a/src/pages/home/home.js +++ b/src/pages/home/home.js @@ -173,7 +173,6 @@ class Home extends Component { async login() { Taro.login({ success(res) { - if (res.code) { // 发起网络请求 // console.log('手机端微信code:',res.code) @@ -396,8 +395,9 @@ class Home extends Component { const demandingElemensArray = this.state.demanding.length ? this.state.demanding.map((item, index) => { + return - + {item.class_name} @@ -406,15 +406,22 @@ class Home extends Component { {item.sd_title} - {item.user_address || '无地址'} + {item.user_address || '--'} 业主:{item.user_name} - + {item.state === '1' ? + + : null || item.state === '2' ? + + : null || item.state === '3' ? + + : null} + {/* - + */} }) : null @@ -539,7 +546,7 @@ class Home extends Component { indicatorColor='#999' indicatorActiveColor='#333' horizontal - circular + displayMultipleItems='2.5' > {demandingElemensArray} diff --git a/src/pages/home/home.scss b/src/pages/home/home.scss index 3cd353a..7486f7b 100644 --- a/src/pages/home/home.scss +++ b/src/pages/home/home.scss @@ -82,7 +82,7 @@ $themeColor: #FF7142; .item-name{ color: #ccc; padding-top: 5px; - font-size: 35px; + font-size: 30px; // margin-top: 10px; overflow: hidden; text-overflow: ellipsis; @@ -101,6 +101,9 @@ $themeColor: #FF7142; } } + .last{ + border-right: 3rpx solid #ddd; + } } .shop-box{ diff --git a/src/pages/index/index.js b/src/pages/index/index.js index 93b0ed6..864ea2b 100644 --- a/src/pages/index/index.js +++ b/src/pages/index/index.js @@ -39,6 +39,7 @@ class Index extends Component { // url:'/pages/mySupplyDemand/mySupplyDemand' url:'/pages/home/home' // url:'/pages/allDemanding/allDemanding' + // url:'/pages/goodsPublish/goodsPublish' }) diff --git a/src/serviceAPI.config.js b/src/serviceAPI.config.js index ac24665..214f718 100644 --- a/src/serviceAPI.config.js +++ b/src/serviceAPI.config.js @@ -50,7 +50,6 @@ const URL = { // 商品编辑页面 Goods-ajaxEditPhoneDeploy GetProductInfo: LOCALURL + 'Goods-ajaxEditPhoneDeploy',// 获取单个商品信息 //我的需求 - PublishMyNeed: LOCALURL + 'Supply-userPost',// 发布我的需求 MyNeedUploadImage: LOCALURL + 'Supply-fileUpload?type=user',// 我的需求图片上传 GetMyNeedsList: LOCALURL + 'Supply-userDemandList',// 获取我的需求列表 diff --git a/src/todo list.txt b/src/todo list.txt index acaeb20..fa3eef8 100644 --- a/src/todo list.txt +++ b/src/todo list.txt @@ -18,762 +18,324 @@ bug: 商品编辑 增加图片后 图片顺序乱了 等待后台--- 单个我的商品页面的图片顺序,单个我的需求页面的接口, 当个我哦的需求编辑页面的接口 + + import Taro, { Component } from '@tarojs/taro' -import { View, Radio, Button } from '@tarojs/components' -import { AtInput, Text, AtIcon, Picker, Image, AtModal, AtModalHeader, AtModalContent, AtModalAction } from 'taro-ui' -import CopyrightComponent from '../../component/copyrightComponent/copyrightComponent' -import ScrollToTopComponent from '../../component/scrollToTopComponent/scrollToTopComponent' +import { View, Text } from '@tarojs/components' -import URL from '../../serviceAPI.config' +import { Picker } from 'taro-ui' +import './goodsTypeInteractionComp.scss' -import './myGoodList.scss' +class GoodsTypeInteractionComp extends Component { - -class MyGoodList extends Component { - config = { - navigationBarTitleText: '商品列表' - } - constructor() { - super(...arguments) - this.state = { - productName: '', - lowestPrice: '', - heightestPrice: '', - minimumSold: '', - maximumSold: '', - productId: '', - productCate: [], //宝贝类目 - productCateSelected: { id: '', name: '全部类目' },// 已选宝贝类目 - filterBar: ['filterPrice', 'filterStock', 'filterSold', 'filterPublishDate',], //筛选选项 - filterBarKeys: { filterPrice: '价格', filterStock: '库存', filterSold: '总销量', filterPublishDate: '发布时间' }, // 筛选选项对应值 - filterOptions: { - filterPrice: false, - filterStock: false, - filterSold: false, - filterPublishDate: false, - }, // 正反排序 - selectedFilterValue: 0, // - myGoodList: [],// 保存后台返回的商品列表 - myGoodListTotal: '0',// 后台的商品总数 - currentPage: 1, - goodsStateParam: 1,//商品状态参数 - pageCountParam: 2,// 商品数量参数 - currPageParam: 1,// 当前页面 参数 - isCheckAll: false,// 是否checked - goodsIdList: [],//商品Id 列表 - isOpenDeleteModal: false,// 是否显示删除模态框 - isOpenOffStockModal: false,// 是否显示下架模态框 - isAddToList: false,// 是否下拉加载 如果是 就添加商品到我的商品列表 - isShowTopNav: false,// 是否显示返回顶部按钮 - loadMorePageIndex: 1,//上拉加载页面数 + config = { + navigationBarTitleText: 'goodsTypeInteractionComp' } - } + constructor() { + super(...arguments); + this.state = { + ///---行业分类 开始 + objectMultiArray: [[{ name: '选择商品分类', id: '' }], [], []], + multiIndex: [0, 0, 0, 0], + formatInWindow: [], + ///---行业分类 结束 + } - productNameChange(event) { - this.setState({ productName: event }) - } - productIdChange(event) { - this.setState({ productId: event }) - } - lowestPriceChange(event) { - this.setState({ lowestPrice: event }) - } - heightestPriceChange(event) { - this.setState({ heightestPrice: event }) - } - minimumSoldChange(event) { - this.setState({ minimumSold: event }) - } - maximumSoldChange(event) { - this.setState({ maximumSold: event }) - } - productCateChange = e => { - this.setState({ - productCateSelected: this.state.productCate[e.detail.value] - }) - } - //获取宝贝类目搜索列表接口api - getBaoBeiCateList() { - Taro.request({ - url: URL.BaoBeiCateList, - method: 'POST', - dataType: 'json', - - header: { - 'Cookie': 'PFWSSS=' + Taro.getStorageSync('session_id'), - 'content-type': 'application/x-www-form-urlencoded', - 'X-Requested-With': 'XMLHttpRequest' - } - }).then(res => { - console.log('baobei', res) - 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 => { - Taro.showToast({ - title: '获取宝贝类目失败', - icon: 'none', - duration: 1500, - - }) - - }) - - } - - // 获取我的商品列表接口api - getMyGoodListApi({ - goodsState = this.state.goodsStateParam, - pageCount = this.state.pageCountParam, - currPage = this.state.currPageParam }) { - Taro.request({ - url: URL.MyGoodList, - method: 'POST', - dataType: 'json', - - data: { - goodsState: goodsState, - pageCount: pageCount, - currPage: currPage - }, - header: { - 'Cookie': 'PFWSSS=' + Taro.getStorageSync('session_id'), - 'content-type': 'application/x-www-form-urlencoded', - '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.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 }) - }) - } else { - this.setState({ - myGoodList: data.goods, - myGoodListTotal: data.goodsCount + } + //商品目录请求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_msg === 'success') { + console.log('商品分类目录', res) + this.formatIndustryType(res.data.data) + this.formatIndustTypeInit(res.data.data) + this.setState({goodsTypeList:res.data.data}) + + } else { + console.log('商品分类请求没有成功', res) + } + } + ) + .catch(error => { + console.log('商品分类请求错误', error) }) + } + - } + + // 第一种formate 用于底部弹层滚动时的数据 + formatIndustryType(data) { + const newIndustryType = [] + if (data) { + for (let outter of data) { + let outterObject = { name: outter.class_name, id: outter.class_id, children: [] } + if (outter.children) { + for (let middler of outter.children) { + const middleObject = { name: middler.class_name, id: middler.class_id, children: [] } + outterObject.children.push(middleObject) + if (middler.children) { + for (let inner of middler.children) { + const innerObject={ name: inner.class_name, id: inner.class_id,children: [] } + middleObject.children.push(innerObject) + + if (inner.children) { + for (let final of inner.children) { + innerObject.children.push({ name: final.class_name, id: final.class_id }) + + } + } else { + innerObject.children.push({ name: '', id: '' }) + } + } + } else { + middleObject.children.push({ name: '', id: '' }) + } + } + } else { + outterObject.children.push({ name: '', id: '', children: [] }) + } + newIndustryType.push(outterObject) + } } else { - Taro.showToast({ - title: '没有更多了', - icon: 'none' - }) + console.log('店铺分类数据问题') } - } else { - console.log('我的商品列表获取失败') - } - }) - } - // 获取搜索结果api - getGoodListResultApi({ - goodsName = this.state.productName, - goodsSn = '', - goodsClass = this.state.productCateSelected.id, - goodsPriceL = this.state.lowestPrice, - goodsPriceU = this.state.heightestPrice, - goodsSalesL = this.state.minimumSold, - goodsSalesU = this.state.maximumSold, - shopClassID = this.state.productId, - goodsState = this.state.goodsStateParam, - pageCount = this.state.pageCountParam, - currPage = this.state.currPageParam, - order = '', }) { - Taro.request({ - url: URL.MyGoodList, - method: 'POST', - dataType: 'json', - data: { - goodsName: goodsName, - goodsSn: goodsSn, - goodsClass: goodsClass, - goodsPriceL: goodsPriceL, - goodsPriceU: goodsPriceU, - goodsSalesL: goodsSalesL, - goodsSalesU: goodsSalesU, - shopClassID: shopClassID, - goodsState: goodsState, - pageCount: pageCount, - currPage: currPage, - order: order - }, - header: { - 'Cookie': 'PFWSSS=' + Taro.getStorageSync('session_id'), - 'content-type': 'application/x-www-form-urlencoded', - 'X-Requested-With': 'XMLHttpRequest' - } - }).then(res => { - if (res.statusCode === 200) { - console.log('我的商品列表', JSON.parse(res.data)) - const data = JSON.parse(res.data) - const goodCount = Number(data.goodsCount) + this.setState({ formatInWindow: newIndustryType }, () => { + console.log('滚动时的数据', this.state.formatInWindow) + }) + } + //第二种format 用于底部弹层的初始化数据 + formatIndustTypeInit(data) { + const firstArray = [] + const secondArray = [] + const thirdArray = [] + for (let outter of data) { + firstArray.push({ name: outter.class_name, id: outter.class_id }) + if (outter.children) { + for (let middler of outter.children) { + secondArray.push({ name: middler.class_name, id: middler.class_id }) + if (middler.children) { + for (let inner of middler.children) { + thirdArray.push({ name: inner.class_name, id: inner.class_id }) + } + } + } + } + } + // 这里不能加入secondArray,和thirdArray 会有bug + this.setState({ objectMultiArray: [firstArray, [{ name: '', id: '' }], [{ name: '', id: '' }]] }, () => { + console.log('初始化数据', this.state.objectMultiArray) + }) + } + //--- 三级联动-------------- + bindMultiPickerChange(e) { + console.log('picker发送选择改变,携带值为', e.detail.value) this.setState({ - myGoodList: data.goods, - myGoodListTotal: goodCount + multiIndex: e.detail.value + }, () => { + this.returnResultToParent() }) - Taro.hideLoading() - - } else { - console.log('我的商品列表获取失败') - } - - - }) - - } - - // 商品列表下架API - changeGoodState({ goodsState = 0, goodsID = this.state.goodsIdList }) { - Taro.request({ - url: URL.ChangeGoodState, - method: 'POST', - dataType: 'json', - - data: { - goodsState: goodsState, - goodsID: JSON.stringify(goodsID) - }, - header: { - 'Cookie': 'PFWSSS=' + Taro.getStorageSync('session_id'), - 'content-type': 'application/x-www-form-urlencoded', - 'X-Requested-With': 'XMLHttpRequest' - } - }).then(res => { - if (res.statusCode === 200) { - Taro.showToast({ - title: '下架成功', - icon: 'success', - duration: 1500 - }).then(() => { - this.setState({ isCheckAll: false }) - this.getMyGoodListApi({}) - - }) - - - } else { - Taro.showToast({ - title: '下架失败', - icon: 'none', - duration: 1500 - }) - this.setState({ isCheckAll: false }) - } - - - }) - - } - // 商品列表删除api - deleteGood({ goodsState = 1, goodsID = this.state.goodsIdList }) { - Taro.request({ - url: URL.DeleteGood, - method: 'POST', - dataType: 'json', - - data: { - goodsState: goodsState, - goodsID: JSON.stringify(goodsID) - }, - header: { - 'Cookie': 'PFWSSS=' + Taro.getStorageSync('session_id'), - 'content-type': 'application/x-www-form-urlencoded', - 'X-Requested-With': 'XMLHttpRequest' - } - }).then(res => { - if (res.statusCode === 200) { - console.log('商品删除返回', res) - Taro.showToast({ - title: '删除成功', - icon: 'success', - duration: 1500 - }).then(() => { - - this.setState({ isCheckAll: false }) - this.getMyGoodListApi({}) - - }) - } else { - Taro.showToast({ - title: '删除失败', - icon: 'none', - duration: 1500 - }) - this.setState({ isCheckAll: false }) - } - - - }) - - } - - - - - // 搜索 - searchButtonHandler() { - Taro.showLoading({ - title: '加载中', - }) - this.setState({ currentPage: 1, isCheckAll: false }, () => { - this.getGoodListResultApi({}) - }) - } - - - // 清空搜索 - emptyButtonHanlder() { - this.setState({ - productName: '', - lowestPrice: '', - heightestPrice: '', - minimumSold: '', - maximumSold: '', - productId: '', - productCateSelected: { id: '', name: '全部类目' }, - }, () => { - - this.setState({ isCheckAll: false, currentPage: 1 }, () => { - this.getMyGoodListApi({}) - }) - Taro.showToast({ - title: '已清空', - icon: 'success', - duration: 1000 - }) - }) - - } - // 产品排序 - accendingDescending(value) { - this.setState({ selectedFilterValue: value }) - if (value == 0) { - this.setState({ - currentPage: 1, - filterOptions: { - filterPrice: !this.state.filterOptions.filterPrice, - filterStock: false, - filterSold: false, - filterPublishDate: false, + } + returnResultToParent() { + let result = '' + let outter = this.state.formatInWindow[this.state.multiIndex[0]] + let middler = outter.children[this.state.multiIndex[1]] + let inner = middler.children[this.state.multiIndex[2]] + if (outter.id) { + result = outter + if (middler.id) { + result = middler + if (inner.id) { + result = inner + } + } } - } - ) - this.state.filterOptions.filterPrice ? this.getGoodListResultApi({ order: "goods_price desc" }) : this.getGoodListResultApi({ order: "goods_price" }) + this.passDataToParent(result) } - if (value == 1) { - this.setState({ - currentPage: 1, - filterOptions: { - filterPrice: false, - filterStock: !this.state.filterOptions.filterStock, - filterSold: false, - filterPublishDate: false, + bindMultiPickerCol(e) { + console.log('修改的列为', e.detail.column, ',值为', e.detail.value) + const data = { + multiArray: this.state.objectMultiArray, + multiIndex: this.state.multiIndex } - }, () => { - this.state.filterOptions.filterStock ? this.getGoodListResultApi({ order: "goods_stock desc" }) : this.getGoodListResultApi({ order: "goods_stock" }) - } - ) - } - if (value == 2) { - this.setState({ - currentPage: 1, - filterOptions: { - filterPrice: false, - filterStock: false, - filterSold: !this.state.filterOptions.filterSold, - filterPublishDate: false, + data.multiIndex[e.detail.column] = e.detail.value + + switch (e.detail.column) { + case 0: + switch (data.multiIndex[0]) { + case 0: + data.multiArray[1] = this.state.formatInWindow[0].children + data.multiArray[2] = this.state.formatInWindow[0].children + break + case 1: + data.multiArray[1] = this.state.formatInWindow[1].children + break + case 2: + data.multiArray[1] = this.state.formatInWindow[2].children + break + case 3: + data.multiArray[1] = this.state.formatInWindow[3].children + break + case 4: + data.multiArray[1] = this.state.formatInWindow[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.formatInWindow[1].children[0].children + break + case 1: + data.multiArray[2] = this.state.formatInWindow[1].children[1].children + break + case 2: + data.multiArray[2] = this.state.formatInWindow[1].children[2].children + break + case 3: + data.multiArray[2] = this.state.formatInWindow[1].children[3].children ? this.state.formatInWindow[1].children[3].children : [{ class_name: '' }] + break + } + break + case 2: + switch (data.multiIndex[1]) { + case 0: + data.multiArray[2] = this.state.formatInWindow[2].children[0].children + break + case 1: + data.multiArray[2] = this.state.formatInWindow[2].children[1].children + break + case 2: + data.multiArray[2] = this.state.formatInWindow[2].children[2].children + break + case 3: + data.multiArray[2] = this.state.formatInWindow[2].children[3].children + break + case 4: + data.multiArray[2] = this.state.formatInWindow[2].children[4].children + break + case 5: + data.multiArray[2] = this.state.formatInWindow[2].children[5].children + break + } + break + case 3: + switch (data.multiIndex[1]) { + case 0: + data.multiArray[2] = this.state.formatInWindow[3].children[0].children + break + case 1: + data.multiArray[2] = this.state.formatInWindow[3].children[1].children + break + case 2: + data.multiArray[2] = this.state.formatInWindow[3].children[2].children + break + case 3: + data.multiArray[2] = this.state.formatInWindow[3].children[3].children + break + case 3: + data.multiArray[2] = this.state.formatInWindow[3].children[3].children + break + } + break + case 4: + switch (data.multiIndex[1]) { + case 0: + data.multiArray[2] = this.state.formatInWindow[4].children[0].children + break + case 1: + data.multiArray[2] = this.state.formatInWindow[4].children[1].children + break + case 2: + data.multiArray[2] = this.state.formatInWindow[4].children[2].children + break + + } + break + + } + data.multiIndex[2] = 0 + data.multiIndex[3] = 0 + break } - }, () => { - this.state.filterOptions.filterSold ? this.getGoodListResultApi({ order: "sales_volume desc" }) : this.getGoodListResultApi({ order: "sales_volume" }) - } + this.setState({ multiIndex: data.multiIndex }) + } - ) + //--------------------结束-行业分类picker + passDataToParent(industryTypeSelected) { + this.props.onPassDataToChild(industryTypeSelected) + } + + + componentDidMount() { + this.getProductCateList(this.props.url) } - if (value == 3) { - this.setState({ - currentPage: 1, - filterOptions: { - filterPrice: false, - filterStock: false, - filterSold: false, - filterPublishDate: !this.state.filterOptions.filterPublishDate, - - } - }, () => { - this.state.filterOptions.filterPublishDate ? this.getGoodListResultApi({ order: "update_date desc" }) : this.getGoodListResultApi({ order: "update_date" }) - } - ) - } - } - - - // 商品全部选择 - checkAllHandler() { - if (this.state.myGoodList.length) { - const newMyGoodList = this.state.myGoodList.map((item) => { - item.checked = !this.state.isCheckAll - return item - }) - this.setState({ isCheckAll: !this.state.isCheckAll, myGoodList: newMyGoodList }, () => { - console.log('全选列表', this.state.myGoodList) - }) - } - else { - this.setState({ - isCheckAll: true - }, () => { - this.setState({ isCheckAll: false }) - }) - Taro.showToast({ - title: '全选无效', - icon: 'none', - duration: 1500 - }).then(() => { - - }) + // 当然父组件有新的props的 会从新渲染组件 + componentWillReceiveProps(nextProps) { } - } + componentWillUnmount() { } + componentDidShow() { } - // 单个商品选择 - handleCheckChange(Id) { - //如果goodid 一样的那么checked 就取反 - const newMyGoodList = this.state.myGoodList.map((item) => { - if (item.goods_id === Id) { - item.checked = !item.checked - } - return item - }) - this.setState({ myGoodList: newMyGoodList }) - } - // 删除商品 - deleteGoodsHandler() { - const checkedGoodsId = [] - this.state.myGoodList.forEach(item => { - if (item.checked) { - checkedGoodsId.push(item.goods_id) - } - }); - checkedGoodsId.length ? this.setState({ isOpenDeleteModal: true }) : Taro.showToast({ - title: '请选择要删除的商品', - icon: 'none', - duration: 1500 - }) - // // this.deleteGood({ goodsID: checkedGoodsId }) + componentDidHide() { } + render() { + return ( + + + + + * + 商品分类: + + {this.props.selectedValue.name} + + {/* {this.state.objectMultiArray[0].length? {this.state.objectMultiArray[0][this.state.multiIndex[0]].name}:null} + {this.state.objectMultiArray[1].length?{this.state.objectMultiArray[1][this.state.multiIndex[1]].name}:null} + {this.state.objectMultiArray[2].length?{this.state.objectMultiArray[2][this.state.multiIndex[2]].name}:null} */} - } - // 改变商品状态 - offStockGoodHandler() { - const checkedGoodsId = [] - this.state.myGoodList.forEach(item => { - if (item.checked) { - checkedGoodsId.push(item.goods_id) - } - }); - //this.changeGoodState({ goodsID: checkedGoodsId }) - checkedGoodsId.length ? this.setState({ isOpenOffStockModal: true }) : Taro.showToast({ - title: '请选择要下架的商品', - icon: 'none', - duration: 1500 - }) - } - // 导航到商品编辑页面myGoodsEdit - goToGoodEditPage(goodId) { - Taro.navigateTo({ - url: '/pages/myGoodsEdit/myGoodsEdit?id=' + goodId - }) - } - // 导航到商品发布页面 - - goToGoodsPublishPage() { - Taro.navigateTo({ - url: '/pages/goodsPublish/goodsPublish' - }) - } - goToGoodspage(goodId) { - Taro.navigateTo({ - url: '/pages/goods/goods?id=' + goodId - }) - } - - DeleteConfirm() { - this.setState({ - isOpenDeleteModal: false - }) - const checkedGoodsId = [] - this.state.myGoodList.forEach(item => { - if (item.checked) { - checkedGoodsId.push(item.goods_id) - } - }); - this.deleteGood({ goodsID: checkedGoodsId }) - } - deleteModalClose() { - this.setState({ - isOpenDeleteModal: false - }) - } - OffStockConfirm() { - - this.setState({ - isOpenOffStockModal: false - }) - const checkedGoodsId = [] - this.state.myGoodList.forEach(item => { - if (item.checked) { - checkedGoodsId.push(item.goods_id) - } - }); - this.changeGoodState({ goodsID: checkedGoodsId }) - } - offStockModalClose() { - this.setState({ - isOpenOffStockModal: false - }) - } - - componentDidMount() { - Taro.showLoading({ - title: '加载中' - }) - this.getMyGoodListApi({}) - this.getBaoBeiCateList() - } - componentWillReceiveProps(nextProps) { - console.log(this.props, nextProps) - } - - componentWillUnmount() { } - - componentDidShow() { } - - componentDidHide() { } - // 页面位置 - onPageScroll(location) { - if (location.scrollTop <= 300 && this.state.isShowTopNav) { - this.setState({ isShowTopNav: false }) - } else if (location.scrollTop > 300 && !this.state.isShowTopNav) { - this.setState({ isShowTopNav: true }) - } - } - // 底部加载 - onReachBottom() { - Taro.showLoading({ - title: '加载中' - }) - this.setState({ isAddToList: true, loadMorePageIndex: this.state.loadMorePageIndex + 1 }, () => { - this.getMyGoodListApi({ currPage: this.state.loadMorePageIndex }) - }) - - - } - - render() { - - - //等待接口数据 - const goodListElementArray = this.state.myGoodList.map((item, index) => { - return - - - - {/* */} - - - {item.goods_name} - ¥{item.goods_price} - {item.sales_volume} - - - - - - - - }) - // 筛选项目排序element - const filterElementsArray = this.state.filterBar.map((item, index) => { - let isTure = this.state.filterOptions[item] - - return - - {this.state.filterBarKeys[item]} - - {isTure ? : } - - }) - // 删除提示模态弹窗element - const modalMessageDeleteElement = - 提示 - - 确定要删除已选商品? - - - - // 下架提示模态弹窗element - const modalMessageOffStockElement = - 提示 - - 确定要下架已选商品? - - - - - return ( - - {/* 删除模态提示框 */} - {modalMessageDeleteElement} - {/* 下架模态框提示 */} - {modalMessageOffStockElement} - - - - - - - - - - - - - - - - - - - - - 宝贝类目: - - {this.state.productCateSelected.name} - - + + + - - - - - - - - - - - - - - - 出售中的宝贝{this.state.myGoodListTotal}条记录 - - - - {filterElementsArray} - - - - 全选 - - - - - - - - - - {goodListElementArray} - - {this.state.isShowTopNav ? : null} - - - - ) - } + ) + } } -export default MyGoodList +export default GoodsTypeInteractionComp + +