submit.vue 4.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147
  1. <template>
  2. <div class="app-container">
  3. <!-- 支付信息 -->
  4. <el-card v-loading="loading">
  5. <el-descriptions title="支付信息" :column="3" border>
  6. <el-descriptions-item label="支付单号">{{ payOrder.id }}</el-descriptions-item>
  7. <el-descriptions-item label="商品标题">{{ payOrder.subject }}</el-descriptions-item>
  8. <el-descriptions-item label="商品内容">{{ payOrder.body }}</el-descriptions-item>
  9. <el-descriptions-item label="支付金额">¥{{ (payOrder.amount / 100.0).toFixed(2) }}</el-descriptions-item>
  10. <el-descriptions-item label="创建时间">{{ parseTime(payOrder.createTime) }}</el-descriptions-item>
  11. <el-descriptions-item label="过期时间">{{ parseTime(payOrder.expireTime) }}</el-descriptions-item>
  12. </el-descriptions>
  13. </el-card>
  14. <!-- 微信支付 -->
  15. <el-card style="margin-top: 10px">
  16. <!-- 支付宝 -->
  17. <el-descriptions title="选择支付宝支付">
  18. </el-descriptions>
  19. <div class="pay-channel-container">
  20. <div class="box" v-for="channel in aliPayChannels" :key="channel.code">
  21. <img :src="icons[channel.code]">
  22. <div class="title">{{ channel.name }}</div>
  23. </div>
  24. </div>
  25. <!-- 微信支付 -->
  26. <el-descriptions title="选择微信支付" style="margin-top: 20px;" />
  27. <div class="pay-channel-container">
  28. <div class="box" v-for="channel in wxPayChannels" :key="channel.code">
  29. <img :src="icons[channel.code]">
  30. <div class="title">{{ channel.name }}</div>
  31. </div>
  32. </div>
  33. <!-- 其它支付 -->
  34. <el-descriptions title="选择其它支付" style="margin-top: 20px;" />
  35. <div class="pay-channel-container">
  36. <div class="box" v-for="channel in otherPayChannels" :key="channel.code">
  37. <img :src="icons[channel.code]">
  38. <div class="title">{{ channel.name }}</div>
  39. </div>
  40. </div>
  41. </el-card>
  42. </div>
  43. </template>
  44. <script>
  45. import { DICT_TYPE, getDictDatas } from "@/utils/dict";
  46. import { getOrder } from '@/api/pay/order';
  47. import { PayOrderStatusEnum } from "@/utils/constants";
  48. export default {
  49. name: "PayOrderSubmit",
  50. components: {
  51. },
  52. data() {
  53. return {
  54. id: undefined, // 请假编号
  55. loading: false, // 支付信息的 loading
  56. payOrder: {}, // 支付信息
  57. aliPayChannels: [], // 阿里支付的渠道
  58. wxPayChannels: [], // 微信支付的渠道
  59. otherPayChannels: [], // 其它的支付渠道
  60. icons: {
  61. alipay_qr: require("@/assets/images/pay/icon/alipay_qr.svg"),
  62. alipay_app: require("@/assets/images/pay/icon/alipay_app.svg"),
  63. alipay_wap: require("@/assets/images/pay/icon/alipay_wap.svg"),
  64. alipay_pc: require("@/assets/images/pay/icon/alipay_pc.svg"),
  65. wx_app: require("@/assets/images/pay/icon/wx_app.svg"),
  66. wx_lite: require("@/assets/images/pay/icon/wx_lite.svg"),
  67. wx_pub: require("@/assets/images/pay/icon/wx_pub.svg"),
  68. mock: require("@/assets/images/pay/icon/mock.svg"),
  69. },
  70. };
  71. },
  72. created() {
  73. this.id = this.$route.query.id;
  74. this.getDetail();
  75. this.initPayChannels();
  76. },
  77. methods: {
  78. /** 初始化支付渠道 */
  79. initPayChannels() {
  80. // 微信支付
  81. for (const dict of getDictDatas(DICT_TYPE.PAY_CHANNEL_CODE_TYPE)) {
  82. const payChannel = {
  83. name: dict.label,
  84. code: dict.value
  85. }
  86. if (dict.value.indexOf('wx_') === 0) {
  87. this.wxPayChannels.push(payChannel);
  88. } else if (dict.value.indexOf('alipay_') === 0) {
  89. this.aliPayChannels.push(payChannel);
  90. } else {
  91. this.otherPayChannels.push(payChannel);
  92. }
  93. }
  94. },
  95. /** 获得请假信息 */
  96. getDetail() {
  97. // 1.1 未传递订单编号
  98. if (!this.id) {
  99. this.$message.error('未传递支付单号,无法查看对应的支付信息');
  100. this.$router.go(-1);
  101. return;
  102. }
  103. getOrder(this.id).then(response => {
  104. // 1.2 无法查询到支付信息
  105. if (!response.data) {
  106. this.$message.error('支付订单不存在,请检查!');
  107. this.$router.go(-1);
  108. return;
  109. }
  110. // 1.3 订单已支付
  111. if (response.data.status !== PayOrderStatusEnum.WAITING.status) {
  112. this.$message.error('支付订单不处于待支付状态,请检查!');
  113. this.$router.go(-1);
  114. return;
  115. }
  116. // 2. 可以展示
  117. this.payOrder = response.data;
  118. });
  119. },
  120. }
  121. };
  122. </script>
  123. <style lang="scss" scoped>
  124. .pay-channel-container {
  125. display: flex;
  126. margin-top: -10px;
  127. .box {
  128. width: 130px;
  129. border: 1px solid #e6ebf5;
  130. cursor: pointer;
  131. text-align: center;
  132. padding-top: 10px;
  133. padding-bottom: 5px;
  134. margin-right: 10px;
  135. img {
  136. width: 40px;
  137. height: 40px;
  138. }
  139. .title {
  140. padding-top: 5px
  141. }
  142. }
  143. }
  144. </style>