index.vue 9.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451
  1. <template>
  2. <view class="content">
  3. <view class="one">
  4. <view class="one_1">
  5. <input type="text" v-model="searchInfo.title" @blur="toInput" placeholder="请输入视频名称">
  6. </view>
  7. <view class="one_2">
  8. <button size="mini" @tap="toFilter()">筛选</button>
  9. </view>
  10. </view>
  11. <view class="two">
  12. <scroll-view scroll-y="true" class="scroll-view" @scrolltolower="toPage" @scroll="toScroll">
  13. <view class="list-scroll-view">
  14. <view class="two_1">
  15. <view class="list" v-for="(item,index) in list" :key="index" @tap="videoView(item)">
  16. <image class="image" :src="item.img_url&&item.img_url.length>0?item.img_url[0].url:''"
  17. mode="">
  18. </image>
  19. <view class="name textOver">
  20. {{item.title}}
  21. </view>
  22. <view class="other">
  23. <view class="other_1">
  24. <uni-icons type="eye" color="var(--rgbfff)" size="12"></uni-icons>
  25. {{item.view_num}}
  26. </view>
  27. <view class="other_2">
  28. {{item.time_num}}
  29. </view>
  30. </view>
  31. <view class="vip" v-if="item.is_vip=='1'">
  32. <span>VIP</span>
  33. </view>
  34. </view>
  35. </view>
  36. </view>
  37. </scroll-view>
  38. </view>
  39. <c-drawer :drawer="drawer" @toClose="toClose">
  40. <view class="drawer_one">
  41. <view class="drawer_one_1">
  42. <uni-forms ref="searchInfo" :model="searchInfo" label-width="auto">
  43. <uni-forms-item>
  44. <template>
  45. <view class="label">是否VIP</view>
  46. <view class="value">
  47. <uni-data-checkbox mode="tag" v-model="searchInfo.is_vip" :localdata="isnoList"
  48. :map="{text:'label',value:'value'}"></uni-data-checkbox>
  49. </view>
  50. </template>
  51. </uni-forms-item>
  52. <uni-forms-item>
  53. <template>
  54. <view class="label">是否热推</view>
  55. <view class="value">
  56. <uni-data-checkbox mode="tag" v-model="searchInfo.is_hot" :localdata="isnoList"
  57. :map="{text:'label',value:'value'}"></uni-data-checkbox>
  58. </view>
  59. </template>
  60. </uni-forms-item>
  61. <uni-forms-item>
  62. <template>
  63. <view class="label">厂商</view>
  64. <view class="value">
  65. <uni-data-checkbox mode="tag" v-model="searchInfo.firm_id" :localdata="firmList"
  66. :map="{text:'title',value:'id'}"></uni-data-checkbox>
  67. </view>
  68. </template>
  69. </uni-forms-item>
  70. <uni-forms-item>
  71. <template>
  72. <view class="label">类型</view>
  73. <view class="value">
  74. <uni-data-checkbox mode="tag" v-model="searchInfo.type_id" :localdata="typeList"
  75. :map="{text:'title',value:'id'}"></uni-data-checkbox>
  76. </view>
  77. </template>
  78. </uni-forms-item>
  79. <uni-forms-item>
  80. <template>
  81. <view class="label">产地</view>
  82. <view class="value">
  83. <uni-data-checkbox mode="tag" v-model="searchInfo.place_id" :localdata="placeList"
  84. :map="{text:'title',value:'id'}"></uni-data-checkbox>
  85. </view>
  86. </template>
  87. </uni-forms-item>
  88. <uni-forms-item>
  89. <template>
  90. <view class="label">年份</view>
  91. <view class="value">
  92. <uni-data-checkbox mode="tag" v-model="searchInfo.year" :localdata="yearList"
  93. :map="{text:'title',value:'id'}"></uni-data-checkbox>
  94. </view>
  95. </template>
  96. </uni-forms-item>
  97. <uni-forms-item>
  98. <template>
  99. <view class="label">领衔演员</view>
  100. <view class="value">
  101. <uni-data-checkbox mode="tag" v-model="searchInfo.head_actor" :localdata="actorList"
  102. :map="{text:'title',value:'id'}"></uni-data-checkbox>
  103. </view>
  104. </template>
  105. </uni-forms-item>
  106. </uni-forms>
  107. </view>
  108. <view class="drawer_one_2">
  109. <button size="mini" @tap="toReset()">重置</button>
  110. <button size="mini" @tap="toSave()">确认</button>
  111. </view>
  112. </view>
  113. </c-drawer>
  114. </view>
  115. </template>
  116. <script>
  117. import cDrawer from "../components/c-drawer.vue";
  118. export default {
  119. components: {
  120. cDrawer
  121. },
  122. data() {
  123. return {
  124. searchInfo: {},
  125. list: [],
  126. total: 0,
  127. page: 0,
  128. skip: 0,
  129. limit: 10,
  130. // 数据是否触底
  131. is_bottom: false,
  132. scrollTop: 0,
  133. drawer: {
  134. title: '筛选',
  135. show: false,
  136. mode: 'right'
  137. },
  138. // 字典表
  139. isnoList: [],
  140. firmList: [],
  141. typeList: [],
  142. placeList: [],
  143. yearList: [],
  144. actorList: [],
  145. }
  146. },
  147. async onLoad() {
  148. const that = this;
  149. await that.searchOther();
  150. await that.search();
  151. },
  152. onHide() {
  153. const that = this;
  154. // that.clearPage()
  155. },
  156. onPullDownRefresh: async function() {
  157. const that = this;
  158. that.clearPage();
  159. await that.search();
  160. uni.stopPullDownRefresh();
  161. },
  162. methods: {
  163. async search() {
  164. const that = this;
  165. let info = {
  166. skip: that.skip,
  167. limit: that.limit,
  168. }
  169. let res = await that.$api('videos', 'GET', {
  170. ...info,
  171. ...that.searchInfo,
  172. })
  173. if (res.errcode == '0') {
  174. let list = [...that.list, ...res.data]
  175. that.$set(that, `list`, list);
  176. that.$set(that, `total`, res.total);
  177. }
  178. },
  179. toInput(e) {
  180. const that = this;
  181. let title = e.detail.value;
  182. if (title) that.$set(that.searchInfo, `title`, title);
  183. else delete that.searchInfo.title;
  184. that.clearPage();
  185. that.search()
  186. },
  187. toPage() {
  188. const that = this;
  189. let list = that.list;
  190. let limit = that.limit;
  191. if (that.total > list.length) {
  192. uni.showLoading({
  193. title: '加载中',
  194. mask: true
  195. })
  196. let page = that.page + 1;
  197. that.$set(that, `page`, page)
  198. let skip = page * limit;
  199. that.$set(that, `skip`, skip)
  200. that.search();
  201. uni.hideLoading();
  202. } else that.$set(that, `is_bottom`, true)
  203. },
  204. toScroll(e) {
  205. const that = this;
  206. let up = that.scrollTop;
  207. that.$set(that, `scrollTop`, e.detail.scrollTop);
  208. let num = Math.sign(up - e.detail.scrollTop);
  209. if (num == 1) that.$set(that, `is_bottom`, false);
  210. },
  211. // 打开弹框
  212. toFilter() {
  213. const that = this;
  214. that.$set(that, `drawer`, {
  215. title: '筛选',
  216. show: true,
  217. mode: 'right'
  218. })
  219. },
  220. // 重置
  221. toReset() {
  222. const that = this;
  223. that.$set(that, `searchInfo`, {})
  224. that.clearPage();
  225. that.search()
  226. },
  227. toSave() {
  228. const that = this;
  229. that.clearPage();
  230. that.toClose();
  231. that.search()
  232. },
  233. // 关闭弹框
  234. toClose() {
  235. const that = this;
  236. that.$set(that, `drawer`, {
  237. title: '筛选',
  238. show: false,
  239. mode: 'right'
  240. })
  241. },
  242. // 视频查看
  243. videoView(e) {
  244. uni.navigateTo({
  245. url: `/pagesVideo/video/index?id=${e._id}`
  246. })
  247. },
  248. // 查询其他信息
  249. async searchOther() {
  250. const that = this;
  251. let res;
  252. // 是否
  253. res = await that.$api('dictdata', 'GET', {
  254. type: 'is_no'
  255. })
  256. if (res.errcode == '0') {
  257. that.$set(that, `isnoList`, res.data)
  258. }
  259. res = await that.$api('scenetype', 'GET', {
  260. is_use: '0'
  261. })
  262. if (res.errcode == '0') {
  263. for (const val of res.data) {
  264. let arr;
  265. let type = '';
  266. if (val.title == '厂商') type = 'firm';
  267. else if (val.title == '类型') type = 'type';
  268. else if (val.title == '产地') type = 'place';
  269. else if (val.title == '年份') type = 'year';
  270. else if (val.title == '演员') type = 'actor';
  271. arr = await that.$api('scenedata', 'GET', {
  272. is_use: '0',
  273. type_id: val._id
  274. })
  275. if (arr.errcode == '0') {
  276. that.$set(that, `${type}List`, arr.data);
  277. }
  278. }
  279. }
  280. },
  281. // 清空列表
  282. clearPage() {
  283. const that = this;
  284. that.$set(that, `list`, [])
  285. that.$set(that, `skip`, 0)
  286. that.$set(that, `limit`, 10)
  287. that.$set(that, `page`, 0)
  288. if (!that.searchInfo.title) delete that.searchInfo.title;
  289. },
  290. }
  291. }
  292. </script>
  293. <style lang="scss">
  294. .content {
  295. background-color: var(--rgb111);
  296. .one {
  297. background-color: var(--rgb111);
  298. display: flex;
  299. padding: 2vw;
  300. .one_1 {
  301. flex-grow: 1;
  302. input {
  303. border: 1px solid var(--rgbf1f);
  304. height: 30px;
  305. border-radius: 2px;
  306. padding: 0 5px;
  307. font-size: 12px;
  308. color: var(--rgbfff);
  309. }
  310. }
  311. .one_2 {
  312. button {
  313. height: 100%;
  314. background-color: var(--rgbfa4);
  315. color: var(--rgbfff);
  316. }
  317. }
  318. }
  319. .two {
  320. flex-grow: 1;
  321. position: relative;
  322. .two_1 {
  323. display: flex;
  324. flex-wrap: wrap;
  325. .list {
  326. position: relative;
  327. width: 48%;
  328. margin: 0 10px 10px 0;
  329. .image {
  330. width: 100%;
  331. height: 100px;
  332. overflow: hidden;
  333. border-radius: 5px;
  334. box-shadow: 0 0 5px var(--rgbf1f);
  335. margin: 0 0 5px 0;
  336. }
  337. .name {
  338. font-size: 14px;
  339. color: var(--rgbfff);
  340. margin: 0 0 5px 0;
  341. }
  342. .other {
  343. display: flex;
  344. color: var(--rgbfff);
  345. font-size: 12px;
  346. justify-content: space-between;
  347. }
  348. .vip {
  349. position: absolute;
  350. top: 0;
  351. left: 1vw;
  352. span {
  353. font-size: 14px;
  354. font-weight: bold;
  355. color: var(--rgbffd);
  356. }
  357. }
  358. }
  359. .list:nth-child(2n) {
  360. margin: 0 0 10px 0;
  361. }
  362. }
  363. }
  364. }
  365. .scroll-view {
  366. position: absolute;
  367. top: 0;
  368. left: 0;
  369. right: 0;
  370. bottom: 0;
  371. .list-scroll-view {
  372. display: flex;
  373. flex-direction: column;
  374. padding: 0 2vw;
  375. }
  376. }
  377. .is_bottom {
  378. text-align: center;
  379. text {
  380. padding: 2vw 0;
  381. display: inline-block;
  382. color: #858585;
  383. font-size: 14px;
  384. }
  385. }
  386. .drawer_one {
  387. display: flex;
  388. flex-direction: column;
  389. width: 77vw;
  390. height: 92vh;
  391. .drawer_one_1 {
  392. flex-grow: 1;
  393. overflow-y: auto;
  394. .uni-forms-item {
  395. margin: 0;
  396. }
  397. .label {
  398. font-weight: bold;
  399. margin: 0 0 5px 0;
  400. }
  401. .value {}
  402. }
  403. .drawer_one_2 {
  404. text-align: center;
  405. padding: 2vw 0;
  406. button {
  407. width: 30%;
  408. margin: 0 2vw;
  409. line-height: 2.5;
  410. }
  411. button:nth-child(1) {
  412. background-color: var(--rgbfa4);
  413. color: var(--rgbfff);
  414. }
  415. button:nth-child(2) {
  416. background-color: var(--rgb67c);
  417. color: var(--rgbfff);
  418. }
  419. }
  420. }
  421. </style>