pay.vue 2.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788
  1. <template>
  2. <div class="pay-card" v-loading="pageLoading">
  3. <h1 class="pay-card__title">
  4. 课程购买
  5. </h1>
  6. <el-table
  7. :data="courses"
  8. stripe
  9. class="pay-card__table"
  10. >
  11. <el-table-column
  12. label="课程"
  13. width="200">
  14. <template slot-scope="scope">
  15. <img :src="scope.row.picture" class="pay-card__picture"/>
  16. </template>
  17. </el-table-column>
  18. <el-table-column
  19. prop="course"
  20. >
  21. </el-table-column>
  22. <el-table-column
  23. prop="total"
  24. label="原价"
  25. width="100">
  26. </el-table-column>
  27. <el-table-column
  28. prop="num"
  29. label="数量"
  30. width="100">
  31. </el-table-column>
  32. <el-table-column
  33. prop="discount"
  34. label="折扣"
  35. width="100">
  36. </el-table-column>
  37. </el-table>
  38. <div class="pay-card__foot">
  39. <div class="pay-card__final">
  40. 合计:16.00元
  41. </div>
  42. <el-button type="primary" plain @click="pay">确认支付</el-button>
  43. </div>
  44. </div>
  45. </template>
  46. <script>
  47. export default {
  48. name: 'pay',
  49. data () {
  50. return {
  51. pageLoading: true,
  52. courses: [
  53. { course: 'JVM简要入门', total: '20.00', discount: '4.00', num: 1, picture: '/image/JVM.jpg' }
  54. ]
  55. }
  56. },
  57. mounted () {
  58. this.pageLoading = false
  59. },
  60. methods: {
  61. pay () {
  62. this.$api.post('http://pay.seec.seecoder.cn/api/alipay/pay', {
  63. userId: 794,
  64. productId: 1,
  65. subject: '测试支付',
  66. platformType: 'SEEC_I',
  67. price: 16,
  68. returnUrl: window.location.protocol + '//' + window.location.host + '/return'
  69. }).then(resp => {
  70. const divForm = document.getElementsByTagName('div')
  71. if (divForm.length) {
  72. document.body.removeChild(divForm[0])
  73. }
  74. const div = document.createElement('div')
  75. div.innerHTML = resp.data.res // data就是接口返回的form 表单字符串
  76. document.body.appendChild(div)
  77. document.forms[0].setAttribute('target', '_blank') // 新开窗口跳转
  78. document.forms[0].submit()
  79. })
  80. }
  81. }
  82. }
  83. </script>
  84. <style lang="scss" scoped>
  85. @import '~/assets/css/pay.scss';
  86. </style>