var util = require('../../../utils/util.js'); var api = require('../../../config/api.js'); var check = require('../../../utils/check.js'); var app = getApp(); Page({ /** * 页面的初始数据 */ data: { referee: {}, showAuth: true, tipsShow: false, teamText: true, checked: false, tipType: 1, topType: 'blance', //头部显示内容 day: 0 //每月8号 可以提现 }, goList() { wx.navigateTo({ url: '/pages/referee/blance/list/list', }) }, onChange(e) { console.log(e); this.setData({ checked: e.detail, }); }, userProtocol() { wx.navigateTo({ url: '/pages/referee/protocol/protocol' }); }, goCheckAuth() { //是否实名认证过 let day = (new Date()).getDate(); console.log(day); // if(day!=8){ // wx.showModal({ // title: '非提现时间', // showCancel:false, // content: '提现申请时间为每月8号,请按时提现。', // }); // return false; // } let that = this util.request(api.RefereeCashoutAuthCheck, {}).then(function (res) { if (res.errno === 0 && res.data) { that.goCashout(); } else { that.setData({ showAuth: true }) } }) }, goCashout() { //提现申请 let that = this wx.showModal({ title: '提示', content: '提现金额为' + that.data.referee.commissionBlance + ',平台通过授权第三方(“云账户”)向您的微信钱包打款,涉及手续费由引荐人自行承担,故最终提现金额应以实际到账金额为准。', success: function (sm) { if (sm.confirm) { util.request(api.RefereeCashoutApply, { cashout: that.data.referee.commissionBlance }).then(function (res) { if (res.errno === 0) { wx.showToast({ title: '提现申请成功', icon: 'none', duration: 2000 }); that.setData({ showAuth: false }) that.getBlance(); } }); } else if (sm.cancel) { console.log('用户点击取消') } } }) }, goCancel() { this.setData({ showAuth: false }) }, bindinputName(e) { let val = e.detail.value; this.setData({ ['referee.refereeName']: val }); }, bindinputNid(e) { let val = e.detail.value; this.setData({ ['referee.refereeNid']: val }) }, cashoutAuth() { if (this.data.referee.refereeName == '') { wx.showToast({ title: '请输入真实姓名', icon: 'none', duration: 2000 }); return false; } else if (!check.isCardCheck(this.data.referee.refereeNid)) { wx.showToast({ title: '请输入正确的身份证号', icon: 'none', duration: 2000 }); return false; } else if (!this.data.checked) { wx.showToast({ title: '请阅读《用户条款》并勾选', icon: 'none', duration: 2000 }); return false; } util.request(api.RefereeCashoutAuth, { name: this.data.referee.refereeName, nid: this.data.referee.refereeNid, mobile: this.data.referee.refereeMobile }).then(res => { if (res.errno == 0) { this.goCashout(); } }); }, /** * 生命周期函数--监听页面加载 */ onLoad: function (options) { let topType = options.type; //如果不等于blance 则将待结算和余额位置调换 if (topType) { this.setData({ topType: topType }) } var now = new Date(); this.setData({ day: now.getDate() }) console.info(this.data.day) }, /** * 生命周期函数--监听页面初次渲染完成 */ onReady: function () { }, /** * 生命周期函数--监听页面显示 */ onShow: function () { this.getBlance(); }, getBlance() { let that = this; util.request(api.RefereeMyBlance, {}).then(function (res) { if (res.errno === 0) { that.setData({ referee: res.data }); } }); }, showTip1() { this.setData({ tipType: 1, tipsShow: true, }) }, showTip2() { this.setData({ tipType: 2, tipsShow: true, }) }, showTip3() { this.setData({ tipType: 3, tipsShow: true, }) }, onClickHide() { this.setData({ tipsShow: false }) }, /** * 生命周期函数--监听页面隐藏 */ onHide: function () { }, /** * 生命周期函数--监听页面卸载 */ onUnload: function () { }, /** * 页面相关事件处理函数--监听用户下拉动作 */ onPullDownRefresh: function () { }, /** * 页面上拉触底事件的处理函数 */ onReachBottom: function () { }, /** * 用户点击右上角分享 */ onShareAppMessage: function () { } })