index.vue 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458
  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. showStatus: 1
  168. },
  169. goodsList: [],
  170. };
  171. },
  172. mounted() {
  173. this.params.goodsName = this.$route.query.searchKey || "";
  174. // this.params.searchKey = this.$route.query.searchKey || "";
  175. this.params.educationTypeId = this.$route.query.educationId || "";
  176. this.params.projectId = this.$route.query.projectId || "";
  177. this.params.businessId = this.$route.query.businessId || "";
  178. if (this.params.businessId) {
  179. this.getSubjectList();
  180. }
  181. this.getEducationTypeList();
  182. },
  183. methods: {
  184. ...mapMutations(["getCartCount"]),
  185. search(key) {
  186. this.params.goodsName = key || "";
  187. // this.params.searchKey = key || "";
  188. this.params.projectId = "";
  189. this.params.educationTypeId = "";
  190. this.params.businessId = "";
  191. this.params.subjectId = "";
  192. this.changeSubject();
  193. },
  194. changeSort(sortType) {
  195. if (this.params.sortType == sortType) return;
  196. this.params.sortType = sortType;
  197. this.changeSubject();
  198. },
  199. currentChange(e) {
  200. this.params.pageNum = e;
  201. this.changeSubject();
  202. },
  203. toGoodsDetail(item) {
  204. this.$router.push({
  205. path: "/course-detail/" + item.goodsId,
  206. });
  207. },
  208. addCart(item) {
  209. this.$request
  210. .addCart({ goodsId: item.goodsId })
  211. .then((res) => {
  212. this.getCartCount();
  213. this.$message({
  214. message: "加入购物车成功",
  215. type: "success",
  216. });
  217. })
  218. .catch((err) => {
  219. if (err.code == 500) {
  220. this.$message({
  221. message: err.msg,
  222. type: "warning",
  223. });
  224. }
  225. });
  226. },
  227. /**
  228. * 切换教育类型
  229. */
  230. changeType(item) {
  231. if (this.params.educationTypeId == item.id) {
  232. return;
  233. }
  234. this.params.projectId = "";
  235. this.params.educationTypeId = item.id;
  236. this.params.businessId = "";
  237. this.businessList = [];
  238. this.params.subjectId = "";
  239. this.subjectList = [];
  240. this.params.pageNum = 1;
  241. this.getBusinessList();
  242. this.changeSubject();
  243. },
  244. /**
  245. * 切换科目分类
  246. */
  247. changeSubject(item) {
  248. if (item) {
  249. if (this.params.subjectId != item.id) {
  250. this.params.subjectId = item.id;
  251. this.params.pageNum = 1;
  252. }
  253. }
  254. this.$request.goodsList(this.params).then((res) => {
  255. this.goodsList = res.rows;
  256. this.total = res.total;
  257. });
  258. },
  259. /**
  260. * 获取科目分类
  261. */
  262. getSubjectList() {
  263. this.$request
  264. .subjectList({
  265. businessId: this.params.businessId,
  266. projectId: this.projectId,
  267. educationId: this.params.educationTypeId,
  268. })
  269. .then((res) => {
  270. this.subjectList = res.rows;
  271. this.subjectList.unshift({ id: 0, subjectName: "全部" });
  272. this.params.subjectId = 0;
  273. this.changeSubject(this.subjectList[0]);
  274. });
  275. },
  276. /**
  277. * 切换业务层级
  278. */
  279. changeBusiness(item) {
  280. if (this.params.subjectId == item.id) {
  281. return;
  282. }
  283. this.params.businessId = item.id;
  284. this.projectId = item.projectId;
  285. this.params.subjectId = "";
  286. this.subjectList = [];
  287. this.params.pageNum = 1;
  288. this.getSubjectList();
  289. },
  290. /**
  291. * 获取业务层级
  292. */
  293. getBusinessList() {
  294. this.$request
  295. .businessList({ educationId: this.params.educationTypeId })
  296. .then((res) => {
  297. this.businessList = res.rows.filter((item) => item.aliasName);
  298. this.projectId = this.businessList[0].projectId;
  299. });
  300. },
  301. /**
  302. * 获取教育类型
  303. */
  304. getEducationTypeList() {
  305. this.$request.educationTypeList().then((res) => {
  306. this.typeList = res.rows;
  307. //有传入教育类型
  308. if (this.params.educationTypeId) {
  309. this.getBusinessList();
  310. } else {
  311. this.params.educationTypeId = res.rows[0].id;
  312. this.getBusinessList();
  313. }
  314. this.changeSubject();
  315. });
  316. },
  317. },
  318. };
  319. </script>
  320. <!-- Add "scoped" attribute to limit CSS to this component only -->
  321. <style scoped lang="scss">
  322. .payment {
  323. .section {
  324. &__header {
  325. height: 40px;
  326. display: flex;
  327. align-items: center;
  328. padding: 0 20px;
  329. }
  330. &__body {
  331. background: #ebf2fc;
  332. .course-classify {
  333. overflow: hidden;
  334. &__list {
  335. display: flex;
  336. margin: 6px 0;
  337. align-items: flex-start;
  338. .left-item {
  339. margin-top: 10px;
  340. padding: 8px 0;
  341. width: 80px;
  342. font-size: 16px;
  343. font-family: Microsoft YaHei;
  344. font-weight: 400;
  345. color: #333333;
  346. }
  347. .right-item {
  348. flex: 1;
  349. .list {
  350. display: flex;
  351. flex-wrap: wrap;
  352. .item {
  353. cursor: pointer;
  354. border-radius: 8px;
  355. margin: 10px;
  356. padding: 8px 16px;
  357. color: #666666;
  358. font-size: 16px;
  359. background: #f7f9fc;
  360. color: #999;
  361. &.active {
  362. color: #fff;
  363. background: #3f8dfd;
  364. }
  365. }
  366. }
  367. }
  368. }
  369. }
  370. }
  371. &__footer {
  372. .course-list {
  373. &__header {
  374. margin-top: 32px;
  375. .sort-list {
  376. display: flex;
  377. align-items: center;
  378. &__item {
  379. cursor: pointer;
  380. width: 96px;
  381. height: 32px;
  382. border-radius: 16px;
  383. background: #ffffff;
  384. border: 1px solid #bfbfbf;
  385. border-radius: 16px;
  386. text-align: center;
  387. line-height: 30px;
  388. font-size: 16px;
  389. margin-right: 20px;
  390. &.active {
  391. background: #ebf2fc;
  392. border: 1px solid #3f8dfd;
  393. border-radius: 16px;
  394. color: #3f8dfd;
  395. }
  396. }
  397. }
  398. }
  399. &__body {
  400. .list {
  401. width: 100%;
  402. .course-item {
  403. float: left;
  404. }
  405. }
  406. }
  407. &__footer {
  408. overflow: hidden;
  409. .btn {
  410. cursor: pointer;
  411. width: 146px;
  412. height: 40px;
  413. background: #e3eaf7;
  414. border-radius: 8px;
  415. margin: 20px auto 40px;
  416. color: #3f8dfd;
  417. text-align: center;
  418. line-height: 40px;
  419. &:hover {
  420. color: #fff;
  421. box-shadow: 0px 8px 4px 0px rgba(7, 82, 208, 0.08);
  422. background: #3f8dfd;
  423. }
  424. }
  425. }
  426. }
  427. .pagination {
  428. padding: 30px 0;
  429. text-align: center;
  430. }
  431. }
  432. }
  433. }
  434. </style>