From c8465522f093f6726d9b65bdc794256d051cb7a8 Mon Sep 17 00:00:00 2001 From: youngS Date: Mon, 15 Mar 2021 17:24:29 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BC=98=E5=8C=96=E4=B8=8B=E8=BD=BD=E7=A0=81?= =?UTF-8?q?=E8=B7=A8=E5=9F=9F=E6=98=BE=E7=A4=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- fir_client/src/components/FirAppInfosBase.vue | 14 +++++++++++--- fir_client/src/utils/index.js | 19 ++++++++++++++++++- 2 files changed, 29 insertions(+), 4 deletions(-) diff --git a/fir_client/src/components/FirAppInfosBase.vue b/fir_client/src/components/FirAppInfosBase.vue index 839b96e..6fd2bb4 100644 --- a/fir_client/src/components/FirAppInfosBase.vue +++ b/fir_client/src/components/FirAppInfosBase.vue @@ -19,7 +19,7 @@ width="288">
import {apputils} from "../restful"; import VueQr from 'vue-qr'; + import {ImgToBase64} from "../utils" export default { name: "FirAppInfosBase", @@ -122,6 +123,7 @@ margin: 20 }, icon_url: "", + b64_icon_url: '', appinfos: {}, master_release: {}, allapp: [], @@ -182,6 +184,12 @@ this.setfunactive('supersign', 70); 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() { }, filters: { @@ -215,11 +223,11 @@ "app_id": this.$route.params.id }); if (this.$store.state.currentapp.master_release) { - this.icon_url = this.$store.state.currentapp.master_release.icon_url + this.set_icon_url() } }, watch: { '$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 () { this.appinfos = this.$store.state.currentapp; diff --git a/fir_client/src/utils/index.js b/fir_client/src/utils/index.js index 30c0fe5..fde4c37 100644 --- a/fir_client/src/utils/index.js +++ b/fir_client/src/utils/index.js @@ -270,4 +270,21 @@ export function checkEmail(email) { export function checkphone(email) { let re = /^1\d{10}$/; return re.test(email); -} \ No newline at end of file +} + +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; + }; +}