indedxSearch.vue 19 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628
  1. <template>
  2. <view class="container search-container">
  3. <view class="sticky-content">
  4. <view class="searchTarget-header">
  5. <input
  6. type="text"
  7. :placeholder="searchPlaceholderList.TabSearch"
  8. placeholder-class="sea_ipt_placeholder"
  9. class="sea_ipt"
  10. v-model="searchTxt"
  11. focus="true"
  12. confirm-type="search"
  13. @confirm="searchHandle"
  14. />
  15. <icon type="search" size="15" class="sea_ico" />
  16. <view class="ipt-right">
  17. <icon type="clear" size="16" color="#E0E0E0" v-show="searchTxt" @click="clearIpt" />
  18. <text class="line">|</text>
  19. <text @click="searchHandle" style="color: #3385ff">搜索</text>
  20. </view>
  21. </view>
  22. <view class="search-tabs" v-if="isResult">
  23. <view :class="['tabs-item', tabsActive === item.id && 'active']" v-for="item in tabsList" :key="item.id" @click="tabsHandel(item)">
  24. {{ item.title }}
  25. <view class="item-act" v-if="tabsActive === item.id"></view>
  26. </view>
  27. </view>
  28. <block v-if="isResult">
  29. <view class="more-summary more-box" v-if="(tabsActive === 1 || tabsActive === 2) && haveResultSummary">
  30. <view>
  31. <text class="more-text" v-if="tabsActive === 1"> 纪要/图表 </text>
  32. </view>
  33. <view style="display: flex; align-items: center">
  34. <view class="summary-select">
  35. <text @click="summarySelectHandler(item, '纪要')" :class="['select-item', summarySelectActive == item.value && 'active-item']" v-for="item in summarySelect" :key="item.value">{{
  36. item.name
  37. }}</text>
  38. </view>
  39. <view v-if="tabsActive === 1" class="more-rivet" @click="tabsActiveMore(2)"> 更多 <u-icon name="arrow-right" color="#3385FF" size="28"></u-icon> </view>
  40. </view>
  41. </view>
  42. <view class="activity-select" style="display: flex; align-items: center; justify-content: flex-end" v-if="tabsActive == 4">
  43. <view class="summary-select">
  44. <text @click="summarySelectHandler(item, '活动')" :class="['select-item', activitySelectActive == item.value && 'active-item']" v-for="item in activitySelect" :key="item.value">
  45. {{ item.name }}
  46. </text>
  47. </view>
  48. <view v-if="tabsActive === 1" class="more-rivet" @click="tabsActiveMore(2)"> 更多 <u-icon name="arrow-right" color="#3385FF" size="28"></u-icon> </view>
  49. </view>
  50. </block>
  51. </view>
  52. <view class="search-cont" v-if="!isResult">
  53. <block v-for="key in keywordList" :key="key.title">
  54. <view class="history" v-if="key.title !== '搜索历史' || (key.title == '搜索历史' && historySearchList.length)">
  55. <view class="history-title title">
  56. <text>{{ key.title }}</text>
  57. <image v-if="key.imgShown" @click="clearHistory" src="https://hzchart.oss-cn-shanghai.aliyuncs.com/cygx/czbk/empty_ico.png" class="empty_ico"></image>
  58. </view>
  59. <view class="history-item">
  60. <block v-for="(item, index) in relyOn(key.title)" :key="item">
  61. <block v-if="key.title == '搜索历史'">
  62. <view v-if="index < 8" class="item" @click="chooseTarget(item)">{{ item }}</view>
  63. </block>
  64. <view v-else class="item" @click="chooseTarget(item)">{{ item }}</view>
  65. </block>
  66. </view>
  67. </view>
  68. </block>
  69. </view>
  70. <view v-else class="content">
  71. <block v-if="haveResult">
  72. <view>
  73. <summary-chart :resultList="tabsActive == 1 ? resultList.slice(0, 10) : resultList" :tabsActiveChild="tabsActive" v-if="resultList.length && (tabsActive == 2 || tabsActive == 1)" />
  74. <view class="more-report more-box" v-if="tabsActive === 1 && haveResultReport">
  75. <text class="more-text"> 资源包/报告 </text>
  76. <view>
  77. <view class="more-rivet" @click="tabsActiveMore(3)"> 更多 <u-icon name="arrow-right" color="#3385FF" size="28"></u-icon> </view>
  78. </view>
  79. </view>
  80. <reportPage :reportPageData="reportPageData" id="container-report-page" v-if="Object.keys(reportPageData).length && (tabsActive == 3 || tabsActive == 1)" />
  81. <view class="more-activity more-box" v-if="tabsActive === 1 && haveResultActivity">
  82. <text class="more-text"> 活动/回放 </text>
  83. <view>
  84. <view class="more-rivet" @click="tabsActiveMore(4)"> 更多 <u-icon name="arrow-right" color="#3385FF" size="28"></u-icon> </view>
  85. </view>
  86. </view>
  87. <activityBack :collectLists="collectList" :tabsActiveSearch="tabsActive" v-if="collectList.length && (tabsActive == 4 || tabsActive == 1)" />
  88. </view>
  89. </block>
  90. <view class="nodata" v-else>
  91. <image src="https://hzchart.oss-cn-shanghai.aliyuncs.com/cygx/czbk/act_search.png" mode="" class="nodata_ico"></image>
  92. <text>未找到您想搜索的内容</text>
  93. </view>
  94. </view>
  95. </view>
  96. </template>
  97. <script>
  98. import { KeywordList, TabsList, SummarySelect, ActivitySelect } from "./searchList";
  99. import { Search, activity, Report } from "@/config/api";
  100. import { Debounce, Throttle } from "@/config/util.js";
  101. import summaryChart from "../components/summaryChart.vue";
  102. import activityBack from "../components/activityBack.vue";
  103. import reportPage from "../components/report.vue";
  104. export default {
  105. components: { summaryChart, activityBack, reportPage },
  106. data() {
  107. return {
  108. searchTxt: "",
  109. isResult: false,
  110. historySearchList: [], //历史搜索
  111. hotKeyWord: [], //热搜关键词
  112. wordList: [], //推荐关键词
  113. tabsActive: 1, //搜索的筛选条件
  114. resultList: [], //纪要与图表
  115. resultDataList: [], ////纪要与图表
  116. collectList: [], //活动的数据
  117. reportPageData: {}, //报告的数据
  118. haveResultSummary: true, //是否有搜索数据
  119. haveResultActivity: true, //是否有搜索数据
  120. haveResultReport: true, //是否有搜索数据
  121. summarySelectActive: "Matching",
  122. activitySelectActive: "0",
  123. refresh: false, //正在下拉
  124. pageNum: 1,
  125. pageSize: null,
  126. totalPage: 0,
  127. status: "loadmore",
  128. loadText: {
  129. loadmore: "上拉加载更多",
  130. loading: "加载中",
  131. nomore: "已经到底了",
  132. },
  133. };
  134. },
  135. computed: {
  136. keywordList() {
  137. return KeywordList;
  138. },
  139. tabsList() {
  140. return TabsList;
  141. },
  142. summarySelect() {
  143. return SummarySelect;
  144. },
  145. activitySelect() {
  146. return ActivitySelect;
  147. },
  148. haveResult() {
  149. let all = this.haveResultSummary || this.haveResultActivity || this.haveResultReport;
  150. return this.tabsActive == 1 ? all : this.tabsActive == 2 ? this.haveResultSummary : this.tabsActive == 3 ? this.haveResultReport : this.haveResultActivity;
  151. },
  152. },
  153. watch: {
  154. tabsActive: {
  155. handler(val) {
  156. val == 1 ? (this.pageSize = 5) : (this.pageSize = 10);
  157. },
  158. deep: true,
  159. immediate: true,
  160. },
  161. },
  162. methods: {
  163. //搜索事件
  164. searchHandle() {
  165. if (this.searchTxt) {
  166. if (!this.historySearchList.includes(this.searchTxt)) {
  167. this.historySearchList.unshift(this.searchTxt);
  168. this.$db.set("historySearchList", JSON.stringify(this.historySearchList));
  169. }
  170. this.getListInit();
  171. this.getDataList();
  172. } else {
  173. this.$util.toast("请输入关键字");
  174. }
  175. },
  176. //清除搜索关键字
  177. clearIpt() {
  178. this.searchTxt = "";
  179. this.tabsActive = 1;
  180. this.isResult = false;
  181. this.getListInit();
  182. },
  183. //关键词 遍历的依赖
  184. relyOn(val) {
  185. return val == "搜索历史" ? this.historySearchList : val == "热搜关键词" ? this.hotKeyWord : this.wordList;
  186. },
  187. //点击了筛选项目
  188. tabsHandel(item) {
  189. this.tabsActive = item.id;
  190. this.getListInit();
  191. this.getDataList();
  192. },
  193. //获取热搜关键词的请求
  194. async researchHotKeyWord() {
  195. const res = await Search.getKeys();
  196. if (res.Ret === 200) {
  197. this.hotKeyWord = res.Data.ListHot ? res.Data.ListHot.map((key) => key.KeyWord) : [];
  198. this.wordList = res.Data.Item ? res.Data.Item.ConfigValue.split(",") : [];
  199. }
  200. },
  201. // 选择历史搜索
  202. chooseTarget(item) {
  203. this.searchTxt = item;
  204. if (!this.historySearchList.includes(item)) {
  205. this.historySearchList.unshift(item);
  206. this.$db.set("historySearchList", JSON.stringify(this.historySearchList));
  207. }
  208. this.getListInit();
  209. this.getDataList();
  210. },
  211. //搜索
  212. getDataList() {
  213. this.isResult = true;
  214. if (this.tabsActive == 1) {
  215. this.synthesiz();
  216. this.getReportList();
  217. this.getActivityBackList();
  218. } else if (this.tabsActive == 2) {
  219. this.synthesiz();
  220. } else if (this.tabsActive == 3) {
  221. this.getReportList();
  222. } else if (this.tabsActive == 4) {
  223. this.getActivityBackList();
  224. }
  225. },
  226. //纪要 图表的搜索
  227. async synthesiz() {
  228. const res = await Search.getArtAndChartList({
  229. KeyWord: this.searchTxt.replace(/^\s+|\s+$/g, ""),
  230. OrderColumn: this.summarySelectActive,
  231. PageSize: 10,
  232. CurrentIndex: this.pageNum,
  233. ListType: 1,
  234. });
  235. if (res.Ret === 200) {
  236. this.status = this.pageNum < res.Data.Paging.Pages ? "loadmore" : "nomore";
  237. this.totalPage = res.Data.Paging.Totals;
  238. if (this.pageNum == 1) {
  239. this.haveResultSummary = res.Data.List.length || res.Data.ChartList.length ? true : false;
  240. }
  241. if (res.Data.List.length && res.Data.ChartList.length) {
  242. if (this.pageNum == 1) {
  243. this.resultDataList.push(res.Data.List.shift());
  244. if (this.refresh) {
  245. uni.stopPullDownRefresh();
  246. this.refresh = false;
  247. }
  248. }
  249. let newArr = [];
  250. let newArrTwo = [];
  251. for (let i = 0; i < res.Data.List.length; i += 2) {
  252. newArr.push(res.Data.List.slice(i, i + 2));
  253. }
  254. for (let i = 0; i < res.Data.ChartList.length; i += 2) {
  255. newArrTwo.push(res.Data.ChartList.slice(i, i + 2));
  256. }
  257. let arr = [];
  258. newArr.forEach((item, index) => {
  259. if (newArrTwo[index]) {
  260. arr.push(newArrTwo[index], item);
  261. } else {
  262. arr.push(item);
  263. }
  264. });
  265. this.resultDataList = this.resultDataList.concat(arr.flat(Infinity));
  266. } else if (!res.Data.List.length) {
  267. res.Data.ChartList.length && this.resultDataList.push(...res.Data.ChartList);
  268. } else if (!res.Data.ChartList.length) {
  269. res.Data.List.length && this.resultDataList.push(...res.Data.List);
  270. }
  271. this.resultList = this.resultDataList;
  272. }
  273. },
  274. //活动回放的接口获取列表
  275. async getActivityBackList() {
  276. const res =
  277. this.tabsActive === 1 || this.activitySelectActive == 0
  278. ? await activity.getActivityListSearch({
  279. PageSize: this.pageSize,
  280. CurrentIndex: this.pageNum,
  281. KeyWord: this.searchTxt,
  282. ActiveState: "1,2,3", //活动进行状态
  283. PlayBack: Number(this.activitySelectActive),
  284. })
  285. : await activity.getActivityListNew({
  286. PageSize: this.pageSize,
  287. CurrentIndex: this.pageNum,
  288. KeyWord: this.searchTxt,
  289. ActiveState: "1,2,3", //活动进行状态
  290. PlayBack: Number(this.activitySelectActive),
  291. });
  292. if (res.Ret !== 200) return;
  293. this.status = this.pageNum < res.Data.Paging.Pages ? "loadmore" : "nomore";
  294. this.totalPage = res.Data.Paging.Pages; //总页数
  295. if (this.pageNum === 1) {
  296. this.collectList = res.Data.List || [];
  297. this.haveResultActivity = this.collectList.length ? true : false;
  298. if (this.refresh) {
  299. uni.stopPullDownRefresh();
  300. this.refresh = false;
  301. }
  302. } else {
  303. this.collectList.push(...res.Data.List);
  304. }
  305. },
  306. //获取报告的
  307. async getReportList() {
  308. const res = await Report.getSearchReportAndResource({
  309. KeyWord: this.searchTxt.replace(/^\s+|\s+$/g, ""),
  310. PageSize: this.tabsActive == 1 ? 5 : "",
  311. });
  312. if (res.Ret === 200) {
  313. if (this.refresh) {
  314. uni.stopPullDownRefresh();
  315. this.refresh = false;
  316. }
  317. this.reportPageData = res.Data || {};
  318. if (res.Data.ListHzReport.length || res.Data.ListHzResource.length || res.Data.ListYxReport.length || res.Data.ListYxResource.length) {
  319. this.haveResultReport = true;
  320. } else {
  321. this.haveResultReport = false;
  322. }
  323. }
  324. },
  325. //点击了更多
  326. tabsActiveMore(val) {
  327. this.tabsActive = val;
  328. this.getListInit();
  329. this.getDataList();
  330. },
  331. //纪要、图标的筛选
  332. summarySelectHandler(item, type) {
  333. this.pageNum = 1;
  334. if (type == "纪要") {
  335. this.summarySelectActive = item.value;
  336. this.resultList = [];
  337. this.resultDataList = [];
  338. this.synthesiz();
  339. } else {
  340. this.activitySelectActive = item.value;
  341. this.collectList = [];
  342. this.getActivityBackList();
  343. }
  344. },
  345. /* 历史搜索清空 */
  346. clearHistory() {
  347. this.historySearchList = [];
  348. this.$db.del("historySearchList");
  349. },
  350. getListInit() {
  351. uni.pageScrollTo({
  352. scrollTop: 0,
  353. duration: 300,
  354. });
  355. this.pageNum = 1;
  356. this.pageSize = this.tabsActive == 1 ? 5 : 10;
  357. this.totalPage = 0;
  358. this.summarySelectActive = "Matching";
  359. this.activitySelectActive = "0";
  360. this.status = "loadmore";
  361. this.resultList = [];
  362. this.resultDataList = [];
  363. this.collectList = [];
  364. this.reportPageData = {};
  365. },
  366. },
  367. onLoad(options) {
  368. this.researchHotKeyWord();
  369. if (this.$db.get("historySearchList")) {
  370. this.historySearchList = JSON.parse(this.$db.get("historySearchList"));
  371. }
  372. },
  373. onShow() {},
  374. /* 下拉刷新 */
  375. onPullDownRefresh: Throttle(function () {
  376. this.page_no = 1;
  377. this.refresh = true;
  378. this.getDataList();
  379. }),
  380. // 上拉加载this.resultList
  381. onReachBottom: Throttle(function () {
  382. if (this.tabsActive == 1) return;
  383. if (this.status === "nomore") return;
  384. this.status = "loading";
  385. this.pageNum++;
  386. this.getDataList();
  387. }),
  388. };
  389. </script>
  390. <style lang="scss" scoped>
  391. .search-container {
  392. background-color: #f5f6fa;
  393. padding: 200rpx 0 0rpx;
  394. min-height: 100vh;
  395. box-sizing: border-box;
  396. .sticky-content {
  397. position: fixed;
  398. top: 0;
  399. left: 0;
  400. width: 100%;
  401. z-index: 99;
  402. background-color: #fff;
  403. }
  404. .searchTarget-header {
  405. padding: 0 34rpx;
  406. width: 100%;
  407. position: relative;
  408. padding: 30rpx 0;
  409. display: flex;
  410. justify-content: center;
  411. align-items: center;
  412. .sea_ipt_placeholder {
  413. color: #8d8d8d;
  414. }
  415. .sea_ipt {
  416. width: 682rpx;
  417. height: 70rpx;
  418. line-height: 70rpx;
  419. box-sizing: border-box;
  420. background: #f9f9f9;
  421. font-size: 26rpx;
  422. color: #4a4a4a;
  423. padding: 0 180rpx 0 78rpx;
  424. border-radius: 70rpx;
  425. }
  426. .sea_ico {
  427. width: 31rpx;
  428. height: 31rpx;
  429. position: absolute;
  430. left: 68rpx;
  431. top: 50%;
  432. transform: translateY(-50%);
  433. }
  434. .ipt-right {
  435. display: flex;
  436. align-items: center;
  437. position: absolute;
  438. right: 59rpx;
  439. top: 50%;
  440. transform: translateY(-50%);
  441. color: #3385ff;
  442. .line {
  443. margin: 0 21rpx;
  444. color: #e0e0e0;
  445. }
  446. }
  447. }
  448. .search-cont {
  449. padding: 32rpx;
  450. font-size: 24rpx;
  451. margin-top: -80rpx;
  452. color: #666666;
  453. background-color: #fff;
  454. height: calc(100vh - 135rpx);
  455. overflow: hidden;
  456. .title {
  457. font-size: 32rpx;
  458. font-weight: 500;
  459. color: #333333;
  460. }
  461. .history {
  462. height: 270rpx;
  463. .history-title {
  464. display: flex;
  465. align-items: center;
  466. justify-content: space-between;
  467. .empty_ico {
  468. width: 36rpx;
  469. height: 36rpx;
  470. }
  471. }
  472. .history-item {
  473. width: 100%;
  474. overflow: hidden;
  475. display: flex;
  476. flex-wrap: wrap;
  477. .item {
  478. background-color: #f9f9f9;
  479. padding: 10rpx 20rpx;
  480. margin: 20rpx 20rpx 0 0;
  481. border-radius: 4rpx;
  482. }
  483. }
  484. }
  485. }
  486. .search-tabs {
  487. display: flex;
  488. align-items: center;
  489. justify-content: center;
  490. width: 100%;
  491. font-size: 32rpx;
  492. color: #333333;
  493. padding-left: 35rpx;
  494. overflow: hidden;
  495. overflow-x: auto;
  496. background-color: #fff;
  497. margin-bottom: 10rpx;
  498. .tabs-item {
  499. margin-right: 50rpx;
  500. flex-shrink: 0;
  501. padding-bottom: 10rpx;
  502. position: relative;
  503. .item-act {
  504. width: 80%;
  505. position: absolute;
  506. bottom: 0;
  507. left: 50%;
  508. transform: translateX(-50%);
  509. height: 4rpx;
  510. border-radius: 21px;
  511. background: linear-gradient(90deg, #2e85ff 0%, #7eeaf6 100%);
  512. }
  513. }
  514. .active {
  515. color: #4791ff;
  516. font-weight: 500;
  517. }
  518. }
  519. .content {
  520. width: 100%;
  521. background-color: #f5f6fa;
  522. }
  523. .nodata {
  524. font-size: 40rpx;
  525. .bind-mobile {
  526. width: 244rpx;
  527. height: 58rpx;
  528. background: #3385ff;
  529. border-radius: 8rpx;
  530. font-size: 28rpx;
  531. line-height: 58rpx;
  532. text-align: center;
  533. color: #fff;
  534. margin: 50rpx auto;
  535. }
  536. }
  537. .more-box {
  538. display: flex;
  539. height: 88rpx;
  540. padding: 0 30rpx;
  541. align-items: center;
  542. justify-content: space-between;
  543. font-size: 28rpx;
  544. background-color: #f5f6fa;
  545. position: sticky;
  546. left: 0;
  547. z-index: 99;
  548. .more-text {
  549. font-weight: 500;
  550. color: #333333;
  551. &::before {
  552. content: "";
  553. display: inline-block;
  554. height: 20rpx;
  555. width: 4rpx;
  556. background-color: #3189ff;
  557. margin-right: 20rpx;
  558. }
  559. }
  560. .more-rivet {
  561. color: #3385ff;
  562. margin-left: 20rpx;
  563. }
  564. }
  565. .summary-select {
  566. display: flex;
  567. align-items: center;
  568. width: 252rpx;
  569. background-color: #f9f9f9;
  570. color: #999999;
  571. font-size: 24rpx;
  572. height: 51rpx;
  573. border-radius: 47rpx;
  574. box-shadow: 0rpx 0rpx 4rpx 0rpx rgba(0, 0, 0, 0.09);
  575. overflow: hidden;
  576. .select-item {
  577. display: flex;
  578. align-items: center;
  579. justify-content: center;
  580. width: 50%;
  581. height: 100%;
  582. border-radius: 47rpx;
  583. }
  584. .active-item {
  585. background-color: #3385ff;
  586. color: #fff;
  587. }
  588. }
  589. .activity-select {
  590. padding-right: 34rpx;
  591. height: 88rpx;
  592. position: sticky;
  593. top: 184rpx;
  594. left: 0;
  595. z-index: 99;
  596. background-color: #f5f6fa;
  597. }
  598. .more-summary {
  599. top: 184rpx;
  600. }
  601. .more-report {
  602. top: 184rpx;
  603. z-index: 100;
  604. }
  605. .more-activity {
  606. top: 184rpx;
  607. z-index: 101;
  608. }
  609. }
  610. </style>
  611. <style lang="scss">
  612. #container-report-page {
  613. .industry-video-module {
  614. .global-video-box {
  615. .video-content {
  616. top: 400rpx !important;
  617. }
  618. .close-icon {
  619. top: 330rpx !important;
  620. }
  621. }
  622. }
  623. }
  624. </style>