// components/My_TwoDimensionalCode/index.js Component({ /** * 组件的属性列表 */ properties: { title: { type: String }, codeName: { type: String }, imageUrl: { type: String, value: 'https://bwj.obs.cn-east-2.myhuaweicloud.com:443/202112101639101631143B33e18617.png' } }, /** * 组件的初始数据 */ data: { }, /** * 组件的方法列表 */ methods: { /* 预览大图 */ preViewImage() { const url = [this.data.imageUrl]; wx.previewImage({ urls: url, }) }, /* 下载二维码 */ download() { wx.downloadFile({ url: this.data.imageUrl, success: function (res) { const tempFilePath = res.tempFilePath; // 保存文件 wx.saveFile({ tempFilePath, success: function (res) { const savedFilePath = res.savedFilePath; // 打开文件 wx.openDocument({ filePath: savedFilePath, success: function (res) { console.log(res) }, }); }, fail: function (err) { console.log('保存失败:', err) wx.showToast({ title: '保存失败', icon: "none" }) } }); }, fail: function (err) { console.log('下载失败:', err); wx.showToast({ title: '下载失败', icon: "none" }) }, }); } } })