The compressed image

      	cosnt ctx = wx.createCanvasContext( "firstCanvas".this); 
          /** Create canvas */
          // Place SRC in cancas with the width and height of the image
          
          ctx.drawImage(tempFilePath, 0.0, width, height);
          ctx.setFontSize(12);
          ctx.setFillStyle("#fff");
          let textToWidth = width * 0.3; /* (ress.width / 3) * 0.5 */
          let textToHeight = height * 0.5; /* (reess. height / 3) * 0.3 */
          
          ctx.fillText(
            formatDate(Date.parse(new Date())),
            textToWidth,
            textToHeight
          );
          
          ctx.draw(false.() = > {
            setTimeout(() = > {
            // Handle image inches
              uni.canvasToTempFilePath(
                {
                  x: 0.y: 0.canvasId: "firstCanvas".success: (res1) = > {
                  // Here the storage is needed to pay attention, will appear
                    that.storageImage            
                    uni.hideLoading();
                  },
                  fail(err) {
                    uni.hideLoading();
                  },
                },
                that
              );
            }, 500);
          });

Copy the code

When storing and previewing images, a black screen will appear in Android and ios enterprise wechat (previewImage), and the image path cannot be found

There will be many problems in the enterprise wechat, we need to determine how to store pictures

storageImage(res, type){
	const tempFilePath = res.tempFilePath;
    const res = wx.getSystemInfoSync();
    this.platform = res.platform === "android" ? "android" : "";
   Wx.getfilesystemmanager () for ios
   // Android can use saveFile() directly to store a getSavedFileList in ios
   const path = `${wx.env.USER_DATA_PATH}`.const xx2 =  wx.getFileSystemManager()
   // Save filePath, Android/and ios/wx. PreviewImage/wx
   //`${path}/${Date.now()}_${type}.jpg`;
   const filePath
   xx2.saveFile({
    filePath,
    tempFilePath, 
   })
}
Copy the code

The subprogram can only be called in wechat, so WX directly used does not use UNI