应用层PC端前端服务

payDialog.vue 3.4KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138
  1. <template>
  2. <div>
  3. <el-dialog
  4. :title="payTitle"
  5. :visible.sync="openPay"
  6. v-if="openPay"
  7. width="800px"
  8. append-to-body
  9. :destroy-on-close="true"
  10. >
  11. <el-descriptions title="订单信息">
  12. <el-descriptions-item label="案件编号:">{{
  13. form.caseNum
  14. }}</el-descriptions-item>
  15. <el-descriptions-item label="申请人:">{{
  16. form.applicant
  17. }}</el-descriptions-item>
  18. <el-descriptions-item label="案件标的:">{{
  19. form.caseSubjectAmount
  20. }}</el-descriptions-item>
  21. <el-descriptions-item label="案件应缴费用:">{{
  22. form.feePayable
  23. }}</el-descriptions-item>
  24. <el-descriptions-item label="被申请人:">{{
  25. form.respondent
  26. }}</el-descriptions-item>
  27. <el-descriptions-item label="申请人仲裁诉求:">{{
  28. form.arbitratClaims
  29. }}</el-descriptions-item>
  30. <el-descriptions-item label="案件状态:">{{
  31. form.caseStatusName
  32. }}</el-descriptions-item>
  33. </el-descriptions>
  34. <div class="payType">
  35. <span>请选择支付方式:</span>
  36. <i class="iconfont icon-weixinzhifu" @click="pay(0)"></i>
  37. <i class="iconfont icon-zhifubao" @click="pay(1)"></i>
  38. </div>
  39. <div class="payImg">
  40. <div id="qrcodeImg"></div>
  41. </div>
  42. <div class="payTitle">{{ payMain }}</div>
  43. <div slot="footer" class="dialog-footer">
  44. <el-button @click="payCancel">取 消</el-button>
  45. </div>
  46. </el-dialog>
  47. </div>
  48. </template>
  49. <script>
  50. import { casePay } from "@/api/pay/pay";
  51. import QRCode from "qrcodejs2";
  52. export default {
  53. props: ["openPay", "payTitle", "form", "payForm"],
  54. data() {
  55. return {
  56. // key: value
  57. // 支付文字
  58. payMain: "",
  59. };
  60. },
  61. methods: {
  62. // 生成二维码
  63. qrcode(url) {
  64. // 前端根据 URL 生成微信支付二维码
  65. document.getElementById("qrcodeImg").innerHTML = "";
  66. return new QRCode("qrcodeImg", {
  67. width: 200,
  68. height: 200,
  69. text: url,
  70. colorDark: "#000",
  71. colorLight: "#fff",
  72. });
  73. },
  74. // 支付
  75. pay(val) {
  76. if (this.payForm.feePayable == 0 || !this.payForm.feePayable) {
  77. this.$message({
  78. message: "此案件无需缴费",
  79. type: "error",
  80. });
  81. return;
  82. }
  83. let payType = "";
  84. if (val == 0) {
  85. payType = "wxpay";
  86. this.payMain = "请使用微信扫二维码支付";
  87. } else if (val == 1) {
  88. payType = "alipay";
  89. this.payMain = "请使用支付宝扫二维码支付";
  90. }
  91. casePay({
  92. totalFee: this.payForm.feePayable * 100,
  93. caseId: this.payForm.caseId,
  94. tradeType: "native",
  95. platform: payType,
  96. }).then((res) => {
  97. this.paySrc = res.data.code_url;
  98. this.qrcode(this.paySrc);
  99. });
  100. },
  101. payCancel() {
  102. this.$emit("paycancelRow");
  103. this.payMain = "";
  104. },
  105. },
  106. };
  107. </script>
  108. <style lang="scss" scoped>
  109. .payType {
  110. height: 80px;
  111. line-height: 80px;
  112. .icon-weixinzhifu {
  113. font-size: 24px;
  114. color: #27a56f;
  115. margin-right: 15px;
  116. }
  117. .icon-zhifubao {
  118. font-size: 24px;
  119. color: #1d76cc;
  120. }
  121. }
  122. .payImg {
  123. width: 100%;
  124. display: flex;
  125. justify-content: center;
  126. }
  127. .payTitle {
  128. margin-top: 20px;
  129. width: 100%;
  130. text-align: center;
  131. }
  132. </style>