let Parse = getApp().Parse; const company = getApp().globalData.company Page({ /** * 页面的初始数据 */ data: { department: [] }, // async getDepartment() { // let Department = new Parse.Query('Department') // Department.equalTo('company', company) // let department = await Department.find() // if (department && department.length > 0) { // let listJSON = [] // department.forEach(c => { // listJSON.push(c.toJSON()) // }) // this.setData({ // department: listJSON // }) // } // console.log(this.data.department); // }, async getDepartment() { let Department = new Parse.Query('Department') Department.equalTo('company', company) Department.notEqualTo('isDeleted', "true") // Department.equalTo('isShow', 'true') 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); }, villagedetails(e) { let id = e.currentTarget.dataset.item.objectId console.log(id); wx.navigateTo({ url: '/nova-tourism/pages/home/village/village-details/index?id=' + id }); }, /** * 生命周期函数--监听页面加载 */ onLoad: function(options) { this.getDepartment() }, /** * 生命周期函数--监听页面初次渲染完成 */ onReady: function() { }, /** * 生命周期函数--监听页面显示 */ onShow: function() { }, /** * 生命周期函数--监听页面隐藏 */ onHide: function() { }, /** * 生命周期函数--监听页面卸载 */ onUnload: function() { }, /** * 页面相关事件处理函数--监听用户下拉动作 */ onPullDownRefresh: function() { }, /** * 页面上拉触底事件的处理函数 */ onReachBottom: function() { }, /** * 用户点击右上角分享 */ onShareAppMessage: function() { } })