Micro-channel simple applet development process

In early 2017 a small micro-channel low-key official on-line program, users can experience a wide variety of micro-channel services provided.

As the name suggests, it is characterized by the characteristics of the applet: 'Small', i.e. not need to download it can use various services provided by the micro-channel client. This memory is getting enough of the phone, like dew, upon release will fire up. Meanwhile, after more than two years of development, the applet has formed its own unique development environments and developer ecosystem.

Well, that is entered, let us look at the development of small programs What are the steps?

First, prepare

  1. In the micro-channel public platform registered a small program account. Note that since the official micro-channel, micro-channel, applets, public numbers must use a separate mailbox. So, more and more registered mail it.

  2. deploy a server, as a background. And must be used to access https way back.

  3. above are met, to see official documents small program introduced step by step to come.

Second, the development

  1. Authorization

  To facilitate understanding, let us just how small a step by step procedure for authorization to sign in with a logic diagram view of it.

 

 

The above is the login authorization logic I sort of small program, the government has also given the decryption logic applet, as follows,

 

   2. Call back api

   I am a callback using node.js of Promise made, specifically to see the code.

var apiMethod = {
    login: 'login'
};

var request = (api,params) => new Promise((resolve, reject) => {
  log.info(api)
    wx.request({
    url: baseUrl + api,
    data: params,
    header: { 
      'content-type': 'application/json',
      'token':wx.getStorageSync("session_id"),//读取token
      'Sign ' : Sign // signature 
    }, // pass the request's header 
        Success: (RES) => { 
      log.info (RES) 
      Resolve (RES); 
        }, 
        Fail: ERR => { 
      log.info ( " API ERR " ); 
      log.info (ERR); 
            Reject (ERR); 
        } 
    }) 
}) 

var Login = ( the params ) => Request ( 
  apiMethod [ ' Login ' ], the params 
); 

module.exports =  {
    Login
};

  Hey, well, say these bars. Little revealed the secret to say anything, because I was doing the background, the front line and actually written by someone else's code. Specifically upload, review, directory structure, grammar jumps, etc., limited space to see their official development document it.

  Quite a long time to play a small program, the first step in beginning to think about how to get permission? How the next step? It puzzled me for quite a long time. Now that I think is really funny, in fact, all of them written in the document, as long as the next patience to read the official document, is not really all things.

  In addition, Welcome to my personal small program, I love to write, so they both can use in order to experience all the features. But now the individual parts can still drop it.

  

 

 

 

 

Guess you like

Origin www.cnblogs.com/two-bees/p/11769931.html