微信里点“发现”,扫一下
二维码便可将本文分享至朋友圈。
', 33 | wechatQrcodeSize: 100, 34 | 35 | summary: '', 36 | weibokey: '', 37 | }; 38 | 39 | this.wechatQrCode = undefined; 40 | 41 | /** 42 | * 初始化控制器 43 | */ 44 | this.init = function () { 45 | }; 46 | 47 | /** 48 | * 仅获取链接 49 | */ 50 | this.getLink = function (key, config) { 51 | if (this.template[key]) { 52 | var link = this.template[key]; 53 | for (var x in this.$socialconfig) { 54 | var regx = '/{{' + x.toUpperCase() + '}}/g'; 55 | if (config && config.hasOwnProperty(x)) { 56 | link = link.replace(eval(regx), config[x]); 57 | } else { 58 | link = link.replace(eval(regx), this.$socialconfig[x]); 59 | } 60 | } 61 | console.log('分享链接: ' + link); 62 | return link; 63 | } 64 | return false; 65 | }; 66 | 67 | this.init();//自动初始化 68 | }; 69 | 70 | module.exports = (appVar) => { 71 | return new Share(appVar); 72 | }; -------------------------------------------------------------------------------- /app/util/VerifyCodeUtil.js: -------------------------------------------------------------------------------- 1 | var verifyCodenums = ["1", "2", "3", "4", "5", "6", "7", "8", "9", "0", 2 | 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z', 3 | 'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z' 4 | ]; 5 | var verifyCodestr = ''; 6 | var verVals = []; 7 | 8 | // 绘制验证码 9 | function drawCode(verifyCodestr, eleid) { 10 | var canvas = document.getElementById(eleid + '-canvas'); //获取HTML端画布 11 | var context = canvas.getContext("2d"); //获取画布2D上下文 12 | context.fillStyle = "cornflowerblue"; //画布填充色 13 | context.fillRect(0, 0, canvas.width, canvas.height); //清空画布 14 | context.fillStyle = "white"; //设置字体颜色 15 | context.font = "25px Arial"; //设置字体 16 | var rand = new Array(); 17 | var x = new Array(); 18 | var y = new Array(); 19 | for (var i = 0; i < 4; i++) { 20 | rand.push(rand[i]); 21 | rand[i] = verifyCodenums[Math.floor(Math.random() * verifyCodenums.length)]; 22 | x[i] = i * 20 + 10; 23 | y[i] = Math.random() * 20 + 20; 24 | context.fillText(rand[i], x[i], y[i]); 25 | } 26 | verifyCodestr = rand.join('').toUpperCase(); 27 | //画3条随机线 28 | for (var i = 0; i < 3; i++) { 29 | drawline(canvas, context); 30 | } 31 | 32 | // 画30个随机点 33 | for (var i = 0; i < 30; i++) { 34 | drawDot(canvas, context); 35 | } 36 | convertCanvasToImage(canvas, eleid); 37 | return verifyCodestr; 38 | } 39 | 40 | // 随机线 41 | function drawline(canvas, context) { 42 | context.moveTo(Math.floor(Math.random() * canvas.width), Math.floor(Math.random() * canvas.height)); //随机线的起点x坐标是画布x坐标0位置,y坐标是画布高度的随机数 43 | context.lineTo(Math.floor(Math.random() * canvas.width), Math.floor(Math.random() * canvas.height)); //随机线的终点x坐标是画布宽度,y坐标是画布高度的随机数 44 | context.lineWidth = 0.5; //随机线宽 45 | context.strokeStyle = 'rgba(50,50,50,0.3)'; //随机线描边属性 46 | context.stroke(); //描边,即起点描到终点 47 | } 48 | 49 | // 随机点(所谓画点其实就是画1px像素的线,方法不再赘述) 50 | function drawDot(canvas, context) { 51 | var px = Math.floor(Math.random() * canvas.width); 52 | var py = Math.floor(Math.random() * canvas.height); 53 | context.moveTo(px, py); 54 | context.lineTo(px + 1, py + 1); 55 | context.lineWidth = 0.2; 56 | context.stroke(); 57 | 58 | } 59 | 60 | // 绘制图片 61 | function convertCanvasToImage(canvas, eleid) { 62 | $('#' + eleid + '-canvas').hide(); 63 | var image = $('#' + eleid).children('img'); 64 | image.attr('src', canvas.toDataURL("image/png")); 65 | return image; 66 | } 67 | 68 | // 点击div刷新 69 | function resetVerifyCode(eleid) { 70 | var width = $('#' + eleid).width(); 71 | var height = $('#' + eleid).height(); 72 | $('#' + eleid).children('canvas').remove(); 73 | $('#' + eleid).children('img').before('') 74 | var verVal = drawCode('', eleid); 75 | getVerifyCode(eleid, verVal); 76 | } 77 | 78 | //查询验证码 79 | function getVerifyCode(id, newcode) { 80 | for (var x in verVals) { 81 | if (verVals[x].id === id) { 82 | if (newcode) { 83 | verVals[x].code = newcode; 84 | } else { 85 | return verVals[x].code; 86 | } 87 | } 88 | } 89 | } 90 | 91 | //渲染验证码控件 92 | function renderVerifyCode(seletor) { 93 | var drawDiv = $(seletor); 94 | drawDiv.each(function () { 95 | $(this).html('\n' + 96 | 'Version {{proxy.appVar._version_show}}
23 | 24 |Privacy Policy: {{proxy.appVar._siteurl}}privacy
25 |Terms of Use: {{proxy.appVar._siteurl}}terms
26 | 27 |Copyright © 2019 inetech.com. All rights reserved.
28 |