recent-news.js 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394
  1. // pages/recent-news/recent-news.js
  2. var http = require("../../utils/http.js");
  3. var config = require("../../utils/config.js");
  4. Page({
  5. /**
  6. * 页面的初始数据
  7. */
  8. data: {
  9. news:[],
  10. },
  11. /**
  12. * 生命周期函数--监听页面加载
  13. */
  14. onLoad: function (options) {
  15. },
  16. /**
  17. * 生命周期函数--监听页面初次渲染完成
  18. */
  19. onReady: function () {
  20. },
  21. /**
  22. * 生命周期函数--监听页面显示
  23. */
  24. onShow: function () {
  25. var ths = this;
  26. //加载公告
  27. var params = {
  28. url: "/shop/notice/noticeList",
  29. method: "GET",
  30. data: {},
  31. callBack: function (res) {
  32. // console.log(res);
  33. ths.setData({
  34. news: res.records,
  35. });
  36. }
  37. };
  38. http.request(params);
  39. },
  40. // 跳转公告详情页
  41. toNewsDetail:function(e){
  42. console.log(e)
  43. var id = e.currentTarget.dataset.id
  44. // console.log(id)
  45. wx.navigateTo({
  46. url: '/pages/news-detail/news-detail?id='+e.currentTarget.dataset.id,
  47. })
  48. // console.log(id)
  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. })