Loading…

Read parameter configuration

# 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) # Requirements description Configure some parameters in the background (text parameters, switch values, file download addresses, etc.); The applet can directly read these configurations; Later, as long as the background parameters are changed, there is no need to modify the applet code, and the latest configuration data can be automatically read; # budget 0 yuan, free implementation # Requirements realization ### Enable system parameter setting module Log in to the "First Step" registration background, left menu --> Factory settings --> Module management Find the "System Parameter Settings" module, click "Enable Module", then F5 to refresh the background interface, you will see the new menu: "System Settings" --> "System Parameters"; ### Write small program code: ##### Can read the current background level ```plain const WXAPI = require('apifm-wxapi') WXAPI.init('gooking') Page({ data: { }, onLoad: function (options) { // Read the type of current backend (free backend, professional version, value-added version) WXAPI.vipLevel().then(res => { console.log('Merchant type:', res) }) } }) ``` > 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); > Value of _res.data: 0 = Free backend; 1= Professional version; 2= Value-added version_ ##### Read a single system parameter ```plain const WXAPI = require('apifm-wxapi') WXAPI.init('gooking') Page({ data: { }, onLoad: function (options) { //Read a single system parameter WXAPI.queryConfigValue('test1').then(res => { console.log('Parameters read:', res) }) } }) ``` > 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); > **Screenshot of background parameter settings** ![](https://dcdn.it120.cc/yuque/0/2019/png/572726/1572848000538-a65ea9ae-c837-4ac3-afce-337e11fb8eda.png) ##### Read multiple system parameters in batches ```plain const WXAPI = require('apifm-wxapi') WXAPI.init('gooking') Page({ data: { }, onLoad: function (options) { //Read a single system parameter WXAPI.queryConfigBatch('test1,test').then(res => { console.log('Parameters read:', res) }) } }) ``` > 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); > _Multiple parameter numbers to be obtained can be easily separated in English_ _The batch reading method reads an array of multiple system parameter configurations, and you can process it according to specific needs_ Looking forward to your progress! grateful!