let Parse = getApp().Parse; const company = getApp().globalData.company Component({ /** * 组件的属性列表 */ properties: { }, /** * 组件的初始数据 */ data: { value: '', active: 1, activeKey: 0, food: [], homestay: [], department: [], banners: [], active1:0, currentTab:0, tabs: [ { title: '村落推荐', icon: 'https://s1.ax1x.com/2023/04/06/ppoPu9J.png' }, { title: '美食推荐', icon: 'https://s1.ax1x.com/2023/04/06/ppoPmh4.png' }, { title: '民宿推荐', icon: 'https://s1.ax1x.com/2023/04/06/ppoPZAU.png' }, // { // title: '商超推荐', // icon: 'https://s1.ax1x.com/2023/04/06/ppoPE7T.png' // }, ], tabIndex: 0, sidebarIndex: 0, // sidebars: [ // { // time: '2023/04/07', // text: '今日首推景点' // }, // { // time: '2023/04/07', // text: '今日特惠景点' // }, // { // time: '2023/04/07', // text: '今日热门景点' // } // ] type:'catering' }, ready: async function() { // 在组件布局完成后执行,确保options参数中有data信息 this.getBanner() this.getData() }, lifetimes: { attached() { } }, /** * 组件的方法列表 */ methods: { getData() { // this.getShopStore() // this.gethomestay() this.getDepartment() }, villagedetails(e) { let id = e.currentTarget.dataset.item.objectId wx.navigateTo({ url: '/nova-tourism/pages/home/village/village-details/index?id=' + id }); }, onPullDownRefresh: function() { this.setData({ pageNum: 1, theEnd: false }, () => { // this.getList().then(res => wx.stopPullDownRefresh()) }) }, village() { wx.navigateTo({ url: '/nova-tourism/pages/home/village/index' }); }, gourmet() { wx.navigateTo({ url: '/nova-tourism/pages/gourmet/index' }); }, foodlist() { wx.navigateTo({ url: '/nova-tourism/pages/food-list/index' }); }, homestay() { wx.navigateTo({ url: '/nova-tourism/pages/homestay/hotel-list/index' }); }, hoteldetails(e) { let id = e.currentTarget.dataset.item.objectId wx.navigateTo({ url: '/nova-tourism/pages/homestay/hotel-details/index?id=' + id }); }, storepackage(e) { let id = e.currentTarget.dataset.item.objectId wx.navigateTo({ url: '/nova-tourism/pages/gourmet/store-package/index?id=' + id }); }, // homestay(e) { // let id = e.currentTarget.dataset.item.objectId // console.log(id); // wx.navigateTo({ // url: '/nova-tourism/pages/homestay/hotel-details/index?id=' + id // }); // }, async getShopStore() { let { type } = this.data this.setData({ listDate: [] }) let ShopStore = new Parse.Query('ShopStore') ShopStore.notEqualTo('isDeleted', "true") ShopStore.equalTo('company', company) ShopStore.equalTo('type', type) ShopStore.equalTo('isShow', "true") this.data.value && ShopStore.contains('storeName',this.data.value) let shopStores = await ShopStore.find() if (shopStores && shopStores.length > 0) { let listJSON = [] shopStores.forEach(c => { listJSON.push(c.toJSON()) }) this.setData({ listDate: listJSON }) } console.log(this.data.listDate); }, player() { console.log('播放视频') }, async getBanner() { let Banner = new Parse.Query('Banner') Banner.notEqualTo('isDeleted', "true") Banner.equalTo('company', company) Banner.equalTo('isEnabled', "true") Banner.equalTo('type','home') let banner = await Banner.find() if (banner && banner.length > 0) { let listJSON = [] banner.forEach(c => { listJSON.push(c.toJSON()) }) this.setData({ banners: listJSON }) } }, async gethomestay() { let ShopStore = new Parse.Query('ShopStore') ShopStore.notEqualTo('isDeleted', "true") ShopStore.equalTo('company', company) ShopStore.equalTo('type', "stay") ShopStore.equalTo('isShow', "true") let shopStores = await ShopStore.find() if (shopStores && shopStores.length > 0) { let listJSON = [] shopStores.forEach(c => { listJSON.push(c.toJSON()) }) this.setData({ homestay: listJSON }) } }, async getDepartment() { let Department = new Parse.Query('Department') Department.notEqualTo('isDeleted', "true") Department.equalTo('company', company) Department.limit(3) let department = await Department.find() if (department && department.length > 0) { let listJSON = [] department.forEach(c => { let dJSON = c.toJSON() let imageExtend = [ "png","jpg","jpeg","ico","gif", "JPG","PNG","JPEG","ICO","GIF" ] let videoExtend = [ "mp4","flv","avi", "MP4", "FLV", "AIV" ] let nameArray = dJSON.logo ? dJSON.logo.split(".") : '' let extend = nameArray.length>0?nameArray[nameArray.length-1]:"" let logoType if(imageExtend.indexOf(extend)>-1){ logoType = "image" } if(videoExtend.indexOf(extend)>-1){ logoType = "video" } dJSON.logoType = logoType listJSON.push(dJSON) }) this.setData({ department: listJSON }) console.log(this.data.department); } }, onSearch() { wx.showToast({ title: `搜索 ${this.data.value}`, icon: 'none', }); }, onClick() { wx.showToast({ title: `搜索 ${this.data.value}`, icon: 'none', }); }, onChange(e) { this.setData({ value: e.detail, }); this.getShopStore() }, // 处理点击tab onTabClick(e) { let id = e.currentTarget.id; console.log(id); let objMap = { '1':{ type:'catering' }, '2':{ type:'stay' }, '3':{ type:'shop' }, } this.setData({ tabIndex: id, }) if(id > 0){ this.setData({ type:objMap[id].type }) } id > 0 && this.getShopStore(objMap[id].equl) }, onSidebarClick(e) { let id = e.currentTarget.id; this.setData({ sidebarIndex: id, }) }, // switchNav: function (e) { // let page = this; // let id = e.target.id; // if (this.data.currentTab == id) { // return false; // } else { // page.setData({ // currentTab: id // }); // } // page.setData({ // active1: id // }); // }, }, })