index.js 1.7 KB

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