index.js 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101
  1. // pages/articleList/index.js
  2. import {
  3. httpCloud
  4. } from "../../utils/httpFunc";
  5. Page({
  6. /**
  7. * 页面的初始数据
  8. */
  9. data: {
  10. list: []
  11. },
  12. activity: '',
  13. showBack(articleType) {
  14. const _this = this;
  15. httpCloud({
  16. name: "server",
  17. type: "getArticleList",
  18. data: {
  19. activityName: _this.activity,
  20. articleType
  21. },
  22. call(res) {
  23. console.log(res)
  24. _this.setData({
  25. list: res || []
  26. })
  27. }
  28. })
  29. },
  30. toDetail(e) {
  31. if (!e.currentTarget.dataset.id) return
  32. wx.navigateTo({
  33. url: '/pages/activityDetail/index?id=' + e.currentTarget.dataset.id + '&activityName=' + this.activity
  34. })
  35. },
  36. /**
  37. * 生命周期函数--监听页面加载
  38. */
  39. onLoad(options) {
  40. this.activity = decodeURIComponent(options.activity);
  41. options.title && wx.setNavigationBarTitle({
  42. title: decodeURIComponent(options.title)
  43. })
  44. this.showBack(options.type.split('_')[1]);
  45. },
  46. /**
  47. * 生命周期函数--监听页面初次渲染完成
  48. */
  49. onReady() {
  50. },
  51. /**
  52. * 生命周期函数--监听页面显示
  53. */
  54. onShow() {
  55. },
  56. /**
  57. * 生命周期函数--监听页面隐藏
  58. */
  59. onHide() {
  60. },
  61. /**
  62. * 生命周期函数--监听页面卸载
  63. */
  64. onUnload() {
  65. },
  66. /**
  67. * 页面相关事件处理函数--监听用户下拉动作
  68. */
  69. onPullDownRefresh() {
  70. },
  71. /**
  72. * 页面上拉触底事件的处理函数
  73. */
  74. onReachBottom() {
  75. },
  76. /**
  77. * 用户点击右上角分享
  78. */
  79. onShareAppMessage: function () {
  80. return {
  81. title: "", // 分享名称
  82. path: 'pages/home/index', // 点击分享后的链接要来到的页面的路径已经对应需要的参数
  83. }
  84. }
  85. })