paymentCode.vue 13 KB

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