From fc44a8b8288533a64a3036017867b12a87e5dcf8 Mon Sep 17 00:00:00 2001 From: Maoqiang Zheng Date: Thu, 14 Mar 2019 17:19:08 +0800 Subject: [PATCH] =?UTF-8?q?=E6=94=AF=E4=BB=98=E5=AE=9D-checker=20bug=20-?= =?UTF-8?q?=E5=9B=BE=E7=89=87=E4=B8=8A=E4=BC=A0bug-=E7=BC=96=E8=BE=91-?= =?UTF-8?q?=E5=8F=91=E5=B8=83?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/app.js | 1 + src/app.scss | 1 + .../filteredShopComponent.js | 36 +- .../filteredShopComponent.scss | 1 + .../pictureUploadComponent.js | 178 ++++ .../pictureUploadComponent.scss | 21 + .../shopItemComponent/shopItemComponent.scss | 2 + .../shopTypeInteractionComp.js | 4 +- src/pages/allDemanding/allDemanding.js | 9 +- src/pages/goods/goods.js | 50 +- src/pages/goods/goods.scss | 18 +- src/pages/goodsPublish/goodsPublish.js | 73 +- src/pages/grabOrderPage/grabOrderPage.js | 11 +- src/pages/home/home.js | 73 +- src/pages/home/home.scss | 9 +- .../home/mainCateSlider/mainCateSlider.js | 1 - .../individualCenter/individualCenter.js | 33 +- .../myDemandSupplyEdit/myDemandSupplyEdit.js | 56 +- src/pages/myGoodList/myGoodList.js | 34 +- src/pages/myGoodList/myGoodList.scss | 4 + src/pages/myGoodsEdit/myGoodsEdit.js | 117 ++- src/pages/myNeeds/myNeeds.js | 18 +- src/pages/myNeedsEdit/myNeedsEdit.js | 107 +-- src/pages/myNeedsPublish/myNeedsPublish.js | 85 +- src/pages/myNeedsPublish/myNeedsPublish.scss | 2 +- src/pages/myNeedsView/myNeedsView.js | 3 +- src/pages/mySupplyDemand/mySupplyDemand.js | 25 +- src/pages/shop/shop.js | 13 +- .../supplyDemandPublish.js | 52 +- .../supplyDemandView/supplyDemandView.js | 19 +- src/serviceAPI.config.js | 2 +- src/todo list.txt | 588 ------------ src/util/checkLogin.js | 31 + src/util/getSetStoage.js | 8 +- src/util/hideShowLoading.js | 24 + todo list.json | 873 ++++++++++++++++++ 36 files changed, 1603 insertions(+), 979 deletions(-) create mode 100644 src/component/pictureUploadComponent/pictureUploadComponent.js create mode 100644 src/component/pictureUploadComponent/pictureUploadComponent.scss delete mode 100644 src/todo list.txt create mode 100644 src/util/checkLogin.js create mode 100644 src/util/hideShowLoading.js create mode 100644 todo list.json diff --git a/src/app.js b/src/app.js index 5b3e4d6..6679a2b 100644 --- a/src/app.js +++ b/src/app.js @@ -20,6 +20,7 @@ class App extends Component { config = { pages: [ //'pages/index/index', // index页面 + 'pages/home/home',//首页 --------------------- 'pages/login/login',//登入页面 --------------------- diff --git a/src/app.scss b/src/app.scss index 8ebfa3b..364745c 100644 --- a/src/app.scss +++ b/src/app.scss @@ -7,6 +7,7 @@ $linearGreen:linear-gradient(to right, #5cb85c, #5cb85c);; $linearBlue:linear-gradient(to right, #337ab7, #337ab7); page{ height: 100%; + background-color: white; } .input-index--at-input__title{ diff --git a/src/component/filteredShopComponent/filteredShopComponent.js b/src/component/filteredShopComponent/filteredShopComponent.js index 465eec4..9273020 100644 --- a/src/component/filteredShopComponent/filteredShopComponent.js +++ b/src/component/filteredShopComponent/filteredShopComponent.js @@ -35,8 +35,8 @@ class recommondShop extends Component { isOpenConsult: false, consultTip: '', voucherResponseMsg: 'i am voucherResponseMsg', - userName: getGlobalStorage('user_identity').username || '', - userPhone: getGlobalStorage('user_identity').userphone || '', + userName: '', + userPhone: '', isCanConsult: true, isCanVoucher: true @@ -223,6 +223,10 @@ class recommondShop extends Component { //console.log(this.props, nextProps) } componentDidMount() { + this.setState({ + userName: getGlobalStorage('user_identity') ? getGlobalStorage('user_identity').username : '', + userPhone: getGlobalStorage('user_identity') ? getGlobalStorage('user_identity').userphone : '', + }) } componentWillUnmount() { } @@ -265,14 +269,14 @@ class recommondShop extends Component { 联系人: - + - + @@ -280,13 +284,13 @@ class recommondShop extends Component { 联系电话: - + diff --git a/src/component/filteredShopComponent/filteredShopComponent.scss b/src/component/filteredShopComponent/filteredShopComponent.scss index bc4eb73..835daf8 100644 --- a/src/component/filteredShopComponent/filteredShopComponent.scss +++ b/src/component/filteredShopComponent/filteredShopComponent.scss @@ -148,6 +148,7 @@ $linearBlue:linear-gradient(to right, #337ab7, #337ab7); text-overflow: ellipsis; .details-text{ font-weight: bold; + display: inline-block; } } diff --git a/src/component/pictureUploadComponent/pictureUploadComponent.js b/src/component/pictureUploadComponent/pictureUploadComponent.js new file mode 100644 index 0000000..7515da4 --- /dev/null +++ b/src/component/pictureUploadComponent/pictureUploadComponent.js @@ -0,0 +1,178 @@ + +import Taro, { Component } from '@tarojs/taro' +import { View, Text, Image, Button } from '@tarojs/components' +import { AtIcon } from 'taro-ui' + +import URL from '../../serviceAPI.config' + + +import './pictureUploadComponent.scss' +import onClickValueService from '../../util/onClickValueService'; +import { getGlobalStorage } from '../../util/getSetStoage'; + + +class PictureUploadComponent extends Component { + + + // maxLength={4} + // isReceiveImageUrl={true} + // url={URL.UploadDSPorductImage} + // onGetImageDetails={this.getImageDetails.bind(this)} + // initialImageURL={this.state.initialImageURL} + // initialImagesInfo={this.state.initialImagesInfo} + static defaultProps = { + url: '', + maxLength: 100, + isReceiveImageUrl: true, + imageURLList: [] + }; + config = { + navigationBarTitleText: 'pictureUploadComponent' + } + constructor() { + super(...arguments); + + this.state = { + imageURL: [], + imageDetails: [], + onlyOnce: true,// initial props 只setstate一次 + } + } + uploadImage() { + const that = this + my.chooseImage({ + count: this.props.maxLength, + sizeType: ['original', 'compressed'], + sourceType: ['album', 'camera'], + success(res) { + // tempFilePath可以作为img标签的src属性显示图片 + // console.log('res.apFilePaths',res.apFilePaths) + res.apFilePaths.forEach(item => { + that.onChangeImg(item) + }); + }, + fail(err) { + Taro.showToast({ + title: err, + icon: 'none' + }) + } + }) + } + // 上传图片apo + onChangeImg(files) { + const that = this + my.uploadFile({ + url: this.props.url, + filePath: files, + fileName: 'file', + fileType: 'image', + formData: { + 'key': 'michael', + }, + header: { + 'content-type': 'multipart/form-data; boundary=----WebKitFormBoundaryAWxeadaAVmRVQCiz', + 'Cookie': 'PFWSSS=' + getGlobalStorage('session_id'), + 'X-Requested-With': 'XMLHttpRequest' + }, + success(response) { + const data = JSON.parse(response.data) + + if (data.err_code === 0) { + console.log('上传成功') + const imagePath = URL.Base + data.file_path + that.setState({ imageURL: [...that.state.imageURL, { url: imagePath }], imageDetails: [...that.state.imageDetails, data] }, () => { + that.props.onGetImageDetails(that.state.imageDetails) + }) + Taro.showToast({ + title: '上传成功', + icon: 'success', + duration: 1500 + }) + } else { + Taro.showToast({ + title: data.err_msg, + icon: 'none', + duration: 1500 + }) + } + + }, + fail(err) { + Taro.showToast({ + title: err, + icon: 'none' + }) + } + }) + + + } + + deleteButton(e) { + const value = onClickValueService(e) + this.state.imageURL.splice(value, 1) + this.state.imageDetails.splice(value, 1) + this.setState({ + imageURL: this.state.imageURL, + imageDetails: this.state.imageDetails, + }, () => { + this.props.onGetImageDetails(this.state.imageDetails) + }) + Taro.showToast({ + title: '删除成功', + icon: 'success', + duration: 1500 + }) + } + + componentDidMount() { + + } + // 当然父组件有新的props的 会从新渲染组件 + componentWillReceiveProps(nextProps) { + // 第一次的props 要给state + console.log('next props', nextProps) + if (nextProps.isReceiveImageUrl) { + if (this.state.onlyOnce) { + console.log('onlyonce') + this.setState({ + imageURL: nextProps.initialImageURL, + imageDetails: nextProps.initialImagesInfo, + onlyOnce: false + }) + + } + } + + } + componentWillUnmount() { } + + + componentDidShow() { } + + componentDidHide() { } + + render() { + console.log('state', this.state) + const { maxLength } = this.props + const imageElementArray = this.state.imageURL.map((item, index) => { + return + + + + + }) + + return ( + + {this.state.imageURL.length < maxLength ? : null} < View className='image-container' > {imageElementArray} + ) + } +} + +export default PictureUploadComponent + diff --git a/src/component/pictureUploadComponent/pictureUploadComponent.scss b/src/component/pictureUploadComponent/pictureUploadComponent.scss new file mode 100644 index 0000000..324ccdb --- /dev/null +++ b/src/component/pictureUploadComponent/pictureUploadComponent.scss @@ -0,0 +1,21 @@ +.image-container{ + display: flex; + flex-wrap: wrap; + flex-direction: row; + .image-wrapper{ + box-sizing: border-box; + width: 25%; + height: 200px; + border-radius: 50%; + position: relative; + .delete{ + position: absolute; + top:10px; + right: 10px; + background-color: rgb(153, 153, 153); + opacity: 0.8; + padding: 5px; + border-radius: 50%; + } + } +} \ No newline at end of file diff --git a/src/component/shopItemComponent/shopItemComponent.scss b/src/component/shopItemComponent/shopItemComponent.scss index f99f0f4..36651ab 100644 --- a/src/component/shopItemComponent/shopItemComponent.scss +++ b/src/component/shopItemComponent/shopItemComponent.scss @@ -40,6 +40,8 @@ margin:0 5%; .name{ font-size: 30px; + overflow: hidden; + white-space: nowrap; } } diff --git a/src/component/shopTypeInteractionComp/shopTypeInteractionComp.js b/src/component/shopTypeInteractionComp/shopTypeInteractionComp.js index d526edd..245caa8 100644 --- a/src/component/shopTypeInteractionComp/shopTypeInteractionComp.js +++ b/src/component/shopTypeInteractionComp/shopTypeInteractionComp.js @@ -5,7 +5,7 @@ import { Picker } from 'taro-ui' import './shopTypeInteractionComp.scss' import loginExpired from '../../util/loginExpired'; -import { getGlobalStorage } from '../../util/getSetStoage'; +import { getGlobalStorage,setGlobalStorage } from '../../util/getSetStoage'; class ShopTypeInteractionComp extends Component { @@ -48,7 +48,7 @@ class ShopTypeInteractionComp extends Component { } console.log('店铺分类目录', res) if(!getGlobalStorage('shopTypeObject')){ - Taro.setStorageSync('shopTypeObject',res.data.data) + setGlobalStorage('shopTypeObject',res.data.data) } this.setState({ interactionMultiArray: this.interactionData(res.data.data), diff --git a/src/pages/allDemanding/allDemanding.js b/src/pages/allDemanding/allDemanding.js index 4566952..2de1116 100644 --- a/src/pages/allDemanding/allDemanding.js +++ b/src/pages/allDemanding/allDemanding.js @@ -12,6 +12,7 @@ import URL from '../../serviceAPI.config' import './allDemanding.scss' import eyeIcon from '../../icons/eye.png' import { getGlobalStorage } from '../../util/getSetStoage'; +import { showLoading } from '../../util/hideShowLoading'; @@ -181,7 +182,7 @@ class AllDemanding extends Component { this.GrabDemand({ demandId: this.state.grabOrderId }) } searchHanlder() { - Taro.showLoading({ title: '加载中' }) + showLoading({ title: '加载中' }) this.searchDemanding({}) } //清空筛选项 @@ -217,9 +218,9 @@ class AllDemanding extends Component { } componentDidMount() { // 得到第一页需求数据 - Taro.showLoading({ title: '加载中' }).then(() => { + showLoading({ title: '加载中' }) this.searchDemanding({}) - }) + } @@ -240,7 +241,7 @@ class AllDemanding extends Component { // 底部加载 onReachBottom() { - Taro.showLoading({ + showLoading({ title: '加载中' }) diff --git a/src/pages/goods/goods.js b/src/pages/goods/goods.js index ab52984..33ffddd 100644 --- a/src/pages/goods/goods.js +++ b/src/pages/goods/goods.js @@ -8,6 +8,8 @@ import LoginService from '../../util/LoginService' import URL from '../../serviceAPI.config' import './goods.scss' import { getGlobalStorage } from '../../util/getSetStoage'; +import { showLoading } from '../../util/hideShowLoading'; +import onClickValueService from '../../util/onClickValueService' class Goods extends Component { @@ -31,13 +33,14 @@ class Goods extends Component { monthSold: '',//月销量 totalSold: '',//总销量 browsingCount: '',// 浏览数 - shopId: '' + shopId: '', + actived:0// 默认tab } } // 商品详情api getGoodDescription() { - + Taro.request({ url: URL.GetShopItemDetail, method: 'POST', @@ -122,6 +125,12 @@ class Goods extends Component { }) } + clickTabHandler(e){ + let value=onClickValueService(e) + this.setState({ + actived:value + }) + } // 数量或者规格方法 onChange = e => { this.setState({ @@ -130,9 +139,9 @@ class Goods extends Component { } componentDidMount() { - Taro.showLoading({ + showLoading({ title: '加载中' - }) + }) this.getGoodDescription() } componentWillReceiveProps(nextProps) { @@ -146,7 +155,13 @@ class Goods extends Component { componentDidHide() { } render() { + const mainTabList = [{ title: '宝贝详情' }, { title: '全部评价' }, { title: '猜你喜欢' }] + const tabArrayElement=mainTabList.map((item,index)=>{ + return + {item.title} + + }) // const subTabList = [{ title: '全部' }, { title: '好评' }, { title: '差评' }, { title: '公开' }, { title: '匿名' }] const itemPicsBannerElementArray = this.state.productImagesUrl.map((item, index) => { return @@ -168,13 +183,13 @@ class Goods extends Component { {/* */} {itemPicsBannerElementArray} @@ -240,7 +255,12 @@ class Goods extends Component { {/* 详情和评论区 */} + + {tabArrayElement} + + + {/* 大类 */} @@ -258,9 +278,9 @@ class Goods extends Component { { /*子标签类*/} { this.state.subCurrent === 0 @@ -330,7 +350,7 @@ class Goods extends Component { - + ) } } diff --git a/src/pages/goods/goods.scss b/src/pages/goods/goods.scss index 1f6f741..2661d7e 100644 --- a/src/pages/goods/goods.scss +++ b/src/pages/goods/goods.scss @@ -213,4 +213,20 @@ $themeColor:#FF7142; } } - \ No newline at end of file + .tabs{ + display: flex; + flex-wrap: nowrap; + flex-direction: row; + height: 80px; + + border-bottom: 1px solid #d6e4ef; + .tab{ + flex:1; + text-align: center; + padding: 24px; + } + .actived{ + color:#FF7142; + border-bottom: 3px solid#FF7142 + } + } \ No newline at end of file diff --git a/src/pages/goodsPublish/goodsPublish.js b/src/pages/goodsPublish/goodsPublish.js index 0f42cb8..97b2389 100644 --- a/src/pages/goodsPublish/goodsPublish.js +++ b/src/pages/goodsPublish/goodsPublish.js @@ -2,6 +2,7 @@ import Taro, { Component } from '@tarojs/taro' import { View, Text, Button } from '@tarojs/components' import { AtInput, AtImagePicker, AtTextarea, } from 'taro-ui' import CopyrightComponent from '../../component/copyrightComponent/copyrightComponent' +import PictureUploadComponent from '../../component/pictureUploadComponent/pictureUploadComponent' import ShopTypeInteractionComp from '../../component/shopTypeInteractionComp/shopTypeInteractionComp' @@ -14,6 +15,8 @@ import URL from '../../serviceAPI.config' import './goodsPublish.scss' import loginExpired from '../../util/loginExpired'; import { getGlobalStorage } from '../../util/getSetStoage'; +import { showLoading } from '../../util/hideShowLoading'; +import { isUserShopOwner } from '../../util/checkLogin'; class GoodsPublish extends Component { @@ -205,7 +208,12 @@ class GoodsPublish extends Component { }) } } - + // 从图片子组件获取信息 + getImageDetails(value) { + this.setState({ + ImagesInfo: value + }) + } publishButtonHandler() { if (this.state.productName && @@ -214,22 +222,22 @@ class GoodsPublish extends Component { this.state.ImagesInfo.length && this.state.goodsTypeSelected.id && this.state.shopTypeSelected.id) { - Taro.showLoading({ title: '发布中' }).then(() => { - this.setState({ isPublish: true }, () => { - this.uploadGoods({ - goods_name: this.state.productName, - goods_price: this.state.productPrice, - goods_unit: this.state.productUnit, - goods_profiles: this.state.productDescript, - class_id: this.state.goodsTypeSelected.id, - shop_class_id: this.state.shopTypeSelected.id, - }) - + showLoading({ title: '发布中' }) + this.setState({ isPublish: true }, () => { + this.uploadGoods({ + goods_name: this.state.productName, + goods_price: this.state.productPrice, + goods_unit: this.state.productUnit, + goods_profiles: this.state.productDescript, + class_id: this.state.goodsTypeSelected.id, + shop_class_id: this.state.shopTypeSelected.id, }) - }) + + + } else { Taro.showToast({ title: '请填写完表格', icon: 'none' }) } @@ -242,22 +250,22 @@ class GoodsPublish extends Component { this.state.ImagesInfo.length && this.state.goodsTypeSelected.id && this.state.shopTypeSelected.id) { - Taro.showLoading({ title: '发布中' }).then(() => { - this.setState({ isPublishAndAdd: true }, () => { - this.uploadGoods({ - goods_name: this.state.productName, - goods_price: this.state.productPrice, - goods_unit: this.state.productUnit, - goods_profiles: this.state.productDescript, - class_id: this.state.goodsTypeSelected.id, - shop_class_id: this.state.shopTypeSelected.id, - }) - + showLoading({ title: '发布中' }) + this.setState({ isPublishAndAdd: true }, () => { + this.uploadGoods({ + goods_name: this.state.productName, + goods_price: this.state.productPrice, + goods_unit: this.state.productUnit, + goods_profiles: this.state.productDescript, + class_id: this.state.goodsTypeSelected.id, + shop_class_id: this.state.shopTypeSelected.id, }) - }) + + + } else { Taro.showToast({ title: '请填写完表格', icon: 'none' }) } @@ -298,12 +306,7 @@ class GoodsPublish extends Component { componentWillUnmount() { } componentDidShow() { - if (!getGlobalStorage('shopInfo').shop_id && getGlobalStorage('userInfo').user_id) { - Taro.showToast({ - title: '您还没有店铺,不能使用该功能,快去申请吧', - icon: 'none' - }) - } + isUserShopOwner() } componentDidHide() { } @@ -364,7 +367,9 @@ class GoodsPublish extends Component { * 上传图片: - + + + {/* - + */} {/* 店铺分类 */} diff --git a/src/pages/grabOrderPage/grabOrderPage.js b/src/pages/grabOrderPage/grabOrderPage.js index 498c32e..941e4fd 100644 --- a/src/pages/grabOrderPage/grabOrderPage.js +++ b/src/pages/grabOrderPage/grabOrderPage.js @@ -10,6 +10,7 @@ import CopyrightComponent from '../../component/copyrightComponent/copyrightComp import './grabOrderPage.scss' import loginExpired from '../../util/loginExpired'; import { getGlobalStorage } from '../../util/getSetStoage'; +import { showLoading } from '../../util/hideShowLoading'; class GrabOrderPage extends Component { @@ -153,16 +154,16 @@ class GrabOrderPage extends Component { handleGrabConfirm() { this.setState({ isOpen: false }) // 确认抢单之后 - Taro.showLoading({ + showLoading({ title: '加载中' }) this.GrabDemand({ demandId: this.state.grabOrderId }) } componentDidMount() { - Taro.showLoading({ - title:'加载中' - }) + showLoading({ + title: '加载中' + }) this.getGrabOrderInfo() } componentWillReceiveProps(nextProps) { @@ -239,7 +240,7 @@ class GrabOrderPage extends Component { } render() { - const localStoageUserId = getGlobalStorage('userInfo').user_id + const localStoageUserId = getGlobalStorage('userInfo')?getGlobalStorage('userInfo').user_id:'' // 提示框 const deleteModalWindowElement = diff --git a/src/pages/home/home.js b/src/pages/home/home.js index 060eec0..f13e623 100644 --- a/src/pages/home/home.js +++ b/src/pages/home/home.js @@ -13,6 +13,8 @@ import LoginService from '../../util/LoginService' import weChatLogin from '../../util/weChatLogin' import URL from '../../serviceAPI.config' import './home.scss' +import { showLoading } from '../../util/hideShowLoading'; +import { getGlobalStorage } from '../../util/getSetStoage'; @@ -35,8 +37,8 @@ class Home extends Component { otherData: [], // 底部导航栏 isOpen: false, // 抢单消息提示 grabOrderId: '',//抢到订单的id - userName: Taro.getStorageSync('user_identity').userName || '',//用户名字 - userPhone: Taro.getStorageSync('user_identity').userPhone || '',// 用户电话 + userName: '',//用户名字 + userPhone: '',// 用户电话 isShowTopNav: false,// 是否显示返回顶部按钮 loadMorePageIndex: 1,//下拉加载页面数 isAddToList: false, @@ -50,7 +52,7 @@ class Home extends Component { } // onPullDownRefresh() { - // Taro.showLoading({ title: '加载中' }) + // showLoading({ title: '加载中' }) // this.login().then(() => { // this.getShops({}) @@ -150,7 +152,7 @@ class Home extends Component { my.getLocation({ success(res) { my.hideLoading(); - + resolve(res) }, fail(res) { @@ -159,31 +161,31 @@ class Home extends Component { reject(res) }, }) - + }) - - - } else if (process.env.TARO_ENV === 'weapp') { - return new Promise((resolve, reject) => { - Taro.getLocation({ - type: 'wgs84', // 返回可以用于wx.openLocation的经纬度 - success(res) { - resolve(res) - }, - fail(res) { - Taro.showToast({ - title: '获取定位失败', - icon: 'none' - }) - reject(res) - } + + + } else if (process.env.TARO_ENV === 'weapp') { + return new Promise((resolve, reject) => { + Taro.getLocation({ + type: 'wgs84', // 返回可以用于wx.openLocation的经纬度 + success(res) { + resolve(res) + }, + fail(res) { + Taro.showToast({ + title: '获取定位失败', + icon: 'none' + }) + reject(res) + } + }) + }) - }) - - } - + } + } @@ -240,8 +242,8 @@ class Home extends Component { // 点击大类icon onClickParentCate(e) { const item = onClickValueService(e) - - Taro.showLoading({ + + showLoading({ title: '加载中' }) this.setState({ parentClass: item.class_id, childClass: item.class_id, supplyLevel: 1, subCate: item.children || [] }, () => { @@ -251,7 +253,7 @@ class Home extends Component { // 点击子类 clickChildCateHanlder(e) { const item = onClickValueService(e) - Taro.showLoading({ + showLoading({ title: '加载中' }) this.setState({ childClass: item.class_id, supplyLevel: 2 }, () => { @@ -299,8 +301,6 @@ class Home extends Component { this.GrabDemand({ demandId: this.state.grabOrderId }) } - - goToMyNeedsPublish() { // 传参数给myNeedsPublish页面- 显示效果图选项 Taro.navigateTo({ @@ -312,8 +312,7 @@ class Home extends Component { componentDidMount() { // 页面加载后 得到首页的基本信息和推荐店铺的信息 - - Taro.showLoading({ title: '加载中' }) + showLoading({ title: '加载中' }) // promise 返回经纬度给state 然后调用函数 this.getUserLocation().then(res => { this.setState({ @@ -329,10 +328,6 @@ class Home extends Component { }) // 本地缓存没有userid时 从新登入 Taro.getStorageSync('userInfo').user_id ? true : weChatLogin() - - - - } componentWillMount() { @@ -363,7 +358,7 @@ class Home extends Component { } // 底部加载 onReachBottom() { - Taro.showLoading({ + showLoading({ title: '加载中' }) this.setState({ loadMorePageIndex: this.state.loadMorePageIndex + 1, isAddToList: true }, () => { @@ -402,7 +397,7 @@ class Home extends Component { {item.class_name} }) : null - + return ( {/* 第二行图片滚动条 */} - + diff --git a/src/pages/home/home.scss b/src/pages/home/home.scss index 8e45b25..435f0df 100644 --- a/src/pages/home/home.scss +++ b/src/pages/home/home.scss @@ -9,7 +9,14 @@ $themeColor: #FF7142; width: 100%; } } - .first-banner ,.third-banner{ + .first-banner { + height:250px; + .banner-img{ + height: 100%; + width: 100%; + } + } + .third-banner{ height:200px; .banner-img{ height: 100%; diff --git a/src/pages/home/mainCateSlider/mainCateSlider.js b/src/pages/home/mainCateSlider/mainCateSlider.js index e8920d3..a61459e 100644 --- a/src/pages/home/mainCateSlider/mainCateSlider.js +++ b/src/pages/home/mainCateSlider/mainCateSlider.js @@ -28,7 +28,6 @@ class MainCateSlider extends Component { item.value = item.class_name return item }) - console.log('formatedData', formatedData) return formatedData } render() { diff --git a/src/pages/individualCenter/individualCenter.js b/src/pages/individualCenter/individualCenter.js index 0e2bb6a..20492c2 100644 --- a/src/pages/individualCenter/individualCenter.js +++ b/src/pages/individualCenter/individualCenter.js @@ -9,6 +9,7 @@ import './individualCenter.scss' import URL from '../../serviceAPI.config' import onClickValueService from '../../util/onClickValueService'; import { getGlobalStorage } from '../../util/getSetStoage'; +import { isUserLogin } from '../../util/checkLogin'; @@ -52,12 +53,12 @@ class IndividualCenter extends Component { username: '', avatar: '', isShop: false, - vip_level:'' + vip_level: '' } } handlerGridClick(e) { const value = onClickValueService(e).value - + switch (value) { case '需求发布': Taro.switchTab({ @@ -101,19 +102,25 @@ class IndividualCenter extends Component { // }) } getInfoFromStorage() { - const username = getGlobalStorage('userInfo').login_name||'' - const avatar = getGlobalStorage('userInfo').avatar||'' - const vip_level=getGlobalStorage('userInfo').vip_name||'' + const username = getGlobalStorage('userInfo').login_name || '' + const avatar = getGlobalStorage('userInfo').avatar || '' + const vip_level = getGlobalStorage('userInfo').vip_name || '' const isShop = getGlobalStorage('shopInfo').shop_id ? true : false this.setState({ - username, avatar, isShop,vip_level + username, avatar, isShop, vip_level }) } handleLogoutClick() { Logout() } + componentDidMount() { - this.getInfoFromStorage() + isUserLogin().then(res=>{ + return res + }).then(res=>{ + this.getInfoFromStorage() + }) + } componentWillReceiveProps(nextProps) { console.log(this.props, nextProps) @@ -122,17 +129,13 @@ class IndividualCenter extends Component { componentWillUnmount() { } componentDidShow() { - if (!getGlobalStorage('userInfo').user_id) { - console.log('login service') - LoginService() - return - } + isUserLogin() } componentDidHide() { } render() { - const { client, seller, username, avatar,vip_level, isShop } = this.state + const { client, seller, username, avatar, vip_level, isShop } = this.state return ( @@ -156,14 +159,14 @@ class IndividualCenter extends Component { 我的足迹 */} - + {isShop ? - + : } diff --git a/src/pages/myDemandSupplyEdit/myDemandSupplyEdit.js b/src/pages/myDemandSupplyEdit/myDemandSupplyEdit.js index 92ab4a5..918cadf 100644 --- a/src/pages/myDemandSupplyEdit/myDemandSupplyEdit.js +++ b/src/pages/myDemandSupplyEdit/myDemandSupplyEdit.js @@ -2,7 +2,7 @@ import Taro, { Component } from '@tarojs/taro' import { View, Text, Button, Input } from '@tarojs/components' import { AtInput, AtImagePicker, AtTextarea, Picker, AtModal, AtModalHeader, AtModalContent, AtModalAction } from 'taro-ui' - +import PictureUploadComponent from '../../component/pictureUploadComponent/pictureUploadComponent' import CopyrightComponent from '../../component/copyrightComponent/copyrightComponent' import URL from '../../serviceAPI.config' @@ -10,6 +10,7 @@ import URL from '../../serviceAPI.config' import './myDemandSupplyEdit.scss' import loginExpired from '../../util/loginExpired'; import { getGlobalStorage } from '../../util/getSetStoage'; +import { showLoading } from '../../util/hideShowLoading'; @@ -32,6 +33,8 @@ class MyDemandSupplyEdit extends Component { content: '', pickerImageUrl: [], // 上传的图片 ImagesInfo: [],// 后台传回来的图片信息 + initialImagesInfo: [],//初始化图片信息 + initialImageURL: [],//初始化图片url isFormCompleted: false, isConfirmWindow: false,// 删除提示框 demandSupplyId: '',// 供求id @@ -73,14 +76,16 @@ class MyDemandSupplyEdit extends Component { demandingSupplyStateSelected: selectedState, pickerImageUrl: imageFile, ImagesInfo: res.data.sdInfo.file_path, + initialImageURL: imageFile, + initialImagesInfo: res.data.sdInfo.file_path, }) - + } else if (res.data.err_code === 88888) { loginExpired(res) - }else{ + } else { Taro.showToast({ - title:res.data.err_msg, - icon:'none' + title: res.data.err_msg, + icon: 'none' }) } }) @@ -149,7 +154,7 @@ class MyDemandSupplyEdit extends Component { } else { Taro.redirectTo({ url: '/pages/mySupplyDemand/mySupplyDemand',//我的供求页面 - }) + }) } }, 1000); }) @@ -212,6 +217,13 @@ class MyDemandSupplyEdit extends Component { }) } } + + // 从图片子组件获取信息 + getImageDetails(value) { + this.setState({ + ImagesInfo: value + }) + } // 删除我的供求api onDelete({ sdID = 0 }) { Taro.request({ @@ -283,10 +295,9 @@ class MyDemandSupplyEdit extends Component { saveButtonHandler() { 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({ isSaveAndNew: false }, () => { - this.uploadDemSup({}) - }) + showLoading({ title: '保存中' }) + this.setState({ isSaveAndNew: false }, () => { + this.uploadDemSup({}) }) } else { @@ -301,11 +312,11 @@ class MyDemandSupplyEdit extends Component { // 上传供求api saveAndNewButton() { 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({ isSaveAndNew: true }, () => { - this.uploadDemSup({}) - }) + showLoading({ title: '保存中' }) + this.setState({ isSaveAndNew: true }, () => { + this.uploadDemSup({}) }) + } else { Taro.showToast({ title: '请填写完表格', @@ -317,7 +328,7 @@ class MyDemandSupplyEdit extends Component { goToMyDemSupPage() { Taro.redirectTo({ url: '/pages/mySupplyDemand/mySupplyDemand',//我的供求页面 - }) + }) } deleteButtonHandler() { this.setState({ isConfirmWindow: true }) @@ -336,7 +347,7 @@ class MyDemandSupplyEdit extends Component { componentDidMount() { // console.log('this.$router.params.sdId',this.$router.params.sdId) - Taro.showLoading({ title: '加载中' }) + showLoading({ title: '加载中' }) this.getSupplyDemandInfo() } componentWillReceiveProps(nextProps) { @@ -438,8 +449,15 @@ class MyDemandSupplyEdit extends Component { 需求图片: (最多4张) - - + + {/* - + */} diff --git a/src/pages/myGoodList/myGoodList.js b/src/pages/myGoodList/myGoodList.js index 9655432..6b800fc 100644 --- a/src/pages/myGoodList/myGoodList.js +++ b/src/pages/myGoodList/myGoodList.js @@ -1,5 +1,5 @@ import Taro, { Component } from '@tarojs/taro' -import { View, Radio, Button, MovableArea, MovableView } from '@tarojs/components' +import { View, Button, MovableArea, MovableView, CheckboxGroup, Checkbox } 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' @@ -494,11 +494,14 @@ class MyGoodList extends Component { // 单个商品选择 handleCheckChange(e) { //如果goodid 一样的那么checked 就取反 - console.log('clicke') - const id = onClickValueService(e) + // const id = onClickValueService(e) + const id = e.detail.value + const newMyGoodList = this.state.myGoodList.map((item) => { - if (item.goods_id === id) { - item['checked'] = !item.checked + if (id.includes(item.goods_id)) { + item['checked'] = true + } else { + item['checked'] = false } return item }) @@ -518,9 +521,6 @@ class MyGoodList extends Component { duration: 1500 }) // // this.deleteGood({ goodsID: checkedGoodsId }) - - - } // 改变商品状态 offStockGoodHandler() { @@ -539,9 +539,9 @@ class MyGoodList extends Component { } // 导航到商品编辑页面myGoodsEdit goToGoodEditPage(e) { - console.log('e',e) + console.log('e', e) const goodId = onClickValueService(e) - console.log('goodId',goodId) + console.log('goodId', goodId) Taro.navigateTo({ url: '/pages/myGoodsEdit/myGoodsEdit?id=' + goodId }) @@ -662,7 +662,7 @@ class MyGoodList extends Component { const goodListElementArray = this.state.myGoodList.map((item, index) => { return - + {/* */} @@ -818,19 +818,23 @@ class MyGoodList extends Component { - 全选 - + + 全选 + + - + {this.state.myGoodList.length ? - {goodListElementArray} + + {goodListElementArray} + : 没有更多了} {this.state.isShowTopNav ? : null} diff --git a/src/pages/myGoodList/myGoodList.scss b/src/pages/myGoodList/myGoodList.scss index 2cdd250..7a38bb5 100644 --- a/src/pages/myGoodList/myGoodList.scss +++ b/src/pages/myGoodList/myGoodList.scss @@ -17,6 +17,10 @@ $themeColor:#FF7142; opacity:1 ; position:fixed; } +.align-item{ + display: flex; + align-items: center; +} .MyGoodList{ padding: 10px 20px; .filterbar-container{ diff --git a/src/pages/myGoodsEdit/myGoodsEdit.js b/src/pages/myGoodsEdit/myGoodsEdit.js index d33cbc5..bf25a98 100644 --- a/src/pages/myGoodsEdit/myGoodsEdit.js +++ b/src/pages/myGoodsEdit/myGoodsEdit.js @@ -4,11 +4,13 @@ import { AtInput, AtImagePicker, AtTextarea, Button, } from 'taro-ui' import ShopTypeInteractionComp from '../../component/shopTypeInteractionComp/shopTypeInteractionComp' import CopyrightComponent from '../../component/copyrightComponent/copyrightComponent' +import PictureUploadComponent from '../../component/pictureUploadComponent/pictureUploadComponent' import URL from '../../serviceAPI.config' import './myGoodsEdit.scss' import loginExpired from '../../util/loginExpired'; import { getGlobalStorage } from '../../util/getSetStoage'; +import { showLoading } from '../../util/hideShowLoading'; class MyGoodsEdit extends Component { config = { @@ -24,6 +26,8 @@ class MyGoodsEdit extends Component { productDescript: '', pickerImageUrl: [], // 上传的图片 ImagesInfo: [],// 后台传回来的图片信息 + initialImagesInfo: [],//初始化图片信息 + initialImageURL: [],//初始化图片url goodsTypeParam: '',//商品分类参数 goodId: '',//商品id isSaveButton: false,//是否点击了保存按钮 @@ -48,25 +52,27 @@ class MyGoodsEdit extends Component { }) .then(res => { Taro.hideLoading() + if (res.data.err_code === 0) { console.log('商品详情获取成功', res) const imageFile = res.data.goodsFiles.map((item) => { return { url: URL.Base + item.files.file_path } }) - // let shopTypeSelected + let shopTypeSelected - // const shopTypeId = res.data.goods.shop_class_id - // for (let key in this.state.shopTypeList) { - // for (let item of this.state.shopTypeList[key].c) { - // if (item.id === shopTypeId) { - // shopTypeSelected = { name: item.n, id: item.id } - // } - // } - // } + const shopTypeId = res.data.goods.shop_class_id + for (let key in this.state.shopTypeList) { + for (let item of this.state.shopTypeList[key].c) { + if (item.id === shopTypeId) { + shopTypeSelected = { name: item.n, id: item.id } + } + } + } if (getGlobalStorage('shopTypeObject')) { let selectedValue = '' const shopTypeObject = getGlobalStorage('shopTypeObject') + console.log('shopTypeObject',shopTypeObject) for (let key in shopTypeObject) { for (let item of shopTypeObject[key].c) { if (item.id === res.data.goods.shop_class_id) { @@ -81,12 +87,14 @@ class MyGoodsEdit extends Component { productDescript: res.data.goods.goods_profiles, pickerImageUrl: imageFile, ImagesInfo: res.data.goodsFiles, - shopTypeSelected: selectedValue, + initialImageURL: imageFile, + initialImagesInfo: res.data.goodsFiles, + shopTypeSelected: selectedValue, goodsTypeParam: res.data.goods.class_id, goodId: res.data.goods.goods_id, }) - } + } } else if (res.data.err_code === 88888) { console.log('88888') @@ -173,14 +181,14 @@ class MyGoodsEdit extends Component { }).then(() => { setTimeout(() => { if (this.state.isSaveButton) { - // Taro.navigateBack({ + // Taro.navigateBack({ - // delta:1 - // url: '/pages/myGoodsList/myGoodsEdit?id=' + this.$router.params.id - // }) - Taro.redirectTo({ - url: '/pages/myGoodList/myGoodList' - }) + // delta:1 + // url: '/pages/myGoodsList/myGoodsEdit?id=' + this.$router.params.id + // }) + Taro.redirectTo({ + url: '/pages/myGoodList/myGoodList' + }) } else if (this.state.isSaveAndNewBUtton) { Taro.switchTab({ url: '/pages/goodsPublish/goodsPublish' @@ -286,6 +294,12 @@ class MyGoodsEdit extends Component { } } + // 从图片子组件获取信息 + getImageDetails(value) { + this.setState({ + ImagesInfo: value + }) + } shopCategoryChanged(e) { this.setState({ shopCategoryCheckedPicker: this.state.shopCategoryList[e.detail.value] @@ -296,20 +310,20 @@ class MyGoodsEdit extends Component { // 保存按钮 saveButtonHandler() { if (this.state.productName && this.state.productPrice && this.state.productUnit && this.state.ImagesInfo.length && this.state.shopTypeSelected.id) { - Taro.showLoading({ title: '保存中' }).then(() => { - this.setState({ isSaveButton: true }, () => { - this.uploadGoods({ - goods_name: this.state.productName, - goods_price: this.state.productPrice, - goods_unit: this.state.productUnit, - goods_profiles: this.state.productDescript, - shop_class_id: this.state.shopTypeSelected.id, - class_id: this.state.goodsTypeParam, - goods_id: this.state.goodId, - }) - + showLoading({ title: '保存中' }) + this.setState({ isSaveButton: true }, () => { + this.uploadGoods({ + goods_name: this.state.productName, + goods_price: this.state.productPrice, + goods_unit: this.state.productUnit, + goods_profiles: this.state.productDescript, + shop_class_id: this.state.shopTypeSelected.id, + class_id: this.state.goodsTypeParam, + goods_id: this.state.goodId, }) + }) + } else { Taro.showToast({ title: '请填写完表格', @@ -322,21 +336,21 @@ class MyGoodsEdit extends Component { // 保存并新增按钮 saveAndNewButton() { if (this.state.productName && this.state.productPrice && this.state.productUnit && this.state.ImagesInfo.length && this.state.shopTypeSelected.id) { - Taro.showLoading({ title: '保存中' }).then(() => { - this.setState({ isSaveAndNewBUtton: true }, () => { - this.uploadGoods({ - goods_name: this.state.productName, - goods_price: this.state.productPrice, - goods_unit: this.state.productUnit, - goods_profiles: this.state.productDescript, - shop_class_id: this.state.shopTypeSelected.id, - class_id: this.state.goodsTypeParam, - goods_id: this.state.goodId, - }) - + showLoading({ title: '保存中' }) + this.setState({ isSaveAndNewBUtton: true }, () => { + this.uploadGoods({ + goods_name: this.state.productName, + goods_price: this.state.productPrice, + goods_unit: this.state.productUnit, + goods_profiles: this.state.productDescript, + shop_class_id: this.state.shopTypeSelected.id, + class_id: this.state.goodsTypeParam, + goods_id: this.state.goodId, }) }) + + } else { Taro.showToast({ title: '请填写完表格', @@ -365,8 +379,8 @@ class MyGoodsEdit extends Component { componentDidMount() { - Taro.showLoading({ - title:'加载中' + showLoading({ + title: '加载中' }) this.getGoodsInfo() @@ -429,7 +443,15 @@ class MyGoodsEdit extends Component { * 上传图片: - + + {/* - + */} {/* 店铺分类 */} - diff --git a/src/pages/myNeeds/myNeeds.js b/src/pages/myNeeds/myNeeds.js index fed1a21..72dd020 100644 --- a/src/pages/myNeeds/myNeeds.js +++ b/src/pages/myNeeds/myNeeds.js @@ -12,6 +12,8 @@ import './myNeeds.scss' import loginExpired from '../../util/loginExpired'; import onClickValueService from '../../util/onClickValueService'; import { getGlobalStorage } from '../../util/getSetStoage'; +import { showLoading } from '../../util/hideShowLoading'; +import { isUserLogin } from '../../util/checkLogin'; class MyNeeds extends Component { @@ -185,7 +187,7 @@ class MyNeeds extends Component { // 搜索按钮 onSearchButtonHandler() { - Taro.showLoading({ title: '加载中' }).then(() => { + showLoading({ title: '加载中' }).then(() => { this.setState({ currentPage: 1, loadMorePageIndex: 1 }, () => { this.getMyNeedsList({ curr_page: this.state.currentPage, @@ -283,10 +285,15 @@ class MyNeeds extends Component { componentDidMount() { - Taro.showLoading({ + isUserLogin().then(res=>{ + return res + }).then(res=>{ + showLoading({ title: '加载中' }) this.getMyNeedsList({}) + }) + } componentWillReceiveProps(nextProps) { @@ -296,10 +303,7 @@ class MyNeeds extends Component { componentWillUnmount() { } componentDidShow() { - if (!getGlobalStorage('userInfo').user_id) { - LoginService() - return - } + isUserLogin() } componentDidHide() { } @@ -314,7 +318,7 @@ class MyNeeds extends Component { } // 底部加载 onReachBottom() { - Taro.showLoading({ + showLoading({ title: '加载中' }) this.setState({ isAddToList: true, loadMorePageIndex: this.state.loadMorePageIndex + 1 }, () => { diff --git a/src/pages/myNeedsEdit/myNeedsEdit.js b/src/pages/myNeedsEdit/myNeedsEdit.js index cfae7bb..bea1c36 100644 --- a/src/pages/myNeedsEdit/myNeedsEdit.js +++ b/src/pages/myNeedsEdit/myNeedsEdit.js @@ -1,14 +1,16 @@ import Taro, { Component } from '@tarojs/taro' import { View, Text, Button, Input } from '@tarojs/components' -import { AtInput, AtImagePicker, AtTextarea, Picker, AtModal, AtModalHeader, AtModalContent, AtModalAction } from 'taro-ui' +import { AtInput, AtTextarea, Picker, AtModal, AtModalHeader, AtModalContent, AtModalAction } from 'taro-ui' import InteractionComponent from '../../component/interactionComponent/interactionComponent' import CopyrightComponent from '../../component/copyrightComponent/copyrightComponent' +import PictureUploadComponent from '../../component/pictureUploadComponent/pictureUploadComponent' import URL from '../../serviceAPI.config' import './myNeedsEdit.scss' import loginExpired from '../../util/loginExpired'; import { getGlobalStorage } from '../../util/getSetStoage'; +import { showLoading } from '../../util/hideShowLoading'; class MyNeedsEdit extends Component { @@ -34,9 +36,10 @@ class MyNeedsEdit extends Component { contactAddress: '', content: '',//描述 pickerImageUrl: [], - ImagesInfo: '', + ImagesInfo: [],// 图片详细信息 + initialImagesInfo: [],//初始化图片信息 + initialImageURL: [],//初始化图片url isDeleteModal: false,// 删除提示框 - isSaveAndNew: false,//是否点击保存新增按钮 @@ -62,7 +65,7 @@ class MyNeedsEdit extends Component { // 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) { @@ -102,13 +105,15 @@ class MyNeedsEdit extends Component { contactAddress: res.data.sdInfo.user_address, content: res.data.sdInfo.sd_desc, needsStateSelected: needsState, - pickerImageUrl: imageFile, + initialImageURL: imageFile, + initialImagesInfo: res.data.sdInfo.file_path, + ImageURL: imageFile, ImagesInfo: res.data.sdInfo.file_path, }) - - }else if (JSON.parse(res.data).err_code === 88888) { + + } else if (JSON.parse(res.data).err_code === 88888) { loginExpired(res) - } else { + } else { Taro.showToast({ title: JSON.parse(res.data).err_msg, icon: 'none' @@ -119,8 +124,6 @@ class MyNeedsEdit extends Component { ) } - - // uploadMyNeedsApi 上传需求 的api uploadMyNeedsApi() { @@ -185,9 +188,9 @@ class MyNeedsEdit extends Component { } }, 1500); }) - }else if (res.data.err_code === 88888) { + } else if (res.data.err_code === 88888) { loginExpired(res) - } else { + } else { Taro.showToast({ title: '保存失败', icon: 'none', @@ -199,51 +202,6 @@ class MyNeedsEdit extends Component { } - // 上传图片 - onChangeImg(files, operationType, index) { - const that = this - if (operationType === 'add') { - Taro.uploadFile({ - url: URL.UploadDSPorductImage, - filePath: files[files.length - 1].url, - name: 'file', - header: { - 'content-type': 'multipart/form-data', - 'Cookie': 'PFWSSS=' + getGlobalStorage('session_id'), - 'X-Requested-With': 'XMLHttpRequest' - }, - success(response) { - const data = JSON.parse(response.data) - const imagePath = URL.Base + data.file_path - const newPickerImageUrl = that.state.pickerImageUrl.concat({ url: imagePath }) - const newImageInfo = that.state.ImagesInfo.concat(data) - that.setState({ - pickerImageUrl: newPickerImageUrl, - ImagesInfo: newImageInfo - }) - Taro.showToast({ - title: '上传成功', - icon: 'success', - duration: 1500 - }) - } - }) - } - if (operationType === 'remove') { - this.state.ImagesInfo.splice(index, 1) // 删除显示的图片 - this.state.pickerImageUrl.splice(index, 1)// 删除图片param - that.setState({ - pockerImageUrl: this.state.pickerImageUrl, - ImagesInfo: this.state.ImagesInfo, - }) - Taro.showToast({ - title: '删除成功', - icon: 'success', - duration: 1500 - }) - } - } - //删除我的需求 api DeleteMyNeeds deleteMyNeeds({ demandId = 10 }) { Taro.request({ @@ -274,9 +232,9 @@ class MyNeedsEdit extends Component { }) }, 1000); - }else if (res.data.err_code === 88888) { + } else if (res.data.err_code === 88888) { loginExpired(res) - } else { + } else { Taro.showToast({ title: res.data.err_msg, icon: 'none', @@ -319,14 +277,14 @@ class MyNeedsEdit extends Component { url: '/pages/myNeeds/myNeeds' }) } - + // 保存需求按钮 saveButtonHandler() { if (this.state.title && this.state.contactName && this.state.contactNumber && this.state.content && this.state.needsStateSelected) { - Taro.showLoading({ + showLoading({ title: '保存中' }) this.setState({ isSaveAndNew: false }, () => { @@ -340,13 +298,19 @@ class MyNeedsEdit extends Component { }) } } + // 从图片子组件获取信息 + getImageDetails(value) { + this.setState({ + ImagesInfo: value + }) + } // 保存新增按钮 saveAndNewButton() { if (this.state.title && this.state.contactName && this.state.contactNumber && this.state.content && this.state.needsStateSelected) { - Taro.showLoading({ + showLoading({ title: '保存中' }) this.setState({ isSaveAndNew: true }, () => { @@ -486,17 +450,14 @@ class MyNeedsEdit extends Component { 需求图片: (最多4张) - - - - + diff --git a/src/pages/myNeedsPublish/myNeedsPublish.js b/src/pages/myNeedsPublish/myNeedsPublish.js index 93fe32a..c3ac7ad 100644 --- a/src/pages/myNeedsPublish/myNeedsPublish.js +++ b/src/pages/myNeedsPublish/myNeedsPublish.js @@ -1,17 +1,20 @@ import Taro, { Component } from '@tarojs/taro' -import { View, Text, Button, Input } from '@tarojs/components' -import { AtInput, AtImagePicker, AtTextarea, Picker } from 'taro-ui' +import { View, Text, Button, Input, } from '@tarojs/components' +import { AtInput, AtTextarea, Picker } from 'taro-ui' + +import PictureUploadComponent from '../../component/pictureUploadComponent/pictureUploadComponent' import CopyrightComponent from '../../component/copyrightComponent/copyrightComponent' import URL from '../../serviceAPI.config' import InteractionComponent from '../../component/interactionComponent/interactionComponent' -import LoginService from '../../util/LoginService' import './myNeedsPublish.scss' import loginExpired from '../../util/loginExpired'; import { getGlobalStorage } from '../../util/getSetStoage'; +import { showLoading } from '../../util/hideShowLoading'; +import {isUserLogin} from '../../util/checkLogin'; @@ -29,14 +32,14 @@ class MyNeedsPublish extends Component { needsType: [{ name: '业主需求', id: '4' }, { name: '效果图', id: '5' }], needsTypeSelected: { name: '业主需求', id: '4' }, title: '', - contactName: getGlobalStorage('user_identity').username || '', - contactNumber: getGlobalStorage('user_identity').userphone || '', + contactName: '', + contactNumber: '', contactAddress: '', content: '', pickerImageUrl: [], // 上传的图片 ImagesInfo: [],// 后台传回来的图片信息 - isPublishAndNew: false,//是否点击发布新增按钮 + } } @@ -72,7 +75,6 @@ class MyNeedsPublish extends Component { sd_desc: this.state.content, state: this.state.needsStateSelected.id, file_path: file_path, - }) }, header: { @@ -82,36 +84,34 @@ class MyNeedsPublish extends Component { } }) .then(response => { - console.log('上传需求', response) - - const res = JSON.parse(response.data) - console.log('jonson parse', res) + console.log('上传需求成功', response) + const res = response.data Taro.hideLoading() if (res.err_code === 0) { + console.log('error code 0') Taro.showToast({ title: '发布成功', icon: 'success', duration: 1500 - }).then(() => { - setTimeout(() => { - if (this.state.isPublishAndNew) { - Taro.navigateTo({ - url: '/pages/myNeedsPublish/myNeedsPublish' - }) - } else { - Taro.navigateTo({ - url: '/pages/myNeedsEdit/myNeedsEdit?id=' + res.sd_id - }) - } - }, 1500); }) - + setTimeout(() => { + console.log('settimeout') + if (this.state.isPublishAndNew) { + Taro.navigateTo({ + url: '/pages/myNeedsPublish/myNeedsPublish' + }) + } else { + Taro.navigateTo({ + url: '/pages/myNeedsEdit/myNeedsEdit?id=' + res.sd_id + }) + } + }, 1500); } else if (res.err_code === 88888) { - + console.log('返回错误88888') const resp = { data: { err_msg: res.err_msg } } - console.log('resp',resp) loginExpired(resp) } else { + Taro.showToast({ title: res.err_msg, icon: 'none', @@ -121,12 +121,12 @@ class MyNeedsPublish extends Component { } ) - } // 上传图片 onChangeImg(files, operationType, index) { const that = this + if (operationType === 'add') { Taro.uploadFile({ url: URL.MyNeedUploadImage, @@ -199,6 +199,13 @@ class MyNeedsPublish extends Component { } contentChange(event) { this.setState({ content: event.target.value }) + } + // 从图片子组件获取信息 + + getImageDetails(value) { + this.setState({ + ImagesInfo: value + }) } // 发布按钮 publishButtonHandler() { @@ -207,7 +214,7 @@ class MyNeedsPublish extends Component { && this.state.contactNumber && this.state.content && this.state.needsStateSelected) { - Taro.showLoading({ + showLoading({ title: '发布中' }) this.setState({ isPublishAndNew: false }, () => { @@ -231,7 +238,7 @@ class MyNeedsPublish extends Component { && this.state.contactNumber && this.state.content && this.state.needsStateSelected) { - Taro.showLoading({ + showLoading({ title: '发布中' }) this.setState({ isPublishAndNew: true }, () => { @@ -259,6 +266,10 @@ class MyNeedsPublish extends Component { componentDidMount() { + this.setState({ + contactName: getGlobalStorage('user_identity')?getGlobalStorage('user_identity').username : '', + contactNumber: getGlobalStorage('user_identity')?getGlobalStorage('user_identity').userphone : '', + }) // console.log('this.$router.params.sdId',this.$router.params.sdId) // Taro.showLoading({title:'加载中'}) // this.getSupplyDemandInfo() @@ -274,11 +285,8 @@ class MyNeedsPublish extends Component { componentWillUnmount() { } - componentDidShow() { - if (!getGlobalStorage('userInfo').user_id) { - LoginService() - return - } + componentDidShow() { + isUserLogin() } componentDidHide() { } @@ -365,13 +373,18 @@ class MyNeedsPublish extends Component { placeholder='' /> + + + 需求图片: (最多4张) + - + {/* 微信使用 */} + {/* - + */} diff --git a/src/pages/myNeedsPublish/myNeedsPublish.scss b/src/pages/myNeedsPublish/myNeedsPublish.scss index 12d119c..5b1778c 100644 --- a/src/pages/myNeedsPublish/myNeedsPublish.scss +++ b/src/pages/myNeedsPublish/myNeedsPublish.scss @@ -76,4 +76,4 @@ $themeColor:#FF7142; .title-box{ line-height:100rpx; } -} \ No newline at end of file +} diff --git a/src/pages/myNeedsView/myNeedsView.js b/src/pages/myNeedsView/myNeedsView.js index d5e6869..0a90794 100644 --- a/src/pages/myNeedsView/myNeedsView.js +++ b/src/pages/myNeedsView/myNeedsView.js @@ -10,6 +10,7 @@ import CopyrightComponent from '../../component/copyrightComponent/copyrightComp import './myNeedsView.scss' import loginExpired from '../../util/loginExpired'; import { getGlobalStorage } from '../../util/getSetStoage'; +import { showLoading } from '../../util/hideShowLoading'; @@ -194,7 +195,7 @@ class SupplyDemandView extends Component { } componentDidMount() { - Taro.showLoading({ title: '加载中' }) + showLoading({ title: '加载中' }) this.getSingleMyNeedInfo() } componentWillReceiveProps(nextProps) { diff --git a/src/pages/mySupplyDemand/mySupplyDemand.js b/src/pages/mySupplyDemand/mySupplyDemand.js index 18c365c..3bf5cf3 100644 --- a/src/pages/mySupplyDemand/mySupplyDemand.js +++ b/src/pages/mySupplyDemand/mySupplyDemand.js @@ -12,6 +12,8 @@ import loginExpired from '../../util/loginExpired' import './mySupplyDemand.scss' import onClickValueService from '../../util/onClickValueService'; import { getGlobalStorage } from '../../util/getSetStoage'; +import { showLoading } from '../../util/hideShowLoading'; +import { isUserShopOwner } from '../../util/checkLogin'; class MySupplyDemand extends Component { @@ -116,7 +118,7 @@ class MySupplyDemand extends Component { onSearchButtonHandler() { - Taro.showLoading({ title: '加载中' }) + showLoading({ title: '加载中' }) this.setState({ loadMorePageIndex: 1 }, () => { this.getMySupplyDemand({ curr_page: this.state.loadMorePageIndex }) @@ -227,7 +229,7 @@ class MySupplyDemand extends Component { } handleWindowConfirm() { this.setState({ isConfirmWindow: false }) - Taro.showLoading({ + showLoading({ title: '加载中' }) this.onDelete({ sdID: this.state.demandSupplyId }) @@ -286,23 +288,14 @@ class MySupplyDemand extends Component { componentDidMount() { this.getUserSystemInfo() - Taro.showLoading({ title: '加载中' }).then(() => { - this.getMySupplyDemand({}) - }) + showLoading({ title: '加载中' }) + this.getMySupplyDemand({}) + } componentWillUnmount() { } componentDidShow() { - if (!getGlobalStorage('userInfo').user_id) { - LoginService() - return - } - if (!getGlobalStorage('shopInfo').shop_id && getGlobalStorage('userInfo').user_id) { - Taro.showToast({ - title: '您还没有店铺,不能使用该功能,快去申请吧', - icon: 'none' - }) - } + isUserShopOwner() } componentDidHide() { } @@ -316,7 +309,7 @@ class MySupplyDemand extends Component { } // 底部加载 onReachBottom() { - Taro.showLoading({ + showLoading({ title: '加载中' }) diff --git a/src/pages/shop/shop.js b/src/pages/shop/shop.js index 486b748..7b8e499 100644 --- a/src/pages/shop/shop.js +++ b/src/pages/shop/shop.js @@ -13,6 +13,7 @@ import ShopItem from '../../component/shopItemComponent/shopItemComponent' import CopyrightComponent from '../../component/copyrightComponent/copyrightComponent' import onClickValueService from '../../util/onClickValueService'; import { getGlobalStorage } from '../../util/getSetStoage'; +import { showLoading } from '../../util/hideShowLoading'; const locationIcon = require('../../assets/img/location.png') @@ -355,7 +356,7 @@ class Shop extends Component { // 产品排序 accendingDescending(e) { const value = onClickValueService(e) - Taro.showLoading({ title: '加载中' }) + showLoading({ title: '加载中' }) this.setState({ selectedFilterValue: value }) if (value == 0) { this.setState({ @@ -456,7 +457,7 @@ class Shop extends Component { // 选择侧边筛选的标签 selectTag(name) { const id = name.name - Taro.showLoading({ title: '加载中' }) + showLoading({ title: '加载中' }) // 处理分类筛选项 const newMainType = this.state.mainType.map((item) => { if (item.id === id) { @@ -523,7 +524,7 @@ class Shop extends Component { } handleOnPageChange(value) { - Taro.showLoading({ title: '加载中' }) + showLoading({ title: '加载中' }) this.goodsSearch({ curr_page: value.current, order: this.state.filterCondition }) } showHomePage() { @@ -541,7 +542,7 @@ class Shop extends Component { //重置按键筛选 resetFilterList() { - Taro.showLoading({ title: '加载中' }) + showLoading({ title: '加载中' }) this.setState({ checkedFilterIdList: [], curr_page: 1, @@ -573,7 +574,7 @@ class Shop extends Component { }) } componentDidMount() { - Taro.showLoading({ title: '加载中' }) + showLoading({ title: '加载中' }) //页面加载之后 得到指定店铺的商品 和 筛选标签 this.goodsSearch({}) // 加载店铺商品 this.getSearchParams({})// 加载筛选项 @@ -586,7 +587,7 @@ class Shop extends Component { // 底部加载 onReachBottom() { - Taro.showLoading({ + showLoading({ title: '加载中' }) this.setState({ isAddToList: true, loadMorePageIndex: this.state.loadMorePageIndex + 1 }, () => { diff --git a/src/pages/supplyDemandPublish/supplyDemandPublish.js b/src/pages/supplyDemandPublish/supplyDemandPublish.js index ba885dd..a5ab5e0 100644 --- a/src/pages/supplyDemandPublish/supplyDemandPublish.js +++ b/src/pages/supplyDemandPublish/supplyDemandPublish.js @@ -4,12 +4,15 @@ import { View, Text, Button, Input } from '@tarojs/components' import { AtInput, AtImagePicker, AtTextarea, Picker } from 'taro-ui' import CopyrightComponent from '../../component/copyrightComponent/copyrightComponent' -import LoginService from '../../util/LoginService' +import PictureUploadComponent from '../../component/pictureUploadComponent/pictureUploadComponent' +import LoginService from '../../util/LoginService' import URL from '../../serviceAPI.config' import './supplyDemandPublish.scss' import loginExpired from '../../util/loginExpired'; import { getGlobalStorage } from '../../util/getSetStoage'; +import { showLoading } from '../../util/hideShowLoading'; +import { isUserShopOwner } from '../../util/checkLogin'; class SupplyDemand extends Component { config = { @@ -23,8 +26,8 @@ class SupplyDemand extends Component { demandingSupplyState: [{ name: '上架', id: '1' }, { name: '下架', id: '0' }], // 状态选择 demandingSupplyStateSelected: { name: '上架', id: '1' },// 当前状态 title: '', - contactName: getGlobalStorage('user_identity').username||'', - contactNumber: getGlobalStorage('user_identity').userphone||'', + contactName:'', + contactNumber: '', contactAddress: '', content: '', pickerImageUrl: [], // 上传的图片 @@ -165,6 +168,12 @@ class SupplyDemand extends Component { duration: 1500 }) } + } + // 从图片子组件获取信息 + getImageDetails(value) { + this.setState({ + ImagesInfo: value + }) } // 修改供求类型 demandingSupplyCate = e => { @@ -203,11 +212,11 @@ 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({ isPublishAndNew: false }, () => { - this.uploadDemSup({}) - }) + showLoading({ title: '发布中' }) + this.setState({ isPublishAndNew: false }, () => { + this.uploadDemSup({}) }) + } else { Taro.showToast({ title: '请填写完表格', @@ -223,11 +232,11 @@ 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({ isPublishAndNew: true }, () => { - this.uploadDemSup({}) - }) + showLoading({ title: '发布中' }) + this.setState({ isPublishAndNew: true }, () => { + this.uploadDemSup({}) }) + } else { Taro.showToast({ title: '请填写完表格', @@ -250,7 +259,10 @@ class SupplyDemand extends Component { } componentDidMount() { - +this.setState({ + contactName: getGlobalStorage('user_identity').username || '', + contactNumber: getGlobalStorage('user_identity').userphone || '', +}) } componentWillReceiveProps(nextProps) { // console.log(this.props, nextProps) @@ -259,16 +271,7 @@ class SupplyDemand extends Component { componentWillUnmount() { } componentDidShow() { - if (!getGlobalStorage('userInfo').user_id) { - LoginService() - return - } - if (!getGlobalStorage('shopInfo').shop_id && getGlobalStorage('userInfo').user_id) { - Taro.showToast({ - title: '您还没有店铺,不能使用该功能,快去申请吧', - icon: 'none' - }) - } + isUserShopOwner() } componentDidHide() { } @@ -353,8 +356,9 @@ class SupplyDemand extends Component { 需求图片: (最多4张) + - + {/* - + */} diff --git a/src/pages/supplyDemandView/supplyDemandView.js b/src/pages/supplyDemandView/supplyDemandView.js index 3e36ba6..bae8d97 100644 --- a/src/pages/supplyDemandView/supplyDemandView.js +++ b/src/pages/supplyDemandView/supplyDemandView.js @@ -10,6 +10,7 @@ import CopyrightComponent from '../../component/copyrightComponent/copyrightComp import './supplyDemandView.scss' import loginExpired from '../../util/loginExpired'; import { getGlobalStorage } from '../../util/getSetStoage'; +import { showLoading } from '../../util/hideShowLoading'; @@ -64,15 +65,15 @@ class SupplyDemandView extends Component { images: res.data.sdInfo.file_path, itemId: res.data.sdInfo.sd_id }) - + } else if (res.data.err_code === 88888) { loginExpired(res) - }else{ + } else { Taro.showToast({ - title:res.data.err_msg, - icon:'none' + title: res.data.err_msg, + icon: 'none' }) - } + } } ) @@ -120,7 +121,7 @@ class SupplyDemandView extends Component { } ) - + } goToSDPublishPage() { Taro.redirectTo({ @@ -153,15 +154,15 @@ class SupplyDemandView extends Component { } handleWindowConfirm() { this.setState({ isDeleteModal: false }) - Taro.showLoading({ + showLoading({ title: '加载中' }) this.onDelete({ sdID: this.state.itemId }) } - componentDidMount() { - Taro.showLoading({ title: '加载中' }) + showLoading({ title: '加载中' }) + this.getSupplyDemandInfo() } componentWillReceiveProps(nextProps) { diff --git a/src/serviceAPI.config.js b/src/serviceAPI.config.js index c8e6e7a..c95a9bb 100644 --- a/src/serviceAPI.config.js +++ b/src/serviceAPI.config.js @@ -1,6 +1,6 @@ const LOCALURL = "http://192.168.1.230/" -// const LOCALURL = "https://www.ihome6.com/" + //const LOCALURL = "https://www.ihome6.com/" const URL = { Base: LOCALURL, diff --git a/src/todo list.txt b/src/todo list.txt deleted file mode 100644 index 2721e4e..0000000 --- a/src/todo list.txt +++ /dev/null @@ -1,588 +0,0 @@ -todo list: -首页: -商品发布页面: - -供求发布页面 -全部业主需求页面: -我的供求页面: -我的商品列表页面 - 商品编辑页面 - -我的需求列表页面: -接口问题: -优惠卷和询价 -bug: 商品编辑 增加图片后 图片顺序乱了 - - - - -等待后台--- 单个我的商品页面的图片顺序,单个我的需求页面的接口, 当个我哦的需求编辑页面的接口 -import Taro, { Component } from '@tarojs/taro' -import { View, Button, Text, Swiper, SwiperItem, Image, } from '@tarojs/components' -import { AtModal, AtModalHeader, AtModalContent, AtModalAction } from 'taro-ui' -import MainCateSlider from './mainCateSlider/mainCateSlider' -import FilteredShopComponent from '../../component/filteredShopComponent/filteredShopComponent' -import ScrollToTopComponent from '../../component/scrollToTopComponent/scrollToTopComponent' -import CopyrightComponent from '../../component/copyrightComponent/copyrightComponent' - - -import LoginService from '../../util/LoginService' -import weChatLogin from '../../util/weChatLogin' -import URL from '../../serviceAPI.config' -import './home.scss' - - - - -class Home extends Component { - - config = { - navigationBarTitleText: '首页', - - } - - constructor() { - super(...arguments); - this.state = { - shops: [], // 推荐店铺的信息 - ads: [], //广告图片数组 - categories: [],// 大类 - subCate: [], //小类 - demanding: [],// 业主需求 - otherData: [], // 底部导航栏 - isOpen: false, // 抢单消息提示 - grabOrderId: '',//抢到订单的id - userName: getGlobalStorage('user_identity').userName || '',//用户名字 - userPhone: getGlobalStorage('user_identity').userPhone || '',// 用户电话 - isShowTopNav: false,// 是否显示返回顶部按钮 - loadMorePageIndex: 1,//下拉加载页面数 - isAddToList: false, - parentClass: '',// 大类的id - childClass: '-1',//小类的id - supplyLevel: 1,// 筛选1是小类或者2是大类, - latitude: '', - longitude: '', - - } - } - - // onPullDownRefresh() { - // Taro.showLoading({ title: '加载中' }) - - // this.login().then(() => { - // this.getShops({}) - // this.getHomeCategoriesInfo() - // }).catch(err => console.log('微信登入失败:', err)) - - // Taro.stopPullDownRefresh() - // } - - - //api得到首页的信息 - getHomeCategoriesInfo() { - Taro.request({ - url: URL.ShopWxStore, - header: { - // 'Cookie': 'PFWSSS=' + getGlobalStorage('session_id'), - } - }) - .then(res => { - console.log('首页基本信息', res) - if (res.data.err_msg === 'success') { - - this.setState({ - ads: res.data.data.adsLb, - categories: [res.data.data.supplyClass[0], Object.values(res.data.data.supplyClass[1])], - demanding: res.data.data.demand.supplys, - otherData: res.data.otherData, - userName: res.data.otherData.userName, - userPhone: res.data.otherData.userPhone, - }) - } else { - Taro.showToast({ - title: res.data.err_msg, - icon: 'none', - duration: 1500 - }) - } - }) - } - // api 得到推荐商店的信息 - getShops({ parent_supply_class = this.state.parentClass, supply_class = this.state.childClass, supply_level = this.state.supplyLevel, curr_page = 1, - page_count = 5, action = "2" }) { - Taro.request({ - url: URL.ShopSupplyShops, - method: 'POST', - dataType: 'json', - data: { - param: JSON.stringify({ - curr_page: curr_page, - page_count: page_count, - parent_supply_class: parent_supply_class, //父级class id - supply_class: supply_class,// 子级class id - supply_level: supply_level,// 层级 - action: action, - latitude: this.state.latitude, - longitude: this.state.longitude, - }) - }, - header: { - 'content-type': 'application/x-www-form-urlencoded', - 'Cookie': 'PFWSSS=' + getGlobalStorage('session_id'), - } - }) - .then(res => { - console.log('所有店铺的信息', res) - Taro.hideLoading() - if (res.data.err_code === 0) { - if (this.state.isAddToList) { - if (res.data.shops) { - this.setState({ shops: this.state.shops.concat(res.data.shops), isAddToList: false }) - } else { - Taro.showToast({ - title: '没有更多了', - icon: 'none', - duration: 1500 - }) - } - } else { - res.data.shops ? this.setState({ shops: res.data.shops }) : this.setState({ shops: [] }) - } - } else { - Taro.showToast({ - title: res.data.err_msg, - icon: 'none', - duration: 1500 - }) - } - - this.setState({ isAddToList: false }) - } - ) - } - getUserLocation() { - return new Promise((resolve, reject) => { - Taro.getLocation({ - type: 'wgs84', // 返回可以用于wx.openLocation的经纬度 - success(res) { - resolve(res) - }, - fail(res) { - Taro.showToast({ - title: '获取定位失败', - icon: 'none' - }) - reject(res) - } - }) - - }) - - } - - - // 微信用户设置 - // wxUserSetting() { - // Taro.getSetting({ - // success(res) { - // if (res.authSetting['scope.userInfo']) { - // console.log('personal info', res) - // Taro.authorize({ - // scope: 'scope.userInfo', - // success() { - // // 用户已经同意小程序使用录音功能,后续调用 wx.startRecord 接口不会弹窗询问 - // // Taro.getUserInfo({ - // // success(res1) { - // // console.log('res1',res1) - // // } - // // }) - // console.log('权限允许') - // } - // }) - // } - // } - // }) - // } - // api 抢单请求 - GrabDemand({ demandId = 218 }) { - Taro.request({ - url: URL.GrabDemand, - method: 'POST', - dataType: 'json', - data: { - demandId: demandId - }, - header: { - 'content-type': 'application/x-www-form-urlencoded', - 'Cookie': 'PFWSSS=' + getGlobalStorage('session_id'), - 'X-Requested-With': 'XMLHttpRequest' - } - }) - .then(res => { - Taro.showToast({ - title: res.data.err_msg === 'success' ? '抢单成功' : res.data.err_msg, - icon: 'none', - duration: 1500 - }) - - console.log('抢单请求:', res) - - }) - - } - // 点击大类icon - onClickParentCate(e) { - const item = e.currentTarget.dataset.eTapAA - Taro.showLoading({ - title: '加载中' - }) - this.setState({ parentClass: item.class_id, childClass: item.class_id, supplyLevel: 1, subCate: item.children || [] }, () => { - this.getShops({}) - }) - - - } - // 点击子类 - onClickChildCate(e) { - const item = e.currentTarget.dataset.eTapAA - Taro.showLoading({ - title: '加载中' - }) - this.setState({ childClass: item.class_id, supplyLevel: 2 }, () => { - this.getShops({}) - - }) - // this.getShops(item.parent_class_id, item.class_id, 2) - - } - scrollToSubCate(item) { - - Taro.pageScrollTo({ - scrollTop: 410, - duration: 300 - }) - this.onClickParentCate(item) - } - // 转到其他页面 - goToAllDemandingPage() { - if (!getGlobalStorage('userInfo').user_id) { - LoginService() - return - } - Taro.navigateTo({ - url: '/pages/allDemanding/allDemanding' - }) - } - - grabOrderId(e) { - const id = e.currentTarget.dataset.eTapAA - this.setState({ isOpen: true, grabOrderId: id }) - } - handleGrabModalClose() { - this.setState({ isOpen: false }) - } - handleGrabModalCancel() { - this.setState({ isOpen: false }) - } - handleGrabConfirm() { - if (!getGlobalStorage('userInfo').user_id) { - LoginService() - } - this.setState({ isOpen: false }) - // 确认抢单之后 - this.GrabDemand({ demandId: this.state.grabOrderId }) - } - - - // 导航去抢单页面 - goToGrabOrderPage(e) { - const orderId = e.currentTarget.dataset.eTapAA - - Taro.navigateTo({ - url: '/pages/grabOrderPage/grabOrderPage?orderId=' + orderId - }) - } - goToMyNeedsPublish() { - // 传参数给myNeedsPublish页面- 显示效果图选项 - Taro.navigateTo({ - url: '/pages/myNeedsPublish/myNeedsPublish?id=1' - }) - - } - - - componentDidMount() { - // 页面加载后 得到首页的基本信息和推荐店铺的信息 - - Taro.showLoading({ title: '加载中' }) - // promise 返回经纬度给state 然后调用函数 - this.getUserLocation().then(res => { - this.setState({ - latitude: res.latitude, - longitude: res.longitude - }, () => { - this.getShops({}) - this.getHomeCategoriesInfo() - }) - }).catch(err => { - this.getShops({}) - this.getHomeCategoriesInfo() - }) - // 本地缓存没有userid时 从新登入 - getGlobalStorage('userInfo').user_id ? true : weChatLogin() - - - - - } - - componentWillMount() { - - } - componentWillUnmount() { } - - componentDidShow() { - - } - - componentDidHide() { } - - - // 微信用户信息 - onGotUserInfo(e) { - console.log(e.detail.errMsg) - console.log(e.detail.userInfo) - console.log(e.detail.rawData) - } - // 页面位置 - 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({ loadMorePageIndex: this.state.loadMorePageIndex + 1, isAddToList: true }, () => { - this.getShops({ curr_page: this.state.loadMorePageIndex, }) - }) - } - - render() { - // 提示模态弹窗element - const modalMessageGrabElement = - 提示 - - 确认抢单? - - - - - const demandingElemensArray = this.state.demanding.length ? this.state.demanding.map((item, index) => { - - return - - - - {item.class_name} - - - {item.sd_title} - - - {item.user_address || '--'} - - - 业主:{item.user_name} - - - {item.state === '1' ? - - : null || item.state === '2' ? - - : null || item.state === '3' ? - - : null} - {/* - - */} - - - }) : null - - const adsImgElementsArray = this.state.ads.length ? this.state.ads.map((item, index) => { - return - - - }) : null - - // 这里应该代码可以优化----- - const categoriesElementsArray1 = this.state.categories.length ? this.state.categories[0].map((item, index) => { - return - {/* onClick={this.onClickParentCate.bind(this, item)}> */} - - {item.class_name} - - }) : null - const categoriesElementsArray2 = this.state.categories.length ? this.state.categories[1].map((item, index) => { - return - {/* onClick={this.onClickParentCate.bind(this, item)}> */} - - {item.class_name} - - }) : null - - const shopCollectionElementsArray = this.state.shops.length ? this.state.shops.map((item, index) => { - return - }) : 没有更多了 - const subCateElementsArray = this.state.subCate.length ? this.state.subCate.map((item, index) => { - return - {item.class_name} - - }) : null - - return ( - - - {/* 获取微信用户的信息 */} - {/* 获取微信用户的信息 */} - - {modalMessageGrabElement} - - - - {adsImgElementsArray} - - - - {/* 第二行图片滚动条 */} - {/* - - - - {categoriesElementsArray1} - - - - - {categoriesElementsArray2} - - - - */} - - {/* 第三行图片滚动条 */} - - - - - - - - - - - {/* 业主需求和行业推荐 */} - - - - - 业主需求 - - - 更多>> - - - - - {demandingElemensArray} - - - - - {this.state.subCate.length ? 4.5 ? 4.5 : this.state.subCate.length} - > - {subCateElementsArray} - : null} - - - - 行业推荐 - - - - - - {shopCollectionElementsArray} - - - - {this.state.isShowTopNav ? : null} - - - - - - - - - - {/* */} - - {/* {this.state.isShopOwner ? : } */} - - ) - } -} - -export default Home diff --git a/src/util/checkLogin.js b/src/util/checkLogin.js new file mode 100644 index 0000000..3182a78 --- /dev/null +++ b/src/util/checkLogin.js @@ -0,0 +1,31 @@ +import { getGlobalStorage } from "./getSetStoage"; +import Taro from '@tarojs/taro' +// check if user login + +const isUserLogin = () => { + return new Promise((resolve,reject)=>{ + let isLogin = getGlobalStorage('userInfo') ? true : false + if (!isLogin) { + Taro.switchTab({ + url: '/pages/home/home' + }) + Taro.navigateTo({ + url: '/pages/login/login' + }) + + }else{ + resolve('继续') + } + }) + +} +const isUserShopOwner = () => { + let isShopOwner = getGlobalStorage('shopInfo') ? true : false + if (!isShopOwner) { + Taro.showToast({ + title: '您还没有店铺,不能使用该功能,快去申请吧', + icon: 'none' + }) + } +} +export { isUserLogin, isUserShopOwner } \ No newline at end of file diff --git a/src/util/getSetStoage.js b/src/util/getSetStoage.js index 79a657f..cd8353e 100644 --- a/src/util/getSetStoage.js +++ b/src/util/getSetStoage.js @@ -25,8 +25,12 @@ const getGlobalStorage = (key) => { let res = my.getStorageSync({ key: key, }) - res.data=res.data?res.data:{username:'',userphone:'',user_id:''} - return res.data ||res.APDataStorage + if (res.data||res.APDataStorage) { + return res.data||res.APDataStorage + } else { + return + } + } } export { setGlobalStorage, getGlobalStorage } \ No newline at end of file diff --git a/src/util/hideShowLoading.js b/src/util/hideShowLoading.js new file mode 100644 index 0000000..8b349ee --- /dev/null +++ b/src/util/hideShowLoading.js @@ -0,0 +1,24 @@ +import Taro from '@tarojs/taro' + + +const showLoading = ({ title='加载中'}) => { + if (process.env.TARO_ENV === 'weapp') { + Taro.showLoading({ + title: title + }) + + } else if (process.env.TARO_ENV === 'alipay') { + my.showLoading({ + content: title + }) + } +} +const hideLoading = () => { + if (process.env.TARO_ENV === 'weapp') { + Taro.hideLoading() + + } else if (process.env.TARO_ENV === 'alipay') { + my.hideLoading() + } +} +export { showLoading, hideLoading } \ No newline at end of file diff --git a/todo list.json b/todo list.json new file mode 100644 index 0000000..cdd7018 --- /dev/null +++ b/todo list.json @@ -0,0 +1,873 @@ +todo list: +首页: +商品发布页面: + +供求发布页面 +全部业主需求页面: +我的供求页面: +我的商品列表页面 + 商品编辑页面 + +我的需求列表页面: +接口问题: +优惠卷和询价 +bug: 商品编辑 增加图片后 图片顺序乱了 + + + + +等待后台--- 单个我的商品页面的图片顺序,单个我的需求页面的接口, 当个我哦的需求编辑页面的接口 + +import Taro, { Component } from '@tarojs/taro' +import { View, Radio, Button, MovableArea, MovableView } 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 URL from '../../serviceAPI.config' +import './myGoodList.scss' +import loginExpired from '../../util/loginExpired'; +import onClickValueService from '../../util/onClickValueService'; +import { getGlobalStorage } from '../../util/getSetStoage'; +import { showLoading } from '../../util/hideShowLoading'; + + +class MyGoodList extends Component { + config = { + navigationBarTitleText: '商品列表' + } + constructor() { + super(...arguments) + this.state = { + productName: '', + lowestPrice: '', + heightestPrice: '', + minimumSold: '', + maximumSold: '', + order: '',// 商品列表排序参数 + 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',// 后台的商品总数 + goodsStateParam: 1,//商品状态参数 + pageCountParam: 20,// 商品数量参数 + currPageParam: 1,// 当前页面 参数 + isCheckAll: false,// 是否checked + goodsIdList: [],//商品Id 列表 + isOpenDeleteModal: false,// 是否显示删除模态框 + isOpenOffStockModal: false,// 是否显示下架模态框 + isAddToList: false,// 是否下拉加载 如果是 就添加商品到我的商品列表 + isShowTopNav: false,// 是否显示返回顶部按钮 + screenWidth: '', + screenHeight: '' + } + } + + + 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=' + getGlobalStorage('session_id'), + 'content-type': 'application/x-www-form-urlencoded', + 'X-Requested-With': 'XMLHttpRequest' + } + }).then(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 }) + } else { + Taro.showToast({ + title: res.data.err_msg, + icon: 'none', + duration: 1500, + }) + } + }) + } + + // 获取我的商品列表接口api + getMyGoodListApi({ + goodsName = this.state.productName, + goodsSn = this.state.productId, + goodsClass = this.state.productCateSelected.id, + goodsPriceL = this.state.lowestPrice, + goodsPriceU = this.state.heightestPrice, + goodsSalesL = this.state.minimumSold, + goodsSalesU = this.state.maximumSold, + goodsState = this.state.goodsStateParam, + pageCount = this.state.pageCountParam, + currPage = this.state.currPageParam, + order = this.state.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, + goodsState: goodsState, + pageCount: pageCount, + currPage: currPage, + order: order + }, + header: { + 'Cookie': 'PFWSSS=' + getGlobalStorage('session_id'), + 'content-type': 'application/x-www-form-urlencoded', + 'X-Requested-With': 'XMLHttpRequest' + } + }).then(res => { + const data = JSON.parse(res.data) + if (data.err_code === 88888) { + loginExpired(data) + } else if (data.err_code != 10) { + console.log('我的商品列表', JSON.parse(res.data)) + + 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 }) + }) + } else { + this.setState({ + myGoodList: data.goods, + myGoodListTotal: data.goodsCount + }) + } + } else { + if (data.goods === null) { + this.setState({ + myGoodList: [], + myGoodListTotal: data.goodsCount + }) + } else { + this.setState({ isAddToList: false }) + Taro.showToast({ + title: '没有更多了', + icon: 'none' + }) + } + } + } else { + Taro.showToast({ + title: data.err_msg, + icon: 'none' + }) + } + }) + + } + // 获取搜索结果api + // getMyGoodListApi({ + // 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=' + getGlobalStorage('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({ + // myGoodList: data.goods, + // myGoodListTotal: goodCount + // }) + // 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=' + getGlobalStorage('session_id'), + 'content-type': 'application/x-www-form-urlencoded', + 'X-Requested-With': 'XMLHttpRequest' + } + }).then(res => { + let responseData = JSON.parse(res.data) + Taro.hideLoading() + if (responseData.err_code === 0) { + this.setState({ + isCheckAll: false, + currPageParam: 1, + + }, () => { + this.getMyGoodListApi({}) + Taro.showToast({ + title: '下架成功', + icon: 'success', + duration: 1500 + }) + }) + } else if (responseData.err_code === 88888) { + loginExpired(res) + } else { + Taro.showToast({ + title: responseData.err_msg, + 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=' + getGlobalStorage('session_id'), + 'content-type': 'application/x-www-form-urlencoded', + 'X-Requested-With': 'XMLHttpRequest' + } + }).then(res => { + let responseData = JSON.parse(res.data) + Taro.hideLoading() + if (responseData.err_code === 0) { + Taro.showToast({ + title: '删除成功', + icon: 'success', + duration: 1500 + }).then(() => { + this.setState({ isCheckAll: false, currPageParam: 1 }, () => { + this.getMyGoodListApi({}) + }) + + }) + } else if (responseData.err_code === 88888) { + loginExpired(res) + } else { + Taro.showToast({ + title: responseData.err_msg, + icon: 'none', + duration: 1500 + }) + this.setState({ isCheckAll: false }) + } + + + + }) + + } + + + + + // 搜索 + searchButtonHandler() { + showLoading({ + title: '加载中', + }) + this.setState({ currPageParam: 1, isCheckAll: false, order: '' }, () => { + this.getMyGoodListApi({}) + }) + } + + + // 清空搜索 + emptyButtonHanlder() { + this.setState({ + isCheckAll: false, + currPageParam: 1, + productName: '', + lowestPrice: '', + heightestPrice: '', + minimumSold: '', + maximumSold: '', + productId: '', + productCateSelected: { id: '', name: '全部类目' }, + order: '', + }, () => { + this.getMyGoodListApi({}) + Taro.showToast({ + title: '已清空', + icon: 'success', + duration: 1000 + }) + }) + + } + // 产品排序 + accendingDescending(e) { + showLoading({ + title: '加载中' + }) + const value = onClickValueService(e) + this.setState({ selectedFilterValue: value }) + if (value == 0) { + this.setState({ + currPageParam: 1, + filterOptions: { + filterPrice: !this.state.filterOptions.filterPrice, + filterStock: false, + filterSold: false, + filterPublishDate: false, + } + }, () => { + this.state.filterOptions.filterPrice ? this.setState({ order: "goods_price" }, () => { + this.getMyGoodListApi({}) + }) : this.setState({ order: "goods_price desc" }, () => { + this.getMyGoodListApi({}) + }) + + + }) + } + if (value == 1) { + this.setState({ + currPageParam: 1, + filterOptions: { + filterPrice: false, + filterStock: !this.state.filterOptions.filterStock, + filterSold: false, + filterPublishDate: false, + } + }, () => { + this.state.filterOptions.filterStock ? this.setState({ order: "goods_stock" }, () => { + this.getMyGoodListApi({}) + }) : this.setState({ order: "goods_stock desc" }, () => { + this.getMyGoodListApi({}) + }) + } + ) + } + if (value == 2) { + this.setState({ + currPageParam: 1, + filterOptions: { + filterPrice: false, + filterStock: false, + filterSold: !this.state.filterOptions.filterSold, + filterPublishDate: false, + + } + }, () => { + this.state.filterOptions.filterSold ? this.setState({ order: "sales_volume " }, () => { + this.getMyGoodListApi({}) + }) : this.setState({ order: "sales_volume desc" }, () => { + this.getMyGoodListApi({}) + }) + } + + ) + } + if (value == 3) { + this.setState({ + currPageParam: 1, + filterOptions: { + filterPrice: false, + filterStock: false, + filterSold: false, + filterPublishDate: !this.state.filterOptions.filterPublishDate, + + } + }, () => { + this.state.filterOptions.filterPublishDate ? this.setState({ order: "update_date desc" }, () => { + this.getMyGoodListApi({}) + }) : this.setState({ order: "update_date" }, () => { + this.getMyGoodListApi({}) + }) + } + ) + } + } + + + // 商品全部选择 + 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(() => { + + }) + + } + } + + + // 单个商品选择 + handleCheckChange(e) { + //如果goodid 一样的那么checked 就取反 + console.log('clicke') + const id = onClickValueService(e) + 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 }) + + + + } + // 改变商品状态 + 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(e) { + console.log('e', e) + const goodId = onClickValueService(e) + console.log('goodId', goodId) + Taro.navigateTo({ + url: '/pages/myGoodsEdit/myGoodsEdit?id=' + goodId + }) + } + // 导航到商品发布页面 + + goToGoodsPublishPage() { + Taro.navigateTo({ + url: '/pages/goodsPublish/goodsPublish' + }) + } + goToGoodspage(e) { + const goodId = onClickValueService(e) + 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) + } + }); + showLoading({ + title: '加载中' + }) + 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) + } + }); + showLoading({ + title: '加载中' + }) + this.changeGoodState({ goodsID: checkedGoodsId }) + } + offStockModalClose() { + this.setState({ + isOpenOffStockModal: false + }) + } + goToCenterPage() { + Taro.switchTab({ + url: '/pages/individualCenter/individualCenter' + }) + } + getUserSystemInfo() { + Taro.getSystemInfo().then(res => { + return res + }).then(res => { + this.setState({ + screenWidth: res.screenWidth - 80 + 'px', + screenHeight: res.screenHeight - 200 + 'px' + }) + }) + + } + + componentDidMount() { + this.getUserSystemInfo() + 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() { + showLoading({ + title: '加载中' + }) + this.setState({ isAddToList: true, currPageParam: this.state.currPageParam + 1 }, () => { + this.getMyGoodListApi({}) + }) + + + } + + 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} + + + + 全选 + + + + + + + + + {this.state.myGoodList.length ? + + {goodListElementArray} + : 没有更多了} + {this.state.isShowTopNav ? : null} + + + + + + + + + 个人中心 + + + ) + } +} + +export default MyGoodList