find-old.nvue 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129
  1. <template>
  2. <view class="find-container">
  3. <view v-if="currentList.length > 0" class="main">
  4. <swiper :current-item-id="currentId" :style="{height: wanlsys.windowHeight + 'px'}" circular acceleration
  5. @change="changeCurrent" @animationfinish="animationFinish">
  6. <!-- 滑动视频页 -->
  7. <swiper-item item-id="video">
  8. <wanl-find-play ref="videoPlay" :width="wanlsys.windowWidth" :height="wanlsys.windowHeight"
  9. :bottom="wanlsys.windowBottom" />
  10. </swiper-item>
  11. <swiper-item item-id="find">
  12. <wanl-find-list ref="findPlay" :width="wanlsys.windowWidth" :height="wanlsys.windowHeight"
  13. :bottom="wanlsys.windowBottom" />
  14. </swiper-item>
  15. </swiper>
  16. </view>
  17. <wanl-find-header :currentItemId="currentId" :currentList="currentList" :height="wanlsys.headHeight"
  18. :top="wanlsys.headTop" :width="wanlsys.windowWidth" @onChange="onChangeTab" />
  19. </view>
  20. </template>
  21. <script>
  22. import wanlFindHeader from './header';
  23. import wanlFindPlay from './play';
  24. import wanlFindList from './lists.vue';
  25. export default {
  26. components: {
  27. wanlFindHeader,
  28. wanlFindPlay,
  29. wanlFindList
  30. },
  31. beforeCreate() {
  32. // #ifdef APP-NVUE
  33. var domModule = weex.requireModule('dom');
  34. domModule.addRule('fontFace', {
  35. 'fontFamily': "iconfont",
  36. 'src': "url('/static/css/font/iconfont.ttf')"
  37. });
  38. // #endif
  39. },
  40. data() {
  41. return {
  42. wanlsys: {},
  43. currentId: '',
  44. currentList: [],
  45. };
  46. },
  47. watch: {
  48. currentId(newVal, oldVal) {
  49. if (newVal === 'find') {
  50. console.log("关注,视频停止")
  51. this.$nextTick(() => {
  52. this.$refs.videoPlay.handleVideoPause();
  53. })
  54. }
  55. if (newVal === 'video') {
  56. console.log("视频,关注停止")
  57. this.$nextTick(() => {
  58. this.$refs.findPlay.handleVideoPause();
  59. })
  60. }
  61. }
  62. },
  63. onShow() {
  64. if (this.currentId === 'video') {
  65. uni.setTabBarStyle({
  66. backgroundColor: '#161616',
  67. borderStyle: 'black'
  68. })
  69. }
  70. },
  71. onHide() {
  72. setTimeout(() => {
  73. uni.setTabBarStyle({
  74. backgroundColor: '#ffffff',
  75. borderStyle: 'white'
  76. })
  77. this.$nextTick(() => {
  78. this.$refs.findPlay.handleVideoPause();
  79. this.$refs.videoPlay.handleVideoPause();
  80. })
  81. }, 50);
  82. },
  83. onShow() {
  84. const sys = uni.getSystemInfoSync();
  85. this.wanlsys = {
  86. headTop: sys.statusBarHeight,
  87. headHeight: sys.statusBarHeight + uni.upx2px(90),
  88. windowWidth: sys.windowWidth,
  89. windowHeight: sys.windowHeight,
  90. windowBottom: 0
  91. };
  92. // #ifdef APP-NVUE
  93. this.wanlsys.windowBottom = sys.windowBottom;
  94. // #endif
  95. this.loadData();
  96. },
  97. methods: {
  98. async loadData() {
  99. let client = '';
  100. this.currentId = 'video';
  101. this.currentList = [{
  102. name: '发现',
  103. type: 'video',
  104. },
  105. {
  106. name: '关注',
  107. type: 'find',
  108. }
  109. ]
  110. },
  111. animationFinish(e) {
  112. //#ifdef APP-PLUS
  113. this.changeCurrent(e)
  114. //#endif
  115. },
  116. changeCurrent(e) {
  117. this.currentId = e.detail.currentItemId;
  118. },
  119. onChangeTab(e) {
  120. this.currentId = e;
  121. }
  122. }
  123. }
  124. </script>
  125. <style scoped>
  126. @import '@/static/css/common.css';
  127. </style>