|
|
|
@ -118,33 +118,38 @@ |
|
|
|
|
// usingIn: this //在自定义组件下,第二个参数传入组件实例this |
|
|
|
|
}) |
|
|
|
|
|
|
|
|
|
console.log(qrde, " qrde") |
|
|
|
|
// 把当前画布指定区域的内容导出生成图片,并返回文件路径。 |
|
|
|
|
const ctx = uni.createCanvasContext('qrImg'); |
|
|
|
|
ctx.draw(true,setTimeout(() => { |
|
|
|
|
uni.canvasToTempFilePath({ |
|
|
|
|
canvasId: 'qrImg', |
|
|
|
|
success: (res) => { |
|
|
|
|
uni.hideLoading() |
|
|
|
|
// 在H5平台下,tempFilePath 为 base64 |
|
|
|
|
// console.log('yz-qr图片路径:', res) |
|
|
|
|
console.log('二维码图片地址', res.tempFilePath) |
|
|
|
|
this.dataInfo.recommendCodeGoods = res.tempFilePath; |
|
|
|
|
/* qrcode = null; */ |
|
|
|
|
/* uni.getFileSystemManager().readFile({ |
|
|
|
|
filePath: res.tempFilePath, //选择图片返回的相对路径 |
|
|
|
|
encoding: 'base64', //编码格式 |
|
|
|
|
success: res => { |
|
|
|
|
// 成功的回调 |
|
|
|
|
let base64 = 'data:image/jpeg;base64,' + res.data; |
|
|
|
|
this.dataInfo.recommendCodeGoods = base64; |
|
|
|
|
} |
|
|
|
|
}); */ |
|
|
|
|
|
|
|
|
|
}, |
|
|
|
|
fail: (err) => { |
|
|
|
|
uni.hideLoading(); |
|
|
|
|
/* qrcode = null; */ |
|
|
|
|
console.log(err) |
|
|
|
|
} |
|
|
|
|
}, this); |
|
|
|
|
}, 0)) |
|
|
|
|
// 把当前画布指定区域的内容导出生成图片,并返回文件路径。 |
|
|
|
|
// uni.canvasToTempFilePath({ |
|
|
|
|
// canvasId: 'qrImg', |
|
|
|
|
// success: (res) => { |
|
|
|
|
// uni.hideLoading() |
|
|
|
|
// // 在H5平台下,tempFilePath 为 base64 |
|
|
|
|
// // console.log('yz-qr图片路径:', res) |
|
|
|
|
// this.dataInfo.recommendCodeGoods = res.tempFilePath; |
|
|
|
|
// /* qrcode = null; */ |
|
|
|
|
// }, |
|
|
|
|
// fail: (err) => { |
|
|
|
|
// uni.hideLoading(); |
|
|
|
|
// /* qrcode = null; */ |
|
|
|
|
// console.log(err) |
|
|
|
|
// } |
|
|
|
|
// }, this); |
|
|
|
|
|
|
|
|
|
// console.log('绘制完成'); |
|
|
|
|
}, |
|
|
|
@ -287,73 +292,98 @@ |
|
|
|
|
uni.hideLoading(); |
|
|
|
|
// #endif |
|
|
|
|
// #ifdef MP-WEIXIN |
|
|
|
|
|
|
|
|
|
this.savePosterPath(imgUrl) |
|
|
|
|
// #endif |
|
|
|
|
|
|
|
|
|
}, |
|
|
|
|
savePosterPath(url) { |
|
|
|
|
uni.showLoading({ |
|
|
|
|
title: '海报下载中' |
|
|
|
|
title: '海报下载中...' |
|
|
|
|
}); |
|
|
|
|
// if (this.settingWritePhotosAlbum) { |
|
|
|
|
//获取用户的当前设置。获取相册权限 |
|
|
|
|
uni.getSetting({ |
|
|
|
|
success: res => { |
|
|
|
|
if (res.authSetting['scope.writePhotosAlbum']) { |
|
|
|
|
uni.saveImageToPhotosAlbum({ |
|
|
|
|
filePath: imgUrl, |
|
|
|
|
success: (res) => { |
|
|
|
|
//如果没有相册权限 |
|
|
|
|
if (!res.authSetting["scope.writePhotosAlbum"]) { |
|
|
|
|
//向用户发起授权请求 |
|
|
|
|
uni.authorize({ |
|
|
|
|
scope: "scope.writePhotosAlbum", |
|
|
|
|
success: () => { |
|
|
|
|
//授权成功保存图片到系统相册 |
|
|
|
|
uni.saveImageToPhotosAlbum({ |
|
|
|
|
//图片路径,不支持网络图片路径 |
|
|
|
|
filePath: url, |
|
|
|
|
success: (res) => { |
|
|
|
|
uni.hideLoading(); |
|
|
|
|
uni.showToast({ |
|
|
|
|
title: '保存成功' |
|
|
|
|
return uni.showToast({ |
|
|
|
|
title: "保存成功!", |
|
|
|
|
}); |
|
|
|
|
}, |
|
|
|
|
fail: (res) => { |
|
|
|
|
console.log(res.errMsg); |
|
|
|
|
return uni.showToast({ |
|
|
|
|
title: res.errMsg, |
|
|
|
|
}); |
|
|
|
|
}, |
|
|
|
|
fail() { |
|
|
|
|
complete: (res) => { |
|
|
|
|
uni.hideLoading(); |
|
|
|
|
} |
|
|
|
|
}, |
|
|
|
|
}); |
|
|
|
|
} else { |
|
|
|
|
}, |
|
|
|
|
//授权失败 |
|
|
|
|
fail: () => { |
|
|
|
|
uni.hideLoading(); |
|
|
|
|
uni.showModal({ |
|
|
|
|
title: '提示', |
|
|
|
|
content: '请先在设置页面打开“保存相册”使用权限', |
|
|
|
|
confirmText: '去设置', |
|
|
|
|
cancelText: '算了', |
|
|
|
|
success: data => { |
|
|
|
|
if (data.confirm) { |
|
|
|
|
|
|
|
|
|
uni.openSetting(); |
|
|
|
|
title: "您已拒绝获取相册权限", |
|
|
|
|
content: "是否进入权限管理,调整授权?", |
|
|
|
|
success: (res) => { |
|
|
|
|
if (res.confirm) { |
|
|
|
|
//调起客户端小程序设置界面,返回用户设置的操作结果。(重新让用户授权) |
|
|
|
|
uni.openSetting({ |
|
|
|
|
success: (res) => { |
|
|
|
|
console.log(res |
|
|
|
|
.authSetting |
|
|
|
|
); |
|
|
|
|
}, |
|
|
|
|
}); |
|
|
|
|
} else if (res.cancel) { |
|
|
|
|
return uni.showToast({ |
|
|
|
|
title: "已取消!", |
|
|
|
|
}); |
|
|
|
|
} |
|
|
|
|
}, |
|
|
|
|
}); |
|
|
|
|
}, |
|
|
|
|
}); |
|
|
|
|
} else { |
|
|
|
|
//如果已有相册权限,直接保存图片到系统相册 |
|
|
|
|
uni.saveImageToPhotosAlbum({ |
|
|
|
|
filePath: url, |
|
|
|
|
success: (res) => { |
|
|
|
|
uni.hideLoading(); |
|
|
|
|
return uni.showToast({ |
|
|
|
|
title: "保存成功!", |
|
|
|
|
}); |
|
|
|
|
}, |
|
|
|
|
fail() { |
|
|
|
|
fail: (res) => { |
|
|
|
|
uni.hideLoading(); |
|
|
|
|
} |
|
|
|
|
console.log(res.errMsg); |
|
|
|
|
return uni.showToast({ |
|
|
|
|
title: res.errMsg, |
|
|
|
|
}); |
|
|
|
|
} |
|
|
|
|
}, |
|
|
|
|
fail() { |
|
|
|
|
//无论成功失败都走的回调 |
|
|
|
|
complete: (res) => { |
|
|
|
|
uni.hideLoading(); |
|
|
|
|
}, |
|
|
|
|
}); |
|
|
|
|
} |
|
|
|
|
}, |
|
|
|
|
fail: (res) => { |
|
|
|
|
uni.hideLoading() |
|
|
|
|
}, |
|
|
|
|
}); |
|
|
|
|
// } else { |
|
|
|
|
// this.settingWritePhotosAlbum = true; |
|
|
|
|
// uni.authorize({ |
|
|
|
|
// scope: 'scope.writePhotosAlbum', |
|
|
|
|
// success: () => { |
|
|
|
|
// uni.saveImageToPhotosAlbum({ |
|
|
|
|
// filePath: imgUrl, |
|
|
|
|
// success: () => { |
|
|
|
|
// uni.hideLoading(); |
|
|
|
|
// uni.showToast({ |
|
|
|
|
// title: '保存成功' |
|
|
|
|
// }); |
|
|
|
|
// }, |
|
|
|
|
// fail(){ |
|
|
|
|
// uni.hideLoading(); |
|
|
|
|
// } |
|
|
|
|
// }); |
|
|
|
|
// }, |
|
|
|
|
// fail(){ |
|
|
|
|
// uni.hideLoading(); |
|
|
|
|
// } |
|
|
|
|
// }); |
|
|
|
|
// } |
|
|
|
|
// #endif |
|
|
|
|
|
|
|
|
|
}, |
|
|
|
|
// 文字换行 |
|
|
|
|
drawtext(text, maxWidth) { |
|
|
|
|