html2canvas 转至cdn

This commit is contained in:
aixianling
2022-08-08 15:06:42 +08:00
parent ac46d37527
commit 3da33a88d3
8 changed files with 186 additions and 189 deletions

View File

@@ -46,7 +46,6 @@
"core-js": "^3.11.0",
"dayjs": "^1.10.6",
"echarts": "^4.9.0",
"html2canvas": "^1.4.1",
"recorder-core": "^1.1.21080800",
"regenerator-runtime": "^0.12.1",
"vue": "^2.6.11",

View File

@@ -14,8 +14,8 @@
v-for="(item, index) in configList"
:class="[currIndex === index ? 'active' : '']"
@click="changeComponent(item, index)">
<image class="img" :src="item.thum" />
<image class="checked" v-if="currIndex === index" src="./images/xuanzhong.png" />
<image class="img" :src="item.thum"/>
<image class="checked" v-if="currIndex === index" src="./images/xuanzhong.png"/>
<span @click="toEdit">编辑</span>
</div>
</div>
@@ -24,17 +24,17 @@
</template>
<script>
import Daily from './components/report/Daily'
import WorkReport from './components/report/WorkReport'
import InspectLog from './components/report/InspectLog'
import MeetingMminutes from './components/report/MeetingMminutes'
import Daily from './components/report/Daily'
import WorkReport from './components/report/WorkReport'
import InspectLog from './components/report/InspectLog'
import MeetingMminutes from './components/report/MeetingMminutes'
export default {
export default {
name: 'Report',
appName: '拼图汇报',
data () {
data() {
return {
component: 'WorkReport',
configList: [],
@@ -51,20 +51,20 @@
},
computed: {
currConfig () {
currConfig() {
if (this.currIndex < 0 || !this.configList.length) return []
return this.configList[this.currIndex].itemList
}
},
onLoad (query) {
onLoad(query) {
this.albumId = query.id || ''
this.getConfig()
},
methods: {
getConfig () {
getConfig() {
this.$http.post(`/api/appalbumtemplate/list?size=100&templateType=1&status=1`).then(res => {
if (res.code === 0) {
this.configList = res.data.records
@@ -72,19 +72,19 @@
})
},
back () {
back() {
uni.navigateBack({
delta: 1
})
},
toEdit () {
toEdit() {
this.$refs.reportItem.linkTo()
},
save () {
save() {
this.$loading()
this.$refs.reportItem.screenshot() && this.$refs.reportItem.screenshot().then(canvas => {
this.$refs.reportItem?.screenshot().then(canvas => {
let dataURL = canvas.toDataURL('image/png')
const file = this.dataURLtoFile(dataURL, 'photo.png')
let formData = new FormData()
@@ -104,7 +104,7 @@
})
},
dataURLtoFile (dataurl, filename) {
dataURLtoFile(dataurl, filename) {
let arr = dataurl.split(',')
let mime = arr[0].match(/:(.*?);/)[1]
let bstr = atob(arr[1])
@@ -113,15 +113,15 @@
while (n--) {
u8arr[n] = bstr.charCodeAt(n)
}
return new File([u8arr], filename, { type: mime })
return new File([u8arr], filename, {type: mime})
},
changeComponent (e, index) {
changeComponent(e, index) {
this.currIndex = index
this.component = this.mapComponent(e.watermarkType)
},
mapComponent (type) {
mapComponent(type) {
return {
'9': 'WorkReport',
'10': 'Daily',
@@ -130,11 +130,11 @@
}[type]
}
}
}
}
</script>
<style lang="scss" scoped>
.report {
.report {
position: relative;
padding-bottom: 330px;
@@ -230,5 +230,5 @@
}
}
}
}
}
</style>

View File

@@ -1,12 +1,12 @@
<template>
<div class="form">
<component ref="TabPage" :is="component" @change="onChange" :params="params"/>
<component v-if="html2canvas" ref="TabPage" :is="component" @change="onChange" :params="params"/>
</div>
</template>
<script>
import Tabbar from './components/Tabbar.vue'
import { mapActions, mapState } from "vuex"
import {mapActions, mapState} from "vuex"
export default {
name: 'AppCountryAlbum',
@@ -14,6 +14,7 @@ export default {
data() {
return {
html2canvas: null,
component: 'Tabbar',
params: {}
}
@@ -23,7 +24,7 @@ export default {
Tabbar
},
onLoad () {
onLoad() {
uni.setStorageSync('address', {
lat: '',
lng: '',
@@ -31,7 +32,9 @@ export default {
weather: '',
cityCode: ``
})
this.$injectLib("https://cdn.cunwuyun.cn/html2canvas.min.js", () => {
this.html2canvas = window?.html2canvas
})
setTimeout(() => {
this.getLocation()
@@ -54,7 +57,7 @@ export default {
this.component = e.type
},
getLocation () {
getLocation() {
this.injectJWeixin(['getLocation']).then(() => {
wx.getLocation({
type: 'wgs84',
@@ -83,7 +86,7 @@ export default {
})
},
getWeather (code) {
getWeather(code) {
this.$http.post(`/api/bdweather/wdata?districtId=${code}`).then(res => {
if (res.code === 0) {
const data = res.data.result.now

View File

@@ -111,7 +111,6 @@
</template>
<script>
import html2canvas from 'html2canvas'
import Watermark1 from './components/watermark/Watermark1'
import Watermark2 from './components/watermark/Watermark2'
import Watermark3 from './components/watermark/Watermark3'

View File

@@ -40,7 +40,6 @@
</template>
<script>
import html2canvas from 'html2canvas'
import RenderContent from './RenderContent.vue'
import { mapFieldLable } from '../../config'
export default {

View File

@@ -42,7 +42,6 @@
</template>
<script>
import html2canvas from 'html2canvas'
import { mapFieldLable } from '../../config'
import RenderContent from './RenderContent.vue'
export default {

View File

@@ -53,7 +53,6 @@
</template>
<script>
import html2canvas from 'html2canvas'
import RenderContent from './RenderContent.vue'
import { mapFieldLable } from '../../config'
export default {

View File

@@ -39,7 +39,6 @@
</template>
<script>
import html2canvas from 'html2canvas'
import RenderContent from './RenderContent.vue'
import { mapFieldLable } from '../../config'