quotation.vue 12 KB

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