239 lines
8.2 KiB
JavaScript
239 lines
8.2 KiB
JavaScript
|
!(function () {
|
|||
|
getApp();
|
|||
|
var t = getApp(),
|
|||
|
e = "https://aip.baidubce.com/rest/2.0/ocr/v1/vin_code";
|
|||
|
Page({
|
|||
|
data: {
|
|||
|
src: "",
|
|||
|
src_01: "",
|
|||
|
leixing: 2,
|
|||
|
result_1: [],
|
|||
|
xuanze: "VIN车架号识别",
|
|||
|
},
|
|||
|
onLoad: function (t) {
|
|||
|
t.type && this.setData({ typeapi: t.type });
|
|||
|
try {
|
|||
|
wx.removeStorageSync("result_1");
|
|||
|
} catch (t) {}
|
|||
|
this.setData({
|
|||
|
src: "https://api.ym23.com/addons/monai_market/static/images/car/vin.jpg",
|
|||
|
});
|
|||
|
},
|
|||
|
onReady: function () {},
|
|||
|
onShow: function () {},
|
|||
|
onHide: function () {},
|
|||
|
onUnload: function () {},
|
|||
|
copyBtn: function () {
|
|||
|
var e = this;
|
|||
|
1 == this.data.vadopen
|
|||
|
? t.videoad(this.data.videoId, "看完视频广告复制~").then((t) => {
|
|||
|
console.log("回调广告:", t), 1 == t && e.copyBtnb();
|
|||
|
})
|
|||
|
: e.copyBtnb();
|
|||
|
},
|
|||
|
copyBtnb: function (t) {
|
|||
|
for (var e = this.data.result_1, a = [], o = 0, s = e.length; o < s; o++)
|
|||
|
a += e[o].words + "\n\n";
|
|||
|
wx.setClipboardData({
|
|||
|
data: a,
|
|||
|
success: function (t) {
|
|||
|
wx.showToast({
|
|||
|
icon: "success",
|
|||
|
title: "复制成功",
|
|||
|
duration: 1500,
|
|||
|
success: function () {},
|
|||
|
});
|
|||
|
},
|
|||
|
fail: function () {
|
|||
|
wx.showToast({ icon: "loading", title: "复制失败" });
|
|||
|
},
|
|||
|
});
|
|||
|
},
|
|||
|
shibie_1: function () {
|
|||
|
var o = this,
|
|||
|
s = this;
|
|||
|
1 == o.data.leixing
|
|||
|
? ((a = o.data.url),
|
|||
|
wx.chooseImage({
|
|||
|
count: 1,
|
|||
|
sizeType: ["compressed"],
|
|||
|
sourceType: ["album", "camera"],
|
|||
|
success: function (a) {
|
|||
|
wx.showLoading({ title: "提取中.." });
|
|||
|
var i = a.tempFilePaths[0],
|
|||
|
n = a.tempFilePaths[0],
|
|||
|
c =
|
|||
|
t.util.url("entry/wxapp/Wenzisb") +
|
|||
|
"&m=" +
|
|||
|
t.siteInfo.m +
|
|||
|
"&api=" +
|
|||
|
e +
|
|||
|
"&type=" +
|
|||
|
s.data.typeapi;
|
|||
|
wx.uploadFile({
|
|||
|
url: c,
|
|||
|
filePath: i,
|
|||
|
name: "file",
|
|||
|
success: function (t) {
|
|||
|
wx.hideLoading(), console.log("上传参数b", t);
|
|||
|
var e = t.data,
|
|||
|
a = JSON.parse(e),
|
|||
|
i = JSON.parse(a.data);
|
|||
|
if ((console.log("上传参数", i), "87014" == i.errcode))
|
|||
|
return (
|
|||
|
wx.hideLoading(),
|
|||
|
void wx.showModal({
|
|||
|
title: "温馨提示",
|
|||
|
content: "你上传的图片存在违规,请重新上传。",
|
|||
|
success: function (t) {
|
|||
|
t.confirm || console.log("点击取消回调");
|
|||
|
},
|
|||
|
})
|
|||
|
);
|
|||
|
s.setData({ src: n }),
|
|||
|
"1" == s.data.typeapi &&
|
|||
|
(wx.setStorageSync("vinimgurl", a.message),
|
|||
|
wx.setStorageSync("cardata", i.words_result),
|
|||
|
wx.navigateBack({ delta: 1 })),
|
|||
|
"2" == s.data.typeapi &&
|
|||
|
(wx.setStorageSync("cardata", i.words_result),
|
|||
|
wx.navigateBack({ delta: 1 })),
|
|||
|
wx.hideLoading(),
|
|||
|
o.setData({ result_1: i.words_result, show: 1 }),
|
|||
|
0 == i.words_result.length
|
|||
|
? (wx.showLoading({ title: "不能识别!" }),
|
|||
|
setTimeout(function () {
|
|||
|
wx.hideLoading();
|
|||
|
}, 2e3))
|
|||
|
: wx.hideLoading();
|
|||
|
},
|
|||
|
fail: function () {
|
|||
|
console.log("错误");
|
|||
|
},
|
|||
|
});
|
|||
|
},
|
|||
|
}))
|
|||
|
: 2 == o.data.leixing &&
|
|||
|
wx.chooseImage({
|
|||
|
count: 1,
|
|||
|
sizeType: ["compressed"],
|
|||
|
sourceType: ["album", "camera"],
|
|||
|
success: function (a) {
|
|||
|
wx.showLoading({ title: "提取中.." });
|
|||
|
var i = a.tempFilePaths[0],
|
|||
|
n = a.tempFilePaths[0],
|
|||
|
c =
|
|||
|
t.util.url("entry/wxapp/Wenzisb") +
|
|||
|
"&m=" +
|
|||
|
t.siteInfo.m +
|
|||
|
"&api=" +
|
|||
|
e +
|
|||
|
"&type=" +
|
|||
|
s.data.typeapi;
|
|||
|
wx.uploadFile({
|
|||
|
url: c,
|
|||
|
filePath: i,
|
|||
|
name: "file",
|
|||
|
success: function (t) {
|
|||
|
wx.hideLoading(), console.log("上传参数b", t);
|
|||
|
var e = t.data,
|
|||
|
a = JSON.parse(e),
|
|||
|
i = JSON.parse(a.data);
|
|||
|
if ((console.log("上传参数", i), "87014" == i.errcode))
|
|||
|
return (
|
|||
|
wx.hideLoading(),
|
|||
|
void wx.showModal({
|
|||
|
title: "温馨提示",
|
|||
|
content: "你上传的图片存在违规,请重新上传。",
|
|||
|
success: function (t) {
|
|||
|
t.confirm || console.log("点击取消回调");
|
|||
|
},
|
|||
|
})
|
|||
|
);
|
|||
|
s.setData({ src: n }),
|
|||
|
"1" == s.data.typeapi &&
|
|||
|
(wx.setStorageSync("vinimgurl", a.message),
|
|||
|
wx.setStorageSync("cardata", i.words_result),
|
|||
|
wx.navigateBack({ delta: 1 })),
|
|||
|
"2" == s.data.typeapi &&
|
|||
|
(wx.setStorageSync("cardata", i.words_result),
|
|||
|
wx.navigateBack({ delta: 1 })),
|
|||
|
wx.hideLoading(),
|
|||
|
o.setData({ result_1: i.words_result, show: 1 }),
|
|||
|
0 == i.words_result.length
|
|||
|
? (wx.showLoading({ title: "不能识别!" }),
|
|||
|
setTimeout(function () {
|
|||
|
wx.hideLoading();
|
|||
|
}, 2e3))
|
|||
|
: wx.hideLoading();
|
|||
|
},
|
|||
|
fail: function () {
|
|||
|
console.log("错误");
|
|||
|
},
|
|||
|
});
|
|||
|
},
|
|||
|
});
|
|||
|
},
|
|||
|
deletewenzi: function (t) {
|
|||
|
var e = this,
|
|||
|
a = t.target.dataset.index;
|
|||
|
e.data.result_1,
|
|||
|
wx.showActionSheet({
|
|||
|
itemList: ["复制"],
|
|||
|
success: function (o) {
|
|||
|
if ((console.log(a), console.log(o.tapIndex), 0 == o.tapIndex))
|
|||
|
wx.setClipboardData({
|
|||
|
data: t.target.dataset.words,
|
|||
|
success: function (t) {
|
|||
|
wx.showToast({
|
|||
|
icon: "success",
|
|||
|
title: a + "复制成功",
|
|||
|
duration: 1500,
|
|||
|
success: function () {},
|
|||
|
});
|
|||
|
},
|
|||
|
fail: function () {
|
|||
|
wx.showToast({ icon: "loading", title: "复制失败" });
|
|||
|
},
|
|||
|
});
|
|||
|
else if ((console.log(o.tapIndex), 1 == o.tapIndex))
|
|||
|
e.setData({
|
|||
|
xianshi: "display:none",
|
|||
|
upstyle: "display:hidden",
|
|||
|
xiugai_idx: t.target.dataset.index,
|
|||
|
upwenzi: e.data.result_1[a].words,
|
|||
|
});
|
|||
|
else if (2 == o.tapIndex) {
|
|||
|
delete e.data.result_1[a];
|
|||
|
for (var s = [], i = 0; i < e.data.result_1.length; i++)
|
|||
|
null != e.data.result_1[i] && s.push(e.data.result_1[i]);
|
|||
|
try {
|
|||
|
wx.setStorageSync("result_1", s);
|
|||
|
} catch (t) {}
|
|||
|
e.onShow();
|
|||
|
}
|
|||
|
},
|
|||
|
fail: function (t) {
|
|||
|
console.log(t.errMsg);
|
|||
|
},
|
|||
|
});
|
|||
|
},
|
|||
|
gohome: function () {
|
|||
|
wx.switchTab({ url: "/pages/picmake/index" });
|
|||
|
},
|
|||
|
onShareAppMessage: function (t) {
|
|||
|
return (
|
|||
|
this.data.url,
|
|||
|
{
|
|||
|
title: "汽车VIN车架号识别小工具!",
|
|||
|
imageUrl: "",
|
|||
|
path: "/packageA/pages/vinsb/vinsb",
|
|||
|
fail: function (t) {
|
|||
|
console.log("失败");
|
|||
|
},
|
|||
|
}
|
|||
|
);
|
|||
|
},
|
|||
|
});
|
|||
|
})();
|