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' }) }, tokf(){ console.log('oninfo'); var that = this var url = 'v1/user/info' var params = {} var success = function (res) { let info = res.data; if(info.wx_user.id){ let uurl = encodeURIComponent(`https://tfohowapi.hiwavo.com/h5yingyuchat.html?visitor_id=fohow-${info.wx_user.id}&visitor_name=${info.wx_user.nickname}&avator=${info.wx_user.head}&from=xcx`); console.log("uurl",uurl); wx.navigateTo({ url: '/pages/web/web?id='+uurl }) }else{ wx.showToast({ title: '请先登录' }) } } _request.$get(url, params, success); }, })