From 082badc787e15f096b7656bf52bc0633bad8f40e Mon Sep 17 00:00:00 2001 From: jia <1451658316@qq.com> Date: Wed, 1 Nov 2023 15:06:35 +0800 Subject: [PATCH] =?UTF-8?q?=E6=96=B0=E5=A2=9E=E5=85=B3=E9=97=AD=E5=8A=9F?= =?UTF-8?q?=E8=83=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- App.vue | 6 + api/api.js | 30 + components/content-top/index.vue | 92 + components/qiqb-share/qiqb-share1.vue | 444 +++++ config/request.js | 2 +- config/requesta.js | 2 +- manifest.json | 54 +- pages/index/index.vue | 262 +-- pages/index/index1.vue | 2239 +++++++++++++++++++++++++ static/icon/fb1.png | Bin 0 -> 446 bytes static/icon/fb2.png | Bin 0 -> 1119 bytes 11 files changed, 2986 insertions(+), 145 deletions(-) create mode 100644 components/content-top/index.vue create mode 100644 components/qiqb-share/qiqb-share1.vue create mode 100644 pages/index/index1.vue create mode 100644 static/icon/fb1.png create mode 100644 static/icon/fb2.png diff --git a/App.vue b/App.vue index b5d8f5c..26a6b9a 100644 --- a/App.vue +++ b/App.vue @@ -2,6 +2,11 @@ export default { onLaunch: function(info) { console.log('App Launch'); + uni.sendHostEvent('log',info, (ret) => { + //发送消息成功回调 + console.log('消息成功app' + JSON.stringify(info)); + + }); if (info.referrerInfo?.extraData?.uniMP) { uni.setStorageSync('uniMP', info.referrerInfo?.extraData?.uniMP); uni.setStorageSync('APP_token', info.referrerInfo?.extraData?.token); @@ -24,4 +29,5 @@ diff --git a/api/api.js b/api/api.js index 29f717d..91ca6fd 100644 --- a/api/api.js +++ b/api/api.js @@ -18,6 +18,36 @@ export function ttWss(data) { return requesta.post(`index/tts`, data); } +//图片识别 +export function ttocr(data) { + return request.post(`xun_fei/ocr`, data); +} + + + + +// base64 转 二进制流(blob) +export function dataURLtoBlob(dataurl) { + // console.log(dataurl); + // let str = "data:audio/wav;base64," + dataurl.slice(2) + // console.log(str); + let mime = "audio/wav" + // var arr = str.split(","), + // mime = arr[0].match(/:(.*?);/), + // let bstr = atob(arr[1]) + let bstr = atob(dataurl) + let n = bstr.length + let u8arr = new Uint8Array(n); + while (n--) { + u8arr[n] = bstr.charCodeAt(n); + } + console.log(u8arr) + // return new Blob([u8arr], { + // type: mime, + // }); +} + + // -防抖 export function debounce(fn, wait) { let delay = wait || 500 diff --git a/components/content-top/index.vue b/components/content-top/index.vue new file mode 100644 index 0000000..02b9206 --- /dev/null +++ b/components/content-top/index.vue @@ -0,0 +1,92 @@ + + + + + \ No newline at end of file diff --git a/components/qiqb-share/qiqb-share1.vue b/components/qiqb-share/qiqb-share1.vue new file mode 100644 index 0000000..0dc3ca9 --- /dev/null +++ b/components/qiqb-share/qiqb-share1.vue @@ -0,0 +1,444 @@ + + + + + + \ No newline at end of file diff --git a/config/request.js b/config/request.js index 4bac5f7..9c2cada 100644 --- a/config/request.js +++ b/config/request.js @@ -39,7 +39,7 @@ function baseRequest(url, method, data, { data: data || {}, success: (res) => { // #ifdef APP-PLUS - // console.log('app', Url + '/api/' + url, res.data); + // #endif if (noVerify) diff --git a/config/requesta.js b/config/requesta.js index df13df9..50d1a90 100644 --- a/config/requesta.js +++ b/config/requesta.js @@ -40,7 +40,7 @@ function baseRequest(url, method, data, { success: (res) => { // #ifdef APP-PLUS - // console.log('app', Url + '/api/' + url, res.data); + console.log('app', Url + '/api/' + url, res.data); // #endif if (noVerify) diff --git a/manifest.json b/manifest.json index cac0549..8eabe35 100644 --- a/manifest.json +++ b/manifest.json @@ -1,6 +1,6 @@ { - "name" : "情感咨询", - "appid" : "__UNI__8080F14", + "name" : "农业咨询", + "appid" : "__UNI__9620511", "description" : "", "versionName" : "1.0.0", "versionCode" : "100", @@ -17,26 +17,34 @@ "delay" : 0 }, /* 模块配置 */ - "modules" : {}, + "modules" : { + "Record" : {}, + "Speech" : {}, + "Camera" : {} + }, /* 应用发布信息 */ "distribute" : { /* android打包配置 */ "android" : { "permissions" : [ - "", - "", - "", - "", - "", + "", "", "", + "", "", - "", - "", + "", "", - "", "", - "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", "" ], "abiFilters" : [ "armeabi-v7a", "arm64-v8a", "x86" ] @@ -47,7 +55,25 @@ }, /* SDK配置 */ "sdkConfigs" : { - "ad" : {} + "ad" : {}, + "speech" : {}, + "share" : {} + } + }, + "nativePlugins" : { + "YL-SpeechRecognition" : { + "__plugin_info__" : { + "name" : "YL-SpeechRecognition-语音合成,语音听写,基于科大讯飞,双端 - [试用版,仅用于自定义调试基座]", + "description" : "语音合成,语音听写,基于科大讯飞,双端(QQ:453503875,微信同)", + "platforms" : "Android,iOS", + "url" : "https://ext.dcloud.net.cn/plugin?id=9512", + "android_package_name" : "", + "ios_bundle_id" : "", + "isCloud" : true, + "bought" : 0, + "pid" : "9512", + "parameters" : {} + } } } }, @@ -55,7 +81,7 @@ "quickapp" : {}, /* 小程序特有相关 */ "mp-weixin" : { - "appid" : "", + "appid" : "wx3267f87bc81f2890", "setting" : { "urlCheck" : false }, diff --git a/pages/index/index.vue b/pages/index/index.vue index e7cdbb5..596ab2b 100644 --- a/pages/index/index.vue +++ b/pages/index/index.vue @@ -5,9 +5,10 @@ - + 情感咨询 + @@ -17,26 +18,26 @@ - - - 您好! - - - 您可以和我说任何有关情感的问题。
- 例如下面的问题,赶快试试吧! -
- - 下方输入: - - 当我被爱情伤害时,我该如何重新振作起来? - + + + 您好! + + 您可以和我说任何有关情感的问题。
+ 例如下面的问题,赶快试试吧! +
+ + 下方输入: + + 怎么保持心情愉快 + + + +
- -
- + @@ -49,11 +50,9 @@ - - - {{c_content}} + + + {{c_content}} --> - - + + @@ -251,19 +248,20 @@ import qiqbshare from "@/components/qiqb-share/qiqb-share.vue" +import returntop from '@/components/content-top/index.vue' const recorderManager = uni.getRecorderManager() const innerAudioContext = uni.createInnerAudioContext() export default { components: { 'bing-math': BingMath, 'qiqbshare': qiqbshare, - +returntop }, data() { return { - wssType: 'qinggan', // 网络连接类型 - avatarType: "/static/icon/qg.png", // AI头像类型 + wssType: 'qinggan', // 网络连接类型 + avatarType: "/static/icon/qg.png", // AI头像类型 talkList: [], ajax: { rows: 15, //每页数量 @@ -321,7 +319,7 @@ Imageurl: '', content1: '', audioContext: null, // 存储当前的innerAudioContext实例 - + } }, mounted() { @@ -345,7 +343,7 @@ }, - + onLoad() { let avatar = uni.getStorageSync('avatar'); avatar ? this.avatar = avatar : null; @@ -373,7 +371,7 @@ // obeyMuteSwitch: false // }) let that = this; - + recorderManager.onStop(function(res) { // 解决第一次录音,挂实例挂载问题 that.$nextTick(() => { @@ -382,7 +380,7 @@ that.voicePath = res.tempFilePath; }) }); - + }, watch: { @@ -479,7 +477,7 @@ sourceType: ['album'], //这要注意,camera掉拍照,album是打开手机相册 success: (res) => { // const tempFilePaths = res.tempFilePaths; - console.log(res.tempFilePaths, '2222222222') + console.log(res.tempFilePaths,'2222222222') uni.uploadFile({ url: HTTP_REQUEST_URL + '/api/upload/image', // 上传地址 filePath: res.tempFilePaths[0], // 要上传的文件路径 @@ -490,7 +488,7 @@ success: function(res) { let data = JSON.parse(res.data) - console.log(data, '222222222222') + console.log(data,'222222222222') if (data.code == 1) { // this.File() let data1 = { @@ -588,24 +586,24 @@ } }); }, - + //图片预览 - previewImage(url) { + previewImage(url){ uni.previewImage({ - urls: [url], // 图片地址数组 - current: url, // 当前预览的图片地址 - success: function() { - console.log('预览图片成功'); - }, - fail: function(error) { - console.error('预览图片失败', error); - } + urls: [url], // 图片地址数组 + current: url, // 当前预览的图片地址 + success: function() { + console.log('预览图片成功'); + }, + fail: function(error) { + console.error('预览图片失败', error); + } }); }, //图片转文字 imgfile(tempFilePath) { let that = this - that.content1 = '' + that.content1='' // console.log(tempFilePath, '2') ttocr({ image: tempFilePath @@ -619,7 +617,7 @@ that.gnishow = false that.talkList = that.talkList.filter(item => item.id !== '@'); - + if (res.data.words.length > 0) { for (let i in res.data.words) { @@ -736,7 +734,7 @@ }, //语音转文字 uploadFile(tempFilePath) { - + let that = this // console.log(tempFilePath) uni.uploadFile({ @@ -747,14 +745,14 @@ 'content-type': 'multipart/form-data' }, success: function(res) { - - + + let data = JSON.parse(res.data) if (data.code == 1) { uni.showToast({ title: '语音识别成功' }); - + that.talkList = that.talkList.filter(item => item.id !== '@'); if (data.data.words.length > 0) { that.content = data.data.words @@ -766,16 +764,16 @@ title: '语音识别失败' }); } - - - + + + }, fail: function(error) { // 上传失败处理逻辑 that.deletespeech() console.log(error, 11); uni.hideLoading(); - + } }) }, @@ -814,32 +812,32 @@ }, - + start(e) { - - this.onFeedTap() - this.touchT = new Date().getTime(); - this.islong = true - this.risshow = false - this.$refs.popup.open('center') - // 限制时长 - this.timer = setInterval(() => { - this.num++ - }, 1000) - this.btnStatus = 1 - recorderManager.start({ - //时长5分钟,单位毫秒 - duration: 300000, - - // format: "pcm", - }); - - this.touchStartX = e.touches[0].pageX; // 获取触摸时的原点 - this.touchStartY = e.touches[0].pageY; // 获取触摸时的原点 + + this.onFeedTap() + this.touchT = new Date().getTime(); + this.islong = true + this.risshow = false + this.$refs.popup.open('center') + // 限制时长 + this.timer = setInterval(() => { + this.num++ + }, 1000) + this.btnStatus = 1 + recorderManager.start({ + //时长5分钟,单位毫秒 + duration: 300000, + + // format: "pcm", + }); + + this.touchStartX = e.touches[0].pageX; // 获取触摸时的原点 + this.touchStartY = e.touches[0].pageY; // 获取触摸时的原点 }, move(e) { - + let that = this; let moveX = this.touchMoveX - e.touches[0].pageX; let moveY = this.touchMoveY - e.touches[0].pageY; @@ -870,15 +868,15 @@ this.touchE = new Date().getTime(); - + if (this.islong) { this.closePop() - + this.islong = false clearInterval(this.timer) this.btnStatus = 0 recorderManager.stop(); - + // this.closePop() if (this.risshow == false && this.touchE - this.touchT > 3000) { let data = { @@ -887,7 +885,7 @@ "type": 2, } this.talkList.push(data); - + // 异步,解决录音结束后,路径没赋值就传值,导致的路径为空 setTimeout(() => { let obj = { @@ -898,31 +896,31 @@ soundTime: this.num }] } - + if (this.voicePath.length > 0 && this.risshow == false) { // this.huashow=true this.TabItemTap() - - + + throttle(this.uploadFile(this.voicePath), 1000) - + } - + this.num = 0 }, 500) - + } else { if (!this.risshow) { uni.showModal({ title: "录音时长不超过3s" }) } - + } - - + + } - + }, @@ -996,18 +994,18 @@ //音频播放 palyaudio(items, i) { - + // console.log(this.talkList,items.audio_file,'000000') if (this.audioContext) { // 停止上一段对话内容的播放 this.audioContext.stop(); this.audioContext = null; } - + this.talkList.forEach((item, index) => { if (index != i) { item.playStatus = true - + } // item.playStatus = (index == i); }); @@ -1016,15 +1014,15 @@ this.talkList[i].playStatus = !this.talkList[i].playStatus if (!this.talkList[i].playStatus) { - - if (items.audio_file.length > 0) { + + if(items.audio_file.length>0){ innerAudioContext.src = items.audio_file; innerAudioContext.play() this.talkList[i].playStatus = false - } else { - this.talkList[i].playStatus = true + }else{ + this.talkList[i].playStatus = true } - + } else { innerAudioContext.pause() @@ -1184,28 +1182,28 @@ }, // 关闭连接 closeSocketTask() { - - try { - this.talkList = this.talkList.filter(item => item.id !== '@'); - clearInterval(this.timer); - this.talkList[this.talkList.length - 1].audio_file = '' - this.talkList[this.talkList.length - 1].content = this.c_content + ''; - // console.log(this.talkList[this.talkList.length - 1].content); - // this.c_content = ''; - // this.n_content = ''; - this.socketTask.close({ - code: 500, // APP端存在BUG,正常关闭的code为1000,无法正常关闭,需要将code换为其他值 - complete: (res) => { - this.showStop = false; - console.log('主动断开', res); - this.wsLiveFlag = false; - } - }) - } catch (e) { - //TODO handle the exception - } - - + + try { + this.talkList = this.talkList.filter(item => item.id !== '@'); + clearInterval(this.timer); + this.talkList[this.talkList.length - 1].audio_file='' + this.talkList[this.talkList.length - 1].content = this.c_content + ''; + // console.log(this.talkList[this.talkList.length - 1].content); + // this.c_content = ''; + // this.n_content = ''; + this.socketTask.close({ + code: 500, // APP端存在BUG,正常关闭的code为1000,无法正常关闭,需要将code换为其他值 + complete: (res) => { + this.showStop = false; + console.log('主动断开', res); + this.wsLiveFlag = false; + } + }) + } catch (e) { + //TODO handle the exception + } + + }, // 发送信息 @@ -1217,8 +1215,8 @@ }) return; } - - + + // 将当前发送信息 添加到消息列表。 let data = { "id": new Date().getTime(), @@ -1254,7 +1252,7 @@ }, - + send1() { if (!this.content1) { uni.showToast({ @@ -1339,7 +1337,7 @@ // } // } // }; - + if (this.historyTextList.length > 9) this.params = JSON.parse(JSON.stringify(this .historyTextList .splice(-9))); @@ -1367,11 +1365,11 @@ realThis.tempRes = realThis.tempRes + dataArray[i].content } - if (this.n_content.length > 0) { + if(this.n_content.length>0){ this.nums = this.talkList.length - 1 this.txtspeech(this.n_content, this.talkList.length - 1) - this.showStop = true; + this.showStop = true; } this.cavshare(this.talkList) let temp = JSON.parse(res.data) @@ -1396,7 +1394,7 @@ "role": "assistant", "content": this.tempRes }) - + setTimeout(() => { let that = this realThis.socketTask.close({ @@ -1605,9 +1603,15 @@ top: 0; position: fixed; z-index: 10; + .container-retun{ + position: absolute; + right: 20rpx; + padding-top: var(--status-bar-height); + top: 0; + } + } - .popup_box { height: 100vh; width: 100vw; diff --git a/pages/index/index1.vue b/pages/index/index1.vue new file mode 100644 index 0000000..723ac0d --- /dev/null +++ b/pages/index/index1.vue @@ -0,0 +1,2239 @@ + + + + + \ No newline at end of file diff --git a/static/icon/fb1.png b/static/icon/fb1.png new file mode 100644 index 0000000000000000000000000000000000000000..786e3f31f35939f0542352f9846ea2b19a60fce6 GIT binary patch literal 446 zcmV;v0YUzWP)Px$cu7P-R7gw3)jvyIQ4j_2--3mO5DU8~u`oo-6oO3(L5PK*Mba6PPCvpz0%-(4 zKq@O2)J{;rU;-9)QLs=DOsZG}B4}ZmLWqpqh3CV4`%l)}J>JYY=g!PMQ_}wF#T;fZ zjQIY8eXL@uU5Zkh0I!pfz5<+Gyu*2`Tv?INFoAyj#CKd308e8bT@8>2-YZ-d#J<2J zdT^5X|3!RNLSWDu%b}UL*!{1_*$IzRbVHzrdgd)$-t|gXzkzB;#yec z5c$6j(;miiF+VWYtisgNrA*#n8k-`h%41iu8yAgK@&lF&X7XivZP}1c&1AU2NWIq` zGqnAPulsE*g{)78KZZ{|#V>rTl oG`qWplHfBOVhx+E0$1~H05~#E!`+b`&j0`b07*qoM6N<$g2)HOl>h($ literal 0 HcmV?d00001 diff --git a/static/icon/fb2.png b/static/icon/fb2.png new file mode 100644 index 0000000000000000000000000000000000000000..a9534065e79c604528fc2cdb79dba242eae84170 GIT binary patch literal 1119 zcmV-l1fctgP)Px(8A(JzR9Hv7m|Lh-RTPFlGo&IdE7G#aO3fY&GKn(s5@l9|X^7^d<%?ZJp$F5n zjKmviA_VpzLWx8{C1QeNX{9JZT82eh5N2gw$h?=ycbHRVleO1gOSg@;bN0CWYmI;0 zRy*oTJKzrBUf?d^R-ij@6>tS`0QeR70oV>~0@ea2>x42$RWbMrz*9iiszyQY6tEJQ z3v8}pTLoBOUo#y7SCkf5o&4#SuRP{l9;6~zlWM_!7L0}Hli;{n~ zRYi#t=Ucy;z+MBUmDsEab2X}L6WE_X#~Q#s3;nGQwr0TI1D;GAZWfqb-KG|0Au#cO zPG#QDRtju2Ff;-3A@D>Aurv(kOinrRqxc5hy)cfzVF-lT~y_En-raI zoq=`XwdRgp>O9}xZqhJQJ7ajoOZ2pfMjelwN5V33)~?aPdnK?u7!;+?bME~>UODkC za41ofL!M&~hb7RDEk)ue8WZOAe||6fMBtv}=K((xq+PicJTqldLr%4wYq?bUsB%+q zFuE0p0!@729cBKi0E_l^cDD}Oir>QO%EzI2T(g@UIfdkJ7SJ(bb96FzIs5VC#>~id l+BV~5FOLM(XtgekcLr(s%Yx}q$(aBE002ovPDHLkV1kui{;B`~ literal 0 HcmV?d00001