提交 8c561906 编写于 作者: 小帅丶's avatar 小帅丶

:sparkles:增加从聊天页面选择图片的功能

上级 c92adc98
......@@ -33,6 +33,30 @@ Page({
wx.navigateTo({
url: '../logs/logs'
})
},
//从聊天页面选择图片
chooseMessage:function(){
var that = this;
wx.chooseMessageFile({
count: 1,
sizeType: ['compressed'],
type:'image',
success(res){
if (res.tempFiles[0].size > (4096 * 1024)) {
wx.showToast({
title: '图片文件过大哦',
icon: 'none',
mask: true,
duration: 1500
})
} else {
that.setData({
img: res.tempFiles[0].path
})
that.generalDetect(res.tempFiles[0].path);
}
}
})
},
//请求方法
uploads: function () {
......@@ -60,55 +84,60 @@ Page({
duration: 1500
})
} else {
wx.showLoading({
title: "识别中...",
mask: true
}),
that.setData({
img: res.tempFilePaths[0]
})
that.generalDetect(res.tempFilePaths[0]);
}
api.generalRequest(res.tempFilePaths[0], app.globalData.userId, api.faceAcnespotmole_url, {
success(result) {
var resultJ = JSON.parse(result)
wx.hideLoading();
if (resultJ.code == 200) {
that.setData({
img: 'data:image/jpg;base64,' + resultJ.data.image_base64,
acne_count: resultJ.data.acne_count,
speckle_count: resultJ.data.speckle_count,
mole_count: resultJ.data.mole_count
})
} else {
if (resultJ.code == 87014) {
wx.hideLoading();
wx.showModal({
content: '存在敏感内容,请更换图片',
showCancel: false,
confirmText: '明白了'
})
that.setData({
img: null
})
} else {
wx.hideLoading();
wx.showModal({
content: resultJ.msg_zh,
showCancel: false,
confirmText: '明白了'
})
}
}
}
})
},
})
},
onLoad: function () {
},
//通用识别
generalDetect(file){
var that = this;
wx.showLoading({
title: "斑痘痣检测中...",
mask: true
}),
that.setData({
img: file
})
api.generalRequest(file, app.globalData.userId, api.faceAcnespotmole_url, {
success(result) {
var resultJ = JSON.parse(result)
wx.hideLoading();
if (resultJ.code == 200) {
that.setData({
img: 'data:image/jpg;base64,' + resultJ.data.image_base64,
acne_count: resultJ.data.acne_count,
speckle_count: resultJ.data.speckle_count,
mole_count: resultJ.data.mole_count
})
} else {
if (resultJ.code == 87014) {
wx.hideLoading();
wx.showModal({
content: '存在敏感内容,请更换图片',
showCancel: false,
confirmText: '明白了'
})
that.setData({
img: null
})
} else {
wx.hideLoading();
wx.showModal({
content: resultJ.msg_zh,
showCancel: false,
confirmText: '明白了'
})
}
}
}
})
},
/**
* 点击查看图片,可以进行保存
*/
* 点击查看图片,可以进行保存
*/
preview(e) {
var that = this;
if (null == that.data.img || that.data.img == '') {
......@@ -125,4 +154,4 @@ Page({
})
}
}
});
\ No newline at end of file
});
<cu-custom bgColor="bg-gradual-blue" isBack="{{true}}">
<view slot="backText">返回</view>
<view slot="content">斑痘痣检测</view>
<view slot="backText">返回</view>
<view slot="content">斑痘痣检测</view>
</cu-custom>
<view class="page-body">
<view class="page-body-wrapper">
<image src="{{ img }}" bindtap='preview' style="width:100%;height:400rpx;" id="imageDom" mode='aspectFit'/>
</view>
<view class="padding flex flex-direction">
<button class="cu-btn bg-xsblue margin-tb-sm lg" bindtap="uploads">拍照/选取图片</button>
<view class="page-body-wrapper">
<image src="{{ img }}" bindtap='preview' style="width:100%;height:400rpx;" id="imageDom" mode='aspectFit'/>
</view>
<view class="padding flex flex-direction">
<button class="cu-btn bg-xsblue margin-tb-sm lg" bindtap="uploads">拍照/选取图片</button>
<!--从聊天中选择-->
<view class="text-center text-grey text-lg" style="text-decoration:underline;" bindtap="chooseMessage">
<view>从聊天中选择</view>
</view>
</view>
<!--检测结果-->
<view class="cu-bar bg-white margin-top">
<view class="action">
<text class="cuIcon-title text-blue"></text>
斑痘痣个数
</view>
</view>
<view class="padding-xs">
<view class="cu-tag" style="background-color:#0081ff;color:#fff" wx:if="{{acne_count!=-99}}">{{acne_count}} 个痘
</view>
<view class="cu-tag" style="background-color:#39b54a;color:#fff" wx:if="{{speckle_count!=-99}}">
{{speckle_count}} 个斑
</view>
<view class="cu-tag" style="background-color:#e54d42;color:#fff" wx:if="{{mole_count!=-99}}">{{mole_count}} 个痣
</view>
</view>
</view>
<!--检测结果-->
<view class="cu-bar bg-white margin-top">
<view class="action">
<text class="cuIcon-title text-blue"></text>斑痘痣个数
</view>
</view>
<view class="padding-xs">
<view class="cu-tag" style="background-color:#0081ff;color:#fff" wx:if="{{acne_count!=-99}}">{{acne_count}} 个痘</view>
<view class="cu-tag" style="background-color:#39b54a;color:#fff" wx:if="{{speckle_count!=-99}}">{{speckle_count}} 个斑</view>
<view class="cu-tag" style="background-color:#e54d42;color:#fff" wx:if="{{mole_count!=-99}}">{{mole_count}} 个痣</view>
</view>
</view>
<!--温馨提示-->
<view>
<!--温馨提示-->
<view>
<text class='reason_txt'>温馨提示</text>
<view class='reminder-content'>1.效果仅供参考 不提供真实性依据</view>
<view class='reminder-content'>2.蓝色痘、绿色斑、红色痣</view>
......@@ -30,9 +39,9 @@
</view>
<!--浮动按钮跳转主页-->
<view class="round-click">
<navigator url='/pages/index/index' open-type="switchTab">
<image src="../../../images/tabbar/index_cur.png"></image>
</navigator >
<navigator url='/pages/index/index' open-type="switchTab">
<image src="../../../images/tabbar/index_cur.png"></image>
</navigator>
</view>
<!--给一个高度让内显示完整-->
<view class="cu-tabbar-height"></view>
......@@ -8,13 +8,12 @@ Page({
resultData: null,
cityId: '110000',
img: '',
modalName:'',
modalTitle:null,
modalContent:null
modalName: '',
modalTitle: null,
modalContent: null
},
//用户点击右上角分享朋友圈
onShareTimeline: function () {
},
onShareTimeline: function () {},
//用户点击右上角分享朋友|朋友圈
onShareAppMessage: function () {
wx.showShareMenu({
......@@ -66,6 +65,30 @@ Page({
url: '../logs/logs'
})
},
//从聊天页面选择图片
chooseMessage:function(){
var that = this;
wx.chooseMessageFile({
count: 1,
sizeType: ['compressed'],
type:'image',
success(res){
if (res.tempFiles[0].size > (4096 * 1024)) {
wx.showToast({
title: '图片文件过大哦',
icon: 'none',
mask: true,
duration: 1500
})
} else {
that.setData({
img: res.tempFiles[0].path
})
that.animal(res.tempFiles[0].path);
}
}
})
},
//请求方法
uploads: function () {
var that = this
......@@ -80,7 +103,7 @@ Page({
src: res.tempFilePaths[0],
success(res) {
takephonewidth = res.width,
takephoneheight = res.height
takephoneheight = res.height
}
})
// 返回选定照片的本地文件路径列表,tempFilePath可以作为img标签的src属性显示图片
......@@ -92,52 +115,56 @@ Page({
duration: 1500
})
} else {
wx.showLoading({
title: "识别中...",
mask: true
}),
that.animal(res.tempFilePaths[0]);
}
},
})
},
onLoad: function () {},
//动物识别
animal(file) {
var that = this
wx.showLoading({
title: "动物识别中...",
mask: true
}),
that.setData({
img: file
})
api.icrRequest(file, app.globalData.userId, 'animal', {
success(result) {
var resultJ = JSON.parse(result)
wx.hideLoading();
if (resultJ.code == 200) {
that.setData({
resultData: resultJ.result
})
} else {
if (resultJ.code == 87014) {
wx.hideLoading();
wx.showModal({
content: '存在敏感内容,请更换图片',
showCancel: false,
confirmText: '明白了'
})
that.setData({
img: res.tempFilePaths[0]
img: null
})
}
api.icrRequest(res.tempFilePaths[0], app.globalData.userId,'animal', {
success(result) {
var resultJ = JSON.parse(result)
} else {
wx.hideLoading();
if (resultJ.code == 200) {
that.setData({
resultData: resultJ.result
})
} else {
if (resultJ.code == 87014) {
wx.hideLoading();
wx.showModal({
content: '存在敏感内容,请更换图片',
showCancel: false,
confirmText: '明白了'
})
that.setData({
img: null
})
} else {
wx.hideLoading();
wx.showModal({
content: resultJ.msg_zh,
showCancel: false,
confirmText: '明白了'
})
}
}
wx.showModal({
content: resultJ.msg_zh,
showCancel: false,
confirmText: '明白了'
})
}
})
},
}
}
})
},
onLoad: function () {
},
/**
* 点击查看图片,可以进行保存
*/
* 点击查看图片,可以进行保存
*/
preview(e) {
var that = this;
wx.previewImage({
......
<cu-custom bgColor="bg-gradual-blue" isBack="{{true}}">
<view slot="backText">返回</view>
<view slot="content">动物识别</view>
<view slot="backText">返回</view>
<view slot="content">动物识别</view>
</cu-custom>
<view class="page-body">
<view class="page-body-wrapper">
<image src="{{ img }}" bindtap='preview' style="width:100%;height:400rpx;" id="imageDom" mode='aspectFit'/>
</view>
<view class="padding flex flex-direction">
<button class="cu-btn bg-xsblue margin-tb-sm lg" bindtap="uploads">拍照/选取图片识别</button>
</view>
<view class="page-body-wrapper">
<image src="{{ img }}" bindtap='preview' style="width:100%;height:400rpx;" id="imageDom" mode='aspectFit'/>
</view>
<view class="padding flex flex-direction">
<button class="cu-btn bg-xsblue margin-tb-sm lg" bindtap="uploads">拍照/选取图片</button>
<!--从聊天中选择-->
<view class="text-center text-grey text-lg" style="text-decoration:underline;" bindtap="chooseMessage">
<view>从聊天中选择</view>
</view>
</view>
</view>
<!--查询详情-->
<block wx:if="{{resultData}}">
<view class="cu-bar bg-white solid-bottom margin-top">
<view class="action">
<text class="cuIcon-title text-xsblue "></text> 动物识别结果
</view>
</view>
<!--动物识别列表-->
<view class="cu-list menu-avatar">
<block wx:for="{{resultData}}">
<view class="cu-item">
<block wx:if="{{item.baike_info.image_url}}">
<view class="cu-avatar lg" style="background-image:url({{item.baike_info.image_url}});"></view>
</block>
<block wx:else>
<view class="cu-avatar lg" style="background-image:url(https://wximage-1251091977.cos.ap-beijing.myqcloud.com/xai/error.png);"></view>
</block>
<view class="content">
<view class="text-black">{{item.name}}</view>
<view class="text-gray text-sm flex">
<text>
<text class="margin-right-xs"></text>可信度{{item.score}}%
</text>
<view class="cu-bar bg-white solid-bottom margin-top">
<view class="action">
<text class="cuIcon-title text-xsblue "></text>
动物识别结果
</view>
</view>
<view class="action">
<view class="cu-tag round bg-xsblue lg" bindtap="showDetail" data-name="{{item.name}}" data-description="{{item.baike_info.description}}">介绍</view>
</view>
</view>
</block>
</view>
<!--动物识别列表-->
<view class="cu-list menu-avatar">
<block wx:for="{{resultData}}">
<view class="cu-item">
<block wx:if="{{item.baike_info.image_url}}">
<view class="cu-avatar lg" style="background-image:url({{item.baike_info.image_url}});"></view>
</block>
<block wx:else>
<view class="cu-avatar lg"
style="background-image:url(https://wximage-1251091977.cos.ap-beijing.myqcloud.com/xai/error.png);"></view>
</block>
<view class="content">
<view class="text-black">{{item.name}}</view>
<view class="text-gray text-sm flex">
<text>
<text class="margin-right-xs"></text>
可信度{{item.score}}%
</text>
</view>
</view>
<view class="action">
<view class="cu-tag round bg-xsblue lg" bindtap="showDetail" data-name="{{item.name}}"
data-description="{{item.baike_info.description}}">介绍
</view>
</view>
</view>
</block>
</view>
</block>
<!--温馨提示-->
<view>
<!--温馨提示-->
<view>
<text class='reason_txt'>温馨提示</text>
<view class='reminder-content'>1.上传图片最好包含动物正面</view>
<view class='reminder-content'>2.点击介绍可查看百科信息</view>
......@@ -51,9 +60,9 @@
</view>
<!--浮动按钮跳转主页-->
<view class="round-click">
<navigator url='/pages/index/index' open-type="switchTab">
<image src="../../../images/tabbar/index_cur.png"></image>
</navigator >
<navigator url='/pages/index/index' open-type="switchTab">
<image src="../../../images/tabbar/index_cur.png"></image>
</navigator>
</view>
<!--给一个高度让内显示完整-->
<view class="cu-tabbar-height"></view>
......@@ -33,6 +33,30 @@ Page({
wx.navigateTo({
url: '../logs/logs'
})
},
//从聊天页面选择图片
chooseMessage:function(){
var that = this;
wx.chooseMessageFile({
count: 1,
sizeType: ['compressed'],
type:'image',
success(res){
if (res.tempFiles[0].size > (4096 * 1024)) {
wx.showToast({
title: '图片文件过大哦',
icon: 'none',
mask: true,
duration: 1500
})
} else {
that.setData({
img: res.tempFiles[0].path
})
that.generalDetect(res.tempFiles[0].path);
}
}
})
},
//请求方法
uploads: function () {
......@@ -60,49 +84,54 @@ Page({
duration: 1500
})
} else {
wx.showLoading({
title: "转换中...",
mask: true
}),
that.setData({
img: res.tempFilePaths[0]
})
that.generalDetect(res.tempFilePaths[0]);
}
api.generalRequest(res.tempFilePaths[0], app.globalData.userId, api.ascii_url, {
success(result) {
var resultJ = JSON.parse(result)
wx.hideLoading();
if (resultJ.code == 200) {
that.setData({
img: 'data:image/jpg;base64,' + resultJ.image
})
} else {
if (resultJ.code == 87014) {
wx.hideLoading();
wx.showModal({
content: '存在敏感内容,请更换图片',
showCancel: false,
confirmText: '明白了'
})
that.setData({
img: null
})
} else {
wx.hideLoading();
wx.showModal({
content: resultJ.msg_zh,
showCancel: false,
confirmText: '明白了'
})
}
}
}
})
},
})
},
onLoad: function () {
},
//通用识别
generalDetect(file){
var that = this;
that.setData({
img: file
})
wx.showLoading({
title: "转换中...",
mask: true
}),
api.generalRequest(file, app.globalData.userId, api.ascii_url, {
success(result) {
var resultJ = JSON.parse(result)
wx.hideLoading();
if (resultJ.code == 200) {
that.setData({
img: 'data:image/jpg;base64,' + resultJ.image
})
} else {
if (resultJ.code == 87014) {
wx.hideLoading();
wx.showModal({
content: '存在敏感内容,请更换图片',
showCancel: false,
confirmText: '明白了'
})
that.setData({
img: null
})
} else {
wx.hideLoading();
wx.showModal({
content: resultJ.msg_zh,
showCancel: false,
confirmText: '明白了'
})
}
}
}
})
},
/**
* 点击查看图片,可以进行保存
*/
......@@ -122,4 +151,4 @@ Page({
})
}
}
});
\ No newline at end of file
});
<cu-custom bgColor="bg-gradual-blue" isBack="{{true}}">
<view slot="backText">返回</view>
<view slot="content">图片转字符画</view>
<view slot="backText">返回</view>
<view slot="content">图片转字符画</view>
</cu-custom>
<view class="page-body">
<view class="page-body-wrapper">
<image src="{{ img }}" bindtap='preview' style="width:100%;height:400rpx;" id="imageDom" mode='aspectFit'/>
</view>
<view class="padding flex flex-direction">
<button class="cu-btn bg-xsblue margin-tb-sm lg" bindtap="uploads">拍照/选取图片</button>
<view class="page-body-wrapper">
<image src="{{ img }}" bindtap='preview' style="width:100%;height:400rpx;" id="imageDom" mode='aspectFit'/>
</view>
<view class="padding flex flex-direction">
<button class="cu-btn bg-xsblue margin-tb-sm lg" bindtap="uploads">拍照/选取图片</button>
<!--从聊天中选择-->
<view class="text-center text-grey text-lg" style="text-decoration:underline;" bindtap="chooseMessage">
<view>从聊天中选择</view>
</view>
</view>
</view>
</view>
<!--温馨提示-->
<view>
<!--温馨提示-->
<view>
<text class='reason_txt'>温馨提示</text>
<view class='reminder-content'>效果仅供娱乐</view>
</view>
<!--浮动按钮跳转主页-->
<view class="round-click">
<navigator url='/pages/index/index' open-type="switchTab">
<image src="../../../images/tabbar/index_cur.png"></image>
</navigator >
<navigator url='/pages/index/index' open-type="switchTab">
<image src="../../../images/tabbar/index_cur.png"></image>
</navigator>
</view>
<!--给一个高度让内显示完整-->
<view class="cu-tabbar-height"></view>
\ No newline at end of file
<view class="cu-tabbar-height"></view>
......@@ -56,6 +56,30 @@ Page({
wx.navigateTo({
url: '../logs/logs'
})
},
//从聊天页面选择图片
chooseMessage:function(){
var that = this;
wx.chooseMessageFile({
count: 1,
sizeType: ['compressed'],
type:'image',
success(res){
if (res.tempFiles[0].size > (4096 * 1024)) {
wx.showToast({
title: '图片文件过大哦',
icon: 'none',
mask: true,
duration: 1500
})
} else {
that.setData({
img: res.tempFiles[0].path
})
that.icrDetect(res.tempFiles[0].path);
}
}
})
},
//请求方法
uploads: function () {
......@@ -83,50 +107,56 @@ Page({
duration: 1500
})
} else {
wx.showLoading({
title: "识别中...",
mask: true
}),
that.setData({
img: res.tempFilePaths[0]
})
that.icrDetect(res.tempFilePaths[0]);
}
api.icrRequest(res.tempFilePaths[0], app.globalData.userId, 'car', {
success(result) {
var resultJ = JSON.parse(result)
wx.hideLoading();
if (resultJ.code == 200) {
that.setData({
resultData: resultJ,
img: 'data:image/jpg;base64,'+resultJ.deal_base64
})
} else {
if (resultJ.code == 87014) {
wx.hideLoading();
wx.showModal({
content: '存在敏感内容,请更换图片',
showCancel: false,
confirmText: '明白了'
})
that.setData({
img: null
})
} else {
wx.hideLoading();
wx.showModal({
content: resultJ.msg_zh,
showCancel: false,
confirmText: '明白了'
})
}
}
}
})
},
})
},
onLoad: function () {
},
//车型识别
icrDetect(file){
var that = this;
that.setData({
img: file
})
wx.showLoading({
title: "车型识别中...",
mask: true
}),
api.icrRequest(file, app.globalData.userId, 'car', {
success(result) {
var resultJ = JSON.parse(result)
wx.hideLoading();
if (resultJ.code == 200) {
that.setData({
resultData: resultJ,
img: 'data:image/jpg;base64,'+resultJ.deal_base64
})
} else {
if (resultJ.code == 87014) {
wx.hideLoading();
wx.showModal({
content: '存在敏感内容,请更换图片',
showCancel: false,
confirmText: '明白了'
})
that.setData({
img: null
})
} else {
wx.hideLoading();
wx.showModal({
content: resultJ.msg_zh,
showCancel: false,
confirmText: '明白了'
})
}
}
}
})
},
/**
* 点击查看图片,可以进行保存
*/
......@@ -137,4 +167,4 @@ Page({
current: that.data.img
})
}
});
\ No newline at end of file
});
<cu-custom bgColor="bg-gradual-blue" isBack="{{true}}">
<view slot="backText">返回</view>
<view slot="content">车型识别</view>
<view slot="backText">返回</view>
<view slot="content">车型识别</view>
</cu-custom>
<view class="page-body">
<view class="page-body-wrapper">
<image src="{{ img }}" bindtap='preview' style="width:100%;height:400rpx;" id="imageDom" mode='aspectFit'/>
</view>
<view class="padding flex flex-direction">
<button class="cu-btn bg-xsblue margin-tb-sm lg" bindtap="uploads">拍照/选取图片识别</button>
</view>
<view class="page-body-wrapper">
<image src="{{ img }}" bindtap='preview' style="width:100%;height:400rpx;" id="imageDom" mode='aspectFit'/>
</view>
<view class="padding flex flex-direction">
<button class="cu-btn bg-xsblue margin-tb-sm lg" bindtap="uploads">拍照/选取图片</button>
<!--从聊天中选择-->
<view class="text-center text-grey text-lg" style="text-decoration:underline;" bindtap="chooseMessage">
<view>从聊天中选择</view>
</view>
</view>
</view>
<!--查询详情-->
<block wx:if="{{resultData}}">
<view class="cu-bar bg-white solid-bottom margin-top">
<view class="action">
<text class="cuIcon-title text-xsblue "></text> 车型识别结果 颜色:{{resultData.color_result}}
</view>
</view>
<!--车型识别列表-->
<view class="cu-list menu-avatar">
<block wx:for="{{resultData.result}}">
<view class="cu-item">
<block wx:if="{{item.baike_info.image_url}}">
<view class="cu-avatar lg" style="background-image:url({{item.baike_info.image_url}});"></view>
</block>
<block wx:else>
<view class="cu-avatar lg" style="background-image:url(https://wximage-1251091977.cos.ap-beijing.myqcloud.com/xai/error.png);"></view>
</block>
<view class="content">
<view class="text-black">{{item.name}} 年份:{{item.year}}</view>
<view class="text-gray text-sm flex">
<text>
<text class="margin-right-xs"></text>可信度{{item.score}}%
</text>
<view class="cu-bar bg-white solid-bottom margin-top">
<view class="action">
<text class="cuIcon-title text-xsblue "></text>
车型识别结果 颜色:{{resultData.color_result}}
</view>
</view>
<view class="action">
<view class="cu-tag round bg-xsblue lg" bindtap="showDetail" data-name="{{item.name}}" data-description="{{item.baike_info.description}}">介绍</view>
</view>
</view>
</block>
</view>
<!--车型识别列表-->
<view class="cu-list menu-avatar">
<block wx:for="{{resultData.result}}">
<view class="cu-item">
<block wx:if="{{item.baike_info.image_url}}">
<view class="cu-avatar lg" style="background-image:url({{item.baike_info.image_url}});"></view>
</block>
<block wx:else>
<view class="cu-avatar lg"
style="background-image:url(https://wximage-1251091977.cos.ap-beijing.myqcloud.com/xai/error.png);"></view>
</block>
<view class="content">
<view class="text-black">{{item.name}} 年份:{{item.year}}</view>
<view class="text-gray text-sm flex">
<text>
<text class="margin-right-xs"></text>
可信度{{item.score}}%
</text>
</view>
</view>
<view class="action">
<view class="cu-tag round bg-xsblue lg" bindtap="showDetail" data-name="{{item.name}}"
data-description="{{item.baike_info.description}}">介绍
</view>
</view>
</view>
</block>
</view>
</block>
<!--温馨提示-->
<view>
<!--温馨提示-->
<view>
<text class='reason_txt'>温馨提示</text>
<view class='reminder-content'>1.上传图片最好包含车辆</view>
<view class='reminder-content'>2.点击介绍可查看百科信息</view>
......@@ -51,9 +60,9 @@
</view>
<!--浮动按钮跳转主页-->
<view class="round-click">
<navigator url='/pages/index/index' open-type="switchTab">
<image src="../../../images/tabbar/index_cur.png"></image>
</navigator >
<navigator url='/pages/index/index' open-type="switchTab">
<image src="../../../images/tabbar/index_cur.png"></image>
</navigator>
</view>
<!--给一个高度让内显示完整-->
<view class="cu-tabbar-height"></view>
......@@ -23,6 +23,30 @@ Page({
path: '/pages/bizz/clothing/clothing'
}
},
//从聊天页面选择图片
chooseMessage:function(){
var that = this;
wx.chooseMessageFile({
count: 1,
sizeType: ['compressed'],
type:'image',
success(res){
if (res.tempFiles[0].size > (4096 * 1024)) {
wx.showToast({
title: '图片文件过大哦',
icon: 'none',
mask: true,
duration: 1500
})
} else {
that.setData({
img: res.tempFiles[0].path
})
that.generalDetect(res.tempFiles[0].path);
}
}
})
},
//请求方法
uploads: function () {
var that = this
......@@ -49,58 +73,8 @@ Page({
duration: 150088888
})
} else {
wx.showLoading({
title: "分析中...",
mask: true
}),
that.setData({
img: res.tempFilePaths[0]
})
that.generalDetect(res.tempFilePaths[0]);
}
api.generalRequest(res.tempFilePaths[0], app.globalData.userId, api.clothing_url, {
success(result) {
var resultJ = JSON.parse(result)
wx.hideLoading();
if (resultJ.code == 200) {
that.setData({
clothing: resultJ.data.outfits
})
} else {
if (resultJ.code == 87014) {
wx.hideLoading();
wx.showModal({
content: '存在敏感内容,请更换图片',
showCancel: false,
confirmText: '明白了'
})
that.setData({
img: null
})
} else if (resultJ.code == 10006){
wx.hideLoading();
wx.showModal({
content: '找不到合适的搭配',
showCancel: false,
confirmText: '明白了'
})
} else if (resultJ.code == 10007) {
wx.hideLoading();
wx.showModal({
content: '找不到合适的搭配',
showCancel: false,
confirmText: '明白了'
})
} else {
wx.hideLoading();
wx.showModal({
content: resultJ.msg_zh,
showCancel: false,
confirmText: '明白了'
})
}
}
}
})
},
})
},
......@@ -110,6 +84,61 @@ Page({
onLoad: function (options) {
},
//通用识别
generalDetect(file){
var that = this;
that.setData({
img: file
})
wx.showLoading({
title: "搭配分析中...",
mask: true
}),
api.generalRequest(file, app.globalData.userId, api.clothing_url, {
success(result) {
var resultJ = JSON.parse(result)
wx.hideLoading();
if (resultJ.code == 200) {
that.setData({
clothing: resultJ.data.outfits
})
} else {
if (resultJ.code == 87014) {
wx.hideLoading();
wx.showModal({
content: '存在敏感内容,请更换图片',
showCancel: false,
confirmText: '明白了'
})
that.setData({
img: null
})
} else if (resultJ.code == 10006){
wx.hideLoading();
wx.showModal({
content: '找不到合适的搭配',
showCancel: false,
confirmText: '明白了'
})
} else if (resultJ.code == 10007) {
wx.hideLoading();
wx.showModal({
content: '找不到合适的搭配',
showCancel: false,
confirmText: '明白了'
})
} else {
wx.hideLoading();
wx.showModal({
content: resultJ.msg_zh,
showCancel: false,
confirmText: '明白了'
})
}
}
}
})
},
/**
* 生命周期函数--监听页面初次渲染完成
......@@ -201,4 +230,4 @@ Page({
})
}
}
})
\ No newline at end of file
})
<cu-custom bgColor="bg-gradual-blue" isBack="{{true}}">
<view slot="backText">返回</view>
<view slot="content">穿衣搭配</view>
<view slot="backText">返回</view>
<view slot="content">穿衣搭配</view>
</cu-custom>
<view class="page-body">
<view class="page-body-wrapper">
<image src="{{ img }}" style="width:100%;height:400rpx;" id="imageDom" mode='aspectFit'/>
</view>
<view class="padding flex flex-direction">
<button class="cu-btn bg-xsblue margin-tb-sm lg" bindtap="uploads">拍照/选取图片</button>
</view>
<view class="page-body-wrapper">
<image src="{{ img }}" style="width:100%;height:400rpx;" id="imageDom" mode='aspectFit'/>
</view>
<view class="padding flex flex-direction">
<button class="cu-btn bg-xsblue margin-tb-sm lg" bindtap="uploads">拍照/选取图片</button>
<!--从聊天中选择-->
<view class="text-center text-grey text-lg" style="text-decoration:underline;" bindtap="chooseMessage">
<view>从聊天中选择</view>
</view>
</view>
</view>
<!--穿衣搭配-->
<!--穿衣搭配-->
<block wx:if="{{clothing}}" wx:for="{{clothing}}" wx:key="{{index}}" wx:for-item="item">
<view class="cu-bar bg-white margin-top solid-bottom">
<view class="action">
<text class="cuIcon-title text-xsblue"></text> 第{{index+1}}套--搭配分数:{{item.score}}
</view>
</view>
<view class="cu-list grid col-2 no-border">
<block wx:for="{{item.items}}" wx:key='index' wx:for-item="itemData">
<view class="cu-item">
<image src="{{itemData.image_url}}" class="productImg" mode="aspectFill"></image>
<text class="text-sm">{{itemData.item_name}}</text>
<view class="cu-bar bg-white margin-top solid-bottom">
<view class="action">
<text class="cuIcon-title text-xsblue"></text>
第{{index+1}}套--搭配分数:{{item.score}}
</view>
</view>
<view class="cu-list grid col-2 no-border">
<block wx:for="{{item.items}}" wx:key='index' wx:for-item="itemData">
<view class="cu-item">
<image src="{{itemData.image_url}}" class="productImg" mode="aspectFill"></image>
<text class="text-sm">{{itemData.item_name}}</text>
</view>
</block>
</view>
</block>
</view>
</block>
<!--温馨提示-->
<view>
</block>
<!--温馨提示-->
<view>
<text class='reason_txt'>温馨提示</text>
<view class='reminder-content'>1.上传图片中最好包含服装</view>
<view class='reminder-content'>2.结果仅供参考,默认最大10套搭配推荐</view>
</view>
<!--浮动按钮跳转主页-->
<view class="round-click">
<navigator url='/pages/index/index' open-type="switchTab">
<image src="../../../images/tabbar/index_cur.png"></image>
</navigator >
<navigator url='/pages/index/index' open-type="switchTab">
<image src="../../../images/tabbar/index_cur.png"></image>
</navigator>
</view>
<!--给一个高度让内显示完整-->
<view class="cu-tabbar-height"></view>
......@@ -28,6 +28,30 @@ Page({
*/
onLoad: function (options) {
},
//从聊天页面选择图片
chooseMessage:function(){
var that = this;
wx.chooseMessageFile({
count: 1,
sizeType: ['compressed'],
type:'image',
success(res){
if (res.tempFiles[0].size > (4096 * 1024)) {
wx.showToast({
title: '图片文件过大哦',
icon: 'none',
mask: true,
duration: 1500
})
} else {
that.setData({
img: res.tempFiles[0].path
})
that.generalDetect(res.tempFiles[0].path);
}
}
})
},
//请求方法
uploads: function () {
......@@ -55,45 +79,50 @@ Page({
duration: 1500
})
} else {
wx.showLoading({
title: "分析中...",
mask: true
}),
that.generalDetect(res.tempFilePaths[0]);
}
},
})
},
//通用识别
generalDetect(file){
var that = this;
that.setData({
img: file
})
wx.showLoading({
title: "颜色识别中...",
mask: true
}),
api.generalRequest(file, app.globalData.userId, api.color_url, {
success(result) {
var resultJ = JSON.parse(result)
wx.hideLoading();
if (resultJ.code == 200) {
that.setData({
colors: resultJ.data.color_list
})
} else {
if (resultJ.code == 87014) {
wx.hideLoading();
wx.showModal({
content: '存在敏感内容,请更换图片',
showCancel: false,
confirmText: '明白了'
})
that.setData({
img: res.tempFilePaths[0]
img: null
})
}
api.generalRequest(res.tempFilePaths[0], app.globalData.userId, api.color_url, {
success(result) {
var resultJ = JSON.parse(result)
} else {
wx.hideLoading();
if (resultJ.code == 200) {
that.setData({
colors: resultJ.data.color_list
})
} else {
if (resultJ.code == 87014) {
wx.hideLoading();
wx.showModal({
content: '存在敏感内容,请更换图片',
showCancel: false,
confirmText: '明白了'
})
that.setData({
img: null
})
} else {
wx.hideLoading();
wx.showModal({
content: resultJ.msg_zh,
showCancel: false,
confirmText: '明白了'
})
}
}
wx.showModal({
content: resultJ.msg_zh,
showCancel: false,
confirmText: '明白了'
})
}
})
},
}
}
})
},
/**
......@@ -164,4 +193,4 @@ Page({
}
})
}
})
\ No newline at end of file
})
<cu-custom bgColor="bg-gradual-blue" isBack="{{true}}">
<view slot="backText">返回</view>
<view slot="content">颜色识别</view>
<view slot="backText">返回</view>
<view slot="content">颜色识别</view>
</cu-custom>
<view class="page-body">
<view class="page-body-wrapper">
<image src="{{ img }}" style="width:100%;height:400rpx;" id="imageDom" mode='aspectFit'/>
</view>
<view class="padding flex flex-direction">
<button class="cu-btn bg-xsblue margin-tb-sm lg" bindtap="uploads">拍照/选取图片</button>
</view>
<view class="page-body-wrapper">
<image src="{{ img }}" style="width:100%;height:400rpx;" id="imageDom" mode='aspectFit'/>
</view>
<view class="padding flex flex-direction">
<button class="cu-btn bg-xsblue margin-tb-sm lg" bindtap="uploads">拍照/选取图片</button>
<!--从聊天中选择-->
<view class="text-center text-grey text-lg" style="text-decoration:underline;" bindtap="chooseMessage">
<view>从聊天中选择</view>
</view>
</view>
</view>
<block wx:if="{{colors}}">
<view class="cu-bar bg-white solid-bottom">
<view class="action">
<text class="cuIcon-title text-blue"></text>颜色识别结果
</view>
</view>
<view class="grid col-3 padding-sm">
<view class="padding-sm" wx:for="{{colors}}" wx:key>
<view class="padding radius text-center shadow-blur" bindtap="copyText" style="background-color:{{item.hex}}" data-rgb="{{item.rgb}}" data-hex="{{item.hex}}"></view>
<view class="text-sm padding-top-sm">HEX:{{item.hex}}</view>
<view class="text-sm">RGB:{{item.rgb}}</view>
<view class="text-sm">颜色占比:{{item.percentage}}</view>
</view>
</view>
<view class="cu-bar bg-white solid-bottom">
<view class="action">
<text class="cuIcon-title text-blue"></text>颜色识别结果
</view>
</view>
<view class="grid col-3 padding-sm">
<view class="padding-sm" wx:for="{{colors}}" wx:key>
<view class="padding radius text-center shadow-blur" bindtap="copyText"
style="background-color:{{item.hex}}" data-rgb="{{item.rgb}}" data-hex="{{item.hex}}"></view>
<view class="text-sm padding-top-sm">HEX:{{item.hex}}</view>
<view class="text-sm">RGB:{{item.rgb}}</view>
<view class="text-sm">颜色占比:{{item.percentage}}</view>
</view>
</view>
</block>
<!--温馨提示-->
<view>
<!--温馨提示-->
<view>
<text class='reason_txt'>温馨提示</text>
<view class='reminder-content'>1.颜色结果仅供参考</view>
<view class='reminder-content'>2.点击颜色块可复制RGB、HEX</view>
</view>
<!--浮动按钮跳转主页-->
<view class="round-click">
<navigator url='/pages/index/index' open-type="switchTab">
<image src="../../../images/tabbar/index_cur.png"></image>
</navigator >
<navigator url='/pages/index/index' open-type="switchTab">
<image src="../../../images/tabbar/index_cur.png"></image>
</navigator>
</view>
<!--给一个高度让内显示完整-->
<view class="cu-tabbar-height"></view>
......@@ -33,6 +33,30 @@ Page({
wx.navigateTo({
url: '../logs/logs'
})
},
//从聊天页面选择图片
chooseMessage:function(){
var that = this;
wx.chooseMessageFile({
count: 1,
sizeType: ['compressed'],
type:'image',
success(res){
if (res.tempFiles[0].size > (4096 * 1024)) {
wx.showToast({
title: '图片文件过大哦',
icon: 'none',
mask: true,
duration: 1500
})
} else {
that.setData({
img: res.tempFiles[0].path
})
that.icrDetect(res.tempFiles[0].path);
}
}
})
},
//请求方法
uploads: function () {
......@@ -60,45 +84,51 @@ Page({
duration: 1500
})
} else {
wx.showLoading({
title: "上色中...",
mask: true
}),
that.icrDetect(res.tempFilePaths[0]);
}
},
})
},
//黑白图上色
icrDetect(file){
var that = this;
that.setData({
img: file
}),
wx.showLoading({
title: "上色中...",
mask: true
}),
api.icrHandleRequest(file, app.globalData.userId, 'colourize', {
success(result) {
var resultJ = JSON.parse(result)
wx.hideLoading();
if (resultJ.code == 200) {
that.setData({
img: 'data:image/jpg;base64,' + resultJ.deal_base64
})
} else {
if (resultJ.code == 87014) {
wx.hideLoading();
wx.showModal({
content: '存在敏感内容,请更换图片',
showCancel: false,
confirmText: '明白了'
})
that.setData({
img: res.tempFilePaths[0]
img: null
})
}
api.icrHandleRequest(res.tempFilePaths[0], app.globalData.userId, 'colourize', {
success(result) {
var resultJ = JSON.parse(result)
} else {
wx.hideLoading();
if (resultJ.code == 200) {
that.setData({
img: 'data:image/jpg;base64,' + resultJ.deal_base64
})
} else {
if (resultJ.code == 87014) {
wx.hideLoading();
wx.showModal({
content: '存在敏感内容,请更换图片',
showCancel: false,
confirmText: '明白了'
})
that.setData({
img: null
})
} else {
wx.hideLoading();
wx.showModal({
content: resultJ.msg_zh,
showCancel: false,
confirmText: '明白了'
})
}
}
wx.showModal({
content: resultJ.msg_zh,
showCancel: false,
confirmText: '明白了'
})
}
})
},
}
}
})
},
onLoad: function () {
......@@ -122,4 +152,4 @@ Page({
})
}
}
});
\ No newline at end of file
});
<cu-custom bgColor="bg-gradual-blue" isBack="{{true}}">
<view slot="backText">返回</view>
<view slot="content">黑白图上色</view>
<view slot="backText">返回</view>
<view slot="content">黑白图上色</view>
</cu-custom>
<view class="page-body">
<view class="page-body-wrapper">
<image src="{{ img }}" bindtap='preview' style="width:100%;height:400rpx;" id="imageDom" mode='aspectFit'/>
</view>
<view class="padding flex flex-direction">
<button class="cu-btn bg-xsblue margin-tb-sm lg" bindtap="uploads">拍照/选取图片</button>
<view class="page-body-wrapper">
<image src="{{ img }}" bindtap='preview' style="width:100%;height:400rpx;" id="imageDom" mode='aspectFit'/>
</view>
<view class="padding flex flex-direction">
<button class="cu-btn bg-xsblue margin-tb-sm lg" bindtap="uploads">拍照/选取图片</button>
<!--从聊天中选择-->
<view class="text-center text-grey text-lg" style="text-decoration:underline;" bindtap="chooseMessage">
<view>从聊天中选择</view>
</view>
</view>
</view>
</view>
<!--温馨提示-->
<view>
<!--温馨提示-->
<view>
<text class='reason_txt'>温馨提示</text>
<view class='reminder-content'>1.上传图片最好为黑白色调,长宽比3:1以内</view>
<view class='reminder-content'>2.上色效果仅供参考</view>
</view>
<!--浮动按钮跳转主页-->
<view class="round-click">
<navigator url='/pages/index/index' open-type="switchTab">
<image src="../../../images/tabbar/index_cur.png"></image>
</navigator >
<navigator url='/pages/index/index' open-type="switchTab">
<image src="../../../images/tabbar/index_cur.png"></image>
</navigator>
</view>
<!--给一个高度让内显示完整-->
<view class="cu-tabbar-height"></view>
......@@ -33,6 +33,30 @@ Page({
wx.navigateTo({
url: '../logs/logs'
})
},
//从聊天页面选择图片
chooseMessage:function(){
var that = this;
wx.chooseMessageFile({
count: 1,
sizeType: ['compressed'],
type:'image',
success(res){
if (res.tempFiles[0].size > (4096 * 1024)) {
wx.showToast({
title: '图片文件过大哦',
icon: 'none',
mask: true,
duration: 1500
})
} else {
that.setData({
img: res.tempFiles[0].path
})
that.icrDetect(res.tempFiles[0].path);
}
}
})
},
//请求方法
uploads: function () {
......@@ -60,46 +84,53 @@ Page({
duration: 1500
})
} else {
wx.showLoading({
title: "识别中...",
mask: true
}),
that.icrDetect(res.tempFilePaths[0]);
}
},
})
},
//货币识别
icrDetect(file){
var that = this;
that.setData({
img: file
}),
wx.showLoading({
title: "货币识别中...",
mask: true
}),
api.icrRequest(file, app.globalData.userId, 'currency', {
success(result) {
var resultJ = JSON.parse(result)
wx.hideLoading();
if (resultJ.code == 200) {
that.setData({
resultData: resultJ.data
})
} else {
if (resultJ.code == 87014) {
wx.hideLoading();
wx.showModal({
content: '存在敏感内容,请更换图片',
showCancel: false,
confirmText: '明白了'
})
that.setData({
img: res.tempFilePaths[0]
img: null
})
}
api.icrRequest(res.tempFilePaths[0], app.globalData.userId, 'currency', {
success(result) {
var resultJ = JSON.parse(result)
} else {
wx.hideLoading();
if (resultJ.code == 200) {
that.setData({
resultData: resultJ.data
})
} else {
if (resultJ.code == 87014) {
wx.hideLoading();
wx.showModal({
content: '存在敏感内容,请更换图片',
showCancel: false,
confirmText: '明白了'
})
that.setData({
img: null
})
} else {
wx.hideLoading();
wx.showModal({
content: resultJ.msg_zh,
showCancel: false,
confirmText: '明白了'
})
}
}
wx.showModal({
content: resultJ.msg_zh,
showCancel: false,
confirmText: '明白了'
})
}
})
},
}
}
})
},
onLoad: function () {
},
......@@ -122,4 +153,4 @@ Page({
})
}
}
});
\ No newline at end of file
});
<cu-custom bgColor="bg-gradual-blue" isBack="{{true}}">
<view slot="backText">返回</view>
<view slot="content">货币识别</view>
<view slot="backText">返回</view>
<view slot="content">货币识别</view>
</cu-custom>
<view class="page-body">
<view class="page-body-wrapper">
<image src="{{ img }}" bindtap='preview' style="width:100%;height:400rpx;" id="imageDom" mode='aspectFit'/>
</view>
<view class="padding flex flex-direction">
<button class="cu-btn bg-xsblue margin-tb-sm lg" bindtap="uploads">拍照/选取图片识别</button>
</view>
<view class="page-body-wrapper">
<image src="{{ img }}" bindtap='preview' style="width:100%;height:400rpx;" id="imageDom" mode='aspectFit'/>
</view>
<view class="padding flex flex-direction">
<button class="cu-btn bg-xsblue margin-tb-sm lg" bindtap="uploads">拍照/选取图片</button>
<!--从聊天中选择-->
<view class="text-center text-grey text-lg" style="text-decoration:underline;" bindtap="chooseMessage">
<view>从聊天中选择</view>
</view>
</view>
</view>
<!--货币名称-->
<block wx:if="{{resultData.currencyName}}">
<view class="cu-bar bg-white margin-top">
<view class="action">
<text class="cuIcon-title text-blue"></text>货币名称
</view>
</view>
<view class="padding-sm flex flex-wrap">
<view class="padding-xs">
<view class="text-lg" style="word-break:break-all;display:block;white-space:pre-wrap;">{{resultData.currencyName}}</view>
</view>
</view>
<view class="cu-bar bg-white margin-top">
<view class="action">
<text class="cuIcon-title text-blue"></text>
货币名称
</view>
</view>
<view class="padding-sm flex flex-wrap">
<view class="padding-xs">
<view class="text-lg" style="word-break:break-all;display:block;white-space:pre-wrap;">
{{resultData.currencyName}}
</view>
</view>
</view>
</block>
<!--货币代码-->
<block wx:if="{{resultData.currencyCode}}">
<view class="cu-bar bg-white margin-top">
<view class="action">
<text class="cuIcon-title text-blue"></text>货币代码
</view>
</view>
<view class="padding-sm flex flex-wrap">
<view class="padding-xs">
<view class="text-lg" style="word-break:break-all;display:block;white-space:pre-wrap;">{{resultData.currencyCode}}</view>
</view>
</view>
<view class="cu-bar bg-white margin-top">
<view class="action">
<text class="cuIcon-title text-blue"></text>
货币代码
</view>
</view>
<view class="padding-sm flex flex-wrap">
<view class="padding-xs">
<view class="text-lg" style="word-break:break-all;display:block;white-space:pre-wrap;">
{{resultData.currencyCode}}
</view>
</view>
</view>
</block>
<!--货币面值-->
<block wx:if="{{resultData.currencyDenomination}}">
<view class="cu-bar bg-white margin-top">
<view class="action">
<text class="cuIcon-title text-blue"></text>货币面值
</view>
</view>
<view class="padding-sm flex flex-wrap">
<view class="padding-xs">
<view class="text-lg" style="word-break:break-all;display:block;white-space:pre-wrap;">{{resultData.currencyDenomination}}</view>
</view>
</view>
<view class="cu-bar bg-white margin-top">
<view class="action">
<text class="cuIcon-title text-blue"></text>
货币面值
</view>
</view>
<view class="padding-sm flex flex-wrap">
<view class="padding-xs">
<view class="text-lg" style="word-break:break-all;display:block;white-space:pre-wrap;">
{{resultData.currencyDenomination}}
</view>
</view>
</view>
</block>
<!--货币年份-->
<block wx:if="{{resultData.year}}">
<view class="cu-bar bg-white margin-top">
<view class="action">
<text class="cuIcon-title text-blue"></text>货币年份
</view>
</view>
<view class="padding-sm flex flex-wrap">
<view class="padding-xs">
<view class="text-lg" style="word-break:break-all;display:block;white-space:pre-wrap;">{{resultData.year}}</view>
</view>
</view>
<view class="cu-bar bg-white margin-top">
<view class="action">
<text class="cuIcon-title text-blue"></text>
货币年份
</view>
</view>
<view class="padding-sm flex flex-wrap">
<view class="padding-xs">
<view class="text-lg" style="word-break:break-all;display:block;white-space:pre-wrap;">{{resultData.year}}
</view>
</view>
</view>
</block>
<!--温馨提示-->
<view>
<!--温馨提示-->
<view>
<text class='reason_txt'>温馨提示</text>
<view class='reminder-content'>1.上传图片最好包含钱币</view>
<view class='reminder-content'>2.可识别百余种国内外常见货币</view>
</view>
<!--浮动按钮跳转主页-->
<view class="round-click">
<navigator url='/pages/index/index' open-type="switchTab">
<image src="../../../images/tabbar/index_cur.png"></image>
</navigator >
<navigator url='/pages/index/index' open-type="switchTab">
<image src="../../../images/tabbar/index_cur.png"></image>
</navigator>
</view>
<!--给一个高度让内显示完整-->
<view class="cu-tabbar-height"></view>
......@@ -64,6 +64,30 @@ Page({
wx.navigateTo({
url: '../logs/logs'
})
},
//从聊天页面选择图片
chooseMessage:function(){
var that = this;
wx.chooseMessageFile({
count: 1,
sizeType: ['compressed'],
type:'image',
success(res){
if (res.tempFiles[0].size > (4096 * 1024)) {
wx.showToast({
title: '图片文件过大哦',
icon: 'none',
mask: true,
duration: 1500
})
} else {
that.setData({
img: res.tempFiles[0].path
})
that.icrDetect(res.tempFiles[0].path);
}
}
})
},
//请求方法
uploads: function () {
......@@ -91,45 +115,50 @@ Page({
duration: 1500
})
} else {
wx.showLoading({
title: "识别中...",
mask: true
}),
that.icrDetect(res.tempFilePaths[0]);
}
},
})
},
//菜品识别
icrDetect(file){
var that = this;
that.setData({
img: file
}),
wx.showLoading({
title: "菜品识别中...",
mask: true
}),
api.icrRequest(file, app.globalData.userId, 'dish', {
success(result) {
var resultJ = JSON.parse(result)
wx.hideLoading();
if (resultJ.code == 200) {
that.setData({
resultData: resultJ.result
})
} else {
if (resultJ.code == 87014) {
wx.hideLoading();
wx.showModal({
content: '存在敏感内容,请更换图片',
showCancel: false,
confirmText: '明白了'
})
that.setData({
img: res.tempFilePaths[0]
img: null
})
}
api.icrRequest(res.tempFilePaths[0], app.globalData.userId, 'dish', {
success(result) {
var resultJ = JSON.parse(result)
} else {
wx.hideLoading();
if (resultJ.code == 200) {
that.setData({
resultData: resultJ.result
})
} else {
if (resultJ.code == 87014) {
wx.hideLoading();
wx.showModal({
content: '存在敏感内容,请更换图片',
showCancel: false,
confirmText: '明白了'
})
that.setData({
img: null
})
} else {
wx.hideLoading();
wx.showModal({
content: resultJ.msg_zh,
showCancel: false,
confirmText: '明白了'
})
}
}
wx.showModal({
content: resultJ.msg_zh,
showCancel: false,
confirmText: '明白了'
})
}
})
},
}
}
})
},
onLoad: function () {
......@@ -144,4 +173,4 @@ Page({
current: that.data.img
})
}
});
\ No newline at end of file
});
<cu-custom bgColor="bg-gradual-blue" isBack="{{true}}">
<view slot="backText">返回</view>
<view slot="content">菜品识别</view>
<view slot="backText">返回</view>
<view slot="content">菜品识别</view>
</cu-custom>
<view class="page-body">
<view class="page-body-wrapper">
<image src="{{ img }}" bindtap='preview' style="width:100%;height:400rpx;" id="imageDom" mode='aspectFit'/>
</view>
<view class="padding flex flex-direction">
<button class="cu-btn bg-xsblue margin-tb-sm lg" bindtap="uploads">拍照/选取图片识别</button>
</view>
<view class="page-body-wrapper">
<image src="{{ img }}" bindtap='preview' style="width:100%;height:400rpx;" id="imageDom" mode='aspectFit'/>
</view>
<view class="padding flex flex-direction">
<button class="cu-btn bg-xsblue margin-tb-sm lg" bindtap="uploads">拍照/选取图片</button>
<!--从聊天中选择-->
<view class="text-center text-grey text-lg" style="text-decoration:underline;" bindtap="chooseMessage">
<view>从聊天中选择</view>
</view>
</view>
</view>
<!--查询详情-->
<block wx:if="{{resultData}}">
<view class="cu-bar bg-white solid-bottom margin-top">
<view class="action">
<text class="cuIcon-title text-xsblue "></text>菜品识别结果
</view>
</view>
<!--菜品识别列表-->
<view class="cu-list menu-avatar">
<block wx:for="{{resultData}}">
<view class="cu-item">
<block wx:if="{{item.baike_info.image_url}}">
<view class="cu-avatar lg" style="background-image:url({{item.baike_info.image_url}});"></view>
</block>
<block wx:else>
<view class="cu-avatar lg" style="background-image:url(https://wximage-1251091977.cos.ap-beijing.myqcloud.com/xai/error.png);"></view>
</block>
<view class="content">
<view class="text-black">{{item.name}}<block wx:if="{{item.has_calorie==true}}">--卡路里:{{item.calorie}}KJ/100g</block></view>
<view class="text-gray text-sm flex">
<text>
<text class="margin-right-xs blod">可信度{{item.probability}}%</text>
</text>
<view class="cu-bar bg-white solid-bottom margin-top">
<view class="action">
<text class="cuIcon-title text-xsblue "></text>
菜品识别结果
</view>
</view>
<view class="action">
<view class="cu-tag round bg-xsblue lg" bindtap="showDetail" data-name="{{item.name}}" data-description="{{item.baike_info.description}}">介绍</view>
</view>
</view>
</block>
</view>
<!--菜品识别列表-->
<view class="cu-list menu-avatar">
<block wx:for="{{resultData}}">
<view class="cu-item">
<block wx:if="{{item.baike_info.image_url}}">
<view class="cu-avatar lg" style="background-image:url({{item.baike_info.image_url}});"></view>
</block>
<block wx:else>
<view class="cu-avatar lg"
style="background-image:url(https://wximage-1251091977.cos.ap-beijing.myqcloud.com/xai/error.png);"></view>
</block>
<view class="content">
<view class="text-black">{{item.name}}
<block wx:if="{{item.has_calorie==true}}">--卡路里:{{item.calorie}}KJ/100g</block>
</view>
<view class="text-gray text-sm flex">
<text>
<text class="margin-right-xs blod">可信度{{item.probability}}%</text>
</text>
</view>
</view>
<view class="action">
<view class="cu-tag round bg-xsblue lg" bindtap="showDetail" data-name="{{item.name}}"
data-description="{{item.baike_info.description}}">介绍
</view>
</view>
</view>
</block>
</view>
</block>
<!--温馨提示-->
<view>
<!--温馨提示-->
<view>
<text class='reason_txt'>温馨提示</text>
<view class='reminder-content'>1.上传图片最好包含菜品</view>
<view class='reminder-content'>2.点击介绍可查看百科信息</view>
......@@ -51,9 +61,9 @@
</view>
<!--浮动按钮跳转主页-->
<view class="round-click">
<navigator url='/pages/index/index' open-type="switchTab">
<image src="../../../images/tabbar/index_cur.png"></image>
</navigator >
<navigator url='/pages/index/index' open-type="switchTab">
<image src="../../../images/tabbar/index_cur.png"></image>
</navigator>
</view>
<!--给一个高度让内显示完整-->
<view class="cu-tabbar-height"></view>
......@@ -30,6 +30,30 @@ Page({
wx.navigateTo({
url: '../logs/logs'
})
},
//从聊天页面选择图片
chooseMessage:function(){
var that = this;
wx.chooseMessageFile({
count: 1,
sizeType: ['compressed'],
type:'image',
success(res){
if (res.tempFiles[0].size > (4096 * 1024)) {
wx.showToast({
title: '图片文件过大哦',
icon: 'none',
mask: true,
duration: 1500
})
} else {
that.setData({
img: res.tempFiles[0].path
})
that.generalDetect(res.tempFiles[0].path);
}
}
})
},
//请求方法
uploads: function () {
......@@ -57,45 +81,50 @@ Page({
duration: 1500
})
} else {
wx.showLoading({
title: "识别中...",
mask: true
}),
that.generalDetect(res.tempFilePaths[0]);
}
},
})
},
//通用识别
generalDetect(file){
var that = this;
that.setData({
img: file
}),
wx.showLoading({
title: "黑眼圈眼袋检测中...",
mask: true
}),
api.generalRequest(file, app.globalData.userId, api.eyesattr_url, {
success(result) {
var resultJ = JSON.parse(result)
wx.hideLoading();
if (resultJ.code == 200) {
that.setData({
img: 'data:image/jpg;base64,' + resultJ.data.image_base64
})
} else {
if (resultJ.code == 87014) {
wx.hideLoading();
wx.showModal({
content: '存在敏感内容,请更换图片',
showCancel: false,
confirmText: '明白了'
})
that.setData({
img: res.tempFilePaths[0]
img: null
})
}
api.generalRequest(res.tempFilePaths[0], app.globalData.userId, api.eyesattr_url, {
success(result) {
var resultJ = JSON.parse(result)
} else {
wx.hideLoading();
if (resultJ.code == 200) {
that.setData({
img: 'data:image/jpg;base64,' + resultJ.data.image_base64
})
} else {
if (resultJ.code == 87014) {
wx.hideLoading();
wx.showModal({
content: '存在敏感内容,请更换图片',
showCancel: false,
confirmText: '明白了'
})
that.setData({
img: null
})
} else {
wx.hideLoading();
wx.showModal({
content: resultJ.msg_zh,
showCancel: false,
confirmText: '明白了'
})
}
}
wx.showModal({
content: resultJ.msg_zh,
showCancel: false,
confirmText: '明白了'
})
}
})
},
}
}
})
},
onLoad: function () {
......@@ -119,4 +148,4 @@ Page({
})
}
}
});
\ No newline at end of file
});
<cu-custom bgColor="bg-gradual-blue" isBack="{{true}}">
<view slot="backText">返回</view>
<view slot="content">黑眼圈眼袋检测</view>
<view slot="backText">返回</view>
<view slot="content">黑眼圈眼袋检测</view>
</cu-custom>
<view class="page-body">
<view class="page-body-wrapper">
<image src="{{ img }}" bindtap='preview' style="width:100%;height:400rpx;" id="imageDom" mode='aspectFit'/>
</view>
<view class="padding flex flex-direction">
<button class="cu-btn bg-xsblue margin-tb-sm lg" bindtap="uploads">拍照/选取图片</button>
<view class="page-body-wrapper">
<image src="{{ img }}" bindtap='preview' style="width:100%;height:400rpx;" id="imageDom" mode='aspectFit'/>
</view>
<view class="padding flex flex-direction">
<button class="cu-btn bg-xsblue margin-tb-sm lg" bindtap="uploads">拍照/选取图片</button>
<!--从聊天中选择-->
<view class="text-center text-grey text-lg" style="text-decoration:underline;" bindtap="chooseMessage">
<view>从聊天中选择</view>
</view>
</view>
</view>
</view>
<!--温馨提示-->
<view>
<!--温馨提示-->
<view>
<text class='reason_txt'>温馨提示</text>
<view class='reminder-content'>1.效果仅供参考 不提供真实性依据</view>
<view class='reminder-content'>2.红色为标注,点击图片可放大查看</view>
</view>
<!--浮动按钮跳转主页-->
<view class="round-click">
<navigator url='/pages/index/index' open-type="switchTab">
<image src="../../../images/tabbar/index_cur.png"></image>
</navigator >
<navigator url='/pages/index/index' open-type="switchTab">
<image src="../../../images/tabbar/index_cur.png"></image>
</navigator>
</view>
<!--给一个高度让内显示完整-->
<view class="cu-tabbar-height"></view>
\ No newline at end of file
<view class="cu-tabbar-height"></view>
......@@ -35,6 +35,30 @@ Page({
url: '../logs/logs'
})
},
//从聊天页面选择图片
chooseMessage:function(){
var that = this;
wx.chooseMessageFile({
count: 1,
sizeType: ['compressed'],
type:'image',
success(res){
if (res.tempFiles[0].size > (4096 * 1024)) {
wx.showToast({
title: '图片文件过大哦',
icon: 'none',
mask: true,
duration: 1500
})
} else {
that.setData({
img: res.tempFiles[0].path
})
that.generalDetect(res.tempFiles[0].path);
}
}
})
},
//请求方法
uploads: function () {
var that = this
......@@ -61,47 +85,52 @@ Page({
duration: 1500
})
} else {
wx.showLoading({
title: "识别中...",
mask: true
}),
that.generalDetect(res.tempFilePaths[0]);
}
},
})
},
//通用识别
generalDetect(file){
var that = this;
that.setData({
img: file
}),
wx.showLoading({
title: "面部分析中...",
mask: true
}),
api.generalRequest(file, app.globalData.userId,api.facedetect_url, {
success(result) {
var resultJ = JSON.parse(result)
wx.hideLoading();
if (resultJ.code == 200) {
that.setData({
resultData: resultJ.data.face_list,
faceNum: resultJ.data.face_num,
img: 'data:image/jpg;base64,' + resultJ.data.deal_image
})
} else {
if (resultJ.code == 87014) {
wx.hideLoading();
wx.showModal({
content: '存在敏感内容,请更换图片',
showCancel: false,
confirmText: '明白了'
})
that.setData({
img: res.tempFilePaths[0]
img: null
})
}
api.generalRequest(res.tempFilePaths[0], app.globalData.userId,api.facedetect_url, {
success(result) {
var resultJ = JSON.parse(result)
} else {
wx.hideLoading();
if (resultJ.code == 200) {
that.setData({
resultData: resultJ.data.face_list,
faceNum: resultJ.data.face_num,
img: 'data:image/jpg;base64,' + resultJ.data.deal_image
})
} else {
if (resultJ.code == 87014) {
wx.hideLoading();
wx.showModal({
content: '存在敏感内容,请更换图片',
showCancel: false,
confirmText: '明白了'
})
that.setData({
img: null
})
} else {
wx.hideLoading();
wx.showModal({
content: resultJ.msg_zh,
showCancel: false,
confirmText: '明白了'
})
}
}
wx.showModal({
content: resultJ.msg_zh,
showCancel: false,
confirmText: '明白了'
})
}
})
},
}
}
})
},
onLoad: function () {
......@@ -116,4 +145,4 @@ Page({
current: that.data.img
})
}
});
\ No newline at end of file
});
......@@ -3,12 +3,16 @@
<view slot="content">颜值估测</view>
</cu-custom>
<view class="page-body">
<view class="page-body-wrapper">
<image src="{{ img }}" bindtap='preview' style="width:100%;height:400rpx;" id="imageDom" mode='aspectFit'/>
</view>
<view class="padding flex flex-direction">
<button class="cu-btn bg-xsblue margin-tb-sm lg" bindtap="uploads">拍照/选取图片识别</button>
</view>
<view class="page-body-wrapper">
<image src="{{ img }}" bindtap='preview' style="width:100%;height:400rpx;" id="imageDom" mode='aspectFit'/>
</view>
<view class="padding flex flex-direction">
<button class="cu-btn bg-xsblue margin-tb-sm lg" bindtap="uploads">拍照/选取图片</button>
<!--从聊天中选择-->
<view class="text-center text-grey text-lg" style="text-decoration:underline;" bindtap="chooseMessage">
<view>从聊天中选择</view>
</view>
</view>
</view>
<!--查询详情-->
<block wx:if="{{resultData}}">
......
......@@ -36,6 +36,35 @@ Page({
path: '/pages/bizz/facemerge/facemerge'
}
},
//从聊天页面选择图片
chooseMessage:function(){
var that = this;
wx.chooseMessageFile({
count: 1,
sizeType: ['compressed'],
type:'image',
success(res){
if (res.tempFiles[0].size > (4096 * 1024)) {
wx.showToast({
title: '图片文件过大哦',
icon: 'none',
mask: true,
duration: 1500
})
} else {
that.setData({
img: res.tempFiles[0].path,
tempFilePath: res.tempFiles[0].path
})
wx.showLoading({
title: "效果生成中...",
mask: true
}),
that.faceMerge();
}
}
})
},
uploads: function () {
var that = this
var takephonewidth
......@@ -198,4 +227,4 @@ Page({
})
}
}
})
\ No newline at end of file
})
......@@ -4,10 +4,14 @@
</cu-custom>
<view class="page-body">
<view class="page-body-wrapper">
<image src="{{img}}" bindtap='preview' style="width:100%;height:400rpx;" id="imageDom" mode='aspectFit' />
<image src="{{img}}" bindtap='preview' style="width:100%;height:400rpx;" id="imageDom" mode='aspectFit'/>
</view>
<view class="padding flex flex-direction">
<button class="cu-btn bg-xsblue margin-tb-sm lg" bindtap="uploads">拍照/选取图片</button>
<!--从聊天中选择-->
<view class="text-center text-grey text-lg" style="text-decoration:underline;" bindtap="chooseMessage">
<view>从聊天中选择</view>
</view>
</view>
<!--模板图-->
<view class="cu-bar tabbar bg-white shadow foot">
......@@ -36,4 +40,4 @@
</navigator >
</view>
<!--给一个高度让内显示完整-->
<view class="cu-tabbar-height"></view>
\ No newline at end of file
<view class="cu-tabbar-height"></view>
......@@ -40,6 +40,30 @@ Page({
wx.navigateTo({
url: '../logs/logs'
})
},
//从聊天页面选择图片
chooseMessage:function(){
var that = this;
wx.chooseMessageFile({
count: 1,
sizeType: ['compressed'],
type:'image',
success(res){
if (res.tempFiles[0].size > (4096 * 1024)) {
wx.showToast({
title: '图片文件过大哦',
icon: 'none',
mask: true,
duration: 1500
})
} else {
that.setData({
img: res.tempFiles[0].path
})
that.generalDetect(res.tempFiles[0].path);
}
}
})
},
//请求方法
uploads: function () {
......@@ -67,54 +91,59 @@ Page({
duration: 1500
})
} else {
wx.showLoading({
title: "分析中...",
mask: true
}),
that.generalDetect(res.tempFilePaths[0]);
}
},
})
},
//面相识别
generalDetect(file){
var that = this;
that.setData({
img: file
}),
wx.showLoading({
title: "面相分析中...",
mask: true
}),
api.faceOrgansRequest(file, app.globalData.userId,{
success(result){
var resultJ = JSON.parse(result)
wx.hideLoading();
if (resultJ.code==200){
that.setData({
eye: resultJ.eye,
eyebrow: resultJ.eyebrow,
face: resultJ.face,
faceFortune: resultJ.faceFortune,
face_shape: resultJ.face_shape,
lips: resultJ.lips,
nose: resultJ.nose,
skin_color: resultJ.skin_color,
fortune: resultJ.fortune,
faceMessage: resultJ.faceMessage
})
} else {
if (resultJ.code == 87014) {
wx.hideLoading();
wx.showModal({
content: '存在敏感内容,请更换图片',
showCancel: false,
confirmText: '明白了'
})
that.setData({
img: res.tempFilePaths[0]
img: null
})
}
api.faceOrgansRequest(res.tempFilePaths[0], app.globalData.userId,{
success(result){
var resultJ = JSON.parse(result)
} else {
wx.hideLoading();
if (resultJ.code==200){
that.setData({
eye: resultJ.eye,
eyebrow: resultJ.eyebrow,
face: resultJ.face,
faceFortune: resultJ.faceFortune,
face_shape: resultJ.face_shape,
lips: resultJ.lips,
nose: resultJ.nose,
skin_color: resultJ.skin_color,
fortune: resultJ.fortune,
faceMessage: resultJ.faceMessage
})
} else {
if (resultJ.code == 87014) {
wx.hideLoading();
wx.showModal({
content: '存在敏感内容,请更换图片',
showCancel: false,
confirmText: '明白了'
})
that.setData({
img: null
})
} else {
wx.hideLoading();
wx.showModal({
content: resultJ.msg_zh,
showCancel: false,
confirmText: '明白了'
})
}
}
wx.showModal({
content: resultJ.msg_zh,
showCancel: false,
confirmText: '明白了'
})
}
})
},
}
}
})
},
onLoad: function () {
......@@ -129,4 +158,4 @@ Page({
current: that.data.img
})
}
});
\ No newline at end of file
});
<cu-custom bgColor="bg-gradual-blue" isBack="{{true}}">
<view slot="backText">返回</view>
<view slot="content">面相(五官)分析</view>
<view slot="backText">返回</view>
<view slot="content">面相(五官)分析</view>
</cu-custom>
<view class="page-body">
<view class="page-body-wrapper">
<image src="{{ img }}" bindtap='preview' style="width:100%;height:500rpx;" id="imageDom" mode='aspectFit' />
</view>
<view class="padding flex flex-direction">
<button class="cu-btn bg-xsblue margin-tb-sm lg" bindtap="uploads">拍照/选取图片识别</button>
</view>
<view class="page-body-wrapper">
<image src="{{ img }}" bindtap='preview' style="width:100%;height:500rpx;" id="imageDom" mode='aspectFit'/>
</view>
<view class="padding flex flex-direction">
<button class="cu-btn bg-xsblue margin-tb-sm lg" bindtap="uploads">拍照/选取图片</button>
<!--从聊天中选择-->
<view class="text-center text-grey text-lg" style="text-decoration:underline;" bindtap="chooseMessage">
<view>从聊天中选择</view>
</view>
</view>
<!--面相评分-->
<block wx:if="{{face}}">
<view class="cu-bar bg-white solid-bottom margin-top">
......@@ -137,7 +141,7 @@
<view class="cu-list grid col-3 no-border">
<block wx:for="{{faceFortune.plantsList}}" wx:key='index'>
<view class="cu-item" bindtap="detail">
<navigator hover-class="other-navigator-hover" open-type="navigate">
<navigator hover-class="other-navigator-hover" open-type="navigate">
<view>
<image src="{{item.imgUrl}}" class="productImg" mode="aspectFill"></image>
</view>
......@@ -162,4 +166,4 @@
</navigator >
</view>
<!--给一个高度让内显示完整-->
<view class="cu-tabbar-height"></view>
\ No newline at end of file
<view class="cu-tabbar-height"></view>
......@@ -124,6 +124,35 @@ Page({
wx.navigateTo({
url: '../logs/logs'
})
},
//从聊天页面选择图片
chooseMessage:function(){
var that = this;
wx.chooseMessageFile({
count: 1,
sizeType: ['compressed'],
type:'image',
success(res){
if (res.tempFiles[0].size > (4096 * 1024)) {
wx.showToast({
title: '图片文件过大哦',
icon: 'none',
mask: true,
duration: 1500
})
} else {
that.setData({
img: res.tempFiles[0].path,
tempFilePath: res.tempFiles[0].path
}),
wx.showLoading({
title: "虚拟换妆中...",
mask: true
}),
that.faceTransfer();
}
}
})
},
uploads: function () {
var that = this
......@@ -157,9 +186,9 @@ Page({
title: "虚拟换妆中...",
mask: true
}),
that.setData({
img: res.tempFilePaths[0]
})
that.setData({
img: res.tempFilePaths[0]
})
that.faceTransfer();
}
},
......@@ -221,4 +250,4 @@ Page({
})
}
}
});
\ No newline at end of file
});
......@@ -4,10 +4,14 @@
</cu-custom>
<view class="page-body">
<view class="page-body-wrapper">
<image src="{{ img }}" bindtap='preview' style="width:100%;height:400rpx;" id="imageDom" mode='aspectFit' />
<image src="{{ img }}" bindtap='preview' style="width:100%;height:400rpx;" id="imageDom" mode='aspectFit'/>
</view>
<view class="padding flex flex-direction">
<button class="cu-btn bg-xsblue margin-tb-sm lg" bindtap="uploads">拍照/选取图片识别</button>
<button class="cu-btn bg-xsblue margin-tb-sm lg" bindtap="uploads">拍照/选取图片</button>
<!--从聊天中选择-->
<view class="text-center text-grey text-lg" style="text-decoration:underline;" bindtap="chooseMessage">
<view>从聊天中选择</view>
</view>
</view>
<!--模板图类型-->
<scroll-view scroll-x class="bg-white nav padding-top-xs padding-bottom-sm text-df">
......@@ -52,4 +56,4 @@
</navigator >
</view>
<!--给一个高度让内显示完整-->
<view class="cu-tabbar-height"></view>
\ No newline at end of file
<view class="cu-tabbar-height"></view>
......@@ -31,6 +31,30 @@ Page({
wx.navigateTo({
url: '../logs/logs'
})
},
//从聊天页面选择图片
chooseMessage:function(){
var that = this;
wx.chooseMessageFile({
count: 1,
sizeType: ['compressed'],
type:'image',
success(res){
if (res.tempFiles[0].size > (4096 * 1024)) {
wx.showToast({
title: '图片文件过大哦',
icon: 'none',
mask: true,
duration: 1500
})
} else {
that.setData({
img: res.tempFiles[0].path
})
that.generalDetect(res.tempFiles[0].path);
}
}
})
},
//请求方法
uploads: function () {
......@@ -58,46 +82,52 @@ Page({
duration: 1500
})
} else {
wx.showLoading({
title: "识别中...",
mask: true
}),
that.generalDetect(res.tempFilePaths[0]);
}
},
})
},
//通用识别
generalDetect(file){
var that = this;
that.setData({
img: file
}),
wx.showLoading({
title: "皱纹检测中...",
mask: true
}),
api.generalRequest(file, app.globalData.userId, api.facewrinkle_url, {
success(result) {
var resultJ = JSON.parse(result)
wx.hideLoading();
if (resultJ.code == 200) {
that.setData({
img: 'data:image/jpg;base64,' + resultJ.data.image_base64,
wrinkle_num: resultJ.data.wrinkle_num
})
} else {
if (resultJ.code == 87014) {
wx.hideLoading();
wx.showModal({
content: '存在敏感内容,请更换图片',
showCancel: false,
confirmText: '明白了'
})
that.setData({
img: res.tempFilePaths[0]
img: null
})
}
api.generalRequest(res.tempFilePaths[0], app.globalData.userId, api.facewrinkle_url, {
success(result) {
var resultJ = JSON.parse(result)
} else {
wx.hideLoading();
if (resultJ.code == 200) {
that.setData({
img: 'data:image/jpg;base64,' + resultJ.data.image_base64,
wrinkle_num: resultJ.data.wrinkle_num
})
} else {
if (resultJ.code == 87014) {
wx.hideLoading();
wx.showModal({
content: '存在敏感内容,请更换图片',
showCancel: false,
confirmText: '明白了'
})
that.setData({
img: null
})
} else {
wx.hideLoading();
wx.showModal({
content: resultJ.msg_zh,
showCancel: false,
confirmText: '明白了'
})
}
}
wx.showModal({
content: resultJ.msg_zh,
showCancel: false,
confirmText: '明白了'
})
}
})
},
}
}
})
},
onLoad: function () {
......@@ -121,4 +151,4 @@ Page({
})
}
}
});
\ No newline at end of file
});
<cu-custom bgColor="bg-gradual-blue" isBack="{{true}}">
<view slot="backText">返回</view>
<view slot="content">皱纹检测</view>
<view slot="backText">返回</view>
<view slot="content">皱纹检测</view>
</cu-custom>
<view class="page-body">
<view class="page-body-wrapper">
<image src="{{ img }}" bindtap='preview' style="width:100%;height:400rpx;" id="imageDom" mode='aspectFit'/>
</view>
<view class="padding flex flex-direction">
<button class="cu-btn bg-xsblue margin-tb-sm lg" bindtap="uploads">拍照/选取图片</button>
</view>
<view class="page-body-wrapper">
<image src="{{ img }}" bindtap='preview' style="width:100%;height:400rpx;" id="imageDom" mode='aspectFit'/>
</view>
<view class="padding flex flex-direction">
<button class="cu-btn bg-xsblue margin-tb-sm lg" bindtap="uploads">拍照/选取图片</button>
<!--从聊天中选择-->
<view class="text-center text-grey text-lg" style="text-decoration:underline;" bindtap="chooseMessage">
<view>从聊天中选择</view>
</view>
</view>
<!--检测结果-->
<view class="cu-bar bg-white margin-top">
<view class="action">
......@@ -31,4 +35,4 @@
</navigator >
</view>
<!--给一个高度让内显示完整-->
<view class="cu-tabbar-height"></view>
\ No newline at end of file
<view class="cu-tabbar-height"></view>
......@@ -64,6 +64,30 @@ Page({
wx.navigateTo({
url: '../logs/logs'
})
},
//从聊天页面选择图片
chooseMessage:function(){
var that = this;
wx.chooseMessageFile({
count: 1,
sizeType: ['compressed'],
type:'image',
success(res){
if (res.tempFiles[0].size > (4096 * 1024)) {
wx.showToast({
title: '图片文件过大哦',
icon: 'none',
mask: true,
duration: 1500
})
} else {
that.setData({
img: res.tempFiles[0].path
})
that.icrDetect(res.tempFiles[0].path);
}
}
})
},
//请求方法
uploads: function () {
......@@ -91,45 +115,50 @@ Page({
duration: 1500
})
} else {
wx.showLoading({
title: "识别中...",
mask: true
}),
that.icrDetect(res.tempFilePaths[0]);
}
},
})
},
//花卉识别
icrDetect(file){
var that = this;
that.setData({
img: file
}),
wx.showLoading({
title: "花卉识别中...",
mask: true
}),
api.icrRequest(file, app.globalData.userId, 'flower', {
success(result) {
var resultJ = JSON.parse(result)
wx.hideLoading();
if (resultJ.code == 200) {
that.setData({
resultData: resultJ.result
})
} else {
if (resultJ.code == 87014) {
wx.hideLoading();
wx.showModal({
content: '存在敏感内容,请更换图片',
showCancel: false,
confirmText: '明白了'
})
that.setData({
img: res.tempFilePaths[0]
img: null
})
}
api.icrRequest(res.tempFilePaths[0], app.globalData.userId, 'flower', {
success(result) {
var resultJ = JSON.parse(result)
} else {
wx.hideLoading();
if (resultJ.code == 200) {
that.setData({
resultData: resultJ.result
})
} else {
if (resultJ.code == 87014) {
wx.hideLoading();
wx.showModal({
content: '存在敏感内容,请更换图片',
showCancel: false,
confirmText: '明白了'
})
that.setData({
img: null
})
} else {
wx.hideLoading();
wx.showModal({
content: resultJ.msg_zh,
showCancel: false,
confirmText: '明白了'
})
}
}
wx.showModal({
content: resultJ.msg_zh,
showCancel: false,
confirmText: '明白了'
})
}
})
},
}
}
})
},
onLoad: function () {
......@@ -144,4 +173,4 @@ Page({
current: that.data.img
})
}
});
\ No newline at end of file
});
<cu-custom bgColor="bg-gradual-blue" isBack="{{true}}">
<view slot="backText">返回</view>
<view slot="content">花卉识别</view>
<view slot="backText">返回</view>
<view slot="content">花卉识别</view>
</cu-custom>
<view class="page-body">
<view class="page-body-wrapper">
<image src="{{ img }}" bindtap='preview' style="width:100%;height:400rpx;" id="imageDom" mode='aspectFit'/>
</view>
<view class="padding flex flex-direction">
<button class="cu-btn bg-xsblue margin-tb-sm lg" bindtap="uploads">拍照/选取图片识别</button>
</view>
<view class="page-body-wrapper">
<image src="{{ img }}" bindtap='preview' style="width:100%;height:400rpx;" id="imageDom" mode='aspectFit'/>
</view>
<view class="padding flex flex-direction">
<button class="cu-btn bg-xsblue margin-tb-sm lg" bindtap="uploads">拍照/选取图片</button>
<!--从聊天中选择-->
<view class="text-center text-grey text-lg" style="text-decoration:underline;" bindtap="chooseMessage">
<view>从聊天中选择</view>
</view>
</view>
</view>
<!--查询详情-->
<block wx:if="{{resultData}}">
......
......@@ -32,6 +32,30 @@ Page({
wx.navigateTo({
url: '../logs/logs'
})
},
//从聊天页面选择图片
chooseMessage:function(){
var that = this;
wx.chooseMessageFile({
count: 1,
sizeType: ['compressed'],
type:'image',
success(res){
if (res.tempFiles[0].size > (4096 * 1024)) {
wx.showToast({
title: '图片文件过大哦',
icon: 'none',
mask: true,
duration: 1500
})
} else {
that.setData({
img: res.tempFiles[0].path
})
that.generalDetect(res.tempFiles[0].path);
}
}
})
},
//请求方法
uploads: function () {
......@@ -59,45 +83,50 @@ Page({
duration: 1500
})
} else {
wx.showLoading({
title: "分析中...",
mask: true
}),
that.generalDetect(res.tempFilePaths[0]);
}
},
})
},
//垃圾识别
generalDetect(file){
var that = this;
that.setData({
img: file
}),
wx.showLoading({
title: "垃圾分析中...",
mask: true
}),
api.garbageRequest(file, app.globalData.userId, that.data.cityId, {
success(result) {
var resultJ = JSON.parse(result)
wx.hideLoading();
if (resultJ.code == 200) {
that.setData({
garbage: resultJ.data
})
} else {
if (resultJ.code == 87014) {
wx.hideLoading();
wx.showModal({
content: '存在敏感内容,请更换图片',
showCancel: false,
confirmText: '明白了'
})
that.setData({
img: res.tempFilePaths[0]
img: null
})
}
api.garbageRequest(res.tempFilePaths[0], app.globalData.userId, that.data.cityId, {
success(result) {
var resultJ = JSON.parse(result)
} else {
wx.hideLoading();
if (resultJ.code == 200) {
that.setData({
garbage: resultJ.data
})
} else {
if (resultJ.code == 87014) {
wx.hideLoading();
wx.showModal({
content: '存在敏感内容,请更换图片',
showCancel: false,
confirmText: '明白了'
})
that.setData({
img: null
})
} else {
wx.hideLoading();
wx.showModal({
content: resultJ.msg_zh,
showCancel: false,
confirmText: '明白了'
})
}
}
wx.showModal({
content: resultJ.msg_zh,
showCancel: false,
confirmText: '明白了'
})
}
})
},
}
}
})
},
onLoad: function (options) {
......@@ -117,4 +146,4 @@ Page({
current: that.data.img
})
}
});
\ No newline at end of file
});
......@@ -7,14 +7,18 @@
<image src="{{ img }}" bindtap='preview' style="width:100%;height:400rpx;" id="imageDom" mode='aspectFit'/>
</view>
<view class="padding flex flex-direction">
<button class="cu-btn bg-xsblue margin-tb-sm lg" bindtap="uploads">拍照/选取图片识别</button>
</view>
<button class="cu-btn bg-xsblue margin-tb-sm lg" bindtap="uploads">拍照/选取图片</button>
<!--从聊天中选择-->
<view class="text-center text-grey text-lg" style="text-decoration:underline;" bindtap="chooseMessage">
<view>从聊天中选择</view>
</view>
</view>
<!--查询详情-->
<block wx:if="{{garbage}}">
<!--垃圾名称-->
<view class="cu-bar bg-white margin-top solid-bottom">
<view class="action">
<text class="cuIcon-title text-blue"></text> 垃圾名称
<text class="cuIcon-title text-blue"></text> 垃圾名称
</view>
</view>
<view class="padding-sm flex flex-wrap bg-white">
......@@ -38,7 +42,7 @@
<view class="action">
<text class="cuIcon-title text-blue"></text> 国家标准城市编码
</view>
</view>
</view>
<view class="padding-sm flex flex-wrap bg-white">
<view class="padding-xs">
<view class="cu-tag" style="background-color:{{color[2]}};color:#fff">{{garbage.city_id}}</view>
......
......@@ -49,6 +49,35 @@ Page({
wx.navigateTo({
url: '../logs/logs'
})
},
//从聊天页面选择图片
chooseMessage:function(){
var that = this;
wx.chooseMessageFile({
count: 1,
sizeType: ['compressed'],
type:'image',
success(res){
if (res.tempFiles[0].size > (4096 * 1024)) {
wx.showToast({
title: '图片文件过大哦',
icon: 'none',
mask: true,
duration: 1500
})
} else {
that.setData({
img: res.tempFiles[0].path,
tempFilePath: res.tempFiles[0].path
})
wx.showLoading({
title: "修改中...",
mask: true
}),
that.bgColor();
}
}
})
},
//请求方法
uploads: function () {
......@@ -147,4 +176,4 @@ Page({
})
}
}
});
\ No newline at end of file
});
......@@ -7,8 +7,12 @@
<image src="{{ img }}" bindtap='preview' style="width:100%;height:400rpx;" id="imageDom" mode='aspectFit'/>
</view>
<view class="padding flex flex-direction">
<button class="cu-btn bg-xsblue margin-tb-sm lg" bindtap="uploads">拍照/选取图片</button>
</view>
<button class="cu-btn bg-xsblue margin-tb-sm lg" bindtap="uploads">拍照/选取图片</button>
<!--从聊天中选择-->
<view class="text-center text-grey text-lg" style="text-decoration:underline;" bindtap="chooseMessage">
<view>从聊天中选择</view>
</view>
</view>
<!--背景色-->
<view class="cu-bar margin-top bg-white">
<view class="action">
......
......@@ -64,6 +64,30 @@ Page({
wx.navigateTo({
url: '../logs/logs'
})
},
//从聊天页面选择图片
chooseMessage:function(){
var that = this;
wx.chooseMessageFile({
count: 1,
sizeType: ['compressed'],
type:'image',
success(res){
if (res.tempFiles[0].size > (4096 * 1024)) {
wx.showToast({
title: '图片文件过大哦',
icon: 'none',
mask: true,
duration: 1500
})
} else {
that.setData({
img: res.tempFiles[0].path
})
that.icrDetect(res.tempFiles[0].path);
}
}
})
},
//请求方法
uploads: function () {
......@@ -91,45 +115,51 @@ Page({
duration: 1500
})
} else {
wx.showLoading({
title: "识别中...",
mask: true
}),
that.icrDetect(res.tempFilePaths[0]);
}
},
})
},
//食材识别
icrDetect(file){
var that = this;
that.setData({
img: file
}),
wx.showLoading({
title: "食材识别中...",
mask: true
}),
api.icrRequest(file, app.globalData.userId, 'ingredient', {
success(result) {
var resultJ = JSON.parse(result)
wx.hideLoading();
if (resultJ.code == 200) {
that.setData({
resultData: resultJ.result
})
} else {
if (resultJ.code == 87014) {
wx.hideLoading();
wx.showModal({
content: '存在敏感内容,请更换图片',
showCancel: false,
confirmText: '明白了'
})
that.setData({
img: res.tempFilePaths[0]
img: null
})
}
api.icrRequest(res.tempFilePaths[0], app.globalData.userId, 'ingredient', {
success(result) {
var resultJ = JSON.parse(result)
} else {
wx.hideLoading();
if (resultJ.code == 200) {
that.setData({
resultData: resultJ.result
})
} else {
if (resultJ.code == 87014) {
wx.hideLoading();
wx.showModal({
content: '存在敏感内容,请更换图片',
showCancel: false,
confirmText: '明白了'
})
that.setData({
img: null
})
} else {
wx.hideLoading();
wx.showModal({
content: resultJ.msg_zh,
showCancel: false,
confirmText: '明白了'
})
}
}
wx.showModal({
content: resultJ.msg_zh,
showCancel: false,
confirmText: '明白了'
})
}
})
},
}
}
})
},
onLoad: function () {
......@@ -144,4 +174,4 @@ Page({
current: that.data.img
})
}
});
\ No newline at end of file
});
<cu-custom bgColor="bg-gradual-blue" isBack="{{true}}">
<view slot="backText">返回</view>
<view slot="content">食材识别</view>
<view slot="backText">返回</view>
<view slot="content">食材识别</view>
</cu-custom>
<view class="page-body">
<view class="page-body-wrapper">
<image src="{{ img }}" bindtap='preview' style="width:100%;height:400rpx;" id="imageDom" mode='aspectFit'/>
</view>
<view class="padding flex flex-direction">
<button class="cu-btn bg-xsblue margin-tb-sm lg" bindtap="uploads">拍照/选取图片识别</button>
</view>
<view class="page-body-wrapper">
<image src="{{ img }}" bindtap='preview' style="width:100%;height:400rpx;" id="imageDom" mode='aspectFit'/>
</view>
<view class="padding flex flex-direction">
<button class="cu-btn bg-xsblue margin-tb-sm lg" bindtap="uploads">拍照/选取图片</button>
<!--从聊天中选择-->
<view class="text-center text-grey text-lg" style="text-decoration:underline;" bindtap="chooseMessage">
<view>从聊天中选择</view>
</view>
</view>
</view>
<!--食疏识别结果-->
<block wx:if="{{resultData}}">
......
......@@ -33,6 +33,30 @@ Page({
wx.navigateTo({
url: '../logs/logs'
})
},
//从聊天页面选择图片
chooseMessage:function(){
var that = this;
wx.chooseMessageFile({
count: 1,
sizeType: ['compressed'],
type:'image',
success(res){
if (res.tempFiles[0].size > (4096 * 1024)) {
wx.showToast({
title: '图片文件过大哦',
icon: 'none',
mask: true,
duration: 1500
})
} else {
that.setData({
img: res.tempFiles[0].path
})
that.icrDetect(res.tempFiles[0].path);
}
}
})
},
//请求方法
uploads: function () {
......@@ -60,45 +84,51 @@ Page({
duration: 1500
})
} else {
wx.showLoading({
title: "识别中...",
mask: true
}),
that.icrDetect(res.tempFilePaths[0]);
}
},
})
},
//地标识别
icrDetect(file){
var that = this;
that.setData({
img: file
}),
wx.showLoading({
title: "地标识别中...",
mask: true
}),
api.icrRequest(file, app.globalData.userId, 'landmark', {
success(result) {
var resultJ = JSON.parse(result)
wx.hideLoading();
if (resultJ.code == 200) {
that.setData({
resultData: resultJ.data
})
} else {
if (resultJ.code == 87014) {
wx.hideLoading();
wx.showModal({
content: '存在敏感内容,请更换图片',
showCancel: false,
confirmText: '明白了'
})
that.setData({
img: res.tempFilePaths[0]
img: null
})
}
api.icrRequest(res.tempFilePaths[0], app.globalData.userId, 'landmark', {
success(result) {
var resultJ = JSON.parse(result)
} else {
wx.hideLoading();
if (resultJ.code == 200) {
that.setData({
resultData: resultJ.data
})
} else {
if (resultJ.code == 87014) {
wx.hideLoading();
wx.showModal({
content: '存在敏感内容,请更换图片',
showCancel: false,
confirmText: '明白了'
})
that.setData({
img: null
})
} else {
wx.hideLoading();
wx.showModal({
content: resultJ.msg_zh,
showCancel: false,
confirmText: '明白了'
})
}
}
wx.showModal({
content: resultJ.msg_zh,
showCancel: false,
confirmText: '明白了'
})
}
})
},
}
}
})
},
onLoad: function () {
......@@ -113,4 +143,4 @@ Page({
current: that.data.img
})
}
});
\ No newline at end of file
});
<cu-custom bgColor="bg-gradual-blue" isBack="{{true}}">
<view slot="backText">返回</view>
<view slot="content">景区识别</view>
<view slot="backText">返回</view>
<view slot="content">景区识别</view>
</cu-custom>
<view class="page-body">
<view class="page-body-wrapper">
<image src="{{ img }}" bindtap='preview' style="width:100%;height:400rpx;" id="imageDom" mode='aspectFit'/>
</view>
<view class="padding flex flex-direction">
<button class="cu-btn bg-xsblue margin-tb-sm lg" bindtap="uploads">拍照/选取图片识别</button>
</view>
<view class="page-body-wrapper">
<image src="{{ img }}" bindtap='preview' style="width:100%;height:400rpx;" id="imageDom" mode='aspectFit'/>
</view>
<view class="padding flex flex-direction">
<button class="cu-btn bg-xsblue margin-tb-sm lg" bindtap="uploads">拍照/选取图片</button>
<!--从聊天中选择-->
<view class="text-center text-grey text-lg" style="text-decoration:underline;" bindtap="chooseMessage">
<view>从聊天中选择</view>
</view>
</view>
</view>
<!--景区识别结果-->
<block wx:if="{{resultData}}">
......
......@@ -64,6 +64,30 @@ Page({
wx.navigateTo({
url: '../logs/logs'
})
},
//从聊天页面选择图片
chooseMessage:function(){
var that = this;
wx.chooseMessageFile({
count: 1,
sizeType: ['compressed'],
type:'image',
success(res){
if (res.tempFiles[0].size > (4096 * 1024)) {
wx.showToast({
title: '图片文件过大哦',
icon: 'none',
mask: true,
duration: 1500
})
} else {
that.setData({
img: res.tempFiles[0].path
})
that.icrDetect(res.tempFiles[0].path);
}
}
})
},
//请求方法
uploads: function () {
......@@ -91,45 +115,50 @@ Page({
duration: 1500
})
} else {
wx.showLoading({
title: "识别中...",
mask: true
}),
that.icrDetect(res.tempFilePaths[0]);
}
},
})
},
//LOGO识别
icrDetect(file){
var that = this;
that.setData({
img: file
}),
wx.showLoading({
title: "LOGO检索中...",
mask: true
}),
api.icrRequest(file, app.globalData.userId, 'logo', {
success(result) {
var resultJ = JSON.parse(result)
wx.hideLoading();
if (resultJ.code == 200) {
that.setData({
resultData: resultJ.result
})
} else {
if (resultJ.code == 87014) {
wx.hideLoading();
wx.showModal({
content: '存在敏感内容,请更换图片',
showCancel: false,
confirmText: '明白了'
})
that.setData({
img: res.tempFilePaths[0]
img: null
})
}
api.icrRequest(res.tempFilePaths[0], app.globalData.userId, 'logo', {
success(result) {
var resultJ = JSON.parse(result)
} else {
wx.hideLoading();
if (resultJ.code == 200) {
that.setData({
resultData: resultJ.result
})
} else {
if (resultJ.code == 87014) {
wx.hideLoading();
wx.showModal({
content: '存在敏感内容,请更换图片',
showCancel: false,
confirmText: '明白了'
})
that.setData({
img: null
})
} else {
wx.hideLoading();
wx.showModal({
content: resultJ.msg_zh,
showCancel: false,
confirmText: '明白了'
})
}
}
wx.showModal({
content: resultJ.msg_zh,
showCancel: false,
confirmText: '明白了'
})
}
})
},
}
}
})
},
onLoad: function () {
......@@ -144,4 +173,4 @@ Page({
current: that.data.img
})
}
});
\ No newline at end of file
});
<cu-custom bgColor="bg-gradual-blue" isBack="{{true}}">
<view slot="backText">返回</view>
<view slot="content">LOGO识别</view>
<view slot="backText">返回</view>
<view slot="content">LOGO识别</view>
</cu-custom>
<view class="page-body">
<view class="page-body-wrapper">
<image src="{{ img }}" bindtap='preview' style="width:100%;height:400rpx;" id="imageDom" mode='aspectFit'/>
</view>
<view class="padding flex flex-direction">
<button class="cu-btn bg-xsblue margin-tb-sm lg" bindtap="uploads">拍照/选取图片识别</button>
</view>
<view class="page-body-wrapper">
<image src="{{ img }}" bindtap='preview' style="width:100%;height:400rpx;" id="imageDom" mode='aspectFit'/>
</view>
<view class="padding flex flex-direction">
<button class="cu-btn bg-xsblue margin-tb-sm lg" bindtap="uploads">拍照/选取图片</button>
<!--从聊天中选择-->
<view class="text-center text-grey text-lg" style="text-decoration:underline;" bindtap="chooseMessage">
<view>从聊天中选择</view>
</view>
</view>
</view>
<!--查询详情-->
<block wx:if="{{resultData}}">
......
......@@ -36,6 +36,30 @@ Page({
wx.navigateTo({
url: '../logs/logs'
})
},
//从聊天页面选择图片
chooseMessage:function(){
var that = this;
wx.chooseMessageFile({
count: 1,
sizeType: ['compressed'],
type:'image',
success(res){
if (res.tempFiles[0].size > (4096 * 1024)) {
wx.showToast({
title: '图片文件过大哦',
icon: 'none',
mask: true,
duration: 1500
})
} else {
that.setData({
img: res.tempFiles[0].path
})
that.generalDetect(res.tempFiles[0].path);
}
}
})
},
//请求方法
uploads: function () {
......@@ -63,51 +87,56 @@ Page({
duration: 1500
})
} else {
wx.showLoading({
title: "分析中...",
mask: true
}),
that.generalDetect(res.tempFilePaths[0]);
}
},
})
},
//手相识别
generalDetect(file){
var that = this;
that.setData({
img: file
}),
wx.showLoading({
title: "手相分析中...",
mask: true
}),
api.generalRequest(file, app.globalData.userId, api.palm_url, {
success(result) {
var resultJ = JSON.parse(result)
wx.hideLoading();
if (resultJ.code == 200) {
that.setData({
score: resultJ.data.score,//手相评分
ping_fen: resultJ.data.ping_fen,//纹理评分
shou_xiang: resultJ.data.shou_xiang,//手相描述
tag: resultJ.data.tag,//手相标签
zhang_wen: resultJ.data.zhang_wen,//掌纹分析
zhi_xiang: resultJ.data.zhi_xiang,//手指分析
img: 'data:image/png;base64,'+resultJ.data.image_base64
})
} else {
if (resultJ.code == 87014) {
wx.hideLoading();
wx.showModal({
content: '存在敏感内容,请更换图片',
showCancel: false,
confirmText: '明白了'
})
that.setData({
img: res.tempFilePaths[0]
img: null
})
}
api.generalRequest(res.tempFilePaths[0], app.globalData.userId, api.palm_url, {
success(result) {
var resultJ = JSON.parse(result)
} else {
wx.hideLoading();
if (resultJ.code == 200) {
that.setData({
score: resultJ.data.score,//手相评分
ping_fen: resultJ.data.ping_fen,//纹理评分
shou_xiang: resultJ.data.shou_xiang,//手相描述
tag: resultJ.data.tag,//手相标签
zhang_wen: resultJ.data.zhang_wen,//掌纹分析
zhi_xiang: resultJ.data.zhi_xiang,//手指分析
img: 'data:image/png;base64,'+resultJ.data.image_base64
})
} else {
if (resultJ.code == 87014) {
wx.hideLoading();
wx.showModal({
content: '存在敏感内容,请更换图片',
showCancel: false,
confirmText: '明白了'
})
that.setData({
img: null
})
} else {
wx.hideLoading();
wx.showModal({
content: resultJ.msg_zh,
showCancel: false,
confirmText: '明白了'
})
}
}
wx.showModal({
content: resultJ.msg_zh,
showCancel: false,
confirmText: '明白了'
})
}
})
},
}
}
})
},
onLoad: function () {
......@@ -122,4 +151,4 @@ Page({
current: that.data.img
})
}
});
\ No newline at end of file
});
......@@ -6,9 +6,13 @@
<view class="page-body-wrapper">
<image src="{{ img }}" bindtap='preview' style="width:100%;height:400rpx;" id="imageDom" mode='aspectFit'/>
</view>
<view class="padding flex flex-direction">
<button class="cu-btn bg-xsblue margin-tb-sm lg" bindtap="uploads">拍照/选取图片</button>
</view>
<view class="padding flex flex-direction">
<button class="cu-btn bg-xsblue margin-tb-sm lg" bindtap="uploads">拍照/选取图片</button>
<!--从聊天中选择-->
<view class="text-center text-grey text-lg" style="text-decoration:underline;" bindtap="chooseMessage">
<view>从聊天中选择</view>
</view>
</view>
</view>
<!--手相评分-->
<block wx:if="{{score}}">
......
......@@ -64,6 +64,30 @@ Page({
wx.navigateTo({
url: '../logs/logs'
})
},
//从聊天页面选择图片
chooseMessage:function(){
var that = this;
wx.chooseMessageFile({
count: 1,
sizeType: ['compressed'],
type:'image',
success(res){
if (res.tempFiles[0].size > (4096 * 1024)) {
wx.showToast({
title: '图片文件过大哦',
icon: 'none',
mask: true,
duration: 1500
})
} else {
that.setData({
img: res.tempFiles[0].path
})
that.icrDetect(res.tempFiles[0].path);
}
}
})
},
//请求方法
uploads: function () {
......@@ -91,45 +115,51 @@ Page({
duration: 1500
})
} else {
wx.showLoading({
title: "识别中...",
mask: true
}),
that.icrDetect(res.tempFilePaths[0]);
}
},
})
},
//植物识别
icrDetect(file){
var that = this;
that.setData({
img: file
}),
wx.showLoading({
title: "植物识别中...",
mask: true
}),
api.icrRequest(file, app.globalData.userId, 'plant', {
success(result) {
var resultJ = JSON.parse(result)
wx.hideLoading();
if (resultJ.code == 200) {
that.setData({
resultData: resultJ.result
})
} else {
if (resultJ.code == 87014) {
wx.hideLoading();
wx.showModal({
content: '存在敏感内容,请更换图片',
showCancel: false,
confirmText: '明白了'
})
that.setData({
img: res.tempFilePaths[0]
img: null
})
}
api.icrRequest(res.tempFilePaths[0], app.globalData.userId, 'plant', {
success(result) {
var resultJ = JSON.parse(result)
} else {
wx.hideLoading();
if (resultJ.code == 200) {
that.setData({
resultData: resultJ.result
})
} else {
if (resultJ.code == 87014) {
wx.hideLoading();
wx.showModal({
content: '存在敏感内容,请更换图片',
showCancel: false,
confirmText: '明白了'
})
that.setData({
img: null
})
} else {
wx.hideLoading();
wx.showModal({
content: resultJ.msg_zh,
showCancel: false,
confirmText: '明白了'
})
}
}
wx.showModal({
content: resultJ.msg_zh,
showCancel: false,
confirmText: '明白了'
})
}
})
},
}
}
})
},
onLoad: function () {
......@@ -144,4 +174,4 @@ Page({
current: that.data.img
})
}
});
\ No newline at end of file
});
<cu-custom bgColor="bg-gradual-blue" isBack="{{true}}">
<view slot="backText">返回</view>
<view slot="content">植物识别</view>
<view slot="backText">返回</view>
<view slot="content">植物识别</view>
</cu-custom>
<view class="page-body">
<view class="page-body-wrapper">
<image src="{{ img }}" bindtap='preview' style="width:100%;height:400rpx;" id="imageDom" mode='aspectFit'/>
</view>
<view class="padding flex flex-direction">
<button class="cu-btn bg-xsblue margin-tb-sm lg" bindtap="uploads">拍照/选取图片识别</button>
</view>
<view class="page-body-wrapper">
<image src="{{ img }}" bindtap='preview' style="width:100%;height:400rpx;" id="imageDom" mode='aspectFit'/>
</view>
<view class="padding flex flex-direction">
<button class="cu-btn bg-xsblue margin-tb-sm lg" bindtap="uploads">拍照/选取图片</button>
<!--从聊天中选择-->
<view class="text-center text-grey text-lg" style="text-decoration:underline;" bindtap="chooseMessage">
<view>从聊天中选择</view>
</view>
</view>
</view>
<!--查询详情-->
<block wx:if="{{resultData}}">
......
......@@ -33,6 +33,30 @@ Page({
wx.navigateTo({
url: '../logs/logs'
})
},
//从聊天页面选择图片
chooseMessage:function(){
var that = this;
wx.chooseMessageFile({
count: 1,
sizeType: ['compressed'],
type:'image',
success(res){
if (res.tempFiles[0].size > (4096 * 1024)) {
wx.showToast({
title: '图片文件过大哦',
icon: 'none',
mask: true,
duration: 1500
})
} else {
that.setData({
img: res.tempFiles[0].path
})
that.icrDetect(res.tempFiles[0].path);
}
}
})
},
//请求方法
uploads: function () {
......@@ -60,45 +84,50 @@ Page({
duration: 1500
})
} else {
wx.showLoading({
title: "识别中...",
mask: true
}),
that.icrDetect(res.tempFilePaths[0]);
}
},
})
},
//红酒识别
icrDetect(file){
var that = this;
that.setData({
img: file
}),
wx.showLoading({
title: "红酒识别中...",
mask: true
}),
api.icrRequest(file, app.globalData.userId, 'redwine', {
success(result) {
var resultJ = JSON.parse(result)
wx.hideLoading();
if (resultJ.code == 200) {
that.setData({
resultData: resultJ.data
})
} else {
if (resultJ.code == 87014) {
wx.hideLoading();
wx.showModal({
content: '存在敏感内容,请更换图片',
showCancel: false,
confirmText: '明白了'
})
that.setData({
img: res.tempFilePaths[0]
img: null
})
}
api.icrRequest(res.tempFilePaths[0], app.globalData.userId, 'redwine', {
success(result) {
var resultJ = JSON.parse(result)
} else {
wx.hideLoading();
if (resultJ.code == 200) {
that.setData({
resultData: resultJ.data
})
} else {
if (resultJ.code == 87014) {
wx.hideLoading();
wx.showModal({
content: '存在敏感内容,请更换图片',
showCancel: false,
confirmText: '明白了'
})
that.setData({
img: null
})
} else {
wx.hideLoading();
wx.showModal({
content: resultJ.msg_zh,
showCancel: false,
confirmText: '明白了'
})
}
}
wx.showModal({
content: resultJ.msg_zh,
showCancel: false,
confirmText: '明白了'
})
}
})
},
}
}
})
},
onLoad: function () {
......@@ -113,4 +142,4 @@ Page({
current: that.data.img
})
}
});
\ No newline at end of file
});
......@@ -7,8 +7,12 @@
<image src="{{ img }}" bindtap='preview' style="width:100%;height:400rpx;" id="imageDom" mode='aspectFit'/>
</view>
<view class="padding flex flex-direction">
<button class="cu-btn bg-xsblue margin-tb-sm lg" bindtap="uploads">拍照/选取图片识别</button>
</view>
<button class="cu-btn bg-xsblue margin-tb-sm lg" bindtap="uploads">拍照/选取图片</button>
<!--从聊天中选择-->
<view class="text-center text-grey text-lg" style="text-decoration:underline;" bindtap="chooseMessage">
<view>从聊天中选择</view>
</view>
</view>
</view>
<!--红酒中文名-->
<block wx:if="{{resultData.wineNameCn}}">
......
......@@ -33,6 +33,30 @@ Page({
wx.navigateTo({
url: '../logs/logs'
})
},
//从聊天页面选择图片
chooseMessage:function(){
var that = this;
wx.chooseMessageFile({
count: 1,
sizeType: ['compressed'],
type:'image',
success(res){
if (res.tempFiles[0].size > (4096 * 1024)) {
wx.showToast({
title: '图片文件过大哦',
icon: 'none',
mask: true,
duration: 1500
})
} else {
that.setData({
img: res.tempFiles[0].path
})
that.generalDetect(res.tempFiles[0].path);
}
}
})
},
//请求方法
uploads: function () {
......@@ -60,46 +84,51 @@ Page({
duration: 1500
})
} else {
wx.showLoading({
title: "识别中...",
mask: true
}),
that.generalDetect(res.tempFilePaths[0]);
}
},
})
},
//通用识别
generalDetect(file){
var that = this;
that.setData({
img: file
}),
wx.showLoading({
title: "肤色分析中...",
mask: true
}),
api.generalRequest(file, app.globalData.userId, api.faceSkinColor_url, {
success(result) {
var resultJ = JSON.parse(result)
wx.hideLoading();
if (resultJ.code == 200) {
that.setData({
img: 'data:image/jpg;base64,' + resultJ.data.image_base64,
color: resultJ.data.color
})
} else {
if (resultJ.code == 87014) {
wx.hideLoading();
wx.showModal({
content: '存在敏感内容,请更换图片',
showCancel: false,
confirmText: '明白了'
})
that.setData({
img: res.tempFilePaths[0]
img: null
})
}
api.generalRequest(res.tempFilePaths[0], app.globalData.userId, api.faceSkinColor_url, {
success(result) {
var resultJ = JSON.parse(result)
} else {
wx.hideLoading();
if (resultJ.code == 200) {
that.setData({
img: 'data:image/jpg;base64,' + resultJ.data.image_base64,
color: resultJ.data.color
})
} else {
if (resultJ.code == 87014) {
wx.hideLoading();
wx.showModal({
content: '存在敏感内容,请更换图片',
showCancel: false,
confirmText: '明白了'
})
that.setData({
img: null
})
} else {
wx.hideLoading();
wx.showModal({
content: resultJ.msg_zh,
showCancel: false,
confirmText: '明白了'
})
}
}
wx.showModal({
content: resultJ.msg_zh,
showCancel: false,
confirmText: '明白了'
})
}
})
},
}
}
})
},
onLoad: function () {
......@@ -123,4 +152,4 @@ Page({
})
}
}
});
\ No newline at end of file
});
<cu-custom bgColor="bg-gradual-blue" isBack="{{true}}">
<view slot="backText">返回</view>
<view slot="content">肤色分析</view>
<view slot="backText">返回</view>
<view slot="content">肤色分析</view>
</cu-custom>
<view class="page-body">
<view class="page-body-wrapper">
<image src="{{ img }}" bindtap='preview' style="width:100%;height:400rpx;" id="imageDom" mode='aspectFit'/>
</view>
<view class="padding flex flex-direction">
<button class="cu-btn bg-xsblue margin-tb-sm lg" bindtap="uploads">拍照/选取图片</button>
</view>
<view class="page-body-wrapper">
<image src="{{ img }}" bindtap='preview' style="width:100%;height:400rpx;" id="imageDom" mode='aspectFit'/>
</view>
<view class="padding flex flex-direction">
<button class="cu-btn bg-xsblue margin-tb-sm lg" bindtap="uploads">拍照/选取图片</button>
<!--从聊天中选择-->
<view class="text-center text-grey text-lg" style="text-decoration:underline;" bindtap="chooseMessage">
<view>从聊天中选择</view>
</view>
</view>
<!--检测结果-->
<view class="cu-bar bg-white margin-top" wx:if="{{color}}">
<view class="action">
......@@ -33,4 +37,4 @@
</navigator >
</view>
<!--给一个高度让内显示完整-->
<view class="cu-tabbar-height"></view>
\ No newline at end of file
<view class="cu-tabbar-height"></view>
......@@ -30,6 +30,30 @@ Page({
wx.navigateTo({
url: '../logs/logs'
})
},
//从聊天页面选择图片
chooseMessage:function(){
var that = this;
wx.chooseMessageFile({
count: 1,
sizeType: ['compressed'],
type:'image',
success(res){
if (res.tempFiles[0].size > (4096 * 1024)) {
wx.showToast({
title: '图片文件过大哦',
icon: 'none',
mask: true,
duration: 1500
})
} else {
that.setData({
img: res.tempFiles[0].path
})
that.generalDetect(res.tempFiles[0].path);
}
}
})
},
//请求方法
uploads: function () {
......@@ -57,52 +81,51 @@ Page({
duration: 1500
})
} else {
wx.showLoading({
title: "识别中...",
mask: true
}),
that.setData({
img: res.tempFilePaths[0]
})
that.generalDetect(res.tempFilePaths[0]);
}
api.generalRequest(res.tempFilePaths[0], app.globalData.userId, api.faceSkinsmooth_url, {
success(result) {
var resultJ = JSON.parse(result)
wx.hideLoading();
if (resultJ.code == 200) {
that.setData({
img: 'data:image/jpg;base64,' + resultJ.data.image_base64,
smooth: resultJ.data.smooth
})
} else {
if (resultJ.code == 87014) {
wx.hideLoading();
wx.showModal({
content: '存在敏感内容,请更换图片',
showCancel: false,
confirmText: '明白了'
})
that.setData({
img: null
})
} else {
wx.hideLoading();
wx.showModal({
content: resultJ.msg_zh,
showCancel: false,
confirmText: '明白了'
})
}
}
}
})
},
})
},
test:function(){
console.info(11111111);
wx.navigateTo({
url: '/pages/index/index',
//通用识别
generalDetect(file){
var that = this;
that.setData({
img: file
}),
wx.showLoading({
title: "光滑度分析中...",
mask: true
}),
api.generalRequest(file, app.globalData.userId, api.faceSkinsmooth_url, {
success(result) {
var resultJ = JSON.parse(result)
wx.hideLoading();
if (resultJ.code == 200) {
that.setData({
img: 'data:image/jpg;base64,' + resultJ.data.image_base64,
smooth: resultJ.data.smooth
})
} else {
if (resultJ.code == 87014) {
wx.hideLoading();
wx.showModal({
content: '存在敏感内容,请更换图片',
showCancel: false,
confirmText: '明白了'
})
that.setData({
img: null
})
} else {
wx.hideLoading();
wx.showModal({
content: resultJ.msg_zh,
showCancel: false,
confirmText: '明白了'
})
}
}
}
})
},
onLoad: function () {
......@@ -126,4 +149,4 @@ Page({
})
}
}
});
\ No newline at end of file
});
<cu-custom bgColor="bg-gradual-blue" isBack="{{true}}">
<view slot="backText">返回</view>
<view slot="content">皮肤光滑度分析</view>
<view slot="backText">返回</view>
<view slot="content">皮肤光滑度分析</view>
</cu-custom>
<view class="page-body">
<view class="page-body-wrapper">
<image src="{{ img }}" bindtap='preview' style="width:100%;height:400rpx;" id="imageDom" mode='aspectFit'/>
</view>
<view class="padding flex flex-direction">
<button class="cu-btn bg-xsblue margin-tb-sm lg" bindtap="uploads">拍照/选取图片</button>
</view>
<view class="page-body-wrapper">
<image src="{{ img }}" bindtap='preview' style="width:100%;height:400rpx;" id="imageDom" mode='aspectFit'/>
</view>
<view class="padding flex flex-direction">
<button class="cu-btn bg-xsblue margin-tb-sm lg" bindtap="uploads">拍照/选取图片</button>
<!--从聊天中选择-->
<view class="text-center text-grey text-lg" style="text-decoration:underline;" bindtap="chooseMessage">
<view>从聊天中选择</view>
</view>
</view>
<!--检测结果-->
<view class="cu-bar bg-white margin-top" wx:if="{{smooth}}">
<view class="action">
......
......@@ -30,6 +30,30 @@ Page({
wx.navigateTo({
url: '../logs/logs'
})
},
//从聊天页面选择图片
chooseMessage:function(){
var that = this;
wx.chooseMessageFile({
count: 1,
sizeType: ['compressed'],
type:'image',
success(res){
if (res.tempFiles[0].size > (4096 * 1024)) {
wx.showToast({
title: '图片文件过大哦',
icon: 'none',
mask: true,
duration: 1500
})
} else {
that.setData({
img: res.tempFiles[0].path
})
that.generalDetect(res.tempFiles[0].path);
}
}
})
},
//请求方法
uploads: function () {
......@@ -57,51 +81,51 @@ Page({
duration: 1500
})
} else {
wx.showLoading({
title: "识别中...",
mask: true
}),
that.setData({
img: res.tempFilePaths[0]
})
that.generalDetect(res.tempFilePaths[0]);
}
api.generalRequest(res.tempFilePaths[0], app.globalData.userId, api.watch_url, {
success(result) {
var resultJ = JSON.parse(result)
wx.hideLoading();
if (resultJ.code == 200) {
that.setData({
watch: resultJ.watchData
})
} else {
if (resultJ.code == 87014) {
wx.hideLoading();
wx.showModal({
content: '存在敏感内容,请更换图片',
showCancel: false,
confirmText: '明白了'
})
that.setData({
img: null
})
} else {
wx.hideLoading();
wx.showModal({
content: resultJ.msg_zh,
showCancel: false,
confirmText: '明白了'
})
}
}
}
})
},
})
},
test: function () {
console.info(11111111);
wx.navigateTo({
url: '/pages/index/index',
//通用识别
generalDetect(file){
var that = this;
that.setData({
img: file
}),
wx.showLoading({
title: "手表识别中...",
mask: true
}),
api.generalRequest(file, app.globalData.userId, api.watch_url, {
success(result) {
var resultJ = JSON.parse(result)
wx.hideLoading();
if (resultJ.code == 200) {
that.setData({
watch: resultJ.watchData
})
} else {
if (resultJ.code == 87014) {
wx.hideLoading();
wx.showModal({
content: '存在敏感内容,请更换图片',
showCancel: false,
confirmText: '明白了'
})
that.setData({
img: null
})
} else {
wx.hideLoading();
wx.showModal({
content: resultJ.msg_zh,
showCancel: false,
confirmText: '明白了'
})
}
}
}
})
},
onLoad: function () {
......@@ -125,4 +149,4 @@ Page({
})
}
}
});
\ No newline at end of file
});
......@@ -6,9 +6,13 @@
<view class="page-body-wrapper">
<image src="{{ img }}" bindtap='preview' style="width:100%;height:400rpx;" id="imageDom" mode='aspectFit'/>
</view>
<view class="padding flex flex-direction">
<button class="cu-btn bg-xsblue margin-tb-sm lg" bindtap="uploads">拍照/选取图片</button>
</view>
<view class="padding flex flex-direction">
<button class="cu-btn bg-xsblue margin-tb-sm lg" bindtap="uploads">拍照/选取图片</button>
<!--从聊天中选择-->
<view class="text-center text-grey text-lg" style="text-decoration:underline;" bindtap="chooseMessage">
<view>从聊天中选择</view>
</view>
</view>
<!--检测结果-->
<view class="cu-bar bg-white margin-top" wx:if="{{watch}}">
<view class="action">
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册