30488344 by renchao@pashanhoo.com

style:证书预览

1 parent 4a4f2929
1 <!-- 1 <!--
2 * @Description: 2 * @Description:
3 * @Autor: renchao 3 * @Autor: renchao
4 * @LastEditTime: 2023-08-10 13:43:32 4 * @LastEditTime: 2023-08-16 10:37:13
5 --> 5 -->
6 <template> 6 <template>
7 <div class="from-clues loadingtext" v-Loading="loading" element-loading-text="拼命加载中..." style="height:720px;text-align: center;"> 7 <div class="from-clues loadingtext" v-Loading="loading" element-loading-text="拼命加载中..." style="height:720px;text-align: center;">
...@@ -124,21 +124,27 @@ ...@@ -124,21 +124,27 @@
124 const image = new Image(); 124 const image = new Image();
125 image.onload = () => { 125 image.onload = () => {
126 context.drawImage(image, 0, 0); 126 context.drawImage(image, 0, 0);
127 context.font = '18px 楷体'; 127 context.font = '14px 楷体';
128 context.fillStyle = '#000000'; 128 context.fillStyle = '#000000';
129 context.fillText(this.bdcqz.sjjc ? this.bdcqz.sjjc : '', 60, 56); 129 context.fillText(this.bdcqz.sjjc ? this.bdcqz.sjjc : '', 60, 56);
130 context.fillText(this.bdcqz.djnd ? this.bdcqz.djnd : '', 113, 56); 130 context.fillText(this.bdcqz.djnd ? this.bdcqz.djnd : '', 113, 56);
131 context.fillText(this.bdcqz.sxqc ? this.bdcqz.sxqc : '', 180, 56); 131 context.fillText(this.bdcqz.sxqc ? this.bdcqz.sxqc : '', 180, 56);
132 context.fillText(this.bdcqz.sxh ? this.bdcqz.sxh : '', 370, 56); 132 context.fillText(this.bdcqz.sxh ? this.bdcqz.sxh : '', 370, 56);
133 context.fillText(this.bdcqz.qlr ? this.bdcqz.qlr : '', 138, 97); 133 context.fillText(this.bdcqz.qlr ? this.bdcqz.qlr : '', 129, 97);
134 context.fillText(this.bdcqz.gyqk ? this.bdcqz.gyqk : '', 138, 138); 134 context.fillText(this.bdcqz.gyqk ? this.bdcqz.gyqk : '', 129, 136);
135 context.fillText(this.bdcqz.zl ? this.bdcqz.zl : '', 138, 180); 135
136 context.fillText(this.bdcqz.bdcdyh ? this.bdcqz.bdcdyh : '', 138, 223); 136
137 context.fillText(this.bdcqz.qllx ? this.bdcqz.qllx : '', 138, 263); 137 // context.fillText(this.bdcqz.zl ? this.bdcqz.zl : '', 129, 170);
138 context.fillText(this.bdcqz.qlxz ? this.bdcqz.qlxz : '', 138, 303); 138
139 context.fillText(this.bdcqz.yt ? this.bdcqz.yt : '', 138, 346); 139
140 context.fillText(this.bdcqz.mj ? this.bdcqz.mj : '', 138, 386); 140
141 context.fillText(this.bdcqz.syqx ? this.bdcqz.syqx : '', 138, 429); 141
142 context.fillText(this.bdcqz.bdcdyh ? this.bdcqz.bdcdyh : '', 129, 223);
143 context.fillText(this.bdcqz.qllx ? this.bdcqz.qllx : '', 129, 263);
144 context.fillText(this.bdcqz.qlxz ? this.bdcqz.qlxz : '', 129, 303);
145 context.fillText(this.bdcqz.yt ? this.bdcqz.yt : '', 129, 346);
146 context.fillText(this.bdcqz.mj ? this.bdcqz.mj : '', 129, 386);
147 context.fillText(this.bdcqz.syqx ? this.bdcqz.syqx : '', 129, 429);
142 // qlqtzk 148 // qlqtzk
143 const maxWidth = 280; // 最大宽度限制 149 const maxWidth = 280; // 最大宽度限制
144 let lines = this.bdcqz.qlqtzk ? this.bdcqz.qlqtzk.split('\n') : []; 150 let lines = this.bdcqz.qlqtzk ? this.bdcqz.qlqtzk.split('\n') : [];
...@@ -158,12 +164,12 @@ ...@@ -158,12 +164,12 @@
158 } 164 }
159 arr.push(currentLine); 165 arr.push(currentLine);
160 arr.forEach((line, index) => { 166 arr.forEach((line, index) => {
161 context.fillText(line, 138, y + (index * 20)); // 调整行高 167 context.fillText(line, 129, y + (index * 20)); // 调整行高
162 }) 168 })
163 }) 169 })
164 let lines1 = this.bdcqz.fj ? this.bdcqz.fj.split(' ') : []; 170 let lines1 = this.bdcqz.fj ? this.bdcqz.fj.split(' ') : [];
165 lines1.forEach((line, index) => { 171 lines1.forEach((line, index) => {
166 const y = 100 + (index * 37); // 每行文本的垂直位置 172 const y = 100 + (index * 27); // 每行文本的垂直位置
167 let currentLine = ''; 173 let currentLine = '';
168 let arr = []; 174 let arr = [];
169 for (let word of line) { 175 for (let word of line) {
...@@ -182,6 +188,53 @@ ...@@ -182,6 +188,53 @@
182 }) 188 })
183 }) 189 })
184 190
191
192
193 let lines2 = this.bdcqz.zl ? this.bdcqz.zl.split(' ') : [];
194 if (lines2.length > 22) {
195 lines2.forEach((line, index) => {
196 const y = 170 + (index * 27); // 每行文本的垂直位置
197 let currentLine = '';
198 let arr = [];
199 for (let word of line) {
200 const testLine = currentLine + word;
201 const lineWidth = context.measureText(testLine).width;
202 if (lineWidth <= 360) {
203 currentLine = testLine;
204 } else {
205 arr.push(currentLine);
206 currentLine = word;
207 }
208 }
209 arr.push(currentLine);
210 arr.forEach((line, index) => {
211 context.fillText(line, 129, y + (index * 20)); // 调整行高
212 })
213 })
214 } else {
215 lines2.forEach((line, index) => {
216 const y = 180 + (index * 27); // 每行文本的垂直位置
217 let currentLine = '';
218 let arr = [];
219 for (let word of line) {
220 const testLine = currentLine + word;
221 const lineWidth = context.measureText(testLine).width;
222 if (lineWidth <= 360) {
223 currentLine = testLine;
224 } else {
225 arr.push(currentLine);
226 currentLine = word;
227 }
228 }
229 arr.push(currentLine);
230 arr.forEach((line, index) => {
231 context.fillText(line, 129, y + (index * 20)); // 调整行高
232 })
233 })
234
235 }
236
237
185 } 238 }
186 image.src = this.imgSrc 239 image.src = this.imgSrc
187 }, 240 },
......