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; + }; +}