123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157 |
- // pages/fund/addWithdrawApply.js
- import * as API_WithdrawAccount from '../../api/withdrawAccount'
- import * as API_RebateShop from '../../api/rebateShop'
- import Toast from '../../miniprogram_npm/vant-weapp/toast/toast'
- import * as API_Member from '../../api/member'
- const app=getApp()
- Page({
- /**
- * 页面的初始数据
- */
- data: {
- accounts:[],
- selectedAccount:null,
- rebateShop:{},
- submitForm:{
- apply_money: null,
- apply_remark:''
- },
- member:{}
- },
- /**
- * 生命周期函数--监听页面加载
- */
- onLoad: function (options) {
- this.getRebateAccounts()
- this.getRebateShop()
- this.getMemberDetail(app.globalData.authorInfo.uid)
- },
- /**
- * 生命周期函数--监听页面初次渲染完成
- */
- onReady: function () {
- },
- /**
- * 生命周期函数--监听页面显示
- */
- onShow: function () {
- },
- /**
- * 生命周期函数--监听页面隐藏
- */
- onHide: function () {
- },
- /**
- * 生命周期函数--监听页面卸载
- */
- onUnload: function () {
- },
- /**
- * 页面相关事件处理函数--监听用户下拉动作
- */
- onPullDownRefresh: function () {
- },
- /**
- * 页面上拉触底事件的处理函数
- */
- onReachBottom: function () {
- },
- /**
- * 用户点击右上角分享
- */
- onShareAppMessage: function () {
- },
- getRebateAccounts(){
- let that=this
- API_WithdrawAccount.getListByShopId(app.globalData.sellerShop.shop_id).then(res=>{
- that.setData({
- accounts:[...res]
- })
- })
- },
- onClick(e){
- const { name } = e.currentTarget.dataset;
- this.setData({
- selectedAccount: name,
- })
- },
- getRebateShop(){
- let that=this
- API_RebateShop.getRebateShop(app.globalData.sellerShop.shop_id).then(res=>{
- that.setData({
- rebateShop:{...res}
- })
- })
- },
- submit(){
- let that=this
- if(!that.data.submitForm.apply_money||that.data.submitForm.apply_money===''){
- Toast.fail('请输入提现金额')
- return false
- }
- if(that.data.selectedAccount===null){
- Toast.fail('请选择提现账户')
- return false
- }
- const account=that.data.accounts.find(p=>p.id===that.data.selectedAccount)
- let param = {
- ...that.data.submitForm,
- ...account,
- apply_member_id:account.member_id,
- apply_name:that.data.member.nickname,
- rebate_account_id:account.id
- }
- delete param.id
- console.log(param)
- API_RebateShop.applyWithdraw(param).then(res=>{
- Toast.success({
- type: 'success',
- message: '提交成功',
- duration:2000,
- onClose: () => {
- wx.navigateBack({
- delta: 1,
- })
- },
- })
- }).catch(err=>{
- Toast.fail(err.message)
- })
- },
- onChange(e){
- console.log(e.detail)
- this.setData({
- ['submitForm.apply_money']:Number(e.detail)
- })
- },
- remarkChange(e){
- this.setData({
- ['submitForm.apply_remark']:e.detail
- })
- },
- /** 获取当前登录用户信息 */
- getMemberDetail(id){
- let that=this
- API_Member.getCareMember(id,{}).then(res=>{
- console.log(res)
- that.setData({
- member:{...res}
- })
- })
- }
- })
|