From bec8203d47968cb911d3201141d813a1aeaacab5 Mon Sep 17 00:00:00 2001 From: chenxiaojun <956334972@qq.com> Date: Mon, 16 Dec 2019 15:42:36 +0800 Subject: [PATCH] =?UTF-8?q?=E6=8E=A8=E5=B9=BF=E5=B9=B3=E5=8F=B0>=E6=88=91?= =?UTF-8?q?=E7=9A=84=E6=B8=B8=E6=88=8F--=E6=9B=B4=E6=96=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Home/View/default/Apply/my_game.html | 26 ++++++++++++++++--- 1 file changed, 23 insertions(+), 3 deletions(-) diff --git a/Application/Home/View/default/Apply/my_game.html b/Application/Home/View/default/Apply/my_game.html index 2fae01956..a709f5dd2 100644 --- a/Application/Home/View/default/Apply/my_game.html +++ b/Application/Home/View/default/Apply/my_game.html @@ -876,9 +876,20 @@ fontname: 'Ubuntu', fontcolor: '#ff9818', }; - var logo = $(linkTag).parents('.game-li').eq(0).find('.img-box').children('img')[0] - $('#game_link_ercode').empty().qrcode(options); - $("#game_link_ercode canvas")[0].getContext('2d').drawImage(logo, (qrcodeWidth - logoWidth) / 2, (qrcodeHeight - logoHeight) / 2, logoWidth, logoHeight); + + var logo = null; + var logoSrc = $(linkTag).parents('.game-li').eq(0).find('.img-box').children('img').attr('src'); + console.log(isImg(logoSrc)); + if (isImg(logoSrc)) { + logo = $(linkTag).parents('.game-li').eq(0).find('.img-box').children('img')[0] + } else { + var img = document.createElement('img'); + img.src = '__IMG__/game_icon.png'; + logo = img; + } + + $('#game_link_ercode').empty().qrcode(options); + $("#game_link_ercode canvas")[0].getContext('2d').drawImage(logo, (qrcodeWidth - logoWidth) / 2, (qrcodeHeight - logoHeight) / 2, logoWidth, logoHeight); $('#clipboard-btn').attr('data-text', response.data.url) $('#clipboard-btn').click() @@ -896,6 +907,15 @@ }); }); + function isImg(src) { + var img = new Image(); + img.src = src; + if (img.width > 0 || img.height > 0) { + return true; + } + return false; + } + var clipboard = new ClipboardJS('#clipboard-btn', { text: function(trigger) { return trigger.getAttribute('data-text');