1***@163.com
1***@163.com
  • 发布:2023-09-20 11:36
  • 更新:2023-09-20 11:36
  • 阅读:202

【分享】飞书跳转其他小程序

分类:uni-app

在uniapp开发过程中遇到需要跳转其他小程序并携带参数的需求
uniapp的官方API为:

uni.navigateToMiniProgram({  
    appId: appId,  
    path: 'pages/index',  
    extraData: {  
      token: token  
    },  
    fail(res) {  
      uni.showToast({  
        title: '跳转失败:' + res,  
        icon: 'none'  
      })  
    }  
  })

但是该API在飞书平台IOS系统中跳转失败并报错:navigateToMiniProgram:fail feature is not supported in app.
查阅飞书文档,利用uniapp差异性编译特性编写飞书跳转js

const uriPath = 'pages/index?token=' + token  
      tt.openSchema({  
        schema:  
          'https://applink.feishu.cn/client/mini_program/open?appId=' +  
          appId +  
          '&relaunch=true&path=' +  
          encodeURIComponent(uriPath), //path需要encode编译  
        external: true,  
        success(res) {  
          console.log(JSON.stringify(res))  
        },  
        fail(res) {  
          uni.showToast({  
            title: '跳转失败:' + res,  
            icon: 'none'  
          })  
        }  
      })

参考文档:https://open.feishu.cn/document/common-capabilities/applink-protocol/supported-protocol/open-a-gadget#7d956a09

1 关注 分享
DCloud_UNI_OttoJi

要回复文章请先登录注册