index.js 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124
  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. let url = `/Applets/shengshizhongguo/json/${options.url || 'shengshi'}`;
  54. if (globalData.miniProgram.envVersion === 'develop') {
  55. url += '-dev'
  56. } else if (globalData.miniProgram.envVersion === 'trial') {
  57. url += '-tri'
  58. }
  59. url += `.json?${Date.now()}`
  60. httpOrther({
  61. url,
  62. call(res) {
  63. _this.setData({
  64. iconList: res.list || [],
  65. headTitle: res.headTitle || '',
  66. headImage: res.headImage || ''
  67. })
  68. }
  69. })
  70. },
  71. /**
  72. * 生命周期函数--监听页面初次渲染完成
  73. */
  74. onReady: function () {
  75. },
  76. /**
  77. * 生命周期函数--监听页面显示
  78. */
  79. onShow: function () {
  80. wx.hideHomeButton()
  81. },
  82. /**
  83. * 生命周期函数--监听页面隐藏
  84. */
  85. onHide: function () {
  86. },
  87. /**
  88. * 生命周期函数--监听页面卸载
  89. */
  90. onUnload: function () {
  91. },
  92. /**
  93. * 页面相关事件处理函数--监听用户下拉动作
  94. */
  95. onPullDownRefresh: function () {
  96. },
  97. /**
  98. * 页面上拉触底事件的处理函数
  99. */
  100. onReachBottom: function () {
  101. },
  102. /**
  103. * 用户点击右上角分享
  104. */
  105. onShareAppMessage: function () {
  106. }
  107. })