quotation.vue 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609
  1. <template>
  2. <view style="background-color: #ea552d;height: 100vh;">
  3. <view class="page dis f-c a-c" id="panelcanvas">
  4. <view class="Basic-information dis f-c" style="background: bisque;border-radius: 0;">
  5. <view class=" dis a-c j-c" style="padding: 4px;">
  6. <image :src="logoimg" mode="" style="width: 30px;height: 30px;">
  7. </image>
  8. <text style="font-weight: bold;margin-left: 6px;">{{dataInfo.inscompany}}报价单</text>
  9. </view>
  10. </view>
  11. <view class="Basic-information dis f-c" style="border-top-right-radius: 0;border-top-left-radius: 0;">
  12. <view class="basic-logo dis a-c">
  13. <image :src="caricon" mode=""></image>
  14. <view class="dis f-c">
  15. <text>{{dataInfo.licenseno}}</text>
  16. <text>{{carinfo.modelcname}}</text>
  17. </view>
  18. </view>
  19. <view class="basic-data dis f-c">
  20. <view class="arrange ">
  21. <text>订单号:</text>
  22. <text>{{dataInfo.orderno}}</text>
  23. </view>
  24. <view class="arrange ">
  25. <text>车主姓名:</text>
  26. <text>{{ownerinfo.name}}</text>
  27. </view>
  28. <view class="arrange ">
  29. <text>投保人姓名:</text>
  30. <text>{{applyinfo.name}}</text>
  31. </view>
  32. <view class="arrange ">
  33. <text>被保人姓名:</text>
  34. <text>{{insureinfo.name}}</text>
  35. </view>
  36. <view class="arrange ">
  37. <text>发动机号:</text>
  38. <text>{{carinfo.engineNo}}</text>
  39. </view>
  40. <view class="arrange ">
  41. <text>车架号:</text>
  42. <text>{{carinfo.vinNo}}</text>
  43. </view>
  44. <view class="arrange ">
  45. <text>座位数:</text>
  46. <text>{{carinfo.seatCount}}</text>
  47. </view>
  48. <view class="arrange " v-if="dataInfo.jqstartdate">
  49. <text>交强投保时间:</text>
  50. <text>{{ dataInfo.jqstartdate }}</text>
  51. </view>
  52. <view class="arrange " v-if="dataInfo.systartdate">
  53. <text>商业投保时间:</text>
  54. <text>{{ dataInfo.systartdate }}</text>
  55. </view>
  56. </view>
  57. </view>
  58. <view class="Basic-information Circle Circle1" style="padding-bottom: 10px;">
  59. <view class="bjdCarSum dis j-s ">
  60. <text>应缴金额</text>
  61. <text style="color:rgb(255, 30, 7)">¥{{dataInfo.sumpremium}}</text>
  62. </view>
  63. <view class="bjdCarSum dis j-s " v-if="dataInfo.jqpremium">
  64. <text>交强险</text>
  65. <text>¥{{dataInfo.jqpremium}}</text>
  66. </view>
  67. <view class="bjdCarSum dis j-s " v-if="dataInfo.taxamount">
  68. <text>车船税</text>
  69. <text>¥{{dataInfo.taxamount}}</text>
  70. </view>
  71. <view class="bjdCarSum dis j-s " v-if="dataInfo.jypremium">
  72. <text>驾意险</text>
  73. <text>¥{{dataInfo.jypremium}}</text>
  74. </view>
  75. <view class="bjdCarSum dis j-s " v-if="dataInfo.sypremium">
  76. <text>商业险</text>
  77. <text>¥{{dataInfo.sypremium}}</text>
  78. </view>
  79. <view class="bjdCarSum dis j-s " v-if="dataInfo.jqdiscountrate">
  80. <text>交强险优惠比例</text>
  81. <text>{{dataInfo.jqdiscountrate}}%</text>
  82. </view>
  83. <view class="bjdCarSum dis j-s " v-if="dataInfo.sydiscountrate">
  84. <text>商业险优惠比例</text>
  85. <text>{{dataInfo.sydiscountrate}}%</text>
  86. </view>
  87. <view class="coverage dis j-s f-c" style="border: none;" v-if="dataInfo.sypremium">
  88. <view class="coverage-title dis">
  89. <view style="">
  90. <text>商业险金额</text>
  91. </view>
  92. <view>
  93. <text>保险金额</text>
  94. </view>
  95. <view>
  96. <text>保费</text>
  97. </view>
  98. </view>
  99. <view class="coverage-sum dis j-s" v-for="(item,index) in dataInfo.kindinfo" :key="index">
  100. <view style="">
  101. <text>{{item.kindName}}</text>
  102. </view>
  103. <view v-if="['D4', 'SY_FJ_YBW2'].includes(item.kindCode)">
  104. <text>{{item.unitAmount}}/座*{{dataInfo.carinfo.seatCount-1}}</text>
  105. </view>
  106. <view v-else-if="['MJ1', 'MJ2', 'MJ3', 'MJ4'].includes(item.kindCode)">
  107. <text>{{item.deductibleRate}}</text>
  108. </view>
  109. <view v-else-if="['TY1', 'TY2', 'TY3', 'TY4'].includes(item.kindCode)">
  110. <text>{{item.serviceTimes}}/次</text>
  111. </view>
  112. <view v-else>
  113. <text>{{item.amount}}</text>
  114. </view>
  115. <view>
  116. <text>¥{{item.coveragePremium}}</text>
  117. </view>
  118. </view>
  119. </view>
  120. </view>
  121. </view>
  122. <view class="infoBottom d-flex a-center j-center j-sb">
  123. <button type="default" class="d-flex a-center j-center" @tap="sendPayCode">发送到微信</button>
  124. </view>
  125. </view>
  126. </view>
  127. </template>
  128. <script>
  129. import {
  130. pathToBase64,
  131. base64ToPath
  132. } from '@/common/pdf.js'
  133. export default {
  134. data() {
  135. return {
  136. payImg: "",
  137. posterUrl: "",
  138. caricon: "", //carlogo
  139. show: false,
  140. companyId: "",
  141. dataInfo: {},
  142. carinfo: {}, //车辆信息
  143. ownerinfo: {}, //车主信息
  144. applyinfo: {}, //投保人信息
  145. insureinfo: {}, //被保人信息
  146. insCompanyList: [{
  147. name: "中煤财险",
  148. icon: "../../static/insuranceicon/zhongmei.png"
  149. }, //华农
  150. {
  151. name: "恒邦财险",
  152. icon: "../../static/insuranceicon/hengbang.png"
  153. },
  154. {
  155. name: "安盛天平",
  156. icon: "../../static/insuranceicon/ansheng.png"
  157. },
  158. {
  159. name: "中国人寿",
  160. icon: "../../static/insuranceicon/renshou.png"
  161. },
  162. {
  163. name: "众安财险",
  164. icon: "../../static/insuranceicon/zhongan.png"
  165. },
  166. {
  167. name: "永诚财险",
  168. icon: "../../static/insuranceicon/yongcheng.png"
  169. },
  170. {
  171. name: "永安财险",
  172. icon: "../../static/insuranceicon/yongan.png"
  173. },
  174. {
  175. name: "紫金财险",
  176. icon: "../../static/insuranceicon/zijin.png"
  177. },
  178. {
  179. name: "国任财险",
  180. icon: "../../static/insuranceicon/guoren.png"
  181. },
  182. {
  183. name: "华泰财险",
  184. icon: "../../static/insuranceicon/huatai.png"
  185. },
  186. {
  187. name: "大家财险",
  188. icon: "../../static/insuranceicon/dajia.png"
  189. },
  190. {
  191. name: "太平财险",
  192. icon: "../../static/insuranceicon/taiping.png"
  193. },
  194. {
  195. name: "华农财险",
  196. icon: "../../static/insuranceicon/huanong.png"
  197. },
  198. ],
  199. logoimg: "",
  200. }
  201. },
  202. async onLoad(options) {
  203. this.companyId = options.companyId;
  204. let params = {
  205. companyId: options.companyId
  206. };
  207. let res = await this.$http.post('/insurance/order/getByCompanyId', params);
  208. var data = res.data;
  209. data.kindinfo.map((ele, index) => {
  210. switch (ele.kindCode) {
  211. case "A":
  212. if (ele.amount == 1) {
  213. ele.amount = "投保"
  214. } else {
  215. ele.amount = ele.amount
  216. }
  217. break;
  218. case "D4":
  219. case "SY_FJ_YBW2":
  220. ele.unitAmount = this.toChinesNum(ele.unitAmount);
  221. break;
  222. case "MJ1":
  223. case "MJ2":
  224. case "MJ3":
  225. case "MJ4":
  226. ele.deductibleRate = ele.deductibleRate + "%";
  227. break;
  228. default:
  229. ele.amount = this.toChinesNum(ele.amount);
  230. }
  231. return ele;
  232. });
  233. this.insCompanyList.map(ele => {
  234. if (ele.name == data.inscompany) {
  235. uni.getImageInfo({
  236. src: ele.icon,
  237. success: image => {
  238. pathToBase64(image.path)
  239. .then(base64 => {
  240. this.logoimg = base64;
  241. })
  242. .catch(error => {});
  243. },
  244. fail: err => {}
  245. });
  246. }
  247. return ele;
  248. })
  249. this.dataInfo = data;
  250. this.carinfo = data.carinfo;
  251. this.ownerinfo = data.ownerinfo;
  252. this.applyinfo = data.applyinfo;
  253. this.insureinfo = data.insureinfo;
  254. uni.getImageInfo({
  255. src: '../../static/icon/bjdcar.png',
  256. success: image => {
  257. pathToBase64(image.path)
  258. .then(base64 => {
  259. this.caricon = base64
  260. })
  261. .catch(error => {});
  262. },
  263. });
  264. },
  265. methods: {
  266. //本地图片转换成base64
  267. turnBase64Image() {
  268. this.
  269. uni.getImageInfo({
  270. src: img,
  271. success: image => {
  272. pathToBase64(image.path)
  273. .then(base64 => {
  274. this[key] = base64;
  275. })
  276. .catch(error => {});
  277. },
  278. fail: err => {}
  279. });
  280. },
  281. toChinesNum(num) {
  282. let changeNum = [
  283. "零", "1", "2", "3", "4", "5", "6", "7", "8", "9"
  284. ];
  285. let unit = ["", "0", "00", "000", "0000"];
  286. num = parseInt(num);
  287. let getWan = temp => {
  288. let strArr = temp
  289. .toString()
  290. .split("")
  291. .reverse();
  292. let newNum = "";
  293. let newArr = [];
  294. strArr.forEach((item, index) => {
  295. newArr.unshift(
  296. item === "0" ? changeNum[item] : changeNum[item] + unit[index]
  297. );
  298. });
  299. let numArr = [];
  300. newArr.forEach((m, n) => {
  301. if (m !== "零") numArr.push(n);
  302. });
  303. if (newArr.length > 1) {
  304. newArr.forEach((m, n) => {
  305. if (newArr[newArr.length - 1] === "零") {
  306. if (n <= numArr[numArr.length - 1]) {
  307. newNum += m;
  308. }
  309. } else {
  310. newNum += m;
  311. }
  312. });
  313. } else {
  314. newNum = newArr[0];
  315. }
  316. return newNum;
  317. };
  318. let overWan = Math.floor(num / 10000);
  319. let noWan = num % 10000;
  320. if (noWan.toString().length < 4) {
  321. noWan = "0" + noWan;
  322. }
  323. return overWan ? getWan(overWan) + "万" + getWan(noWan) : getWan(num);
  324. },
  325. //分享图片到微信
  326. sendPayCode() {
  327. if (this.payImg) {
  328. uni.share({
  329. provider: "weixin",
  330. scene: "WXSceneSession",
  331. type: 2,
  332. imageUrl: this.payImg
  333. })
  334. }
  335. },
  336. //页面截图转路径
  337. receiveRenderData(val) {
  338. this.posterUrl = val.replace(/[\r\n]/g, ''); // 去除base64位中的空格
  339. const imageStr = this.posterUrl;
  340. // 将base64转化为临时地址
  341. base64ToPath(imageStr).then(path => {
  342. this.payImg = path
  343. }).catch(error => {});
  344. },
  345. showLoading() {
  346. uni.showLoading({
  347. title: '正在生成图片'
  348. });
  349. },
  350. hideLoading() {
  351. uni.hideLoading();
  352. },
  353. },
  354. }
  355. </script>
  356. <script module="canvasImage" lang="renderjs">
  357. import html2canvas from 'html2canvas'
  358. export default {
  359. data() {
  360. return {
  361. }
  362. },
  363. mounted() {
  364. // #ifdef APP-PLUS
  365. setTimeout(() => {
  366. this.canvasImage.generateImage()
  367. }, 1000);
  368. // #endif
  369. },
  370. methods: {
  371. // #ifdef APP-PLUS
  372. generateImage() {
  373. setTimeout(() => {
  374. this.$ownerInstance.callMethod('showLoading')
  375. const dom = document.getElementById('panelcanvas') // 需要生成图片内容的 dom 节点
  376. html2canvas(dom, {
  377. width: dom.clientWidth, //dom 原始宽度
  378. height: dom.clientHeight,
  379. scrollY: 0, // html2canvas默认绘制视图内的页面,需要把scrollY,scrollX设置为0
  380. scrollX: 0,
  381. useCORS: true, //支持跨域
  382. // allowTaint: false,
  383. scale: 2, // 设置生成图片的像素比例,默认是1,如果生成的图片模糊的话可以开启该配置项
  384. }).then((canvas) => {
  385. // 生成成功
  386. this.$ownerInstance.callMethod('hideLoading')
  387. this.$ownerInstance.callMethod('receiveRenderData', canvas.toDataURL('image/png'))
  388. }).catch(err => {
  389. // 生成失败 弹出提示弹窗
  390. this.$ownerInstance.callMethod('_errAlert', `【生成图片失败,请重试】${err}`)
  391. })
  392. }, 300)
  393. }
  394. // #endif
  395. },
  396. }
  397. </script>
  398. <style lang="scss" scoped>
  399. @import '@/style/mixin.scss';
  400. .page {
  401. background-color: rgba(234, 85, 45, 1);
  402. padding: 20px 10px 100px 10px;
  403. box-sizing: border-box;
  404. }
  405. .Basic-information {
  406. background-color: white;
  407. width: 100%;
  408. height: auto;
  409. .basic-logo {
  410. padding: 10px 16px;
  411. border-bottom: 1px solid #f2f2f2;
  412. image {
  413. width: 50px;
  414. height: 50px;
  415. margin-right: 20px;
  416. }
  417. text {
  418. font-size: 12px;
  419. }
  420. text:first-child {
  421. font-weight: bold;
  422. font-size: 18px;
  423. }
  424. }
  425. .basic-data {
  426. padding: 16px;
  427. .arrange {
  428. margin: 4px 0;
  429. font-size: 14px;
  430. text:first-child {
  431. font-weight: bold;
  432. margin-right: 5px;
  433. }
  434. text:last-child {
  435. color: #606266;
  436. }
  437. &::before {
  438. content: "·";
  439. color: #606266;
  440. margin-right: 10px;
  441. font-weight: bold;
  442. }
  443. }
  444. }
  445. .bjdCarSum {
  446. padding: 10px 16px;
  447. border-bottom: 1px solid #f2f2f2;
  448. font-weight: bold;
  449. font-size: 14px;
  450. }
  451. .coverage {
  452. padding: 10px 16px;
  453. .coverage-title {
  454. width: 100%;
  455. view:first-child {
  456. border-top-left-radius: 8px;
  457. }
  458. view:last-child {
  459. border-top-right-radius: 8px;
  460. }
  461. view:nth-child(2) {
  462. border-left: none;
  463. border-right: none;
  464. }
  465. view {
  466. width: 33.33%;
  467. text-align: center;
  468. background: #ff8f63;
  469. color: #fff;
  470. padding: 6px 16px;
  471. border: 1px solid #fff;
  472. font-size: 12px;
  473. box-sizing: border-box;
  474. }
  475. }
  476. .coverage-sum {
  477. width: 100%;
  478. view:nth-child(2) {
  479. border-left: none;
  480. border-right: none;
  481. }
  482. view {
  483. width: 33.33%;
  484. text-align: center;
  485. font-size: 12px;
  486. background-color: #fbf6f7;
  487. padding: 6px 16px;
  488. border: 1px solid #fff;
  489. border-top: none;
  490. }
  491. }
  492. }
  493. }
  494. .Circle {
  495. position: relative;
  496. &::before {
  497. display: block;
  498. content: "";
  499. position: absolute;
  500. width: 20px;
  501. height: 20px;
  502. background: rgba(234, 85, 45, 1);
  503. top: -10px;
  504. left: -10px;
  505. border-radius: 50%;
  506. }
  507. &::after {
  508. content: "";
  509. position: absolute;
  510. width: 20px;
  511. height: 20px;
  512. background: rgba(234, 85, 45, 1);
  513. top: -10px;
  514. right: -10px;
  515. border-radius: 50%;
  516. }
  517. }
  518. .footer-button {
  519. z-index: 9999;
  520. margin-top: 20px;
  521. position: fixed;
  522. bottom: 0;
  523. width: 100%;
  524. background: white;
  525. padding: 10px 20px;
  526. button {
  527. width: 70%;
  528. cursor: pointer;
  529. }
  530. }
  531. .tip {
  532. width: 100%;
  533. background-color: #fff;
  534. border-radius: 10upx;
  535. font-size: 32upx;
  536. font-weight: bold;
  537. margin: 0 auto;
  538. padding: 20px;
  539. box-sizing: border-box;
  540. position: fixed;
  541. bottom: 0;
  542. }
  543. /* 底部的样式Start */
  544. .infoBottom {
  545. height: 140upx;
  546. position: fixed;
  547. bottom: 0;
  548. left: 0;
  549. right: 0;
  550. background: #ea552d;
  551. border-top: 1upx solid #ea552d;
  552. z-index: 99;
  553. margin-top: 100px;
  554. }
  555. .infoBottom>button {
  556. // font-size: 30upx;
  557. background: #fff;
  558. color: #333;
  559. flex: 1;
  560. margin: 0upx 30px;
  561. font-weight: bold;
  562. }
  563. /* 底部的样式End */
  564. </style>