index.js 1.6 KB

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