help-pay-qrcode.vue 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174
  1. <template>
  2. <div class="x-qrcode">
  3. <img src="../assets/qr-back.png"
  4. alt=""
  5. class="qr-back"
  6. @click="$router.back()">
  7. <div class="box"
  8. v-show="qrImg">
  9. <img src="../assets/qr-title.jpg"
  10. alt=""
  11. class="title">
  12. </div>
  13. <div class="qr-wrapper">
  14. <img :src="qrImg"
  15. alt="">
  16. </div>
  17. <div class="qr-wrapper2">
  18. <img src="/static/img/2018101901.jpg"
  19. class="bg"
  20. alt="">
  21. <div class="user">
  22. <img :src="info.head_img"
  23. class="head">
  24. <p class="name">{{info.nickname ? info.nickname : '微信好友' }}:</p>
  25. </div>
  26. <div class="qr-img"></div>
  27. </div>
  28. <p class="notice"
  29. v-show="qrImg">代充成功后书币会到账,扣款发生在实际支付人</p>
  30. </div>
  31. </template>
  32. <script>
  33. import html2canvas from "html2canvas";
  34. import QRCode from "qrcodejs2";
  35. import { Pay } from "./namespace.js";
  36. import { getSubstitutePay } from "../api";
  37. export default {
  38. data() {
  39. return {
  40. Pay: Pay.name,
  41. qrImg: "",
  42. info: {
  43. head_img: "",
  44. nickname: "",
  45. },
  46. defaultHead: require("../assets/default.png"),
  47. qrcode: "",
  48. };
  49. },
  50. async mounted() {
  51. let { product_id } = this.$route.query;
  52. await getSubstitutePay(product_id).then((r) => {
  53. this.info = r;
  54. new QRCode(document.querySelector(".qr-wrapper2 .qr-img"), {
  55. text: r.help_pay_page,
  56. width: 120,
  57. height: 120,
  58. colorDark: "#000000",
  59. colorLight: "#ffffff",
  60. correctLevel: 2,
  61. scale: 2,
  62. });
  63. });
  64. this.$Indicator.open("正在生成中....");
  65. this.$nextTick(() => {
  66. html2canvas(document.querySelector(".qr-wrapper2")).then((canvas) => {
  67. this.$Indicator.close();
  68. this.$Toast("代付二维码生成成功!");
  69. this.qrImg = canvas.toDataURL("image/jpeg");
  70. document.querySelector(".qr-wrapper2").remove();
  71. });
  72. });
  73. },
  74. };
  75. </script>
  76. <style lang="scss" scoped>
  77. .x-qrcode {
  78. background: #deedff;
  79. position: absolute;
  80. top: 0;
  81. bottom: 0;
  82. left: 0;
  83. right: 0;
  84. overflow: scroll;
  85. }
  86. .box {
  87. text-align: center;
  88. }
  89. .title {
  90. width: 90%;
  91. margin: 0.6rem auto;
  92. }
  93. .qr-wrapper,
  94. .qr-wrapper2 {
  95. position: relative;
  96. .bg {
  97. width: 100%;
  98. }
  99. .qr-img {
  100. position: absolute;
  101. left: 0.2rem;
  102. bottom: 0.2rem;
  103. width: 120px;
  104. height: 120px;
  105. }
  106. }
  107. .qr-wrapper {
  108. padding: 0 0.4rem;
  109. img {
  110. width: 100%;
  111. }
  112. }
  113. .qr-wrapper2 {
  114. position: absolute;
  115. z-index: -1;
  116. }
  117. .user {
  118. position: absolute;
  119. top: 0.4rem;
  120. left: 0.5rem;
  121. display: flex;
  122. justify-content: flex-start;
  123. align-items: center;
  124. .head {
  125. width: 0.8rem;
  126. height: 0.8rem;
  127. border-radius: 50%;
  128. }
  129. .name {
  130. margin-left: 0.3rem;
  131. color: #fff;
  132. font-size: 0.32rem;
  133. font-weight: bolder;
  134. }
  135. }
  136. .notice {
  137. padding: 0.4rem;
  138. font-size: 0.28rem;
  139. &::before {
  140. content: "";
  141. display: inline-block;
  142. width: 0.1rem;
  143. height: 0.1rem;
  144. background: red;
  145. border-radius: 50%;
  146. margin-right: 0.1rem;
  147. vertical-align: middle;
  148. }
  149. }
  150. .qr-back {
  151. position: fixed;
  152. top: 0.4rem;
  153. left: 0.4rem;
  154. width: 0.64rem;
  155. height: 0.64rem;
  156. }
  157. </style>