paymentCode.vue 13 KB

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