复制
复制
//点击复制
copyText(e) {
wx.setClipboardData({
data: e.currentTarget.dataset.text,
success: function (res) {
wx.getClipboardData({
success: function (res) {
wx.showToast({
title: '复制成功'
})
}
})
}
})
},
保存页面为图片
// HTML
<canvas class='pic' canvas-id='pic' style='width:{{canvasW}}px;height:{{canvasH}}px;' bindlongpress='savePic'></canvas>
<cover-view class='jilu'>
<cover-image src="{{imgurl}}m_jilu.png"></cover-image>
</cover-view>
wx.getSystemInfo({
success: function (res) {
var canvasW = res.windowWidth
var canvasH = res.windowHeight
var tg_bg = app.globalData.imgurl +'m_share.png';
var maImg = app.globalData.imgurl + 'm_ma.png';
console.log(res)
wx.getImageInfo({
src: tg_bg,
success: function (ress) {
that.setData({
canvasW: canvasW,
canvasH: canvasH
})
ctx.drawImage(tg_bg, 0, 0, canvasW, canvasH)
ctx.save()
console.log(canvasW / 2)
ctx.drawImage(maImg,(canvasW/2)-54, (canvasH/2)-40,100,100);
ctx.draw()
wx.hideLoading()
}
})
//长按保存图片
savePic: function () {
wx.canvasToTempFilePath({
canvasId: 'pic',
success: function (res) {
wx.saveImageToPhotosAlbum({
filePath: res.tempFilePath,
success(result) {
wx.showToast({
title: '图片保存成功',
icon: 'success',
duration: 2000
})
}
})
}
})
},