diff --git a/pages/user/tui-guang.vue b/pages/user/tui-guang.vue
index b91cf92..af2ab33 100644
--- a/pages/user/tui-guang.vue
+++ b/pages/user/tui-guang.vue
@@ -71,18 +71,15 @@
-
-
-
+
+
+
+
+
+
-
@@ -116,9 +113,57 @@
},
onLoad() {
console.log(uni.getStorageSync('userinfo').ID)
- onReady();
},
methods: {
+ saveImageToPhotosAlbum() {
+ const imageUrl = this.getHaiBao(); // 替换为你的网络图片地址
+ // 下载图片到本地
+ wx.downloadFile({
+ url: imageUrl,
+ success: (res) => {
+ if (res.statusCode === 200) {
+ const tempFilePath = res.tempFilePath; // 获取临时文件路径
+ // 保存图片到相册
+ wx.saveImageToPhotosAlbum({
+ filePath: tempFilePath,
+ success: () => {
+ uni.showToast({
+ title: '保存成功',
+ icon: 'success',
+ });
+ },
+ fail: (err) => {
+ uni.showToast({
+ title: '保存失败',
+ icon: 'none',
+ });
+ console.error('保存失败', err);
+ },
+ });
+ } else {
+ uni.showToast({
+ title: '图片下载失败',
+ icon: 'none',
+ });
+ console.error('图片下载失败', res);
+ }
+ },
+ fail: (err) => {
+ uni.showToast({
+ title: '图片下载失败',
+ icon: 'none',
+ });
+ console.error('图片下载失败', err);
+ },
+ });
+ },
+ getHaiBao() {
+ return this.$baseUrl + '/api/generate_urllinks?userId=' + uni.getStorageSync('userinfo').ID;
+ },
+ getXiaZai() {
+ return this.$baseUrl + '/dow.png';
+
+ },
/*下拉刷新的回调 */
downCallback() {
this.mescroll.resetUpScroll()
@@ -160,48 +205,7 @@
//海报弹窗
showPosterPopup() {
this.$refs.posterPopup.open();
- this.drawAndExport();
- },
- onReady() {
- // 获取uQRCode实例
- var qr = new UQRCode();
- // 设置二维码内容
- qr.data = "https://uqrcode.cn/doc";
- // 设置二维码大小,必须与canvas设置的宽高一致
- qr.size = 150;
- // 调用制作二维码方法
- qr.make();
- // 获取canvas上下文
- var canvasContext = uni.createCanvasContext('qrcode', this); // 如果是组件,this必须传入
- // 设置uQRCode实例的canvas上下文
- qr.canvasContext = canvasContext;
- // 调用绘制方法将二维码图案绘制到canvas上
- qr.drawCanvas();
- },
-
- drawAndExport() {
- const ctx = uni.createCanvasContext('myPoster', this);
- ctx.setFillStyle('red');
- ctx.fillRect(10, 10, 150, 75);
- ctx.setFontSize(18);
- ctx.setFillStyle('black');
- ctx.fillText('Hello, Canvas!', 50, 50);
- ctx.draw(false, () => {
- uni.canvasToTempFilePath({
- canvasId: 'myPoster',
- success: res => {
- console.log('图片路径:', res.tempFilePath);
- // 在这里处理生成的图片路径,比如下载、显示或上传
- },
- fail: err => {
- console.error('生成图片失败:', err);
- }
- });
- });
- uni.showToast({
- title: "图片"
- })
}
}
}