From 9d725d20b7473c773c4c41bb81ec0378415c2baa Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=A8=E8=B1=AA?= <781521347@qq.com> Date: Thu, 30 Dec 2021 10:08:04 +0800 Subject: [PATCH] =?UTF-8?q?=E6=8F=90=E4=BA=A4=E4=BB=A3=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- api/http.js | 4 +-- api/user.js | 14 ++++++--- app.js | 6 ++++ pages/user/bindCard/index.js | 53 ++++++++++++++++++++++++++++++++-- pages/user/bindCard/index.wxml | 8 ++--- pages/user/cashOut/index.js | 53 +++++++++++++++++++++++++++++----- pages/user/cashOut/index.wxml | 8 ++--- 7 files changed, 123 insertions(+), 23 deletions(-) diff --git a/api/http.js b/api/http.js index 792be50..1c8f129 100644 --- a/api/http.js +++ b/api/http.js @@ -1,5 +1,5 @@ -const baseURL= 'http://192.168.0.111:8088/api/'; -// const baseURL= "https://www.cyjyyjy.com/api/" +// const baseURL= 'http://192.168.0.111:8088/api/'; +const baseURL= "https://www.cyjyyjy.com/api/" export function $http(methods,url,params){ var header = { 'content-type': 'application/json', diff --git a/api/user.js b/api/user.js index 8e053cb..8250ac6 100644 --- a/api/user.js +++ b/api/user.js @@ -1,8 +1,14 @@ const http = require('./http.js') -//绑定手机号 -export function bingPhone(){ - return http.$http() +//绑定银行卡 +export function bingCard(data){ + return http.$http('post','userBank/saveBankInfo',data) } + +//提现 +export function cash(data){ + return http.$http('post','extract/cash',data) +} + //获取用户信息 export function getUserInfo(){ return http.$http('get','userinfo') @@ -15,7 +21,7 @@ export function saleLeads(data){ // 获取我的团队 export function getMyTeam(){ - return http.$http('post','user/myTeam') + return http.$http('post','extract/cash') } // 积分动态 diff --git a/app.js b/app.js index 5f74709..2a44279 100644 --- a/app.js +++ b/app.js @@ -44,6 +44,12 @@ App({ }) }) }, + alertMessage(msg){ + wx.showToast({ + title: msg, + icon: 'none' + }) +}, globalData: { http: http.$http, products: [] diff --git a/pages/user/bindCard/index.js b/pages/user/bindCard/index.js index e3ab625..826513f 100644 --- a/pages/user/bindCard/index.js +++ b/pages/user/bindCard/index.js @@ -1,11 +1,17 @@ // pages/user/bindCard/index.js +const app = getApp() +const user = require('../../../api/user.js') Page({ /** * 页面的初始数据 */ data: { - + form: { + name: '', + card: '', + bank: '' + } }, /** @@ -14,7 +20,50 @@ Page({ onLoad: function (options) { }, - + inpChange(e){ + let t= e.currentTarget.dataset.type + switch (t){ + case 'name': + this.setData({ + 'form.name': e.detail.value + }) + break + case 'card': + this.setData({ + 'form.card': e.detail.value + }) + break + case 'bank': + this.setData({ + 'form.bank': e.detail.value + }) + break + } + }, + submit(){ + console.log(this.data.form) + if(this.data.form.name == '' ){ + return app.alertMessage('请输入持卡人姓名') + } else if(this.data.form.card == ''){ + return app.alertMessage('请输入银行卡号') + } else if(this.data.form.bank == ''){ + return app.alertMessage('请输入开户行') + } + user.bingCard({ + bankName: this.data.form.bank, + cardNumber: this.data.form.card, + cardholderName: this.data.form.name + }).then((res)=>{ + wx.showToast({ + title: '绑定成功!', + }) + setTimeout(()=>{ + wx.navigateBack({ + delta: 1, + }) + },1500) + }) + }, /** * 生命周期函数--监听页面初次渲染完成 */ diff --git a/pages/user/bindCard/index.wxml b/pages/user/bindCard/index.wxml index 52650f9..cd091c4 100644 --- a/pages/user/bindCard/index.wxml +++ b/pages/user/bindCard/index.wxml @@ -3,16 +3,16 @@ 持卡人 - + 银行卡号 - + 开户行 - + - 确定 + 确定 diff --git a/pages/user/cashOut/index.js b/pages/user/cashOut/index.js index cdbe294..7519930 100644 --- a/pages/user/cashOut/index.js +++ b/pages/user/cashOut/index.js @@ -1,23 +1,56 @@ // pages/user/cashOut/index.js +const app = getApp() +const user = require('../../../api/user.js') Page({ - /** * 页面的初始数据 */ data: { - brokeragePrice: 0 + userInfo: {}, + cashNum: '' }, /** * 生命周期函数--监听页面加载 */ onLoad: function (options) { - console.log(options) + + }, + allCash(){ this.setData({ - brokeragePrice: options.brokeragePrice + cashNum: this.data.brokeragePrice }) }, - + cashChange(e){ + this.setData({ + cashNum: e.detail.value + }) + }, + cashClick(){ + if(this.data.userInfo.userBank){ + if(this.data.cashNum == '' || this.data.cashNum <= 100){ + return app.alertMessage('请输入正确的积分') + } + user.cash({ + extractType: 'bank', + money: this.data.cashNum + }).then((res)=>{ + wx.showToast({ + title: '申请提现成功', + }) + setTimeout(()=>{ + wx.navigateBack({ + delta: 1, + }) + },1500) + }) + } else{ + wx.navigateTo({ + url: '/pages/user/bindCard/index', + }) + } + + }, /** * 生命周期函数--监听页面初次渲染完成 */ @@ -29,9 +62,15 @@ Page({ * 生命周期函数--监听页面显示 */ onShow: function () { - + this.getUserInfo() + }, + getUserInfo(){ + user.getUserInfo().then((res)=> { + this.setData({ + userInfo: res.data.data + }) + }) }, - /** * 生命周期函数--监听页面隐藏 */ diff --git a/pages/user/cashOut/index.wxml b/pages/user/cashOut/index.wxml index d389275..6ff945f 100644 --- a/pages/user/cashOut/index.wxml +++ b/pages/user/cashOut/index.wxml @@ -4,7 +4,7 @@ 当前可提现积分(积分比例为1:1) - {{brokeragePrice || 0}} + {{userInfo.brokeragePrice || 0}} 注:提现需在每月20-26日进行,其他时间不可提现 @@ -12,9 +12,9 @@ 提现金额 - - 全部提现 + + 全部提现 - 提现 + 提现