Uniapp---跳转微信

由于种种原因,在使用APP的时候,点击需要触发打开微信小程序的功能,具体代码示例:

plus.share.getServices(function(res){
       var sweixin = null;  
       for(var i=0;i<res.length;i++){  
            var t = res[i];  
            if(t.id == 'weixin'){  
                sweixin = t;  
            }
       }  
   if(sweixin){  
    sweixin.launchMiniProgram({  
      id: 'gh_8888888',  //这里写你的小程序原始id(以gh开头)
      type: 0,//这里是不同的环境(默认0)
      path:'/pages/shop/index?storeId=123456'//这里是指定页的路径,如需传参直接字符串拼接(首页可以省略)
    });  
   }  
},function(res){  
  console.log(JSON.stringify(res));  
});

或者:

/**
 * envVersion 类型为字符串
 * envVersion: 'develop', //开发版
 * envVersion: 'trial', //体验版
 * envVersion: 'release',//正式版
 */
uni.navigateToMiniProgram({
    appId:'wxd2ade0f25a874ee2',// 此为生活缴费appid
    path:'main/pages/nativeindex/nativeindex',// 此为生活缴费首页路径
    envVersion:"release",
    success: res => {
      // 打开成功
      console.log("打开成功", res);
    },
    fail: err => {
      console.log(err);
    }
});

可参考:

https://blog.csdn.net/qq_731335498/article/details/120323119
https://blog.csdn.net/qq_33444716/article/details/122618056

打完收工!

posted @ 2022-08-30 17:41  帅到要去报警  阅读(939)  评论(0编辑  收藏  举报