Recently, I received a demand that an H5 page needs to open the designated page of wechat applet in wechat internal browser and external browser, and carry parameters. Note: “Specify page”. Wechat internal open small program to specify the page is relatively simple, write the page address can be, the difficult isExternal H5 opens the applets specified page.

First, let’s distinguish between scenarios and requirements

  1. Browser (wechat browser, external browser)
  2. Open applet (home page by default), open applet specified page (with parameters)

It is very simple to open small program or small program specified page in wechat, no technical difficulties, we will not discuss here. Let’s focus on h5 opening applets in external browsers.

I have developed H5 small program to open wechat before. The way is to host the code on the static website of cloud development and realize it in combination with cloud functions. This should be the simplest way to open the small program outside the chain, without authentication, compared to the use of wechat public number in the form of saving time and effort.

Familiar with this kind of French students will know that H5 open small program is relatively simple, the official documentation is still very clear. Developers.weixin.qq.com/miniprogram…

However, if you are new to the cloud function, it will be a little difficult for you to understand. At the beginning, I was also confused about where to put the cloud function and how to put it. After slowly exploring, I knew that I should add the cloud function to the small program development tool. For those of you who are just starting out, look at this document. Follow the steps, it will help. For opening small procedures do not understand the students can ask ha. Developers.weixin.qq.com/miniprogram…

The following to introduce h5 to open small procedures specified page processing.

If you do, try to use a method called Openappellate () to implement appellate apps

C. callfunction is called to the cloud function, and name and data are the parameters passed to the cloud function.

  1. Name is the name of the calling cloud function
  2. Data is the parameter passed to this function, which is customized and used in the cloud function

Next, let’s look at the processing of cloud functions. The annotation part of the two pictures is the key

  • Cloud. Openapi. Urlscheme. Generate is cloud calls for small program scheme code, suitable for SMS, email, external web pages, such as pull a small application within WeChat business scenario.
  • JumpWxa sets the path and parameters of the applet (the parameters are string format)
  • The getUrlScheme method performs the function of opening the applet

See here, is not clear, ha ha, but for the students just want to do but a face meng

Not only do we have to be able to do it, but more importantly, understand how it works, so that we can solve the problem more easily.

I haven’t written an article for a long time. I’m a little strange, but I have a clear mind this time. I hope I can make it clear