目录

淘宝小程序跳转外部链接

目录

淘宝小程序跳转外部链接

1.外链为淘宝店铺:

my.tb.navigateToTaobaoPage

此API可以跳转多个:有一个参数为appParams

跳转官方业务页面定义的AppCode。

目前支持:shop(打开店铺页):需在appParams中填入shopId

cardCoupon(打开红包卡券页,9.17.0及以上版本);

orderDetail(打开订单详情页,9.18.0及以上版):需在appParams中填入orderId

orderList(打开订单列表页,9.18.0及以上版本);

liveRoom(打开直播间,9.24.0及以上版本)

注:打开直播间有一个必须条件:店铺账号和小程序挂名账号必须是同一个账号下,才能直接跳转到直播间

my.tb.navigateToTaobaoPage({
    appCode:'shop',
    appParams:{
        shopId:"180175726",
        weexShopTab:"shopindexbar",
        weexShopSubTab:"shopindex"
    },
    success: (res) => {
        my.alert({ content: "success - " + res.success })
    },
    fail: (res) => {
        my.alert({ content: "fail - " + res.error })
    }
});

2.外链为淘宝商品详情:

my.tb.openDetail

my.tb.openDetail ({
      itemId: "576308890723",
      success: (res) => {
        my.alert({ content: "success" });
      },
      fail: (res) => {
        my.alert({ content: "fail - " + res.error });
      },
});

3.外链为小程序:

my.navigateToMiniProgram

my.navigateToMiniProgram({
      appId: 'xxxx',
	  extraData:{
  		"data1":"test"
	  },
      success: (res) => {
	    console.log(JSON.stringify(res))
      },
      fail: (res) => {
	    console.log(JSON.stringify(res))
      }
    });

4.外链为h5:

只能使用web-view将h5页面嵌入小程序

<web-view src="https://render.alipay.com/p/s/web-view/index" onMessage="onmessage"></web-view>

注:嵌入链接是否成功,需要在手机端调试,模拟器一般不会报错,链接有问题的话在手机上才会显示