paymentCode.vue 13 KB

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