URL Scheme 生成

登录
普通链接生成
中转跳转生成
功能说明:
生成一个指向“跳板小程序”的链接,参数中携带目标小程序信息。
需在“跳板小程序”的对应页面接收参数并调用 wx.navigateToMiniProgram 实现跳转。
该页面需编写 JS 代码处理跳转逻辑
⚠️ 关键步骤:请将以下代码添加到您的跳板小程序页面 JS 中
// 文件路径: pages/index/index.js
Page({
  onLoad(options) {
    // 1. 接收中转参数
    const targetAppId = options.target_appid;
    const targetPath = options.target_path ? decodeURIComponent(options.target_path) : '';
    const targetQuery = options.target_query ? decodeURIComponent(options.target_query) : '';

    // 2. 拼接完整路径 (如果包含 query)
    let finalPath = targetPath;
    if (targetQuery) {
        finalPath += (finalPath.includes('?') ? '&' : '?') + targetQuery;
    }

    // 3. 执行跳转
    if (targetAppId) {
      wx.navigateToMiniProgram({
        appId: targetAppId,
        path: finalPath,
        success(res) {
          console.log('跳转成功');
        },
        fail(err) {
          console.error('跳转失败', err);
          wx.showModal({
            title: '跳转失败',
            content: '无法打开目标小程序,请重试',
            showCancel: false
          });
        }
      });
    }
  }
})
                
生成的 URL Scheme:
注意: 1. 普通模式:请确保所选小程序的“明文 Scheme 拉起此小程序”开关已在微信后台开启。 2. 中转模式:生成的链接是加密 Scheme(推荐),因为可以携带较长参数且无需目标小程序开启明文。