const app = getApp()
Page({
data: {
},
onLoad: function (e) {
wx.setNavigationBarTitle({
title: "神符"
})
var ctx = wx.createCanvasContext('shenfu')
ctx.drawImage("/images/"+app.globalData.cav_type+".jpg", 0, 0, 600, 1145)
ctx.setTextAlign('center') // 文字居中
ctx.setFillStyle('#a00b0f') // 文字颜色:黑色
ctx.font="normal normal normal 20px KaiTi";
ctx.fillText("ID:"+app.globalData.cav_name+" 所在大区:"+app.globalData.cav_daqu, 600/2, 1050)
ctx.stroke()
ctx.draw(false,function(){
//回调方法
wx.canvasToTempFilePath({
x: 0,
y: 0,
width: 600,
height: 1145,
destWidth: 600,
destHeight: 1145,
canvasId: 'shenfu',
success: function(res) {
console.log(res.tempFilePath)
wx.previewImage({
current: '', // 当前显示图片的http链接
urls: [res.tempFilePath], // 需要预览的图片http链接列表
success: function(resa) {
wx.saveImageToPhotosAlbum({
filePath: res.tempFilePath,
success(resb) {
wx.showModal({
title: '提示',
content: '神符已保存到相册中。',
showCancel:false,
success: function(res) {
if (res.confirm) {
console.log('用户点击确定')
wx.navigateTo({
url: '/pages/index/index'
})
} else if (res.cancel) {
console.log('用户点击取消')
}
}
})
}
})
}
})
}
})
})
},
shengcheng:function(){
wx.canvasToTempFilePath({
x: 0,
y: 0,
width: 600,
height: 1145,
destWidth: 600,
destHeight: 1145,
canvasId: 'shenfu',
success: function(res) {
console.log(res.tempFilePath)
wx.saveImageToPhotosAlbum({
filePath: res.tempFilePath
})
//wx.previewImage({
// current: '', // 当前显示图片的http链接
// urls: [res.tempFilePath] // 需要预览的图片http链接列表
//})
}
})
},
goHome: function(){
console.log('ss')
wx.switchTab({
url: '/pages/index/index'
})
}
})