Seekresult.vue 9.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367
  1. <template>
  2. <!-- 搜索结果 -->
  3. <div class="SeekResult" v-loading="loading" v-if="isData">
  4. <!-- 头部导航及搜索 -->
  5. <Header />
  6. <HeaderOne
  7. :changeKeycode="changeKeycode"
  8. :keycode="keycode"
  9. :title="$t('Key248')"
  10. :classilfyID="classilfyID"
  11. />
  12. <!-- <div class="top">
  13. <div class="title">SEARCH RESULT</div>
  14. </div> -->
  15. <div class="main">
  16. <!-- 搜索结果分类 -->
  17. <div class="classilfy">
  18. <div
  19. v-for="(item, i) in classilfyList"
  20. :key="i + item"
  21. @click="cutClassilfy(item, i)"
  22. :class="classilfyIndex == i ? 'sele' : ''"
  23. >
  24. {{ item }}
  25. </div>
  26. </div>
  27. <template v-if="dataList && dataList.total_count !== 0">
  28. <div class="class_list" v-if="dataList">
  29. <!-- 根据课程和教材进行分别传值 -->
  30. <component
  31. :is="getCurrentQuestionView"
  32. :classList="
  33. classilfyIndex == 0 ? dataList.course_list : dataList.book_list
  34. "
  35. type="list"
  36. ></component>
  37. <!-- <ClassicalCourse
  38. :classList="
  39. classilfyIndex == 0 ? dataList.course_list : dataList.book_list
  40. "
  41. type="1"
  42. /> -->
  43. <div class="paging">
  44. <el-pagination
  45. background
  46. @size-change="handleSizeChange"
  47. @current-change="handleCurrentChange"
  48. :page-sizes="pageSizes"
  49. layout="prev, pager, next,total, sizes,jumper"
  50. :current-page="pageNum"
  51. :page-size="pageSize"
  52. :total="dataList.total_count"
  53. >
  54. </el-pagination>
  55. </div>
  56. </div>
  57. </template>
  58. <template v-else>
  59. <div class="nomore">
  60. <img src="../../assets/learncenter/noSeekResult.png" alt="" />
  61. <p class="p1">
  62. <!-- 抱歉,我找不到相关的内容。 -->
  63. {{ $t('Key547') }}
  64. </p>
  65. <!-- <p class="p2">Try the following keywords</p> -->
  66. <!-- <div class="keywords">
  67. <span>live lesson</span>
  68. <span>live lesson</span>
  69. <span>live lesson</span>
  70. </div> -->
  71. </div>
  72. </template>
  73. </div>
  74. </div>
  75. </template>
  76. <script>
  77. import { cousrseAPI, TextbookAPI } from '@/api/api'
  78. import Header from '@/components/Header'
  79. import HeaderOne from '@/components/learnCenter/HeaderOne'
  80. import ClassicalCourse from '@/components/learnCenter/ClassicalCourse'
  81. import Course from '@/components/learnCenter/Course'
  82. import Textbook from '@/components/learnCenter/Textbook'
  83. import { updateWordPack } from '@/utils/i18n'
  84. export default {
  85. props: [],
  86. components: {
  87. Header,
  88. HeaderOne,
  89. ClassicalCourse,
  90. Course,
  91. Textbook,
  92. },
  93. data() {
  94. return {
  95. CourseList: null, //课程列表
  96. TextList: null, //教材列表
  97. dataList: null, //展示列表
  98. seekContent: '', //搜索内容
  99. gotoPage: '',
  100. keycode: '',
  101. pageNum: 1,
  102. pageSize: 8,
  103. targetPage: 1,
  104. loading: false,
  105. classilfyList: [],
  106. classilfyIndex: 0,
  107. classilfyID: null,
  108. isData: false,
  109. pageSizes: [8, 16, 32, 64],
  110. pageSizes1: [8, 16, 32, 64],
  111. pageSizes2: [10, 20, 30, 40],
  112. }
  113. },
  114. computed: {
  115. getCurrentQuestionView() {
  116. switch (this.classilfyIndex) {
  117. case 0:
  118. return Course
  119. case 1:
  120. return Textbook
  121. default:
  122. return null
  123. }
  124. },
  125. },
  126. watch: {
  127. classilfyIndex(newval, oldval) {
  128. if (newval != oldval) {
  129. if (newval == 0) {
  130. this.pageNum = 1
  131. this.pageSizes = this.pageSizes1
  132. this.getData('课程')
  133. } else if (newval == 1) {
  134. this.pageNum = 1
  135. this.pageSizes = this.pageSizes2
  136. this.getData('教材')
  137. }
  138. }
  139. },
  140. },
  141. methods: {
  142. handleSizeChange(val) {
  143. this.pageNum = 1
  144. this.pageSize = val
  145. if (this.classilfyIndex == 0) {
  146. this.getData('课程')
  147. } else if (this.classilfyIndex == 1) {
  148. this.getData('教材')
  149. }
  150. },
  151. // 跳页
  152. handleCurrentChange(val) {
  153. this.pageNum = val
  154. if (this.classilfyIndex == 0) {
  155. this.getData('课程')
  156. } else if (this.classilfyIndex == 1) {
  157. this.getData('教材')
  158. }
  159. },
  160. // 切换分类
  161. cutClassilfy(item, i) {
  162. this.classilfyIndex = i
  163. },
  164. // 获取子组件传过来的keycode进行查询
  165. changeKeycode(val) {
  166. this.keycode = val
  167. if (this.classilfyIndex == 0) {
  168. this.getData('课程')
  169. } else if (this.classilfyIndex == 1) {
  170. this.getData('教材')
  171. }
  172. },
  173. // 输入目标页 并跳到目标页
  174. toPageChange() {
  175. this.gotoPage = this.gotoPage.replace(/[^\d]/g, '') //使用空字符串去替换非数字的字符
  176. if (this.gotoPage > Math.ceil(this.CourseList.total / 8)) {
  177. return
  178. } else if (this.gotoPage != this.targetPage) {
  179. this.targetPage = this.gotoPage * 1
  180. this.pageNum = this.gotoPage * 1
  181. if (this.classilfyIndex == 0) {
  182. this.getData('课程')
  183. } else if (this.classilfyIndex == 1) {
  184. this.getData('教材')
  185. }
  186. }
  187. },
  188. // 获取数据
  189. getData(val) {
  190. this.loading = true
  191. if (val == '课程') {
  192. // 获取课程列表
  193. cousrseAPI('page_query-PageQueryCourseList', {
  194. page_capacity: this.pageSize,
  195. cur_page: this.pageNum,
  196. finish_status: 53,
  197. release_status: 1,
  198. name_or_teacher_name: this.keycode,
  199. }).then((res) => {
  200. this.dataList = res
  201. this.dataList.course_list.forEach((item, index) => {
  202. item.teacherName = item.teacher_name_desc.replace(/;/g, ' ')
  203. })
  204. this.CourseList = res
  205. this.loading = false
  206. })
  207. } else {
  208. TextbookAPI('book-book_manager-PageQueryBookList', {
  209. cur_page: this.pageNum,
  210. page_capacity: this.pageSize == 8 ? this.pageSize + 2 : this.pageSize,
  211. name: this.keycode,
  212. publish_status: 1,
  213. is_control_publish_scope: 'true',
  214. is_enable_book_org_free_license_query: 'true',
  215. order_column_list: ['name'],
  216. sys_version_type: -1,
  217. }).then((res) => {
  218. this.TextList = res
  219. if (val == '教材') {
  220. this.dataList = null
  221. this.dataList = this.TextList
  222. this.loading = false
  223. }
  224. })
  225. }
  226. },
  227. },
  228. async created() {
  229. this.keycode = this.$route.query.keycode
  230. this.classilfyID = this.$route.query.id
  231. // classilfyIndex
  232. // if (this.$route.query.id == "COURSE") {
  233. this.classilfyIndex = 0
  234. this.getData('课程')
  235. // } else {
  236. // this.getData("教材");
  237. // this.classilfyIndex = 1;
  238. // }
  239. await updateWordPack({
  240. word_key_list: [
  241. 'Key8',
  242. 'Key38',
  243. 'Key39',
  244. 'Key573',
  245. 'Key44',
  246. 'Key215',
  247. 'Key248',
  248. 'Key323',
  249. 'Key547',
  250. ],
  251. })
  252. this.isData = true
  253. this.classilfyList = [this.$t('Key215'), this.$t('Key44')]
  254. },
  255. }
  256. </script>
  257. <style lang="scss" scoped>
  258. .SeekResult {
  259. min-height: 100vh;
  260. background: #f6f6f6;
  261. .top {
  262. width: 95%;
  263. margin: 0 auto;
  264. display: flex;
  265. justify-content: space-between;
  266. align-items: flex-end;
  267. .title {
  268. margin-top: 36px;
  269. font-weight: bold;
  270. font-size: 30px;
  271. }
  272. .title2 {
  273. margin-top: 36px;
  274. font-weight: bold;
  275. font-size: 16px;
  276. color: rgba(0, 0, 0, 0.5);
  277. span {
  278. color: black;
  279. }
  280. }
  281. .more {
  282. cursor: pointer;
  283. color: rgba(0, 0, 0, 0.5);
  284. margin-right: 40px;
  285. }
  286. }
  287. .main {
  288. min-height: 568px;
  289. padding-top: 24px;
  290. background: #f6f6f6;
  291. padding-bottom: 20px;
  292. .classilfy {
  293. display: flex;
  294. width: 1200px;
  295. margin: 0 auto;
  296. margin-top: 16px;
  297. margin-bottom: 16px;
  298. > div {
  299. min-width: 52px;
  300. height: 32px;
  301. display: flex;
  302. justify-content: center;
  303. align-items: center;
  304. cursor: pointer;
  305. padding: 0 10px;
  306. }
  307. .sele {
  308. background: #ff9900;
  309. border-radius: 53px;
  310. color: white;
  311. }
  312. }
  313. }
  314. .paging {
  315. width: 1200px;
  316. margin: 0 auto;
  317. display: flex;
  318. align-items: center;
  319. color: darkgrey;
  320. padding: 32px 0;
  321. .number {
  322. color: black;
  323. }
  324. span {
  325. margin-left: 10px;
  326. }
  327. .gotoPage {
  328. width: 40px;
  329. text-align: center;
  330. }
  331. }
  332. .nomore {
  333. margin-top: 80px;
  334. text-align: center;
  335. .p1 {
  336. font-weight: 600;
  337. font-size: 32px;
  338. color: #2c2c2c;
  339. margin-top: 20px;
  340. }
  341. .p2 {
  342. font-size: 28px;
  343. color: #2c2c2c;
  344. margin-top: 20px;
  345. }
  346. .keywords {
  347. span {
  348. display: inline-block;
  349. // width: 129px;
  350. // height: 55px;
  351. padding: 16px;
  352. background: rgba(44, 44, 44, 0.1);
  353. border-radius: 31px;
  354. color: rgba(44, 44, 44, 0.5);
  355. font-size: 18px;
  356. // line-height: 55px;
  357. margin: 20px 20px 20px 20px;
  358. cursor: pointer;
  359. }
  360. }
  361. }
  362. }
  363. </style>