diff --git a/src/app.js b/src/app.js index c049a7b..c0bcb21 100644 --- a/src/app.js +++ b/src/app.js @@ -2,6 +2,7 @@ import '@tarojs/async-await' import Taro, { Component } from '@tarojs/taro' import { Provider } from '@tarojs/redux' import Home from './pages/home' + import configStore from './store' import './app.scss' @@ -15,7 +16,8 @@ import './app.scss' const store = configStore() class App extends Component { - + + isTrue=Taro.getStorageSync('session_id')?true:false config = { pages: [ //'pages/index/index', // index页面 @@ -36,9 +38,14 @@ class App extends Component { 'pages/myNeedsView/myNeedsView',// 单个需求查看页面 'pages/myNeedsEdit/myNeedsEdit',// 单个需求编辑页面 'pages/myNeedsPublish/myNeedsPublish',// 需求发布 - + // 'pages/shopDescription/shopDescription', ], + permission: { + "scope.userLocation": { + "desc": "你的位置信息将用于小程序位置接口的效果展示" + } + }, window: { backgroundTextStyle: 'light', navigationBarBackgroundColor: '#fff', @@ -49,7 +56,7 @@ class App extends Component { }, tabBar: { - list: [{ + list:[{ pagePath: "pages/home/home", text: "首页", iconPath: "./icons/home.png", @@ -84,10 +91,11 @@ class App extends Component { borderStyle: 'black' } - } - componentDidMount() { } + componentDidMount() { + console.log('this.tabBar', this) + } componentDidShow() { } diff --git a/src/component/clientTabBarComponent/clientTabBarComponent.js b/src/component/clientTabBarComponent/clientTabBarComponent.js new file mode 100644 index 0000000..4e6e64e --- /dev/null +++ b/src/component/clientTabBarComponent/clientTabBarComponent.js @@ -0,0 +1,47 @@ +import Taro, { Component } from '@tarojs/taro' +import { View } from '@tarojs/components' + +import { AtTabBar } from 'taro-ui' +import './clientTabBarComponent.scss' + + + +class ClientTabBarComponent extends Component { + config = { + navigationBarTitleText: '业主底栏导航' + } + + //http://ihome6.com/Shop-supplyShops + componentDidMount() { + + } + componentWillReceiveProps(nextProps) { + } + + componentWillUnmount() { } + + componentDidShow() { } + + componentDidHide() { } + + render() { + return ( + + + + + ) + } +} + +export default ClientTabBarComponent diff --git a/src/component/clientTabBarComponent/clientTabBarComponent.scss b/src/component/clientTabBarComponent/clientTabBarComponent.scss new file mode 100644 index 0000000..e69de29 diff --git a/src/component/filteredShopComponent/voucherPosterComponent/voucherPosterComponent.js b/src/component/filteredShopComponent/voucherPosterComponent/voucherPosterComponent.js index c6a9803..10d4b22 100644 --- a/src/component/filteredShopComponent/voucherPosterComponent/voucherPosterComponent.js +++ b/src/component/filteredShopComponent/voucherPosterComponent/voucherPosterComponent.js @@ -123,7 +123,6 @@ class VoucherPoster extends Component { componentDidHide() { } render() { - console.log('i am poster') return ( {/* */} diff --git a/src/component/scrollToTopComponent/scrollToTopComponent.scss b/src/component/scrollToTopComponent/scrollToTopComponent.scss index 7399acf..c7ae4d0 100644 --- a/src/component/scrollToTopComponent/scrollToTopComponent.scss +++ b/src/component/scrollToTopComponent/scrollToTopComponent.scss @@ -6,7 +6,7 @@ border-radius:50%; text-align:center; position:fixed; - bottom:3%; + bottom:10%; right:5%; font-size:25rpx; .box{ diff --git a/src/component/sellerTabBarComponent/sellerTabBarComponent.js b/src/component/sellerTabBarComponent/sellerTabBarComponent.js new file mode 100644 index 0000000..1153b18 --- /dev/null +++ b/src/component/sellerTabBarComponent/sellerTabBarComponent.js @@ -0,0 +1,78 @@ +import Taro, { Component } from '@tarojs/taro' +import { View } from '@tarojs/components' + +import { AtTabBar } from 'taro-ui' +import './sellerTabBarComponent.scss' + + + +class SellerTabBarComponent extends Component { + config = { + navigationBarTitleText: '店铺底栏导航' + } + constructor(){ + this.state = { + current: 0, + options:[ + { title: '首页', url: '/pages/home/home', iconType: 'bullet-list', text: 'new' }, + { title: '商品发布', url: '/pages/goodsPublish/goodsPublish', iconType: 'camera' }, + { title: '供求发布', url: '/pages/supplyDemandPublish/supplyDemandPublish', iconType: 'folder', text: '100', max: '99' }, + { title: '我的供求', url: '/pages/mySupplyDemand/mySupplyDemand', iconType: 'folder', text: '100', max: '99' }, + { title: '我的需求', url: '/pages/myNeeds/myNeeds', iconType: 'folder', text: '100', max: '99' } + ] + + } + } + handleClick(value) { + + this.setState({ + current: value + }) + + let path = this.state.options[value].url + Taro.navigateTo({ + url: path, + }) + + } + + componentDidMount() { + + } + componentWillReceiveProps(nextProps) { + } + + componentWillUnmount() { } + + componentDidShow() { + console.log('this.props.currentUrl',this.props.currentUrl) + if(this.props.currentUrl==='pages/home/home'){ + this.setState({ + current:0 + }) + }else if(this.props.currentUrl==='pages/supplyDemandPublish/supplyDemandPublish'){ + this.setState({ + current:2 + }) + } + + } + + componentDidHide() { } + + render() { + return ( + + + + + ) + } +} + +export default SellerTabBarComponent diff --git a/src/component/sellerTabBarComponent/sellerTabBarComponent.scss b/src/component/sellerTabBarComponent/sellerTabBarComponent.scss new file mode 100644 index 0000000..e69de29 diff --git a/src/pages/home/home.js b/src/pages/home/home.js index 2f9f60c..57c8434 100644 --- a/src/pages/home/home.js +++ b/src/pages/home/home.js @@ -5,6 +5,7 @@ import FilteredShopComponent from '../../component/filteredShopComponent/filtere 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' @@ -12,6 +13,7 @@ import './home.scss' + class Home extends Component { config = { @@ -37,7 +39,11 @@ class Home extends Component { isAddToList: false, parentClass: '',// 大类的id childClass: '-1',//小类的id - supplyLevel: 1,// 筛选1是小类或者2是大类 + supplyLevel: 1,// 筛选1是小类或者2是大类, + latitude: '', + longitude: '', + isShopOwner: false + } } @@ -96,7 +102,9 @@ class Home extends Component { parent_supply_class: parent_supply_class, //父级class id supply_class: supply_class,// 子级class id supply_level: supply_level,// 层级 - action: action + action: action, + latitude: this.state.latitude, + longitude: this.state.longitude, }) }, header: { @@ -133,6 +141,25 @@ class Home extends Component { } ) } + 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) + } + }) + + }) + + } // 微信用户设置 @@ -263,18 +290,56 @@ 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: '加载中' }) - if(!Taro.getStorageSync('userInfo').user_id){ - weChatLogin() + // 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时 从新登入 + if (!Taro.getStorageSync('userInfo').user_id) { + weChatLogin().then(res => { + Taro.getStorageSync('shopInfo').shop_id ? this.setState({ + isShopOwner: true + }) : this.setState({ + isShopOwner: false + }) + + }).catch(err => { + + }) + + } else { + Taro.getStorageSync('shopInfo').shop_id ? this.setState({ + isShopOwner: true + }) : this.setState({ + isShopOwner: false + }) } - this.getShops({}) - this.getHomeCategoriesInfo() - - // this.login().then(() => { - // this.getShops({}) - // this.getHomeCategoriesInfo() - // }).catch(err => console.log('微信登入失败:', err)) - } componentWillMount() { @@ -283,7 +348,7 @@ class Home extends Component { componentWillUnmount() { } componentDidShow() { - + console.log('home', this.$scope.route) } componentDidHide() { } @@ -314,6 +379,7 @@ class Home extends Component { } render() { + console.log('this.state.isShopOwner', this.state.isShopOwner) // 提示模态弹窗element const modalMessageGrabElement = 提示 @@ -382,7 +448,7 @@ class Home extends Component { shop={item} key={index} categoryLevel={this.state.supplyLevel} - classId={this.state.parentClass===this.state.childClass?this.state.parentClass:this.state.childClass} + classId={this.state.parentClass === this.state.childClass ? this.state.parentClass : this.state.childClass} > }) : 没有更多了 const subCateElementsArray = this.state.subCate.length ? this.state.subCate.map((item, index) => { @@ -390,7 +456,7 @@ class Home extends Component { {item.class_name} }) : null - + return ( @@ -519,9 +585,7 @@ class Home extends Component { {/* */} - - - + {/* {this.state.isShopOwner ? : } */} ) } diff --git a/src/pages/home/needs-actived.png b/src/pages/home/needs-actived.png new file mode 100644 index 0000000..013967b Binary files /dev/null and b/src/pages/home/needs-actived.png differ diff --git a/src/pages/home/needs.png b/src/pages/home/needs.png new file mode 100644 index 0000000..53290f9 Binary files /dev/null and b/src/pages/home/needs.png differ diff --git a/src/serviceAPI.config.js b/src/serviceAPI.config.js index 4f2e54f..ae7a179 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 = "http://192.168.1.230/" +// const LOCALURL = "https://www.ihome6.com/" const URL = { Base: LOCALURL, Login: LOCALURL + 'Applet-login', //登入接口 diff --git a/src/todo list.txt b/src/todo list.txt index d5bd069..4006aff 100644 --- a/src/todo list.txt +++ b/src/todo list.txt @@ -18,373 +18,552 @@ bug: 商品编辑 增加图片后 图片顺序乱了 等待后台--- 单个我的商品页面的图片顺序,单个我的需求页面的接口, 当个我哦的需求编辑页面的接口 - import Taro, { Component } from '@tarojs/taro' -import { View, Text } from '@tarojs/components' +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 { Picker } from 'taro-ui' +import LoginService from '../../util/LoginService' +import weChatLogin from '../../util/weChatLogin' +import URL from '../../serviceAPI.config' +import './home.scss' -import './goodsTypeInteractionComp.scss' -import loginExpired from '../../util/loginExpired' -let maxDepth = 0 -let initialDataArray = [] -class GoodsTypeInteractionComp extends Component { - config = { - navigationBarTitleText: 'goodsTypeInteractionComp' +class Home extends Component { + + config = { + navigationBarTitleText: '首页', + + } + + 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: '' + } - constructor() { - super(...arguments); + } - this.state = { - ///---行业分类 开始 - initailMultiArray: [[{ class_name: '选择商品分类', class_id: '' }], [], []], // 初始化底部数据 - multiIndex: [0, 0, 0, 0],// 默认联动列数为4个并且每一列都是第一行 - interactionMultiArray: [],// 联动 + // 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'), + } + }) + .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 GetShopCategoryList - getProductCateList(url) { - Taro.request({ - url: url, - method: 'POST', - dataType: 'json', - header: { - 'content-type': 'application/x-www-form-urlencoded', - 'Cookie': 'PFWSSS=' + Taro.getStorageSync('session_id'), - 'X-Requested-With': 'XMLHttpRequest' - } + }) + } + // 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, }) - .then(res => { - if (res.data.err_code === 0) { - console.log('商品分类目录', res) - - const recursionInteractionData=this.recursionInteraction(res.data.data) - this.recursionInitialized(res.data.data) // - console.log('initialDataArray',initialDataArray.reverse()) - this.setState({ - interactionMultiArray: recursionInteractionData, - multiIndex: this.recursionDepth(res.data.data), - initailMultiArray:initialDataArray.reverse() - }, () => { - initialDataArray=[]// 把全局变变量赋值给state之后,初始化商品分类为空, 不然第二次进去的时候会自动添加进去 - // console.log('联动数据', this.state.interactionMultiArray) - // console.log('初始化数据', this.state.initailMultiArray) - - - }) // 用递归来整理无限层次的数据 - // console.log('联动数据', this.recursionInteraction(res.data.data)) - // console.log('初始数据', this.recursionInitialized(res.data.data).reverse()) - }else if (res.data.err_code === 88888) { - loginExpired(res) - } else { - Taro.showToast({ - title: res.data.err_msg, - icon: 'none' - }) - } - } - ) - .catch(error => { - console.log('商品分类请求错误', error) - }) - } - - - - - //联动确认 - bindMultiPickerChange(e) { - // 如果没有上商品 那就不执行 - if(Taro.getStorageSync('shopInfo').shop_id){ - this.setState({ - multiIndex: e.detail.value.map(item => { if (item === null) { item = 0 } return item }) - }, () => { - // console.log('picker发送选择改变,携带值为', this.state.multiIndex) - this.returnResultToParent() - - }) - } - } - returnResultToParent() { - let selected = this.state.interactionMultiArray - for (let index of this.state.multiIndex) { - if (selected[index].children[0].id) { - selected = selected[index].children + }, + header: { + 'content-type': 'application/x-www-form-urlencoded', + 'Cookie': 'PFWSSS=' + Taro.getStorageSync('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 { - this.props.onPassDataToChild(selected[index]) - break + 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(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 } - // 递归整理无限层初始数据,将整理好的数据赋值给initialDataArray - recursionInitialized(data) { - const arrayTem = [] - if (data.length) { - for (let item of data) { - arrayTem.push({ name: item.class_name, id: item.class_id }) - } - } - if(data[0].children.length){ - this.recursionInitialized(data[0].children) - } - initialDataArray.push(arrayTem) - return arrayTem + 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({ - // 递归整理无限层联动数据 - recursionInteraction(data) { - let arrayTem = [] - for (let items of data) { - arrayTem.push({ name: items.class_name, id: items.class_id }) - if (items.children) { - arrayTem[arrayTem.length - 1].children = this.recursionInteraction(items.children) - } else { - arrayTem[arrayTem.length - 1].children = [{ name: '', id: '' }] - } - } - return arrayTem // 返回联动数据 - // return arrayTem + 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() } - // 递归整理无限层初始数据 - // recursionInitialized(data) { - // const arrayTem = [] - // const childrenHolderArray = [] - // if (data.length) { - // for (let item of data) { - // arrayTem.push({ name: item.class_name, id: item.class_id }) - // item.children ? childrenHolderArray.push(...item.children) : null - // } - // this.recursionInitialized(childrenHolderArray) - // } + - // arrayTem.length ? initialDataArray.push(arrayTem) : null // 数组为空则不添加 - // return initialDataArray - // } - - // 递归整理无限层初始数据 - recursionDepth(data) { - const arrayTem = [] - const childrenHolderArray = [] - if (data.length) { - for (let item of data) { - arrayTem.push({ name: item.class_name, id: item.class_id }) - item.children ? childrenHolderArray.push(...item.children) : null - } - this.recursionDepth(childrenHolderArray) - maxDepth += 1 - } - return new Array(maxDepth).fill(0) + // this.login().then(() => { + // this.getShops({}) + // this.getHomeCategoriesInfo() + // }).catch(err => console.log('微信登入失败:', err)) + + } + + 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, }) + }) + } - // 触动联动筛选 - bindMultiPickerCol(e) { - console.log('修改的列为', e.detail.column, ',值为', e.detail.value) - console.log(this.state.initailMultiArray) - const data = { - multiArray: this.state.initailMultiArray, - multiIndex: this.state.multiIndex - } - data.multiIndex[e.detail.column] = e.detail.value + render() { + // 提示模态弹窗element + const modalMessageGrabElement = + 提示 + + 确认抢单? + + + + const demandingElemensArray = this.state.demanding.length ? this.state.demanding.map((item, index) => { - if (e.detail.column == 0) { - for (let index in data.multiArray[0]) { - const indexNumber = Number(index) - if (indexNumber === data.multiIndex[0]) { - // data.multiArray[1] = this.state.interactionMultiArray[indexNumber].children - // data.multiArray[2] = this.state.interactionMultiArray[indexNumber].children[0].children - // data.multiArray[3] = this.state.interactionMultiArray[indexNumber].children[0].children[0].children - data.multiArray[1] = this.state.interactionMultiArray[indexNumber].children - data.multiArray[2] = this.state.interactionMultiArray[indexNumber].children[data.multiIndex[1]].children - data.multiArray[3] = this.state.interactionMultiArray[indexNumber].children[data.multiIndex[1]].children[data.multiIndex[2]].children - } - } - } else if (e.detail.column == 1) { - for (let index in data.multiArray[1]) { - const indexNumber = Number(index) - if (indexNumber === data.multiIndex[1]) { - data.multiArray[2] = this.state.interactionMultiArray[data.multiIndex[0]].children[indexNumber].children - } - } - } - else if (e.detail.column == 2) { - for (let index in data.multiArray[2]) { - const indexNumber = Number(index) - if (indexNumber === data.multiIndex[2]) { - data.multiArray[3] = this.state.interactionMultiArray[data.multiIndex[0]].children[data.multiIndex[1]].children[indexNumber].children - } - } - } - - // switch (e.detail.column) {// 移动了第几列 - // case 0: - // switch (data.multiIndex[0]) { // 第一个index 是多少 - // case 0: - // data.multiArray[1] = this.state.interactionMultiArray[0].children - // data.multiArray[2]=this.state.interactionMultiArray[0].children[0].children - // break - // case 1: - // data.multiArray[1] = this.state.interactionMultiArray[1].children - // break - // case 2: - // data.multiArray[1] = this.state.interactionMultiArray[2].children - // break - // case 3: - // data.multiArray[1] = this.state.interactionMultiArray[3].children - // break - // case 4: - // data.multiArray[1] = this.state.interactionMultiArray[4].children - // break - // } - // data.multiIndex[1] = 0 - // data.multiIndex[2] = 0 - // data.multiIndex[3] = 0 - // break - // case 1: - // switch (data.multiIndex[0]) { - // case 0: - - // break - // case 1: - // switch (data.multiIndex[1]) { - // case 0: - // data.multiArray[2] = this.state.interactionMultiArray[1].children[0].children - // break - // case 1: - // data.multiArray[2] = this.state.interactionMultiArray[1].children[1].children - // break - // case 2: - // data.multiArray[2] = this.state.interactionMultiArray[1].children[2].children - // break - // case 3: - // data.multiArray[2] = this.state.interactionMultiArray[1].children[3].children ? this.state.interactionMultiArray[1].children[3].children : [{ class_name: '' }] - // break - // } - // break - // case 2: - // switch (data.multiIndex[1]) { - // case 0: - // data.multiArray[2] = this.state.interactionMultiArray[2].children[0].children - // break - // case 1: - // data.multiArray[2] = this.state.interactionMultiArray[2].children[1].children - // break - // case 2: - // data.multiArray[2] = this.state.interactionMultiArray[2].children[2].children - // break - // case 3: - // data.multiArray[2] = this.state.interactionMultiArray[2].children[3].children - // break - // case 4: - // data.multiArray[2] = this.state.interactionMultiArray[2].children[4].children - // break - // case 5: - // data.multiArray[2] = this.state.interactionMultiArray[2].children[5].children - // break - // } - // break - // case 3: - // switch (data.multiIndex[1]) { - // case 0: - // data.multiArray[2] = this.state.interactionMultiArray[3].children[0].children - // break - // case 1: - // data.multiArray[2] = this.state.interactionMultiArray[3].children[1].children - // break - // case 2: - // data.multiArray[2] = this.state.interactionMultiArray[3].children[2].children - // break - // case 3: - // data.multiArray[2] = this.state.interactionMultiArray[3].children[3].children - // break - // case 3: - // data.multiArray[2] = this.state.interactionMultiArray[3].children[3].children - // break - // } - // break - // case 4: - // switch (data.multiIndex[1]) { - // case 0: - // data.multiArray[2] = this.state.interactionMultiArray[4].children[0].children - // break - // case 1: - // data.multiArray[2] = this.state.interactionMultiArray[4].children[1].children - // break - // case 2: - // data.multiArray[2] = this.state.interactionMultiArray[4].children[2].children - // break - - // } - // break - - // } - // data.multiIndex[2] = 0 - // data.multiIndex[3] = 0 - // break - // } - this.setState({ multiIndex: data.multiIndex }) - } - - componentDidMount() { - - if(Taro.getStorageSync('shopInfo').shop_id){ - this.getProductCateList(this.props.url) - }else{ - - } - - } - // 当然父组件有新的props的 会从新渲染组件 - componentWillReceiveProps(nextProps) { - - } - componentWillUnmount() { } - - componentDidShow() { } - - componentDidHide() { } - - render() { - return ( - - - - - * - 商品分类: - - {this.props.selectedValue.name} - - - {/* {this.state.initailMultiArray[0].length? {this.state.initailMultiArray[0][this.state.multiIndex[0]].name}:null} - {this.state.initailMultiArray[1].length?{this.state.initailMultiArray[1][this.state.multiIndex[1]].name}:null} - {this.state.initailMultiArray[2].length?{this.state.initailMultiArray[2][this.state.multiIndex[2]].name}:null} */} - - - - + 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 GoodsTypeInteractionComp - - +export default Home diff --git a/src/util/weChatLogin.js b/src/util/weChatLogin.js index 0ec42ca..9a0ecc7 100644 --- a/src/util/weChatLogin.js +++ b/src/util/weChatLogin.js @@ -27,6 +27,7 @@ const setUserInfoToStorage = () => { // 异步函数登入api export default function login() { + return new Promise((resolve,reject)=>{ Taro.login({ success(res) { if (res.code) { @@ -55,12 +56,14 @@ export default function login() { Taro.setStorageSync('shopInfo', response.data.shop_info) Taro.setStorageSync('userInfo', response.data.user_info) setUserInfoToStorage() + resolve('微信登入成功') } else { Taro.showToast({ title: '微信登入失败', icon: 'none', duration: 2000 }) + reject('微信登入失败') // Taro.clearStorageSync() } @@ -72,4 +75,6 @@ export default function login() { } } }) + }) + } \ No newline at end of file