从A小程序跳转到B小程序

从A小程序跳转到B小程序:

A小程序 wxml:

<navigator target="miniProgram" open-type="navigate" app- path="pages/personal/personal" extra-data="{{dataList}}" version="release" />

注释:

1. app-id 设置要跳转的小程序的APPID  
2. path 配置跳转后进入的页面  
3. extra-data 可以设置要携带的数据,该参数是一个对象  
4. version是要打开的小程序版本,有效值: develop(开发版),trial(体验版),release(正式版),仅在当前小程序为开发版或体验版时此参数有效;如果当前小程序是正式版,则打开的小程序必定是正式版。

A小程序 app.json:

{
  "navigateToMiniProgramAppIdList": [
    "wx82b7c63d360a3b10"
  ]
}

B小程序通过在onload函数或者onShow函数中可以接收到,通过路径或者extra-data携带过来的参数

B小程序app.js:

onShow: function (options) {
    console.log(options)
    console.log(options.referrerInfo)
    if (options.referrerInfo) {
      if (options.referrerInfo.extraData) {
        this.data.lotteryId = options.referrerInfo.extraData.id
        //获取共享抽奖派发的代金券id
        if (options.referrerInfo.extraData.type == 2) {
          this.data.lotteryVoucherId = options.referrerInfo.extraData.vouchersId
        }
        //获取共享抽奖派发的搜城币数量
        if (options.referrerInfo.extraData.type == 5) {
          this.data.lotteryNumber = options.referrerInfo.extraData.number
        }
      }
    }
  },

options.referrerInfo.extraData则是A小程序携带的对象