Seekresult.vue 9.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382
  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"
  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: this.keycode,
  199. }).then((res) => {
  200. this.dataList = res
  201. this.dataList.course_list.forEach((item, index) => {
  202. let teacher_list = [
  203. {
  204. teacher_name: '张仪',
  205. },
  206. {
  207. teacher_name: '吴先文',
  208. },
  209. {
  210. teacher_name: '韦所所',
  211. },
  212. {
  213. teacher_name: '罗蒙',
  214. },
  215. ]
  216. item.teacherName = teacher_list
  217. .map(function(obj, index) {
  218. return obj.teacher_name
  219. })
  220. .join(' ')
  221. })
  222. this.CourseList = res
  223. this.loading = false
  224. })
  225. } else {
  226. TextbookAPI('book-book_manager-PageQueryBookList', {
  227. cur_page: this.pageNum,
  228. page_capacity: this.pageSize == 8 ? this.pageSize + 2 : this.pageSize,
  229. name: this.keycode,
  230. publish_status: 1,
  231. is_control_publish_scope: 'true',
  232. }).then((res) => {
  233. this.TextList = res
  234. if (val == '教材') {
  235. this.dataList = null
  236. this.dataList = this.TextList
  237. this.loading = false
  238. }
  239. })
  240. }
  241. },
  242. },
  243. async created() {
  244. this.keycode = this.$route.query.keycode
  245. this.classilfyID = this.$route.query.id
  246. // classilfyIndex
  247. // if (this.$route.query.id == "COURSE") {
  248. this.classilfyIndex = 0
  249. this.getData('课程')
  250. // } else {
  251. // this.getData("教材");
  252. // this.classilfyIndex = 1;
  253. // }
  254. await updateWordPack({
  255. word_key_list: [
  256. 'Key8',
  257. 'Key38',
  258. 'Key39',
  259. 'Key573',
  260. 'Key44',
  261. 'Key215',
  262. 'Key248',
  263. 'Key323',
  264. 'Key547',
  265. ],
  266. })
  267. this.isData = true
  268. this.classilfyList = [this.$t('Key215'), this.$t('Key44')]
  269. },
  270. }
  271. </script>
  272. <style lang="scss" scoped>
  273. .SeekResult {
  274. min-height: 100vh;
  275. background: #f6f6f6;
  276. .top {
  277. width: 95%;
  278. margin: 0 auto;
  279. display: flex;
  280. justify-content: space-between;
  281. align-items: flex-end;
  282. .title {
  283. margin-top: 36px;
  284. font-weight: bold;
  285. font-size: 30px;
  286. }
  287. .title2 {
  288. margin-top: 36px;
  289. font-weight: bold;
  290. font-size: 16px;
  291. color: rgba(0, 0, 0, 0.5);
  292. span {
  293. color: black;
  294. }
  295. }
  296. .more {
  297. cursor: pointer;
  298. color: rgba(0, 0, 0, 0.5);
  299. margin-right: 40px;
  300. }
  301. }
  302. .main {
  303. min-height: 568px;
  304. padding-top: 24px;
  305. background: #f6f6f6;
  306. padding-bottom: 20px;
  307. .classilfy {
  308. display: flex;
  309. width: 1200px;
  310. margin: 0 auto;
  311. margin-top: 16px;
  312. margin-bottom: 16px;
  313. > div {
  314. min-width: 52px;
  315. height: 32px;
  316. display: flex;
  317. justify-content: center;
  318. align-items: center;
  319. cursor: pointer;
  320. padding: 0 10px;
  321. }
  322. .sele {
  323. background: #ff9900;
  324. border-radius: 53px;
  325. color: white;
  326. }
  327. }
  328. }
  329. .paging {
  330. width: 1200px;
  331. margin: 0 auto;
  332. display: flex;
  333. align-items: center;
  334. color: darkgrey;
  335. padding: 32px 0;
  336. .number {
  337. color: black;
  338. }
  339. span {
  340. margin-left: 10px;
  341. }
  342. .gotoPage {
  343. width: 40px;
  344. text-align: center;
  345. }
  346. }
  347. .nomore {
  348. margin-top: 80px;
  349. text-align: center;
  350. .p1 {
  351. font-weight: 600;
  352. font-size: 32px;
  353. color: #2c2c2c;
  354. margin-top: 20px;
  355. }
  356. .p2 {
  357. font-size: 28px;
  358. color: #2c2c2c;
  359. margin-top: 20px;
  360. }
  361. .keywords {
  362. span {
  363. display: inline-block;
  364. // width: 129px;
  365. // height: 55px;
  366. padding: 16px;
  367. background: rgba(44, 44, 44, 0.1);
  368. border-radius: 31px;
  369. color: rgba(44, 44, 44, 0.5);
  370. font-size: 18px;
  371. // line-height: 55px;
  372. margin: 20px 20px 20px 20px;
  373. cursor: pointer;
  374. }
  375. }
  376. }
  377. }
  378. </style>