diff --git a/src/app.js b/src/app.js index c0bcb21..87baeb9 100644 --- a/src/app.js +++ b/src/app.js @@ -16,11 +16,11 @@ import './app.scss' const store = configStore() class App extends Component { - - isTrue=Taro.getStorageSync('session_id')?true:false + config = { pages: [ //'pages/index/index', // index页面 + 'pages/individualCenter/individualCenter',// 个人中心页面 'pages/home/home',//首页 --------------------- 'pages/login/login',//登入页面 --------------------- 'pages/shop/shop',//店铺页面 --------------------- @@ -39,6 +39,8 @@ class App extends Component { 'pages/myNeedsEdit/myNeedsEdit',// 单个需求编辑页面 'pages/myNeedsPublish/myNeedsPublish',// 需求发布 + + // 'pages/shopDescription/shopDescription', ], permission: { @@ -56,33 +58,27 @@ class App extends Component { }, tabBar: { - list:[{ + list: [{ pagePath: "pages/home/home", text: "首页", iconPath: "./icons/home.png", selectedIconPath: "./icons/home-actived.png" }, { - pagePath: "pages/goodsPublish/goodsPublish", - text: "商品发布", - iconPath: "./icons/box.png", - selectedIconPath: "./icons/box-actived.png" - }, { - pagePath: "pages/supplyDemandPublish/supplyDemandPublish", - text: "供求发布", + pagePath: "pages/myNeedsPublish/myNeedsPublish", + text: "需求发布", iconPath: "./icons/publish.png", selectedIconPath: "./icons/publish-actived.png" - } - , { - pagePath: "pages/mySupplyDemand/mySupplyDemand", - text: "我的供求", - iconPath: "./icons/menu.png", - selectedIconPath: "./icons/menu-actived.png" } , { pagePath: "pages/myNeeds/myNeeds", text: "我的需求", iconPath: "./icons/needs.png", selectedIconPath: "./icons/needs-actived.png" + }, { + pagePath: "pages/individualCenter/individualCenter", + text: "个人中心", + iconPath: "./icons/needs.png", + selectedIconPath: "./icons/needs-actived.png" } ], color: '#333', @@ -94,7 +90,7 @@ class App extends Component { } componentDidMount() { - console.log('this.tabBar', this) + } componentDidShow() { } diff --git a/src/component/backToCenterComponent/backToCenterComponent.js b/src/component/backToCenterComponent/backToCenterComponent.js new file mode 100644 index 0000000..345ff27 --- /dev/null +++ b/src/component/backToCenterComponent/backToCenterComponent.js @@ -0,0 +1,53 @@ +//scrollToTopComponent +import Taro, { Component } from '@tarojs/taro' +import { View, Text,MovableArea, MovableView } from '@tarojs/components' + + +import './backToCenterComponent.scss' + + + + +class BackToCenterComponent extends Component { + config = { + navigationBarTitleText: '顶部' + } + + + goToCenterPage(){ + Taro.switchTab({ + url:'/pages/individualCenter/individualCenter' + }) + } + + componentDidMount() { + + } + componentWillReceiveProps(nextProps) { + // console.log(this.props, nextProps) + } + + componentWillUnmount() { } + + componentDidShow() { } + + componentDidHide() { } + + render() { + return ( + // + // + // 个人中心 + + // + + // + + hello world + + + ) + } +} + +export default BackToCenterComponent diff --git a/src/component/backToCenterComponent/backToCenterComponent.scss b/src/component/backToCenterComponent/backToCenterComponent.scss new file mode 100644 index 0000000..bd79283 --- /dev/null +++ b/src/component/backToCenterComponent/backToCenterComponent.scss @@ -0,0 +1,17 @@ +.backToCenterComponent{ + height:100rpx; + width:100rpx; + color:#ffffff; + background-color:black; + opacity: 0.3; + border-radius:50%; + position:fixed; + bottom:12%; + right:3%; + font-size:25rpx; + display: flex; + align-items: center; + justify-content: center + + +} \ No newline at end of file diff --git a/src/component/interactionComponent/interactionComponent.js b/src/component/interactionComponent/interactionComponent.js index 8077912..b4b53a7 100644 --- a/src/component/interactionComponent/interactionComponent.js +++ b/src/component/interactionComponent/interactionComponent.js @@ -45,7 +45,7 @@ class Interaction extends Component { let initailMultiArray = this.recursionInitialized(res.data.data) initailMultiArray[1].unshift({ name: '全部', id: '-1' }) initailMultiArray[0] = [{ name: '--', id: '' }] - console.log('initailMultiArray', initailMultiArray) + // console.log('initailMultiArray', initailMultiArray) this.setState({ @@ -112,7 +112,7 @@ class Interaction extends Component { return new Array(maxDepth).fill(0) } bindMultiPickerCol(e) { - console.log('修改的列为', e.detail.column, ',值为', e.detail.value) + // console.log('修改的列为', e.detail.column, ',值为', e.detail.value) const data = { multiArray: this.state.initailMultiArray, @@ -124,7 +124,7 @@ class Interaction extends Component { const indexNumber = Number(index) if (indexNumber === data.multiIndex[0]) { data.multiArray[1] = this.state.interactionMultiArray[indexNumber].children - console.log('datat', data) + } } } diff --git a/src/component/scrollToTopComponent/scrollToTopComponent.scss b/src/component/scrollToTopComponent/scrollToTopComponent.scss index c7ae4d0..675267e 100644 --- a/src/component/scrollToTopComponent/scrollToTopComponent.scss +++ b/src/component/scrollToTopComponent/scrollToTopComponent.scss @@ -6,8 +6,8 @@ border-radius:50%; text-align:center; position:fixed; - bottom:10%; - right:5%; + bottom:1%; + right:3%; font-size:25rpx; .box{ margin-top:6%; diff --git a/src/icons/client-needs-actived.png b/src/icons/client-needs-actived.png new file mode 100644 index 0000000..5b92fc3 Binary files /dev/null and b/src/icons/client-needs-actived.png differ diff --git a/src/icons/client-needs.png b/src/icons/client-needs.png new file mode 100644 index 0000000..44df01d Binary files /dev/null and b/src/icons/client-needs.png differ diff --git a/src/icons/client-publish-actived.png b/src/icons/client-publish-actived.png new file mode 100644 index 0000000..4b6d512 Binary files /dev/null and b/src/icons/client-publish-actived.png differ diff --git a/src/icons/client-publish.png b/src/icons/client-publish.png new file mode 100644 index 0000000..47a9749 Binary files /dev/null and b/src/icons/client-publish.png differ diff --git a/src/icons/individualCenter-actived.png b/src/icons/individualCenter-actived.png new file mode 100644 index 0000000..fd93d86 Binary files /dev/null and b/src/icons/individualCenter-actived.png differ diff --git a/src/icons/individualCenter.png b/src/icons/individualCenter.png new file mode 100644 index 0000000..f7d1e77 Binary files /dev/null and b/src/icons/individualCenter.png differ diff --git a/src/pages/goodsPublish/goodsPublish.js b/src/pages/goodsPublish/goodsPublish.js index aaaa74d..f552819 100644 --- a/src/pages/goodsPublish/goodsPublish.js +++ b/src/pages/goodsPublish/goodsPublish.js @@ -106,12 +106,12 @@ class GoodsPublish extends Component { setTimeout(() => { if (this.state.isPublish) { // 导航到编辑页面 - Taro.navigateTo({ - url: '/pages/myGoodsEdit/myGoodsEdit?id=' + res.data.goods_id + Taro.redirectTo({ + url: '/pages/myGoodsList/myGoodsList' }) } else if (this.state.isPublishAndAdd) { // 导航到发布页面 - Taro.reLaunch({ + Taro.navigateTo({ url: '/pages/goodsPublish/goodsPublish' }) } @@ -269,7 +269,7 @@ class GoodsPublish extends Component { LoginService() return } - Taro.navigateTo({ + Taro.redirectTo({ url: '/pages/myGoodList/myGoodList' }) } @@ -403,9 +403,9 @@ class GoodsPublish extends Component { {/* */} - + {/* - + */} diff --git a/src/pages/grabOrderPage/grabOrderPage.js b/src/pages/grabOrderPage/grabOrderPage.js index 04bed15..444da30 100644 --- a/src/pages/grabOrderPage/grabOrderPage.js +++ b/src/pages/grabOrderPage/grabOrderPage.js @@ -76,7 +76,7 @@ class GrabOrderPage extends Component { icon: 'none' }) setTimeout(() => { - Taro.reLaunch({ + Taro.switchTab({ url: '/pages/home/home' }) }, 1500); @@ -218,7 +218,7 @@ class GrabOrderPage extends Component { duration: 1500 }) setTimeout(() => { - Taro.reLaunch({ + Taro.switchTab({ url: '/pages/myNeeds/myNeeds' }) }, 1500); diff --git a/src/pages/home/home.js b/src/pages/home/home.js index 57c8434..fdd569d 100644 --- a/src/pages/home/home.js +++ b/src/pages/home/home.js @@ -42,7 +42,6 @@ class Home extends Component { supplyLevel: 1,// 筛选1是小类或者2是大类, latitude: '', longitude: '', - isShopOwner: false } } @@ -290,22 +289,7 @@ class Home extends Component { componentDidMount() { // 页面加载后 得到首页的基本信息和推荐店铺的信息 - // Taro.setTabBarItem({ - // index: 2, - // text: 'client', - // iconPath: './icons/needs-actived.png', - // selectedIconPath: './icon/needs.png', - // success: function (res) { - // console.log('indexBarSuccess3', res) - // }, - // fail: function (res) { - // console.log('indexBarFail3', res) - // }, - // complete: function (res) { - // console.log('indexBarComplete3', res) - // } - // }) Taro.showLoading({ title: '加载中' }) // promise 返回经纬度给state 然后调用函数 this.getUserLocation().then(res => { @@ -321,25 +305,11 @@ class Home extends Component { this.getHomeCategoriesInfo() }) // 本地缓存没有userid时 从新登入 - if (!Taro.getStorageSync('userInfo').user_id) { - weChatLogin().then(res => { - Taro.getStorageSync('shopInfo').shop_id ? this.setState({ - isShopOwner: true - }) : this.setState({ - isShopOwner: false - }) + Taro.getStorageSync('userInfo').user_id ? true : weChatLogin() + - }).catch(err => { - }) - } else { - Taro.getStorageSync('shopInfo').shop_id ? this.setState({ - isShopOwner: true - }) : this.setState({ - isShopOwner: false - }) - } } componentWillMount() { @@ -348,7 +318,7 @@ class Home extends Component { componentWillUnmount() { } componentDidShow() { - console.log('home', this.$scope.route) + } componentDidHide() { } @@ -379,7 +349,6 @@ class Home extends Component { } render() { - console.log('this.state.isShopOwner', this.state.isShopOwner) // 提示模态弹窗element const modalMessageGrabElement = 提示 @@ -456,7 +425,7 @@ class Home extends Component { {item.class_name} }) : null - + return ( diff --git a/src/pages/individualCenter/individualCenter.js b/src/pages/individualCenter/individualCenter.js new file mode 100644 index 0000000..1a5d7af --- /dev/null +++ b/src/pages/individualCenter/individualCenter.js @@ -0,0 +1,170 @@ +import Taro, { Component } from '@tarojs/taro' +import { View, Image, Button } from '@tarojs/components' +import { AtGrid, AtList, AtListItem, AtAvatar, AtButton } from "taro-ui" + + +import './individualCenter.scss' +import URL from '../../serviceAPI.config' + + + + +class IndividualCenter extends Component { + config = { + navigationBarTitleText: '个人中心' + } + constructor() { + this.state = { + client: [ + { + image: 'https://img12.360buyimg.com/jdphoto/s72x72_jfs/t6160/14/2008729947/2754/7d512a86/595c3aeeNa89ddf71.png', + value: '需求发布' + }, + { + image: 'https://img20.360buyimg.com/jdphoto/s72x72_jfs/t15151/308/1012305375/2300/536ee6ef/5a411466N040a074b.png', + value: '我的需求' + } + + ], + seller: [ + { + image: 'https://img12.360buyimg.com/jdphoto/s72x72_jfs/t6160/14/2008729947/2754/7d512a86/595c3aeeNa89ddf71.png', + value: '我的商品' + }, + { + image: 'https://img20.360buyimg.com/jdphoto/s72x72_jfs/t15151/308/1012305375/2300/536ee6ef/5a411466N040a074b.png', + value: '商品发布' + }, + { + image: 'https://img10.360buyimg.com/jdphoto/s72x72_jfs/t5872/209/5240187906/2872/8fa98cd/595c3b2aN4155b931.png', + value: '我的供求' + }, + { + image: 'https://img12.360buyimg.com/jdphoto/s72x72_jfs/t10660/330/203667368/1672/801735d7/59c85643N31e68303.png', + value: '供求发布' + } + ], + username: '', + avatar: '', + isShop: false, + } + } + handlerGridClick(e) { + const value = e.currentTarget.dataset.eTapAA.value + switch (value) { + case '需求发布': + Taro.switchTab({ + url: '/pages/myNeedsPublish/myNeedsPublish' + }) + break; + case '我的需求': + Taro.switchTab({ + url: '/pages/myNeeds/myNeeds' + }) + break; + case '我的商品': + Taro.navigateTo({ + url: '/pages/myGoodList/myGoodList' + }) + break; + case '商品发布': + Taro.navigateTo({ + url: '/pages/goodsPublish/goodsPublish' + }) + break; + case '我的供求': + Taro.navigateTo({ + url: '/pages/mySupplyDemand/mySupplyDemand' + }) + break; + case '供求发布': + Taro.navigateTo({ + url: '/pages/supplyDemandPublish/supplyDemandPublish' + }) + break; + + default: + // code block + } + } + handlerTitleBarClick() { + Taro.showToast({ + title: '暂时没有更多', + icon: 'none' + }) + } + getInfoFromStorage() { + const username = Taro.getStorageSync('userInfo').login_name + const avatar = Taro.getStorageSync('userInfo').avatar + const isShop = Taro.getStorageSync('shopInfo').shop_id ? true : false + this.setState({ + username, avatar, isShop + }) + } + handleLogoutClick() { + Taro.clearStorageSync() + Taro.reLaunch({ + url: '/pages/login/login' + }) + + } + componentDidMount() { + this.getInfoFromStorage() + } + componentWillReceiveProps(nextProps) { + console.log(this.props, nextProps) + } + + componentWillUnmount() { } + + componentDidShow() { } + + componentDidHide() { } + + render() { + const { client, seller, username, avatar, isShop } = this.state + return ( + + + + + + {username} + ???? + + + + + + + + 收藏的宝贝| + 收藏的店铺| + 我的足迹 + + + + + + + + {isShop ? + + + + + : } + + {/* 退出 */} + + + + ) + } +} + +export default IndividualCenter diff --git a/src/pages/individualCenter/individualCenter.scss b/src/pages/individualCenter/individualCenter.scss new file mode 100644 index 0000000..9d71c60 --- /dev/null +++ b/src/pages/individualCenter/individualCenter.scss @@ -0,0 +1,40 @@ +.individualCenter{ + position: relative; + .avatar{ + position: absolute; + top:190rpx; + left: 50rpx; + display: flex; + .user-name{ + display: flex; + font-size: 25rpx; + color: #FFFFFF; + .name{ + margin-left: 15rpx + } + .badge{ + margin-left: 15rpx + } + } + } + .row{ + height: 80rpx; + font-size: 26rpx; + display: flex; + align-items: center; + justify-content:flex-end; + .title{ + margin-left:10rpx; + margin-right:10rpx; + + } + } + .logout{ + width:30%; + margin:0 auto; + margin-top: 10% + } + .seller-container{ + + } +} \ No newline at end of file diff --git a/src/pages/myDemandSupplyEdit/myDemandSupplyEdit.js b/src/pages/myDemandSupplyEdit/myDemandSupplyEdit.js index 4fec13b..5a91871 100644 --- a/src/pages/myDemandSupplyEdit/myDemandSupplyEdit.js +++ b/src/pages/myDemandSupplyEdit/myDemandSupplyEdit.js @@ -31,7 +31,6 @@ class MyDemandSupplyEdit extends Component { content: '', pickerImageUrl: [], // 上传的图片 ImagesInfo: [],// 后台传回来的图片信息 - isFormCompleted: false, isConfirmWindow: false,// 删除提示框 demandSupplyId: '',// 供求id @@ -57,6 +56,7 @@ class MyDemandSupplyEdit extends Component { }) .then(res => { console.log('供求详情获取成功', res) + Taro.hideLoading() if (res.data.err_code === 0) { const selectedType = this.state.demandingSupplyCate.filter(item => item.id == res.data.sdInfo.sd_type)[0] const selectedState = this.state.demandingSupplyState.filter(item => item.id == res.data.sdInfo.state)[0] @@ -73,9 +73,14 @@ class MyDemandSupplyEdit extends Component { pickerImageUrl: imageFile, ImagesInfo: res.data.sdInfo.file_path, }) - Taro.hideLoading() + } else if (res.data.err_code === 88888) { loginExpired(res) + }else{ + Taro.showToast({ + title:res.data.err_msg, + icon:'none' + }) } }) @@ -137,7 +142,7 @@ class MyDemandSupplyEdit extends Component { setTimeout(() => { console.log('this.state.isSaveAndNew', this.state.isSaveAndNew) if (this.state.isSaveAndNew) { - Taro.reLaunch({ + Taro.navigateTo({ url: '/pages/supplyDemandPublish/supplyDemandPublish' }) } else { @@ -309,8 +314,8 @@ class MyDemandSupplyEdit extends Component { } } goToMyDemSupPage() { - Taro.switchTab({ - url: '/pages/mySupplyDemand/mySupplyDemand' + Taro.navigateBack({ + delta: 1 }) } deleteButtonHandler() { diff --git a/src/pages/myGoodList/myGoodList.js b/src/pages/myGoodList/myGoodList.js index 1161a7e..6b2c978 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 } from '@tarojs/components' +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' @@ -47,6 +47,8 @@ class MyGoodList extends Component { isOpenOffStockModal: false,// 是否显示下架模态框 isAddToList: false,// 是否下拉加载 如果是 就添加商品到我的商品列表 isShowTopNav: false,// 是否显示返回顶部按钮 + screenWidth:'', + screenHeight:'' } } @@ -87,7 +89,7 @@ class MyGoodList extends Component { 'X-Requested-With': 'XMLHttpRequest' } }).then(res => { - console.log('宝贝类目',res) + console.log('宝贝类目', res) if (res.data.err_code != 10) { const productCate = [{ name: '全部类目', id: '' }] for (let item of res.data.goodsClass) { @@ -144,7 +146,7 @@ class MyGoodList extends Component { const data = JSON.parse(res.data) if (data.err_code != 10) { console.log('我的商品列表', JSON.parse(res.data)) - + Taro.hideLoading() if (data.goodsCount != '0' && data.goods.length) { data.goods.forEach(item => { @@ -272,9 +274,9 @@ class MyGoodList extends Component { duration: 1500 }) }) - }else if (responseData.err_code === 88888) { + } else if (responseData.err_code === 88888) { loginExpired(res) - } else { + } else { Taro.showToast({ title: responseData.err_msg, icon: 'none', @@ -311,14 +313,14 @@ class MyGoodList extends Component { icon: 'success', duration: 1500 }).then(() => { - this.setState({ isCheckAll: false, currPageParam: 1 },()=>{ + this.setState({ isCheckAll: false, currPageParam: 1 }, () => { this.getMyGoodListApi({}) }) - + }) - }else if (responseData.err_code === 88888) { + } else if (responseData.err_code === 88888) { loginExpired(res) - } else { + } else { Taro.showToast({ title: responseData.err_msg, icon: 'none', @@ -526,7 +528,8 @@ class MyGoodList extends Component { }) } // 导航到商品编辑页面myGoodsEdit - goToGoodEditPage(goodId) { + goToGoodEditPage(e) { + const goodId = e.currentTarget.dataset.eTapAA Taro.navigateTo({ url: '/pages/myGoodsEdit/myGoodsEdit?id=' + goodId }) @@ -534,11 +537,12 @@ class MyGoodList extends Component { // 导航到商品发布页面 goToGoodsPublishPage() { - Taro.switchTab({ + Taro.navigateTo({ url: '/pages/goodsPublish/goodsPublish' }) } - goToGoodspage(goodId) { + goToGoodspage(e) { + const goodId = e.currentTarget.dataset.eTapAA Taro.navigateTo({ url: '/pages/goods/goods?id=' + goodId }) @@ -579,8 +583,26 @@ class MyGoodList extends Component { isOpenOffStockModal: false }) } + goToCenterPage() { + Taro.switchTab({ + url: '/pages/individualCenter/individualCenter' + }) + } + getUserSystemInfo(){ + Taro.getSystemInfo().then(res=>{ + return res + }).then(res=>{ + console.log('res',res) + this.setState({ + screenWidth:res.screenWidth-80+'px', + screenHeight:res.screenHeight-200+'px' + }) + }) + + } componentDidMount() { + this.getUserSystemInfo() Taro.showLoading({ title: '加载中' }) @@ -594,7 +616,7 @@ class MyGoodList extends Component { componentWillUnmount() { } componentDidShow() { - + } componentDidHide() { } @@ -619,8 +641,6 @@ class MyGoodList extends Component { } render() { - - //等待接口数据 const goodListElementArray = this.state.myGoodList.map((item, index) => { return @@ -671,135 +691,141 @@ class MyGoodList extends Component { return ( - - {/* 删除模态提示框 */} - {modalMessageDeleteElement} - {/* 下架模态框提示 */} - {modalMessageOffStockElement} + + + {/* 删除模态提示框 */} + {modalMessageDeleteElement} + {/* 下架模态框提示 */} + {modalMessageOffStockElement} - - - - - + + + + - - - - - - + type='number' + value={this.state.lowestPrice} + onChange={this.lowestPriceChange.bind(this)} + border={false} + /> + + + + + + - - - - - - - - 宝贝类目: + + + + + + + + 宝贝类目: + + {this.state.productCateSelected.name} + - {this.state.productCateSelected.name} - + + + + + - - - - - - - - - - - - - - - 出售中的宝贝{this.state.myGoodListTotal}条记录 - - - - {filterElementsArray} - - - - 全选 - - + + - - + + + + 出售中的宝贝{this.state.myGoodListTotal}条记录 + + + + {filterElementsArray} + + + + 全选 + + + + + + + + + {this.state.myGoodList.length ? + {goodListElementArray} + : 没有更多了} + {this.state.isShowTopNav ? : null} + + + + + + + 个人中心 + - {this.state.myGoodList.length ? - {goodListElementArray} - : 没有更多了} - {this.state.isShowTopNav ? : null} - - - - - + ) } } diff --git a/src/pages/myGoodList/myGoodList.scss b/src/pages/myGoodList/myGoodList.scss index b425041..2cdd250 100644 --- a/src/pages/myGoodList/myGoodList.scss +++ b/src/pages/myGoodList/myGoodList.scss @@ -2,6 +2,21 @@ $themeColor:#FF7142; .button-orange, .button-dark-red,.button-green{ font-size:28rpx; } +.movable-point{ + height:130rpx; + width:130rpx; + color:#ffffff; + background-color:black; + opacity: 0.3; + border-radius:50%; + position:fixed; + display: flex; + align-items: center; + justify-content:center; + font-size:25rpx; + opacity:1 ; + position:fixed; +} .MyGoodList{ padding: 10px 20px; .filterbar-container{ diff --git a/src/pages/myGoodsEdit/myGoodsEdit.js b/src/pages/myGoodsEdit/myGoodsEdit.js index 0fb7823..e91053d 100644 --- a/src/pages/myGoodsEdit/myGoodsEdit.js +++ b/src/pages/myGoodsEdit/myGoodsEdit.js @@ -70,7 +70,7 @@ class MyGoodsEdit extends Component { for (let key in shopTypeObject) { for (let item of shopTypeObject[key].c) { if (item.id === res.data.goods.shop_class_id) { - selectedValue = {name:item.n,id:item.id} + selectedValue = { name: item.n, id: item.id } } } } @@ -91,6 +91,12 @@ class MyGoodsEdit extends Component { } else if (res.data.err_code === 88888) { loginExpired(res) } + else { + Taro.showToast({ + title: res.data.err_msg, + icon: 'none', + }) + } } ) @@ -166,9 +172,10 @@ class MyGoodsEdit extends Component { }).then(() => { setTimeout(() => { if (this.state.isSaveButton) { - // Taro.redirectTo({ - // url: '/pages/myGoodsEdit/myGoodsEdit?id=' + this.$router.params.id - // }) + Taro.navigateBack({ + delta:1 + // url: '/pages/myGoodsList/myGoodsEdit?id=' + this.$router.params.id + }) } else if (this.state.isSaveAndNewBUtton) { Taro.switchTab({ url: '/pages/goodsPublish/goodsPublish' @@ -455,9 +462,9 @@ class MyGoodsEdit extends Component { {/* */} - + {/* - + */} diff --git a/src/pages/myNeedsEdit/myNeedsEdit.js b/src/pages/myNeedsEdit/myNeedsEdit.js index 5d8ea04..1b9b17a 100644 --- a/src/pages/myNeedsEdit/myNeedsEdit.js +++ b/src/pages/myNeedsEdit/myNeedsEdit.js @@ -265,7 +265,7 @@ class MyNeedsEdit extends Component { duration: 1000 }) setTimeout(() => { - Taro.reLaunch({ + Taro.switchTab({ url: '/pages/myNeeds/myNeeds' }) @@ -311,7 +311,7 @@ class MyNeedsEdit extends Component { this.setState({ content: event.target.value }) } goToMyNeedsPage() { - Taro.reLaunch({ + Taro.switchTab({ url: '/pages/myNeeds/myNeeds' }) } diff --git a/src/pages/myNeedsPublish/myNeedsPublish.js b/src/pages/myNeedsPublish/myNeedsPublish.js index 1a7b00e..3651e27 100644 --- a/src/pages/myNeedsPublish/myNeedsPublish.js +++ b/src/pages/myNeedsPublish/myNeedsPublish.js @@ -239,7 +239,7 @@ class MyNeedsPublish extends Component { } goToMyNeedsPage() { - Taro.reLaunch({ + Taro.switchTab({ url: '/pages/myNeeds/myNeeds' }) } diff --git a/src/pages/mySupplyDemand/mySupplyDemand.js b/src/pages/mySupplyDemand/mySupplyDemand.js index 775d087..efaa0eb 100644 --- a/src/pages/mySupplyDemand/mySupplyDemand.js +++ b/src/pages/mySupplyDemand/mySupplyDemand.js @@ -111,6 +111,7 @@ class MySupplyDemand extends Component { } onSearchButtonHandler() { + Taro.showLoading({ title: '加载中' }) this.setState({ loadMorePageIndex: 1 }, () => { @@ -160,7 +161,7 @@ class MySupplyDemand extends Component { // 新增我的供求 addDemandSupply() { - Taro.reLaunch({ + Taro.navigateTo({ url: '/pages/supplyDemandPublish/supplyDemandPublish' }) } @@ -234,14 +235,16 @@ class MySupplyDemand extends Component { // 编辑我的供求 // 跳转到我的供求编辑页面 - goToMyDSEditPage(sdId) { + goToMyDSEditPage(e) { + const sdId=e.currentTarget.dataset.eTapAA Taro.navigateTo({ url: '/pages/myDemandSupplyEdit/myDemandSupplyEdit?sdId=' + sdId }) } // 转到供求查看页面 - goSupplyDemandView(sdId) { + goSupplyDemandView(e) { + const sdId=e.currentTarget.dataset.eTapAA Taro.navigateTo({ url: '/pages/supplyDemandView/supplyDemandView?sdId=' + sdId }) diff --git a/src/pages/supplyDemandPublish/supplyDemandPublish.js b/src/pages/supplyDemandPublish/supplyDemandPublish.js index bb1283d..0f6faee 100644 --- a/src/pages/supplyDemandPublish/supplyDemandPublish.js +++ b/src/pages/supplyDemandPublish/supplyDemandPublish.js @@ -84,12 +84,12 @@ class SupplyDemand extends Component { console.log('this.state.isPublishAndNew', this.state.isPublishAndNew) setTimeout(() => { if (this.state.isPublishAndNew) { - Taro.reLaunch({ + Taro.navigateTo({ url: '/pages/supplyDemandPublish/supplyDemandPublish' }) } else { - Taro.navigateTo({ - url: '/pages/myDemandSupplyEdit/myDemandSupplyEdit?sdId=' + res.data.sd_id + Taro.redirectTo({ + url: '/pages/mySupplyDemand/mySupplyDemand' }) } }, 1000); @@ -240,7 +240,7 @@ class SupplyDemand extends Component { LoginService() return } - Taro.switchTab({ + Taro.navigateTo({ url: '/pages/mySupplyDemand/mySupplyDemand' }) } @@ -383,9 +383,9 @@ class SupplyDemand extends Component { - + {/* - + */} diff --git a/src/pages/supplyDemandView/supplyDemandView.js b/src/pages/supplyDemandView/supplyDemandView.js index d535937..09b011d 100644 --- a/src/pages/supplyDemandView/supplyDemandView.js +++ b/src/pages/supplyDemandView/supplyDemandView.js @@ -49,6 +49,7 @@ class SupplyDemandView extends Component { }) .then(res => { console.log('供求详情获取成功', res) + Taro.hideLoading() if (res.data.err_code === 0) { const selectedType = this.state.demandingSupplyCate.filter(item => item.id === res.data.sdInfo.sd_type)[0].name this.setState({ @@ -62,10 +63,15 @@ class SupplyDemandView extends Component { images: res.data.sdInfo.file_path, itemId: res.data.sdInfo.sd_id }) - Taro.hideLoading() + } else if (res.data.err_code === 88888) { loginExpired(res) - } + }else{ + Taro.showToast({ + title:res.data.err_msg, + icon:'none' + }) + } } ) @@ -115,7 +121,7 @@ class SupplyDemandView extends Component { } goToSDPublishPage() { - Taro.reLaunch({ + Taro.navigateTo({ url: '/pages/supplyDemandPublish/supplyDemandPublish',// 供求发布页面 }) } @@ -127,7 +133,7 @@ class SupplyDemandView extends Component { } goToMySDPage() { - Taro.reLaunch({ + Taro.navigateBack({ url: '/pages/mySupplyDemand/mySupplyDemand',//我的供求页面 }) } diff --git a/src/todo list.txt b/src/todo list.txt index 4006aff..8307de8 100644 --- a/src/todo list.txt +++ b/src/todo list.txt @@ -18,552 +18,136 @@ bug: 商品编辑 增加图片后 图片顺序乱了 等待后台--- 单个我的商品页面的图片顺序,单个我的需求页面的接口, 当个我哦的需求编辑页面的接口 +import '@tarojs/async-await' 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 FilteredShopComponent from '../../component/filteredShopComponent/filteredShopComponent' -import ScrollToTopComponent from '../../component/scrollToTopComponent/scrollToTopComponent' -import CopyrightComponent from '../../component/copyrightComponent/copyrightComponent' +import { Provider } from '@tarojs/redux' +import Home from './pages/home' -import LoginService from '../../util/LoginService' -import weChatLogin from '../../util/weChatLogin' -import URL from '../../serviceAPI.config' -import './home.scss' +import configStore from './store' +import './app.scss' +// 如果需要在 h5 环境中开启 React Devtools +// 取消以下注释: +// if (process.env.NODE_ENV !== 'production' && process.env.TARO_ENV === 'h5') { +// require('nerv-devtools') +// } -class Home extends Component { +const store = configStore() +class App extends Component { + + isTrue = Taro.getStorageSync('session_id') ? true : false config = { - navigationBarTitleText: '首页', + pages: [ + //'pages/index/index', // index页面 + 'pages/home/home',//首页 --------------------- + 'pages/login/login',//登入页面 --------------------- + 'pages/shop/shop',//店铺页面 --------------------- + 'pages/goods/goods',// 商品页面 --------------------- + 'pages/goodsPublish/goodsPublish',// 商品发布页面 --------------------- + 'pages/supplyDemandPublish/supplyDemandPublish',// 供求发布页面 --------------------- + 'pages/mySupplyDemand/mySupplyDemand',// 我的供求列表页面 --------------------- + 'pages/myGoodsEdit/myGoodsEdit',// 我的商品编辑页面 --------------------- + 'pages/allDemanding/allDemanding',// 所有供求页面 --------------------- + 'pages/myGoodList/myGoodList',// 我的商品列表页面 --------------------- 编辑商品按键 + 'pages/myDemandSupplyEdit/myDemandSupplyEdit',// 我的供求编辑页面 --------------------- + 'pages/supplyDemandView/supplyDemandView',// 查看单个供求页面 + 'pages/grabOrderPage/grabOrderPage',// 抢单页面 + 'pages/myNeeds/myNeeds',// 我的需求页面 + 'pages/myNeedsView/myNeedsView',// 单个需求查看页面 + 'pages/myNeedsEdit/myNeedsEdit',// 单个需求编辑页面 + 'pages/myNeedsPublish/myNeedsPublish',// 需求发布 - } - - constructor() { - super(...arguments); - this.state = { - shops: [], // 推荐店铺的信息 - ads: [], //广告图片数组 - categories: [],// 大类 - subCate: [], //小类 - demanding: [],// 业主需求 - otherData: [], // 底部导航栏 - isOpen: false, // 抢单消息提示 - grabOrderId: '',//抢到订单的id - userName: Taro.getStorageSync('user_identity').userName || '',//用户名字 - userPhone: Taro.getStorageSync('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=' + Taro.getStorageSync('session_id'), + // 'pages/shopDescription/shopDescription', + ], + permission: { + "scope.userLocation": { + "desc": "你的位置信息将用于小程序位置接口的效果展示" } - }) - .then(res => { - console.log('首页基本信息', res) - if (res.data.err_msg === 'success') { + }, + window: { + backgroundTextStyle: 'light', + navigationBarBackgroundColor: '#fff', + navigationBarTitleText: 'WeChat', + navigationBarTextStyle: 'black', + // enablePullDownRefresh:true + onReachBottomDistance: 0 + }, - 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, - }) + tabBar: { + list: [{ + pagePath: "pages/home/home", + text: "首页", + iconPath: "./icons/home.png", + selectedIconPath: "./icons/home-actived.png" }, - header: { - 'content-type': 'application/x-www-form-urlencoded', - 'Cookie': 'PFWSSS=' + Taro.getStorageSync('session_id'), + + , { + pagePath: "pages/myNeedsPublish/myNeedsPublish", + text: "需求发布", + iconPath: "./icons/publish.png", + selectedIconPath: "./icons/publish-actived.png" } - }) - .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 }) + , { + pagePath: "pages/myNeeds/myNeeds", + text: "我的需求", + iconPath: "./icons/needs.png", + selectedIconPath: "./icons/needs-actived.png" } - ) - } - getUserLocation(that) { - Taro.getLocation({ - type: 'gcj02', // 返回可以用于wx.openLocation的经纬度 - success(res) { - that.setState({ - latitude: res.latitude, - longitude: res.longitude - },()=>{ - that.getShops({}) - that.getHomeCategoriesInfo() - }) - } - }) - } - - - // 微信用户设置 - // 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=' + Taro.getStorageSync('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(item) { - Taro.showLoading({ - title: '加载中' - }) - this.setState({ parentClass: item.class_id, childClass: item.class_id, supplyLevel: 1, subCate: item.children || [] }, () => { - this.getShops({}) - }) - - - } - // 点击子类 - onClickChildCate(item) { - 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 (!Taro.getStorageSync('userInfo').user_id) { - LoginService() - return + // , { + // pagePath: "pages/individualCenter/individualCenter", + // text: "个人中心", + // iconPath: "./icons/needs.png", + // selectedIconPath: "./icons/needs-actived.png" + // } + ], + color: '#333', + selectedColor: '#FF7142', + backgroundColor: '#fff', + borderStyle: 'black' } - Taro.navigateTo({ - url: '/pages/allDemanding/allDemanding' - }) - } - - grabOrderId(Id) { - this.setState({ isOpen: true, grabOrderId: Id }) - } - handleGrabModalClose() { - this.setState({ isOpen: false }) - } - handleGrabModalCancel() { - this.setState({ isOpen: false }) - } - handleGrabConfirm() { - if (!Taro.getStorageSync('userInfo').user_id) { - LoginService() - } - this.setState({ isOpen: false }) - // 确认抢单之后 - this.GrabDemand({ demandId: this.state.grabOrderId }) - } - - - // 导航去抢单页面 - goToGrabOrderPage(orderId) { - Taro.navigateTo({ - - url: '/pages/grabOrderPage/grabOrderPage?orderId=' + orderId - }) - } - goToMyNeedsPublish() { - // 传参数给myNeedsPublish页面- 显示效果图选项 - Taro.navigateTo({ - url: '/pages/myNeedsPublish/myNeedsPublish?id=1' - }) } - componentDidMount() { - // 页面加载后 得到首页的基本信息和推荐店铺的信息 - Taro.showLoading({ title: '加载中' }) - this.getUserLocation(this) - if (!Taro.getStorageSync('userInfo').user_id) { - weChatLogin() - } - - - // this.login().then(() => { - // this.getShops({}) - // this.getHomeCategoriesInfo() - // }).catch(err => console.log('微信登入失败:', err)) } - componentWillMount() { - - } - componentWillUnmount() { } - - componentDidShow() { - - } + componentDidShow() { } componentDidHide() { } + componentCatchError() { } - // 微信用户信息 - 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, }) - }) - } + componentDidCatchError() { } + // 在 App 类中的 render() 函数没有实际作用 + // 请勿修改此函数 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} - - - - - - - - - - {/* */} - - - - - + + + ) } } -export default Home +Taro.render(, document.getElementById('app')) + // { + // pagePath: "pages/goodsPublish/goodsPublish", + // text: "商品发布", + // iconPath: "./icons/box.png", + // selectedIconPath: "./icons/box-actived.png" + // }, { + // pagePath: "pages/supplyDemandPublish/supplyDemandPublish", + // text: "供求发布", + // iconPath: "./icons/publish.png", + // selectedIconPath: "./icons/publish-actived.png" + // } + // , { + // pagePath: "pages/mySupplyDemand/mySupplyDemand", + // text: "我的供求", + // iconPath: "./icons/menu.png", + // selectedIconPath: "./icons/menu-actived.png" + // } \ No newline at end of file