index.vue 7.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322
  1. <template>
  2. <div class="payment">
  3. <Header></Header>
  4. <section class="section">
  5. <div class="container">
  6. <div class="section__header">
  7. <div class="icon">✔</div>
  8. <div class="title">购买成功</div>
  9. </div>
  10. <div class="section__body">
  11. <div class="order-msg">
  12. <div class="order-msg__body">
  13. <div class="goods_item">订单编号:{{ orderSn }}</div>
  14. <div class="goods_item">
  15. 订单金额:
  16. <span>{{ total | toFixed }} 元</span>
  17. </div>
  18. <div class="links" v-if="isBK">
  19. <a @click="go('/person-center/my-course')">返回我的网课</a>
  20. <el-button
  21. type="primary"
  22. size="small"
  23. round
  24. @click="
  25. go('/person-center/my-classhour/appointment', {
  26. goodsId: goodsId,
  27. gradeId: gradeId,
  28. orderGoodsId: orderGoodsId,
  29. })
  30. "
  31. >继续本次考试预约</el-button
  32. >
  33. </div>
  34. <div class="links" v-else>
  35. <a @click="go('/person-center/my-order', { state: '2' })"
  36. >查看订单详情</a
  37. >
  38. <el-button type="primary" size="small" round @click="go('/')"
  39. >继续逛逛</el-button
  40. >
  41. </div>
  42. </div>
  43. </div>
  44. </div>
  45. <div
  46. class="section__footer"
  47. v-if="recommendList.goodsList && recommendList.goodsList.length"
  48. >
  49. <div class="recommend">
  50. <div class="recommend__header">
  51. <div class="title">相关推荐</div>
  52. </div>
  53. <div class="recommend__body">
  54. <ul class="list clearfix">
  55. <li
  56. class="recommend-item"
  57. v-for="(itemy, index) in compyRecommend(
  58. recommendList.goodsList
  59. )"
  60. :key="index"
  61. >
  62. <GoodsItem :item="itemy"></GoodsItem>
  63. </li>
  64. </ul>
  65. </div>
  66. <div class="recommend__footer">
  67. <div class="btn" @click="comeMoreList">查看更多</div>
  68. </div>
  69. </div>
  70. </div>
  71. </div>
  72. </section>
  73. <ToolBar></ToolBar>
  74. <Footer></Footer>
  75. </div>
  76. </template>
  77. <script>
  78. import Footer from "@/components/footer/index";
  79. import Header from "@/components/header/index";
  80. import ToolBar from "@/components/toolbar/index";
  81. import GoodsItem from "@/components/goodsItem/index";
  82. export default {
  83. name: "PaymentSuccess",
  84. components: {
  85. Footer,
  86. Header,
  87. ToolBar,
  88. GoodsItem,
  89. },
  90. data() {
  91. return {
  92. isBK: "",
  93. orderSn: "",
  94. total: 0,
  95. goodsId: 0,
  96. gradeId: 0,
  97. orderGoodsId: 0,
  98. recommendList: [],
  99. goodsDetail: {},
  100. };
  101. },
  102. computed: {
  103. compyRecommend: function () {
  104. return function (array) {
  105. let ary = [];
  106. if (array) {
  107. for (let i = 0; i < array.length; i++) {
  108. if (i >= 5) {
  109. break;
  110. } else {
  111. ary.push(array[i]);
  112. }
  113. }
  114. }
  115. return ary;
  116. };
  117. },
  118. },
  119. mounted() {
  120. this.orderSn = this.$route.query.orderSn;
  121. // this.total = this.$route.params.total;
  122. this.isBK = this.$route.query.isBK;
  123. this.goodsId = this.$route.query.goodsId;
  124. this.gradeId = this.$route.query.gradeId;
  125. this.orderGoodsId = this.$route.query.orderGoodsId;
  126. if (this.goodsId) {
  127. this.$request.commonGoodsDetail(this.goodsId).then((res) => {
  128. this.goodsDetail = res.data;
  129. this.getRecommend();
  130. });
  131. }
  132. this.orderDetail();
  133. },
  134. methods: {
  135. orderDetail() {
  136. this.$request.orderDetail(this.orderSn).then((res) => {
  137. this.total = res.data.orderPrice;
  138. });
  139. },
  140. addCart(status, goodsId) {
  141. if (!this.$tools.isLogin()) {
  142. this.setCurrentRouter(this.$route);
  143. this.$router.push({
  144. path: "/login",
  145. });
  146. return;
  147. }
  148. this.$request
  149. .addCart({ goodsId: status ? goodsId : this.goodsId })
  150. .then((res) => {
  151. this.getCartCount();
  152. this.$message({
  153. message: "加入购物车成功",
  154. type: "success",
  155. });
  156. })
  157. .catch((err) => {
  158. if (err.code == 500) {
  159. this.$message({
  160. message: err.msg,
  161. type: "warning",
  162. });
  163. }
  164. });
  165. },
  166. toGoodsDetail(item) {
  167. this.$router.push({
  168. path: "/course-detail/" + item.goodsId,
  169. });
  170. },
  171. /**
  172. * 查看更多
  173. */
  174. comeMoreList() {
  175. this.$router.push({
  176. path: "/course-list",
  177. query: {
  178. educationId: this.goodsDetail.educationTypeId,
  179. projectId: this.goodsDetail.projectId,
  180. businessId: this.goodsDetail.businessId,
  181. },
  182. });
  183. },
  184. /**
  185. *
  186. 获取推荐列表
  187. */
  188. getRecommend() {
  189. this.$request
  190. .appCommonActivityRecommendList({
  191. businessId: this.goodsDetail.businessId,
  192. type: this.goodsDetail.goodsType,
  193. })
  194. .then((res) => {
  195. if (res.rows.length) {
  196. this.recommendList = res.rows[0];
  197. }
  198. });
  199. },
  200. go(path, query) {
  201. this.$router.push({
  202. path,
  203. query,
  204. });
  205. },
  206. },
  207. };
  208. </script>
  209. <!-- Add "scoped" attribute to limit CSS to this component only -->
  210. <style scoped lang="scss">
  211. .payment {
  212. .section {
  213. &__header {
  214. height: 80px;
  215. background: #ebf3ff;
  216. display: flex;
  217. align-items: center;
  218. padding: 0 20px;
  219. .icon {
  220. width: 40px;
  221. height: 40px;
  222. background: rgba(52, 199, 89, 1);
  223. line-height: 40px;
  224. color: #fff;
  225. font-size: 18px;
  226. text-align: center;
  227. box-shadow: 0px 0px 9px 1px rgba(63, 141, 253, 0.3);
  228. border-radius: 50%;
  229. }
  230. .title {
  231. margin-left: 20px;
  232. flex: 1;
  233. font-size: 30px;
  234. font-family: Microsoft YaHei;
  235. font-weight: 400;
  236. color: #333333;
  237. }
  238. }
  239. &__body {
  240. .order-msg {
  241. border-bottom: 2px solid #eee;
  242. &__body {
  243. padding-left: 80px;
  244. .goods_item {
  245. margin: 16px 0;
  246. }
  247. .links {
  248. padding-top: 8px;
  249. padding-bottom: 10px;
  250. a {
  251. margin-right: 40px;
  252. color: #3f8dfd;
  253. }
  254. }
  255. }
  256. }
  257. }
  258. &__footer {
  259. .recommend {
  260. padding-top: 40px;
  261. &__header {
  262. display: flex;
  263. align-items: center;
  264. .title {
  265. font-size: 24px;
  266. font-family: YouSheBiaoTiHei;
  267. font-weight: 400;
  268. color: #333333;
  269. text-shadow: 0px 6px 6px rgba(249, 113, 13, 0.08);
  270. }
  271. }
  272. &__body {
  273. .list {
  274. width: 100%;
  275. .recommend-item {
  276. float: left;
  277. }
  278. }
  279. }
  280. &__footer {
  281. overflow: hidden;
  282. .btn {
  283. cursor: pointer;
  284. width: 146px;
  285. height: 40px;
  286. background: #e3eaf7;
  287. border-radius: 8px;
  288. margin: 20px auto 40px;
  289. color: #3f8dfd;
  290. text-align: center;
  291. line-height: 40px;
  292. &:hover {
  293. color: #fff;
  294. box-shadow: 0px 8px 4px 0px rgba(7, 82, 208, 0.08);
  295. background: #3f8dfd;
  296. }
  297. }
  298. }
  299. }
  300. }
  301. }
  302. }
  303. </style>