video.js 2.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889
  1. const util = require('../../../utils/util.js');
  2. const app = getApp();
  3. Page({
  4. data: {
  5. nav:[],
  6. videoList:[],
  7. bottom:false,
  8. page:1,
  9. vtype:'-1',
  10. src:'',
  11. wid:375,
  12. mask:true,
  13. autoplay:false,
  14. },
  15. onLoad: function (options) {
  16. wx.showNavigationBarLoading();
  17. let that = this;
  18. wx.getSystemInfo({
  19. success: function(res) {
  20. that.setData({wid:res.windowWidth})
  21. }
  22. })
  23. util.ajax({
  24. func:"video/index",
  25. data:{}
  26. },function(res){
  27. if(res.code == 0){
  28. let nav = res.data;
  29. let first = {vtype:'-1',name:'全部'}
  30. nav.unshift(first)
  31. that.setData({nav})
  32. that.getList('',1);
  33. }else{
  34. wx.hideNavigationBarLoading()
  35. util.showTips(res.reason)
  36. setTimeout(function(){
  37. wx.navigateBack({})
  38. },2500)
  39. }
  40. })
  41. },
  42. onReachBottom:function(){
  43. if(!this.data.bottom){
  44. wx.showNavigationBarLoading();
  45. var vtype = '';
  46. this.data.vtype == '-1' ? vtype = '' : vtype = this.data.vtype
  47. this.getList(vtype,this.data.page+1)
  48. }
  49. },
  50. getList:function(vtype,page){
  51. let that = this;
  52. util.ajax({
  53. func:"video/list",
  54. data:{"vtype":vtype,"pageIndex":page,"pageSize":20},
  55. load:false
  56. },function(res){
  57. if(res.code == 0){
  58. let datas = res.data.list,videoList = that.data.videoList,bottom = false;
  59. if(page == 1){
  60. videoList = datas
  61. }else{
  62. videoList = [...videoList,...datas]
  63. }
  64. if(datas.length < 20 && videoList.length >= 20){
  65. bottom = true
  66. }
  67. that.setData({videoList,page,bottom})
  68. wx.hideNavigationBarLoading()
  69. }else{
  70. util.showTips(res.reason)
  71. }
  72. })
  73. },
  74. chooseNav:function(e){
  75. wx.showNavigationBarLoading();
  76. this.setData({vtype:e.currentTarget.dataset.vtype})
  77. var vtype = '';
  78. e.currentTarget.dataset.vtype == '-1' ? vtype = '' : vtype = e.currentTarget.dataset.vtype;
  79. this.getList(vtype,1);
  80. },
  81. onShareAppMessage: function () {
  82. return {
  83. title: '精彩活动视频',
  84. path: '/pages/public/video/video',
  85. imageUrl:'https://img.bbztx.com/images/upload/202211/a3feaddd6ee339fc939e35eac0e63e9.jpg'
  86. }
  87. }
  88. })