pay.vue 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101
  1. <template>
  2. <h2 class="title">
  3. 下载本报告(PDF+PPT),需要支付
  4. <span class="price">{{ detail.useDownPayPrice }}</span> 元
  5. </h2>
  6. <h3>请选择支付方式</h3>
  7. <div class="pay-container">
  8. <div class="pay-box" @click="handlePay(isMobile() ? 'zfb_h5' : 'zfb')">
  9. <div class="pay-name">
  10. <span class="bqfl-iconfont icon-zhifubao f30 color1296DB mr5"></span>
  11. <span>支付宝支付</span>
  12. </div>
  13. </div>
  14. <div class="pay-box" @click="handlePay(isMobile() ? 'wx_h5' : 'wx')">
  15. <div class="pay-name">
  16. <span class="bqfl-iconfont icon-weixinzhifu f30 color00C800 mr5"></span>
  17. <span>微信支付</span>
  18. </div>
  19. </div>
  20. </div>
  21. <n-modal :show="toolsVisible" preset="dialog" :title="toolsTitle" :showIcon="false" @close="toolsVisible = false" @esc="toolsVisible = false" @mask-click="toolsVisible = false" :class="{ 'login-dialog': !pcShow }">
  22. </n-modal>
  23. </template>
  24. <script lang="ts" setup>
  25. import { ref, reactive, onMounted } from "vue";
  26. import { createDiscreteApi } from "naive-ui";
  27. const emit = defineEmits(["closeToolsDialog", "openWXCode"]);
  28. const props = defineProps({
  29. detail: {
  30. type: Object,
  31. default: () => {},
  32. },
  33. });
  34. const handlePay = async (payMethod: string) => {
  35. const { code, data } = await getPayOrder_Api({
  36. researchBriefReportId: props.detail.id,
  37. payMethod: payMethod,
  38. payPrice: props.detail.useDownPayPrice,
  39. });
  40. if (code === 200) {
  41. if (payMethod == "wx") {
  42. emit("openWXCode", data);
  43. } else {
  44. downloadFile(data?.orderPayUrl);
  45. emit("closeToolsDialog", "zfbPayEnd");
  46. }
  47. }
  48. };
  49. onMounted(() => {
  50. console.log("isMobile===>", isMobile());
  51. });
  52. const NMessage = createDiscreteApi(["message"]);
  53. const errorMsg = (msg: any) => {
  54. NMessage.message.error(msg || "服务端异常");
  55. };
  56. </script>
  57. <style lang="scss" scoped>
  58. .title {
  59. text-align: center;
  60. .price {
  61. color: #ff0000;
  62. }
  63. }
  64. h3 {
  65. text-align: center;
  66. }
  67. .pay-container {
  68. padding: 0 30px;
  69. .pay-box {
  70. width: 230px;
  71. background: #ffffff;
  72. margin: 0 auto 20px;
  73. cursor: pointer;
  74. border-radius: 10px;
  75. border: 1px solid #ccc;
  76. &:last-child {
  77. .img {
  78. border-color: #0090ff;
  79. }
  80. }
  81. .pay-name {
  82. display: flex;
  83. justify-content: center;
  84. align-items: center;
  85. text-align: center;
  86. font-size: 18px;
  87. color: #1a1a1a;
  88. }
  89. }
  90. }
  91. </style>