index.vue 5.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266
  1. <template>
  2. <view class="content">
  3. <view class="one">
  4. <input type="text" v-model="searchInfo.title" @blur="toInput" placeholder="请输入视频名称">
  5. </view>
  6. <view class="two">
  7. <scroll-view scroll-y="true" class="scroll-view" @scrolltolower="toPage" @scroll="toScroll">
  8. <view class="list-scroll-view">
  9. <view class="two_1">
  10. <view class="list" v-for="(item,index) in list" :key="index" @tap="videoView(item)">
  11. <image class="image" :src="item.img_url&&item.img_url.length>0?item.img_url[0].url:''"
  12. mode="">
  13. </image>
  14. <view class="name textOver">
  15. {{item.title}}
  16. </view>
  17. <view class="other">
  18. <view class="other_1">
  19. <uni-icons type="eye" color="var(--rgbfff)" size="12"></uni-icons>
  20. {{item.view_num}}
  21. </view>
  22. <view class="other_2">
  23. {{item.time_num}}
  24. </view>
  25. </view>
  26. <view class="vip" v-if="item.is_vip=='1'">
  27. <span>VIP</span>
  28. </view>
  29. </view>
  30. </view>
  31. </view>
  32. </scroll-view>
  33. </view>
  34. </view>
  35. </template>
  36. <script>
  37. export default {
  38. data() {
  39. return {
  40. searchInfo: {},
  41. list: [],
  42. total: 0,
  43. page: 0,
  44. skip: 0,
  45. limit: 10,
  46. // 数据是否触底
  47. is_bottom: false,
  48. scrollTop: 0
  49. }
  50. },
  51. onLoad(options) {
  52. const that = this;
  53. that.$set(that, `searchInfo`, options);
  54. that.searchOther();
  55. that.search();
  56. },
  57. onHide() {
  58. const that = this;
  59. // that.clearPage()
  60. },
  61. onPullDownRefresh: async function() {
  62. const that = this;
  63. that.clearPage();
  64. await that.search();
  65. uni.stopPullDownRefresh();
  66. },
  67. methods: {
  68. async search() {
  69. const that = this;
  70. let info = {
  71. skip: that.skip,
  72. limit: that.limit,
  73. }
  74. let res = await that.$api('videos', 'GET', {
  75. ...info,
  76. ...that.searchInfo,
  77. })
  78. if (res.errcode == '0') {
  79. let list = [...that.list, ...res.data]
  80. that.$set(that, `list`, list);
  81. that.$set(that, `total`, res.total);
  82. }
  83. },
  84. async searchOther() {
  85. const that = this;
  86. if (that.searchInfo.is_hot) {
  87. uni.setNavigationBarTitle({
  88. title: '热播'
  89. });
  90. } else {
  91. let res;
  92. if (that.searchInfo.firm_id) {
  93. res = await that.$api(`scenedata/${that.searchInfo.firm_id}`)
  94. } else if (that.searchInfo.type_id) {
  95. res = await that.$api(`scenedata/${that.searchInfo.type_id}`)
  96. } else if (that.searchInfo.place_id) {
  97. res = await that.$api(`scenedata/${that.searchInfo.place_id}`)
  98. } else if (that.searchInfo.year) {
  99. res = await that.$api(`scenedata/${that.searchInfo.year}`)
  100. } else if (that.searchInfo.head_actor) {
  101. res = await that.$api(`scenedata/${that.searchInfo.head_actor}`)
  102. } else {
  103. res = {
  104. errcode: '0',
  105. data: {
  106. title: '最新'
  107. }
  108. }
  109. }
  110. if (res.errcode == '0') {
  111. uni.setNavigationBarTitle({
  112. title: res.data.title
  113. });
  114. }
  115. }
  116. },
  117. toInput(e) {
  118. const that = this;
  119. let title = e.detail.value;
  120. if (title) that.$set(that.searchInfo, `title`, title);
  121. else delete that.searchInfo.title;
  122. that.clearPage();
  123. that.search()
  124. },
  125. toPage() {
  126. const that = this;
  127. let list = that.list;
  128. let limit = that.limit;
  129. if (that.total > list.length) {
  130. uni.showLoading({
  131. title: '加载中',
  132. mask: true
  133. })
  134. let page = that.page + 1;
  135. that.$set(that, `page`, page)
  136. let skip = page * limit;
  137. that.$set(that, `skip`, skip)
  138. that.search();
  139. uni.hideLoading();
  140. } else that.$set(that, `is_bottom`, true)
  141. },
  142. toScroll(e) {
  143. const that = this;
  144. let up = that.scrollTop;
  145. that.$set(that, `scrollTop`, e.detail.scrollTop);
  146. let num = Math.sign(up - e.detail.scrollTop);
  147. if (num == 1) that.$set(that, `is_bottom`, false);
  148. },
  149. // 视频查看
  150. videoView(e) {
  151. uni.navigateTo({
  152. url: `/pagesVideo/video/index?id=${e._id}`
  153. })
  154. },
  155. // 清空列表
  156. clearPage() {
  157. const that = this;
  158. that.$set(that, `list`, [])
  159. that.$set(that, `skip`, 0)
  160. that.$set(that, `limit`, 10)
  161. that.$set(that, `page`, 0)
  162. if (!that.searchInfo.title) delete that.searchInfo.title;
  163. },
  164. },
  165. }
  166. </script>
  167. <style lang="scss">
  168. .content {
  169. background-color: var(--rgb111);
  170. .one {
  171. padding: 2vw;
  172. input {
  173. border: 1px solid var(--rgbf1f);
  174. border-radius: 5px;
  175. padding: 5px;
  176. font-size: 14px;
  177. color: var(--rgbfff);
  178. }
  179. }
  180. .two {
  181. flex-grow: 1;
  182. position: relative;
  183. .two_1 {
  184. display: flex;
  185. flex-wrap: wrap;
  186. .list {
  187. position: relative;
  188. width: 48%;
  189. margin: 0 10px 10px 0;
  190. .image {
  191. width: 100%;
  192. height: 100px;
  193. overflow: hidden;
  194. border-radius: 5px;
  195. box-shadow: 0 0 5px var(--rgbf1f);
  196. margin: 0 0 5px 0;
  197. }
  198. .name {
  199. font-size: 14px;
  200. color: var(--rgbfff);
  201. margin: 0 0 5px 0;
  202. }
  203. .other {
  204. display: flex;
  205. color: var(--rgbfff);
  206. font-size: 12px;
  207. justify-content: space-between;
  208. }
  209. .vip {
  210. position: absolute;
  211. top: 0;
  212. left: 1vw;
  213. span {
  214. font-size: 14px;
  215. font-weight: bold;
  216. color: var(--rgbffd);
  217. }
  218. }
  219. }
  220. .list:nth-child(2n) {
  221. margin: 0 0 10px 0;
  222. }
  223. }
  224. }
  225. }
  226. .scroll-view {
  227. position: absolute;
  228. top: 0;
  229. left: 0;
  230. right: 0;
  231. bottom: 0;
  232. .list-scroll-view {
  233. display: flex;
  234. flex-direction: column;
  235. padding: 0 2vw;
  236. }
  237. }
  238. .is_bottom {
  239. text-align: center;
  240. text {
  241. padding: 2vw 0;
  242. display: inline-block;
  243. color: #858585;
  244. font-size: 14px;
  245. }
  246. }
  247. </style>