index.vue 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511
  1. <template>
  2. <div class="payment">
  3. <Header></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.projectName }} - {{ item.businessName }}
  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. @click="goodsDetail(item)"
  112. >
  113. <div class="course-item__img">
  114. <img
  115. :src="$tools.splitImgHost(item.coverUrl, true)"
  116. alt=""
  117. />
  118. <div class="note" v-if="item.year">{{ item.year }}</div>
  119. </div>
  120. <div class="course-item__title">
  121. {{ item.goodsName }}
  122. </div>
  123. <div class="course-item__desc">
  124. <div class="price">¥{{ item.standPrice | toFixed }}</div>
  125. <a class="add" @click.stop="addCart(item)">加购物车</a>
  126. </div>
  127. </li>
  128. </ul>
  129. </div>
  130. </div>
  131. <div class="pagination">
  132. <el-pagination
  133. @current-change="currentChange"
  134. background
  135. layout="prev, pager, next"
  136. :total="total"
  137. :pager-count="5"
  138. :page-size="params.pageSize"
  139. >
  140. </el-pagination>
  141. </div>
  142. </div>
  143. </div>
  144. </section>
  145. <ToolBar></ToolBar>
  146. <Footer></Footer>
  147. </div>
  148. </template>
  149. <script>
  150. import Footer from "@/components/footer/index";
  151. import Header from "@/components/header/index";
  152. import ToolBar from "@/components/toolbar/index";
  153. export default {
  154. name: "PaymentSuccess",
  155. components: {
  156. Footer,
  157. Header,
  158. ToolBar,
  159. },
  160. data() {
  161. return {
  162. projectId: "",
  163. typeList: [],
  164. businessList: [],
  165. subjectList: [],
  166. total: 0,
  167. params: {
  168. projectId: "",
  169. educationTypeId: "",
  170. businessId: "",
  171. subjectId: "",
  172. pageNum: 1,
  173. pageSize: 12,
  174. goodsStatus: 1,
  175. goodsType: 1,
  176. sortType: 1,
  177. },
  178. goodsList: [],
  179. };
  180. },
  181. mounted() {
  182. this.params.educationTypeId = this.$route.query.educationId;
  183. this.params.projectId = this.$route.query.projectId;
  184. this.params.businessId = this.$route.query.businessId;
  185. this.getEducationTypeList();
  186. this.changeSubject();
  187. },
  188. methods: {
  189. changeSort(sortType) {
  190. if (this.params.sortType == sortType) return;
  191. this.params.sortType = sortType;
  192. this.changeSubject();
  193. },
  194. currentChange(e) {
  195. this.params.pageNum = e;
  196. this.changeSubject();
  197. },
  198. goodsDetail(item) {
  199. this.$router.push({
  200. path: "/course-detail/" + item.goodsId,
  201. });
  202. },
  203. addCart(item) {
  204. this.$request
  205. .addCart({ goodsId: item.goodsId })
  206. .then((res) => {
  207. this.$message({
  208. message: "加入购物车成功",
  209. type: "success",
  210. });
  211. })
  212. .catch((err) => {
  213. this.$message({
  214. message: err.msg,
  215. type: "warning",
  216. });
  217. });
  218. },
  219. changeType(item) {
  220. if (this.params.educationTypeId == item.id) {
  221. return;
  222. }
  223. this.params.educationTypeId = item.id;
  224. this.params.businessId = "";
  225. this.businessList = [];
  226. this.params.subjectId = "";
  227. this.subjectList = [];
  228. this.params.pageNum = 1;
  229. this.getBusinessList();
  230. this.changeSubject();
  231. },
  232. changeSubject(item) {
  233. if (item) {
  234. if (this.params.subjectId != item.id) {
  235. this.params.subjectId = item.id;
  236. this.params.pageNum = 1;
  237. }
  238. }
  239. this.$request.goodsList(this.params).then((res) => {
  240. this.goodsList = res.rows;
  241. this.total = res.total;
  242. });
  243. },
  244. getSubjectList() {
  245. this.$request
  246. .subjectList({
  247. businessId: this.params.businessId,
  248. projectId: this.projectId,
  249. educationId: this.params.educationTypeId,
  250. })
  251. .then((res) => {
  252. this.subjectList = res.rows;
  253. this.subjectList.unshift({ id: 0, subjectName: "全部" });
  254. this.params.subjectId = 0;
  255. this.changeSubject(this.subjectList[0]);
  256. });
  257. },
  258. changeBusiness(item) {
  259. if (this.params.subjectId == item.id) {
  260. return;
  261. }
  262. this.params.businessId = item.id;
  263. this.projectId = item.projectId;
  264. this.params.subjectId = "";
  265. this.subjectList = [];
  266. this.params.pageNum = 1;
  267. this.getSubjectList();
  268. },
  269. getBusinessList() {
  270. this.$request
  271. .businessList({ educationId: this.params.educationTypeId })
  272. .then((res) => {
  273. this.businessList = res.rows;
  274. this.projectId = this.businessList[0].projectId;
  275. });
  276. },
  277. getEducationTypeList() {
  278. this.$request.educationTypeList().then((res) => {
  279. this.typeList = res.rows;
  280. if (this.params.educationTypeId) {
  281. this.getBusinessList();
  282. }
  283. });
  284. },
  285. },
  286. };
  287. </script>
  288. <!-- Add "scoped" attribute to limit CSS to this component only -->
  289. <style scoped lang="scss">
  290. .payment {
  291. .section {
  292. &__header {
  293. height: 40px;
  294. display: flex;
  295. align-items: center;
  296. padding: 0 20px;
  297. }
  298. &__body {
  299. background: #f5f7fa;
  300. .course-classify {
  301. overflow: hidden;
  302. &__list {
  303. display: flex;
  304. margin: 24px 0;
  305. align-items: flex-start;
  306. .left-item {
  307. padding: 8px 0;
  308. width: 80px;
  309. font-size: 16px;
  310. font-family: Microsoft YaHei;
  311. font-weight: 400;
  312. color: #333333;
  313. }
  314. .right-item {
  315. flex: 1;
  316. .list {
  317. display: flex;
  318. flex-wrap: wrap;
  319. .item {
  320. cursor: pointer;
  321. border-radius: 8px;
  322. margin: 0 10px;
  323. padding: 8px 16px;
  324. color: #666666;
  325. font-size: 16px;
  326. &.active {
  327. color: #fff;
  328. background: #3f8dfd;
  329. }
  330. }
  331. }
  332. }
  333. }
  334. }
  335. }
  336. &__footer {
  337. .course-list {
  338. &__header {
  339. margin-top: 32px;
  340. .sort-list {
  341. display: flex;
  342. align-items: center;
  343. &__item {
  344. cursor: pointer;
  345. width: 96px;
  346. height: 32px;
  347. border-radius: 16px;
  348. text-align: center;
  349. line-height: 32px;
  350. margin-right: 20px;
  351. &.active {
  352. color: #fff;
  353. background: #666666;
  354. }
  355. }
  356. }
  357. }
  358. &__body {
  359. .list {
  360. width: 100%;
  361. .course-item {
  362. float: left;
  363. margin: 110px 9px 0;
  364. width: 300px;
  365. height: 178px;
  366. background: #ffffff;
  367. box-shadow: 0px 10px 13px 3px rgba(63, 141, 253, 0.1);
  368. border-radius: 10px;
  369. position: relative;
  370. background: #fff;
  371. padding-top: 100px;
  372. cursor: pointer;
  373. &__img {
  374. width: 280px;
  375. height: 178px;
  376. background: #ffffff;
  377. box-shadow: 0px 0px 9px 1px rgba(0, 0, 0, 0.08);
  378. border-radius: 10px;
  379. position: absolute;
  380. left: 10px;
  381. top: -78px;
  382. overflow: hidden;
  383. img {
  384. max-width: 100%;
  385. max-width: 100%;
  386. width: 100%;
  387. height: auto;
  388. }
  389. .note {
  390. position: absolute;
  391. left: 0;
  392. top: 0;
  393. width: 80px;
  394. height: 24px;
  395. background: #d94404;
  396. box-shadow: 0px 1px 1px 0px rgba(248, 78, 5, 0.4);
  397. border-radius: 10px 0px 20px 0px;
  398. text-align: center;
  399. line-height: 24px;
  400. color: #fff;
  401. }
  402. }
  403. &__title {
  404. margin: 0 8px;
  405. font-size: 14px;
  406. font-family: Microsoft YaHei;
  407. font-weight: 400;
  408. color: #333333;
  409. line-height: 24px;
  410. overflow: hidden;
  411. text-overflow: ellipsis;
  412. display: -webkit-box;
  413. -webkit-line-clamp: 2;
  414. -webkit-box-orient: vertical;
  415. }
  416. &__desc {
  417. height: 32px;
  418. position: absolute;
  419. left: 0;
  420. right: 0;
  421. bottom: 0;
  422. margin-left: 8px;
  423. display: flex;
  424. justify-content: space-between;
  425. .price {
  426. font-size: 18px;
  427. font-family: Microsoft YaHei;
  428. font-weight: bold;
  429. color: #ff2d55;
  430. line-height: 32px;
  431. }
  432. .add {
  433. display: block;
  434. width: 118px;
  435. height: 32px;
  436. line-height: 30px;
  437. background: #f2f4f7;
  438. border-radius: 10px 0px 10px 0px;
  439. font-size: 16px;
  440. color: #3f8dfd;
  441. text-align: center;
  442. &:hover {
  443. background: #3f8dfd;
  444. color: #f2f4f7;
  445. }
  446. }
  447. }
  448. }
  449. }
  450. }
  451. &__footer {
  452. overflow: hidden;
  453. .btn {
  454. cursor: pointer;
  455. width: 146px;
  456. height: 40px;
  457. background: #e3eaf7;
  458. border-radius: 8px;
  459. margin: 20px auto 40px;
  460. color: #3f8dfd;
  461. text-align: center;
  462. line-height: 40px;
  463. &:hover {
  464. color: #fff;
  465. box-shadow: 0px 8px 4px 0px rgba(7, 82, 208, 0.08);
  466. background: #3f8dfd;
  467. }
  468. }
  469. }
  470. }
  471. .pagination {
  472. padding: 30px 0;
  473. text-align: center;
  474. }
  475. }
  476. }
  477. }
  478. </style>