Loading…

voting 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, 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 Add voting function to mini program Add voting items and voting options in the background, and users can vote on the mini program # enable module Log in to the "First Step" registration background, left menu --> Factory settings --> Module management Find and enable the following modules, then press F5 to refresh the background interface. You will be able to see all the function menus required for this case: **Voting module** ![](https://dcdn.it120.cc/yuque/0/2019/png/572726/1572849449534-e3d0b7da-48a6-401e-8d2f-323469f1bcfe.png) _Voting items can be imported directly from the "Reservation/Registration" module, so that registration for some activities can be realized --> Voting_ ["Using apifm-wxapi to develop WeChat Mini Program reservation/registration solution"](https://www.yuque.com/apifm/doc/wnrgg0) The background function is relatively simple and the operation is relatively user-friendly. The following mainly introduces the use of the mini program apifm-wxapi: # apifm-wxapi method description ### Voting items ```javascript WXAPI.voteItems(Object object) ``` > Read all voting items. The following methods are all for participating in one of the voting items. > > Please refer to the interface document for specific parameters. > ### Voting details ```javascript WXAPI.voteItemDetail(id) ``` > Detailed data on voting items > > Pull all voting options for the current voting item > > At the same time, the extended attribute data of the current voting item set in the background will also be returned. > ### My vote ```javascript WXAPI.myVote(token, voteId) ``` > View my voting status for the voting item voteId > > If 700 is returned, it means you have not voted yet. This method can be used to determine whether I have voted. > ### I want to vote ```javascript WXAPI.vote(token, voteId, items, remark) ``` > Voting action, specific parameter description: > **voteId** _The above voting item id_ **items** _An array of selected voting options. If you select a single option, it will be one option. If you select multiple options, you will select a few_ **remark** _voting remarks_ ### View voting details ```javascript WXAPI.voteLogs(Object object) ``` > Query the list of all participants and specific voting options for a voting project > > Please refer to the interface document for specific parameters. > **For more detailed parameter usage and more advanced advanced usage methods, please refer to the API interface documentation: ** ["api interface document"](#) _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!