index.js 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394
  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. httpOrther({
  32. url: '/Applets/shengshizhongguo/json/shengshi.json',
  33. call(res) {
  34. _this.setData({
  35. iconList: res || []
  36. })
  37. }
  38. })
  39. },
  40. /**
  41. * 生命周期函数--监听页面初次渲染完成
  42. */
  43. onReady: function () {
  44. },
  45. /**
  46. * 生命周期函数--监听页面显示
  47. */
  48. onShow: function () {
  49. },
  50. /**
  51. * 生命周期函数--监听页面隐藏
  52. */
  53. onHide: function () {
  54. },
  55. /**
  56. * 生命周期函数--监听页面卸载
  57. */
  58. onUnload: function () {
  59. },
  60. /**
  61. * 页面相关事件处理函数--监听用户下拉动作
  62. */
  63. onPullDownRefresh: function () {
  64. },
  65. /**
  66. * 页面上拉触底事件的处理函数
  67. */
  68. onReachBottom: function () {
  69. },
  70. /**
  71. * 用户点击右上角分享
  72. */
  73. onShareAppMessage: function () {
  74. }
  75. })