index.vue 13 KB

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