index.js 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123
  1. let Parse = getApp().Parse
  2. const company = getApp().globalData.company
  3. const rechText = require('../../../../../utils/rech-text')
  4. Page({
  5. /**
  6. * 页面的初始数据
  7. */
  8. data: {
  9. id: "",
  10. depart: null,
  11. logoType: "",
  12. activeColor:'#229293'
  13. },
  14. async getDepartment() {
  15. let id = this.data.id
  16. let Department = new Parse.Query('Department')
  17. let department = await Department.get(id)
  18. department = department.toJSON()
  19. department.content = rechText.formatRichText(department.content)
  20. let imageExtend = [
  21. "png","jpg","jpeg","ico","gif", "JPG","PNG","JPEG","ICO","GIF"
  22. ]
  23. let videoExtend = [
  24. "mp4","flv","avi", "MP4", "FLV", "AIV"
  25. ]
  26. let nameArray = department.logo ?department.logo.split(".") : ''
  27. let extend = nameArray.length>0?nameArray[nameArray.length-1]:""
  28. let logoType
  29. if(imageExtend.indexOf(extend)>-1){
  30. logoType = "image"
  31. }
  32. if(videoExtend.indexOf(extend)>-1){
  33. logoType = "video"
  34. }
  35. this.setData({
  36. department,
  37. logoType: logoType
  38. })
  39. console.log(this.data.depart);
  40. },
  41. /**
  42. * 生命周期函数--监听页面加载
  43. */
  44. onLoad: function(options) {
  45. this.setData({
  46. activeColor:getApp().globalData.activeColor || '#229293'
  47. })
  48. let id = options.id
  49. console.log(id);
  50. this.setData({
  51. id
  52. })
  53. this.getDepartment()
  54. },
  55. toWebView(e) {
  56. console.log(e)
  57. let path = e.currentTarget.dataset.path
  58. if(!path) {
  59. wx.showToast({
  60. title: 'VR蔬菜收集中',
  61. duration: 1500,
  62. icon: "none"
  63. })
  64. return
  65. }
  66. wx.navigateTo({
  67. url: '/common-page/pages/web-view/index?path=' + path,
  68. })
  69. },
  70. /**
  71. * 生命周期函数--监听页面初次渲染完成
  72. */
  73. onReady: function() {
  74. },
  75. /**
  76. * 生命周期函数--监听页面显示
  77. */
  78. onShow: function() {
  79. },
  80. /**
  81. * 生命周期函数--监听页面隐藏
  82. */
  83. onHide: function() {
  84. },
  85. /**
  86. * 生命周期函数--监听页面卸载
  87. */
  88. onUnload: function() {
  89. },
  90. /**
  91. * 页面相关事件处理函数--监听用户下拉动作
  92. */
  93. onPullDownRefresh: function() {
  94. },
  95. /**
  96. * 页面上拉触底事件的处理函数
  97. */
  98. onReachBottom: function() {
  99. },
  100. /**
  101. * 用户点击右上角分享
  102. */
  103. onShareAppMessage: function() {
  104. }
  105. })