Commit 35777462 authored by mengcuiguang's avatar mengcuiguang

优化抖音图片检测

parent 02ae65c1
...@@ -14,8 +14,8 @@ ...@@ -14,8 +14,8 @@
</view> </view>
</view> </view>
<l-clipper v-if="showlip" :image-url="imgUri" :isShowPhotoBtn="false" type="2d" :minWidth="400" :maxHeight="400" <l-clipper v-if="showlip" :image-url="tempUri" :isShowPhotoBtn="false" type="2d" :minWidth="400" :maxHeight="400"
@success="imgUri = $event.url; showlip = false;" @cancel="showlip = false" /> @success="tempUri = $event.url; showlip = false;" @cancel="showlip = false" />
</view> </view>
</template> </template>
...@@ -46,14 +46,16 @@ ...@@ -46,14 +46,16 @@
data() { data() {
return { return {
imgUri: '', imgUri: '',
tempUri: '',
userBean: {}, userBean: {},
type: '', type: '',
ocrUrl: '',
scantype: '', scantype: '',
showlip: false showlip: false
}; };
}, },
onLoad(option) { onLoad(option) {
this.imgUri = decodeURIComponent(option.uri) this.tempUri = decodeURIComponent(option.uri)
this.type = option.type this.type = option.type
if (this.type == 0) { if (this.type == 0) {
...@@ -79,6 +81,8 @@ ...@@ -79,6 +81,8 @@
// 图片转pdf // 图片转pdf
this.scantype = ScanTypeBean.scan_pdf this.scantype = ScanTypeBean.scan_pdf
} }
}, },
onShow() { onShow() {
this.post({ this.post({
...@@ -91,7 +95,12 @@ ...@@ -91,7 +95,12 @@
} }
}); });
}, },
methods: { methods: {
loadData() {
setTimeout(() => {
this.compress();
}, 500);
},
crop() { crop() {
this.showlip = true this.showlip = true
}, },
...@@ -103,27 +112,25 @@ ...@@ -103,27 +112,25 @@
let that = this let that = this
// #ifdef MP-TOUTIAO // #ifdef MP-TOUTIAO
tt.compressImage({ tt.compressImage({
src: that.imgUri, src: that.tempUri,
quality: 80, quality: 80,
success: res => { success: res => {
that.uploadImg(res.tempFilePath) that.uploadImg(res.tempFilePath)
}, },
fail: err => { fail: err => {
that.uploadImg(that.imgUri) that.uploadImg(that.tempUri)
} }
}) })
// #endif // #endif
}, },
clickOcr() { clickOcr() {
this.compress() if (this.userBean.expireTime <= 0) {
// 开通VIP会员
// if (this.userBean.expireTime <= 0) { navigateTo(`/pagesA/vipPay/vipPay`)
// // 开通VIP会员 } else {
// navigateTo(`/pagesA/vipPay/vipPay`) this.ocr(this.ocrUrl)
// } else { }
// this.compress()
// }
}, },
ocr(imgUrl) { ocr(imgUrl) {
if (this.scantype == ScanTypeBean.fanyi) { if (this.scantype == ScanTypeBean.fanyi) {
...@@ -147,16 +154,11 @@ ...@@ -147,16 +154,11 @@
success: ({ success: ({
data data
}) => { }) => {
if (that.userBean.expireTime <= 0) { that.goResult(data, imgUrl);
// 开通VIP会员
navigateTo(`/pagesA/vipPay/vipPay`)
} else {
that.goResult(data, myimgUrl);
}
}, },
fail: () => { fail: () => {
setTimeout(() => { setTimeout(() => {
message.notify('图片存在风险,请重新上传'); message.notify('图片异常,请重新上传');
setTimeout(() => { setTimeout(() => {
navigateBack(); navigateBack();
}, 500); }, 500);
...@@ -177,20 +179,15 @@ ...@@ -177,20 +179,15 @@
success: ({ success: ({
data data
}) => { }) => {
if (that.userBean.expireTime <= 0) { that.goResult(data, myimgUrl);
// 开通VIP会员
navigateTo(`/pagesA/vipPay/vipPay`)
} else {
that.goResult(data, myimgUrl);
}
}, },
fail: () => { fail: () => {
uni.hideLoading() uni.hideLoading()
setTimeout(() => { setTimeout(() => {
message.notify('图片存在风险,请重新上传'); message.notify('图片异常,请重新上传');
setTimeout(() => { setTimeout(() => {
navigateBack(); navigateBack();
}, 500); }, 500);
}, 1000); }, 1000);
} }
}); });
...@@ -219,13 +216,38 @@ ...@@ -219,13 +216,38 @@
}, },
success: (uploadFileRes) => { success: (uploadFileRes) => {
let myData = JSON.parse(uploadFileRes.data) let myData = JSON.parse(uploadFileRes.data)
that.ocr(myData.data.url) that.ocrUrl = myData.data.url
that.dyLink(that.ocrUrl)
}, },
fail: (res) => { fail: (res) => {
uni.hideLoading() uni.hideLoading()
} }
}); });
}, },
dyLink(url) {
let that = this;
this.post({
url: '/ai/image/dyLink',
data: {
imgUrl: url
},
showLoading: true,
success: ({
data
}) => {
that.imgUri = that.tempUri
},
fail: () => {
uni.hideLoading()
setTimeout(() => {
message.notify('图片存在风险,请重新上传');
setTimeout(() => {
navigateBack();
}, 500);
}, 1000);
}
});
},
goResult(data, imgUrl) { goResult(data, imgUrl) {
uni.hideLoading() uni.hideLoading()
if (this.type == 0) { if (this.type == 0) {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment