quoteOffer1.vue 24 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814
  1. <template>
  2. <view class="page page-fill" :style="getHeight">
  3. <!-- 公共组件-每个页面必须引入 -->
  4. <public-module></public-module>
  5. <view class="pending-wapper">
  6. <image id="face" :src="imgBase64" class="pending-face" mode="scaleToFill" v-if="imgBase64"></image>
  7. </view>
  8. <view class="footer-opertor">
  9. <view class="opertor-words" @click="save">保存到本地</view>
  10. <!-- #ifndef H5 -->
  11. <view class="opertor-words" @click="share">分享到微信</view>
  12. <!-- #endif -->
  13. </view>
  14. <!-- 绘制掌柜报价单模板 -->
  15. <canvas canvas-id="myCanvas" id='canvasImg' @error="canvasIdErrorCallback" style=""></canvas>
  16. </view>
  17. </template>
  18. <script>
  19. export default {
  20. data() {
  21. return {
  22. imgBase64: null, //掌柜报价单图片
  23. orderno: "", //订单号
  24. icon: "", //保险公司logo
  25. name: "", //保险公司名称
  26. insCompanyCode: "", //保险公司表示
  27. carInfo: {}, //车辆信息
  28. ownerInfo: {}, //车主信息
  29. policyHolderInfo: {}, //投保人信息
  30. insuredPersonInfo: {}, //被保人信息
  31. riskList: [], //险种大类信息
  32. kindList: [], //商业险险别
  33. sumPermium: "", //报价金额
  34. taxAmount: "", //车船税金额
  35. insureList: [{
  36. amount: "0",
  37. coveragePremium: "",
  38. amtList: [{
  39. "label": "投保",
  40. "value": "1"
  41. }],
  42. kindCode: "A",
  43. isMainRisk: true,
  44. kindName: "机动车损失险"
  45. },
  46. {
  47. amount: "0",
  48. coveragePremium: "",
  49. amtList: [{
  50. "label": "10万",
  51. "value": "100000"
  52. }, {
  53. "label": "15万",
  54. "value": "150000"
  55. }, {
  56. "label": "20万",
  57. "value": "200000"
  58. }, {
  59. "label": "30万",
  60. "value": "300000"
  61. }, {
  62. "label": "50万",
  63. "value": "500000"
  64. }, {
  65. "label": "100万",
  66. "value": "1000000"
  67. }, {
  68. "label": "150万",
  69. "value": "1500000"
  70. }, {
  71. "label": "200万",
  72. "value": "2000000"
  73. }, {
  74. "label": "250万",
  75. "value": "2500000"
  76. }, {
  77. "label": "300万",
  78. "value": "3000000"
  79. }, {
  80. "label": "500万",
  81. "value": "5000000"
  82. }, {
  83. "label": "1000万",
  84. "value": "10000000"
  85. }],
  86. kindCode: "B",
  87. isMainRisk: true,
  88. kindName: "第三者责任险"
  89. },
  90. {
  91. amount: "0",
  92. coveragePremium: "",
  93. amtList: [{
  94. "label": "1万",
  95. "value": "10000"
  96. }, {
  97. "label": "2万",
  98. "value": "20000"
  99. }, {
  100. "label": "5万",
  101. "value": "50000"
  102. }, {
  103. "label": "10万",
  104. "value": "100000"
  105. }, {
  106. "label": "15万",
  107. "value": "150000"
  108. }, {
  109. "label": "20万",
  110. "value": "200000"
  111. }],
  112. kindCode: "D3",
  113. isMainRisk: true,
  114. kindName: "司机责任险"
  115. },
  116. {
  117. amount: "0",
  118. coveragePremium: "",
  119. amtList: [{
  120. "label": "1万",
  121. "value": "10000"
  122. }, {
  123. "label": "2万",
  124. "value": "20000"
  125. }, {
  126. "label": "5万",
  127. "value": "50000"
  128. }, {
  129. "label": "10万",
  130. "value": "100000"
  131. }, {
  132. "label": "15万",
  133. "value": "150000"
  134. }, {
  135. "label": "20万",
  136. "value": "200000"
  137. }],
  138. kindCode: "D4",
  139. isMainRisk: true,
  140. kindName: "乘客责任险"
  141. },
  142. {
  143. amount: "0",
  144. coveragePremium: "",
  145. amtList: [{
  146. "label": "2000",
  147. "value": "2000"
  148. }, {
  149. "label": "5000",
  150. "value": "5000"
  151. }, {
  152. "label": "1万",
  153. "value": "10000"
  154. }],
  155. isMainRisk: false,
  156. kindCode: "L",
  157. kindName: "车身划痕险",
  158. mainRiskCodeList: "A"
  159. },
  160. {
  161. amount: "0",
  162. coveragePremium: "",
  163. amtList: [{
  164. "label": "5%",
  165. "value": "5"
  166. }, {
  167. "label": "10%",
  168. "value": "10"
  169. }, {
  170. "label": "15%",
  171. "value": "15"
  172. }, {
  173. "label": "20%",
  174. "value": "20"
  175. }],
  176. isMainRisk: false,
  177. kindCode: "MJ1",
  178. kindName: "绝对免赔率特约险(车损)",
  179. mainRiskCodeList: "A"
  180. },
  181. {
  182. amount: "0",
  183. coveragePremium: "",
  184. amtList: [{
  185. "label": "5%",
  186. "value": "5"
  187. }, {
  188. "label": "10%",
  189. "value": "10"
  190. }, {
  191. "label": "15%",
  192. "value": "15"
  193. }, {
  194. "label": "20%",
  195. "value": "20"
  196. }],
  197. isMainRisk: false,
  198. kindCode: "MJ2",
  199. kindName: "绝对免赔率特约险(三者)",
  200. mainRiskCodeList: "B"
  201. },
  202. {
  203. amount: "0",
  204. coveragePremium: "",
  205. amtList: [{
  206. "label": "5%",
  207. "value": "5"
  208. }, {
  209. "label": "10%",
  210. "value": "10"
  211. }, {
  212. "label": "15%",
  213. "value": "15"
  214. }, {
  215. "label": "20%",
  216. "value": "20"
  217. }],
  218. isMainRisk: false,
  219. kindCode: "MJ3",
  220. kindName: "绝对免赔率特约险(司机)",
  221. mainRiskCodeList: "D3"
  222. },
  223. {
  224. amount: "0",
  225. coveragePremium: "",
  226. amtList: [{
  227. "label": "5%",
  228. "value": "5"
  229. }, {
  230. "label": "10%",
  231. "value": "10"
  232. }, {
  233. "label": "15%",
  234. "value": "15"
  235. }, {
  236. "label": "20%",
  237. "value": "20"
  238. }],
  239. isMainRisk: false,
  240. kindCode: "MJ4",
  241. kindName: "绝对免赔率特约险(乘客)",
  242. mainRiskCodeList: "D4"
  243. },
  244. {
  245. amount: "0",
  246. coveragePremium: "",
  247. amtList: [{
  248. "label": "投保",
  249. "value": "1"
  250. }],
  251. isMainRisk: false,
  252. kindCode: "BD",
  253. kindName: "法定节假日限额翻倍险",
  254. mainRiskCodeList: "B"
  255. }
  256. ],
  257. box: {},
  258. }
  259. },
  260. computed: {
  261. getHeight() {
  262. let height = uni.getSystemInfoSync().windowHeight;
  263. return `height: ${height}px;`;
  264. }
  265. },
  266. async onLoad(params) {
  267. uni.getSystemInfo({
  268. success(res) {
  269. console.log(res)
  270. this.popWidth = res.windowWidth;
  271. this.popWidth = res.windowWidth;
  272. // 设备像素比大于1
  273. if (res.devicePixelRatio > 1) {
  274. this.devicePixelRatio = res.devicePixelRatio;
  275. }
  276. }
  277. });
  278. if (params.orderno != undefined) {
  279. this.orderno = params.orderno;
  280. let res = await this.$http.get('/insOrder/queryOrder?orderno=' + params.orderno);
  281. console.log(res)
  282. if (res.code == 200) {
  283. //获取前一个页面传过来的信息(车辆信息,人员信息,险种信息)
  284. this.insCompanyCode = res.data.inscompany;
  285. this.icon = "";
  286. this.name = res.data.inscompany;
  287. this.carInfo = res.data.carinfo;
  288. this.ownerInfo = res.data.ownerinfo;
  289. this.policyHolderInfo = res.data.applyinfo;
  290. this.insuredPersonInfo = res.data.insureinfo;
  291. this.riskList = res.data.riskinfo;
  292. this.kindList = res.data.kindinfo;
  293. this.sumPermium = res.data.sumpremium;
  294. this.taxAmount = res.data.taxamount;
  295. if (this.riskList.length > 0) {
  296. for (let i = 0; i < this.riskList.length; i++) {
  297. if (this.riskList[i].riskCode == '0510') {
  298. for (let j = 0; j < this.kindList.length; j++) {
  299. for (let m = 0; m < this.insureList.length; m++) {
  300. if (this.kindList[j].kindCode == this.insureList[m].kindCode) {
  301. this.insureList[m].coveragePremium = this.kindList[j].coveragePremium;
  302. if (this.kindList[j].kindCode == 'B') {
  303. this.insureList[9].amtList[0].value = this.kindList[j].amount;
  304. }
  305. if (this.kindList[j].kindCode == 'A') {
  306. this.insureList[m].amount = '1';
  307. } else if (this.insureList[m].kindCode == 'D4') {
  308. this.insureList[m].amount = this.kindList[j].unitAmount;
  309. } else if (this.insureList[m].isMainRisk || (this.insureList[m].kindCode ==
  310. 'BD') || (this.insureList[m].kindCode == 'L')) {
  311. this.insureList[m].amount = this.kindList[j].amount;
  312. } else {
  313. this.insureList[m].amount = this.kindList[j].deductibleRate;
  314. }
  315. }
  316. }
  317. }
  318. }
  319. }
  320. }
  321. this.mounted();
  322. }
  323. } else {
  324. uni.showModal({
  325. showCancel: false,
  326. title: "未查询到该订单"
  327. })
  328. }
  329. },
  330. methods: {
  331. canvasIdErrorCallback: function(e) {
  332. console.error(e.detail.errMsg)
  333. },
  334. // 保存到本地
  335. save() {
  336. uni.saveImageToPhotosAlbum({ //保存图片
  337. filePath: this.imgBase64,
  338. success: (res) => {
  339. uni.showToast({
  340. title: '保存成功',
  341. })
  342. }
  343. })
  344. },
  345. // 分享到微信
  346. share() {
  347. uni.share({
  348. provider: "weixin",
  349. scene: "WXSceneSession",
  350. type: 2,
  351. imageUrl: this.imgBase64
  352. })
  353. },
  354. // 绘制掌柜报价单
  355. drawQuoteOffer() {
  356. uni.showLoading({ //增加loading等待效果
  357. mask: true,
  358. title: "报价单生成中"
  359. })
  360. let ww, hh;
  361. const query = uni.createSelectorQuery().in(this);
  362. query.select('#canvasImg').boundingClientRect((data) => { //获取canvas-dom
  363. ww = data.width; //准确的宽高
  364. hh = data.height;
  365. var ctx = uni.createCanvasContext('myCanvas') //绑定画布
  366. var rectH = 10;
  367. var rectW = 20;
  368. ctx.lineWidth = 0.1; //线条的宽度
  369. ctx.strokeStyle = "#000"; //线条的颜色
  370. ctx.setFillStyle('#FFF'); //设置颜色为白色
  371. ctx.fillRect(0, 0, ww, hh); //把画布
  372. // ctx.drawImage('../../static/logo.png', 0, 0, ww, hh); //填充进图片
  373. for (var p = 0; p < 8; p++) { //水印
  374. for (var q = 0; q < 10; q++) {
  375. // 绘制文字 注意::绘制斜体文字 旋转以后会发生位移,所以必须在旋转之后进行位置的调整;
  376. var text = "掌柜车险";
  377. ctx.save(); //保存原来的状态 绘制字体都是需要旋转倾斜 那么之前绘制的图片就要进行状态的保存
  378. ctx.rotate(-Math.PI / 6); //绘制倾斜字体
  379. ctx.translate(q * -80, 40 * p); //发生位移进行位移的恢复
  380. ctx.font = "10px serif";
  381. ctx.fillStyle = 'rgba(30, 30, 30, 0.1)';
  382. ctx.fillText(text, p * 50, (q * 30) + 50);
  383. ctx.restore(); //状态的恢复
  384. }
  385. }
  386. ctx.setFillStyle('#f00') //设置内容1的文字样式
  387. ctx.font = "12px 楷体";
  388. ctx.setTextAlign('center') //设置对于坐标点的对齐方式
  389. ctx.fillText("掌柜车险报价方案", ww / 2, 25) //计算距离,将文字定位于图片的某处
  390. ctx.setFillStyle('#000') //设置内容1的文字样式
  391. ctx.font = "6px 宋体";
  392. ctx.setTextAlign('left') //设置对于坐标点的对齐方式
  393. var today = new Date().getFullYear() + '年' + (new Date().getMonth() + 1) + '月' + new Date()
  394. .getDate() + '日';
  395. ctx.fillText("尊敬的客户,您于" + today + "车险投保方案如下:", 20, 40) //计算距离,将文字定位于图片的某处
  396. ctx.font = "8px 楷体";
  397. ctx.setTextAlign('center') //设置对于坐标点的对齐方式
  398. // ctx.setFillStyle(company.color) //设置内容1的文字样式
  399. ctx.fillText(this.name + "车险投保方案", ww / 2, 55) //计算距离,将文字定位于图片的某处
  400. //绘制表格
  401. for (var i = 0; i < 8; i++) { //绘制横线
  402. ctx.moveTo(20, rectH * i + 60); //如果不设置moveTo,当前画笔没有位置
  403. ctx.lineTo(ww - 20, rectH * i + 60);
  404. }
  405. ctx.moveTo(20, 60); //五条竖线
  406. ctx.lineTo(20, 130);
  407. ctx.moveTo(65, 60);
  408. ctx.lineTo(65, 130);
  409. ctx.moveTo(150, 60);
  410. ctx.lineTo(150, 130);
  411. ctx.moveTo(200, 60);
  412. ctx.lineTo(200, 130);
  413. ctx.moveTo(ww - 20, 60);
  414. ctx.lineTo(ww - 20, 130);
  415. // 填充表格内容
  416. ctx.setFillStyle('#000') //设置内容1的文字样式
  417. ctx.font = "5px 宋体";
  418. ctx.setTextAlign('center') //设置对于坐标点的对齐方式
  419. ctx.fillText("被保险人", 42, 67)
  420. ctx.fillText("发动机号", 42, 77)
  421. ctx.fillText("车辆类型", 42, 87)
  422. ctx.fillText("车辆型号", 42, 97)
  423. ctx.fillText("核定载质量", 42, 107)
  424. ctx.fillText("新车购置价", 42, 117)
  425. ctx.fillText("交强险起保日期", 42, 127)
  426. ctx.fillText(this.ownerInfo.name, 107, 67)
  427. ctx.fillText(this.carInfo.engineNo, 107, 77)
  428. ctx.fillText(this.carInfo.licenseTypeCode, 107, 87)
  429. ctx.fillText(this.carInfo.brandName, 107, 97)
  430. ctx.fillText(this.carInfo.limitLoad, 107, 107)
  431. ctx.fillText(this.carInfo.purchasePrice, 107, 117)
  432. for (let i = 0; i < this.riskList.length; i++) {
  433. if (this.riskList[i].riskCode == '0507') {
  434. ctx.fillText(this.riskList[i].startDate, 107, 127);
  435. }
  436. }
  437. ctx.fillText("车牌号码", 175, 67)
  438. ctx.fillText("车架号", 175, 77)
  439. ctx.fillText("能源类型", 175, 87)
  440. ctx.fillText("初登日期", 175, 97)
  441. ctx.fillText("核定载客量", 175, 107)
  442. ctx.fillText("汽车排量", 175, 117)
  443. ctx.fillText("商业险起保日期", 175, 127)
  444. ctx.fillText(String(this.carInfo.licenseNo), (ww + 180) / 2, 67)
  445. ctx.fillText(String(this.carInfo.vinNo), (ww + 180) / 2, 77)
  446. ctx.fillText(String(this.carInfo.powertype), (ww + 180) / 2, 87)
  447. /* */
  448. if (!!this.carInfo.registerDate) {
  449. let year1 = new Date(this.carInfo.registerDate).getFullYear()
  450. let month1 = new Date(this.carInfo.registerDate).getMonth() + 1
  451. if (month1 < 10) {
  452. month1 = '0' + month1;
  453. }
  454. let day1 = new Date(this.carInfo.registerDate).getDate()
  455. if (day1 < 10) {
  456. day1 = '0' + day1;
  457. }
  458. this.carInfo.registerDate = year1 + '-' + month1 + '-' + day1
  459. }
  460. ctx.fillText(this.carInfo.registerDate, (ww + 180) / 2, 97)
  461. ctx.fillText(this.carInfo.seatCount, (ww + 180) / 2, 107)
  462. ctx.fillText(this.carInfo.enginedesc, (ww + 180) / 2, 117)
  463. for (let i = 0; i < this.riskList.length; i++) {
  464. if (this.riskList[i].riskCode == '0510') {
  465. ctx.fillText(this.riskList[i].startDate, (ww + 180) / 2, 127)
  466. }
  467. }
  468. if ((this.riskList.length == 1) && (this.riskList[0].riskCode == '0507')) { //单交强
  469. ctx.moveTo(20, 140); //标题栏
  470. ctx.lineTo(ww - 20, 140);
  471. ctx.moveTo(20, 150);
  472. ctx.lineTo(ww - 20, 150);
  473. ctx.moveTo(20, 160);
  474. ctx.lineTo(ww - 20, 160);
  475. ctx.moveTo(20, 170);
  476. ctx.lineTo(ww - 20, 170);
  477. ctx.moveTo(20, 180);
  478. ctx.lineTo(ww - 20, 180);
  479. ctx.moveTo(20, 140); //三条竖线
  480. ctx.lineTo(20, 180);
  481. ctx.moveTo(120, 140);
  482. ctx.lineTo(120, 180);
  483. ctx.moveTo(200, 140);
  484. ctx.lineTo(200, 160);
  485. ctx.moveTo(ww - 20, 140);
  486. ctx.lineTo(ww - 20, 180);
  487. ctx.setTextAlign('center')
  488. ctx.fillText("险别名称", 70, 147)
  489. ctx.fillText("保额(元)", 160, 147)
  490. ctx.fillText("保费(元)", (ww + 200) / 2, 147)
  491. ctx.fillText("交强险", 70, 157)
  492. ctx.setTextAlign('right')
  493. ctx.fillText(this.riskList[0].amount, 165, 157)
  494. ctx.fillText(this.riskList[0].premium, ww - 24, 157)
  495. ctx.setTextAlign('center')
  496. ctx.fillText("代收车船税", 70, 167)
  497. ctx.setTextAlign('right')
  498. ctx.fillText(this.taxAmount, ww - 24, 167)
  499. ctx.setTextAlign('center')
  500. ctx.fillText("保费合计", 70, 177)
  501. ctx.setTextAlign('right')
  502. ctx.fillText(this.sumPermium, ww - 24, 177)
  503. // ctx.setFillStyle(company.color) //设置内容1的文字样式
  504. // ctx.setFillStyle('#f00')
  505. ctx.font = "8px 楷体";
  506. ctx.setTextAlign('left')
  507. ctx.fillText("掌柜车险,您全方位立体式的车服务管家,为您的爱车保驾护航!", 20, 197) //计算距离,将文字定位于图片的某处
  508. ctx.fillText("祝您幸福安康,工作顺心!", 20, 207) //计算距离,将文字定位于图片的某处
  509. }
  510. if ((this.riskList.length == 1) && (this.riskList[0].riskCode == '0510')) { //单商业
  511. ctx.moveTo(20, 140); //标题栏
  512. ctx.lineTo(ww - 20, 140);
  513. ctx.moveTo(20, 150);
  514. ctx.lineTo(ww - 20, 150);
  515. ctx.moveTo(20, 140); //三条竖线
  516. ctx.lineTo(20, 150);
  517. ctx.moveTo(120, 140);
  518. ctx.lineTo(120, 150);
  519. ctx.moveTo(200, 140);
  520. ctx.lineTo(200, 150);
  521. ctx.moveTo(ww - 20, 140);
  522. ctx.lineTo(ww - 20, 150);
  523. ctx.setTextAlign('center')
  524. ctx.fillText("险别名称", 70, 147)
  525. ctx.fillText("保额(元)", 160, 147)
  526. ctx.fillText("保费(元)", (ww + 200) / 2, 147)
  527. var lineSum = 0;
  528. var deductiblePriceSum = 0;
  529. for (let i = 0; i < this.insureList.length; i++) {
  530. if (this.insureList[i].amount != 0) {
  531. ctx.setTextAlign('center')
  532. ctx.fillText(this.insureList[i].kindName, 70, 157 + rectH * lineSum)
  533. for (let j = 0; j < this.insureList[i].amtList.length; j++) {
  534. if (this.insureList[i].amount == this.insureList[i].amtList[j].value) {
  535. ctx.fillText(this.insureList[i].amtList[j].label, 160, 157 + rectH *
  536. lineSum)
  537. ctx.fillText(this.insureList[i].coveragePremium, (ww + 200) / 2, 157 +
  538. rectH * lineSum)
  539. }
  540. }
  541. lineSum++;
  542. }
  543. }
  544. for (var i = 0; i < lineSum; i++) {
  545. ctx.moveTo(20, 150 + rectH * i); //三条竖线
  546. ctx.lineTo(20, 160 + rectH * i);
  547. ctx.moveTo(120, 150 + rectH * i);
  548. ctx.lineTo(120, 160 + rectH * i);
  549. ctx.moveTo(200, 150 + rectH * i);
  550. ctx.lineTo(200, 160 + rectH * i);
  551. ctx.moveTo(ww - 20, 150 + rectH * i);
  552. ctx.lineTo(ww - 20, 160 + rectH * i);
  553. ctx.moveTo(20, 160 + rectH * i);
  554. ctx.lineTo(ww - 20, 160 + rectH * i);
  555. }
  556. ctx.moveTo(20, 160 + rectH * lineSum);
  557. ctx.lineTo(ww - 20, 160 + rectH * lineSum);
  558. ctx.moveTo(20, 150 + rectH * lineSum); //三条竖线
  559. ctx.lineTo(20, 170 + rectH * lineSum);
  560. ctx.moveTo(120, 150 + rectH * lineSum);
  561. ctx.lineTo(120, 170 + rectH * lineSum);
  562. ctx.moveTo(ww - 20, 150 + rectH * lineSum);
  563. ctx.lineTo(ww - 20, 170 + rectH * lineSum);
  564. // 合计
  565. for (var j = 0; j < 1; j++) {
  566. ctx.moveTo(20, 170 + rectH * (lineSum + j));
  567. ctx.lineTo(ww - 20, 170 + rectH * (lineSum + j));
  568. }
  569. // 填充合计
  570. ctx.setTextAlign('center')
  571. ctx.fillText("商业险合计", 70, 157 + rectH * lineSum)
  572. ctx.setTextAlign('right')
  573. ctx.fillText(this.riskList[0].premium, ww - 24, 157 + rectH * lineSum)
  574. ctx.setTextAlign('center')
  575. ctx.fillText("保费合计", 70, 167 + rectH * lineSum)
  576. ctx.setTextAlign('right')
  577. ctx.fillText(this.sumPermium, ww - 24, 167 + rectH * lineSum)
  578. // ctx.setFillStyle(company.color) //设置内容1的文字样式
  579. // ctx.setFillStyle('#f00')
  580. ctx.font = "8px 楷体";
  581. ctx.setTextAlign('left')
  582. ctx.fillText("掌柜车险,您全方位立体式的车服务管家,为您的爱车保驾护航!", 20, 185 + rectH * lineSum) //计算距离,将文字定位于图片的某处
  583. ctx.fillText("祝您幸福安康,工作顺心!", 20, 195 + rectH * lineSum) //计算距离,将文字定位于图片的某处
  584. }
  585. if (this.riskList.length == 2) {
  586. ctx.moveTo(20, 140); //标题栏
  587. ctx.lineTo(ww - 20, 140);
  588. ctx.moveTo(20, 150);
  589. ctx.lineTo(ww - 20, 150);
  590. ctx.moveTo(20, 140); //三条竖线
  591. ctx.lineTo(20, 150);
  592. ctx.moveTo(120, 140);
  593. ctx.lineTo(120, 150);
  594. ctx.moveTo(200, 140);
  595. ctx.lineTo(200, 150);
  596. ctx.moveTo(ww - 20, 140);
  597. ctx.lineTo(ww - 20, 150);
  598. ctx.setTextAlign('center')
  599. ctx.fillText("险别名称", 70, 147)
  600. ctx.fillText("标准保费", 160, 147)
  601. ctx.fillText("保费(元)", (ww + 200) / 2, 147)
  602. var lineSum = 0;
  603. var deductiblePriceSum = 0;
  604. for (let i = 0; i < this.insureList.length; i++) {
  605. if (this.insureList[i].amount != 0) {
  606. ctx.setTextAlign('center')
  607. ctx.fillText(this.insureList[i].kindName, 70, 157 + rectH * lineSum)
  608. for (let j = 0; j < this.insureList[i].amtList.length; j++) {
  609. if (this.insureList[i].amount == this.insureList[i].amtList[j].value) {
  610. ctx.fillText(this.insureList[i].amtList[j].label, 160, 157 + rectH *
  611. lineSum)
  612. ctx.fillText(this.insureList[i].coveragePremium, (ww + 200) / 2, 157 +
  613. rectH * lineSum)
  614. }
  615. }
  616. lineSum++;
  617. }
  618. }
  619. for (var i = 0; i < lineSum; i++) {
  620. ctx.moveTo(20, 150 + rectH * i); //三条竖线
  621. ctx.lineTo(20, 160 + rectH * i);
  622. ctx.moveTo(120, 150 + rectH * i);
  623. ctx.lineTo(120, 160 + rectH * i);
  624. ctx.moveTo(200, 150 + rectH * i);
  625. ctx.lineTo(200, 160 + rectH * i);
  626. ctx.moveTo(ww - 20, 150 + rectH * i);
  627. ctx.lineTo(ww - 20, 160 + rectH * i);
  628. ctx.moveTo(20, 160 + rectH * i);
  629. ctx.lineTo(ww - 20, 160 + rectH * i);
  630. }
  631. ctx.moveTo(20, 160 + rectH * lineSum);
  632. ctx.lineTo(ww - 20, 160 + rectH * lineSum);
  633. ctx.moveTo(20, 150 + rectH * lineSum); //三条竖线
  634. ctx.lineTo(20, 190 + rectH * lineSum);
  635. ctx.moveTo(120, 150 + rectH * lineSum);
  636. ctx.lineTo(120, 190 + rectH * lineSum);
  637. ctx.moveTo(200, 160 + rectH * lineSum);
  638. ctx.lineTo(200, 170 + rectH * lineSum);
  639. ctx.moveTo(ww - 20, 150 + rectH * lineSum);
  640. ctx.lineTo(ww - 20, 190 + rectH * lineSum);
  641. // // 合计
  642. for (var j = 0; j < 3; j++) {
  643. ctx.moveTo(20, 170 + rectH * (lineSum + j));
  644. ctx.lineTo(ww - 20, 170 + rectH * (lineSum + j));
  645. }
  646. // 填充合计
  647. ctx.setTextAlign('center')
  648. ctx.fillText("商业险合计", 70, 157 + rectH * lineSum)
  649. ctx.setTextAlign('right')
  650. for (let i = 0; i < this.riskList.length; i++) {
  651. if (this.riskList[i].riskCode == '0510') {
  652. ctx.fillText(this.riskList[i].premium, ww - 24, 157 + rectH * lineSum)
  653. }
  654. }
  655. ctx.setTextAlign('center')
  656. ctx.fillText("交强险", 70, 167 + rectH * lineSum)
  657. ctx.setTextAlign('right')
  658. for (let i = 0; i < this.riskList.length; i++) {
  659. if (this.riskList[i].riskCode == '0507') {
  660. ctx.fillText(this.riskList[i].amount, 170, 167 + rectH * lineSum)
  661. ctx.fillText(this.riskList[i].premium, ww - 24, 167 + rectH * lineSum)
  662. }
  663. }
  664. ctx.setTextAlign('center')
  665. ctx.fillText("代收车船税", 70, 177 + rectH * lineSum)
  666. ctx.setTextAlign('right')
  667. ctx.fillText(this.taxAmount, ww - 24, 177 + rectH * lineSum)
  668. ctx.setTextAlign('center')
  669. ctx.fillText("保费合计", 70, 187 + rectH * lineSum)
  670. ctx.setTextAlign('right')
  671. ctx.fillText(this.sumPermium, ww - 24, 187 + rectH * lineSum)
  672. // ctx.setFillStyle(company.color) //设置内容1的文字样式
  673. // // ctx.setFillStyle('#f00')
  674. ctx.font = "8px 楷体";
  675. ctx.setTextAlign('left')
  676. ctx.fillText("掌柜车险,您全方位立体式的车服务管家,为您的爱车保驾护航!", 20, 205 + rectH * lineSum) //计算距离,将文字定位于图片的某处
  677. ctx.fillText("祝您幸福安康,工作顺心!", 20, 215 + rectH * lineSum) //计算距离,将文字定位于图片的某处
  678. }
  679. setTimeout(() => { //不加延迟的话,base64有时候会赋予undefined
  680. ctx.stroke(); //画线
  681. ctx.draw(); //输出到画布中
  682. uni.canvasToTempFilePath({
  683. canvasId: 'myCanvas',
  684. success: (res) => {
  685. this.imgBase64 = res.tempFilePath;
  686. uni.hideLoading();
  687. }
  688. })
  689. }, 1200)
  690. }).exec();
  691. },
  692. },
  693. mounted() {
  694. setTimeout(() => {
  695. this.drawQuoteOffer();
  696. }, 300);
  697. },
  698. }
  699. </script>
  700. <style>
  701. #canvasImg {
  702. position: absolute;
  703. width: 595rpx;
  704. height: 842rpx;
  705. top: -99999899rpx;
  706. }
  707. /* 页面铺满屏幕 */
  708. .page-fill {
  709. width: 100%;
  710. position: absolute;
  711. background-color: black;
  712. }
  713. .pending-wapper {
  714. display: flex;
  715. flex-direction: row;
  716. justify-content: center;
  717. margin-top: 120upx;
  718. }
  719. .pending-face {
  720. width: 595upx;
  721. height: 842upx;
  722. }
  723. /* 底部操作Start */
  724. .footer-opertor {
  725. position: fixed;
  726. bottom: 0;
  727. border-top: #515050 solid 1px;
  728. width: 100%;
  729. display: flex;
  730. flex-direction: row;
  731. justify-content: space-between;
  732. padding: 30upx;
  733. }
  734. .opertor-words {
  735. color: #e8e5e5;
  736. font-size: 32upx;
  737. width: 200upx;
  738. }
  739. /* 底部操作End */
  740. </style>