index.js 1.9 KB

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