searchDetail.vue 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674
  1. <template>
  2. <div class="search-detail" v-loading="loading">
  3. <Header
  4. :headerBg="'#299772'"
  5. :headerBorder="'#30A47D'"
  6. :userBg="'rgba(0, 0, 0, 0.08)'"
  7. :LoginNavIndex="-1"
  8. />
  9. <div class="banner">
  10. <a class="goback" @click="$router.go(-1)"
  11. ><i class="el-icon-arrow-left"></i>返回</a
  12. >
  13. <div class="banner-inner">
  14. <img src="../../assets/icon-search-small.png" />
  15. <SearchInput
  16. class="search-compent"
  17. :searchQuery="searchQuery"
  18. :selectIndex="selectIndex"
  19. @changeSelectIndex="changeSelectIndex"
  20. />
  21. </div>
  22. </div>
  23. <div class="main">
  24. <!-- <ul class="typelist">
  25. <li class="typeitem" :class="[typeIndex===indexT?'active':'']" v-for="(itemT,indexT) in typeList" :key="indexT" @click="handleTypeIndex('typeIndex',indexT)">
  26. <svg-icon :icon-class="itemT.img" className="icon-img"></svg-icon>
  27. <span class="OPPOSans">{{itemT.name}}</span>
  28. <b class="OPPOSans">{{itemT.value}}</b>
  29. </li>
  30. </ul> -->
  31. <div class="main-inner">
  32. <!-- <ul v-if="typeList && typeList.length > 0" class="gradelist">
  33. <li
  34. :class="['gradeitem', indeG === typeIndex ? 'active' : '']"
  35. v-for="(itemG, indeG) in typeList"
  36. :key="indeG"
  37. @click="handleTypeIndex('typeIndex', indeG)"
  38. >
  39. {{ itemG.name + " " + itemG.value }}
  40. </li>
  41. </ul> -->
  42. <ul v-if="gradeList && gradeList.length > 0" class="gradelist">
  43. <li
  44. :class="['gradeitem', itemG.id === gradeIndex ? 'active' : '']"
  45. v-for="(itemG, indeG) in gradeList"
  46. :key="indeG"
  47. @click="handleTypeIndex('gradeIndex', itemG.id)"
  48. >
  49. {{ itemG.name }}
  50. </li>
  51. </ul>
  52. <ul v-if="yearList && yearList.length > 0" class="gradelist">
  53. <li
  54. :class="['gradeitem', itemG.value === yearIndex ? 'active' : '']"
  55. v-for="(itemG, indeG) in yearList"
  56. :key="indeG"
  57. @click="handleTypeIndex('yearIndex', itemG.value)"
  58. >
  59. {{ itemG.label }}
  60. </li>
  61. </ul>
  62. <p class="timeconsume">
  63. {{ courseTotal }}条结果,耗时
  64. {{ takeTime >= 1000 ? takeTime / 1000 + "s" : takeTime + "ms" }}。
  65. </p>
  66. <div class="searchChangebox">
  67. <div
  68. class="searchChange"
  69. :class="[item.sortName == sortField ? 'active' : '']"
  70. v-for="(item, indexC) in changeList"
  71. :key="indexC"
  72. >
  73. <span>
  74. {{ item.name }}
  75. </span>
  76. <div :class="['sort']">
  77. <div>
  78. <svg-icon
  79. icon-class="up"
  80. className="icon-up"
  81. :class="[item.sort == 'up' ? 'active' : '']"
  82. @click="SortEvent('up', item.name, item.sortName)"
  83. ></svg-icon>
  84. </div>
  85. <div>
  86. <svg-icon
  87. icon-class="down"
  88. className="icon-down"
  89. :class="[item.sort == 'down' ? 'active' : '']"
  90. @click="SortEvent('down', item.name, item.sortName)"
  91. ></svg-icon>
  92. </div>
  93. </div>
  94. </div>
  95. </div>
  96. <template v-if="searchList && searchList.length > 0">
  97. <div
  98. class="search-item"
  99. v-for="(itemS, indexS) in searchList"
  100. :key="indexS"
  101. @click="handleLink(itemS)"
  102. >
  103. <el-image :src="itemS.iss_cover_url" :fit="'cover'"> </el-image>
  104. <div class="search-inner">
  105. <div class="top">
  106. <h2 v-html="itemS.title"></h2>
  107. <span v-html="itemS.author"></span>
  108. </div>
  109. <div class="content" v-html="itemS.content"></div>
  110. <div class="bottom">
  111. <span v-if="itemS.iss_no">{{ itemS.iss_no }}</span>
  112. <span v-if="itemS.study_phase_name">{{
  113. itemS.study_phase_name
  114. }}</span>
  115. <span v-if="itemS.wc">长度:{{ itemS.wc }}</span>
  116. <span v-if="itemS.wdc">词数:{{ itemS.wdc }}</span>
  117. </div>
  118. </div>
  119. </div>
  120. <el-pagination
  121. background
  122. :current-page="currentPage"
  123. :page-size="page_capacity"
  124. :page-sizes="[10, 20, 30, 40, 50]"
  125. :total="courseTotal"
  126. layout="sizes, prev, pager, next, jumper"
  127. @current-change="handleCurrentChange"
  128. @size-change="handleSizeChange"
  129. />
  130. </template>
  131. <div class="nodata" v-else>
  132. <img src="../../assets/nodata.png" />
  133. <p>找不到文件</p>
  134. </div>
  135. </div>
  136. </div>
  137. </div>
  138. </template>
  139. <script>
  140. //这里可以导入其它文件(比如:组件,工具js,第三方插件js,json文件,图片文件等等)
  141. //例如:import 《组件名称》from ‘《组件路径》';
  142. import Header from "../../components/Header.vue";
  143. import SearchInput from "./components/SearchInput.vue";
  144. import BookCard from "@/components/common/BookCard.vue";
  145. import { getLogin } from "@/api/ajax";
  146. export default {
  147. //import引入的组件需要注入到对象中才能使用
  148. components: { Header, SearchInput, BookCard },
  149. props: {},
  150. data() {
  151. //这里存放数据
  152. return {
  153. searchQuery: this.$route.query.content ? this.$route.query.content : "",
  154. config: this.$route.query.headerConfig
  155. ? decodeURIComponent(this.$route.query.headerConfig)
  156. : "",
  157. LoginNavIndex: 0,
  158. userBg: "rgba(0, 0, 0, 0.24)",
  159. headerBorder: "#5C5C5C",
  160. headerBg: "#1F1F1F",
  161. selectIndex: this.$route.query.selectIndex
  162. ? this.$route.query.selectIndex * 1
  163. : 0,
  164. typeIndex: 0,
  165. gradeList: [
  166. {
  167. name: "全部",
  168. id: null,
  169. },
  170. ],
  171. yearList: [
  172. {
  173. label: "全部",
  174. value: null,
  175. },
  176. ],
  177. gradeIndex: null,
  178. yearIndex: null,
  179. sortType: 0,
  180. sortField: "",
  181. changeList: [
  182. {
  183. name: "长度",
  184. sort: "",
  185. sortName: "wc",
  186. },
  187. {
  188. name: "词数",
  189. sort: "",
  190. sortName: "wdc",
  191. },
  192. ],
  193. searchList: [],
  194. currentPage: 1, // 当前页码
  195. page_capacity: 10, // 每页条数
  196. courseTotal: 0, // 数据总条数
  197. timer: null,
  198. takeTime: 0, //耗时
  199. loading: false,
  200. };
  201. },
  202. //计算属性 类似于data概念
  203. computed: {},
  204. //监控data中数据变化
  205. watch: {
  206. searchQuery: {
  207. handler(val, oldVal) {
  208. if (val !== oldVal) {
  209. this.currentPage = 1;
  210. this.searchArticle();
  211. }
  212. },
  213. // 深度观察监听
  214. deep: true,
  215. },
  216. },
  217. //方法集合
  218. methods: {
  219. handleTypeIndex(type, index) {
  220. this[type] = index;
  221. this.currentPage = 1;
  222. this.searchArticle();
  223. },
  224. SortEvent(type, name, sortName) {
  225. let sort = "";
  226. this.changeList.forEach((item) => {
  227. if (item.name == name) {
  228. item.sort = type;
  229. sort = type;
  230. } else {
  231. item.sort = "";
  232. }
  233. });
  234. if (sort == "down") {
  235. this.sortType = 1;
  236. } else {
  237. this.sortType = 0;
  238. }
  239. this.sortField = sortName;
  240. this.currentPage = 1;
  241. this.searchArticle();
  242. },
  243. // 跳转文章
  244. handleLink(item) {
  245. let url = this.config + "&&&搜索";
  246. this.$router.push({
  247. path: "/articleDetail",
  248. query: {
  249. headerConfig: encodeURIComponent(url),
  250. iss_id: item.iss_id,
  251. id: item.art_id,
  252. },
  253. });
  254. },
  255. // 切换每页条数
  256. handleSizeChange(val) {
  257. this.currentPage = 1;
  258. this.page_capacity = val;
  259. this.searchArticle();
  260. },
  261. // 切换页码
  262. handleCurrentChange(val) {
  263. this.currentPage = val;
  264. this.searchArticle();
  265. },
  266. // 查询搜索内容
  267. searchArticle() {
  268. this.loading = true;
  269. this.takeTime = 0;
  270. this.timer = setInterval(() => {
  271. this.takeTime += 20;
  272. }, 20);
  273. let orderObj = null;
  274. if (this.sortField) {
  275. orderObj = {
  276. name: this.sortField,
  277. asc: !this.sortType,
  278. };
  279. }
  280. let MethodName = "/PaperServer/Client/Search/SearchArticle";
  281. let data = {
  282. word: this.searchQuery,
  283. page_size: this.page_capacity,
  284. page_no: this.currentPage,
  285. only_my_bought: this.selectIndex,
  286. study_phase: this.gradeIndex,
  287. release_year: this.yearIndex,
  288. order_bys: orderObj ? [orderObj] : [],
  289. };
  290. getLogin(MethodName, data)
  291. .then((res) => {
  292. clearInterval(this.timer);
  293. this.loading = false;
  294. if (res.status === 1) {
  295. this.courseTotal = res.data.total;
  296. this.searchList = res.data.results;
  297. this.yearList = [
  298. {
  299. value: null,
  300. label: "全部",
  301. },
  302. ];
  303. let yearList = [];
  304. if (res.data.exData && res.data.exData.years) {
  305. res.data.exData.years.forEach((nowYear) => {
  306. let obj = {
  307. value: nowYear,
  308. label: nowYear,
  309. };
  310. yearList.push(obj);
  311. });
  312. }
  313. this.yearList = this.yearList.concat(yearList);
  314. if (res.data.exData && res.data.exData.studyPhases) {
  315. let gradeList = [
  316. {
  317. id: null,
  318. name: "全部",
  319. },
  320. ];
  321. this.gradeList = gradeList.concat(res.data.exData.studyPhases);
  322. }
  323. }
  324. })
  325. .catch(() => {
  326. this.loading = false;
  327. clearInterval(this.timer);
  328. });
  329. },
  330. changeSelectIndex(val) {
  331. this.selectIndex = val;
  332. },
  333. },
  334. //生命周期 - 创建完成(可以访问当前this实例)
  335. created() {
  336. if (this.config) {
  337. let arr = this.config.split("&&&");
  338. this.LoginNavIndex = arr[0] * 1;
  339. this.userBg = arr[1];
  340. this.headerBorder = arr[2];
  341. this.headerBg = arr[3];
  342. }
  343. this.searchArticle();
  344. },
  345. //生命周期 - 挂载完成(可以访问DOM元素)
  346. mounted() {},
  347. //生命周期-创建之前
  348. beforeCreated() {},
  349. //生命周期-挂载之前
  350. beforeMount() {},
  351. //生命周期-更新之前
  352. beforUpdate() {},
  353. //生命周期-更新之后
  354. updated() {},
  355. //生命周期-销毁之前
  356. beforeDestory() {
  357. clearInterval(this.timer);
  358. },
  359. //生命周期-销毁完成
  360. destoryed() {},
  361. //如果页面有keep-alive缓存功能,这个函数会触发
  362. activated() {},
  363. };
  364. </script>
  365. <style lang="scss" scoped>
  366. /* @import url(); 引入css类 */
  367. .search-detail {
  368. width: 100%;
  369. .banner {
  370. width: 100%;
  371. height: 88px;
  372. background: #299772;
  373. position: relative;
  374. .goback {
  375. position: absolute;
  376. left: 24px;
  377. top: 24px;
  378. width: 96px;
  379. height: 40px;
  380. display: block;
  381. text-align: center;
  382. cursor: pointer;
  383. color: #ffffff;
  384. line-height: 40px;
  385. .el-icon-arrow-left {
  386. width: 24px;
  387. height: 24px;
  388. text-align: center;
  389. line-height: 24px;
  390. margin: 0 4px;
  391. }
  392. }
  393. .banner-inner {
  394. width: 868px;
  395. height: 100%;
  396. display: flex;
  397. align-items: center;
  398. justify-content: center;
  399. margin: 0 auto;
  400. position: relative;
  401. > img {
  402. width: 40px;
  403. margin-right: 24px;
  404. position: absolute;
  405. left: 50%;
  406. top: 24px;
  407. margin-left: -434px;
  408. }
  409. .search-compent {
  410. position: absolute;
  411. top: 16px;
  412. }
  413. }
  414. }
  415. .main {
  416. width: 100%;
  417. background: #ffffff;
  418. max-height: calc(100vh - 160px);
  419. overflow-y: scroll;
  420. &::-webkit-scrollbar {
  421. display: none;
  422. }
  423. .typelist {
  424. margin: 32px 0;
  425. padding: 0;
  426. list-style: none;
  427. display: flex;
  428. justify-content: space-between;
  429. li {
  430. width: 200px;
  431. height: 48px;
  432. border-radius: 30px;
  433. padding: 12px 24px;
  434. display: flex;
  435. align-items: center;
  436. cursor: pointer;
  437. border: 1px solid #e5e6eb;
  438. &.active {
  439. border-color: #3459d2;
  440. background: #eef3ff;
  441. .icon-img,
  442. span {
  443. color: #175dff;
  444. }
  445. b {
  446. color: #ed5f00;
  447. }
  448. }
  449. svg {
  450. width: 24px;
  451. height: 24px;
  452. margin-right: 16px;
  453. }
  454. span {
  455. color: #2f3742;
  456. font-weight: 700;
  457. font-size: 16px;
  458. line-height: 24px;
  459. flex: 1;
  460. }
  461. b {
  462. color: #929ca8;
  463. font-weight: 700;
  464. font-size: 16px;
  465. line-height: 24px;
  466. }
  467. }
  468. }
  469. .main-inner {
  470. width: 1200px;
  471. margin: 0 auto;
  472. // border-radius: 8px;
  473. padding: 34px 40px;
  474. ul {
  475. list-style: none;
  476. display: flex;
  477. flex-flow: wrap;
  478. padding: 0;
  479. margin: 0;
  480. li {
  481. padding: 8px 15px;
  482. cursor: pointer;
  483. margin: 6px 16px 6px 0;
  484. font-weight: 400;
  485. font-size: 16px;
  486. line-height: 22px;
  487. color: #2f3742;
  488. &.active {
  489. background: #e7eeff;
  490. border-radius: 4px;
  491. color: #175dff;
  492. }
  493. }
  494. }
  495. .searchChangebox {
  496. margin-top: 13px;
  497. display: flex;
  498. > div {
  499. display: flex;
  500. align-items: center;
  501. justify-content: space-between;
  502. padding: 8px 15px;
  503. height: 38px;
  504. margin-right: 16px;
  505. border-radius: 4px;
  506. &.active {
  507. background: #e7eeff;
  508. > span {
  509. color: #175dff;
  510. }
  511. .sort {
  512. > div {
  513. svg {
  514. &.active {
  515. color: #175dff;
  516. }
  517. }
  518. }
  519. }
  520. }
  521. > span {
  522. font-weight: 400;
  523. font-size: 16px;
  524. line-height: 22px;
  525. color: #2f3742;
  526. margin-right: 8px;
  527. }
  528. .sort {
  529. cursor: pointer;
  530. height: 20px;
  531. > div {
  532. font-size: 0;
  533. svg {
  534. width: 11px;
  535. height: 11px;
  536. color: #c2c2c2;
  537. padding: 3px 2px 2px 2px;
  538. &.icon-down {
  539. height: 9px;
  540. padding: 0 2px 2px 2px;
  541. }
  542. }
  543. }
  544. }
  545. }
  546. }
  547. .timeconsume {
  548. margin: 21px 0 0;
  549. font-weight: 400;
  550. font-size: 14px;
  551. line-height: 22px;
  552. color: rgba(0, 0, 0, 0.4);
  553. }
  554. .search-item {
  555. margin: 24px 0 50px 0;
  556. width: 100%;
  557. display: flex;
  558. cursor: pointer;
  559. .el-image {
  560. width: 110px;
  561. height: 110px;
  562. margin-right: 24px;
  563. }
  564. .search-inner {
  565. flex: 1;
  566. .top {
  567. display: flex;
  568. h2 {
  569. font-weight: 700;
  570. font-size: 16px;
  571. line-height: 24px;
  572. color: #2f3742;
  573. margin: 0 16px 0 0;
  574. font-family: "Rubik";
  575. }
  576. span {
  577. font-weight: 400;
  578. font-size: 16px;
  579. line-height: 24px;
  580. color: #929ca8;
  581. }
  582. }
  583. .content {
  584. margin: 8px 0;
  585. word-break: break-word;
  586. text-overflow: ellipsis;
  587. display: -webkit-box;
  588. -webkit-box-orient: vertical;
  589. -webkit-line-clamp: 2; /* 超出几行省略 */
  590. overflow: hidden;
  591. color: #2f3742;
  592. font-weight: 400;
  593. font-size: 16px;
  594. line-height: 24px;
  595. height: 48px;
  596. }
  597. .bottom {
  598. span {
  599. font-weight: 400;
  600. font-size: 16px;
  601. line-height: 24px;
  602. color: #929ca8;
  603. margin-right: 16px;
  604. }
  605. }
  606. }
  607. }
  608. .search-list {
  609. display: flex;
  610. flex-flow: wrap;
  611. width: 100%;
  612. .search-items {
  613. width: 200px;
  614. margin: 24px 30px 24px 0;
  615. flex-shrink: 0;
  616. &.margin0 {
  617. margin-right: 0;
  618. }
  619. .el-image {
  620. width: 200px;
  621. height: 280px;
  622. flex-shrink: 0;
  623. margin: 0;
  624. }
  625. .periodicalNumber {
  626. font-weight: 400;
  627. font-size: 14px;
  628. line-height: 22px;
  629. color: #2f3742;
  630. margin: 12px 12px 4px 12px;
  631. white-space: nowrap;
  632. overflow: hidden;
  633. text-overflow: ellipsis;
  634. }
  635. .date {
  636. font-size: 12px;
  637. line-height: 20px;
  638. color: #929ca8;
  639. margin: 0 12px 12px 12px;
  640. }
  641. .price {
  642. margin: 0 12px;
  643. align-items: flex-end;
  644. display: flex;
  645. :nth-child(1) {
  646. font-weight: 700;
  647. font-size: 14px;
  648. line-height: 22px;
  649. color: #ec5e41;
  650. }
  651. :nth-child(2) {
  652. font-weight: 400;
  653. font-size: 12px;
  654. line-height: 20px;
  655. text-decoration-line: line-through;
  656. color: #929ca8;
  657. margin-left: 8px;
  658. }
  659. }
  660. }
  661. }
  662. }
  663. }
  664. }
  665. </style>
  666. <style lang="scss">
  667. .search-detail {
  668. .lightbg {
  669. background: #fff500;
  670. }
  671. }
  672. </style>