index.js 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110
  1. // pages/home/index.js
  2. const {
  3. globalData
  4. } = getApp();
  5. import {
  6. httpOrther
  7. } from "../../utils/httpFunc";
  8. Page({
  9. /**
  10. * 页面的初始数据
  11. */
  12. data: {
  13. list: [],
  14. heights: []
  15. },
  16. title: '',
  17. showBack() {
  18. const _this = this;
  19. httpOrther({
  20. url: `/Applets/shengshizhongguo/json/list.json?${Date.now()}`,
  21. call(res) {
  22. const defaultItem = (res.list || [])[0]
  23. if (!res.showList) {
  24. wx.redirectTo({
  25. url: `/pages/activityDetail/index?url=${defaultItem.fileName}&title=${defaultItem.title}`
  26. })
  27. return
  28. }
  29. _this.setData({
  30. list: res.list || []
  31. })
  32. }
  33. })
  34. },
  35. toDetail(e) {
  36. wx.navigateTo({
  37. url: '/pages/activityDetail/index?url=' + e.currentTarget.dataset.file + '&title=' + e.currentTarget.dataset.title
  38. })
  39. },
  40. imageload(e) {
  41. let width = globalData.client.screenWidth * 73 / 75;
  42. const ori = JSON.parse(JSON.stringify(this.data.heights));
  43. ori[e.currentTarget.dataset.index || 0] = width * e.detail.height / globalData.client.screenWidth;
  44. this.setData({
  45. heights: ori
  46. })
  47. },
  48. /**
  49. * 生命周期函数--监听页面加载
  50. */
  51. onLoad(options) {
  52. wx.setNavigationBarTitle({
  53. title: '媒体行',
  54. })
  55. this.showBack();
  56. },
  57. /**
  58. * 生命周期函数--监听页面初次渲染完成
  59. */
  60. onReady() {
  61. },
  62. /**
  63. * 生命周期函数--监听页面显示
  64. */
  65. onShow() {
  66. },
  67. /**
  68. * 生命周期函数--监听页面隐藏
  69. */
  70. onHide() {
  71. },
  72. /**
  73. * 生命周期函数--监听页面卸载
  74. */
  75. onUnload() {
  76. },
  77. /**
  78. * 页面相关事件处理函数--监听用户下拉动作
  79. */
  80. onPullDownRefresh() {
  81. },
  82. /**
  83. * 页面上拉触底事件的处理函数
  84. */
  85. onReachBottom() {
  86. },
  87. /**
  88. * 用户点击右上角分享
  89. */
  90. onShareAppMessage() {
  91. }
  92. })