index.js 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120
  1. // miniprogram/pages/home/index.js
  2. import {
  3. httpOrther
  4. } from "../../utils/httpFunc";
  5. const {
  6. globalData
  7. } = getApp();
  8. Page({
  9. /**
  10. * 页面的初始数据
  11. */
  12. data: {
  13. iconList: [],
  14. headTitle: ""
  15. },
  16. activity: "",
  17. clickFunc(data) {
  18. const index = data.currentTarget.dataset.index;
  19. const item = this.data.iconList[index];
  20. let url = ""
  21. if (!item.type) return;
  22. const parames = `?title=${item.text}&activity=${this.activity}`
  23. switch (item.type) {
  24. case 'live':
  25. url = '/pages/livelist/index' + parames + "&mediaType=" + item.type;
  26. break;
  27. case 'image':
  28. case 'video':
  29. url = '/pages/mediaController/index' + parames + "&mediaType=" + item.type;
  30. break;
  31. case "schedule":
  32. url = '/pages/schedule/index' + parames + '&noToday=1';
  33. break;
  34. default:
  35. url = '/pages/detail/detail' + parames + "&id=" + item.id;
  36. break;
  37. }
  38. wx.navigateTo({
  39. url
  40. })
  41. },
  42. /**
  43. * 生命周期函数--监听页面加载
  44. */
  45. onLoad: function (options) {
  46. if (options.title) {
  47. this.activity = decodeURIComponent(options.title)
  48. wx.setNavigationBarTitle({
  49. title: this.activity
  50. });
  51. }
  52. const _this = this;
  53. httpOrther({
  54. url: `/Applets/shengshizhongguo/json/${(options.url || 'shengshi') + globalData.miniProgram.envVersion}.json?${Date.now()}`,
  55. call(res) {
  56. _this.setData({
  57. iconList: res.list || [],
  58. headTitle: res.headTitle || '',
  59. headImage: res.headImage || ''
  60. })
  61. }
  62. })
  63. },
  64. /**
  65. * 生命周期函数--监听页面初次渲染完成
  66. */
  67. onReady: function () {
  68. },
  69. /**
  70. * 生命周期函数--监听页面显示
  71. */
  72. onShow: function () {
  73. wx.hideHomeButton()
  74. },
  75. /**
  76. * 生命周期函数--监听页面隐藏
  77. */
  78. onHide: function () {
  79. },
  80. /**
  81. * 生命周期函数--监听页面卸载
  82. */
  83. onUnload: function () {
  84. },
  85. /**
  86. * 页面相关事件处理函数--监听用户下拉动作
  87. */
  88. onPullDownRefresh: function () {
  89. },
  90. /**
  91. * 页面上拉触底事件的处理函数
  92. */
  93. onReachBottom: function () {
  94. },
  95. /**
  96. * 用户点击右上角分享
  97. */
  98. onShareAppMessage: function () {
  99. return {
  100. title: "", // 分享名称
  101. path: 'pages/home/index', // 点击分享后的链接要来到的页面的路径已经对应需要的参数
  102. }
  103. }
  104. })