123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198 |
- // pages/trans/trans.js
- const app = getApp()
- const link = app.globalData.url
- Page({
- /**
- * 页面的初始数据
- */
- data: {
- openId:"",
- amount:"",
- },
- /**
- * 生命周期函数--监听页面加载
- */
- onLoad: function (options) {
- var that = this
-
- that.openId = wx.getStorageSync('openId')
- console.log(that.openId)
- wx.request( {
- url: link + "/v1/forward/lhf",
- header: {
- "Content-Type": "application/json",
- "function":"/v1/user/trans/list"
- },
- method: "POST",
- data: { openId: that.openId,pidStatus:1,pageIndex:1,pageSize:999 },
- complete: function( res ) {
- console.log(res)
- if( res == null || res.data == null ) {
- console.error( '网络请求失败' );
- return;
- }
-
- that.setData({
- transList: res.data.data.rows,
- })
-
- }
- })
- },
- tixian:function (){
- var that = this
- wx.showModal({
- title: '提现',
- content: '提现金额:'+that.amount,
- showCancel: true,//是否显示取消按钮
- cancelText:"取消",//默认是“取消”
- //cancelColor:'skyblue',//取消文字的颜色
- confirmText:"提现",//默认是“确定”
- //confirmColor: 'skyblue',//确定文字的颜色
- success: function (res) {
- if (res.cancel) {
- //点击取消,默认隐藏弹框
- } else {
- wx.request( {
- url: link + "/v1/forward/lhf",
- header: {
- "Content-Type": "application/json",
- "function":"/v1/user/trans/create"
- },
- method: "POST",
- data: { openId: that.openId,amount:that.amount,pidStatus:1 },
- complete: function( res ) {
- console.log(res)
- if( res == null || res.data == null ) {
- console.error( '网络请求失败' );
- return;
- }
- if (res.data.code == 401){
- wx.navigateTo({
- url:"/pages/pay/pay"
- })
- return
- }
- that.openId = wx.getStorageSync('openId')
- console.log(that.openId)
- wx.request( {
- url: link + "/v1/forward/lhf",
- header: {
- "Content-Type": "application/json",
- "function":"/v1/user/trans/get"
- },
- method: "POST",
- data: { openId: that.openId,pidStatus:1 },
- complete: function( res ) {
- console.log(res)
- if( res == null || res.data == null ) {
- console.error( '网络请求失败' );
- return;
- }
- that.amount = res.data.data.wallet.availableAmount
- that.setData({
- wallet: res.data.data,
- })
-
- }
- })
-
- }
- })
-
- }
- },
- fail: function (res) { },//接口调用失败的回调函数
- complete: function (res) { },//接口调用结束的回调函数(调用成功、失败都会执行)
- })
- },
- /**
- * 生命周期函数--监听页面初次渲染完成
- */
- onReady: function () {
- },
- /**
- * 编辑
- */
- update:function () {
- wx.navigateTo({
- url:"/pages/pay/pay"
- })
- },
- /**
- * 生命周期函数--监听页面显示
- */
- onShow: function () {
- var that = this
-
- that.openId = wx.getStorageSync('openId')
- console.log(that.openId)
- wx.request( {
- url: link + "/v1/forward/lhf",
- header: {
- "Content-Type": "application/json",
- "function":"/v1/user/trans/get"
- },
- method: "POST",
- data: { openId: that.openId,pidStatus:1 },
- complete: function( res ) {
- console.log(res)
- if( res == null || res.data == null ) {
- console.error( '网络请求失败' );
- return;
- }
- that.amount = res.data.data.wallet.availableAmount
- that.setData({
- wallet: res.data.data,
- })
-
- }
- })
- },
- /**
- * 生命周期函数--监听页面隐藏
- */
- onHide: function () {
- },
- /**
- * 生命周期函数--监听页面卸载
- */
- onUnload: function () {
- },
- /**
- * 页面相关事件处理函数--监听用户下拉动作
- */
- onPullDownRefresh: function () {
- },
- /**
- * 页面上拉触底事件的处理函数
- */
- onReachBottom: function () {
- },
- /**
- * 用户点击右上角分享
- */
- onShareAppMessage: function () {
- }
- })
|