uni-canvas-image 1.1.4 → 1.1.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "uni-canvas-image",
3
- "version": "1.1.4",
3
+ "version": "1.1.5",
4
4
  "description": "租房项目使用uniapp canvas合并图片",
5
5
  "main": "src/index.js",
6
6
  "type": "module",
@@ -48,7 +48,7 @@ export async function base64ToBlob(base64Data) {
48
48
 
49
49
  export async function drawImageToCanvas(arr, canvasId = 'canvas-1', api, config) {
50
50
  return new Promise((resolve, reject) => {
51
- const { bgc = '#fff' } = config || {}
51
+ const { bgc = '#fff', className = '' } = config || {}
52
52
  const ctx = uni.createCanvasContext(canvasId)
53
53
  ctx.setFillStyle(bgc)
54
54
  ctx.fillRect(0, 0, 375, 300)
@@ -90,15 +90,15 @@ export async function drawImageToCanvas(arr, canvasId = 'canvas-1', api, config)
90
90
  ctx.clearRect(0, 0, 375, 300)
91
91
  let filePath
92
92
  // #ifdef MP-WEIXIN
93
- filePath = tempRes.tempFilePath
93
+ filePath = tempRes
94
94
  // #endif
95
95
  // #ifdef H5
96
96
  const blob = await base64ToBlob(tempRes.tempFilePath)
97
- filePath = URL.createObjectURL(blob)
97
+ filePath.tempFilePath = URL.createObjectURL(blob)
98
98
  // #endif
99
99
  if (!api) return resolve(filePath)
100
100
  else {
101
- const { result } = await api('/third-party/open/upload/uploadFile', filePath, {}, 'file')
101
+ const { result } = await api({ filePath, className })
102
102
  resolve(result)
103
103
  // #ifdef MP-WEIXIN
104
104
  uni.getFileSystemManager().unlink({ filePath })
@@ -33,7 +33,7 @@ async function attractImage(params) {
33
33
  data.mainBuilding = data.mainBuilding.join('、').length > 8 ? data.mainBuilding.join('、').slice(0, 8) + '...' : data.mainBuilding.join('、')
34
34
  const newBuildingInfo = { type: 'text', text: data.mainBuilding, x: 86, y: 258, color: '#fff', fontSize: 16 }
35
35
  const newObj = [...staticInfo, newAreaInfo, newImgInfo, maskInfo, buildingLabel, newBuildingInfo]
36
- const url = await drawImageToCanvas(newObj, canvasId, api, { bgc: '#f2f2f2' })
36
+ const url = await drawImageToCanvas(newObj, canvasId, api, { bgc: '#f2f2f2', className: 'share-attract-card' })
37
37
  resolve(url)
38
38
  })
39
39
  }
@@ -27,7 +27,7 @@ const coverImage = (params = {}) => {
27
27
  type: 'image',
28
28
  }
29
29
  })
30
- const url = await drawImageToCanvas(newDrawImgs, canvasId, api)
30
+ const url = await drawImageToCanvas(newDrawImgs, canvasId, api, { className: 'share-cover-card' })
31
31
  resolve(url)
32
32
  })
33
33
  }
@@ -46,7 +46,7 @@ async function handleItem(obj, canvasId, api) {
46
46
  const tagsInfos = hanleTagsInfo(obj.tags.slice(0, 3), 14, 212)
47
47
  const categoryInfos = handleCategoryInfo(obj, categoryEnum)
48
48
  const newObj = [newImgInfo, ...titleInfos, ...tagsInfos, ...categoryInfos]
49
- const url = await drawImageToCanvas(newObj, canvasId, api)
49
+ const url = await drawImageToCanvas(newObj, canvasId, api, { className: 'share-house-card' })
50
50
  resolve(url)
51
51
  })
52
52
  }
@@ -90,7 +90,7 @@ function handleItems(arr, canvasId, api) {
90
90
  const categoryInfos = handleCategoryInfo(obj, category)
91
91
  newObj.push(newImgInfo, ...titleInfos, ...tagsInfos, ...categoryInfos)
92
92
  }
93
- const url = await drawImageToCanvas(newObj, canvasId, api)
93
+ const url = await drawImageToCanvas(newObj, canvasId, api, { className: 'share-multi-house-card' })
94
94
  resolve(url)
95
95
  })
96
96
  }
@@ -46,7 +46,7 @@ function handleItem(obj, canvasId, api) {
46
46
  }
47
47
  })
48
48
  const newObj = [newImgInfo, ...titleInfos, ...newContentInfos]
49
- const url = await drawImageToCanvas(newObj, canvasId, api)
49
+ const url = await drawImageToCanvas(newObj, canvasId, api, { className: 'share-note-card' })
50
50
  resolve(url)
51
51
  })
52
52
  }
@@ -90,7 +90,7 @@ function handleItems(arr, canvasId, api) {
90
90
  newObj.push(newImgInfo, ...titleInfos, ...newContentInfos)
91
91
  }
92
92
 
93
- const url = await drawImageToCanvas(newObj, canvasId, api)
93
+ const url = await drawImageToCanvas(newObj, canvasId, api, { className: 'share-multi-note-card' })
94
94
  resolve(url)
95
95
  })
96
96
  }