当前位置:网站首页>0 foundation a literature club low code development member management applet (4)
0 foundation a literature club low code development member management applet (4)
2022-06-24 07:06:00 【Low code preacher】
1 Fourth articles : Member consumption function development
1.1 Last article review
We introduced the development of member recharge record function in the previous article , Add an array field to the data source to save the recharge record information , It also introduces the array operation method of cloud development .
1.2 This paper introduces
In this article, we continue our development , With the member recharge function , Nature needs to have the function of consumption , You can record the consumption amount of members each time , And modify the balance of the members . The development steps are still carried out in our previous order
Modify the data source
Create a page
Develop page functions
Preview release
1.3 Modify the data source
In order to record our consumption information , We need to add the consumption record field to the original member data source , For the type of field, we choose array .
Click the data source management menu , Find the member registration data source we created , Click the title to go to the specific details page
Click the Edit button in the upper right corner of the details page to enter the data source edit mode
Click the add field button on the edit page , New member's consumption record field , The field type is set to array
After the fields are added, we also need to add a custom method , The name of the method is to reduce the balance
The specific code is as follows
module.exports = async function (params, context) {
const newParams = Object.assign({}, params, {
updatedAt: Date.now(),
});
delete newParams.createdAt;
delete newParams._id;
const _ = context.database.command;
console.log(params.account);
let money=-parseInt(params.account)
const result = await context.collection.doc(params._id).update({
account:_.inc(money),
consume:_.push({
money:params.account,
adddate:Date.now()
})
});
return { updated: result.updated };
}
To reduce the balance, we need to take a negative number for the amount of consumption , This accumulation is the difference , For the amount of consumption, we use the push Method is added to the consumption record
The method must be tested after it is added , Otherwise, the subsequent function development will be affected , Click the method test button
In addition, you need to add two parameters to the method , They are the amount of each consumption and the primary key of the current record
You need to record the primary key when testing , How to find it ? First, find the cloud product in the navigation bar , Then click cloud development cloudbase
Enter our low code environment
Find our data source
You can see the primary key information
take id Copy it into our method to test whether the method is correct , Observe whether the results of the database are consistent with our expected results
After seeing the success, click the parameter mapping , Map the result to the output parameter
Click the OK button , In this way, our custom method is created .
1.4 Create a page
After the data source is modified, you need to create a page , The greatest charm of software development is reuse , If you have a similar function, you only need to click the mouse to develop a function .
Actually, the consumption function and recharge function are similar , We just need to copy the previous page . Let's clone the list page first .
Let's modify the page information
Then clone the recharge page
Modify the page information
And then we were in iconfont Download an icon , Modify the third module of the home page for member consumption
Then click the cloud icon of the image component to upload the icon resource and select
Modify the content of the text component for member consumption
We add a jump event to the container component , In order to jump to the member consumption list page when clicking
In addition, the click event on the member consumption list page needs to be changed to the member consumption page , We originally implemented it using a low code approach , Let's still use the low code , Create a new method to jump to the details page
The specific code is as follows :
export default function({event, data}) {
app.navigateTo({
pageId: 'minus', // page Id
params: {memberid: data.target},
});
}
Then change the click event of the list to the new method
After the list page is modified , We need to modify the consumption page , Specifically, modify the title of the page , Method of submission
1.5 Preview release
After the page is modified, we click preview , Live preview , To test whether our function is normal
1.6 The next trailer
In the next article, we will develop the invoice management function , See you next time
边栏推荐
- C语言学生管理系统——可检查用户输入合法性,双向带头循环链表
- Use of SQL join
- 华为云低时延技术的九大绝招
- How to make a website? What should I pay attention to when making a website?
- Surveying and mapping principle of GIS coordinate system: geoid / datum / reference ellipsoid /epsg/sri/wkt
- About Stacked Generalization
- 智能视觉组A4纸识别样例
- Game website making tutorial and correct view of games
- 跳跃游戏II[贪心练习]
- JVM debugging tool -jstack
猜你喜欢

. Net7 miniapi (special part):preview5 optimizes JWT verification (Part 1)
![Command ‘[‘where‘, ‘cl‘]‘ returned non-zero exit status 1.](/img/2c/d04f5dfbacb62de9cf673359791aa9.png)
Command ‘[‘where‘, ‘cl‘]‘ returned non-zero exit status 1.

数据同步工具 DataX 已经正式支持读写 TDengine

C language student management system - can check the legitimacy of user input, two-way leading circular linked list

Mysql开启BINLOG

setInterval里面的函数不能有括号

Application of intelligent reservoir management based on 3D GIS system

潞晨科技获邀加入NVIDIA初创加速计划

机器人迷雾之算力与智能

puzzle(019.1)Hook、Gear
随机推荐
Counter attack of flour dregs: MySQL 66 questions, 20000 words + 50 pictures
leetcode:84. The largest rectangle in the histogram
What is the main function of cloud disk? How to restore deleted pictures
MAUI使用Masa blazor组件库
[problem solving] virtual machine configuration static IP
On BOM and DOM (4): dom0/dom2 event handling analysis
35 year old crisis? It has become a synonym for programmers
浅谈如何运营好小红书账号:利用好长尾词理论
Do you know about Statistics?
Go operation SQLite code error
[Yugong series] June 2022 asp Basic introduction and use of cellreport reporting tool under net core
How long does the domain name filing take and what materials need to be prepared
Internet cafe management system and database
雲監控系統 HertzBeat v1.1.0 發布,一條命令開啟監控之旅!
On BOM and DOM (2): DOM node hierarchy / attributes / Selectors / node relationships / detailed operation
Actual combat | how to deploy flask project using wechat cloud hosting
Jumping game ii[greedy practice]
【问题解决】The connection to the server localhost:8080 was refused
Are internal consultants and external consultants in SAP implementation projects difficult or successful? [English version]
What are the audio formats? Can the audio format be converted