quotation.vue 12 KB

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