优化下载码跨域显示

pull/5/head
youngS 4 years ago
parent 291dd950d5
commit c8465522f0
  1. 14
      fir_client/src/components/FirAppInfosBase.vue
  2. 17
      fir_client/src/utils/index.js

@ -19,7 +19,7 @@
width="288"> width="288">
<div style="text-align: center; margin: 0"> <div style="text-align: center; margin: 0">
<vue-qr :margin="qrinfo.margin" <vue-qr :margin="qrinfo.margin"
:logoSrc="icon_url" :logoScale="qrinfo.logoScale" :logoSrc="b64_icon_url" :logoScale="qrinfo.logoScale"
:logoCornerRadius="qrinfo.logoCornerRadius" :logoCornerRadius="qrinfo.logoCornerRadius"
:correctLevel="qrinfo.correctLevel" :correctLevel="qrinfo.correctLevel"
:text="short_url()" :size="266" :text="short_url()" :size="266"
@ -94,6 +94,7 @@
<script> <script>
import {apputils} from "../restful"; import {apputils} from "../restful";
import VueQr from 'vue-qr'; import VueQr from 'vue-qr';
import {ImgToBase64} from "../utils"
export default { export default {
name: "FirAppInfosBase", name: "FirAppInfosBase",
@ -122,6 +123,7 @@
margin: 20 margin: 20
}, },
icon_url: "", icon_url: "",
b64_icon_url: '',
appinfos: {}, appinfos: {},
master_release: {}, master_release: {},
allapp: [], allapp: [],
@ -182,6 +184,12 @@
this.setfunactive('supersign', 70); this.setfunactive('supersign', 70);
this.$router.push({name: 'FirAppInfossupersign'}); this.$router.push({name: 'FirAppInfossupersign'});
}, },
set_icon_url() {
this.icon_url = this.$store.state.currentapp.master_release.icon_url;
ImgToBase64(this.icon_url, dataURL => {
this.b64_icon_url = dataURL;
})
},
}, created() { }, created() {
}, filters: { }, filters: {
@ -215,11 +223,11 @@
"app_id": this.$route.params.id "app_id": this.$route.params.id
}); });
if (this.$store.state.currentapp.master_release) { if (this.$store.state.currentapp.master_release) {
this.icon_url = this.$store.state.currentapp.master_release.icon_url this.set_icon_url()
} }
}, watch: { }, watch: {
'$store.state.currentapp.master_release.icon_url': function () { '$store.state.currentapp.master_release.icon_url': function () {
this.icon_url = this.$store.state.currentapp.master_release.icon_url this.set_icon_url()
}, },
'$store.state.currentapp': function () { '$store.state.currentapp': function () {
this.appinfos = this.$store.state.currentapp; this.appinfos = this.$store.state.currentapp;

@ -271,3 +271,20 @@ export function checkphone(email) {
let re = /^1\d{10}$/; let re = /^1\d{10}$/;
return re.test(email); return re.test(email);
} }
export function ImgToBase64(url, callback) {
let Img = new Image(),
dataURL = '';
Img.src = url + '?v=' + Math.random();
Img.setAttribute('crossOrigin', 'Anonymous');
Img.onload = function () {
let canvas = document.createElement('canvas'),
width = Img.width,
height = Img.height;
canvas.width = width;
canvas.height = height;
canvas.getContext('2d').drawImage(Img, 0, 0, width, height);
dataURL = canvas.toDataURL('image/jpeg',);
return callback ? callback(dataURL) : null;
};
}

Loading…
Cancel
Save