index.vue 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457
  1. <template>
  2. <div class="payment">
  3. <Header @search="search($event)"></Header>
  4. <section class="section">
  5. <div class="section__header">
  6. <div class="container">
  7. <el-breadcrumb separator="/">
  8. <el-breadcrumb-item :to="{ path: '/index' }"
  9. >首页</el-breadcrumb-item
  10. >
  11. <el-breadcrumb-item>课程</el-breadcrumb-item>
  12. </el-breadcrumb>
  13. </div>
  14. </div>
  15. <div class="section__body">
  16. <div class="container">
  17. <div class="course-classify">
  18. <div class="course-classify__list">
  19. <div class="left-item">教育类型:</div>
  20. <div class="right-item">
  21. <div class="list">
  22. <!-- <div
  23. class="item"
  24. :class="{ active: typeKey == '' }"
  25. @click="changeType('')"
  26. >
  27. 全部
  28. </div> -->
  29. <div
  30. class="item"
  31. v-for="(item, index) in typeList"
  32. :key="index"
  33. :class="{ active: params.educationTypeId == item.id }"
  34. @click="changeType(item)"
  35. >
  36. {{ item.educationName }}
  37. </div>
  38. </div>
  39. </div>
  40. </div>
  41. <div class="course-classify__list" v-if="businessList.length > 0">
  42. <div class="left-item">培训项目:</div>
  43. <div class="right-item">
  44. <div class="list">
  45. <!-- <div class="item active">全部</div> -->
  46. <div
  47. class="item"
  48. v-for="(item, index) in businessList"
  49. :key="index"
  50. :class="{ active: params.businessId == item.id }"
  51. @click="changeBusiness(item)"
  52. >
  53. {{ item.aliasName }}
  54. </div>
  55. </div>
  56. </div>
  57. </div>
  58. <div class="course-classify__list" v-if="subjectList.length > 0">
  59. <div class="left-item">科目分类:</div>
  60. <div class="right-item">
  61. <div class="list">
  62. <div
  63. class="item"
  64. v-for="(item, index) in subjectList"
  65. :key="index"
  66. :class="{ active: params.subjectId == item.id }"
  67. @click="changeSubject(item)"
  68. >
  69. {{ item.subjectName }}
  70. </div>
  71. </div>
  72. </div>
  73. </div>
  74. </div>
  75. </div>
  76. </div>
  77. <div class="section__footer">
  78. <div class="container">
  79. <div class="course-list">
  80. <div class="course-list__header">
  81. <div class="sort-list">
  82. <div
  83. class="sort-list__item"
  84. @click="changeSort(1)"
  85. :class="{ active: params.sortType == 1 ? true : false }"
  86. >
  87. 综合排序
  88. </div>
  89. <div
  90. class="sort-list__item"
  91. @click="changeSort(2)"
  92. :class="{ active: params.sortType == 2 ? true : false }"
  93. >
  94. 低价优先
  95. </div>
  96. <div
  97. class="sort-list__item"
  98. @click="changeSort(3)"
  99. :class="{ active: params.sortType == 3 ? true : false }"
  100. >
  101. 高价优先
  102. </div>
  103. </div>
  104. </div>
  105. <div class="course-list__body">
  106. <ul class="list clearfix">
  107. <li
  108. class="course-item"
  109. v-for="(item, index) in goodsList"
  110. :key="index"
  111. >
  112. <GoodsItem :item="item"></GoodsItem>
  113. </li>
  114. </ul>
  115. </div>
  116. </div>
  117. <div class="pagination">
  118. <el-pagination
  119. @current-change="currentChange"
  120. background
  121. layout="prev, pager, next"
  122. :total="total"
  123. :pager-count="5"
  124. :page-size="params.pageSize"
  125. >
  126. </el-pagination>
  127. </div>
  128. </div>
  129. </div>
  130. </section>
  131. <ToolBar></ToolBar>
  132. <Footer></Footer>
  133. </div>
  134. </template>
  135. <script>
  136. import Footer from "@/components/footer/index";
  137. import Header from "@/components/header/index";
  138. import ToolBar from "@/components/toolbar/index";
  139. import GoodsItem from "@/components/goodsItem/index";
  140. import { mapMutations } from "vuex";
  141. export default {
  142. name: "PaymentSuccess",
  143. components: {
  144. Footer,
  145. Header,
  146. ToolBar,
  147. GoodsItem,
  148. },
  149. data() {
  150. return {
  151. projectId: "",
  152. typeList: [],
  153. businessList: [],
  154. subjectList: [],
  155. total: 0,
  156. params: {
  157. projectId: "",
  158. educationTypeId: "",
  159. businessId: "",
  160. subjectId: "",
  161. pageNum: 1,
  162. pageSize: 15,
  163. goodsStatus: 1,
  164. goodsType: 1,
  165. sortType: 1,
  166. searchKey: "",
  167. },
  168. goodsList: [],
  169. };
  170. },
  171. mounted() {
  172. this.params.goodsName = this.$route.query.searchKey || "";
  173. // this.params.searchKey = this.$route.query.searchKey || "";
  174. this.params.educationTypeId = this.$route.query.educationId || "";
  175. this.params.projectId = this.$route.query.projectId || "";
  176. this.params.businessId = this.$route.query.businessId || "";
  177. if (this.params.businessId) {
  178. this.getSubjectList();
  179. }
  180. this.getEducationTypeList();
  181. },
  182. methods: {
  183. ...mapMutations(["getCartCount"]),
  184. search(key) {
  185. this.params.goodsName = key || "";
  186. // this.params.searchKey = key || "";
  187. this.params.projectId = "";
  188. this.params.educationTypeId = "";
  189. this.params.businessId = "";
  190. this.params.subjectId = "";
  191. this.changeSubject();
  192. },
  193. changeSort(sortType) {
  194. if (this.params.sortType == sortType) return;
  195. this.params.sortType = sortType;
  196. this.changeSubject();
  197. },
  198. currentChange(e) {
  199. this.params.pageNum = e;
  200. this.changeSubject();
  201. },
  202. toGoodsDetail(item) {
  203. this.$router.push({
  204. path: "/course-detail/" + item.goodsId,
  205. });
  206. },
  207. addCart(item) {
  208. this.$request
  209. .addCart({ goodsId: item.goodsId })
  210. .then((res) => {
  211. this.getCartCount();
  212. this.$message({
  213. message: "加入购物车成功",
  214. type: "success",
  215. });
  216. })
  217. .catch((err) => {
  218. if (err.code == 500) {
  219. this.$message({
  220. message: err.msg,
  221. type: "warning",
  222. });
  223. }
  224. });
  225. },
  226. /**
  227. * 切换教育类型
  228. */
  229. changeType(item) {
  230. if (this.params.educationTypeId == item.id) {
  231. return;
  232. }
  233. this.params.projectId = "";
  234. this.params.educationTypeId = item.id;
  235. this.params.businessId = "";
  236. this.businessList = [];
  237. this.params.subjectId = "";
  238. this.subjectList = [];
  239. this.params.pageNum = 1;
  240. this.getBusinessList();
  241. this.changeSubject();
  242. },
  243. /**
  244. * 切换科目分类
  245. */
  246. changeSubject(item) {
  247. if (item) {
  248. if (this.params.subjectId != item.id) {
  249. this.params.subjectId = item.id;
  250. this.params.pageNum = 1;
  251. }
  252. }
  253. this.$request.goodsList(this.params).then((res) => {
  254. this.goodsList = res.rows;
  255. this.total = res.total;
  256. });
  257. },
  258. /**
  259. * 获取科目分类
  260. */
  261. getSubjectList() {
  262. this.$request
  263. .subjectList({
  264. businessId: this.params.businessId,
  265. projectId: this.projectId,
  266. educationId: this.params.educationTypeId,
  267. })
  268. .then((res) => {
  269. this.subjectList = res.rows;
  270. this.subjectList.unshift({ id: 0, subjectName: "全部" });
  271. this.params.subjectId = 0;
  272. this.changeSubject(this.subjectList[0]);
  273. });
  274. },
  275. /**
  276. * 切换业务层级
  277. */
  278. changeBusiness(item) {
  279. if (this.params.subjectId == item.id) {
  280. return;
  281. }
  282. this.params.businessId = item.id;
  283. this.projectId = item.projectId;
  284. this.params.subjectId = "";
  285. this.subjectList = [];
  286. this.params.pageNum = 1;
  287. this.getSubjectList();
  288. },
  289. /**
  290. * 获取业务层级
  291. */
  292. getBusinessList() {
  293. this.$request
  294. .businessList({ educationId: this.params.educationTypeId })
  295. .then((res) => {
  296. this.businessList = res.rows.filter((item) => item.aliasName);
  297. this.projectId = this.businessList[0].projectId;
  298. });
  299. },
  300. /**
  301. * 获取教育类型
  302. */
  303. getEducationTypeList() {
  304. this.$request.educationTypeList().then((res) => {
  305. this.typeList = res.rows;
  306. //有传入教育类型
  307. if (this.params.educationTypeId) {
  308. this.getBusinessList();
  309. } else {
  310. this.params.educationTypeId = res.rows[0].id;
  311. this.getBusinessList();
  312. }
  313. this.changeSubject();
  314. });
  315. },
  316. },
  317. };
  318. </script>
  319. <!-- Add "scoped" attribute to limit CSS to this component only -->
  320. <style scoped lang="scss">
  321. .payment {
  322. .section {
  323. &__header {
  324. height: 40px;
  325. display: flex;
  326. align-items: center;
  327. padding: 0 20px;
  328. }
  329. &__body {
  330. background: #ebf2fc;
  331. .course-classify {
  332. overflow: hidden;
  333. &__list {
  334. display: flex;
  335. margin: 6px 0;
  336. align-items: flex-start;
  337. .left-item {
  338. margin-top: 10px;
  339. padding: 8px 0;
  340. width: 80px;
  341. font-size: 16px;
  342. font-family: Microsoft YaHei;
  343. font-weight: 400;
  344. color: #333333;
  345. }
  346. .right-item {
  347. flex: 1;
  348. .list {
  349. display: flex;
  350. flex-wrap: wrap;
  351. .item {
  352. cursor: pointer;
  353. border-radius: 8px;
  354. margin: 10px;
  355. padding: 8px 16px;
  356. color: #666666;
  357. font-size: 16px;
  358. background: #f7f9fc;
  359. color: #999;
  360. &.active {
  361. color: #fff;
  362. background: #3f8dfd;
  363. }
  364. }
  365. }
  366. }
  367. }
  368. }
  369. }
  370. &__footer {
  371. .course-list {
  372. &__header {
  373. margin-top: 32px;
  374. .sort-list {
  375. display: flex;
  376. align-items: center;
  377. &__item {
  378. cursor: pointer;
  379. width: 96px;
  380. height: 32px;
  381. border-radius: 16px;
  382. background: #ffffff;
  383. border: 1px solid #bfbfbf;
  384. border-radius: 16px;
  385. text-align: center;
  386. line-height: 30px;
  387. font-size: 16px;
  388. margin-right: 20px;
  389. &.active {
  390. background: #ebf2fc;
  391. border: 1px solid #3f8dfd;
  392. border-radius: 16px;
  393. color: #3f8dfd;
  394. }
  395. }
  396. }
  397. }
  398. &__body {
  399. .list {
  400. width: 100%;
  401. .course-item {
  402. float: left;
  403. }
  404. }
  405. }
  406. &__footer {
  407. overflow: hidden;
  408. .btn {
  409. cursor: pointer;
  410. width: 146px;
  411. height: 40px;
  412. background: #e3eaf7;
  413. border-radius: 8px;
  414. margin: 20px auto 40px;
  415. color: #3f8dfd;
  416. text-align: center;
  417. line-height: 40px;
  418. &:hover {
  419. color: #fff;
  420. box-shadow: 0px 8px 4px 0px rgba(7, 82, 208, 0.08);
  421. background: #3f8dfd;
  422. }
  423. }
  424. }
  425. }
  426. .pagination {
  427. padding: 30px 0;
  428. text-align: center;
  429. }
  430. }
  431. }
  432. }
  433. </style>