quotation.vue 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598
  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>
  110. <text>{{item.amount}}</text>
  111. </view>
  112. <view>
  113. <text>¥{{item.coveragePremium}}</text>
  114. </view>
  115. </view>
  116. </view>
  117. </view>
  118. </view>
  119. <view class="infoBottom d-flex a-center j-center j-sb">
  120. <button type="default" class="d-flex a-center j-center" @tap="sendPayCode">发送到微信</button>
  121. </view>
  122. </view>
  123. </view>
  124. </template>
  125. <script>
  126. import {
  127. pathToBase64,
  128. base64ToPath
  129. } from '@/common/pdf.js'
  130. export default {
  131. data() {
  132. return {
  133. payImg: "",
  134. posterUrl: "",
  135. caricon: "", //carlogo
  136. show: false,
  137. companyId: "",
  138. dataInfo: {},
  139. carinfo: {}, //车辆信息
  140. ownerinfo: {}, //车主信息
  141. applyinfo: {}, //投保人信息
  142. insureinfo: {}, //被保人信息
  143. insCompanyList: [{
  144. name: "中煤财险",
  145. icon: "../../static/insuranceicon/zhongmei.png"
  146. }, //华农
  147. {
  148. name: "恒邦财险",
  149. icon: "../../static/insuranceicon/hengbang.png"
  150. },
  151. {
  152. name: "安盛天平",
  153. icon: "../../static/insuranceicon/ansheng.png"
  154. },
  155. {
  156. name: "中国人寿",
  157. icon: "../../static/insuranceicon/renshou.png"
  158. },
  159. {
  160. name: "众安财险",
  161. icon: "../../static/insuranceicon/zhongan.png"
  162. },
  163. {
  164. name: "永诚财险",
  165. icon: "../../static/insuranceicon/yongcheng.png"
  166. },
  167. {
  168. name: "永安财险",
  169. icon: "../../static/insuranceicon/yongan.png"
  170. },
  171. {
  172. name: "紫金财险",
  173. icon: "../../static/insuranceicon/zijin.png"
  174. },
  175. {
  176. name: "国任财险",
  177. icon: "../../static/insuranceicon/guoren.png"
  178. },
  179. {
  180. name: "华泰财险",
  181. icon: "../../static/insuranceicon/huatai.png"
  182. },
  183. {
  184. name: "大家财险",
  185. icon: "../../static/insuranceicon/dajia.png"
  186. },
  187. ],
  188. logoimg: "",
  189. }
  190. },
  191. async onLoad(options) {
  192. this.companyId = options.companyId;
  193. let params = {
  194. companyId: options.companyId
  195. };
  196. let res = await this.$http.post('/insurance/order/getByCompanyId', params);
  197. var data = res.data;
  198. data.kindinfo.map((ele, index) => {
  199. switch (ele.kindCode) {
  200. case "A":
  201. if (ele.amount == 1) {
  202. ele.amount = "投保"
  203. } else {
  204. ele.amount = ele.amount
  205. }
  206. break;
  207. case "D4":
  208. case "SY_FJ_YBW2":
  209. ele.unitAmount = this.toChinesNum(ele.unitAmount);
  210. break;
  211. case "MJ1":
  212. case "MJ2":
  213. case "MJ3":
  214. case "MJ4":
  215. ele.deductibleRate = ele.deductibleRate + "%";
  216. break;
  217. default:
  218. ele.amount = this.toChinesNum(ele.amount);
  219. }
  220. return ele;
  221. });
  222. this.insCompanyList.map(ele => {
  223. if (ele.name == data.inscompany) {
  224. uni.getImageInfo({
  225. src: ele.icon,
  226. success: image => {
  227. pathToBase64(image.path)
  228. .then(base64 => {
  229. this.logoimg = base64;
  230. })
  231. .catch(error => {});
  232. },
  233. fail: err => {}
  234. });
  235. }
  236. return ele;
  237. })
  238. this.dataInfo = data;
  239. this.carinfo = data.carinfo;
  240. this.ownerinfo = data.ownerinfo;
  241. this.applyinfo = data.applyinfo;
  242. this.insureinfo = data.insureinfo;
  243. uni.getImageInfo({
  244. src: '../../static/icon/bjdcar.png',
  245. success: image => {
  246. pathToBase64(image.path)
  247. .then(base64 => {
  248. this.caricon = base64
  249. })
  250. .catch(error => {});
  251. },
  252. });
  253. },
  254. methods: {
  255. //本地图片转换成base64
  256. turnBase64Image() {
  257. this.
  258. uni.getImageInfo({
  259. src: img,
  260. success: image => {
  261. pathToBase64(image.path)
  262. .then(base64 => {
  263. this[key] = base64;
  264. })
  265. .catch(error => {});
  266. },
  267. fail: err => {}
  268. });
  269. },
  270. toChinesNum(num) {
  271. let changeNum = [
  272. "零", "1", "2", "3", "4", "5", "6", "7", "8", "9"
  273. ];
  274. let unit = ["", "0", "00", "000", "0000"];
  275. num = parseInt(num);
  276. let getWan = temp => {
  277. let strArr = temp
  278. .toString()
  279. .split("")
  280. .reverse();
  281. let newNum = "";
  282. let newArr = [];
  283. strArr.forEach((item, index) => {
  284. newArr.unshift(
  285. item === "0" ? changeNum[item] : changeNum[item] + unit[index]
  286. );
  287. });
  288. let numArr = [];
  289. newArr.forEach((m, n) => {
  290. if (m !== "零") numArr.push(n);
  291. });
  292. if (newArr.length > 1) {
  293. newArr.forEach((m, n) => {
  294. if (newArr[newArr.length - 1] === "零") {
  295. if (n <= numArr[numArr.length - 1]) {
  296. newNum += m;
  297. }
  298. } else {
  299. newNum += m;
  300. }
  301. });
  302. } else {
  303. newNum = newArr[0];
  304. }
  305. return newNum;
  306. };
  307. let overWan = Math.floor(num / 10000);
  308. let noWan = num % 10000;
  309. if (noWan.toString().length < 4) {
  310. noWan = "0" + noWan;
  311. }
  312. return overWan ? getWan(overWan) + "万" + getWan(noWan) : getWan(num);
  313. },
  314. //分享图片到微信
  315. sendPayCode() {
  316. if (this.payImg) {
  317. uni.share({
  318. provider: "weixin",
  319. scene: "WXSceneSession",
  320. type: 2,
  321. imageUrl: this.payImg
  322. })
  323. }
  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. // #ifdef APP-PLUS
  354. setTimeout(() => {
  355. this.canvasImage.generateImage()
  356. }, 1000);
  357. // #endif
  358. },
  359. methods: {
  360. // #ifdef APP-PLUS
  361. generateImage() {
  362. setTimeout(() => {
  363. this.$ownerInstance.callMethod('showLoading')
  364. const dom = document.getElementById('panelcanvas') // 需要生成图片内容的 dom 节点
  365. html2canvas(dom, {
  366. width: dom.clientWidth, //dom 原始宽度
  367. height: dom.clientHeight,
  368. scrollY: 0, // html2canvas默认绘制视图内的页面,需要把scrollY,scrollX设置为0
  369. scrollX: 0,
  370. useCORS: true, //支持跨域
  371. // allowTaint: false,
  372. scale: 2, // 设置生成图片的像素比例,默认是1,如果生成的图片模糊的话可以开启该配置项
  373. }).then((canvas) => {
  374. // 生成成功
  375. this.$ownerInstance.callMethod('hideLoading')
  376. this.$ownerInstance.callMethod('receiveRenderData', canvas.toDataURL('image/png'))
  377. }).catch(err => {
  378. // 生成失败 弹出提示弹窗
  379. this.$ownerInstance.callMethod('_errAlert', `【生成图片失败,请重试】${err}`)
  380. })
  381. }, 300)
  382. }
  383. // #endif
  384. },
  385. }
  386. </script>
  387. <style lang="scss" scoped>
  388. @import '@/style/mixin.scss';
  389. .page {
  390. background-color: rgba(234, 85, 45, 1);
  391. padding: 20px 10px 100px 10px;
  392. box-sizing: border-box;
  393. }
  394. .Basic-information {
  395. background-color: white;
  396. width: 100%;
  397. height: auto;
  398. .basic-logo {
  399. padding: 10px 16px;
  400. border-bottom: 1px solid #f2f2f2;
  401. image {
  402. width: 50px;
  403. height: 50px;
  404. margin-right: 20px;
  405. }
  406. text {
  407. font-size: 12px;
  408. }
  409. text:first-child {
  410. font-weight: bold;
  411. font-size: 18px;
  412. }
  413. }
  414. .basic-data {
  415. padding: 16px;
  416. .arrange {
  417. margin: 4px 0;
  418. font-size: 14px;
  419. text:first-child {
  420. font-weight: bold;
  421. margin-right: 5px;
  422. }
  423. text:last-child {
  424. color: #606266;
  425. }
  426. &::before {
  427. content: "·";
  428. color: #606266;
  429. margin-right: 10px;
  430. font-weight: bold;
  431. }
  432. }
  433. }
  434. .bjdCarSum {
  435. padding: 10px 16px;
  436. border-bottom: 1px solid #f2f2f2;
  437. font-weight: bold;
  438. font-size: 14px;
  439. }
  440. .coverage {
  441. padding: 10px 16px;
  442. .coverage-title {
  443. width: 100%;
  444. view:first-child {
  445. border-top-left-radius: 8px;
  446. }
  447. view:last-child {
  448. border-top-right-radius: 8px;
  449. }
  450. view:nth-child(2) {
  451. border-left: none;
  452. border-right: none;
  453. }
  454. view {
  455. width: 33.33%;
  456. text-align: center;
  457. background: #ff8f63;
  458. color: #fff;
  459. padding: 6px 16px;
  460. border: 1px solid #fff;
  461. font-size: 12px;
  462. box-sizing: border-box;
  463. }
  464. }
  465. .coverage-sum {
  466. width: 100%;
  467. view:nth-child(2) {
  468. border-left: none;
  469. border-right: none;
  470. }
  471. view {
  472. width: 33.33%;
  473. text-align: center;
  474. font-size: 12px;
  475. background-color: #fbf6f7;
  476. padding: 6px 16px;
  477. border: 1px solid #fff;
  478. border-top: none;
  479. }
  480. }
  481. }
  482. }
  483. .Circle {
  484. position: relative;
  485. &::before {
  486. display: block;
  487. content: "";
  488. position: absolute;
  489. width: 20px;
  490. height: 20px;
  491. background: rgba(234, 85, 45, 1);
  492. top: -10px;
  493. left: -10px;
  494. border-radius: 50%;
  495. }
  496. &::after {
  497. content: "";
  498. position: absolute;
  499. width: 20px;
  500. height: 20px;
  501. background: rgba(234, 85, 45, 1);
  502. top: -10px;
  503. right: -10px;
  504. border-radius: 50%;
  505. }
  506. }
  507. .footer-button {
  508. z-index: 9999;
  509. margin-top: 20px;
  510. position: fixed;
  511. bottom: 0;
  512. width: 100%;
  513. background: white;
  514. padding: 10px 20px;
  515. button {
  516. width: 70%;
  517. cursor: pointer;
  518. }
  519. }
  520. .tip {
  521. width: 100%;
  522. background-color: #fff;
  523. border-radius: 10upx;
  524. font-size: 32upx;
  525. font-weight: bold;
  526. margin: 0 auto;
  527. padding: 20px;
  528. box-sizing: border-box;
  529. position: fixed;
  530. bottom: 0;
  531. }
  532. /* 底部的样式Start */
  533. .infoBottom {
  534. height: 140upx;
  535. position: fixed;
  536. bottom: 0;
  537. left: 0;
  538. right: 0;
  539. background: #ea552d;
  540. border-top: 1upx solid #ea552d;
  541. z-index: 99;
  542. margin-top: 100px;
  543. }
  544. .infoBottom>button {
  545. // font-size: 30upx;
  546. background: #fff;
  547. color: #333;
  548. flex: 1;
  549. margin: 0upx 30px;
  550. font-weight: bold;
  551. }
  552. /* 底部的样式End */
  553. </style>