quotation.vue 13 KB

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