更换版本
This commit is contained in:
233
packageA/pages/cphsb/cphsb.js
Normal file
233
packageA/pages/cphsb/cphsb.js
Normal file
@@ -0,0 +1,233 @@
|
||||
var e, t, o;
|
||||
(e = getApp()),
|
||||
(t = getApp()),
|
||||
(o = "https://aip.baidubce.com/rest/2.0/ocr/v1/license_plate"),
|
||||
Page({
|
||||
data: {
|
||||
url: e.globalData.ceshiurl,
|
||||
src: "",
|
||||
src_01: "",
|
||||
leixing: 2,
|
||||
result_1: [],
|
||||
xuanze: "车牌号识别",
|
||||
},
|
||||
onLoad: function (a) {
|
||||
a.type && this.setData({ typeapi: a.type });
|
||||
try {
|
||||
wx.removeStorageSync("result_1");
|
||||
} catch (a) {}
|
||||
this.setData({
|
||||
src: "https://pic.ym23.com/uploads/20221114/FqZ-rcL-1r4HucIDc4CrSoRVZGY2.png",
|
||||
}),
|
||||
this.getad();
|
||||
},
|
||||
onReady: function () {},
|
||||
onShow: function () {},
|
||||
onHide: function () {},
|
||||
onUnload: function () {},
|
||||
getad: function () {
|
||||
var a = this;
|
||||
t.ad().then((e) => {
|
||||
console.log("回调广告:", e),
|
||||
a.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 a = this;
|
||||
1 == this.data.vadopen
|
||||
? t.videoad(this.data.videoId, "看完视频广告复制~").then((e) => {
|
||||
console.log("回调广告:", e), 1 == e && a.copyBtnb();
|
||||
})
|
||||
: a.copyBtnb();
|
||||
},
|
||||
copyBtnb: function (e) {
|
||||
console.log(e),
|
||||
wx.setClipboardData({
|
||||
data: a,
|
||||
success: function (a) {
|
||||
wx.showToast({
|
||||
icon: "success",
|
||||
title: "复制成功",
|
||||
duration: 1500,
|
||||
success: function () {},
|
||||
});
|
||||
},
|
||||
fail: function () {
|
||||
wx.showToast({ icon: "loading", title: "复制失败" });
|
||||
},
|
||||
});
|
||||
},
|
||||
shibie_1: function () {
|
||||
var e = this,
|
||||
s = this;
|
||||
1 == e.data.leixing
|
||||
? ((a = e.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=" +
|
||||
o +
|
||||
"&type=" +
|
||||
s.data.typeapi;
|
||||
wx.uploadFile({
|
||||
url: c,
|
||||
filePath: i,
|
||||
name: "file",
|
||||
success: function (a) {
|
||||
wx.hideLoading(), console.log("上传参数b", a);
|
||||
var t = a.data,
|
||||
o = JSON.parse(t),
|
||||
i = JSON.parse(o.data);
|
||||
if ((console.log("上传参数", i), "87014" == i.errcode))
|
||||
return (
|
||||
wx.hideLoading(),
|
||||
void wx.showModal({
|
||||
title: "温馨提示",
|
||||
content: "你上传的图片存在违规,请重新上传。",
|
||||
success: function (a) {
|
||||
a.confirm || console.log("点击取消回调");
|
||||
},
|
||||
})
|
||||
);
|
||||
s.setData({ src: n }),
|
||||
console.log("上传参数", i),
|
||||
console.log("传递参数", s.data.typeapi),
|
||||
"1" == s.data.typeapi &&
|
||||
(wx.setStorageSync("jszimgurl", o.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(),
|
||||
e.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 == e.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=" +
|
||||
o +
|
||||
"&type=" +
|
||||
s.data.typeapi;
|
||||
wx.uploadFile({
|
||||
url: c,
|
||||
filePath: i,
|
||||
name: "file",
|
||||
success: function (a) {
|
||||
wx.hideLoading(), console.log("上传参数b", a);
|
||||
var t = a.data,
|
||||
o = JSON.parse(t),
|
||||
i = JSON.parse(o.data);
|
||||
if ((console.log("上传参数", i), "87014" == i.errcode))
|
||||
return (
|
||||
wx.hideLoading(),
|
||||
void wx.showModal({
|
||||
title: "温馨提示",
|
||||
content: "你上传的图片存在违规,请重新上传。",
|
||||
success: function (a) {
|
||||
a.confirm || console.log("点击取消回调");
|
||||
},
|
||||
})
|
||||
);
|
||||
s.setData({ src: n }),
|
||||
console.log("上传参数", i),
|
||||
console.log("传递参数", s.data.typeapi),
|
||||
"1" == s.data.typeapi &&
|
||||
(wx.setStorageSync("jszimgurl", o.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(),
|
||||
e.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 (a) {
|
||||
console.log(a);
|
||||
var e = a.target.dataset.words;
|
||||
wx.setClipboardData({
|
||||
data: e,
|
||||
success: function (a) {
|
||||
wx.showToast({
|
||||
icon: "success",
|
||||
title: e + "复制成功",
|
||||
duration: 1500,
|
||||
success: function () {},
|
||||
});
|
||||
},
|
||||
fail: function () {
|
||||
wx.showToast({ icon: "loading", title: "复制失败" });
|
||||
},
|
||||
});
|
||||
},
|
||||
gohome: function () {
|
||||
wx.switchTab({ url: "/pages/picmake/index" });
|
||||
},
|
||||
onShareAppMessage: function (a) {
|
||||
return (
|
||||
this.data.url,
|
||||
{
|
||||
title: "汽车车牌识别小工具!",
|
||||
imageUrl: "",
|
||||
path: "/packageA/pages/cphsb/cphsb",
|
||||
fail: function (a) {
|
||||
console.log("失败");
|
||||
},
|
||||
}
|
||||
);
|
||||
},
|
||||
});
|
||||
6
packageA/pages/cphsb/cphsb.json
Normal file
6
packageA/pages/cphsb/cphsb.json
Normal file
@@ -0,0 +1,6 @@
|
||||
{
|
||||
"navigationBarTitleText": "车牌号识别",
|
||||
"usingComponents": {
|
||||
"ocr-navigator": "plugin://ocr-plugin/ocr-navigator"
|
||||
}
|
||||
}
|
||||
24
packageA/pages/cphsb/cphsb.wxml
Normal file
24
packageA/pages/cphsb/cphsb.wxml
Normal file
@@ -0,0 +1,24 @@
|
||||
<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.number}}">
|
||||
<text class="shuoming" style="{{ding}}">~戳文字可进行复制~</text>
|
||||
<text bindtap="deletewenzi" class="xia" data-words="{{result_1.color}}">车牌颜色:{{result_1.color}}</text>
|
||||
<text bindtap="deletewenzi" class="xia" data-words="{{result_1.number}}">车牌号:{{result_1.number}}</text>
|
||||
</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>
|
||||
129
packageA/pages/cphsb/cphsb.wxss
Normal file
129
packageA/pages/cphsb/cphsb.wxss
Normal file
@@ -0,0 +1,129 @@
|
||||
@import "/packageA/pages/vinsb/word.wxss";
|
||||
.ocr-wrapper {
|
||||
margin: 40rpx auto;
|
||||
width: 375rpx;
|
||||
}
|
||||
.intro {
|
||||
margin: 40rpx;
|
||||
}
|
||||
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