indedxSearch.vue 19 KB

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