index.vue 9.2 KB

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