The first three chapters of the series are interface design, which respectively write how to build the front page, answer page and answer result page of the answer mini program.

Now enter the functional interaction section, which is the second chapter of the functional interaction section to realize the function of forwarding and sharing answer scores.

Software architecture: wechat native small program + cloud development

Poke source code address, get source code, version continuous iteration…

Project renderings

So, to achieve the forwarding and sharing of answer scores function? It’s very simple. Don’t be intimidated by the dense apis in the documentation.

Remember, you don’t need to read through the document. I’m going to give you a tip called “The Document search technique — Look for what you need.” Hand in hand to teach white to learn how to develop a small program to look up documents.

The official document of wechat small program provides the API of forwarding and sharing, which is:

OnShareAppMessage (Object Object), note: Only if this event handler is defined, will the “Forward” button be displayed in the upper-right menu.

We can clearly see the configuration items, which are optional.

Here, we can do as simple as we want, just configure a title.

Project sample code

.js file Page({onShareAppMessage(res) {return {title: '@ you, come to participate in the fire safety knowledge answer activity ~'}},})Copy the code

Look, this has realized the function of forwarding and sharing answer scores. With such a small section of code, it is easy to realize the forwarding and sharing function of the small program.

But this is a very important feature, and the ability to retweet and share is crucial to running a small application. Don’t we often see keywords in operations? “User growth: fission, conversion is the key”, “new, conversion”.

These are not based on forwarding and sharing to friends, groups, or Posting moments to spread, is the so-called realization of closed loop traffic, traffic cycle.