videoRecommend.js 1.9 KB

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