From 1e2b785f46cb7dddbaaf87c78df0487b7d910bba Mon Sep 17 00:00:00 2001 From: SunnyQjm Date: Sun, 18 Aug 2019 10:46:57 +0800 Subject: [PATCH] =?UTF-8?q?add:=20=E6=B7=BB=E5=8A=A0=E5=AE=8C=E6=88=90?= =?UTF-8?q?=E6=8C=89=E9=92=AE=E9=9A=90=E8=97=8F=E6=94=AF=E6=8C=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- @types/taro-cropper.d.ts | 1 + package.json | 2 +- src/components/taro-cropper/index.tsx | 56 +++++++++++++++------------ 3 files changed, 34 insertions(+), 25 deletions(-) diff --git a/@types/taro-cropper.d.ts b/@types/taro-cropper.d.ts index a5936ef..45b48ff 100644 --- a/@types/taro-cropper.d.ts +++ b/@types/taro-cropper.d.ts @@ -10,6 +10,7 @@ export interface TaroCropperComponentProps { maxScale?: number, // 最大放大倍数,maxScale >= 1 fullScreen?: boolean, // 组件充满全屏,此时width和height设置无效 src: string, // 要裁剪的图片路径, + hideFinishText?: boolean, // 隐藏完成按钮(可以自己实现,然后调用本实例的cut方法进行裁剪) onCut?: (src: string) => void, // 点击底部的完成按钮,执行裁剪,成功则触发该回调 onFail?: (err) => void, // 裁剪失败触发该回调 } diff --git a/package.json b/package.json index 0f63e30..ee205c9 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "taro-cropper", - "version": "1.0.1", + "version": "1.0.2", "private": false, "description": "Taro框架下的图片裁剪组件封装,开箱即用", "main": "dist/index.js", diff --git a/src/components/taro-cropper/index.tsx b/src/components/taro-cropper/index.tsx index f763336..a28cef8 100644 --- a/src/components/taro-cropper/index.tsx +++ b/src/components/taro-cropper/index.tsx @@ -18,6 +18,7 @@ interface TaroCropperComponentProps { src: string, // 要裁剪的图片路径, onCut: (src: string) => void, // 点击底部的完成按钮,执行裁剪,成功则触发该回调 onFail: (err) => void, // 裁剪失败触发该回调 + hideFinishText: boolean, // 隐藏完成按钮(可以自己实现,然后调用本实例的cut方法进行裁剪) } interface TaroCropperComponentState { @@ -36,8 +37,11 @@ class TaroCropperComponent extends Taro.PureComponent {}, - onFail: () => {} + hideFinishText: false, + onCut: () => { + }, + onFail: () => { + }, }; systemInfo: getSystemInfoSync.Return; @@ -423,7 +427,8 @@ class TaroCropperComponent extends Taro.PureComponent - { - this.cut() - .then(res => { - this.props.onCut && this.props.onCut(res.tempFilePath); - }) - .catch(err => { - this.props.onFail && this.props.onFail(err); - }) - }} - > - 完成 - + { + !hideFinishText && + { + this.cut() + .then(res => { + this.props.onCut && this.props.onCut(res.tempFilePath); + }) + .catch(err => { + this.props.onFail && this.props.onFail(err); + }) + }} + > + 完成 + + } ); }