ctx.save()
ctx.beginPath()
ctx.setFillStyle('#fff')
sketchUp.drawCircle(10.533 * vw, res[6])
ctx.setShadow(0, 0.5 * vw, 10, 'rgba(55,75,99,0.15)')
ctx.fill()
ctx.restore()

ctx.save()
ctx.beginPath()
sketchUp.drawCircle(10 * vw, res[6])
ctx.clip()
sketchUp.drawImg(this.avatarUrl, res[6])
ctx.restore()
ctx.draw(true)


_canvasDraw () {
const ctx = this.sketchUp.ctx
 wechat.draw(ctx).then(res => {
this._canvasToFile(ctx)
}).catch(err => {
console.info(err)
wechat.hideLoading()
this.$refs.toast.show('绘图失败,请重新尝试!')
})
},
_canvasToFile (ctx) {
wechat.canvasToTempFilePath({
x: 0,
   y: 0,
   width: this.divW * this.prop,
   height: this.divH * this.prop,
   destWidth: this.divW * this.prop,
   destHeight: this.divH * this.prop,
   canvasId: 'poster',
   fileType: 'jpg'
 }, ctx).then(res => {
wechat.hideLoading()
// wechat.previewImage({urls: [res.tempFilePath]})
   this._upLoadImg(res.tempFilePath)
const path = `/pages/poster-share/poster-share`
   getApp().globalData.imgUrl = res.tempFilePath
this.$router.push({path})
// console.info(res.tempFilePath)
 }).catch(err => {
console.info(err)
wechat.hideLoading()
this.$refs.toast.show('请重新尝试!')
})



/**
* 绘制圆形
* @param r 半径
* @param res 盒子的信息
* @param xAdjust 可调整的偏移量x轴
* @param yAdjust 可调整的偏移量y轴
* @private
*/
drawCircle (r, res, xAdjust = 0, yAdjust = 0) {
this.ctx.arc((res.left + this.rPos.left + res.width / 2 + xAdjust) * this.prop, (res.top + this.rPos.top + res.width / 2 + yAdjust) * this.prop, r, 2 * Math.PI)
}

/**
* 绘制图片
* @param imgUrl  图片路径
* @param res 盒子信息
* @param xAdjust 可调整的偏移量x轴
* @param yAdjust 可调整的偏移量y轴
* @private
展开全部
收起
1回答
提交回答
  • 至过去的我

    2044人对此回答表示赞同

    我是未来的你,你现在是不是在年找寻小程序答案。你不要感觉诧异,给你来信原因,就是让你不在后悔。今天去学习如何推广小程序,相信......点击查看更多>
    发布于
  • William

    20人对此回答表示赞同

    此类问题之前修复过,请更新客户端版本至6.7.0。如若问题还存在,麻烦给个相关的代码片段,我们定位下问题

    展开
    20
    1回复
    发布于 6年前

    评论(1)

    收起评论

    • 雪中向日葵 2019-02-14 15:29

      谢谢,解决了,升级下微信版本就好了,请问是哪个版本修复的?

      回复
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
咨询热线

13312967497

扫码添加业务即可随时咨询 还可领取小程序推广攻略

业务咨询: 13312967497
扫码咨询

扫码咨询套餐

回到顶部