index.vue 9.1 KB

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