var util = require('../../../utils/util.js'); var api = require('../../../config/api.js'); var user = require('../../../utils/user.js'); var WxParse = require('../../../lib/wxParse/wxParse.js'); var app = getApp(); Page({ data: { userInfo: { nickName: '点击登录', avatarUrl: '/static/images/my.png' }, detail:[], hasLogin: false, myqr_show:false,//我的分享二维码 myqr_url:null, myqr_blur:0//背景模糊值 }, onLoad: function(options) { // 页面初始化 options为页面跳转所带来的参数 }, onReady: function() { }, onShow: function() { //获取用户的登录信息 if (app.globalData.hasLogin) { let userInfo = wx.getStorageSync('userInfo'); this.setData({ userInfo: userInfo, hasLogin: true }); let that = this; util.request(api.DisCommission).then(function(res) { //console.log(res); if (res.errno === 0) { let data=res.data; data.canout=data.total-data.cashout-data.checking; data.canout=that.toFixed(data.canout); that.setData({ detail: data }); } }); } }, toFixed:function (num){ return num.toFixed(2); }, onHide: function() { // 页面隐藏 }, onUnload: function() { // 页面关闭 }, goChild(){ if (this.data.hasLogin) { wx.navigateTo({ url: "/pages/ucenter/parter/child/index" }); } else { wx.navigateTo({ url: "/pages/auth/login/login" }); }; }, goDetail() { if (this.data.hasLogin) { wx.navigateTo({ url: "/pages/ucenter/parter/detail/detail" }); } else { wx.navigateTo({ url: "/pages/auth/login/login" }); }; }, goCashout() { if (this.data.hasLogin) { let m=this.data.detail.total-this.data.detail.cashout-this.data.detail.checking; wx.navigateTo({ url: "/pages/ucenter/parter/cashout/index?m="+m }); } else { wx.navigateTo({ url: "/pages/auth/login/login" }); }; }, goCreateQrcode:function(){//二维码生成 let that=this; util.request(api.QrStarCodeCreate, { path:'/pages/index/index' }, 'POST').then(function(res) { //console.log(res); if(res.errno==0){ that.setData({ myqr_url:res.data.imgUrl, myqr_show:true, myqr_blur:5 }); } }); }, goSaveQrcode:function(){//保存二维码图片 let that=this; console.info(that.data.myqr_url); wx.downloadFile({ url: that.data.myqr_url, success:function(res){ if(res.statusCode===200){ let img=res.tempFilePath; wx.saveImageToPhotosAlbum({ filePath: img, success(res){ that.goCloseMyqr('个人专属二维码图片已保存到您的相册'); }, fail(res){ that.goCloseMyqr('网络或授权问题 图片保存失败 请重试'); } }) } else that.goCloseMyqr('网络或授权问题 图片保存失败 请重试'); }, fail(res){ that.goCloseMyqr('网络或授权问题 图片保存失败 请重试'); } }) }, goCloseMyqr:function(msg){//关闭分享图片的弹层 this.setData({ myqr_blur:0, myqr_show:false }); if(msg){ wx.showToast({ title: msg, icon: 'none', duration: 3000 }) } }, qrtouchstart:function(){ this.setData({ myqr_blur:0, myqr_show:false }); }, goFootprint() { if (this.data.hasLogin) { wx.navigateTo({ url: "/pages/ucenter/footprint/footprint" }); } else { wx.navigateTo({ url: "/pages/auth/login/login" }); }; }, })