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

北京营销型网站建设公司福州网站建设优质服务商

北京营销型网站建设公司,福州网站建设优质服务商,wordpress 商品模板,做外贸在那些网站找客户来源#xff1a; 公司的一个需求#xff0c;需要给新注册的会员和客商需要增加签署协议功能#xff1b; 之前的思路#xff1a; 1、使用vue-signature-pad来实现电子签名#xff0c;但是安卓手机不兼容#xff1b; 2、uniapp插件市场来实现#xff0c;但是对HBuilderX…来源 公司的一个需求需要给新注册的会员和客商需要增加签署协议功能 之前的思路 1、使用vue-signature-pad来实现电子签名但是安卓手机不兼容 2、uniapp插件市场来实现但是对HBuilderX的版本有要求无奈公司只能使用3.4.7版本 前面2种思路都不行那就用Canvas来实现 Canvass canvas 是 html 的一个标签它可以结合 JavaScript 提供的 canvasApi 来绘制各种各样的图形。canvas 主要用于绘制 2D 图形。注意当你不设置 canvas 的宽高时它的默认宽高是 300px、150px。 需要实现的功能如图 代码实现 EctronicSignature.vuetemplateview classectronic-signaturecanvasclassboard-canvascanvas-iddrawCanvasdisable-scrolltruetouchstarttouchStarttouchmovetouchMovetouchendtouchEnd/canvasview classbtnu-button typesuccess clicksaveImage text保存 classbtnItem/u-buttonu-button clickclearDrawBoard text清空 classbtnItem/u-button/view/view /templatestyle langscss scoped …… /styleEctronicSignature.tscurDrawArr: any [];startX: any 0;startY: any 0;ctx: any {};begin: Boolean false;bgColor: String white; //背景色lineWidth: Number 4; //画笔宽度penMode: Boolean true; //打开画笔 开关currentTab: any 1;currentIndex: any 0;selectPointer: any []; //所有选中的线cache: any ;points: any [];onReady() {this.ctx uni.createCanvasContext(drawCanvas, this); // 获取canvas上下文对象 vue的写法是先获取之后通过.getContext(2d)来获取上下文this.cache new Map(); // 缓存this.ctx.setLineWidth(this.lineWidth); // 设置画笔的粗细}// ctx.draw()绘制结果呈现在canvas// isReverse: 是否保留之前的像素draw(isReverse false, cb) {this.ctx.draw(isReverse, () {if (cb typeof cb function) {cb();}});}// 绘画 开始touchStart(e) {console.log(绘画开始, e.touches[0].x, e.touches[0].y);// customPrint(我能够进行绘制);if (this.penMode) {this.lineBegin(e.touches[0].x, e.touches[0].y);this.lineAddPoint(e.touches[0].x, e.touches[0].y);this.draw(true, ); // 呈现画面}this.points.push([e.touches[0].x, e.touches[0].y]); // 存储绘制的点this.selectPointer.push([[e.touches[0].x, e.touches[0].y]]);}// 开始绘制线条lineBegin(x, y) {this.begin true; // 作为一个标记代表开始绘画this.ctx.beginPath(); // 开始创建一个路径this.startX x;this.startY y;this.ctx.moveTo(this.startX, this.startY); // 将路径移动到画布中的指定点this.lineAddPoint(x, y); // 绘制线条中间添加}// 绘画 移动touchMove(e) {console.log(绘画移动, e.touches[0].x, e.touches[0].y);if (this.begin) {if (this.penMode) {this.lineAddPoint(e.touches[0].x, e.touches[0].y);this.draw(true, );}this.points.push([e.touches[0].x, e.touches[0].y]);this.selectPointer[this.selectPointer.length - 1].push([e.touches[0].x, e.touches[0].y]);}}// 绘制线条中间添加点lineAddPoint(x, y) {this.ctx.moveTo(this.startX, this.startY);this.ctx.lineTo(x, y); // 增加一个新的点然后创建一条从上次指定点到目标点的线this.ctx.stroke(); // 画出当前路径的边框this.startX x;this.startY y;}// 绘画 结束touchEnd(e) {if (this.penMode) {// this.curDrawArr [];this.points [];this.lineEnd();}}// 绘制线条结束lineEnd() {this.ctx.closePath(); // 关闭一个路径关闭路径会连接起点和终点this.begin false;}// 检验画布是否为空isCanvasBlank(canvas) {const blank document.createElement(canvas); //系统获取一个空canvas对象blank.width canvas.width;blank.height canvas.height;return canvas.toDataURL() blank.toDataURL(); // .toDataURL()将canvas对象转换为base64位编码}// 保存 图片数据saveImage() {const _this this;uni.canvasToTempFilePath({canvasId: drawCanvas,success: function(res) {console.log(res , res);// 在H5平台下tempFilePath 为 base64// this.uploadimage(res.tempFilePath,save,page.currentTab)const canvas document.getElementsByTagName(canvas)[0];if (_this.isCanvasBlank(canvas)) {uni.showToast({title: 请签字,icon: none,});return false;}},});}//清除clearDrawBoard() {this.ctx.draw();this.selectPointer [];}}推荐资料 https://www.runoob.com/html/html5-canvas.html https://uniapp.dcloud.net.cn/component/canvas.html#canvas https://open.dingtalk.com/document/personalapp/setlinewidth
http://www.zqtcl.cn/news/370097/

相关文章:

  • 网站建设_聊城笑话小网站模板html
  • 智能建造师威海网站优化推广
  • 做网站如何选域名长沙房价2020最新价格
  • seo网站推广济宁一建建设集团有限公司
  • 高端大气网站设计欣赏有意思网站推荐
  • 什么网站做海宁的房产好北控京奥建设有限公司网站
  • 上海网站建设网络推广网页搜索框下记录删不掉
  • 团购网站大全做相册手机网站如何制作免费
  • 承德网站制作方案百度seo关键词排名s
  • 网站建设公司佛山国内网站推广
  • 辽宁网站制作公司潍坊网站建设维护
  • 手机网站图片切换平面图网站
  • 松岗建设网站广州网站定制开发方案
  • 东阳网站建设价格做理财的网站有哪些问题
  • 蓄电池回收网站建设wordpress cp 部署
  • cuteftp 备份网站网站制作课程介绍
  • 杭州网站搭建宁波企业官网建设
  • php免费网站源码网站建设电子书
  • 建设纺织原料网站专业网页制作室
  • 买域名做网站推广都是些什么湘潭什么网站做c1题目
  • 鲜花网站建设图片昆明网站建站平台
  • 密云网站制作案例昆明小程序开发
  • 网站紧急维护商丘手机网站制作
  • 什么专业会制作网站罗湖做网站的公司哪家好
  • 永久免费ppt下载网站有没有跟一起做网店一样的网站
  • 百川网站石家庄物流网站建设
  • 广州外贸网站设计外贸seo外贸推广外贸网站建设外贸网站建设
  • 网站 栏目建设银行网站用户名是什么
  • 服装类的网站建设中原免费网站建设
  • 网站开发培训班多少报名费安徽省建设工程信息网站