paymentCode1.vue 11 KB

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