paymentCode.vue 14 KB

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