index.vue 9.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421
  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">
  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.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.drawer = {
  225. title: '筛选',
  226. show: false,
  227. mode: 'right'
  228. }
  229. },
  230. // 查询其他信息
  231. async searchOther() {
  232. const that = this;
  233. let res;
  234. // 是否
  235. res = await that.$api('dictdata', 'GET', {
  236. type: 'is_no'
  237. })
  238. if (res.errcode == '0') {
  239. that.$set(that, `isnoList`, res.data)
  240. }
  241. res = await that.$api('scenetype', 'GET', {
  242. is_use: '0'
  243. })
  244. if (res.errcode == '0') {
  245. for (const val of res.data) {
  246. let arr;
  247. let type = '';
  248. if (val.title == '厂商') type = 'firm';
  249. else if (val.title == '类型') type = 'type';
  250. else if (val.title == '产地') type = 'place';
  251. else if (val.title == '年份') type = 'year';
  252. else if (val.title == '演员') type = 'actor';
  253. arr = await that.$api('scenedata', 'GET', {
  254. is_use: '0',
  255. type_id: val._id
  256. })
  257. if (arr.errcode == '0') {
  258. that.$set(that, `${type}List`, arr.data);
  259. }
  260. }
  261. }
  262. },
  263. // 清空列表
  264. clearPage() {
  265. const that = this;
  266. that.$set(that, `list`, [])
  267. that.$set(that, `skip`, 0)
  268. that.$set(that, `limit`, 10)
  269. that.$set(that, `page`, 0)
  270. if (!that.searchInfo.title) delete that.searchInfo.title;
  271. },
  272. }
  273. }
  274. </script>
  275. <style lang="scss">
  276. .content {
  277. background-color: var(--rgb111);
  278. .one {
  279. background-color: var(--rgb111);
  280. display: flex;
  281. padding: 2vw;
  282. .one_1 {
  283. flex-grow: 1;
  284. input {
  285. border: 1px solid var(--rgbf1f);
  286. height: 30px;
  287. border-radius: 2px;
  288. padding: 0 5px;
  289. font-size: 12px;
  290. color: var(--rgbfff);
  291. }
  292. }
  293. .one_2 {
  294. button {
  295. height: 100%;
  296. background-color: var(--rgbfa4);
  297. color: var(--rgbfff);
  298. }
  299. }
  300. }
  301. .two {
  302. flex-grow: 1;
  303. position: relative;
  304. .two_1 {
  305. display: flex;
  306. flex-wrap: wrap;
  307. .list {
  308. width: 48%;
  309. margin: 0 10px 10px 0;
  310. .image {
  311. width: 100%;
  312. height: 100px;
  313. overflow: hidden;
  314. border-radius: 5px;
  315. box-shadow: 0 0 5px var(--rgbf1f);
  316. margin: 0 0 5px 0;
  317. }
  318. .name {
  319. font-size: 14px;
  320. color: var(--rgbfff);
  321. margin: 0 0 5px 0;
  322. }
  323. .other {
  324. display: flex;
  325. color: var(--rgbfff);
  326. font-size: 12px;
  327. justify-content: space-between;
  328. }
  329. }
  330. .list:nth-child(2n) {
  331. margin: 0 0 10px 0;
  332. }
  333. }
  334. }
  335. }
  336. .scroll-view {
  337. position: absolute;
  338. top: 0;
  339. left: 0;
  340. right: 0;
  341. bottom: 0;
  342. .list-scroll-view {
  343. display: flex;
  344. flex-direction: column;
  345. padding: 0 2vw;
  346. }
  347. }
  348. .is_bottom {
  349. text-align: center;
  350. text {
  351. padding: 2vw 0;
  352. display: inline-block;
  353. color: #858585;
  354. font-size: 14px;
  355. }
  356. }
  357. .drawer_one {
  358. display: flex;
  359. flex-direction: column;
  360. width: 77vw;
  361. height: 92vh;
  362. .drawer_one_1 {
  363. flex-grow: 1;
  364. overflow-y: auto;
  365. .uni-forms-item {
  366. margin: 0;
  367. }
  368. .label {
  369. font-weight: bold;
  370. margin: 0 0 5px 0;
  371. }
  372. .value {}
  373. }
  374. .drawer_one_2 {
  375. text-align: center;
  376. padding: 2vw 0;
  377. button {
  378. width: 30%;
  379. height: 100%;
  380. margin: 0 2vw;
  381. }
  382. button:nth-child(1) {
  383. background-color: var(--rgbfa4);
  384. color: var(--rgbfff);
  385. }
  386. button:nth-child(2) {
  387. background-color: var(--rgb67c);
  388. color: var(--rgbfff);
  389. }
  390. }
  391. }
  392. </style>