index.js 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128
  1. let Parse = getApp().Parse;
  2. const company = getApp().globalData.company
  3. Page({
  4. /**
  5. * 页面的初始数据
  6. */
  7. data: {
  8. department: []
  9. },
  10. // async getDepartment() {
  11. // let Department = new Parse.Query('Department')
  12. // Department.equalTo('company', company)
  13. // let department = await Department.find()
  14. // if (department && department.length > 0) {
  15. // let listJSON = []
  16. // department.forEach(c => {
  17. // listJSON.push(c.toJSON())
  18. // })
  19. // this.setData({
  20. // department: listJSON
  21. // })
  22. // }
  23. // console.log(this.data.department);
  24. // },
  25. async getDepartment() {
  26. let Department = new Parse.Query('Department')
  27. Department.equalTo('company', company)
  28. Department.notEqualTo('isDeleted', "true")
  29. // Department.equalTo('isShow', 'true')
  30. Department.limit(3)
  31. let department = await Department.find()
  32. if (department && department.length > 0) {
  33. let listJSON = []
  34. department.forEach(c => {
  35. let dJSON = c.toJSON()
  36. let imageExtend = [
  37. "png", "jpg", "jpeg", "ico", "gif", "JPG", "PNG", "JPEG", "ICO", "GIF"
  38. ]
  39. let videoExtend = [
  40. "mp4", "flv", "avi", "MP4", "FLV", "AIV"
  41. ]
  42. let nameArray = dJSON.logo ? dJSON.logo.split(".") : ''
  43. let extend = nameArray.length > 0 ? nameArray[nameArray.length - 1] : ""
  44. let logoType
  45. if (imageExtend.indexOf(extend) > -1) {
  46. logoType = "image"
  47. }
  48. if (videoExtend.indexOf(extend) > -1) {
  49. logoType = "video"
  50. }
  51. dJSON.logoType = logoType
  52. listJSON.push(dJSON)
  53. })
  54. this.setData({
  55. department: listJSON
  56. })
  57. }
  58. console.log(this.data.department);
  59. },
  60. villagedetails(e) {
  61. let id = e.currentTarget.dataset.item.objectId
  62. console.log(id);
  63. wx.navigateTo({
  64. url: '/nova-tourism/pages/home/village/village-details/index?id=' + id
  65. });
  66. },
  67. /**
  68. * 生命周期函数--监听页面加载
  69. */
  70. onLoad: function(options) {
  71. this.getDepartment()
  72. },
  73. /**
  74. * 生命周期函数--监听页面初次渲染完成
  75. */
  76. onReady: function() {
  77. },
  78. /**
  79. * 生命周期函数--监听页面显示
  80. */
  81. onShow: function() {
  82. },
  83. /**
  84. * 生命周期函数--监听页面隐藏
  85. */
  86. onHide: function() {
  87. },
  88. /**
  89. * 生命周期函数--监听页面卸载
  90. */
  91. onUnload: function() {
  92. },
  93. /**
  94. * 页面相关事件处理函数--监听用户下拉动作
  95. */
  96. onPullDownRefresh: function() {
  97. },
  98. /**
  99. * 页面上拉触底事件的处理函数
  100. */
  101. onReachBottom: function() {
  102. },
  103. /**
  104. * 用户点击右上角分享
  105. */
  106. onShareAppMessage: function() {
  107. }
  108. })