index.js 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146
  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. "text": "何以中国",
  15. "url": "https://cxzx.smcic.net/topic/Applets/shengshizhongguo/0.png",
  16. "type": "article_china",
  17. },
  18. {
  19. "text": "日程安排",
  20. "url": "https://cxzx.smcic.net/topic/Applets/shengshizhongguo/1.png",
  21. "type": "schedule",
  22. },
  23. {
  24. "text": "图片集锦",
  25. "url": "https://cxzx.smcic.net/topic/Applets/shengshizhongguo/3.png",
  26. "type": "image"
  27. },
  28. {
  29. "text": "精彩视频",
  30. "url": "https://cxzx.smcic.net/topic/Applets/shengshizhongguo/4.png",
  31. "type": "video"
  32. },
  33. {
  34. "text": "媒体聚焦",
  35. "url": "https://cxzx.smcic.net/topic/Applets/shengshizhongguo/5.png",
  36. "type": "article_media",
  37. },
  38. {
  39. "text": "蓝直播",
  40. "url": "https://cxzx.smcic.net/topic/Applets/shengshizhongguo/2.png",
  41. "type": "live"
  42. }
  43. ],
  44. headTitle: ""
  45. },
  46. activity: "",
  47. clickFunc(data) {
  48. const index = data.currentTarget.dataset.index;
  49. const item = this.data.iconList[index];
  50. let url = ""
  51. if (!item.type) return;
  52. const parames = `?title=${item.text}&activity=${this.activity}`
  53. switch (item.type) {
  54. case 'live':
  55. url = '/pages/livelist/index' + parames + "&mediaType=" + item.type;
  56. break;
  57. case 'image':
  58. case 'video':
  59. url = '/pages/mediaController/index' + parames + "&mediaType=" + item.type;
  60. break;
  61. case "schedule":
  62. url = '/pages/schedule/index' + parames + '&noToday=1';
  63. break;
  64. case "article_china":
  65. case "article_media":
  66. url = '/pages/articleList/index' + parames + '&type=' + item.type;
  67. break;
  68. default:
  69. url = '/pages/detail/detail' + parames + "&id=" + item.id;
  70. break;
  71. }
  72. wx.navigateTo({
  73. url
  74. })
  75. },
  76. /**
  77. * 生命周期函数--监听页面加载
  78. */
  79. onLoad: function (options) {
  80. if (options.title) {
  81. this.activity = decodeURIComponent(options.title)
  82. wx.setNavigationBarTitle({
  83. title: this.activity
  84. });
  85. }
  86. this.setData({
  87. headTitle: options.introduction || '',
  88. headImage: options.theme || ''
  89. })
  90. },
  91. /**
  92. * 生命周期函数--监听页面初次渲染完成
  93. */
  94. onReady: function () {
  95. },
  96. /**
  97. * 生命周期函数--监听页面显示
  98. */
  99. onShow: function () {
  100. wx.hideHomeButton()
  101. },
  102. /**
  103. * 生命周期函数--监听页面隐藏
  104. */
  105. onHide: function () {
  106. },
  107. /**
  108. * 生命周期函数--监听页面卸载
  109. */
  110. onUnload: function () {
  111. },
  112. /**
  113. * 页面相关事件处理函数--监听用户下拉动作
  114. */
  115. onPullDownRefresh: function () {
  116. },
  117. /**
  118. * 页面上拉触底事件的处理函数
  119. */
  120. onReachBottom: function () {
  121. },
  122. /**
  123. * 用户点击右上角分享
  124. */
  125. onShareAppMessage: function () {
  126. return {
  127. title: "", // 分享名称
  128. path: 'pages/home/index', // 点击分享后的链接要来到的页面的路径已经对应需要的参数
  129. }
  130. }
  131. })