cshenfu
2025-04-22 6c5ee436d0301711a8ef91e4a418e7a5306264fb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<style>
    *{
        margin: 0;
        padding: 0;
        border: 0;
    }
    .box_none{
        width: 100%;
        height: 100px;
        float: left;
    }
    .box1{
        width: 100%;
        clear: both;
        overflow: hidden;
    }
    .box2{
        /* background-color: rgb(167, 248, 248); */
        float: left;
        /* border: 0.5px solid black; */
        /* margin: 0 10px; */
        padding: 55.7px 0px 55.7px 40.4px;
        position: relative;
    }
    .left_box{
        margin-right: 10px;
    }
    .right_box{
        margin-left: 10px;
    }
    .box3{
        float: left;
        margin: 35px 10px;
    }
    .box4{
        /* background-color: #555555; */
        float: left;
        margin: 35px 10px -20px;
        width: 380px;
        height: 277px;
        overflow: hidden;
    }
    .box5{
        position: relative;
        height: 75px;
        line-height: 70px;
        /* font-size: 60px; */
        text-align: center;
    }
    .box6{
        background-image: url('./image/mizige2.jpg');
        /* background-position: ; */
        background-size: 170px 190px;
        font-size: 140px;
        text-align: center;
        height: 190px;
        width: 170px;
        position: relative;
        font-family: '华文楷体';
        z-index: 2;
        overflow: hidden;
    }
    .hanzi{
        position: absolute;
        top: 50%;
        left: 50%;
        margin: auto;
        transform: translateX(-50%) translateY(-50%);
    }
    /* .box6::before{
        content: "";
        position: absolute;
        left: 2px;
        top: -2px;
        width: 100%;
        height: 100px;
        box-sizing: border-box;
        border-bottom: 0.5px dashed black;
        transform-origin: bottom center;
        transform: rotateZ(48.4deg) scale(1.5);
    }
    .box6::after{
        content: "";
        position: absolute;
        z-index: -1;
        left: 2px;
        top: -8px;
        width: 100%;
        height: 100px;
        box-sizing: border-box;
        border-bottom: 0.1px dashed black;
        transform-origin: bottom center;
        transform: rotateZ(132deg) scale(1.5);
    } */
    .box6{
        border-top: 2px;
        border-left: 4px;
        border-bottom: 4px;
        border-right: 4px;
        border-color: rgb(44,63,123);
        border-style: solid;
    }
    .box5{
        font-family: "冬青黑体简体中文";
        border-top: 4px;
        border-left: 4px;
        border-bottom: 2px;
        border-right: 4px;
        border-color: rgb(44,63,123);
        border-style: solid;
    }
    p{
        font-size: 30px;
        text-align: center;
        height: 30px;
        line-height: 30px;
        width: 280px;
        white-space: break-word;
    }
    .box4 p{
        width: 98%;
        margin: 3px 4px 30px;
        border-radius: 23px;
        
        /* padding: 0 10px; */
        font-family: "华文楷体";
        height: 45px;
        text-align: center;
        line-height: 45px;
        font-size: 38px;
        font-weight: bold;
        white-space: nowrap;
    }
    .info{
        position: absolute;
        font-family: "圆体-简";
        font-size: 20px;
        width: 178px;
        margin: 0;
        bottom: 60px;
        display: flex;
        /* color: white; */
        justify-content: space-between;
    }
    .info span{
        margin: 0 5px;
    }
    .block{
        display: inline-block;
        width: 15px;
    }
    .box3,.box4 p{
        background-color: white;
    }
    .image_div{
        text-align: right;
    }
    .image_div_right{
        text-align: left;
    }
    img{
        opacity: 0;
        width: 100px;
        height: 100px;
    }
    .img_fake_box{
        opacity: 0;
        width: 100px;
        height: 100px;
    }
    #long_font{
        font-size: 44px;
    }
    #font_long{
        font-size: 20px;
    }
    #end_id{
        font-size: 10px;
    }
    #dun{
        font-size: 14px;
    }
    .heng{
        border-bottom:0.5px dashed black;
        position: absolute;
        margin: 0;
        width: 100%;
        top: 50%;
    }
    .shu{
        border-bottom:0.5px dashed black;
        position: absolute;
        margin: 0;
        width: 190px;
        top: 50%;
        left: -7%;
        transform: rotateZ(90deg);
    }
    .heng1,.heng2{
        position: absolute;
        left: 0;
    }
    .box5::before,  
    .box5::after {  
        content: ""; /* 伪元素需要内容属性,即使它是空的 */  
        position: absolute; /* 伪元素相对于包含块定位 */  
        border-bottom: 0.3px dashed #555555; /* 设置横线样式 */  
        width: 100%; /* 横线宽度与div相同 */  
    }  
    
    .box5::before {  
        top: 35%; /* 第一条横线位于高度33%处 */  
        left: 0;
    }  
    
    .box5::after {  
        top: 67%; /* 第二条横线位于高度66%处 */  
        left: 0;
    }
    .yema_box{
        font-family: "圆体-简";
        width: 50px;
        height: 50px;
        background-color: white;
        position: absolute;
        bottom: 10px;
        border-radius: 50%;
        /* text-align: center; */
        line-height: 50px;
        font-size: 20px;
        text-align: center;
        font-weight: 700;
    }
    .yema_left{
        
        right: -25px;
        background-color: rgb(16, 149, 126);
        color: black;
    }
    .yema_right{
        left: -25px;
        background-color: rgb(16, 149, 126);
        color: black;
    }
    
    .circle_box{
        width: 100%;
        position: absolute;
        top: 0;
        
    }
    .title_box{
        width: 255%;
        position: absolute;
        top: 0;
        overflow: hidden;
        right: -50px;
        height: 50px;
    }
    .circle_box{
        left: 30px;
    }
    
    .circle_box>div{
        position: relative;
        z-index: 1;
        float: left;
        width: 95px;
        height: 95px;
        border-radius: 50%;
        right:-20px
    }
    .title_box>div{
        position: relative;
        top: -100%;
        z-index: 1;
        float: right;
        width: 100px;
        height: 100px;
        border-radius: 50%;
    }
    /* .circle_box :nth-child(odd),.title_box :nth-child(even) {
    background-color: #d130c4;
    }
    .circle_box :nth-child(even),.title_box :nth-child(odd) {
        background-color: #f7b6e9;
    }  */
    .title_box .title{
        overflow: hidden;
        position: absolute;
        top: -50%;
        left: 47%;
        width: 380px;
        height: 70px;
        background-color: rgb(158, 178, 200);
        text-align: center;
        z-index: 0;
        color: black;
        line-height: 18px;
    }
    #sp{
        float: right;
        z-index: 1;
    }
    .title_box .title span{
        color: white;
        font-family: "圆体-简";
        font-weight: bold;
        display: block;
        width: 100%;
        font-size: 20px;
        position: absolute;
        bottom: 10px;
        left: 50%;
        transform: translateX(-50%);
        /* background-color: white; */
    }
</style>
<body>
    <div id="word_box" class="box1">
        
    </div>
    
</body>
<script src="all_json.js"></script>
<script>
     var box = document.getElementById('word_box')
     var pinyin_id = ''
     var pinyin_end = ''
     var word_color
     var end_color = ''
     var circle_1_color = ''
     var circle_2_color = ''
    //  顶部半圆形背景色
     var circle2 = ['rgb(158,178,200)','rgb(224,236,239)']
    //  每三页字格颜色循环一次
     var color_arr_3 = ["rgb(96,180,157)","rgb(220,223,58)","rgb(221,128,171)","rgb(230,157,60)","rgb(153,127,179)","rgb(233,179,202)","rgb(131,185,72)","rgb(96,183,188)"]
     function padNumber(number, length) {
        const stringNumber = number.toString(); // 将数字转为字符串
        return stringNumber.padStart(length, '0'); // 使用'0'填充到指定长度
     }
     function rgbToHex(rgb) {  
        let r = rgb[0].toString(16).padStart(2, '0');  
        let g = rgb[1].toString(16).padStart(2, '0');  
        let b = rgb[2].toString(16).padStart(2, '0'); 
        return `#${r}${g}${b}`;  
    }
    function replaceChars(str, replacements) {  
        // 使用reduce来遍历字符串中的每个字符,并应用替换规则  
        return str.split('').reduce((acc, char) => {  
            // 检查当前字符是否在替换规则中  
            const replacement = replacements[char];  
            // 如果有替换规则,则使用替换后的字符;否则,使用原字符  
            return acc + (replacement ? replacement : char);  
        }, '');  
    } 
    
    // console.log(all_4000_json2)
    for(let i =0;i<1000;i++){
        // 根据页数设置半圆背景颜色
    if(i%24==8||i%24==16||i%24==0){
        circle_1_color = circle2[1]
        circle_2_color = circle2[0]
    }
    const replacements = {' ':'&ensp;'}
    //每页顶部半圆和标题
    let circle_div = 
    `<div class="circle_box">
        <div style="background-color:${circle_1_color}"></div>
        <div style="background-color:${circle_2_color}"></div>
        <div style="background-color:${circle_1_color}"></div>
        <div style="background-color:${circle_2_color}"></div>
        <div style="background-color:${circle_1_color}"></div>
        <div style="background-color:${circle_2_color}"></div>
    </div>`
    let title_box = 
    `<div class="title_box">
        <div style="background-color:${circle_1_color}"></div>
        <div style="background-color:${circle_2_color}"></div>
        <div style="background-color:${circle_1_color}"></div>
        <div style="background-color:${circle_2_color}"></div>
        <div style="background-color:${circle_1_color}"></div>
        <div style="width:350px;"></div>
        <div class="title"><span>第四册&ensp;&ensp;&ensp;&ensp;&ensp;配套词语训练</span></div>
        <div style="background-color:${circle_1_color}"></div>
        <div style="background-color:${circle_2_color}"></div>
        <div style="background-color:${circle_1_color}"></div>
        <div style="background-color:${circle_2_color}"></div>
        <div style="background-color:${circle_1_color}"></div>
    </div>`
        let color_index = color_arr_3.length
   
        pinyin_end = `${all_4000_json2[i+3000]['pinyin']}`
        let chengyu1 = ''
        let chengyu2 = ''
        if(all_4000_json2[i+3000]['chengyu'] != undefined){
            if(all_4000_json2[i+3000]['chengyu'].length>9){
                chengyu1 = all_4000_json2[i+3000]['chengyu'].slice(0,9)
                chengyu2 = all_4000_json2[i+3000]['chengyu'].slice(10)
            }else{
                chengyu1 = all_4000_json2[i+3000]['chengyu']
            }
        }
        console.log(chengyu1,"dddddddd",chengyu2)
        //根据级别更改字的颜色
        if(all_4000_json2[i+3000].level == '一级'){
            word_color = 'red'
        }else if(all_4000_json2[i+3000].level == '二级'){
            word_color = 'blue'
        }else if(all_4000_json2[i+3000].level == '三级'){
            word_color = 'green'
        }else{
            word_color = 'black'
        }
 
        // 根据拼音长度来设置字体大小
        if(pinyin_end.length>15){
            pinyin_id = 'font_long'
        }else if(pinyin_end.length<=15&&pinyin_end.length>6){
            pinyin_id = 'end_id'
        }else{
            pinyin_id = 'long_font'
        }
 
        
 
        //创建每个色块和字格内容
        var div = `<div class="box2 ${i%2==0?'left_box':'right_box'}">
            <div class="box3">
                <div class="box5" id="${pinyin_id}">${pinyin_end}</div>
                <div class='box6'>
                    <div class='hanzi' style='color:${word_color}'>${all_4000_json2[i+3000].word}</div>
                </div>
                <p class = 'info'>
                    <span class = 'xuhao'>${all_4000_json2[i+3000].num}</span>
                    <span class = 'level'>${all_4000_json2[i+3000].level}</span>
                </p>
            </div>
            <div class="box4" style="background-color:${color_arr_3[i%8]}">
                <p style="display:${all_4000_json2[i+3000]['ciyu1']==''?'none':'block'}">${replaceChars(all_4000_json2[i+3000]['ciyu1'], replacements)}</p>
                <p style="display:${all_4000_json2[i+3000]['ciyu2']==''?'none':'block'}">${replaceChars(all_4000_json2[i+3000]['ciyu2'], replacements)}</p>
                <p style="display:${chengyu1==''?'none':'block'}">${replaceChars(chengyu1, replacements)}</p>
                <p style="display:${chengyu2==''?'none':'block'}">${replaceChars(chengyu2, replacements)}</p>
            </div>
        </div>`
        box.insertAdjacentHTML('beforeend',div)
        var box2 = document.getElementsByClassName('box2')
        // console.log(box2)
        let yema_box = `<div class="yema_box yema_right">${(i+1)/8}</div>`
        let yema_box2 = `<div class="yema_box yema_left">${(i+2)/8}</div>`
        // 根据每页八个字为条件插入左右下标页码
        if((i+1)%8 == 0&&(i+1)%16!=0){
            box2[i].insertAdjacentHTML('beforeend',yema_box)
        }else if((i+1)%8 == 1){
            // box2[i].insertAdjacentHTML('beforeend',circle_div)
        }else if((i+1)%8 == 2){
            box2[i].insertAdjacentHTML('beforeend',title_box)
        }else if((i+1)%16 == 15){
            box2[i].insertAdjacentHTML('beforeend',yema_box2)
        }
      
    }
</script>
 
</html>