当前位置:首页
>> 核电技术聚变聚能设备 >> 【uniapp小程序-分享】,w890i(uniapp 小程序)
【uniapp小程序-分享】,w890i(uniapp 小程序)
cpugpu芯片开发光刻机
核电技术聚变聚能设备
5
文件名:【uniapp小程序-分享】,w890i
【uniapp小程序-分享】
//分享到聊天onShareAppMessage() {let shareMessage = {title: this.liveInfo.wx_title,path: '/subPages/livePages/liveCourse/live_course_info?courseid=' +this.courseid,imageUrl: this.liveInfo.wx_thumb};let shearMsg = uni.getStorageSync('shearImg' + this.courseid);if (shearMsg && shearMsg.id == this.courseid) {return {title: shareMessage.title,path: shareMessage.path,imageUrl: `${this.liveInfo.wx_thumb}?imageView2/1/w/640/h/360`|| shearMsg.imgPath};} else {uni.showLoading({title: '分享图片生成中...',icon: 'none'});return new Promise((resolve, reject) => {this.shareCode().then(res => {uni.hideLoading();let img = res uni.hideLoading();resolve({title: shareMessage.title,path: shareMessage.path,imageUrl: img});// 将分享图片加入缓存let msg = {imgPath: img,id: this.courseid};uni.setStorageSync('shearImg' + this.courseid, msg);}).catch(err => {uni.hideLoading();resolve({title: shareMessage.title,path: shareMessage.path,imageUrl: imgPath});});});}},// 分享到朋友圈onShareTimeline() {return {title: this.liveInfo.name,path: '/subPages/livePages/liveCourse/live_course_info?courseid=' +this.courseid,imageUrl: this.liveInfo.wx_thumb};},methods:{// 分享卡片shareCode() {let _this = this;return new Promise(async (resolve, reject) => {const ctx = uni.createCanvasContext('shareCanvas', this);let bg = this.liveInfo.wx_thumblet bt = '背景图';ctx.draw();ctx.save();await uni.getImageInfo({src: bg}).then(res => {if (res[1].errMsg == 'getImageInfo:ok') {ctx.save();ctx.drawImage(res[1].path, 0, 0, 195, 160);ctx.restore();} else {uni.$u.toast('海报生成失败');}});ctx.restore();// 生成图片ctx.draw(true, ret => {setTimeout(() => {uni.canvasToTempFilePath({canvasId: 'shareCanvas',success: res => {resolve(res.tempFilePath);},fail: err => {uni.$u.toast('分享图片生成失败');}},_this);}, 10);});});},textPrewrap(ctx, content, drawX, drawY, lineHeight, lineMaxWidth, lineNum) {var drawTxt = ''; // 当前绘制的内容var drawLine = 1; // 第几行开始绘制var drawIndex = 0; // 当前绘制内容的索引// 判断内容是否可以一行绘制完毕if (ctx.measureText(content).width <= lineMaxWidth) {ctx.fillText(content.substring(drawIndex, i), drawX, drawY);} else {for (var i = 0; i < content.length; i++) {drawTxt += content[i];if (ctx.measureText(drawTxt).width >= lineMaxWidth) {if (drawLine >= lineNum) {ctx.fillText(content.substring(drawIndex, i) + '..', drawX, drawY);break;} else {ctx.fillText(content.substring(drawIndex, i + 1), drawX, drawY);drawIndex = i + 1;drawLine += 1;drawY += lineHeight;drawTxt = '';}} else {// 内容绘制完毕,但是剩下的内容宽度不到lineMaxWidthif (i === content.length - 1) {ctx.fillText(content.substring(drawIndex), drawX, drawY);}}}}},}
同类推荐
-

核电聚能设备的安全性能如何?(核电聚能设备的安全性能如何)
查看 -

核电聚能设备的市场竞争格局如何?(核电站核聚变可控吗)
查看 -

四代核电技术有哪些商业化进展?(四代核电技术有哪些商业化进展情况)
查看 -

【RS码2】RS码的BM迭代译码原理详解及MATLAB实现(不使用MATLAB库函数【全部代码需私信另外付费获取】),点讯输入法
查看 -

【RTOS】基于V7开发板的uCOS-III,uCOS-II,RTX4,RTX5,FreeRTOS原版和带CMSIS-RTOS V2封装层版全部集齐...,苹果4官网
查看 -

【RabbitMQ】golang客户端教程5——使用topic交换器,索爱k810i
查看 -

【React】搭建React项目,三星e338(三星galaxyactive3)
查看 -

【Redis】Java Spring操作redis,联想家悦s系列
查看 -

【Redis】String字符串类型-常用命令,诺基亚 e65
查看