|
@@ -6,52 +6,194 @@
|
|
|
<image :src="path" mode="" class="image"></image>
|
|
<image :src="path" mode="" class="image"></image>
|
|
|
<view class="recognition" v-if="datasTF">
|
|
<view class="recognition" v-if="datasTF">
|
|
|
<p class="recognition_title">{{name}}</p>
|
|
<p class="recognition_title">{{name}}</p>
|
|
|
- <view class="recognition_img">
|
|
|
|
|
- <image :src="path2" mode=""></image>
|
|
|
|
|
|
|
+ <view :class="tishi?'recognition_img':'recognition_img_two'">
|
|
|
|
|
+ <image :src="path2" mode="" @error="error"></image>
|
|
|
</view>
|
|
</view>
|
|
|
- <button class="recognition_details" v-if="tishi" @click="">查看详情</button>
|
|
|
|
|
|
|
+ <button class="recognition_details" v-if="tishi" @click="examine">查看详情</button>
|
|
|
|
|
+ <button class="recognition_details" v-if="!tishi" @click="show=!show">再拍一张</button>
|
|
|
</view>
|
|
</view>
|
|
|
<view class="datas" v-else>
|
|
<view class="datas" v-else>
|
|
|
- <p>{{prevention}}</p>
|
|
|
|
|
|
|
+ <p class="datas_title">{{name}}</p>
|
|
|
|
|
+ <view v-for="(item,index) in preventionArr" :key="index" class="prevention">
|
|
|
|
|
+ <view class="prevention_title">
|
|
|
|
|
+ <u-icon name="play-right-fill" size="24" color="#55A92D"></u-icon>
|
|
|
|
|
+ <p>{{regexptitle[index]}}:</p>
|
|
|
|
|
+ </view>
|
|
|
|
|
+ <p class="prevention_con">{{item}}</p>
|
|
|
|
|
+ </view>
|
|
|
</view>
|
|
</view>
|
|
|
|
|
+ <u-modal v-model="show" :mask-close-able="true" title="" :show-cancel-button="true" confirm-text="拍病害" cancel-text="拍虫害"
|
|
|
|
|
+ content="拍照识别病虫害" @confirm="confirm" @cancel="cancel"></u-modal>
|
|
|
|
|
+ <kps-image-cutter @ok="onok" @cancel="oncancle" :url="url" :fixed="false" :blob="false" :maxWidth="500" :maxHeight="500"></kps-image-cutter>
|
|
|
</view>
|
|
</view>
|
|
|
</template>
|
|
</template>
|
|
|
|
|
|
|
|
<script>
|
|
<script>
|
|
|
|
|
+ import kpsImageCutter from "@/components/ksp-image-cutter/ksp-image-cutter.vue";
|
|
|
export default {
|
|
export default {
|
|
|
|
|
+ components: {
|
|
|
|
|
+ kpsImageCutter
|
|
|
|
|
+ },
|
|
|
data() {
|
|
data() {
|
|
|
return {
|
|
return {
|
|
|
path: "",
|
|
path: "",
|
|
|
- path2:"",
|
|
|
|
|
|
|
+ path2: "",
|
|
|
tishi: true,
|
|
tishi: true,
|
|
|
- name:"",
|
|
|
|
|
- prevention:"",
|
|
|
|
|
- datasTF:true
|
|
|
|
|
|
|
+ name: "",
|
|
|
|
|
+ prevention: "",
|
|
|
|
|
+ datasTF: true,
|
|
|
|
|
+ show: false,
|
|
|
|
|
+ url: "",
|
|
|
|
|
+ preventionArr: [],
|
|
|
|
|
+ regexptitle: []
|
|
|
}
|
|
}
|
|
|
},
|
|
},
|
|
|
methods: {
|
|
methods: {
|
|
|
|
|
+ // pest.pests.insect_discern 虫害
|
|
|
|
|
+ async worm(data) {
|
|
|
|
|
+ const res = await this.$myRequest({
|
|
|
|
|
+ url: '/api/api_gateway?method=pest.pests.insect_discern',
|
|
|
|
|
+ data: {
|
|
|
|
|
+ img_file: data
|
|
|
|
|
+ }
|
|
|
|
|
+ })
|
|
|
|
|
+ // this.res = res.data
|
|
|
|
|
+ console.log(res)
|
|
|
|
|
+ if (res.data.img_urls == undefined) {
|
|
|
|
|
+ this.name = "识别失败,请换张图片"
|
|
|
|
|
+ this.tishi = false
|
|
|
|
|
+ this.path2 = "../../static/image/10ca93e17420371a82826073c8425c0.png"
|
|
|
|
|
+ } else {
|
|
|
|
|
+ this.path2 = res.data.img_urls
|
|
|
|
|
+ this.name = res.data.name
|
|
|
|
|
+ this.tishi = true
|
|
|
|
|
+ this.prevention = res.data.prevention
|
|
|
|
|
+ }
|
|
|
|
|
+ },
|
|
|
|
|
+ //pest.pests.insect_discern病害识别
|
|
|
|
|
+ async disease(data) {
|
|
|
|
|
+ const res = await this.$myRequest({
|
|
|
|
|
+ url: '/api/api_gateway?method=pest.pests.plant_discern',
|
|
|
|
|
+ data: {
|
|
|
|
|
+ img_file: data
|
|
|
|
|
+ }
|
|
|
|
|
+ })
|
|
|
|
|
+ console.log(res)
|
|
|
|
|
+ // this.res = res.data
|
|
|
|
|
+ if (res.data.img_urls == undefined) {
|
|
|
|
|
+ this.name = "识别失败,请换张图片"
|
|
|
|
|
+ this.tishi = false
|
|
|
|
|
+ this.path2 = "../../static/image/10ca93e17420371a82826073c8425c0.png"
|
|
|
|
|
+ } else {
|
|
|
|
|
+ this.path2 = res.data.img_urls
|
|
|
|
|
+ this.name = res.data.name
|
|
|
|
|
+ this.tishi = true
|
|
|
|
|
+ this.prevention = res.data.prevention
|
|
|
|
|
+ }
|
|
|
|
|
+ },
|
|
|
clickLeft() {
|
|
clickLeft() {
|
|
|
uni.switchTab({
|
|
uni.switchTab({
|
|
|
url: "../index/index"
|
|
url: "../index/index"
|
|
|
})
|
|
})
|
|
|
},
|
|
},
|
|
|
- examine(){
|
|
|
|
|
|
|
+ examine() {
|
|
|
this.datasTF = false
|
|
this.datasTF = false
|
|
|
|
|
+ },
|
|
|
|
|
+ confirm() {
|
|
|
|
|
+ this.flag = 1
|
|
|
|
|
+ uni.chooseImage({
|
|
|
|
|
+ count: 1, //默认9
|
|
|
|
|
+ // sizeType: ['original', 'compressed'], //可以指定是原图还是压缩图,默认二者都有
|
|
|
|
|
+ sourceType: ['camera', 'album'], //从相册选择
|
|
|
|
|
+ success: (res) => {
|
|
|
|
|
+ this.url = res.tempFilePaths[0]
|
|
|
|
|
+ }
|
|
|
|
|
+ });
|
|
|
|
|
+ },
|
|
|
|
|
+ cancel() {
|
|
|
|
|
+ this.flag = 2
|
|
|
|
|
+ uni.chooseImage({
|
|
|
|
|
+ count: 1, //默认9
|
|
|
|
|
+ // sizeType: ['original', 'compressed'], //可以指定是原图还是压缩图,默认二者都有
|
|
|
|
|
+ sourceType: ['camera', 'album'], //从相册选择
|
|
|
|
|
+ success: (res) => {
|
|
|
|
|
+ console.log(1)
|
|
|
|
|
+ this.url = res.tempFilePaths[0]
|
|
|
|
|
+ }
|
|
|
|
|
+ });
|
|
|
|
|
+ },
|
|
|
|
|
+ onok(ev) {
|
|
|
|
|
+ if (this.flag == 2) {
|
|
|
|
|
+ // pest.pests.insect_discern 虫害
|
|
|
|
|
+ uni.uploadFile({
|
|
|
|
|
+ // url: 'http://182.92.193.64:8002/api/api_gateway?method=base.bases.base_photo', //仅为示例,非真实的接口地址
|
|
|
|
|
+ url: 'http://182.92.193.64:8002/api/api_gateway?method=pest.pests.insect_discern', //仅为示例,非真实的接口地址
|
|
|
|
|
+ filePath: ev.path,
|
|
|
|
|
+ name: 'img_file',
|
|
|
|
|
+ formData: {
|
|
|
|
|
+ 'user': 'test'
|
|
|
|
|
+ },
|
|
|
|
|
+ success: (uploadFileRes) => {
|
|
|
|
|
+ console.log(JSON.parse(uploadFileRes.data))
|
|
|
|
|
+ this.optionverify(JSON.parse(uploadFileRes.data).data)
|
|
|
|
|
+ }
|
|
|
|
|
+ });
|
|
|
|
|
+ } else if (this.flag == 1) {
|
|
|
|
|
+ //pest.pests.insect_discern病害识别
|
|
|
|
|
+ uni.uploadFile({
|
|
|
|
|
+ // url: 'http://182.92.193.64:8002/api/api_gateway?method=base.bases.base_photo', //仅为示例,非真实的接口地址
|
|
|
|
|
+ url: 'http://182.92.193.64:8002/api/api_gateway?method=pest.pests.plant_discern', //仅为示例,非真实的接口地址
|
|
|
|
|
+ filePath: ev.path,
|
|
|
|
|
+ name: 'img_file',
|
|
|
|
|
+ formData: {
|
|
|
|
|
+ 'user': 'test'
|
|
|
|
|
+ },
|
|
|
|
|
+ success: (uploadFileRes) => {
|
|
|
|
|
+ console.log(JSON.parse(uploadFileRes.data))
|
|
|
|
|
+ this.optionverify(JSON.parse(uploadFileRes.data).data)
|
|
|
|
|
+ }
|
|
|
|
|
+ });
|
|
|
|
|
+ }
|
|
|
|
|
+ this.url = "";
|
|
|
|
|
+ },
|
|
|
|
|
+ oncancle() {
|
|
|
|
|
+ // url设置为空,隐藏控件
|
|
|
|
|
+ this.url = ''
|
|
|
|
|
+ },
|
|
|
|
|
+ error() {
|
|
|
|
|
+ this.path2 = "../../static/image/e1cd85dc59139760f43ddbac15136f2.png"
|
|
|
|
|
+ },
|
|
|
|
|
+ optionverify(data){
|
|
|
|
|
+ if (data == null) {
|
|
|
|
|
+ this.name = "识别失败,请换张图片"
|
|
|
|
|
+ this.tishi = false
|
|
|
|
|
+ this.path2 = "../../static/image/10ca93e17420371a82826073c8425c0.png"
|
|
|
|
|
+ } else {
|
|
|
|
|
+ this.path2 = data.img_urls
|
|
|
|
|
+ this.name = data.name
|
|
|
|
|
+ this.tishi = true
|
|
|
|
|
+ this.prevention = data.prevention
|
|
|
|
|
+ var regex2 = /\[(.+?)\]/g; // [] 中括号
|
|
|
|
|
+ var str = this.prevention
|
|
|
|
|
+ var arr = str.match(regex2)
|
|
|
|
|
+ var arrindex = []
|
|
|
|
|
+ for (var i = 0; i < arr.length; i++) {
|
|
|
|
|
+ arrindex.push(str.indexOf(arr[i]))
|
|
|
|
|
+ }
|
|
|
|
|
+ for (var i = 0; i < arr.length; i++) {
|
|
|
|
|
+ this.preventionArr.push(str.slice(arrindex[i] + arr[i].length, arrindex[i + 1]))
|
|
|
|
|
+ }
|
|
|
|
|
+ for (var i = 0; i < arr.length; i++) {
|
|
|
|
|
+ arr[i] = arr[i].slice(1, arr[i].length - 1)
|
|
|
|
|
+ }
|
|
|
|
|
+ this.regexptitle = arr
|
|
|
|
|
+ }
|
|
|
}
|
|
}
|
|
|
},
|
|
},
|
|
|
onLoad(option) {
|
|
onLoad(option) {
|
|
|
|
|
+ console.log(option)
|
|
|
this.path = option.path
|
|
this.path = option.path
|
|
|
- console.log(JSON.parse(option.datas).img_urls, option.path)
|
|
|
|
|
- if (JSON.parse(option.datas).img_urls== undefined ) {
|
|
|
|
|
- this.name = "识别失败,请换张图片"
|
|
|
|
|
- this.tishi = false
|
|
|
|
|
- } else {
|
|
|
|
|
- this.path2 = JSON.parse(option.datas).img_urls
|
|
|
|
|
- this.name = JSON.parse(option.datas).name
|
|
|
|
|
- this.tishi = true
|
|
|
|
|
- this.prevention = JSON.parse(option.datas).prevention
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
|
|
+ this.optionverify(JSON.parse(option.datas).data)
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
</script>
|
|
</script>
|
|
@@ -88,9 +230,24 @@
|
|
|
line-height: 450rpx;
|
|
line-height: 450rpx;
|
|
|
|
|
|
|
|
image {
|
|
image {
|
|
|
|
|
+ margin-top: 50rpx;
|
|
|
|
|
+ width: 340rpx;
|
|
|
|
|
+ height: 340rpx;
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ .recognition_img_two {
|
|
|
|
|
+ width: 450rpx;
|
|
|
|
|
+ height: 450rpx;
|
|
|
|
|
+ border-radius: 50%;
|
|
|
|
|
+ margin: 0 auto;
|
|
|
|
|
+ text-align: center;
|
|
|
|
|
+ line-height: 450rpx;
|
|
|
|
|
+
|
|
|
|
|
+ image {
|
|
|
margin-top: 10rpx;
|
|
margin-top: 10rpx;
|
|
|
- width: 430rpx;
|
|
|
|
|
- height: 430rpx;
|
|
|
|
|
|
|
+ width: 340rpx;
|
|
|
|
|
+ height: 340rpx;
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
|
|
|
|
@@ -104,11 +261,34 @@
|
|
|
color: #FFFFFF;
|
|
color: #FFFFFF;
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
- .datas{
|
|
|
|
|
|
|
+
|
|
|
|
|
+ .datas {
|
|
|
position: absolute;
|
|
position: absolute;
|
|
|
- top: 244px;
|
|
|
|
|
- width: 90%;
|
|
|
|
|
- left: 5%;
|
|
|
|
|
- padding: 20rpx;
|
|
|
|
|
|
|
+ top: 264px;
|
|
|
|
|
+ width: 95%;
|
|
|
|
|
+ left: 2.5%;
|
|
|
|
|
+ .datas_title{
|
|
|
|
|
+ font-size: 32rpx;
|
|
|
|
|
+ font-weight: 700;
|
|
|
|
|
+ margin-left: 30rpx;
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ .prevention{
|
|
|
|
|
+ font-size: 28rpx;
|
|
|
|
|
+ color: #919191;
|
|
|
|
|
+ width: 95%;
|
|
|
|
|
+ margin: 20rpx auto;
|
|
|
|
|
+ .prevention_title{
|
|
|
|
|
+ display: flex;
|
|
|
|
|
+ p{
|
|
|
|
|
+ margin-left: 20rpx;
|
|
|
|
|
+ color: #000000;
|
|
|
|
|
+ font-size: 28rpx;
|
|
|
|
|
+ font-weight: 700;
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ .prevention_con{
|
|
|
|
|
+ padding-left: 6%;
|
|
|
|
|
+ }
|
|
|
}
|
|
}
|
|
|
</style>
|
|
</style>
|