chenguiya

第一种方式:扫码功能:

 

下面分别是微信开发者工具和真机的代码:

wx.scanCode({
    onlyFromCamera:true,
    success:(res)=>{
       var path = res.path
        //微信开发者工具 在开发者工具里出现乱码需要decodeURIComponent转义,真机不需要,可以直接使用
       console.log("res.path",res.path); //pages/me/me?scene=table_id%3D8%26shop_id%3D1
       path= path.split(\'?\');   //分割字符串 path[0]等于pages/me/me,path[1]等于scene=table_id%3D8%26shop_id%3D1
 
        
       var scene = path[1];                 
       var reg  = new RegExp("scene=","g");   
        var scene = path.replace(reg,"");
        //手机和开放者工具不一样的地方就在这几步了
       var scene = decodeURIComponent(scene);   //在手机上省略这一步  开发者工具需要
        
        scene = scene.split("&");
        
        
        var list = {};
        for(var i = 0; i<scene.length; i++){
            var b = scene[i].split("=");
            list[b[0]] = b[1];
        }
 
        console.log(list);
       
        
       
    }
})


微信小程序wx.scanCode扫码之坑   https://blog.csdn.net/weixin_42143687/article/details/81568492

微信小程序扫码的代码及获取二维码的url地址     https://blog.csdn.net/ZNYSYS520/article/details/80593007

 

微信小程序实战教程1503---生成二维码       https://blog.csdn.net/Yt7589/article/details/60323728

微信小程序 四】二维码生成/扫描二维码     https://blog.csdn.net/xbw12138/article/details/75213274

 

分类:

技术点:

相关文章:

  • 2021-12-23
  • 2022-01-09
  • 2022-01-02
  • 2021-12-05
  • 2021-09-27
  • 2022-01-02
  • 2022-12-23
  • 2021-11-18
猜你喜欢
  • 2021-12-12
  • 2021-12-23
  • 2021-11-23
  • 2021-12-05
  • 2022-12-23
相关资源
相似解决方案