One, foreword

Like every drop of wine can not return to the original grape, I can not return to young. Love is the same, this is the original intention of writing a small program, used to record me and her most beautiful love. What is the most beautiful relationship? Is busy after a letter, together with the goal of struggle, wonderful moments, travel footprint, and that countless anniversaries.

Without further ado, let’s take a look at your first impression of the applet. (The screenshot is the experience version, some functions of the online version are not on oh)

She liked the simplicity of the page.

Second, talk about code

1. The framework

The front end of the small program is written with the Taro framework, the background with cloud development (is a personal developer’s Gospel). Post the overall architecture:

Other architectures, pages and so on are very common. I will specifically say cloud function calls, mainly for database operations:

Cloud function entry (using TcbRouter to call different methods) :

The applet side is called like this:

Call method arguments:

  let param = {
      method:'get',
      collection:'mail',
      id:auth.user._id,
      bindId:auth.user.bindId,
      start:this.start,
      limit:PAGE.LIMIT
    };

    let res = await commonApi.list(param);
Copy the code

Three, talk about functions

Mainly, let’s talk about the function of mailbox. After all, there are fewer and fewer people writing letters now. Here, the process of writing letters can be restored to a large extent. I’ve had so many letters. What about you?

There is also a message board function, she said and wechat chat what difference (difference lies in the absence of websocket), here not to repeat.

Four, conclusion

Tanabata has arrived, fast and dear people bind the most beautiful love relationship! Here, you are the directors, recording love. Special note: this small program, I personally wrote for my girlfriend, thank her for providing demand support, happy Tanabata.

❤️ small egg ❤️

Use small program · Cloud development to follow the following four steps to view the surprise egg ~

In the CloudFuntions folder, right click to create a new cloud function love and deploy the upload.

exports.main = async (event, context) => {
  return {
    timelimit: 10000,}}Copy the code

Use developer tools to create an applet page love and type the following code in love. WXML

<view>You ask me how long I love you?</view>
<image bindtap="loveFunction" src="{{loveurl}}"></image>
<view wx:if="{{timelimit}}">
  <view><text>I love you {{timelimit}} years</text></view>
  <view><text>Cloud development wish all programmers on Chinese Valentine's Day</text></view>  
</view>
Copy the code

Type in love.js:

  data: {
    timelimit:' '.loveurl:"https://tcb-1251009918.cos.ap-guangzhou.myqcloud.com/love.png",
  },

  loveFunction() {
    wx.cloud.callFunction({
      name: 'love'.data: {},success: res= > {
        this.setData({
          timelimit: JSON.stringify(res.result.timelimit)
        })
      }
    })
  },
Copy the code

Type in love-.wxss:

view{text-align: center;margin: 20px 0;font-weight: bold; }text{color: #FFC0CB; }image{width: 100rpx;height: 100rpx}
button{background-color: #FFC0CB;color:#fff;width: 300rpx}
Copy the code

Source link

Github.com/TencentClou…


If you have a technical story about using cloud to develop CloudBase, please feel free to leave a comment and contact us.