qrCode.vue 8.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271
  1. <template>
  2. <div>
  3. <el-dialog :visible.sync="codedialogVisible" width="430px" top="10vh" class="saomazhifucodeClass">
  4. <div class="ORcodebody" v-watermark="orderId">
  5. <div slot="title" class="dialog-title">
  6. <span>扫码付款</span>
  7. </div>
  8. <div class="ORcode">
  9. <div style="padding:13px;position: relative;">
  10. <img v-if="['太平财险', '华泰财险'].includes(carcodeForm.inscompany)" :src="paycodeimg" alt style="width:100%" />
  11. <div v-else id="qrcode" ref="qrcode"></div>
  12. </div>
  13. </div>
  14. <img style="margin-left: -16px" src="../../../assets/image/divider.png" alt />
  15. <div style="font-size:32px;text-align: center;color:#D42426;margin-top:20px">
  16. <span style="font-size:24px;font-weight:bold">¥</span>
  17. {{ carcodeForm.sumpremium }}
  18. </div>
  19. <div class="ORtitle">
  20. <div>
  21. <span>保险公司:</span>
  22. <span>{{ carcodeForm.inscompany }}</span>
  23. </div>
  24. <div>
  25. <span>车牌号:</span>
  26. <span>{{ carcodeForm.cPlateNo }}</span>
  27. </div>
  28. <div>
  29. <span>投保人:</span>
  30. <span>{{ carcodeForm.cInsuredNme }}</span>
  31. </div>
  32. <div v-show="carcodeForm.jqpremium">
  33. <span>交强:</span>
  34. <span>{{ carcodeForm.jqpremium }}</span>
  35. </div>
  36. <div v-show="carcodeForm.sypremium">
  37. <span>商业:</span>
  38. <span>{{ carcodeForm.sypremium }}</span>
  39. </div>
  40. <div v-show="carcodeForm.taxamount">
  41. <span>车船税:</span>
  42. <span>{{ carcodeForm.taxamount }}</span>
  43. </div>
  44. <div v-show="carcodeForm.jqStartDate">
  45. <span>交强险起保日期:</span>
  46. <span>{{ carcodeForm.jqStartDate }}</span>
  47. </div>
  48. <div v-show="carcodeForm.syStartDate">
  49. <span>商业险起保日期:</span>
  50. <span>{{ carcodeForm.syStartDate }}</span>
  51. </div>
  52. <div v-if="carcodeForm.jypremium">
  53. <span>非车险:</span>
  54. <span>{{ carcodeForm.jypremium }}</span>
  55. </div>
  56. </div>
  57. </div>
  58. <span slot="footer" class="dialog-footer display">
  59. <el-button size="small" style="width:100px;border-color:#D42426;color:#D42426 "
  60. @click="codedialogVisible = false">关闭</el-button>
  61. </span>
  62. </el-dialog>
  63. <!--第二种 二维码 -->
  64. <el-dialog :visible.sync="codedialogVisiblePro" width="660px" class="proSaomazhifucodeClass" top="10vh" title="扫码付款">
  65. <div class="flex j-s">
  66. <div class="scan-code">
  67. <div style="font-weight: bold;">
  68. 总金额:
  69. <span style="color:#2D4D89 ">{{ carcodeForm.sumpremium }}</span>
  70. </div>
  71. <div>交强险:{{ carcodeForm.jqpremium }}</div>
  72. <div>车船税:{{ carcodeForm.taxamount }}</div>
  73. <div>商业险:{{ carcodeForm.sypremium }}</div>
  74. <div>非车险:{{ carcodeForm.jypremium }}</div>
  75. </div>
  76. <div>
  77. <img v-if="['太平财险', '华泰财险'].includes(carcodeForm.inscompany)" :src="paycodeimg" alt style="width:200px;height: 200px;" />
  78. <div v-else id="qrcode" ref="qrcode"></div>
  79. </div>
  80. <div class="scan-code">
  81. <div>保险公司:{{ carcodeForm.inscompany }}</div>
  82. <div>车牌号:{{ carcodeForm.cPlateNo }}</div>
  83. <div>投保人:{{ carcodeForm.cInsuredNme }}</div>
  84. <div>交强险起保日期:{{ carcodeForm.jqstartdate }}</div>
  85. <div>商业险起保日期:{{ carcodeForm.systartdate }}</div>
  86. </div>
  87. </div>
  88. <span slot="footer" class="dialog-footer">
  89. <el-button size="small" style="width:100px;background: #EAEDF1;border-color:#EAEDF1;color:#2D4D89 "
  90. @click="codedialogVisiblePro = false">关闭</el-button>
  91. </span>
  92. </el-dialog>
  93. </div>
  94. </template>
  95. <script>
  96. import QRCode from "qrcodejs2";
  97. export default {
  98. data(){
  99. return{
  100. codedialogVisible:false,
  101. codedialogVisiblePro:false,
  102. carcodeForm:{},
  103. paycodeimg:'',
  104. qrcode: null,
  105. qrcodeWidth: "180",
  106. qrcodeHeight: "180",
  107. orderId:''
  108. }
  109. },
  110. methods: {
  111. carcode(row) {
  112. console.log(row);
  113. this.orderId = row.subOrderId
  114. this.$api.letter.getQrCode(row.subOrderId).then(res => {
  115. if (res.code == "200") {
  116. this.carcodeForm=res.data
  117. this.$api.letter.getThemeByUserId().then(res => {
  118. if (res.code == 200) {
  119. if (res.data[0] == 'GD') {
  120. this.codedialogVisiblePro = true;
  121. this.qrcodeWidth = "154";
  122. this.qrcodeHeight = "154";
  123. }
  124. else {
  125. this.codedialogVisible = true;
  126. }
  127. this.$nextTick(function () {
  128. if (row.inscompany == "太平财险") {
  129. let anresult = qrCodeUrl.replace(/[\r\n]/g, "");
  130. let animgBase64 = `data:image/png;base64,${anresult}`;
  131. base64ToPath(animgBase64).then(path => {
  132. this.paycodeimg = path;
  133. });
  134. } else if (row.inscompany == "华泰财险") {
  135. switch (row.apiType) {
  136. case 1:
  137. this.paycodeimg = qrCodeUrl;
  138. break;
  139. case 2:
  140. let anresult = qrCodeUrl.replace(/[\r\n]/g, "");
  141. let animgBase64 = `data:image/png;base64,${anresult}`;
  142. base64ToPath(animgBase64).then(path => {
  143. this.paycodeimg = path;
  144. });
  145. break;
  146. }
  147. }
  148. else {
  149. this.creatQrCode( this.carcodeForm.qrCodeUrl);
  150. }
  151. });
  152. }
  153. })
  154. } else {
  155. this.$message({ message: res.msg, type: "warning" });
  156. }
  157. });
  158. },
  159. //二维码生成插件
  160. creatQrCode(text) {
  161. if (this.qrcode) {
  162. this.qrcode.clear();
  163. this.qrcode.makeCode(text);
  164. } else {
  165. this.qrcode = new QRCode("qrcode", {
  166. text: text,
  167. width: this.qrcodeWidth,
  168. height: this.qrcodeHeight,
  169. colorDark: "#000000",
  170. colorLight: "#ffffff",
  171. correctLevel: QRCode.CorrectLevel.H
  172. });
  173. }
  174. },
  175. }
  176. }
  177. </script>
  178. <style scoped scoped lang="scss">
  179. /deep/{
  180. .saomazhifucodeClass .el-dialog__body,
  181. .saomazhifucodeClass .el-dialog__header,
  182. .saomazhifucodeClass .el-dialog__footer {
  183. padding: 0;
  184. background: #f4e9e9;
  185. }
  186. .saomazhifucodeClass .el-dialog__body {
  187. padding: 15px;
  188. }
  189. .saomazhifucodeClass .el-dialog__footer {
  190. background: #f4e9e9;
  191. padding-bottom: 15px;
  192. }
  193. .saomazhifucodeClass .el-dialog__headerbtn {
  194. margin-top: 10px;
  195. }
  196. }
  197. .ORcodebody {
  198. height: auto;
  199. // background: url(../../../assets/image/group.png) #fff;
  200. padding: 16px;
  201. background-color: #fff;
  202. }
  203. .ORcode {
  204. width: 100%;
  205. height: auto;
  206. display: flex;
  207. justify-content: center;
  208. align-items: center;
  209. padding: 30px;
  210. box-sizing: border-box;
  211. &>div {
  212. width: 176px;
  213. height: 176px;
  214. border: 1px solid var(--themeColor);
  215. border-radius: 5px;
  216. }
  217. }
  218. .ORtitle {
  219. width: 100%;
  220. padding-bottom: 20px;
  221. box-sizing: border-box;
  222. &>div {
  223. width: 100%;
  224. margin: 10px 0;
  225. font-size: 14px;
  226. &>span {
  227. &:nth-child(1) {
  228. color: #868b98;
  229. text-align: end;
  230. width: 150px;
  231. }
  232. &:nth-child(2) {
  233. color: #333333;
  234. }
  235. }
  236. }
  237. }
  238. #qrCode {
  239. display: inline-block;
  240. margin: 0 auto;
  241. /*水平居中*/
  242. position: relative;
  243. top: 15%;
  244. }
  245. #qrCode img {
  246. width: 200px;
  247. height: 200px;
  248. background-color: #fff;
  249. padding: 6px;
  250. }
  251. .display {
  252. display: flex;
  253. justify-content: center;
  254. align-items: center;
  255. box-sizing: border-box;
  256. }
  257. </style>