videoRecommend.js 2.6 KB

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