phoneNewsPaper.js 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110
  1. // pages/phoneNewsPaper/phoneNewsPaper.js
  2. import {
  3. getNanPhoneNewsPaper
  4. } from "../api/newPaper-api"
  5. Page({
  6. /**
  7. * 页面的初始数据
  8. */
  9. data: {
  10. newsPaperInfo: [],
  11. lastId: '',
  12. lastSortNo: ''
  13. },
  14. gotoDetail(e) {
  15. wx.navigateTo({
  16. url: '/pages/web/web?wxUrl=' + encodeURIComponent(e.currentTarget.dataset.url)
  17. })
  18. },
  19. getNanPhoneNewsPaper() {
  20. wx.showLoading({
  21. title: '加载中'
  22. })
  23. getNanPhoneNewsPaper({
  24. id: this.data.lastId,
  25. sortNo: this.data.lastSortNo
  26. }).then(res => {
  27. if (res.data.length <= 0) {
  28. wx.showToast({
  29. title: '已加载全部数据',
  30. icon: 'success',
  31. duration: 1000
  32. })
  33. this.setData({
  34. lastId: '',
  35. lastSortNo: ''
  36. })
  37. } else {
  38. let temp = res.data;
  39. temp = this.data.newsPaperInfo.concat(temp);
  40. this.setData({
  41. newsPaperInfo: temp,
  42. lastId: temp[temp.length - 1].id,
  43. lastSortNo: temp[temp.length - 1].sortNo
  44. })
  45. wx.hideLoading();
  46. }
  47. })
  48. },
  49. /**
  50. * 生命周期函数--监听页面加载
  51. */
  52. onLoad(options) {
  53. this.getNanPhoneNewsPaper();
  54. },
  55. /**
  56. * 生命周期函数--监听页面初次渲染完成
  57. */
  58. onReady() {
  59. },
  60. /**
  61. * 生命周期函数--监听页面显示
  62. */
  63. onShow() {
  64. },
  65. /**
  66. * 生命周期函数--监听页面隐藏
  67. */
  68. onHide() {
  69. },
  70. /**
  71. * 生命周期函数--监听页面卸载
  72. */
  73. onUnload() {
  74. },
  75. /**
  76. * 页面相关事件处理函数--监听用户下拉动作
  77. */
  78. onPullDownRefresh() {
  79. },
  80. /**
  81. * 页面上拉触底事件的处理函数
  82. */
  83. onReachBottom() {
  84. this.getNanPhoneNewsPaper();
  85. },
  86. /**
  87. * 用户点击右上角分享
  88. */
  89. onShareAppMessage() {
  90. return {
  91. title: '南岸报'
  92. }
  93. }
  94. })