var _request = require('../../utils/request.js') Page({ data: { qr: '', popup: false }, onLoad: function (options) { this.getqcode() }, getqcode: function () { var that = this var url = 'v1/customer_service/qrcode' var params = {} var success = function (res) { that.setData({ qr: res.data }) } _request.$get(url, params, success) }, downLoad () { wx.showLoading({ title: '加载中', }) var that = this wx.downloadFile({ url: that.data.qr, success: function(res) { if (res.statusCode === 200) { that.saveImage(res.tempFilePath) } } }) }, saveImage (val) { var that = this wx.saveImageToPhotosAlbum({ filePath: val, success(res) { wx.showToast({ title: '已保存相册', icon: 'success', duration: 2000 }) }, fail (res) { wx.getSetting({ success (res) { if (!res.authSetting['scope.writePhotosAlbum']) { that.setData({ popup: true }) } } }) }, complete () { wx.hideLoading() } }) }, setting () { this.setData({ popup: false }) }, onShareAppMessage: function (val) { return _request.share({ sc: 'xcx_group' }) } })