SoFunction
Updated on 2025-04-10

Example of method of apicloud pulling up applets and passing parameters

Recently, I encountered a need in my work: App to pull up WeChat applets. The app is developed using APICloud. Check APICloud documentation to find that the terminal API->Open SDK->With the wx module, there is a launchMiniProgram method that can be implementedOfficial Documentation

So add the wx module to the project.

Official sample code:

var wx = ('wx');
({
  apiKey: '', // String, the appid obtained by WeChat open platform, if not transmitted, it will be read from the current widget  miniProgramType: 'test', // String, ['test', 'preview', 'release'] (development version, trial version, official version) default test  userName: '', // String, original ID of applet  path: '', // String, pull up the applet page with parameter path, and pull up the applet homepage without filling in the default applet homepage}, function(ret, err) {
  if () {
    alert('success');
  } else {
    alert();
  }
});

According to the official document configuration, I found that I can only jump to WeChat and cannot pull up the mini program.

apicloud App code:

The configuration of the file applet is as follows:

 <feature name="wx">
  <param name="urlScheme" value="wx1007b2********68"/>
  <param name="apiKey" value="wx1007b2********68"/>
  <param name="apiSecret" value="3******67176****39244b********25"/>
 </feature>

Pull up the applet related code:

function launchMini () {
  var wx = ('wx')
  ({
    // apiKey: '', // I don't know if it's because it has been configured in the configuration file or why, with this parameter, you can only open WeChat, and you cannot pull up the applet. After commenting, you can successfully pull up the applet    miniProgramType: 'preview',
    userName: 'gh_******',
    path: 'pages/index/index?from=app666' // Pass the parameter from the value of app666  }, function(ret, err) {
    if () {
      alert('success')
    } else {
      alert()
    }
  }
}

Mini-program code:

onLoad: function (options) {
  (options)
  () // 'app666'
}

The above is all the content of this article. I hope it will be helpful to everyone's study and I hope everyone will support me more.