diff --git a/miniprogram/app.json b/miniprogram/app.json index a63723a..a04b18b 100644 --- a/miniprogram/app.json +++ b/miniprogram/app.json @@ -1,11 +1,13 @@ { - "pages": [ - "pages/index/index", - "pages/logs/logs" - ], - "window": { - "navigationStyle": "custom" - }, - "style": "v2", - "sitemapLocation": "sitemap.json" + "pages": [ + "pages/index/index", + "pages/logs/logs" + ], + "window": { + "navigationStyle": "custom" + }, + "plugins": { + }, + "style": "v2", + "sitemapLocation": "sitemap.json" } \ No newline at end of file diff --git a/miniprogram/pages/index/index.scss b/miniprogram/pages/index/index.scss index 81109a6..e1d90f4 100644 --- a/miniprogram/pages/index/index.scss +++ b/miniprogram/pages/index/index.scss @@ -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{ diff --git a/miniprogram/pages/index/index.ts b/miniprogram/pages/index/index.ts index 9e4481c..749a54b 100644 --- a/miniprogram/pages/index/index.ts +++ b/miniprogram/pages/index/index.ts @@ -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 diff --git a/miniprogram/pages/index/index.wxml b/miniprogram/pages/index/index.wxml index 6cda6b6..a8bedc6 100644 --- a/miniprogram/pages/index/index.wxml +++ b/miniprogram/pages/index/index.wxml @@ -68,7 +68,7 @@