serach.vue 7.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271
  1. <template>
  2. <z-paging
  3. class="content-page-wrap flex-column"
  4. ref="paging"
  5. v-model="videoList"
  6. @query="getSearchList"
  7. :refresher-enabled="false"
  8. :default-page-size="50"
  9. >
  10. <template #top>
  11. <view class="search-box flex-left">
  12. <u-icon
  13. name="arrow-left"
  14. color="#000E08"
  15. size="40rpx"
  16. @tap="goBack"
  17. bold
  18. style="margin-right: 12rpx"
  19. ></u-icon>
  20. <u-input
  21. placeholder="电影 / 电视剧 / 动漫"
  22. v-model="keyword"
  23. height="72rpx"
  24. clearable
  25. @change="keywordInput"
  26. @clear="search"
  27. ref="inputRef"
  28. focus
  29. >
  30. </u-input>
  31. <view @click="search" class="input-right"> 搜索 </view>
  32. </view>
  33. <u-tabs
  34. style="padding: 0 32rpx"
  35. v-if="videoList.length > 0"
  36. :list="tabList"
  37. keyName="title"
  38. lineWidth="0"
  39. lineHeight="0"
  40. :activeStyle="{
  41. color: '#000000',
  42. fontWeight: 'bold',
  43. transform: 'scale(1.05)',
  44. fontSize: '40rpx',
  45. }"
  46. :inactiveStyle="{
  47. color: '#717171',
  48. transform: 'scale(1)',
  49. fontSize: '30rpx',
  50. }"
  51. itemStyle="padding: 0 42rpx 0 0; height: 70rpx;"
  52. @click="setTabSelect"
  53. ></u-tabs>
  54. </template>
  55. <!-- <view class="suggest-box" v-if="keyword && isSearch">
  56. <view
  57. class="search-row flex-left"
  58. v-for="(item, index) in showSearchList"
  59. @click="goVideo(item.title)"
  60. >
  61. <u-icon name="search" color="#D0D0D0" size="24"></u-icon>
  62. <view class="title" v-html="item.showTitle"></view>
  63. </view>
  64. </view> -->
  65. <view class="search-main">
  66. <view
  67. v-for="(item, index) in showSearchList"
  68. class="row-box flex"
  69. @click="goPlayVideo(item)"
  70. >
  71. <image :src="item.img" mode="aspectFill"></image>
  72. <view class="right-content flex_1">
  73. <h4 v-html="item.showTitle"></h4>
  74. <text>{{ item.desc }}</text>
  75. <view class="flex">
  76. <view class="tag">{{
  77. (
  78. tabList.find(
  79. (items) => items.type == item.tag
  80. ) || {}
  81. ).title
  82. }}</view>
  83. </view>
  84. </view>
  85. </view>
  86. </view>
  87. </z-paging>
  88. </template>
  89. <script>
  90. import { hightLight } from "@/utils/hightLight";
  91. import { searchListPackage } from "@/utils/apiMethods.js";
  92. export default {
  93. data() {
  94. return {
  95. keyword: "",
  96. videoList: [],
  97. isSearch: true,
  98. tabList: [
  99. {
  100. title: "全部",
  101. type: "",
  102. },
  103. {
  104. title: "电影",
  105. type: "电影",
  106. },
  107. {
  108. title: "连续剧",
  109. type: "剧集",
  110. },
  111. {
  112. title: "动漫",
  113. type: "动漫",
  114. },
  115. {
  116. title: "综艺",
  117. type: "综艺纪录",
  118. },
  119. {
  120. title: "短剧",
  121. type: "短剧",
  122. },
  123. ],
  124. tabIndex: 0,
  125. };
  126. },
  127. // mounted() {
  128. // this.$nextTick(() => {
  129. // document.querySelector('input').focus();
  130. // });
  131. // },
  132. computed: {
  133. showSearchList() {
  134. let vm = this;
  135. let data = [];
  136. if (vm.keyword) {
  137. vm.videoList.map((item) => {
  138. item.showTitle = hightLight(vm.keyword, item.title);
  139. if (
  140. vm.tabIndex == 0 ||
  141. vm.tabList[vm.tabIndex].type == item.tag
  142. ) {
  143. data.push(item);
  144. }
  145. });
  146. }
  147. return data;
  148. },
  149. },
  150. methods: {
  151. search() {
  152. let vm = this;
  153. vm.videoList = [];
  154. vm.$refs.paging.reload();
  155. // vm.getSearchList();
  156. },
  157. keywordInput(val) {
  158. let vm = this;
  159. if (val) {
  160. uni.$u.debounce(vm.search, 500);
  161. } else {
  162. vm.search();
  163. }
  164. },
  165. setTabSelect(data) {
  166. let vm = this;
  167. vm.tabIndex = data.index;
  168. },
  169. // 搜索视频列表
  170. getSearchList(pageNo = 1) {
  171. let vm = this;
  172. // uni.showLoading({
  173. // title: "搜索中",
  174. // });
  175. uni.request({
  176. url: "https://www.keke1.app/search", // 接口地址
  177. method: "GET",
  178. data: {
  179. k: vm.keyword,
  180. page: pageNo,
  181. },
  182. success: (res) => {
  183. // uni.hideLoading();
  184. vm.$refs.paging.complete(searchListPackage(res.data));
  185. },
  186. fail: (err) => {
  187. uni.hideLoading();
  188. vm.$refs.paging.complete(false);
  189. console.log(err);
  190. },
  191. });
  192. },
  193. // goVideo(val) {
  194. // let vm = this;
  195. // vm.isSearch = false;
  196. // vm.keyword = val;
  197. // vm.search();
  198. // },
  199. goPlayVideo(row) {
  200. uni.reLaunch({
  201. url: "/pages/play/play?url=" + row.url,
  202. });
  203. },
  204. goBack() {
  205. uni.navigateBack();
  206. },
  207. },
  208. };
  209. </script>
  210. <style lang="scss" scoped>
  211. .search-box {
  212. margin: 28rpx;
  213. z-index: 2;
  214. }
  215. .suggest-box {
  216. height: 100%;
  217. width: 100%;
  218. padding: 0 28rpx;
  219. .search-row {
  220. border-bottom: 2rpx solid #e1e1e1;
  221. padding: 16rpx 8rpx;
  222. .title {
  223. color: #000e08;
  224. font-size: 28rpx;
  225. margin-left: 14rpx;
  226. font-weight: bold;
  227. }
  228. }
  229. }
  230. .search-main {
  231. margin-top: 32rpx;
  232. .row-box {
  233. margin-bottom: 40rpx;
  234. image {
  235. width: 140rpx;
  236. height: 196rpx;
  237. border-radius: 16rpx;
  238. }
  239. .right-content {
  240. margin-left: 22rpx;
  241. display: flex;
  242. flex-direction: column;
  243. justify-content: space-between;
  244. flex: 1;
  245. text {
  246. color: #717171;
  247. font-size: 24rpx;
  248. overflow: hidden;
  249. text-overflow: ellipsis;
  250. display: -webkit-box;
  251. -webkit-line-clamp: 2;
  252. -webkit-box-orient: vertical;
  253. }
  254. .tag {
  255. height: 56rpx;
  256. background: #d0f8dd;
  257. border-radius: 8rpx;
  258. padding: 0 18rpx;
  259. display: flex;
  260. align-items: center;
  261. font-weight: bold;
  262. font-size: 28rpx;
  263. color: #1dbc46;
  264. }
  265. }
  266. }
  267. }
  268. </style>