paymentCode1.vue 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466
  1. <template>
  2. <view class=" page" :style="getHeight">
  3. <!-- 公共组件-每个页面必须引入 -->
  4. <public-module></public-module>
  5. <view class="panel dis f-c j-c a-c" id="panelcanvas">
  6. <view class="d-flex a-center j-center qrcode" style="position: relative;">
  7. <image :src="paycodeimg" mode="widthFix"></image>
  8. <image :src="logoimg" mode="" style="width: 30px;height: 30px;position: absolute;margin: 0 auto;">
  9. </image>
  10. </view>
  11. <view class="quotation-data">
  12. <view class="circulate-impany dis a-c">
  13. <view>保险公司:</view>
  14. <view>{{companyName}}</view>
  15. </view>
  16. <view class="circulate-data dis a-c">
  17. <view>投保人:</view>
  18. <view>{{applyName}}</view>
  19. </view>
  20. <view class="circulate-data dis a-c">
  21. <view>车牌号:</view>
  22. <view>{{licenseNo}}</view>
  23. </view>
  24. <view v-if="jqpremium" class="circulate-data dis a-c">
  25. <view>交强险:</view>
  26. <view>¥{{jqpremium}}</view>
  27. </view>
  28. <view v-if="sypremium" class="circulate-data dis a-c">
  29. <view>商业险:</view>
  30. <view>¥{{sypremium}}</view>
  31. </view>
  32. <view v-if="taxamount" class="circulate-data dis a-c">
  33. <view>车船税:</view>
  34. <view>¥{{taxamount}}</view>
  35. </view>
  36. <view v-if="jypremium" class="circulate-data dis a-c">
  37. <view>驾意险:</view>
  38. <view>¥{{jypremium}}</view>
  39. </view>
  40. <view class="circulate-data dis a-c">
  41. <view>保费合计:</view>
  42. <view style="font-size: 34upx;color: #2D4D89;font-weight: bold;">¥{{sumPermium}}</view>
  43. </view>
  44. <view class="circulate-data dis a-c " v-if="jqStartDate">
  45. <view>交强起保日期:</view>
  46. <view>{{jqStartDate}}</view>
  47. </view>
  48. <view class="circulate-data dis a-c " v-if="jqEndDate">
  49. <view>交强终保日期:</view>
  50. <view>{{jqEndDate}}</view>
  51. </view>
  52. <view class="circulate-data dis a-c " v-if="syStartDate">
  53. <view>商业起保日期</view>
  54. <view>{{syStartDate}}</view>
  55. </view>
  56. <view class="circulate-data dis a-c " v-if="sysEndDate">
  57. <view>商业终保日期</view>
  58. <view>{{sysEndDate}}</view>
  59. </view>
  60. </view>
  61. </view>
  62. <!-- #ifdef APP-PLUS -->
  63. <u-button type="primary" style="width: 100%;background: #2D4D89;" @click="sendPayCode">发送到微信</u-button>
  64. <!-- #endif -->
  65. <u-button class="tip" type="default" :hair-line="false"
  66. style="color: #2D4D89;background: #EAEDF1;font-weight: bold;border: none;" @click="navOrder">返回订单</u-button>
  67. <canvas id="mycanvas" ref="mycanvas" canvas-id="mycanvas" style="width: 1080px;height: 1680px;"></canvas>
  68. </view>
  69. </template>
  70. <script>
  71. import {
  72. mapState,
  73. mapMutations
  74. } from "vuex"
  75. import {
  76. pathToBase64,
  77. base64ToPath
  78. } from '@/common/pdf.js'
  79. import QR from "@/common/wxqrcode.js"
  80. export default {
  81. data() {
  82. return {
  83. paycodeimg: "",
  84. payImg: "",
  85. endDateTime: "",
  86. companyId: "",
  87. companyName: "", //保险公司名称
  88. sumPermium: "", //保费合计
  89. licenseNo: "", //车牌号
  90. applyName: "", //车主名字
  91. mobile: "", //车主手机号
  92. jqpremium: "",
  93. sypremium: "",
  94. taxamount: "",
  95. jypremium: "",
  96. jqStartDate: "",
  97. jqEndDate: "",
  98. syStartDate: "",
  99. sysEndDate: "",
  100. arr: false,
  101. posterUrl: "",
  102. insCompanyList: [{
  103. name: "中煤财险",
  104. icon: "../../static/insuranceicon/zhongmei.png"
  105. }, //华农
  106. {
  107. name: "恒邦财险",
  108. icon: "../../static/insuranceicon/hengbang.png"
  109. },
  110. {
  111. name: "安盛天平",
  112. icon: "../../static/insuranceicon/ansheng.png"
  113. },
  114. {
  115. name: "中国人寿",
  116. icon: "../../static/insuranceicon/renshou.png"
  117. },
  118. {
  119. name: "众安财险",
  120. icon: "../../static/insuranceicon/zhongan.png"
  121. },
  122. {
  123. name: "永诚财险",
  124. icon: "../../static/insuranceicon/yongcheng.png"
  125. },
  126. {
  127. name: "永安财险",
  128. icon: "../../static/insuranceicon/yongan.png"
  129. },
  130. {
  131. name: "紫金财险",
  132. icon: "../../static/insuranceicon/zijin.png"
  133. },
  134. {
  135. name: "国任财险",
  136. icon: "../../static/insuranceicon/guoren.png"
  137. },
  138. {
  139. name: "华泰财险",
  140. icon: "../../static/insuranceicon/huatai.png"
  141. },
  142. {
  143. name: "大家财险",
  144. icon: "../../static/insuranceicon/dajia.png"
  145. },
  146. {
  147. name: "太平财险",
  148. icon: "../../static/insuranceicon/taiping.png"
  149. },
  150. {
  151. name: "华农财险",
  152. icon: "../../static/insuranceicon/huanong.png"
  153. },
  154. {
  155. name: "泰康财险",
  156. icon: "../../static/insuranceicon/taikang.png"
  157. },
  158. ],
  159. logoimg: "",
  160. }
  161. },
  162. computed: {
  163. ...mapState(['userInfo', 'token']),
  164. getHeight() {
  165. let height = uni.getSystemInfoSync().windowHeight;
  166. return `height: ${height}px;`;
  167. }
  168. },
  169. async onLoad(data) {
  170. if (!!data.companyId) {
  171. let params = {
  172. companyId: data.companyId
  173. };
  174. let res = await this.$http.get('/order/qrCode/getQrCode?areaCompanyId=' + data.companyId);
  175. //获取前一个页面传过来的信息(车辆信息,人员信息,险种信息)
  176. if (res.code == '200') {
  177. this.companyName = res.data.inscompany;
  178. this.sumPermium = res.data.sumpremium;
  179. this.licenseNo = res.data.cPlateNo;
  180. this.applyName = res.data.cInsuredNme;
  181. this.jqpremium = res.data.jqpremium; // 交强
  182. this.sypremium = res.data.sypremium; // 商业
  183. this.taxamount = res.data.taxamount; // 车船税
  184. this.jypremium = res.data.jypremium; // 驾意险
  185. this.jqStartDate = res.data.jqStartDate; // 交强起保日期
  186. this.jqEndDate = res.data.jqEndDate; // 交强起保日期
  187. this.syStartDate = res.data.syStartDate; // 商业起保日期
  188. this.sysEndDate = res.data.sysEndDate; // 商业起保日期
  189. if (this.companyName == '太平财险') {
  190. let result = res.data.qrCodeUrl.replace(/[\r\n]/g, "");
  191. let imgBase64 = `data:image/png;base64,${result}`;
  192. base64ToPath(imgBase64)
  193. .then(path => {
  194. this.paycodeimg = path;
  195. })
  196. } else if (this.companyName == '华泰财险') {
  197. switch (data.apiType) {
  198. case 1:
  199. case '1':
  200. this.paycodeimg = res.data.qrCodeUrl;
  201. break;
  202. case 2:
  203. case '2':
  204. let result = res.data.qrCodeUrl.replace(/[\r\n]/g, "");
  205. let imgBase64 = `data:image/png;base64,${result}`;
  206. base64ToPath(imgBase64)
  207. .then(path => {
  208. this.paycodeimg = path;
  209. })
  210. break;
  211. }
  212. } else {
  213. this.paycodeimg = QR.createQrCodeImg(res.data.qrCodeUrl, {
  214. size: parseInt(300) //二维码大小
  215. })
  216. }
  217. this.insCompanyList.map(ele => {
  218. if (ele.name == res.data.inscompany) {
  219. uni.getImageInfo({
  220. src: ele.icon,
  221. success: image => {
  222. pathToBase64(image.path)
  223. .then(base64 => {
  224. this.logoimg = base64;
  225. })
  226. .catch(error => {});
  227. },
  228. fail: err => {}
  229. });
  230. }
  231. return ele;
  232. })
  233. } else {
  234. uni.showModal({
  235. showCancel: false,
  236. title: res.msg
  237. })
  238. }
  239. } else {
  240. uni.showModal({
  241. showCancel: false,
  242. title: "未查询到该订单"
  243. })
  244. }
  245. },
  246. methods: {
  247. ...mapMutations(['setOrderType', 'setOrderStage']),
  248. async tpcodeconfirm() { //输入验证码,获取支付二维码
  249. let tpcode = {
  250. issueCode: this.tpcodevalue,
  251. orderno: this.orderno,
  252. }
  253. let tpcoderes = await this.$http.post('/API/insCBIT/taiPingPay', tpcode); //太平
  254. this.paycodeimg = QR.createQrCodeImg(JSON.parse(tpcoderes.data).payUrl, {
  255. size: parseInt(300) //二维码大小
  256. })
  257. },
  258. //发送收款码到微信
  259. sendPayCode() {
  260. // var that = this;
  261. // this.canvasPayImage();
  262. if (this.payImg) {
  263. uni.share({
  264. provider: "weixin",
  265. scene: "WXSceneSession",
  266. type: 2,
  267. imageUrl: this.payImg
  268. })
  269. }
  270. },
  271. // canvasPayImage() {
  272. // let myCanvas = uni.createCanvasContext('mycanvas', this);
  273. // var ww = '1080px';
  274. // var hh = '1680px';
  275. // //画布尺寸
  276. // // 坐标(0,0) 表示从此处开始绘制,相当于偏移。
  277. // //背景
  278. // myCanvas.drawImage('/static/image/car-insure/payBg.jpg', 0, 0, ww, hh);
  279. // // 失效时间
  280. // // if (!this.arr) {
  281. // // myCanvas.setFillStyle('#f00') //文字样式
  282. // // myCanvas.font = `40px Arial,sans-serif`; //绘制文字
  283. // // myCanvas.setTextAlign('center') //设置对于坐标点的对齐方式
  284. // // myCanvas.fillText('该二维码将于 ' + this.endDateTime + ' 失效', 540, 355);
  285. // // }
  286. // //二维码
  287. // myCanvas.drawImage(this.paycodeimg, 315, 415, 435, 435);
  288. // //个人信息
  289. // myCanvas.setFillStyle('#000') //文字样式
  290. // myCanvas.font = `44px Arial,sans-serif`; //绘制文字
  291. // myCanvas.setTextAlign('left')
  292. // myCanvas.fillText(this.applyName, 535, 965);
  293. // myCanvas.fillText(this.licenseNo, 535, 1085);
  294. // myCanvas.fillText(this.companyName, 535, 1205);
  295. // myCanvas.setFillStyle('#f00') //文字样式
  296. // myCanvas.font = `bold 48px Arial,sans-serif`; //绘制文字
  297. // myCanvas.fillText('¥' + this.sumPermium, 535, 1328);
  298. // //开始绘画,必须调用这一步,才会把之前的一些操作实施
  299. // myCanvas.draw(true, () => {
  300. // uni.hideLoading();
  301. // uni.canvasToTempFilePath({
  302. // canvasId: 'mycanvas',
  303. // success: (res) => {
  304. // // 在H5平台下,tempFilePath 为 base64
  305. // this.payImg = res.tempFilePath;
  306. // console.log(this.payImg)
  307. // },
  308. // fail: () => {
  309. // uni.showToast({
  310. // title: '生成支付码海报失败',
  311. // duration: 2000
  312. // });
  313. // }
  314. // });
  315. // });
  316. // },
  317. navOrder() {
  318. this.navigate({
  319. url: "/pages/orders/orders"
  320. }, "switchTab", true);
  321. },
  322. //页面截图转路径
  323. receiveRenderData(val) {
  324. this.posterUrl = val.replace(/[\r\n]/g, ''); // 去除base64位中的空格
  325. const imageStr = this.posterUrl;
  326. // 将base64转化为临时地址
  327. base64ToPath(imageStr).then(path => {
  328. this.payImg = path
  329. }).catch(error => {});
  330. },
  331. showLoading() {
  332. uni.showLoading({
  333. title: '正在生成图片'
  334. });
  335. },
  336. hideLoading() {
  337. uni.hideLoading();
  338. },
  339. }
  340. }
  341. </script>
  342. <script module="canvasImage" lang="renderjs">
  343. import html2canvas from 'html2canvas'
  344. export default {
  345. data() {
  346. return {
  347. }
  348. },
  349. mounted() {
  350. setTimeout(() => {
  351. this.canvasImage.generateImage()
  352. }, 1000);
  353. },
  354. methods: {
  355. generateImage() {
  356. setTimeout(() => {
  357. this.$ownerInstance.callMethod('showLoading')
  358. const dom = document.getElementById('panelcanvas') // 需要生成图片内容的 dom 节点
  359. html2canvas(dom, {
  360. width: dom.clientWidth, //dom 原始宽度
  361. height: dom.clientHeight,
  362. scrollY: 0, // html2canvas默认绘制视图内的页面,需要把scrollY,scrollX设置为0
  363. scrollX: 0,
  364. useCORS: true, //支持跨域
  365. // allowTaint: false,
  366. scale: 2, // 设置生成图片的像素比例,默认是1,如果生成的图片模糊的话可以开启该配置项
  367. }).then((canvas) => {
  368. // 生成成功
  369. this.$ownerInstance.callMethod('hideLoading')
  370. this.$ownerInstance.callMethod('receiveRenderData', canvas.toDataURL('image/png'))
  371. }).catch(err => {
  372. // 生成失败 弹出提示弹窗
  373. this.$ownerInstance.callMethod('_errAlert', `【生成图片失败,请重试】${err}`)
  374. })
  375. }, 300)
  376. }
  377. },
  378. }
  379. </script>
  380. <style lang="scss" scoped>
  381. @import '@/style/mixin.scss';
  382. .page {
  383. padding: 10px 16px;
  384. }
  385. .panel {
  386. width: 100%;
  387. margin-bottom: 20px;
  388. }
  389. .qrcode {
  390. width: 174px;
  391. height: 174px;
  392. padding: 10px;
  393. margin-top: 16px;
  394. border-radius: 4px;
  395. border: 1px solid #2D4D89;
  396. }
  397. .qrcode image {
  398. width: 174px;
  399. height: 174px;
  400. }
  401. .tip {
  402. background-color: #FFFFFF;
  403. margin-top: 30upx;
  404. border-radius: 10upx;
  405. font-size: 32upx;
  406. font-weight: bold;
  407. }
  408. .quotation-data {
  409. width: 100%;
  410. margin-top: 16px;
  411. border: 1px solid #2D4D89;
  412. .circulate-impany {
  413. height: 37px;
  414. padding: 8px 6px;
  415. background: rgba(45, 77, 137, 0.1);
  416. border-bottom: 1px solid #000000;
  417. font-weight: 700;
  418. view:first-child {
  419. margin-right: 10px;
  420. }
  421. }
  422. .circulate-data {
  423. height: 37px;
  424. color: #232832;
  425. padding: 8px 6px;
  426. border-bottom: 1px solid #000000;
  427. view:first-child {
  428. color: #232832;
  429. font-weight: 400;
  430. font-size: 14px;
  431. margin-right: 5px;
  432. }
  433. view:last-child {
  434. font-weight: 400;
  435. color: #232832;
  436. font-size: 14px;
  437. }
  438. }
  439. .circulate-data:last-child {
  440. border: none;
  441. }
  442. }
  443. #mycanvas {
  444. position: absolute;
  445. top: -10000px;
  446. left: -10000px;
  447. }
  448. </style>