Browse Source

update

master
lc18518571399 11 months ago
parent
commit
34bdd8b1e3
  1. 2
      api/config/config.default.js
  2. 56
      h5/src/App.vue

2
api/config/config.default.js

@ -17,7 +17,7 @@ module.exports = appInfo => {
config.middleware = []; config.middleware = [];
config.mongoose = { config.mongoose = {
client: { client: {
url: 'mongodb://127.0.0.1:27011/back', url: 'mongodb://127.0.0.1:9018/back',
options: {} options: {}
} }
} }

56
h5/src/App.vue

@ -1,9 +1,11 @@
<template> <template>
<div> <div v-if="!error">
<el-row v-for="(item, perIndex) in resData.createImgList" :key="perIndex" class="yangshi"> <el-row
<el-col :span="3"> v-for="(item, perIndex) in resData.createImgList"
{{ item.age }} :key="perIndex"
</el-col> class="yangshi"
>
<el-col :span="3"> {{ item.age }} </el-col>
<el-col :span="15"> <el-col :span="15">
<img :src="item.png" height="200px" /> <img :src="item.png" height="200px" />
</el-col> </el-col>
@ -12,33 +14,43 @@
</el-col> </el-col>
</el-row> </el-row>
</div> </div>
<div v-else>{{ error }}</div>
</template> </template>
<script> <script>
import { Download } from '@element-plus/icons-vue';
export default { export default {
name: "app", name: "app",
data() { data() {
return { return {
resData: {}, resData: {},
error: "",
}; };
}, },
async mounted() { async mounted() {
let id = this.$_.get(window.location.href.split('?')[1].split('='), [1]) let url1 = this.$_.get(window.location.href, ["href"]);
console.log(77744, window.location.href, id) if (url1) {
let res = await this.$axios.get(`/api/getPng?id=${id}`) let conf = this.$_.get(url1.split("?"));
this.resData = this.$_.get(res, ["data", 0]) if (conf[1]) {
console.log(777, res) let id = this.$_.get(conf[1].split("="), [1]);
if (id.length === 12) {
console.log(77744, window.location.href, id);
let res = await this.$axios.get(`/api/getPng?id=${id}`);
this.resData = this.$_.get(res, ["data", 0]);
console.log(777, res);
} else {
this.error = "无数据";
}
}
} else {
this.error = "无数据";
}
}, },
methods: { methods: {
downloadFile(content, fileName = Date.now()) { //base64 downloadFile(content, fileName = Date.now()) {
//base64
let base64ToBlob = function (code) { let base64ToBlob = function (code) {
let parts = code.split(';base64,'); let parts = code.split(";base64,");
let contentType = parts[0].split(':')[1]; let contentType = parts[0].split(":")[1];
let raw = window.atob(parts[1]); let raw = window.atob(parts[1]);
let rawLength = raw.length; let rawLength = raw.length;
let uInt8Array = new Uint8Array(rawLength); let uInt8Array = new Uint8Array(rawLength);
@ -46,10 +58,10 @@ export default {
uInt8Array[i] = raw.charCodeAt(i); uInt8Array[i] = raw.charCodeAt(i);
} }
return new Blob([uInt8Array], { return new Blob([uInt8Array], {
type: contentType type: contentType,
}); });
}; };
let aLink = document.createElement('a'); let aLink = document.createElement("a");
let blob = base64ToBlob(content); //new Blob([content]); let blob = base64ToBlob(content); //new Blob([content]);
let evt = document.createEvent("HTMLEvents"); let evt = document.createEvent("HTMLEvents");
evt.initEvent("click", true, true); //initEvent FF evt.initEvent("click", true, true); //initEvent FF
@ -58,8 +70,8 @@ export default {
aLink.click(); aLink.click();
}, },
DownloadPng(item) { DownloadPng(item) {
this.downloadFile(item.png, `${this.resData.name}_${item.age}`) this.downloadFile(item.png, `${this.resData.name}_${item.age}`);
} },
}, },
watch: {}, watch: {},
computed: {}, computed: {},

Loading…
Cancel
Save