// pages/outmoney/outmoney.js Page({ /** * 页面的初始数据 */ data: { outMoney: null, checkPass: false, userInfo: {}, isLogin: false }, outMoney(e) { console.log(e); let outMoney = e.detail.value; this.setData({ outMoney }); if (this.data.userInfo.repaidbalance && outMoney && outMoney >= 0.3 && outMoney <= this.data.userInfo.repaidbalance) { this.setData({ checkPass: true }); } else { this.setData({ checkPass: false }); } }, beginOutMoney(e) { wx.showLoading({ title: '提现中...', mask: true }); let that = this; wx.login({ success(res) { console.log(res); if (res.code) { // 发起网络请求 wx.request({ url: getApp().globalData.postHeadAgreement +'://cdgl.xinyhy.cn/restapi/wechatpay/dopayTransfers', data: { //outTradeNo: new Date().getTime(), //订单号 //totalFee: that.data.chargemoney_select, //钱 totalFee: that.data.outMoney, userId: that.data.userInfo.userId, code: res.code }, header: { 'content-type': 'application/x-www-form-urlencoded;charset=utf-8', }, method: 'POST', success(res1) { wx.hideLoading(); let { data } = res1; if (data && data.code == 200) { wx.navigateBack(); wx.showModal({ showCancel: false, content: '提现成功' }); } else { wx.showModal({ showCancel: false, content: data.msg }); } } }); } else { wx.hideLoading(); console.log('登录失败!' + res.errMsg) } } }) }, /** * 生命周期函数--监听页面加载 */ onLoad: function(options) { }, /** * 生命周期函数--监听页面初次渲染完成 */ onReady: function() { }, /** * 生命周期函数--监听页面显示 */ onShow: function() { let userInfo = wx.getStorageSync('userInfo'); let isLogin = wx.getStorageSync('isLogin'); let that = this; wx.request({ url: getApp().globalData.postHeadAgreement +'://cdgl.xinyhy.cn/restapi/wechat/syncUser', data: { loginName: userInfo.loginName }, method: 'POST', success: function(res) { let { data } = res; if (data.code && data.code != 200) { wx.removeStorageSync('userInfo'); wx.removeStorageSync('isLogin'); let url = '/pages/login/login'; wx.redirectTo({ url, }); } else { that.setData({ userInfo: data, isLogin: true }); wx.setStorageSync('userInfo', data); wx.setStorageSync('isLogin', true); } }, fail(e) { console.log("用户数据同步失败"); } }); }, /** * 生命周期函数--监听页面隐藏 */ onHide: function() { }, /** * 生命周期函数--监听页面卸载 */ onUnload: function() { }, /** * 页面相关事件处理函数--监听用户下拉动作 */ onPullDownRefresh: function() { }, /** * 页面上拉触底事件的处理函数 */ onReachBottom: function() { }, /** * 用户点击右上角分享 */ onShareAppMessage: function() { } })