paymentCode.vue 12 KB

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