Open other applets in half screen in the applet, half screen in developer tool debugging

Foreword:

        It is necessary that in the current applet, when clicking the operation, if he has not registered as a member, he will be forced to go to another applet to register as a member. After the registration is successful, it will return. During this period, opening another applet is displayed on a half-screen .

Realize the effect:

        In applet a, applet b is displayed half-screen, and the information of applet b is displayed on the top of the half screen. The opened vconsole and the sharing at the bottom are all the contents of applet b.

Implementation steps:

1. Configure the appids of the two applets in the WeChat public account platform

Settings--"Third-party settings--"Half-screen applet management Add your two-party applet

 2. Add in app.json in a applet

        For the basic library version below 2.23.1 , the developer needs to declare the applet that needs half-screen jump in the global configuration field. If not configured, it will switch to the ordinary applet jump applet app.json. From version 2.23.1 and above, no configuration is required .embeddedAppIdList

"embeddedAppIdList": ["wx5e7f6f2293842***", "wxfc028f6cd8075***"],

 3. The configuration of app.json in applet b is the same as that in applet a, and the jump method is:

wx.openEmbeddedMiniProgram({
    // 要跳转的小程序的appid
    appId: 'wxfc028f6cd8075***',
    path: `/pages/index/index?scene=inviteCode%3D1668147166040371201`,
    success: () => {},
    fail: (error) => {
        console.log('跳转小程序失败', error)
    },
    complete: () => {

   }
})

4. Other functions provided by the official

Judging the environment of half-screen applets

        Developers can  read  the parameters by calling  wx.getEnterOptionsSyncapiCategory  . When the value embeddedis , it can be judged that the applet is opened in half screen at this time.

Return to the original applet

 The applet opened in half screen can return to the previous applet         by calling  wx.navigateBackMiniProgram .

Developer tools debugging half-screen effect method:

1. Click the normal compilation of the developer tool, if the new project does not exist, create a new one

 2. Open the applet module, you can see that there are a variety of half-screen options

 3. Select the bottom one is our half-screen effect, the half-screen native is the half-screen bullet box added in our project

 

Precautions for b applet opened in half screen:

  • The b applet must be able to use all responsive units such as rpx, vh, etc. If there are px and px calculated by calc, the height will be abnormal
  • b The ratio of the half screen of the applet is: 665/812  

Official api:

Open half-screen Mini Program | WeChat Open Documentation WeChat Developer Platform Documentation https://developers.weixin.qq.com/miniprogram/dev/framework/open-ability/openEmbeddedMiniProgram.html

Guess you like

Origin blog.csdn.net/qq_41619796/article/details/131187591