123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304 |
- var app = getApp();
- var util = require('../../utils/util.js');
- Page({
- mixins: [require('../../mixin/commonMixin.js')],
- /**
- * 页面的初始数据
- */
- data: {
- type: 1,
- items: [{
- name: '1',
- value: '系统余额',
- show: true,
- checked: false
- },
- {
- name: '2',
- value: '微信零钱',
- show: true,
- checked: false
- },
- {
- name: '3',
- value: '支付宝',
- show: true,
- checked: false
- },
- {
- name: '4',
- value: '银行卡',
- show: true,
- checked: false
- }
- ],
- info: [],
- tixian_money: '',
- final_money: 0
- },
- canTixian: true,
- /**
- * 生命周期函数--监听页面加载
- */
- onLoad: function(options) {
- wx.showLoading();
- this.getData();
- },
- onShow: function() {
- let that = this;
- util.check_login_new().then((res) => {
- if (res) {
- that.setData({
- needAuth: false
- })
- } else {
- that.setData({
- needAuth: true
- })
- }
- })
- },
- /**
- * 授权成功回调
- */
- authSuccess: function() {
- let that = this;
- this.setData({
- needAuth: false
- }, () => {
- wx.showLoading();
- that.getData();
- })
- },
- getData: function() {
- var token = wx.getStorageSync('token');
- let that = this;
- app.util.request({
- url: 'entry/wxapp/user',
- data: {
- controller: 'groupdo.get_commission_info',
- token: token
- },
- dataType: 'json',
- success: function(res) {
- wx.hideLoading();
- if (res.data.code == 0) {
- let commiss_tixian_publish = res.data.data.commiss_tixian_publish;
- let items = that.data.items;
- let rdata = res.data.data;
- if (rdata.commiss_tixianway_yuer == 0) items[0].show = false;
- if (rdata.commiss_tixianway_weixin == 0) items[1].show = false;
- if (rdata.commiss_tixianway_alipay == 0) items[2].show = false;
- if (rdata.commiss_tixianway_bank == 0) items[3].show = false;
- let type = that.data.type;
- for (let i = 0; i < items.length; i++) {
- if (items[i].show) {
- items[i].checked = true;
- type = items[i].name;
- break
- }
- }
- that.setData({
- info: res.data.data,
- items,
- type,
- commiss_tixian_publish
- })
- } else {
- wx.showModal({
- title: '提示',
- content: res.data.msg,
- showCancel: false,
- success(res) {
- if (res.confirm) {
- console.log('用户点击确定')
- wx.reLaunch({
- url: '/lionfish_comshop/pages/user/me',
- })
- }
- }
- })
- }
- }
- })
- },
- formSubmit: function(e) {
- const params = e.detail.value;
- let isNull = 0;
- let type = this.data.type;
- let errortip = [{}, {}, {
- bankusername: '微信真实姓名'
- }, {
- bankusername: '支付宝真实姓名',
- bankaccount: '支付宝账户'
- }, {
- bankname: '银行卡名称',
- bankusername: '持卡人姓名',
- bankaccount: '银行卡账户'
- }];
- for (let item in params) {
- params[item] = params[item].replace(/(^\s*)|(\s*$)/g, "");
- if (!params[item]) {
- const itemTip = errortip[type][item];
- wx.showToast({
- title: '请输入' + (itemTip || '正确的表单内容'),
- icon: 'none'
- })
- isNull = 1;
- break;
- }
- if (item == 'money' && params[item] * 1 <= 0) {
- wx.showToast({
- title: '请输入正确的金额',
- icon: 'none'
- })
- return;
- }
- }
- if (isNull == 1) return;
- params.type = this.data.type;
- console.log(params);
- let tdata = this.data;
- let tixian_money = parseFloat(tdata.tixian_money);
- let max_tixian_money = tdata.info.money;
- let community_min_money = parseFloat(tdata.info.commiss_min_tixian_money);
- if (tixian_money == '' || community_min_money > tixian_money) {
- wx.showToast({
- title: '最小提现' + community_min_money + '元',
- icon: "none",
- })
- return false;
- }
- if (tixian_money > max_tixian_money) {
- wx.showToast({
- title: '本次最大可提现' + max_tixian_money + '元',
- icon: "none",
- })
- let fee = tdata.info.commiss_tixian_bili;
- let final_money = (max_tixian_money * (100 - fee) / 100).toFixed(2);
- this.setData({
- tixian_money: max_tixian_money,
- final_money: final_money
- })
- return false;
- }
- if (!this.canTixian) return;
- this.canTixian = false;
- wx.showLoading();
- var token = wx.getStorageSync('token');
- let that = this;
- app.util.request({
- url: 'entry/wxapp/user',
- data: {
- controller: 'groupdo.tixian_sub',
- token: token,
- ...params
- },
- dataType: 'json',
- success: function(res) {
- wx.hideLoading();
- if (res.data.code == 0) {
- wx.showToast({
- title: '已提交申请',
- icon: 'none',
- duration: 2000,
- success: function () {
- that.setData({
- canPay: false,
- tixian_money: '',
- final_money: 0
- })
- that.getData();
- }
- })
- } else {
- wx.showToast({
- title: res.data.msg ? res.data.msg : '提交失败,请重试',
- icon: 'none'
- })
- }
- }
- })
- },
- /**
- * 获得焦点
- */
- bindIptFocus: function() {
- this.setData({
- onFocus: true
- })
- },
- /**
- * 失去焦点
- */
- bindIptBlur: function() {
- this.setData({
- onFocus: false
- })
- },
- radioChange(e) {
- this.setData({
- type: e.detail.value
- })
- },
- bindTixianMoneyInput: function(t) {
- let max_val = this.data.info.money;
- var value = t.detail.value;
- if (!(/^(\d?)+(\.\d{0,2})?$/.test(value))) {
- value = value.substring(0, value.length - 1);
- value = parseFloat(value);
- }
- if (value > max_val) {
- wx.showToast({
- title: '本次最大可提现' + max_val + '元',
- icon: "none",
- })
- }
- let fee = this.data.info.commiss_tixian_bili;
- let final_money = (value * (100 - fee) / 100).toFixed(2);
- let canPay = false;
- value ? canPay = true : canPay = false;
- this.setData({
- tixian_money: value,
- final_money: final_money,
- canPay
- })
- return value;
- },
- getAll: function() {
- const tdata = this.data;
- var max_tixian_money = tdata.info.money * 1;
- let fee = tdata.info.commiss_tixian_bili;
- let final_money = (max_tixian_money * (100 - fee) / 100).toFixed(2);
- let canPay = false;
- max_tixian_money ? canPay = true : canPay = false;
- this.setData({
- tixian_money: max_tixian_money,
- final_money: final_money,
- canPay
- })
- }
- })
|