index.js 2.1 KB

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