search.vue 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556
  1. <template>
  2. <div>
  3. <div class="top-box">
  4. <div class="header">
  5. <u-icon name="arrow-left" @click="back" color="#fff" size="40"></u-icon>
  6. <u--input
  7. color="#fff"
  8. v-model="tournamentName"
  9. :placeholder="$t('match.lab86')"
  10. prefixIcon="search"
  11. prefixIconStyle="font-size: 28px;color: #909399"
  12. >
  13. <template slot="suffix">
  14. <img
  15. class="close"
  16. @click="tournamentName = ''"
  17. src="/static/image/match/close.png"
  18. alt=""
  19. />
  20. </template>
  21. </u--input>
  22. </div>
  23. <div
  24. class="tab"
  25. v-if="
  26. tournamentName.length >= 3 && (matchList.length || tourList.length)
  27. "
  28. >
  29. <div
  30. class="item"
  31. :class="{ active: type == '' }"
  32. @click="changeType('')"
  33. >
  34. <!-- All -->
  35. {{ $t('match.labe58') }}
  36. </div>
  37. <div
  38. class="item"
  39. v-if="matchList.length"
  40. :class="{ active: type == 'match' }"
  41. @click="changeType('match')"
  42. >
  43. <!-- Matches -->
  44. {{ $t('match.lab83') }}
  45. </div>
  46. <div
  47. class="item"
  48. v-if="tourList.length"
  49. :class="{ active: type == 'tour' }"
  50. @click="changeType('tour')"
  51. >
  52. <!-- Tours -->
  53. {{ $t('match.lab88') }}
  54. </div>
  55. </div>
  56. </div>
  57. <div class="no-input" v-if="tournamentName.length < 3">
  58. <u-icon name="error-circle" color="#DC3C23" size="30"></u-icon>
  59. <!-- Enter at
  60. least 3 characters to auto search... -->
  61. {{ $t('match.lab59') }}
  62. </div>
  63. <div v-else>
  64. <div
  65. v-if="
  66. matchList.length == 0 && tourList.length == 0 && !loading && !timer
  67. "
  68. class="no-data"
  69. >
  70. <img class="no" src="/static/image/match/no_tag.png" alt="" />
  71. <div class="result">{{ $t('match.lab60') }}‘{{ tournamentName }}’</div>
  72. <div class="text">{{ $t('match.lab61') }}</div>
  73. </div>
  74. <template v-if="(matchList.length || tourList.length)">
  75. <div class="box1" v-if="type == ''">
  76. <div class="match-list" v-if="matchList.length">
  77. <div class="lab-title" @click="type = 'match'">
  78. <!-- Matches -->
  79. {{ $t('match.lab83') }}
  80. <u-icon name="arrow-right" color="#333" size="32"></u-icon>
  81. </div>
  82. <div
  83. class="item"
  84. v-for="item in matchList.slice(0, 9)"
  85. :key="item.id"
  86. @click="toDetail(item)"
  87. >
  88. <img
  89. class="icon"
  90. src="/static/image/match/search_list_icon.png"
  91. alt=""
  92. />
  93. <div class="title">{{ item.title }}</div>
  94. <div class="text">{{ item.content }}</div>
  95. <div class="tag">
  96. {{ statusText[item.status] }}
  97. </div>
  98. </div>
  99. </div>
  100. <div class="tour-list" v-if="tourList.length">
  101. <div class="lab-title" @click="type = 'tour'">
  102. <!-- Tours -->
  103. {{ $t('match.lab88') }}
  104. <u-icon name="arrow-right" color="#333" size="32"></u-icon>
  105. </div>
  106. <div
  107. class="item"
  108. v-for="item in tourList.slice(0, 9)"
  109. :key="item.id"
  110. @click="toMatchList(item)"
  111. >
  112. <div class="icon-box">
  113. <img
  114. class="icon"
  115. src="/static/image/match/search_list_icon1.png"
  116. alt=""
  117. />
  118. </div>
  119. <div class="text">{{ item.content }}</div>
  120. <div class="title">{{ item.name }}</div>
  121. </div>
  122. </div>
  123. </div>
  124. <div class="box1" v-if="type == 'match'">
  125. <div class="match-list">
  126. <div class="lab-title">
  127. <!-- Matches -->
  128. {{ $t('match.lab83') }}
  129. </div>
  130. <scroll-view
  131. class="scroll"
  132. :scroll-y="true"
  133. @scrolltolower="scrolltolower"
  134. >
  135. <div
  136. class="item"
  137. v-for="item in matchList"
  138. :key="item.id"
  139. @click="toDetail(item)"
  140. >
  141. <img
  142. class="icon"
  143. src="/static/image/match/search_list_icon.png"
  144. alt=""
  145. />
  146. <div class="title">{{ item.title }}</div>
  147. <div class="text">{{ item.content }}</div>
  148. <div class="tag">
  149. {{ statusText[item.status] }}
  150. </div>
  151. </div>
  152. <u-loadmore
  153. :status="status"
  154. fontSize="28"
  155. :line="true"
  156. :loading-text="statusType.loadingText"
  157. :loadmore-text="statusType.loadmoreText"
  158. :nomore-text="statusType.nomoreText"
  159. />
  160. </scroll-view>
  161. </div>
  162. </div>
  163. <div class="box1" v-if="type == 'tour'">
  164. <div class="tour-list">
  165. <div class="lab-title">
  166. <!-- Tours -->
  167. {{ $t('match.lab88') }}
  168. </div>
  169. <scroll-view
  170. class="scroll"
  171. :scroll-y="true"
  172. @scrolltolower="scrolltolower1"
  173. >
  174. <div
  175. class="item"
  176. v-for="item in tourList"
  177. :key="item.id"
  178. @click="toMatchList(item)"
  179. >
  180. <div class="icon-box">
  181. <img
  182. class="icon"
  183. src="/static/image/match/search_list_icon1.png"
  184. alt=""
  185. />
  186. </div>
  187. <div class="text">{{ item.content }}</div>
  188. <div class="title">{{ item.name }}</div>
  189. </div>
  190. <u-loadmore
  191. :status="status1"
  192. fontSize="28"
  193. :line="true"
  194. :loading-text="statusType.loadingText"
  195. :loadmore-text="statusType.loadmoreText"
  196. :nomore-text="statusType.nomoreText"
  197. />
  198. </scroll-view>
  199. </div>
  200. </div>
  201. </template>
  202. </div>
  203. </div>
  204. </template>
  205. <script>
  206. export default {
  207. data() {
  208. return {
  209. tournamentName: "",
  210. type: "",
  211. status: "loadmore",
  212. status1: "loadmore",
  213. matchList: [],
  214. tourList: [],
  215. matchPage: 1,
  216. tourPage: 1,
  217. matchTotal: 1,
  218. tourTotal: 1,
  219. timer: null,
  220. loading: true,
  221. statusType: {
  222. loadingText: this.$t('common.lab'),
  223. loadmoreText: this.$t('common.lab1'),
  224. nomoreText: this.$t('common.lab2')
  225. },
  226. };
  227. },
  228. computed: {
  229. statusText() {
  230. return [this.$t('match.labe62'), this.$t('match.labe63'), this.$t('match.labe64')];
  231. },
  232. },
  233. watch: {
  234. tournamentName(val) {
  235. if (this.timer) {
  236. clearTimeout(this.timer);
  237. this.timer = null;
  238. }
  239. this.matchList = []
  240. this.tourList = []
  241. if (val.length > 2) {
  242. this.timer = setTimeout(() => {
  243. this.matchPage = 1;
  244. this.tourPage = 1;
  245. this.type = "";
  246. this.getMacthList(true);
  247. this.getTourList(true);
  248. }, 1000);
  249. }
  250. },
  251. },
  252. created() {
  253. },
  254. methods: {
  255. changeType(type) {
  256. this.type = type;
  257. },
  258. // 获取公开赛列表
  259. getMacthList(reset) {
  260. if (reset) {
  261. uni.showLoading();
  262. } else {
  263. this.status = "loading";
  264. }
  265. this.loading = true;
  266. let timeZoneId = Intl.DateTimeFormat().resolvedOptions().timeZone; //'Asia/Shanghai'
  267. uni.$u.http
  268. .post("/api/Cricketnew/get_search", {
  269. timezone: timeZoneId,
  270. content: this.tournamentName,
  271. type: "match",
  272. page: this.matchPage,
  273. })
  274. .then((res) => {
  275. if (reset) {
  276. this.matchList = res.data || [];
  277. } else {
  278. this.matchList = this.matchList.concat(res.data || [])
  279. }
  280. this.matchTotal = res.total;
  281. if (this.matchList.length == this.matchTotal) {
  282. this.status = "nomore";
  283. } else {
  284. this.status = "loadmore";
  285. }
  286. })
  287. .finally(() => {
  288. this.timer = null;
  289. if (reset) {
  290. uni.hideLoading();
  291. }
  292. this.loading = false;
  293. });
  294. },
  295. getTourList(reset) {
  296. if (reset) {
  297. uni.showLoading();
  298. } else {
  299. this.status1 = "loading";
  300. }
  301. this.loading = true;
  302. let timeZoneId = Intl.DateTimeFormat().resolvedOptions().timeZone; //'Asia/Shanghai'
  303. uni.$u.http
  304. .post("/api/Cricketnew/get_search", {
  305. timezone: timeZoneId,
  306. content: this.tournamentName,
  307. type: "tour",
  308. page: this.tourPage,
  309. })
  310. .then((res) => {
  311. if (reset) {
  312. this.tourList = res.data || [];
  313. } else {
  314. this.tourList = this.tourList.concat(res.data || [])
  315. }
  316. this.tourTotal = res.total;
  317. if (this.tourList.length == this.tourTotal) {
  318. this.status1 = "nomore";
  319. } else {
  320. this.status1 = "loadmore";
  321. }
  322. })
  323. .finally(() => {
  324. if (reset) {
  325. uni.hideLoading();
  326. }
  327. this.timer = null;
  328. this.loading = false;
  329. });
  330. },
  331. scrolltolower() {
  332. if (this.status == "loadmore") {
  333. this.matchPage += 1
  334. this.getMacthList()
  335. }
  336. },
  337. scrolltolower1() {
  338. if (this.status1 == "loadmore") {
  339. this.tourPage += 1
  340. this.getTourList()
  341. }
  342. },
  343. back() {
  344. uni.switchTab({
  345. url: "/pages/Match/Match",
  346. });
  347. },
  348. toDetail(item) {
  349. this.$toUrl("./match-detail?id=" + item.id);
  350. },
  351. toMatchList(item) {
  352. uni.navigateTo({
  353. url: `./match-list?title=${item.name}&id=${item.id}&type=${item.type}}`,
  354. });
  355. },
  356. },
  357. };
  358. </script>
  359. <style lang="scss" scoped>
  360. page {
  361. background-color: rgb(251, 251, 252);
  362. }
  363. .top-box {
  364. position: sticky;
  365. top: 0;
  366. background-color: #1d2550;
  367. z-index: 5;
  368. .header {
  369. padding: 22rpx 24rpx 22rpx 36rpx;
  370. display: flex;
  371. align-items: center;
  372. .close {
  373. width: 36rpx;
  374. }
  375. .u-input {
  376. flex: 1;
  377. margin-left: 25rpx;
  378. height: 60rpx;
  379. color: #fff;
  380. font-size: 28rpx;
  381. border: none;
  382. box-sizing: border-box;
  383. background-color: rgba(245, 245, 245, 0.3);
  384. border-radius: 30rpx;
  385. }
  386. }
  387. .tab {
  388. padding-top: 8rpx;
  389. padding-bottom: 12rpx;
  390. display: flex;
  391. align-items: center;
  392. justify-content: space-around;
  393. .item {
  394. height: 60rpx;
  395. display: flex;
  396. align-items: center;
  397. padding: 0 24rpx;
  398. border-radius: 30rpx;
  399. line-height: 42rpx;
  400. font-size: 30rpx;
  401. font-weight: 400;
  402. color: #ffffff;
  403. &.active {
  404. background-color: #2a3260;
  405. }
  406. }
  407. }
  408. }
  409. .no-input {
  410. height: 66rpx;
  411. background: #f3f3f7;
  412. display: flex;
  413. align-items: center;
  414. padding-left: 29rpx;
  415. line-height: 33rpx;
  416. font-size: 24rpx;
  417. font-weight: 400;
  418. color: #333333;
  419. .u-icon {
  420. margin-right: 12rpx;
  421. }
  422. }
  423. .no-data {
  424. display: flex;
  425. align-items: center;
  426. justify-content: center;
  427. flex-direction: column;
  428. padding-top: 273rpx;
  429. .no {
  430. display: block;
  431. width: 294rpx;
  432. margin-bottom: 37rpx;
  433. }
  434. .result {
  435. line-height: 45rpx;
  436. font-size: 32rpx;
  437. font-weight: bold;
  438. color: #333333;
  439. margin-bottom: 12rpx;
  440. text-align: center;
  441. }
  442. .text {
  443. line-height: 33rpx;
  444. font-size: 24rpx;
  445. font-weight: 400;
  446. color: #999999;
  447. }
  448. }
  449. .match-list {
  450. background-color: #fff;
  451. & + .tour-list {
  452. margin-top: 20rpx;
  453. }
  454. .lab-title {
  455. height: 88rpx;
  456. display: flex;
  457. align-items: center;
  458. line-height: 1;
  459. font-size: 30rpx;
  460. font-weight: bold;
  461. color: #333333;
  462. padding: 0 24rpx;
  463. }
  464. .item {
  465. position: relative;
  466. padding: 31rpx 170rpx 27rpx 109rpx;
  467. .title {
  468. line-height: 42rpx;
  469. font-size: 30rpx;
  470. font-weight: bold;
  471. color: #333333;
  472. margin-bottom: 10rpx;
  473. }
  474. .text {
  475. line-height: 30rpx;
  476. font-size: 22rpx;
  477. font-weight: 400;
  478. color: #333333;
  479. }
  480. .icon {
  481. position: absolute;
  482. top: 50%;
  483. transform: translateY(-50%);
  484. left: 24rpx;
  485. width: 70rpx;
  486. }
  487. .tag {
  488. position: absolute;
  489. top: 50%;
  490. transform: translateY(-50%);
  491. right: 24rpx;
  492. min-width: 128rpx;
  493. height: 32rpx;
  494. background: #f3f3f7;
  495. border-radius: 6rpx;
  496. display: flex;
  497. align-items: center;
  498. justify-content: center;
  499. font-size: 18rpx;
  500. line-height: 1;
  501. font-weight: 400;
  502. color: #999999;
  503. }
  504. }
  505. }
  506. .tour-list {
  507. background-color: #fff;
  508. .lab-title {
  509. height: 88rpx;
  510. display: flex;
  511. align-items: center;
  512. line-height: 1;
  513. font-size: 30rpx;
  514. font-weight: bold;
  515. color: #333333;
  516. padding: 0 24rpx;
  517. }
  518. .item {
  519. position: relative;
  520. padding: 31rpx 24rpx 27rpx 109rpx;
  521. .title {
  522. line-height: 40rpx;
  523. font-size: 28rpx;
  524. font-weight: bold;
  525. color: #333333;
  526. margin-top: 7rpx;
  527. }
  528. .text {
  529. line-height: 30rpx;
  530. font-size: 22rpx;
  531. font-weight: 400;
  532. color: #333333;
  533. }
  534. .icon-box {
  535. position: absolute;
  536. top: 50%;
  537. transform: translateY(-50%);
  538. left: 24rpx;
  539. width: 70rpx;
  540. height: 70rpx;
  541. border-radius: 10rpx;
  542. border: 1px solid #cccccc;
  543. display: flex;
  544. align-items: center;
  545. justify-content: center;
  546. }
  547. .icon {
  548. width: 43rpx;
  549. }
  550. }
  551. }
  552. .scroll {
  553. height: calc(100vh - 272rpx);
  554. }
  555. </style>