Skip to content

Commit db8d029

Browse files
author
xuqingkai
committed
fix: 🐛 修复 ImgCropper 在钉钉小程序平台无法展示所选图片的问题
1 parent 3785215 commit db8d029

File tree

2 files changed

+12
-9
lines changed

2 files changed

+12
-9
lines changed

src/pages/imgCropper/Index.vue

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<!--
22
* @Author: weisheng
33
* @Date: 2023-09-20 11:10:41
4-
* @LastEditTime: 2023-11-20 18:35:28
4+
* @LastEditTime: 2024-02-29 13:17:27
55
* @LastEditors: weisheng
66
* @Description:
77
* @FilePath: \wot-design-uni\src\pages\imgCropper\Index.vue
@@ -14,7 +14,6 @@
1414
<!-- #endif -->
1515
<demo-block title="基本用法" style="text-align: center">
1616
<wd-img-cropper
17-
id="wd-img-cropper"
1817
v-model="show"
1918
:img-src="src"
2019
@confirm="handleConfirm"

src/uni_modules/wot-design-uni/components/wd-img-cropper/wd-img-cropper.vue

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<template>
22
<!-- 绘制的图片canvas -->
3-
<view id="wd-img-cropper" v-if="modelValue" :class="`wd-img-cropper ${customClass}`" @touchmove="preventTouchMove">
3+
<view v-if="modelValue" :class="`wd-img-cropper ${customClass}`" @touchmove="preventTouchMove">
44
<!-- 展示在用户面前的裁剪框 -->
55
<view class="wd-img-cropper__wrapper">
66
<!-- 画出裁剪框 -->
@@ -146,6 +146,10 @@ const props = withDefaults(defineProps<Props>(), {
146146
const imgAngle = ref<number>(0)
147147
// 是否开启动画
148148
const isAnimation = ref<boolean>(false)
149+
// #ifdef MP-ALIPAY || APP-PLUS
150+
// hack 避免钉钉小程序、支付宝小程序、app抛出相关异常
151+
const animation: any = null
152+
// #endif
149153
150154
// 裁剪框的宽高
151155
const picWidth = ref<number>(0)
@@ -588,12 +592,12 @@ function canvasToImage() {
588592
fileType,
589593
quality,
590594
canvasId: 'wd-img-cropper-canvas',
591-
success: (res) => {
592-
emit('confirm', {
593-
tempFilePath: res.tempFilePath,
594-
width: cutWidth.value * exportScale,
595-
height: cutHeight.value * exportScale
596-
})
595+
success: (res: any) => {
596+
const result = { tempFilePath: res.tempFilePath, width: cutWidth.value * exportScale, height: cutHeight.value * exportScale }
597+
// #ifdef MP-DINGTALK
598+
result.tempFilePath = res.filePath
599+
// #endif
600+
emit('confirm', result)
597601
},
598602
complete: () => {
599603
emit('update:modelValue', false)

0 commit comments

Comments
 (0)