Browse Source

feat: h5;

h5
Fox-33 1 day ago
parent
commit
e09024b599
3 changed files with 24 additions and 52 deletions
  1. +3
    -2
      manifest.json
  2. +1
    -1
      pages.json
  3. +20
    -49
      pages/index/index.vue

+ 3
- 2
manifest.json View File

@ -89,7 +89,7 @@
}
},
"devServer" : {
"https" : false,
"https" : true,
"proxy" : {
"/ws/geocoder/v1/" : {
"target" : "https://apis.map.qq.com",
@ -100,6 +100,7 @@
"changeOrigin" : true
}
}
}
},
"title" : "行后报告"
}
}

+ 1
- 1
pages.json View File

@ -11,7 +11,7 @@
"globalStyle": {
"navigationBarTextStyle": "black",
"navigationBarTitleText": "行后报告",
"navigationBarBackgroundColor": "#F8F8F8",
"navigationBarBackgroundColor": "#DAF3FF",
"backgroundColor": "#F8F8F8",
"navigationStyle": "custom"
},


+ 20
- 49
pages/index/index.vue View File

@ -73,9 +73,7 @@
<img v-if="current < 13" class="turn right" style="display: block;" src="@/static/image/icon-right.png" @click="next" />
<div class="flex bottom">
<div class="flex btns">
<button class="btn" @click="createPdf">生成pdf</button>
</div>
<button class="btn" @click="createPdf">生成pdf</button>
</div>
</div>
@ -166,40 +164,14 @@
fillPage()
}
const canvas = item.value
const contentWidth = canvas.width
const contentHeight = canvas.height
// let imgHeight = (WIDTH / contentWidth) * contentHeight // a4
let pageData = canvas.toDataURL('image/jpeg', 1.0)
PDF.addImage(pageData, 'JPEG', 0, 0, WIDTH, HEIGHT)
return
//
let leftHeight = imgHeight
//
let position = 0
// a4
if (imgHeight > HEIGHT) {
while (leftHeight > 0) {
// xy
PDF.addImage(pageData, 'JPEG', 0, position, WIDTH, imgHeight)
leftHeight = leftHeight - HEIGHT
position -= HEIGHT
if (leftHeight > 0) {
PDF.addPage()
fillPage()
}
}
} else {
PDF.addImage(pageData, 'JPEG', 0, 0, WIDTH, imgHeight)
// const marginY = (HEIGHT - imgHeight) / 2 //
// // xy
// PDF.addImage(pageData, 'JPEG', 0, marginY > 0 ? marginY : 0, a4Width, imgHeight)
}
})
// #ifdef H5
console.log('env: h5')
PDF.save('测试生成pdf' + '.pdf'); //h5pdf
// #endif
@ -304,29 +276,28 @@
}
.bottom {
position: fixed;
left: 0;
bottom: 0;
width: 100vw;
height: 55px;
padding: 0 25px;
position: fixed;
left: 0;
bottom: 0;
width: 100vw;
background: #FFFFFF;
box-sizing: border-box;
padding: 32rpx 40rpx;
padding-bottom: calc(env(safe-area-inset-bottom) + 32rpx);
box-sizing: border-box;
background: #FFFFFF;
box-shadow: 0px 3px 6px 0px rgba(0,0,0,0.16);
.btns {
width: 100%;
// justify-content: space-between;
}
.btn {
padding: 10px 45px;
font-size: 14px;
width: 100%;
padding: 14rpx 0;
font-family: PingFang SC;
font-weight: 500;
font-size: 36rpx;
line-height: 1.4;
color: #FFFFFF;
background: #4883F9;
border-radius: 21px;
border: none;
background: linear-gradient(to right, #21FEEC, #019AF9);
border: 2rpx solid #00A9FF;
border-radius: 41rpx;
}
}
}
</style>

Loading…
Cancel
Save