当前位置:网站首页>Realize the attention function of the article in the applet
Realize the attention function of the article in the applet
2022-07-05 04:05:00 【Low code preacher】
Catalog
A common scenario in social applets is to focus on functions , In this article, we will focus on the published articles as an example , Explain how to realize the focus function .
1 Data source design
Low code tools are divided into two types: model driven and form driven , Micro build low code is a model driven low code tool . The so-called model driven is to design the data source first , Design the relationship between data sources . Let's analyze what the relationship is , There should be a data source for the article , There is also a data source of concern . The relationship between articles and concerns is one to many , The so-called one to many refers to an article that can be followed by multiple people .
1.1 Article data source
We can design the fields of the article data source , It's the title 、 Release date 、 Content . According to the design, we create data sources and corresponding fields 
1.2 Focus on data sources
Pay attention to the data source. We need to store the data ID of the article and the user's openid
2 Enter test data
After the data source is created, we , First, add some test data to the article table . Click more of data sources , Click management data to enter 

3 Create an
After the data source is created , We can develop small programs . Click Apply on the console , Create a custom application 

Click the blank page to complete the creation of the home page 
We need a detail page to show the details of the article , Click... Next to the page + To complete the creation of the new page 

4 Home page function realization
We first place a data list component on the home page to display our article list , Data source selection article table 
Bind the title of the article to the title field 

Then bind the release date 

Then select the ordinary container with circular display , Bind a click event , Pass in the data ID of the current record 
Jump of event selection platform method , You need to create a new page parameter first 
After the parameter is established, we bind it to the data ID of the current record 


5 Details page function realization
Switch to the details page , We can use block template to realize , Add a content detail block 
We need to define a variable to get the information of the current article , Select the model variable according to the type of variable , Method select query single , And bind our parameter variables 
Bind the title of the article to the title in our variable 

The release date is bound to the release date in the variable 

Bind the body to the contents of our variables 

Change the text of the button to follow 
6 Get the user's openid
As soon as the applet starts, it can get the user's openid, We need to define a global variable to store 
Add getting users in the global life cycle of the low code editor openid Code for 
export default {
async onAppLaunch(launchOpts) {
//console.log('---------> LifeCycle onAppLaunch', launchOpts)
const {
OPENID, FROM_OPENID } = await app.utils.getWXContext()
let userId = FROM_OPENID || OPENID
app.dataset.state.openid = userId
console.log(app.dataset.state.openid)
},
onAppShow(appShowOpts) {
//console.log('---------> LifeCycle onAppShow', appShowOpts)
},
onAppHide() {
//console.log('---------> LifeCycle onAppHide')
},
onAppError(options) {
//console.log('---------> LifeCycle onAppError', options)
},
onAppPageNotFound(options) {
//console.log('---------> LifeCycle onAppPageNotFound', options)
},
onAppUnhandledRejection(options) {
//console.log('---------> LifeCycle onAppUnhandledRejection', options)
}
}
7 Set the low code method of concern
When we click the follow button on the details page , Call the concerned low code method , Logic is the data identification passed into the current variable , Get the user's openid Write to data source
export default async function({
event, data}) {
const result = await app.cloud.callModel({
name:'gz_necsx6t',
methodName:'wedaCreate',
params:{
wzbs:data.target,
openid:app.dataset.state.openid
}
})
$page.widgets.id20.text = " Followed "
}
Then set the click event on the container , Call low code method , Parameter the parameter variable passed into the page 
In this way, the whole is done
8 Release preview
Click the Publish button , Released as a beta , Test it on your phone , You can see that the current concerned data source has written data 
9 summary
This article introduces how to realize the attention function of the article , To realize the attention function, we must first design the data source , Then pass in the correct parameters , Write the data source in the low code method . If it works , Remember the praise. 、 Follow and comment .
边栏推荐
猜你喜欢

Rust blockchain development - signature encryption and private key public key
![[brush questions] BFS topic selection](/img/24/7ec68ef60f94f7b366054824223709.png)
[brush questions] BFS topic selection

Three level linkage demo of uniapp uview u-picker components

Containerd series - detailed explanation of plugins

What is test development? Why do so many companies hire test developers now?

About the recent experience of writing questions

北京程序员的真实一天!!!!!

一文带你了解BI的前世今身与企业数字化转型的关系

DMX parameter exploration of grandma2 onpc 3.1.2.5
![[数组]566. 重塑矩阵-简单](/img/3c/593156f5bde67bd56828106d7bed3c.png)
[数组]566. 重塑矩阵-简单
随机推荐
Containerization Foundation
Behavior perception system
MindFusion.Virtual Keyboard for WPF
Special Edition: spreadjs v15.1 vs spreadjs v15.0
Judge whether the stack order is reasonable according to the stack order
输入的查询SQL语句,是如何执行的?
在线文本行固定长度填充工具
Threejs rendering obj+mtl model source code, 3D factory model
open graph协议
陇原战“疫“2021网络安全大赛 Web EasyJaba
Soul 3: what is interface testing, how to play interface testing, and how to play interface automation testing?
Enterprise level: spire Office for . NET:Platinum|7.7. x
How about programmers' eyesight| Daily anecdotes
provide/inject
EasyCVR平台出现WebRTC协议视频播放不了是什么原因?
反絮凝剂-氨碘肽滴眼液
Phpmailer reported an error: SMTP error: failed to connect to server: (0)
PlasticSCM 企业版Crack
Excuse me, my request is a condition update, but it is blocked in the buffer. In this case, can I only flush the cache every time?
我就一写代码的,王总整天和我谈格局...