media.js 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128
  1. const pages = require('../../mixin/pages')
  2. const { getLunboList } = require('./api/index')
  3. Page({
  4. /**
  5. * 页面的初始数据
  6. */
  7. data: {
  8. ...pages.data(),
  9. listUrl: '/api/user/video/list',
  10. searchForm: {
  11. 'key_words': '',
  12. 'type': '1' // 类型 1最新2播放最高
  13. },
  14. swiperActiveDot: 0,
  15. nav: [
  16. {
  17. name: '最新视频',
  18. value: '1'
  19. },
  20. {
  21. name: '播放最高',
  22. value: '2'
  23. }
  24. ],
  25. lunboList: []
  26. },
  27. ...pages.methods,
  28. /**
  29. * 生命周期函数--监听页面加载
  30. */
  31. onLoad(options) {
  32. this.fetchLunboList()
  33. this.fetchOrderList()
  34. },
  35. /**
  36. * 生命周期函数--监听页面初次渲染完成
  37. */
  38. onReady() {
  39. },
  40. /**
  41. * 生命周期函数--监听页面显示
  42. */
  43. onShow() {
  44. },
  45. /**
  46. * 生命周期函数--监听页面隐藏
  47. */
  48. onHide() {
  49. },
  50. /**
  51. * 生命周期函数--监听页面卸载
  52. */
  53. onUnload() {
  54. },
  55. /**
  56. * 页面相关事件处理函数--监听用户下拉动作
  57. */
  58. onPullDownRefresh() {
  59. if (this.data.freshing) {
  60. return
  61. }
  62. this.setData({
  63. freshing: true
  64. })
  65. this.bindCallBack()
  66. },
  67. /**
  68. * 页面上拉触底事件的处理函数
  69. */
  70. onReachBottom() {
  71. this.fetchOrderList()
  72. },
  73. bindCallBack() {
  74. this.fetchLunboList()
  75. this.refreshOrderList()
  76. },
  77. handleSwiperChange(e) {
  78. const { current } = e.detail
  79. this.setData({
  80. swiperActiveDot: current
  81. })
  82. },
  83. handleNav(e) {
  84. const { value } = e.detail
  85. this.setData({
  86. 'searchForm.type': value
  87. }, () => {
  88. this.refreshOrderList()
  89. })
  90. },
  91. jumpMediaDetail(e) {
  92. const { item } = e.currentTarget.dataset
  93. wx.navigateTo({
  94. url: '/pages/mediaDetail/mediaDetail?videoConfig=' + JSON.stringify(item)
  95. })
  96. },
  97. async fetchLunboList() {
  98. try {
  99. const { status, data, msg } = await getLunboList()
  100. if (status) {
  101. this.setData({
  102. lunboList: data.list
  103. })
  104. } else {
  105. wx.showToast({
  106. title: msg,
  107. icon: 'none'
  108. })
  109. }
  110. } catch (err) {}
  111. }
  112. })