index.js 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495
  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. default:
  22. url = '/pages/detail/detail?title=' + item.text + "&id=" + item.id;
  23. break;
  24. }
  25. wx.navigateTo({ url })
  26. },
  27. /**
  28. * 生命周期函数--监听页面加载
  29. */
  30. onLoad: function () {
  31. const _this = this;
  32. httpOrther({
  33. url: '/Applets/shengshizhongguo/json/shengshi.json',
  34. call(res) {
  35. _this.setData({
  36. iconList: res || []
  37. })
  38. }
  39. })
  40. },
  41. /**
  42. * 生命周期函数--监听页面初次渲染完成
  43. */
  44. onReady: function () {
  45. },
  46. /**
  47. * 生命周期函数--监听页面显示
  48. */
  49. onShow: function () {
  50. },
  51. /**
  52. * 生命周期函数--监听页面隐藏
  53. */
  54. onHide: function () {
  55. },
  56. /**
  57. * 生命周期函数--监听页面卸载
  58. */
  59. onUnload: function () {
  60. },
  61. /**
  62. * 页面相关事件处理函数--监听用户下拉动作
  63. */
  64. onPullDownRefresh: function () {
  65. },
  66. /**
  67. * 页面上拉触底事件的处理函数
  68. */
  69. onReachBottom: function () {
  70. },
  71. /**
  72. * 用户点击右上角分享
  73. */
  74. onShareAppMessage: function () {
  75. }
  76. })