微信小程序長按不能識別二維碼/保存圖片


在小程序里面長按圖片只能識別小程序的太陽碼(就是小程序碼),其他的包括普通二維碼,企業微信碼都是不能識別的。

包括小程序普通的頁面和小程序的webview以及imgpreview,都只能識別小程序碼。

 

微信小程序獲取當前路徑信息

 let pages = getCurrentPages();
            let currPage = null;
            if (pages.length) {
              currPage = pages[pages.length - 1];
            }
cosole.log(currPage)

 

 

 

 

微信下載文件:

wx.downloadFile({   //通過微信的下載接口,下載網絡文件
      url: 'https://hj.hj088.cn/carlsberg/miniapp/scene/code2.jpg',
      success (res) {   //res.tempFilePath是下載好的本地路徑,可以用來預覽下載好的東西或者保存文件到手機
        console.log(res);
        if(res.statusCode === 200){
          wx.saveImageToPhotosAlbum({   //下載的如果是圖片,要調用這個方法才能保存的手機相冊
            filePath: res.tempFilePath,
            success: function(data) {
              wx.showToast({
                title: "保存成功",
                icon: "success",
                duration: 2000
              });
            },
            fail: function(err) {
              console.log(err);
            },
            complete(res) {
              console.log(res);
            }
          });

          // wx.saveFile({   //下載的如果不是圖片而已word之類的文檔,要用這個方法保存到手機,文檔的話還可以調用wx.openDocument方法來打開預覽
          //   tempFilePath: res.tempFilePath,
          //   success:() => {
          //    wx.showToast({
          //      title: '保存成功',
          //      type:'success'
          //    })
          //   }
          // })
        }
      }
    })

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM