// pages/mine/myqrcode/myqrcode.js const app = getApp() Page({ data: { qrcodepath: null, loaddisplay: 'none', sqshow: false }, finish: function () { this.setData({ loaddisplay: 'none' }) }, onShow: function() { this.setData({ sqshow: false }) }, onLoad: function (options) { this.setData({ loaddisplay: true }) var that = this wx.request({ url: app.globalData.url + '/CreatePOP', method: 'get', data: { wv_phone: app.globalData.userphone }, success: function (res) { that.setData({ qrcodepath: res.data, loaddisplay: 'none' }) }, fail() { app.timeOut() } }) let _this = this; _this.setData({ navH: app.globalData.navHeight }) }, saveImgToPhotosAlbumTap: function () { var that = this wx.showLoading({ title: '保存中......', icon: 'loading', duration: 5500 }) wx.downloadFile({ url: this.data.qrcodepath, success: function (res) { wx.saveImageToPhotosAlbum({ filePath: res.tempFilePath, success: function (res) { wx.hideLoading() wx.showToast({ title: "保存成功", icon: "success", }) }, fail: function (res) { wx.hideLoading() wx.showToast({ title: "保存失败,请点击按钮授权", icon: "none", }) that.setData({ sqshow: true }) } }) }, fail: function () { wx.hideLoading() wx.showToast({ title: "保存失败,请点击按钮授权", icon: "none", }) that.setData({ sqshow: true }) } }) } })