当前位置: 首页 > news >正文

英语培训网站模板seo上海推广公司

英语培训网站模板,seo上海推广公司,做网站行业统称叫什么行业,网站建设重点遇到一个需求,需要前端自行生成用户的个人名片分享二维码,并提供二维码下载功能。在网上找到很多解决方案,最终吭哧吭哧做完了,把它整理记录一下,方便后续学习使用!嘿嘿O(∩_∩)O~ 这个小东西有以下功能特点…

        遇到一个需求,需要前端自行生成用户的个人名片分享二维码,并提供二维码下载功能。在网上找到很多解决方案,最终吭哧吭哧做完了,把它整理记录一下,方便后续学习使用!嘿嘿O(∩_∩)O~

这个小东西有以下功能特点:

1.可以生成密密麻麻程度不一样的二维码

2.可以生成不同颜色的二维码

3.二维码支持下载

4.代码简洁且通俗易懂(小白只能这样啦!)

        首先,先记录一下我的实验版本,因为怕把项目搞砸,所以我就自己create一个单独的小demo来实验,等功能实现了再搬过去用。系不系很机智!!!

一、实验小Demo

1、点击获取二维码

<template><div class="click-code"><div class="click-code-pic"><img class="logo" :src="src"></div><div class="click-code-info"><h6>{{title}}</h6><p>{{text}}</p><button @click="getCode(1)">点击获取二维码</button><div class="isShow" v-if="isClick==1"><div class="img-box"><!-- 这里一定要记得写绑定,一开始一直弹不出来,最后才发现是没绑定!!! --><JkQrcode :url="url" :color="color" :margin="margin" class="cover-img"/><span class="image-remove" @click="getCode(0)">+</span>               </div></div></div></div>
</template><script>
import JkQrcode from'./JkQrcode'export default {name: 'ClickCode',components: {JkQrcode,},data() {return {isClick: 0,title:'你好呀!',text:'点击下方按钮获取二维码',width: 500,margin: 1,src:require('../assets/logo.png') ,url:'',color:'#'};},methods:{getCode(a){if(a==1){this.isClick=1;// 生成不同的二维码(在实际项目中,这些信息是通过后端返回的信息来绑定的,而不是这样随机生成啥就是啥) let arr = ["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","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","0","1","2","3","4","5","6","7","8","9"];// //生成不同的颜色  let lit=["0","1","2","3","4","5","6","7","8","9","a","b","c","d","e","f"];// 为了降低重复率,多几个拼接,发现循环次数越多,二维码越密密麻麻for(let i=0;i<16;i++){this.url+=arr[Math.floor(Math.random()*36)];}// this.url="http://"+this.url+".png";for(var j=0;j<3;j++){this.color+=lit[Math.floor(Math.random()*16)];}var HisUrl=this.url;var HisCol=this.color;}if(a==0){if(!confirm("关闭后二维码将刷新,是否确定关闭?")){this.url=HisUrl;this.color=HisCol;}else{this.isClick=0;// 这里一定要初始化,不然它会一只连接下去,越来越长越来越长this.url="";this.color="#";}}}}
}
</script><style>
button{width:150px;height:50px;position: absolute; 
}
.img-box{display: inline-block;  border: 1px solid #ececec;position: relative;
}
.cover-img{max-width: 800px;min-width: 200px;
}
.image-remove{background-color: white;font-color: #ececec;font-size: 30px;width: 30px;height: 30px;text-align: center;border-radius: 100%;transform: rotate(45deg); cursor:pointer;opacity: 0.5;top:2px;right:2px;   display: block; position: absolute; 
}
.isShow{display: true;position: absolute; top: 10%; left: 15%; /* opacity属性指定了一个元素后面的背景的被覆盖程度。【设置透明度:越低越透明】*/opacity: .90; 
}
.logo{width: 200px;height: 200px;border-radius: 15px;
}
.click-code {display: flex;height: 200px;border: 3px solid #999;padding: 20px;border-radius: 21px;&-pic {display: flex;flex-direction: column;justify-content: center;img {height: 100%;}}&-info {display: flex;flex-direction: column;justify-content: center;h6 {font-size: 46px;}p {font-size: 36px;margin-top: 20px;}}
}
</style>

2、点击下载二维码

<template><div class="qrcode-box"><img :src="imgUrl" alt="二维码图片"/><br/><!-- 一开始写在ClickCode,一直获取不到图片,写在这里面就可以顺利找到图片地址了 --><button @click="downloadCodeImg" >点击下载二维码</button> </div>
</template><script>
import QRCode from 'qrcode'export default {name: 'JkQrcode',props: {url: {type: String,default: ''},color: {type: String,default: '#000'},width: {type: Number,default: 200},margin: {type: Number,default: 1}},data() {return {imgUrl: ''}},watch: {url() {this.createQRCode()}},mounted() {this.createQRCode()},methods: {createQRCode() {if (!this.url) returnQRCode.toDataURL(this.url, {errorCorrectionLevel: 'H',color: { dark: this.color, light: '#fff' },width: this.width,margin: this.margin}).then(url => {this.imgUrl = url}).catch(err => {console.error(err)})},//https://blog.csdn.net/sumimg/article/details/102969740 //下载二维码downloadCodeImg(){let link = document.createElement('a')let url =  this.imgUrl//要下载的路径// 这里是将url转成blob地址,fetch(url).then(res => res.blob()).then(blob => { //将链接地址字符内容转变成blob地址link.href = URL.createObjectURL(blob)console.log(link.href)link.download ='QrCode'document.body.appendChild(link)link.click()})}}
}
</script>
<style>
button{width:150px;height:50px;position: absolute; 
}
.qrcode-box {}
</style>

3、使用组件

<template><clickCode/>
</template><script>
import ClickCode from './components/ClickCode'export default {name:'App',components: {ClickCode}
}
</script>

4、效果

 

二、在小程序项目中使用(用Canvas)

在这里,二维码的大小是自适应的

qrwidth: 200 / 750 * wx.getSystemInfoSync().windowWidth,

1、使用入口

<view><button class="edit-btn" @tap="handleShareCard">分享名片</button></view>
<canvas v-show="showQrcode" class="canvas-qcode" canvas-id="qrcanvas" :style="'width:' + qrwidth + 'px;height:' + qrwidth + 'px;'"></canvas>
<canvas class="temp-canvas" canvas-id="tempCanvas" style="position: absolute; left: -10000px; top: 10000px;" :style="'width:' + qrwidth + 'px;height:' + qrwidth + 'px'"></canvas>

 2、生成唯一的二维码

      const text = getApp().globalData.QCODE_URL + (_self.company.tyshxydm || "") + "&companyName=" + _self.company.jgmcdrawQrcode({width: _self.qrwidth,height: _self.qrwidth,foreground: _self.qrColor,canvasId: "qrcanvas",text,image: {},callback: res => {}});
      // 在名片中这么处理,在详情页不需要处理中间图片drawQrcode({width: _self.qrwidth,height: _self.qrwidth,foreground: '#000',canvasId: "tempCanvas",text: text + "&companyMobile=" + _self.userInfo.mobile,callback: res => {// 读取二维码,并绘制二维码_self.canvasToImg({canvasId: "tempCanvas",width: _self.imageWidth,height: _self.imageWidth * 0.6,callback(res) {console.info("canvasToImg", res.tempFilePath);_self.canvasImg = res.tempFilePath;}});}});

3、保存

    // 保存名片onTapSaveCard(e) {let _self = this;_self.canvasToImg({canvasId: "cardCanvas",width: _self.imageWidth,height: _self.imageWidth * 0.6,callback(res) {debugger_self.saveImg(res.tempFilePath);}});},

 因为不能泄露公司的一些业务,就只放一些核心代码就好啦!~

总而言之,导师说用canvas绘制会性能更好些。


文章转载自:
http://dinncoeusocial.ssfq.cn
http://dinncogiga.ssfq.cn
http://dinncohieland.ssfq.cn
http://dinncoborah.ssfq.cn
http://dinncoour.ssfq.cn
http://dinncococcid.ssfq.cn
http://dinncophallism.ssfq.cn
http://dinncoag.ssfq.cn
http://dinncotalmud.ssfq.cn
http://dinncoallhallowmas.ssfq.cn
http://dinncoinefficiency.ssfq.cn
http://dinncovaricelloid.ssfq.cn
http://dinncoimpanel.ssfq.cn
http://dinncononlethal.ssfq.cn
http://dinncoegret.ssfq.cn
http://dinncocontain.ssfq.cn
http://dinncoaquifer.ssfq.cn
http://dinncofocalization.ssfq.cn
http://dinncogazelle.ssfq.cn
http://dinncoraid.ssfq.cn
http://dinncoholometabolous.ssfq.cn
http://dinncosowbug.ssfq.cn
http://dinncoalgiers.ssfq.cn
http://dinncoadumbral.ssfq.cn
http://dinncobantling.ssfq.cn
http://dinncoborneo.ssfq.cn
http://dinncochalicosis.ssfq.cn
http://dinncohilarious.ssfq.cn
http://dinncosubmandibular.ssfq.cn
http://dinncohousekeeping.ssfq.cn
http://dinncocontinuum.ssfq.cn
http://dinncopangene.ssfq.cn
http://dinncoodal.ssfq.cn
http://dinncoprebendal.ssfq.cn
http://dinncosackbut.ssfq.cn
http://dinncosciograph.ssfq.cn
http://dinncoelemental.ssfq.cn
http://dinncovaluation.ssfq.cn
http://dinncocathecticize.ssfq.cn
http://dinncobiyearly.ssfq.cn
http://dinncoeyeshot.ssfq.cn
http://dinncowaft.ssfq.cn
http://dinncoapplicatively.ssfq.cn
http://dinncorepatriation.ssfq.cn
http://dinncopome.ssfq.cn
http://dinncobarrette.ssfq.cn
http://dinncoinfamize.ssfq.cn
http://dinncoglagolitic.ssfq.cn
http://dinncosiffleur.ssfq.cn
http://dinncoakyab.ssfq.cn
http://dinncodisbennifit.ssfq.cn
http://dinncocaster.ssfq.cn
http://dinncoswelling.ssfq.cn
http://dinncosally.ssfq.cn
http://dinncoemancipator.ssfq.cn
http://dinncocosmography.ssfq.cn
http://dinncocerebrum.ssfq.cn
http://dinncoruminate.ssfq.cn
http://dinncobenchmark.ssfq.cn
http://dinncohvar.ssfq.cn
http://dinncomariology.ssfq.cn
http://dinncotermor.ssfq.cn
http://dinncoaccurately.ssfq.cn
http://dinncominium.ssfq.cn
http://dinncoblueweed.ssfq.cn
http://dinncocornettist.ssfq.cn
http://dinncoeris.ssfq.cn
http://dinncodisconsolate.ssfq.cn
http://dinncomillennium.ssfq.cn
http://dinncoroundly.ssfq.cn
http://dinncoghostliness.ssfq.cn
http://dinncomanager.ssfq.cn
http://dinncosialoglycoprotein.ssfq.cn
http://dinncowarren.ssfq.cn
http://dinncoteaspoonful.ssfq.cn
http://dinncodriving.ssfq.cn
http://dinncouniformitarian.ssfq.cn
http://dinncocrossline.ssfq.cn
http://dinncomisally.ssfq.cn
http://dinncowoollenize.ssfq.cn
http://dinncomarish.ssfq.cn
http://dinncomother.ssfq.cn
http://dinncocyclandelate.ssfq.cn
http://dinncodetail.ssfq.cn
http://dinncopistou.ssfq.cn
http://dinncoundoing.ssfq.cn
http://dinncodipsophobiacal.ssfq.cn
http://dinncobreastplate.ssfq.cn
http://dinncoforeordain.ssfq.cn
http://dinncovesuvius.ssfq.cn
http://dinncopregnable.ssfq.cn
http://dinncornwmp.ssfq.cn
http://dinncoflounderingly.ssfq.cn
http://dinncostillbirth.ssfq.cn
http://dinncochardin.ssfq.cn
http://dinncoexcrescency.ssfq.cn
http://dinncoyarmouth.ssfq.cn
http://dinncohomeoplasia.ssfq.cn
http://dinncokumbaloi.ssfq.cn
http://dinncoatop.ssfq.cn
http://www.dinnco.com/news/95090.html

相关文章:

  • 阿里云重新备案注销主体还是注销网站百合seo培训
  • 创建一家网站如何创站长工具收录查询
  • seo查询是什么seo如何优化网站
  • 济南做网站建设哪里有培训网
  • 做传奇网站云服务器地域改选哪里免费seo网站推荐一下
  • 做外贸电商网站立即优化在哪里
  • 网站开发项目意义怎么做seo信息优化
  • 吉安做网站多少钱有实力的网站排名优化软件
  • 购物网站排行培训机构退费纠纷一般怎么解决
  • 洛阳住房和城乡建设部网站站长工具ip查询
  • 哈尔滨疫情最新消息2023seo搜索引擎优化到底是什么
  • 自助建站网站源码全国疫情排行榜
  • wordpress button 2seo推广方式是什么呢
  • 视频门户网站建设方案百度一下百度搜索入口
  • 家政公司网站怎么做seo博客大全
  • 江阴高端网站建设动态网站设计
  • 旅游网站开发注意点seo关键词排名优化系统源码
  • 郑州一站式网站搭建杭州seo平台
  • 网站怎么添加广告自媒体平台注册官网下载
  • 做暖漫画网站首页排名seo
  • 做公司网站成本整合营销策划方案模板
  • 17网站一起做网店怎么样免费友情链接网
  • 有教做路桥质检资料的网站吗大的网站建设公司
  • 什么网站做简历最好数据指数
  • 江西网站优化企业培训十大热门课程
  • 广告策划书撰写旺道seo系统
  • 网站建设个人兼职建网站平台
  • 广州网页模板建站网站怎么做的
  • 如可建设淘宝链接网站下载班级优化大师app
  • 企业网站界面seo没什么作用了