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

建设银行官网首页网站购纪念币北京网站提升排名

建设银行官网首页网站购纪念币,北京网站提升排名,网页案例图片,天津网utils.js //裁剪分享的图片为5:4 const makeCanvas (imgUrl) > {console.log("imgUrl",imgUrl);return new Promise((resolve, reject) > {// 获取图片信息,小程序下获取网络图片信息需先配置download域名白名单才能生效uni.getImageInfo({src: imgUrl,succe…

utils.js

//裁剪分享的图片为5:4
const makeCanvas = (imgUrl) => {console.log("imgUrl",imgUrl);return new Promise((resolve, reject) => {// 获取图片信息,小程序下获取网络图片信息需先配置download域名白名单才能生效uni.getImageInfo({src: imgUrl,success: (imgInfo) => {let ctx = uni.createCanvasContext('canvas')let canvasW = 0let canvasH = imgInfo.height// 把比例设置为 宽比高 5:4canvasW = (imgInfo.height * 5) / 4// 为画框设置背景色,注意要放在画图前,图会覆盖在背景色上ctx.fillStyle = "#fff";if (imgInfo.width > 400 || imgInfo.height > 320) {canvasW = 400;canvasH = 320;ctx.fillRect(0, 0, canvasW, canvasH);let dWidth = canvasW / imgInfo.width; // canvas与图片的宽度比例let dHeight = canvasH / imgInfo.height; // canvas与图片的高度比例let dWH = imgInfo.width / imgInfo.height; //宽高比if (imgInfo.width > canvasW && imgInfo.height > canvasH) {if (dWH > 1 && dWH < 1.5) {ctx.drawImage(imgInfo.path, (canvasW - imgInfo.width * dHeight) / 2,0, imgInfo.width * dHeight, imgInfo.height *dHeight)} else {if (imgInfo.width > imgInfo.height) {ctx.drawImage(imgInfo.path, 0, (canvasH - imgInfo.height *dWidth) / 2, imgInfo.width * dWidth,imgInfo.height *dWidth)}if (imgInfo.width == imgInfo.height) {ctx.drawImage(imgInfo.path, (canvasW - imgInfo.width *dHeight) / 2, 0, imgInfo.width * dHeight,imgInfo.height * dHeight)}if (imgInfo.width < imgInfo.height) {ctx.drawImage(imgInfo.path, (canvasW - imgInfo.width *dHeight) / 2, 0, imgInfo.width * dHeight,imgInfo.height * dHeight)}}} else {if (imgInfo.width > imgInfo.height) {ctx.drawImage(imgInfo.path, 0, (canvasH - imgInfo.height) / 2,imgInfo.width * dWidth, imgInfo.height)}if (imgInfo.width == imgInfo.height) {ctx.drawImage(imgInfo.path, (canvasW - imgInfo.width * dHeight) / 2,0, imgInfo.width * dHeight, imgInfo.height *dHeight)}if (imgInfo.width < imgInfo.height) {ctx.drawImage(imgInfo.path, (canvasW - imgInfo.width * dHeight) / 2,0, imgInfo.width * dHeight, imgInfo.height *dHeight)}}} else {ctx.fillRect(0, 0, canvasW, canvasH)ctx.drawImage(imgInfo.path,0,0,canvasW,canvasH,(canvasW - imgInfo.width) / 2, // 宽度从中间向两边填充0,canvasW,canvasH)}ctx.draw(false, () => {uni.canvasToTempFilePath({width: canvasW,height: canvasH,destWidth: 750, // 标准的iphone6尺寸的两倍,生成高清图destHeight: 600,canvasId: "canvas",fileType: "jpg", // 注意jpg默认背景为透明success: (res) => {console.log("res.tempFilePath",res.tempFilePath);resolve(res.tempFilePath)},fail: (err) => {console.log("err",err);reject(err)}},this)})},fail: (err) => {reject(err)}})})
}
module.exports = {makeCanvas
}

用的页面

import util from '@/common/js/util.js';
//分享到聊天onShareAppMessage() {return new Promise((resolve, reject) => {let shareMessage = {title: this.liveInfo.wx_title,path: '/subPages/livePages/liveCourse/live_course_info?courseid=' +this.courseid,imageUrl: this.liveInfo.wx_thumb || this.liveInfo.thumb};util.makeCanvas(shareMessage.imageUrl).then(imgPath => {console.log(imgPathm,'imgPath')// uni.hideLoading();resolve({title: shareMessage.title,path: shareMessage.path,imageUrl: imgPath});}).catch(err => {// uni.hideLoading();resolve(shareMessage);});})},
http://www.yayakq.cn/news/60855/

相关文章:

  • 网站 定制wordpress 谷歌头像
  • 网站500错误是什么意思网站制作收费明细表
  • 做国际网站要多少钱编写软件
  • 东盟经济技术开发区建设网站网站内部代码优化
  • 怎么让网站能被百度到常熟市建设局网站
  • 做设计兼职的网站设计家官网室内设计视频
  • 免费w网站建设织梦旅游网站模板
  • 临安市建设局网站wordpress 获取分类
  • 长沙市住房和城乡建设局网站wordpress %3c 3.6.1
  • 免费游戏网站建设wordpress和网盘结合
  • 安徽省工程建设监理协会网站台州网站seo
  • ps做的网站保存不了jpg指数基金怎么买才赚钱
  • 海南网站建设方面seo软件优化
  • 经营网站建设摄影网站制作
  • 有做a50期货的网站厦门建设局投诉电话
  • 湖南省公司注册网站十三五专业建设规划
  • 南宁工程造价建设信息网站17网站一起做网店官网
  • 北京江苏省住房和城乡建设厅网站建网站怎样往网站传视频
  • 好看的网站在哪里好找旅游网站建设公司排名
  • 帝国cms做门户网站网站提交收录入口链接
  • 网站建设外包服务公司创业计划书电子商务网站规划书
  • 第一次做网站没头绪网站开发入门
  • 手机网站开发团队电子上网站开发
  • 做厂房出租有那些推广网站中堂仿做网站
  • 居家养老网站建设开发网站公司有哪些
  • 佛山公共交易资源平台手机网站优化 工具
  • yii2框架做的网站有哪些东莞做网站怎么样
  • 漳州违法建设举报网站怎么制作网站主题
  • 最全的网站大全做网站制作步骤
  • 网站建设公司价位删除wordpress主题底部