| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170 |
- var app = getApp();
- // pages/cash/cash.js
- Page({
- data: {
- ooo:'',
- _num:0,
- url: app.globalData.urlImages,
- hiddentap: true,
- hidde: true,
- money:'',
- index:0,
- array:["请选择银行","招商银行","建设银行","农业银行"]
- },
- /**
- * 生命周期函数--监听页面加载
- */
- onLoad:function (opends) {
- app.setBarColor();
- var that = this;
- this.getUserInfo();
- this.getUserExtractBank();
- wx.request({
- url: app.globalData.url + '/routine/auth_api/minmoney?uid=' + app.globalData.uid,
- method: 'POST',
- success: function (res) {
- that.setData({
- minmoney: res.data.msg
- })
- }
- })
- },
- getUserInfo:function(){
- var that = this;
- wx.request({
- url: app.globalData.url + '/routine/auth_api/my?uid=' + app.globalData.uid,
- method: 'POST',
- success: function (res) {
- that.setData({
- money: res.data.data.now_money
- })
- }
- });
- },
- getUserExtractBank:function () {
- var that = this;
- wx.request({
- url: app.globalData.url + '/routine/auth_api/get_user_extract_bank?uid=' + app.globalData.uid,
- method: 'get',
- success: function (res) {
- that.setData({
- array: res.data.data
- });
- }
- });
- },
- cardtap:function(e){
- var flag = this.data.hiddentap;
- if (flag){
- this.setData({
- hiddentap: false
- })
- }else{
- this.setData({
- hiddentap: true
- })
- }
- },
- idnumtap: function (e) {
- this.setData({
- _num: e.target.dataset.idnum,
- hiddentap: true
- })
- if (e.target.dataset.idnum==1){
- this.setData({
- hidde: false
- })
- }else{
- this.setData({
- hidde: true
- })
- }
- },
- maskhide:function(e){
- this.setData({
- hiddentap: true
- })
- },
- bindPickerChange:function(e){
- this.setData({
- index: e.detail.value
- })
- },
- formSubmit:function(e){
- var header = {
- // 'content-type': 'application/x-www-form-urlencoded',
- 'cookie': app.globalData.sessionId//读取cookie
- };
- var that = this;
- var flag = true;
- var warn = "";
- var minmon = that.data.minmoney;
- var mymoney = that.data.money;
- var list={};
- if (that.data.hidde==true){
- list.$name = e.detail.value.name;
- list.cardnum = e.detail.value.cardnum;
- list.bankname = that.data.array[that.data.index];
- list.money = e.detail.value.money;
- list.money = Number(list.money);
- list.extract_type = 'bank';
- if (list.$name == "") {
- warn = "请填写持卡人姓名";
- } else if (list.cardnum == "") {
- warn = "请输入银行卡号";
- } else if (list.bankname == "请选择银行") {
- warn = "请选择银行";
- } else if (list.money < minmon) {
- warn = "请输入正确的金额"
- } else if (list.money > mymoney) {
- warn = "您的余额不足"
- }else {
- flag = false;
- }
- if (flag == true) {
- wx.showModal({
- title: '提示',
- content: warn
- })
- return false;
- }
- } else {
- list.weixin = e.detail.value.weixin;
- list.money = e.detail.value.wmoney;
- list.money = Number(list.money);
- list.extract_type = 'weixin';
- if (list.weixin == "") {
- warn = "请填写微信号";
- } else if (list.money < minmon) {
- warn = "请输入正确的金额"
- } else if (list.money > mymoney) {
- warn = "您的余额不足"
- } else {
- flag = false;
- }
- if (flag == true) {
- wx.showModal({
- title: '提示',
- content: warn
- })
- return false;
- }
- }
- wx.request({
- url: app.globalData.url + '/routine/auth_api/user_extract?uid=' + app.globalData.uid,
- data: { lists: list},
- method: 'POST',
- header: header,
- success: function (res) {
- that.setData({
- money: (that.data.money - list.money).toFixed(2)
- })
- wx.showToast({
- title: res.data.msg,
- icon: 'success',
- duration: 1500
- })
- }
- })
- }
- })
|