| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201 |
- var _request = require('../../../../utils/request.js')
- var util = require('../../../../utils/util.js')
- Page({
- data: {
- page: 1,
- per_page: 20,
- list: [],
- more: true,
- balance: 0,
- confirmDialog:false,
- min_cash:0,
- max_cahs:0,
- fee:0,
- withdraw_num:0,
- view_withdraw:0,
- view_fee:0
- },
- onLoad: function (options) {
- this.getBalanceInfo()
- this.getBalanceList()
- // this.getCashTotal()
- },
- onShow () {
- },
- onReachBottom: function () {
- if (this.data.more) {
- var page = this.data.page + 1
- this.setData({
- page: page
- })
- this.getBalanceList()
- }
- },
- getBalanceInfo () {
- var that = this
- var url = 'v1/user/cash/balance/info'
- var params = {
- }
- var success = function (res) {
- var result = res.data.available
- that.setData({
- balance: result,
- cashTotal: res.data
- })
-
-
- that.getWithDrawlimit()
- }
- _request.$get(url, params, success)
- },
- getBalanceList () {
- var that = this
- var url = 'v1/user/cash/balances'
- var params = {
- page: this.data.page,
- per_page: this.data.per_page
- }
- var success = function (res) {
- var result = that.data.list.concat(res.data.balance_list || [])
- that.setData({
- list: result
- })
- var listMore = res.data.balance_count > that.data.list.length
- that.setData({
- more: listMore
- })
- }
- _request.$get(url, params, success)
- },
- getDetail (val) {
- var id = val.currentTarget.dataset.val
- wx.navigateTo({
- url: '/packageUser/pages/user/cashDetail/cashDetail?id=' + id
- })
- },
- onShareAppMessage: function (val) {
- return _request.share({
- sc: 'xcx_user_radish'
- })
- },
- getCashTotal () {
- var that = this
- var url = 'v1/user/cash/balance/info'
- var params = {
- }
- var success = function (res) {
- console.log('res.data',res.data)
- that.setData({
- cashTotal: res.data
- })
- }
- _request.$get(url, params, success)
- },
- getWithDrawlimit () {
- var that = this
- var url = 'v1/user/takecash/limit'
- var params = {}
- var success = function (res) {
- var withdrawnum = that.data.balance > res.data.max_limit_cash ? res.data.max_limit_cash:that.data.balance;
- that.setData({
- min_cash: res.data.min_limit_cash,
- max_cash: res.data.max_limit_cash,
- fee:res.data.fee_bl ? res.data.fee_bl : 0,
- withdraw_num: withdrawnum,
- view_withdraw:parseFloat(withdrawnum/100).toFixed(2),
- view_fee:parseFloat(withdrawnum * (res.data.fee_bl?res.data.fee_bl/100:0)/100).toFixed(2)
- })
- }
- _request.$get(url, params, success)
- },
- goWithdrawClick () {
- wx.navigateTo({
- url: '/packageUser/pages/user/withdraw/withdraw'
- })
- },
- getBankInfoAndTip(){
- var that = this
- // var url = 'v1/user/get_bank_info'
- // var params = {
- // }
- // var success = function (res) {
- // that.setData({
- // has_bank:res.data.has_bank
- // })
-
- // if(that.data.has_bank){
- that.data.confirmDialog = !that.data.confirmDialog
- if (that.data.withdraw_num > that.data.min_cash) {
- that.setData({
- confirmDialog: that.data.confirmDialog
- })
- } else {
- wx.showToast({
- title: '单次提现金额范围,大于'+parseFloat(that.data.min_cash/100).toFixed(2) +'元 单次最高'+parseFloat(that.data.max_cash/100).toFixed(2) +'元',
- icon: 'none',
- duration: 2000
- })
- }
- // }else{
- // wx.showToast({
- // title: '提现请先绑定银行卡~',
- // icon: 'none',
- // duration: 2000
- // })
- // setTimeout(function(){
- // wx.navigateTo({
- // url: '/packageUser/pages/user/bankinfo/bankinfo'
- // })
- // },1000)
- // }
- // }
- // _request.$get(url, params, success)
- },
- confrimClick () {
- var that = this
- console.log('that.data.has_bank',that.data.has_bank)
- // if (that.data.has_bank) {
- that.withdrawClick()
- // } else {
- // that.setData({
- // confirmDialog: false,
- // identityDialog: true
- // })
- // }
- },
- closedDialog () {
- var that = this
- that.setData({
- confirmDialog: false
- })
- },
- withdrawClick () {
- var that = this
- var url = 'v1/user/takecash'
- var params = {
- amount: that.data.withdraw_num
- }
- var success = function (res) {
- if (res.data) {
- that.setData({
- confirmDialog: false
- })
- // that.data.lockWithdraw = false
- wx.showToast({
- title: '提现成功~',
- icon: 'none',
- duration: 2000
- })
- that.getBalanceInfo()
- that.getBalanceList()
- that.getCashTotal()
- that.getWithDrawlimit()
- wx.navigateTo({
- url: '/packageUser/pages/user/withdraw/withdraw'
- })
- }
- }
- _request.$post(url, params, success)
- },
- })
|