|
|
@ -223,6 +223,68 @@ Page({ |
|
|
}); |
|
|
}); |
|
|
} |
|
|
} |
|
|
}); |
|
|
}); |
|
|
|
|
|
}, |
|
|
|
|
|
|
|
|
|
|
|
// 分享二维码
|
|
|
|
|
|
shareQRCode: function () { |
|
|
|
|
|
const { qrCodeUrl } = this.data; |
|
|
|
|
|
|
|
|
|
|
|
if (!qrCodeUrl) { |
|
|
|
|
|
wx.showToast({ |
|
|
|
|
|
title: '请先生成二维码', |
|
|
|
|
|
icon: 'none', |
|
|
|
|
|
duration: 2000 |
|
|
|
|
|
}); |
|
|
|
|
|
return; |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
// 显示加载提示
|
|
|
|
|
|
wx.showLoading({ |
|
|
|
|
|
title: '准备分享...', |
|
|
|
|
|
mask: true |
|
|
|
|
|
}); |
|
|
|
|
|
|
|
|
|
|
|
// 下载图片到本地临时文件
|
|
|
|
|
|
wx.downloadFile({ |
|
|
|
|
|
url: qrCodeUrl, |
|
|
|
|
|
success: (res) => { |
|
|
|
|
|
if (res.statusCode === 200) { |
|
|
|
|
|
wx.hideLoading(); |
|
|
|
|
|
// 打开分享面板
|
|
|
|
|
|
wx.showShareImageMenu({ |
|
|
|
|
|
path: res.tempFilePath, |
|
|
|
|
|
success: () => { |
|
|
|
|
|
console.log('分享成功'); |
|
|
|
|
|
}, |
|
|
|
|
|
fail: (err) => { |
|
|
|
|
|
console.error('分享失败:', err); |
|
|
|
|
|
wx.showToast({ |
|
|
|
|
|
title: '分享失败,请重试', |
|
|
|
|
|
icon: 'none', |
|
|
|
|
|
duration: 2000 |
|
|
|
|
|
}); |
|
|
|
|
|
} |
|
|
|
|
|
}); |
|
|
|
|
|
} else { |
|
|
|
|
|
wx.hideLoading(); |
|
|
|
|
|
console.error('下载图片失败,状态码:', res.statusCode); |
|
|
|
|
|
wx.showToast({ |
|
|
|
|
|
title: '下载图片失败,请重试', |
|
|
|
|
|
icon: 'none', |
|
|
|
|
|
duration: 2000 |
|
|
|
|
|
}); |
|
|
|
|
|
} |
|
|
|
|
|
}, |
|
|
|
|
|
fail: (err) => { |
|
|
|
|
|
wx.hideLoading(); |
|
|
|
|
|
console.error('下载图片失败:', err); |
|
|
|
|
|
wx.showToast({ |
|
|
|
|
|
title: '分享失败,请重试', |
|
|
|
|
|
icon: 'none', |
|
|
|
|
|
duration: 2000 |
|
|
|
|
|
}); |
|
|
|
|
|
} |
|
|
|
|
|
}); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
}); |
|
|
}); |