This commit is contained in:
539943419 committed 2023-11-29 15:36:15 +08:00
1 parent a1f11d317f
commit 93c9df5600
5 files changed
+163 -97

No files matched your search

+11 -9
View File
@@ -1,11 +1,13 @@
{ {
"pages": [ "pages": [
"pages/index/index", "pages/index/index",
"pages/logs/logs" "pages/logs/logs"
], ],
"window": { "window": {
"navigationStyle": "custom" "navigationStyle": "custom"
}, },
"style": "v2", "plugins": {
"sitemapLocation": "sitemap.json" },
"style": "v2",
"sitemapLocation": "sitemap.json"
} }
+5 -1
View File
@@ -30,7 +30,8 @@ page{
.text_startPage{ .text_startPage{
font-size: 60rpx; font-size: 60rpx;
color:var(--text-color) color:var(--text-color);
// mix-blend-mode: difference;
} }
.buttom_startPage{ .buttom_startPage{
@@ -40,6 +41,9 @@ page{
display: flex; display: flex;
justify-content: center; justify-content: center;
align-items: center; align-items: center;
.image{
mix-blend-mode: difference;
}
} }
#gotoSearch{ #gotoSearch{
+144 -85
View File
@@ -1047,12 +1047,7 @@ Page({
}) })
}, },
// 检查session是否过期
// checkSession() {
// return new Promise((resolve, reject) => {
// this
// })
// },
// 上传照片并展示收到的结果 // 上传照片并展示收到的结果
uploadImg(tempImagePath: any) { uploadImg(tempImagePath: any) {
@@ -1060,88 +1055,123 @@ Page({
title: "查询中喵", title: "查询中喵",
mask: true //开启蒙版遮罩 mask: true //开启蒙版遮罩
}); });
return setTimeout(()=>{ // return setTimeout(()=>{
wx.hideLoading(); // wx.hideLoading();
var fake_data = { // var fake_data = {
id:70582140, // id:70582140,
imgUrl:"./static/icons/history.svg", // imgUrl:"./static/icons/history.svg",
res:{ // res:{
scores: 93, // scores: 93,
arr: ["生牛乳"], // arr: ["生牛乳"],
} // }
} // }
var data = fake_data // var data = fake_data
var nowdate = new Date(); // var nowdate = new Date();
var nowyear = nowdate.getFullYear(); // var nowyear = nowdate.getFullYear();
var nowmonth = nowdate.getMonth() + 1; // var nowmonth = nowdate.getMonth() + 1;
var nowday = nowdate.getDate(); // var nowday = nowdate.getDate();
var dateStr = nowyear + '.' + nowmonth + '.' + nowday // var dateStr = nowyear + '.' + nowmonth + '.' + nowday
if (!this.data.data_history[dateStr]) { // if (!this.data.data_history[dateStr]) {
this.data.data_history[dateStr] = [] // this.data.data_history[dateStr] = []
} // }
var historyTemp = // var historyTemp =
{ // {
id: data.id, // id: data.id,
imgUrl: data.imgUrl, // imgUrl: data.imgUrl,
res: data.res, // res: data.res,
hasCollect: false,//目前全是false。。。 // hasCollect: false,
} // }
this.data.data_history[dateStr].push(historyTemp) // this.data.data_history[dateStr].push(historyTemp)
this.setData({ // this.setData({
data_history: this.data.data_history // data_history: this.data.data_history
}) // })
this.sortHistory() // this.sortHistory()
this.show_result_byId(data.id) // this.show_result_byId(data.id)
this.save2storage() // this.save2storage()
},3000) // },3000)
wx.getFileSystemManager().readFile({ // 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, filePath: tempImagePath,
encoding: 'base64', name: 'file',
success: res => { // formData: {
// console.log('data:image/png;base64,' + res.data) // session_key:this.data.session_key
const imgBase64 = res.data // },
wx.request({ success:res=>{
url: '' + serverAddr + '/rcvImg', //仅为示例,并非真实的接口地址 const data = res.data
data: { wx.hideLoading();
imgBase64: imgBase64, var nowdate = new Date();
session_key:this.data.session_key var nowyear = nowdate.getFullYear();
}, var nowmonth = nowdate.getMonth() + 1;
method: "POST", var nowday = nowdate.getDate();
header: { var dateStr = nowyear + '.' + nowmonth + '.' + nowday
'content-type': 'application/json' // 默认值 if (!this.data.data_history[dateStr]) {
}, this.data.data_history[dateStr] = []
success: res => { }
var data = res.data var historyTemp =
console.log(res.data) {
var nowdate = new Date(); id: data.id,
var nowyear = nowdate.getFullYear(); imgUrl: data.imgUrl,
var nowmonth = nowdate.getMonth() + 1; res: data.res,
var nowday = nowdate.getDate(); hasCollect: false,//目前全是false。。。
var dateStr = nowyear + '.' + nowmonth + '.' + nowday }
if (!this.data.data_history[dateStr]) { this.data.data_history[dateStr].push(historyTemp)
this.data.data_history[dateStr] = [] this.setData({
} data_history: this.data.data_history
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)
}
}) })
this.sortHistory()
this.show_result_byId(data.id)
this.save2storage()
} }
}) })
}, },
// 向云发送历史记录和收藏记录数据 // 向云发送历史记录和收藏记录数据
@@ -1444,6 +1474,35 @@ Page({
return res 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 // 获取用户code,以给服务端换取openId
getCode: async function () { getCode: async function () {
var code var code
+1 -1
View File
@@ -68,7 +68,7 @@
<view wx:for="{{ data_lib }}" wx:for-item="n"> <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="ingredient_card" hidden="{{ hidden_lib[n.name.zh] }}" style="background-color: {{ n.riskBgColor }};">
<view class="node_content"> <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_name node_name_en">{{ n.name.en }}</view>
<view class="node_adi"> <view class="node_adi">
+2 -1
View File
@@ -4,5 +4,6 @@
"setting": { "setting": {
"compileHotReLoad": true, "compileHotReLoad": true,
"urlCheck": false "urlCheck": false
} },
"libVersion": "3.2.2"
} }