Getting Started with Node.js WeChat Official Account Development

Setting up a server: WeChat Official Account development requires a server to receive and process messages. I recommend applying for a free cloud server from Tencent Cloud, click here to apply, available at 9:30 AM daily. I chose Ubuntu as the server image. For how to set up a Node environment on the server, refer to my other blog post Using Linux for Web Frontend Development. The principle of Official Account development is to set up a receiving interface; once developer mode is enabled, WeChat’s server will forward messages to this interface.

Read more

Node.js Development Guide - Book Notes

Chapter 3

  1. Single Loading:

    require does not load modules repeatedly. No matter how many times require is called, the module obtained is always the same one.

  2. Overriding exports:

    When encapsulating an object into a module, using exports.Hello = Hello requires require(‘./singleobject’).Hello to obtain the object. This can be simplified as follows: module.exports = Hello; Then you can directly obtain the object: var Hello = require(‘./hello’); hello = new Hello();

  3. Creating Global Links:

    npm link express; This allows you to use the globally installed express in the current directory.

  4. Use npm init to interactively initialize a standard package.json;
    Publish a package: npm publish;
    After modifying the version field in the json file, republish to update the version;
    Unpublish: npm unpublish;

Read more

Schema and Download Bar

Since our company had a website without a corresponding mobile version, we needed to display a download bar at the bottom when the website is accessed from a mobile device. Clicking the download bar needed to meet the following two requirements:

  1. If the app is already installed on the device, attempt to open the corresponding app;
  2. If the app is not installed on the device, redirect to the download page for the corresponding operating system.
Read more

16-Grid Drag and Drop

Implement a 16-grid page as shown below, where each numbered box can be dragged and swapped with another. The horizontal and vertical header bars ABC and XYZ allow pairwise swapping of positions, causing entire columns (or rows) to swap together.

Read more

Notes on JavaScript: The Definitive Guide

  1. When the JavaScript interpreter starts, it creates a new global object and gives it a set of defined initial properties.
  2. Whenever a property of a string literal is referenced, the string value is converted to an object by calling new String(), and once the reference ends, this temporary object is destroyed.
  3. The “==” operator treats primitive values and their wrapper objects as equal, while “===” does not.
  4. Primitive values are immutable; object references are mutable.
  5. undefined converted to number:

    NaN, while null converted to number: 0, empty string converts to 0 and false.

Read more