更换版本
This commit is contained in:
260
packageA/pages/jszsb/jszsb.js
Normal file
260
packageA/pages/jszsb/jszsb.js
Normal file
@@ -0,0 +1,260 @@
|
||||
var t, e, o;
|
||||
(t = getApp()),
|
||||
(e = getApp()),
|
||||
(o = "https://aip.baidubce.com/rest/2.0/ocr/v1/driving_license"),
|
||||
Page({
|
||||
data: {
|
||||
url: t.globalData.ceshiurl,
|
||||
src: "",
|
||||
src_01: "",
|
||||
leixing: 2,
|
||||
result_1: [],
|
||||
xuanze: "驾驶证识别",
|
||||
},
|
||||
onLoad: function (t) {
|
||||
wx.getStorageSync("uid") || getApp().wxlogin(),
|
||||
t.type && this.setData({ typeapi: t.type });
|
||||
try {
|
||||
wx.removeStorageSync("result_1");
|
||||
} catch (t) {}
|
||||
this.setData({
|
||||
src: "https://img.mp.itc.cn/q_70,c_zoom,w_640/upload/20160523/bf7ea2bbb3d948ed81e4a82350784791_th.jpg",
|
||||
});
|
||||
},
|
||||
onReady: function () {},
|
||||
onShow: function () {},
|
||||
onHide: function () {},
|
||||
onUnload: function () {},
|
||||
getad: function () {
|
||||
var t = this;
|
||||
e.ad().then((e) => {
|
||||
console.log("回调广告:", e),
|
||||
t.setData({
|
||||
adunitId: e.adunitId,
|
||||
capingtId: e.capingtId,
|
||||
payId: e.payId,
|
||||
videoId: e.videoId,
|
||||
dyId: e.dyId,
|
||||
fxzq: e.fxzq,
|
||||
wxpay: e.wxpay,
|
||||
adopen: e.adopen,
|
||||
vadopen: e.vadopen,
|
||||
});
|
||||
});
|
||||
},
|
||||
copyBtn: function () {
|
||||
var t = this;
|
||||
1 == this.data.vadopen
|
||||
? e.videoad(this.data.videoId, "看完视频广告复制~").then((e) => {
|
||||
console.log("回调广告:", e), 1 == e && t.copyBtnb();
|
||||
})
|
||||
: t.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 t = this,
|
||||
s = this;
|
||||
1 == t.data.leixing
|
||||
? ((a = t.data.url),
|
||||
wx.chooseImage({
|
||||
count: 1,
|
||||
sizeType: ["compressed"],
|
||||
sourceType: ["album", "camera"],
|
||||
success: function (a) {
|
||||
wx.showLoading({ title: "提取中.." });
|
||||
var n = a.tempFilePaths[0],
|
||||
i = a.tempFilePaths[0],
|
||||
d =
|
||||
e.util.url("entry/wxapp/Wenzisb") +
|
||||
"&m=" +
|
||||
e.siteInfo.m +
|
||||
"&api=" +
|
||||
o +
|
||||
"&type=" +
|
||||
s.data.typeapi;
|
||||
wx.uploadFile({
|
||||
url: d,
|
||||
filePath: n,
|
||||
name: "file",
|
||||
success: function (e) {
|
||||
wx.hideLoading(), console.log("上传参数b", e);
|
||||
var a = e.data,
|
||||
o = JSON.parse(a),
|
||||
n = JSON.parse(o.data);
|
||||
if ((console.log("上传参数", n), "87014" == n.errcode))
|
||||
return (
|
||||
wx.hideLoading(),
|
||||
void wx.showModal({
|
||||
title: "温馨提示",
|
||||
content: "你上传的图片存在违规,请重新上传。",
|
||||
success: function (t) {
|
||||
t.confirm || console.log("点击取消回调");
|
||||
},
|
||||
})
|
||||
);
|
||||
s.setData({ src: i }),
|
||||
console.log("上传参数", n),
|
||||
console.log("传递参数", s.data.typeapi),
|
||||
"1" == s.data.typeapi &&
|
||||
(wx.setStorageSync("jszimgurl", o.message),
|
||||
wx.setStorageSync("cardata", n.words_result),
|
||||
wx.navigateBack({ delta: 1 })),
|
||||
"2" == s.data.typeapi &&
|
||||
(wx.setStorageSync("cardata", n.words_result),
|
||||
wx.navigateBack({ delta: 1 })),
|
||||
wx.hideLoading(),
|
||||
t.setData({ result_1: n.words_result, show: 1 }),
|
||||
0 == n.words_result.length
|
||||
? (wx.showLoading({ title: "不能识别!" }),
|
||||
setTimeout(function () {
|
||||
wx.hideLoading();
|
||||
}, 2e3))
|
||||
: wx.hideLoading();
|
||||
},
|
||||
fail: function () {
|
||||
console.log("错误");
|
||||
},
|
||||
});
|
||||
},
|
||||
}))
|
||||
: 2 == t.data.leixing &&
|
||||
wx.chooseImage({
|
||||
count: 1,
|
||||
sizeType: ["compressed"],
|
||||
sourceType: ["album", "camera"],
|
||||
success: function (a) {
|
||||
wx.showLoading({ title: "提取中.." });
|
||||
var n = a.tempFilePaths[0],
|
||||
i = a.tempFilePaths[0],
|
||||
d =
|
||||
e.util.url("entry/wxapp/Wenzisb") +
|
||||
"&m=" +
|
||||
e.siteInfo.m +
|
||||
"&api=" +
|
||||
o +
|
||||
"&type=" +
|
||||
s.data.typeapi;
|
||||
wx.uploadFile({
|
||||
url: d,
|
||||
filePath: n,
|
||||
name: "file",
|
||||
success: function (e) {
|
||||
wx.hideLoading(), console.log("上传参数b", e);
|
||||
var a = e.data,
|
||||
o = JSON.parse(a),
|
||||
n = JSON.parse(o.data);
|
||||
if ((console.log("上传参数", n), "87014" == n.errcode))
|
||||
return (
|
||||
wx.hideLoading(),
|
||||
void wx.showModal({
|
||||
title: "温馨提示",
|
||||
content: "你上传的图片存在违规,请重新上传。",
|
||||
success: function (t) {
|
||||
t.confirm || console.log("点击取消回调");
|
||||
},
|
||||
})
|
||||
);
|
||||
s.setData({ src: i }),
|
||||
console.log("上传参数", n),
|
||||
console.log("传递参数", s.data.typeapi),
|
||||
"1" == s.data.typeapi &&
|
||||
(wx.setStorageSync("jszimgurl", o.message),
|
||||
wx.setStorageSync("cardata", n.words_result),
|
||||
wx.navigateBack({ delta: 1 })),
|
||||
"2" == s.data.typeapi &&
|
||||
(wx.setStorageSync("cardata", n.words_result),
|
||||
wx.navigateBack({ delta: 1 })),
|
||||
wx.hideLoading(),
|
||||
t.setData({ result_1: n.words_result, show: 1 }),
|
||||
0 == n.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 = [], n = 0; n < e.data.result_1.length; n++)
|
||||
null != e.data.result_1[n] && s.push(e.data.result_1[n]);
|
||||
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: "汽车驾驶证识别小工具!",
|
||||
imageUrl: "",
|
||||
path: "/packageA/pages/jszsb/jszsb",
|
||||
fail: function (t) {
|
||||
console.log("失败");
|
||||
},
|
||||
}
|
||||
);
|
||||
},
|
||||
});
|
||||
4
packageA/pages/jszsb/jszsb.json
Normal file
4
packageA/pages/jszsb/jszsb.json
Normal file
@@ -0,0 +1,4 @@
|
||||
{
|
||||
"navigationBarTitleText": "汽车驾驶证识别",
|
||||
"usingComponents": {}
|
||||
}
|
||||
36
packageA/pages/jszsb/jszsb.wxml
Normal file
36
packageA/pages/jszsb/jszsb.wxml
Normal file
@@ -0,0 +1,36 @@
|
||||
<view class="page-view">
|
||||
<view class="top-title">
|
||||
<text class="top-title-b">汽车驾驶证识别</text>
|
||||
<text class="top-title-l">请拍照/上传清晰驾驶证照片</text>
|
||||
</view>
|
||||
<view class="top-box">
|
||||
<image
|
||||
bindtap="yinshua"
|
||||
class="img001_002"
|
||||
mode="aspectFill"
|
||||
src="{{src}}"
|
||||
></image>
|
||||
</view>
|
||||
<button bindtap="shibie_1" class="search-button">拍照 / 相册</button>
|
||||
<button class="search-button" openType="share">送给小伙伴</button>
|
||||
<view wx:if="{{show==1}}">
|
||||
<view class="shibie_01" wx:if="{{result_1['住址']}}">
|
||||
<text class="shuoming" style="{{ding}}">~戳文字可进行复制~</text>
|
||||
<view wx:for="{{result_1}}" wx:key="{{index}}">
|
||||
<text
|
||||
bindtap="deletewenzi"
|
||||
class="xia"
|
||||
data-index="{{index}}"
|
||||
data-words="{{item.words}}"
|
||||
>{{index}}:{{item.words}}</text
|
||||
>
|
||||
</view>
|
||||
</view>
|
||||
<view class="shibie_01" wx:else>
|
||||
<text class="xia">未找识别到信息</text>
|
||||
</view>
|
||||
</view>
|
||||
<view class="kongge"></view>
|
||||
</view>
|
||||
<import src="../footer/footer.wxml"></import>
|
||||
<template is="item" data="{{text:'forbar'}}"></template>
|
||||
122
packageA/pages/jszsb/jszsb.wxss
Normal file
122
packageA/pages/jszsb/jszsb.wxss
Normal file
@@ -0,0 +1,122 @@
|
||||
@import "/packageA/pages/vinsb/word.wxss";
|
||||
page {
|
||||
background: #f8f8f8;
|
||||
}
|
||||
.page-view {
|
||||
background: linear-gradient(#3960fe, #4e71fc, #f8f8f8);
|
||||
height: 495rpx;
|
||||
width: 100%;
|
||||
}
|
||||
.top-title {
|
||||
color: #fff;
|
||||
padding-top: 30rpx;
|
||||
text-align: center;
|
||||
}
|
||||
.top-title-b {
|
||||
display: block;
|
||||
font-size: 50rpx;
|
||||
font-weight: 700;
|
||||
}
|
||||
.top-title-l {
|
||||
display: block;
|
||||
font-size: 25rpx;
|
||||
margin-bottom: 20rpx;
|
||||
margin-top: 20rpx;
|
||||
}
|
||||
.top-box {
|
||||
background-color: #fff;
|
||||
border-radius: 14rpx;
|
||||
height: 340rpx;
|
||||
margin: 30rpx;
|
||||
padding: 30rpx;
|
||||
}
|
||||
.box-text {
|
||||
display: inline-block;
|
||||
width: 70%;
|
||||
}
|
||||
.brand-text {
|
||||
display: block;
|
||||
font-size: 36rpx;
|
||||
font-weight: 700;
|
||||
height: 46rpx;
|
||||
line-height: 46rpx;
|
||||
}
|
||||
.container {
|
||||
align-items: center;
|
||||
box-sizing: border-box;
|
||||
display: -webkit-flex;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
height: 100%;
|
||||
justify-content: space-between;
|
||||
padding: 200rpx 0;
|
||||
}
|
||||
.img_001 {
|
||||
width: 100%;
|
||||
}
|
||||
.img001_001 {
|
||||
border: 5px solid #0082dc;
|
||||
border-radius: 10px;
|
||||
height: 120px;
|
||||
margin: 7px 7% 7px 18%;
|
||||
width: 200px;
|
||||
}
|
||||
.t01 {
|
||||
color: #000;
|
||||
margin: 10px 0;
|
||||
}
|
||||
.t01,
|
||||
.t02 {
|
||||
display: block;
|
||||
float: left;
|
||||
font-size: 0.9em;
|
||||
font-weight: 800;
|
||||
}
|
||||
.t02 {
|
||||
color: #ee2c2c;
|
||||
margin: 10px 0 10px 2px;
|
||||
}
|
||||
.img_002 {
|
||||
width: 100%;
|
||||
}
|
||||
.img001_002 {
|
||||
border-radius: 6px;
|
||||
height: 146px;
|
||||
width: 100%;
|
||||
}
|
||||
.hf {
|
||||
height: 100px;
|
||||
}
|
||||
.box {
|
||||
background: #f8f8ff;
|
||||
}
|
||||
.bt {
|
||||
margin: 40px 20% 20px;
|
||||
width: 60%;
|
||||
}
|
||||
.bt button {
|
||||
background: #0082dc;
|
||||
border-radius: 50px;
|
||||
color: #fff;
|
||||
margin: 5px 0 20px;
|
||||
}
|
||||
button::after {
|
||||
border: none;
|
||||
}
|
||||
.bt text {
|
||||
color: #969696;
|
||||
display: block;
|
||||
font-size: 0.8em;
|
||||
margin: 20px 0;
|
||||
text-align: center;
|
||||
width: 100%;
|
||||
}
|
||||
.adContainer {
|
||||
margin: 0 5%;
|
||||
width: 90%;
|
||||
}
|
||||
.img001_003 {
|
||||
border-radius: 5px;
|
||||
margin: 15px 25% 2px;
|
||||
width: 50%;
|
||||
}
|
||||
Reference in New Issue
Block a user