Loading…

Withdraw function

# Preface This tutorial is based on the "apifm-wxapi" module and teaches you how to quickly implement small program development, so you may need to understand the following knowledge points first: ["Creating HelloWorld Project"](https://www.yuque.com/apifm/doc/hezlrm) ["Use "apifm-wxapi" to quickly develop small programs"](https://www.yuque.com/apifm/doc/mdldsd) ["Register for free to open the backend and obtain an exclusive domain name"](https://www.yuque.com/apifm/doc/qr6l4m) In this case, the user needs to log in before the operation can be performed, which means token authorization is required. Please understand first: ["WeChat Mini Program login to obtain openid and third-party tokens"](https://www.yuque.com/apifm/doc/kaygbw) To facilitate testing, please log in to the backend first, add available balance to your test users in "User Asset Management", and then you can fully experience the deposit payment process: ["Add a fund module to the existing mini program (view assets, view capital flow)"](https://www.yuque.com/apifm/doc/lhwvwa) # Function introduction 1. The available balance in the user’s mini program account can be withdrawn; 2. The user applies to withdraw part of the available balance on the mini program; 3. Backend financial review, optional manual transfer to users / use WeChat automatic payment interface to send money to users on WeChat; # Enable "User Withdrawal" module Log in to the "First Step" registration background, left menu --> Factory settings --> Module management Find the "User Withdrawal" module, click "Enable Module", then F5 to refresh the background interface, you will see the new menu: "Financial Management" --> "Invoice Management"; ![](https://dcdn.it120.cc/yuque/0/2019/png/572726/1572848320618-90fc14e2-8862-4765-9ea2-331021e84f9f.png) # Mini program interface: ![](https://dcdn.it120.cc/yuque/0/2019/png/572726/1572848320411-8c25c79f-ce0b-4cec-80dd-440ef68a5250.png) ```plain ``` # Mini program code: ```plain const WXAPI = require('apifm-wxapi') WXAPI.init('gooking') Page({ data: { }, onLoad: function (options) { }, onShow: function () { }, goRegist() { wx.navigateTo({ url: '/pages/auth/index' }) }, withDrawLogs() { const loginToken = wx.getStorageSync('loginToken') if (!loginToken) { wx.showToast({ title: 'Please log in first', icon: 'none' }) return } WXAPI.withDrawLogs({ token: loginToken.token }).then(res => { console.log(res) if (res.code == 0) { wx.showToast({ title: 'Read successfully', icon: 'success' }) } else { wx.showToast({ title: res.msg, icon: 'none' }) } }) }, withDrawApply() { const loginToken = wx.getStorageSync('loginToken') if (!loginToken) { wx.showToast({ title: 'Please log in first', icon: 'none' }) return } WXAPI.withDrawApply(loginToken.token, 100).then(res => { console.log(res) if (res.code == 0) { wx.showToast({ title: 'Application successful', icon: 'success' }) } else { wx.showToast({ title: res.msg, icon: 'none' }) } }) }, withDrawDetail() { const withDrawId = 1941 // Record ID in the record const loginToken = wx.getStorageSync('loginToken') if (!loginToken) { wx.showToast({ title: 'Please log in first', icon: 'none' }) return } WXAPI.withDrawDetail(loginToken.token, withDrawId).then(res => { console.log(res) if (res.code == 0) { wx.showToast({ title: 'Read successfully', icon: 'success' }) } else { wx.showToast({ title: res.msg, icon: 'none' }) } }) }, }) ``` > WXAPI.init('gooking') This code links your mini program to your backend, where gooking is your exclusive domain name (please check the chapter about exclusive domain names in the preface); > _You can go to the above "Fund Flow" to view the changes in user fund details caused by the user's application for withdrawal_ _For the paging of the withdrawal record list and the use of more filter conditions, you can view the following interface documents: _ ["api interface document"](#) _No back-end programming is required, as long as you have a good idea, you can quickly implement it! _ Looking forward to your progress! grateful!