Loading…

Product group buying/group purchasing 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) The bargaining function in this example requires the support of the product function. How can you bargain without a product, so you must first understand: ["Using apifm-wxapi to develop WeChat Mini Program stores/categories/products/collections"](https://www.yuque.com/apifm/doc/excd2w) # Modules that need to be enabled 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: _The menu in this case is "Marketing Assistance" --> "Group Settings" + "Group Opening Records" + "Group Buying Records"_ 1. Product group buying # Set up price bargaining in the background 1. Edit the product. On the product editing page, there is a drop-down option for "Enable group buying". Please select to open group buying; 2. On the product editing page, set the group purchase price; 3. In the group purchase settings, configure the group purchase information of the product, the number of people in the group, the timeout, and the refund method if the group is not completed. --- ### Get the group configuration of a certain product ```javascript WXAPI.pingtuanSet(goodsId) ``` > Read several important settings for group buying: how many people are in a group, timeout, how to refund if the group fails to form after timeout, etc. > ### Obtain the group configuration of a group of products in batches ```javascript WXAPI.pingtuanSets(goodsIdArray) ``` > In addition to the above method, the group purchase configuration information of multiple products can be read at one time when necessary. > > goodsIdArray is an array of product IDs: [1,2,3,4,5] > ### Start a group purchase [I initiate a group purchase, I am the group leader, let others participate] ```javascript WXAPI.pingtuanOpen(token, goodsId) ``` > After the group is successfully started, the group leader must first place the order and complete the payment before the group is truly successfully started! > > Only open a group, the group leader does not pay. The group purchase information can be seen in the background, but other users cannot see the group purchase. The group leader can only see and participate after completing the payment. > ### Get all the group deals currently in progress for a certain product ```javascript WXAPI.pingtuanList(Object object) ``` > Pull all the current group purchase list data of a certain product to display multiple sets of ongoing/completed group purchase data for the current product. You can also select one of the group purchases to join the purchase so that you can form a group as soon as possible. > > Of course, you can also open a new group buying queue yourself and let others participate. At this time, this method will be able to return more information about the group you just opened. **The group leader must complete the payment before it can be displayed here** > ### Get the list of participating users of a group purchase ```javascript WXAPI.pingtuanJoinUsers(tuanId) ``` > tuanId is the group number in the above example, which is 7380, not 2 > ### Read all group buying records I have participated in ```javascript WXAPI.pingtuanMyJoined(Object object) ``` > Please refer to the interface documentation for specific parameters. > > Used to display in the personal center --> All group purchases I participated in can be paginated. > **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!