index.js 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122
  1. // pages/home/index.js
  2. const {
  3. globalData
  4. } = getApp();
  5. import {
  6. httpOrther,
  7. httpCloud
  8. } from "../../utils/httpFunc";
  9. Page({
  10. /**
  11. * 页面的初始数据
  12. */
  13. data: {
  14. list: [],
  15. },
  16. title: '',
  17. showBack() {
  18. const _this = this;
  19. httpCloud({
  20. name: "server",
  21. type: "getHome",
  22. data: {
  23. page: 1,
  24. size: 100
  25. },
  26. call(res) {
  27. const list = res || [];
  28. for (let i = 0; i < list.length; i++) {
  29. const v = list[i];
  30. if(!v.isDefaultOpen) continue;
  31. wx.redirectTo({
  32. url: `/pages/activityDetail/index?theme=${v.theme}&title=${v.title}&introduction=${v.introduction}`
  33. })
  34. break
  35. }
  36. _this.setData({
  37. list
  38. })
  39. }
  40. })
  41. },
  42. toDetail(e) {
  43. const data = e.currentTarget.dataset || {};
  44. wx.navigateTo({
  45. url: `/pages/activityDetail/index?theme=${data.theme}&title=${data.title}&introduction=${data.introduction}`
  46. })
  47. },
  48. imageload(e) {
  49. // let width = globalData.client.screenWidth * 73 / 75;
  50. // const ori = JSON.parse(JSON.stringify(this.data.heights));
  51. // ori[e.currentTarget.dataset.index || 0] = width * e.detail.height / globalData.client.screenWidth;
  52. // this.setData({
  53. // heights: ori
  54. // })
  55. },
  56. /**
  57. * 生命周期函数--监听页面加载
  58. */
  59. onLoad(options) {
  60. wx.setNavigationBarTitle({
  61. title: '媒体行',
  62. })
  63. this.showBack();
  64. },
  65. /**
  66. * 生命周期函数--监听页面初次渲染完成
  67. */
  68. onReady() {
  69. },
  70. /**
  71. * 生命周期函数--监听页面显示
  72. */
  73. onShow() {
  74. },
  75. /**
  76. * 生命周期函数--监听页面隐藏
  77. */
  78. onHide() {
  79. },
  80. /**
  81. * 生命周期函数--监听页面卸载
  82. */
  83. onUnload() {
  84. },
  85. /**
  86. * 页面相关事件处理函数--监听用户下拉动作
  87. */
  88. onPullDownRefresh() {
  89. },
  90. /**
  91. * 页面上拉触底事件的处理函数
  92. */
  93. onReachBottom() {
  94. },
  95. /**
  96. * 用户点击右上角分享
  97. */
  98. onShareAppMessage: function () {
  99. return {
  100. title: "", // 分享名称
  101. path: 'pages/home/index', // 点击分享后的链接要来到的页面的路径已经对应需要的参数
  102. }
  103. }
  104. })