......
This commit is contained in:
1 parent
a1f11d317f
commit
93c9df5600
5 files changed
+163
-97
No files matched your search
@@ -30,7 +30,8 @@ page{
|
||||
|
||||
.text_startPage{
|
||||
font-size: 60rpx;
|
||||
color:var(--text-color)
|
||||
color:var(--text-color);
|
||||
// mix-blend-mode: difference;
|
||||
}
|
||||
|
||||
.buttom_startPage{
|
||||
@@ -40,6 +41,9 @@ page{
|
||||
display: flex;
|
||||
justify-content: center;
|
||||
align-items: center;
|
||||
.image{
|
||||
mix-blend-mode: difference;
|
||||
}
|
||||
}
|
||||
|
||||
#gotoSearch{
|
||||
|
||||
@@ -1047,12 +1047,7 @@ Page({
|
||||
})
|
||||
},
|
||||
|
||||
// 检查session是否过期
|
||||
// checkSession() {
|
||||
// return new Promise((resolve, reject) => {
|
||||
// this
|
||||
// })
|
||||
// },
|
||||
|
||||
|
||||
// 上传照片并展示收到的结果
|
||||
uploadImg(tempImagePath: any) {
|
||||
@@ -1060,88 +1055,123 @@ Page({
|
||||
title: "查询中喵",
|
||||
mask: true //开启蒙版遮罩
|
||||
});
|
||||
return setTimeout(()=>{
|
||||
wx.hideLoading();
|
||||
var fake_data = {
|
||||
id:70582140,
|
||||
imgUrl:"./static/icons/history.svg",
|
||||
res:{
|
||||
scores: 93,
|
||||
arr: ["生牛乳"],
|
||||
}
|
||||
}
|
||||
var data = fake_data
|
||||
var nowdate = new Date();
|
||||
var nowyear = nowdate.getFullYear();
|
||||
var nowmonth = nowdate.getMonth() + 1;
|
||||
var nowday = nowdate.getDate();
|
||||
var dateStr = nowyear + '.' + nowmonth + '.' + nowday
|
||||
if (!this.data.data_history[dateStr]) {
|
||||
this.data.data_history[dateStr] = []
|
||||
}
|
||||
var historyTemp =
|
||||
{
|
||||
id: data.id,
|
||||
imgUrl: data.imgUrl,
|
||||
res: data.res,
|
||||
hasCollect: false,//目前全是false。。。
|
||||
}
|
||||
this.data.data_history[dateStr].push(historyTemp)
|
||||
this.setData({
|
||||
data_history: this.data.data_history
|
||||
})
|
||||
this.sortHistory()
|
||||
this.show_result_byId(data.id)
|
||||
this.save2storage()
|
||||
},3000)
|
||||
wx.getFileSystemManager().readFile({
|
||||
// return setTimeout(()=>{
|
||||
// wx.hideLoading();
|
||||
// var fake_data = {
|
||||
// id:70582140,
|
||||
// imgUrl:"./static/icons/history.svg",
|
||||
// res:{
|
||||
// scores: 93,
|
||||
// arr: ["生牛乳"],
|
||||
// }
|
||||
// }
|
||||
// var data = fake_data
|
||||
// var nowdate = new Date();
|
||||
// var nowyear = nowdate.getFullYear();
|
||||
// var nowmonth = nowdate.getMonth() + 1;
|
||||
// var nowday = nowdate.getDate();
|
||||
// var dateStr = nowyear + '.' + nowmonth + '.' + nowday
|
||||
// if (!this.data.data_history[dateStr]) {
|
||||
// this.data.data_history[dateStr] = []
|
||||
// }
|
||||
// var historyTemp =
|
||||
// {
|
||||
// id: data.id,
|
||||
// imgUrl: data.imgUrl,
|
||||
// res: data.res,
|
||||
// hasCollect: false,
|
||||
// }
|
||||
// this.data.data_history[dateStr].push(historyTemp)
|
||||
// this.setData({
|
||||
// data_history: this.data.data_history
|
||||
// })
|
||||
// this.sortHistory()
|
||||
// this.show_result_byId(data.id)
|
||||
// this.save2storage()
|
||||
// },3000)
|
||||
// wx.getFileSystemManager().readFile({
|
||||
// filePath: tempImagePath,
|
||||
// // encoding: 'base64',
|
||||
// success: res => {
|
||||
// // console.log('data:image/png;base64,' + res.data)
|
||||
// const imgBase64 = res.data
|
||||
// wx.request({
|
||||
// url: '' + serverAddr + '/api/ocr', //仅为示例,并非真实的接口地址
|
||||
// data: {
|
||||
// file: imgBase64,
|
||||
// session_key:this.data.session_key
|
||||
// },
|
||||
// method: "POST",
|
||||
// header: {
|
||||
// 'content-type': 'application/json' // 默认值
|
||||
// },
|
||||
// success: res => {
|
||||
// var data = res.data
|
||||
// console.log(res.data)
|
||||
// wx.hideLoading();
|
||||
// var nowdate = new Date();
|
||||
// var nowyear = nowdate.getFullYear();
|
||||
// var nowmonth = nowdate.getMonth() + 1;
|
||||
// var nowday = nowdate.getDate();
|
||||
// var dateStr = nowyear + '.' + nowmonth + '.' + nowday
|
||||
// if (!this.data.data_history[dateStr]) {
|
||||
// this.data.data_history[dateStr] = []
|
||||
// }
|
||||
// var historyTemp =
|
||||
// {
|
||||
// id: data.id,
|
||||
// imgUrl: data.imgUrl,
|
||||
// res: data.res,
|
||||
// hasCollect: false,//目前全是false。。。
|
||||
// }
|
||||
// this.data.data_history[dateStr].push(historyTemp)
|
||||
// this.setData({
|
||||
// data_history: this.data.data_history
|
||||
// })
|
||||
// this.sortHistory()
|
||||
// this.show_result_byId(data.id)
|
||||
// this.save2storage()
|
||||
// },
|
||||
// fail: res => {
|
||||
// console.log(res)
|
||||
// }
|
||||
// })
|
||||
// }
|
||||
// })
|
||||
wx.uploadFile({
|
||||
url: '' + serverAddr + '/api/ocr', //仅为示例,并非真实的接口地址
|
||||
filePath: tempImagePath,
|
||||
encoding: 'base64',
|
||||
success: res => {
|
||||
// console.log('data:image/png;base64,' + res.data)
|
||||
const imgBase64 = res.data
|
||||
wx.request({
|
||||
url: '' + serverAddr + '/rcvImg', //仅为示例,并非真实的接口地址
|
||||
data: {
|
||||
imgBase64: imgBase64,
|
||||
session_key:this.data.session_key
|
||||
},
|
||||
method: "POST",
|
||||
header: {
|
||||
'content-type': 'application/json' // 默认值
|
||||
},
|
||||
success: res => {
|
||||
var data = res.data
|
||||
console.log(res.data)
|
||||
var nowdate = new Date();
|
||||
var nowyear = nowdate.getFullYear();
|
||||
var nowmonth = nowdate.getMonth() + 1;
|
||||
var nowday = nowdate.getDate();
|
||||
var dateStr = nowyear + '.' + nowmonth + '.' + nowday
|
||||
if (!this.data.data_history[dateStr]) {
|
||||
this.data.data_history[dateStr] = []
|
||||
}
|
||||
var historyTemp =
|
||||
{
|
||||
id: data.id,
|
||||
imgUrl: data.imgUrl,
|
||||
res: data.res,
|
||||
hasCollect: false,//目前全是false。。。
|
||||
}
|
||||
this.data.data_history[dateStr].push(historyTemp)
|
||||
this.setData({
|
||||
data_history: this.data.data_history
|
||||
})
|
||||
this.sortHistory()
|
||||
this.show_result_byId(data.id)
|
||||
this.save2storage()
|
||||
},
|
||||
fail: res => {
|
||||
console.log(res)
|
||||
}
|
||||
name: 'file',
|
||||
// formData: {
|
||||
// session_key:this.data.session_key
|
||||
// },
|
||||
success:res=>{
|
||||
const data = res.data
|
||||
wx.hideLoading();
|
||||
var nowdate = new Date();
|
||||
var nowyear = nowdate.getFullYear();
|
||||
var nowmonth = nowdate.getMonth() + 1;
|
||||
var nowday = nowdate.getDate();
|
||||
var dateStr = nowyear + '.' + nowmonth + '.' + nowday
|
||||
if (!this.data.data_history[dateStr]) {
|
||||
this.data.data_history[dateStr] = []
|
||||
}
|
||||
var historyTemp =
|
||||
{
|
||||
id: data.id,
|
||||
imgUrl: data.imgUrl,
|
||||
res: data.res,
|
||||
hasCollect: false,//目前全是false。。。
|
||||
}
|
||||
this.data.data_history[dateStr].push(historyTemp)
|
||||
this.setData({
|
||||
data_history: this.data.data_history
|
||||
})
|
||||
this.sortHistory()
|
||||
this.show_result_byId(data.id)
|
||||
this.save2storage()
|
||||
}
|
||||
})
|
||||
})
|
||||
},
|
||||
|
||||
// 向云发送历史记录和收藏记录数据
|
||||
@@ -1444,6 +1474,35 @@ Page({
|
||||
return res
|
||||
},
|
||||
|
||||
// 文字转语音
|
||||
text2speech:function(e:any){
|
||||
var str = e.target.dataset.name
|
||||
// console.log(e.target.dataset.name)
|
||||
// 个人小程序做不了
|
||||
var plugin = requirePlugin("WechatSI")
|
||||
// plugin.textToSpeech({
|
||||
// lang: "zh_CN",
|
||||
// tts: true,
|
||||
// content: str,
|
||||
// success: function(res:any) {
|
||||
// console.log("succ tts", res.filename)
|
||||
// const innerAudioContext = wx.createInnerAudioContext()
|
||||
// innerAudioContext.autoplay = true
|
||||
// innerAudioContext.src = res.filename
|
||||
// innerAudioContext.onPlay(() => {
|
||||
// console.log('开始播放')
|
||||
// })
|
||||
// innerAudioContext.onError((res) => {
|
||||
// console.log(res.errMsg)
|
||||
// console.log(res.errCode)
|
||||
// })
|
||||
// },
|
||||
// fail: function(res:any) {
|
||||
// console.log("fail tts", res)
|
||||
// }
|
||||
// })
|
||||
},
|
||||
|
||||
// 获取用户code,以给服务端换取openId
|
||||
getCode: async function () {
|
||||
var code
|
||||
|
||||
@@ -68,7 +68,7 @@
|
||||
<view wx:for="{{ data_lib }}" wx:for-item="n">
|
||||
<view class="ingredient_card" hidden="{{ hidden_lib[n.name.zh] }}" style="background-color: {{ n.riskBgColor }};">
|
||||
<view class="node_content">
|
||||
<view class="node_name">{{ n.name.zh }}</view>
|
||||
<view class="node_name" bind:tap="text2speech" data-name="{{n.name.zh}}">{{ n.name.zh }}</view>
|
||||
<view class="node_name node_name_en">{{ n.name.en }}</view>
|
||||
|
||||
<view class="node_adi">
|
||||
|
||||
Reference in new issue
Block a user