# 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, some functions require the user to log in before they can be operated, 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)
# Function introduction
This function is a supplement to the coupon module and supports randomly generating a set of dynamic passwords (coupon number + password), and then users can use these passwords to redeem coupons;
# Enable coupon module
["WeChat Mini ProgramDemo Coupon Display/Receive/Gift/Password Coupon"](https://www.yuque.com/apifm/doc/elt26d)
# Generate coupon number + password

#Write a small program

```plain```
```javascript
const WXAPI = require('apifm-wxapi')
Page({
data: {
},
onLoad: function (options) {
},
onShow: function () {
},
goRegist() {
wx.navigateTo({
url: '/pages/auth/index'
})
},
bindSave(e) {
const loginToken = wx.getStorageSync('loginToken')
if (!loginToken) {
wx.showToast({
title: 'Please log in first',
icon: 'none'
})
this.goRegist()
return
}
const number = e.detail.value.number;
const pwd = e.detail.value.pwd;
if (!number || !pwd) {
wx.showToast({
title: 'Information not filled in',
icon: 'none'
})
return
}
WXAPI.exchangeCoupons(loginToken.token, number, pwd).then(res => {
console.log(res)
if (res.code == 0) {
wx.showToast({
title: 'Redemption successful',
icon: 'success'
})
} else {
wx.showToast({
title: res.msg,
icon: 'none'
})
}
})
},
})
```
_More usage methods about apifm-wxapi: _
["apifm-wxapi Instructions for Use"](https://github.com/gooking/apifm-wxapi/blob/master/instructions.md)
_Download the Demo code of this case: _
["apifm-wxapi using Demo program"](https://github.com/gooking/apifm-wxapi-demo)
Looking forward to your progress!
grateful!