Getting Started Tutorial for WeChat Cloud Development Management Tools

foreword

What is WeChat Cloud Development Management Tool?
Provides a set of background management tools for cloud development and low-code development tools. Developers can connect to business databases based on low-code tools, drag and drop components to generate front-end UIs, and customize various management applications.

Some students here will definitely ask what is the difference between it and cloud development content management CMS ?
It can be understood as more flexible and customizable content management, which is easier and more flexible to use when combined with the micro-build.
If you don’t know about micro-build, you can read the low-code platform micro-build tutorial I wrote before.

to experience

At present, the WeChat cloud development management tool is still in internal testing. If you need to apply for internal testing permissions, click here to apply for the entrance

Open the homepage

When we successfully opened the permissions

  1. Download/update the latest version of WeChat developer tools
  2. Enter the cloud development IDE console

87698202307271411424067.png

3. Select "Management Tools" in "More"

da989202307271411598452.png

4. After opening, it will prompt whether to open the micro-build low-code plug-in prompt, select "Allow"

4dc8e202307271412176926.png

template experience

From this step, you have officially entered the management tool. The first thing you can see is the template page. Currently, commonly used templates have been built in. You need to click "View/Install Tools" for the template.

This makes me feel that this is like an App market on a mobile phone system. You can install whatever you need. As long as there are enough templates, developers can improve a lot of efficiency and development costs can be greatly improved. If this template market can support developers to access and release, similar to how App developers can freely publish App market, and can also make paid templates, then there is still a lot of room for imagination.

5a7b1202307271412349216.png

I first choose a carousel image to manage and test the effect.

23a06202307271412463408.png

Tip: The first loading will be slow, you need to wait patiently

After the installation is successful, you can get the management background address and administrator account password

f833c20230727141257147.png

Copy the link and enter the account password to enter the background management

8f8b9202307271413091674.png

There is a simple banner in the management background. The management background case data
menus are: carousel image management, carousel image management

04600202307271413223400.png

If you need to customize the carousel, you need to upload pictures now in picture management

010f2202307271413313301.png

Then go to the carousel map management to add

4d8ce202307271413407210.png

So how does the applet get the data? We can go back to the cloud development IDE console and see that there is an additional table cloudbase-sample-banner in the database, which contains three pieces of data

cfa9f202307271413507071.png

Applet to get data code

wx.cloud
      .database()
      .collection("cloudbase-sample-banner")
      .where({
        status: "online",
      })
      .get({
        success: (res) => {
          this.setData({
            banner: res.data,
          });
        },
      });

Copy

edit template

So what if the carousel image template cannot meet our needs?
For example: the carousel map needs to be clicked to jump to display the official account articles. At this time, the article path field needs to be added.
Based on the above requirements, let’s modify it. First, return to the management tool home page

53721202307271414071066.png

Click on the carousel image template to view the details, and select the "Edit Tool" at the bottom

20917202307271414175696.png

Here you can perform "page design" on the management page

ba7fe202307271414285659.png

The display of data on all pages is of course inseparable from the data. The second menu is "Data Source"

9e165202307271414391925.png

The remaining two menus are: material and application settings. These two menus are relatively simple and will not be introduced too much.

To add a new field, you need to find "Add Carousel" in "Data Source" and click "Edit"

8585a202307271414502698.png

Add an input parameter, the path parameter represents the path of the article (the operation of editing carousel information is similar)

16ee1202307271414592639.png

Then modify the code and add the attribute path to the place where the parameters are obtained and added

d06ac202307271415095574.png

Finally, click "Method Test" to add a piece of data to see the effect

e353e20230727141518294.png

You can see that the data has been added successfully through the background management page or the cloud development IDE database

1e479202307271415285025.png

4445d202307271415348132.png

The adding method has been modified, and the next step is to modify the query method, select "Query Carousel List" and then add a subset in "Output Parameters". Because the query data is multiple, it is an array, and what we want to query and display is the data object inside. (The operation of querying carousel map information is similar, the difference is adding parameters instead of subsets)

a6ade202307271415449251.png

What field is added is what kind of field is displayed

6d41a202307271415539895.png

The data source part is done!
The next step is to modify the background management page "Add" and "Query", switch to the "Page Design" menu and
click "Add Carousel" to see its layout structure A form container contains many components

c7a0e202307271416039725.png

Our article path needs to be input, so we can drag a single-line input component from the top into the layout

4eb63202307271416128464.png

Then modify the display title and binding fields

30f59202307271416284785.png

When we finish editing, we can click "Preview" in the upper right corner and then click "Live Preview"

612b2202307271416386076.png

In this way, a separate window can be opened for functional testing. After the addition and modification are completed, we will modify the "List Display", select the "Data Table" component and add the path in the "Column Management"

ca8bd202307271416494979.png

List display effect

1b82c202307271416583251.png

After the modification is completed, you need to click "Publish" in the upper right corner to synchronize the online version background.

custom template

Another situation is that the current template cannot meet the business needs. For example, the following "cloud database management" template can only display json for general purpose, and the query cannot be fuzzy, so it needs to be customized at this time.

334ff202307271417075409.png

Next, we will make an activity list display by ourselves, and then make a fuzzy query. This requirement can be said to be the most commonly used operation.

access data

We add a query activity list page based on the "Cloud Database Management" template, first switch to "Data Source" and click the + sign to select "Custom Code"

333f3202307271417178913.png

Enter a name and ID and click Create

21bfc202307271417253106.png

add method

008e020230727141734823.png

Query code, other operations can be found in cloudbase node sdk documentation

const cloudbase = require("@cloudbase/node-sdk");

const envId = "<云开发环境ID>";
const collectionName = "<云数据库集合名>";

const app = cloudbase.init({
  env: envId,
});

const db = app.database();

module.exports = async (event, context) => {
  let { pageNo, pageSize } = event;
  if (pageNo < 1) pageNo = 1;

  // 查询条件先固定为空,即查询集合内的所有数据
  const query = db.collection(collectionName).where({});

  const recordsRes = await query
    .skip((pageNo - 1) * pageSize)
    .limit(pageSize)
    .get();
  const totalRes = await query.count();

  return {
    records: recordsRes.data,
    total: totalRes.total,
  };
};

Copy

Input parameter configuration: pageSize, pageNo
Output parameter configuration: use "method test" to run the test and then use the output parameter mapping

f92b4202307271417496443.png

Data Display

Switch to "Page Design" and click the + sign in the upper right corner

e23af202307271417599258.png

Drag and drop a data table component into the layout

c0a94202307271418091536.png

Set data table data source

404c4202307271418328236.png

The data in the list is displayed, but we will find that the time field is repeated, and the header is the field name, which users may not be able to understand.

d6d4720230727141842947.png

We can delete unnecessary fields in the attribute column management

1c10c202307271418543307.png

You can also modify the attribute title, the effect is as follows:

d7585202307271419069790.png

suggestion

1. Templates need to be richer to meet more developer scenarios.
2. Self-contained template business thinking is not comprehensive enough, too simple to be direct.
3. Custom template operations are too complicated and need to be simplified, such as: automatically generate basic additions, deletions, query and modification codes

Related Tutorials

Official Cloud Development Management Tool Tutorial
Cloud Development Node.js SDK API
Micro-build Component List

Guess you like

Origin blog.csdn.net/weixin_64051447/article/details/131965261