diff --git a/package.json b/package.json index 52afe8a..7d42b65 100644 --- a/package.json +++ b/package.json @@ -45,6 +45,7 @@ "file-saver": "2.0.5", "fuse.js": "6.4.3", "highlight.js": "9.18.5", + "html2canvas": "^1.4.1", "js-beautify": "1.13.0", "js-cookie": "3.0.1", "jsencrypt": "3.0.0-rc.1", diff --git a/src/assets/images/z.png b/src/assets/images/z.png new file mode 100644 index 0000000..397d2e4 Binary files /dev/null and b/src/assets/images/z.png differ diff --git a/src/assets/images/zs.jpg b/src/assets/images/zs.jpg new file mode 100644 index 0000000..2a46b2b Binary files /dev/null and b/src/assets/images/zs.jpg differ diff --git a/src/assets/styles/myTable.scss b/src/assets/styles/myTable.scss index d5ed46d..2a2edcf 100644 --- a/src/assets/styles/myTable.scss +++ b/src/assets/styles/myTable.scss @@ -197,3 +197,51 @@ margin-top: 30px; } } + +// 电子证书 +.zs-box { + height: 450px; + width: 300px; + position: relative; + background: url("~@/assets/images/zs.jpg"); + background-size: 100% 100%; + .zs-z { + position: absolute; + bottom: 10%; + right: 10%; + border: 1px solid red; + height: 50px; + width: 50px; + border-radius: 50%; + overflow: hidden; + background: url("~@/assets/images/z.png"); + background-size: 100% 100%; + } + .top-text { + position: absolute; + top: 30%; + left: 50%; + font-size: 14px; + transform: translateX(-50%); + z-index: 10; + span { + display: inline-block; + width: 60px; + text-align: center; + border-bottom: 1px solid #333; + } + } + .bottom-text { + position: absolute; + bottom: 10%; + right: 10%; + z-index: 10; + .lable-value { + margin-bottom: 3px; + font-size: 13px; + display: flex; + align-items: center; + justify-content: space-between; + } + } +} diff --git a/src/views/volunteer/gxhzs/gxhzsff/index.vue b/src/views/volunteer/gxhzs/gxhzsff/index.vue index 1a456fb..cea2d09 100644 --- a/src/views/volunteer/gxhzs/gxhzsff/index.vue +++ b/src/views/volunteer/gxhzs/gxhzsff/index.vue @@ -194,7 +194,38 @@ 电子证书 -
+
+
+ {{ form.userName }} 先生/女士: +

+ 您在苏州工业园区累计志愿服务0小时,感谢您的无私奉献,特发此证,以兹鼓励。 +

+
+
+
+
签发单位:
+
苏州工业园区宣传和统战部
+
+
+
+
苏州工业园区新时代文明实践中心
+
+
+
+
+ {{ $moment().format("YYYY年MM月DD日") }} +
+
+
+
+
+ 下载电子证书 @@ -207,6 +238,7 @@ import { dsbrecordsInfo, issue, } from "@/api/volunteer/gxhzs/hdzsff/index.js"; +import html2canvas from "html2canvas"; export default { data() { return { @@ -244,6 +276,23 @@ export default { }); }, methods: { + /**下载电子证书 */ + downloadContentAsImage() { + const content = this.$refs.zs; // 获取目标
的DOM节点 + // 创建一个Canvas元素,并设置宽高等于目标
的尺寸 + const canvas = document.createElement("canvas"); + canvas.width = content.offsetWidth; + canvas.height = content.offsetHeight; + const context = canvas.getContext("2d"); + // 使用Canvas绘制目标
中的内容 + html2canvas(content).then((canvas) => { + // 将Canvas转换为DataURL + const dataURL = canvas.toDataURL("image/png"); + // 使用FileSaver.js保存DataURL为图片文件 + saveAs(dataURL, "download.png"); + }); + }, + /**搜索 */ handleSearch(keyWord) { this.queryParams = { diff --git a/src/views/volunteer/gxhzs/mygxhzs/index.vue b/src/views/volunteer/gxhzs/mygxhzs/index.vue index 4159e22..ef2d2fd 100644 --- a/src/views/volunteer/gxhzs/mygxhzs/index.vue +++ b/src/views/volunteer/gxhzs/mygxhzs/index.vue @@ -101,7 +101,38 @@ 电子证书
-
+
+
+ {{ form.userName }} 先生/女士: +

+ 您在苏州工业园区累计志愿服务0小时,感谢您的无私奉献,特发此证,以兹鼓励。 +

+
+
+
+
签发单位:
+
苏州工业园区宣传和统战部
+
+
+
+
苏州工业园区新时代文明实践中心
+
+
+
+
+ {{ $moment().format("YYYY年MM月DD日") }} +
+
+
+
+
+ 下载电子证书
@@ -109,6 +140,7 @@