完善农业咨询小程序
18
App.vue
|
@ -1,13 +1,23 @@
|
|||
<script>
|
||||
export default {
|
||||
onLaunch: function() {
|
||||
console.log('App Launch')
|
||||
onLaunch: function(info) {
|
||||
console.log('App Launch');
|
||||
if (info.referrerInfo?.extraData?.uniMP) {
|
||||
uni.setStorageSync('uniMP', info.referrerInfo?.extraData?.uniMP);
|
||||
uni.setStorageSync('APP_token', info.referrerInfo?.extraData?.token);
|
||||
if(info.referrerInfo?.extraData?.avatar){
|
||||
uni.setStorageSync('avatar', info.referrerInfo?.extraData?.avatar);
|
||||
uni.$emit('MPinfo', {
|
||||
avatar: info.referrerInfo?.extraData?.avatar,
|
||||
});
|
||||
}
|
||||
}
|
||||
},
|
||||
onShow: function() {
|
||||
console.log('App Show')
|
||||
console.log('App Show');
|
||||
},
|
||||
onHide: function() {
|
||||
console.log('App Hide')
|
||||
console.log('App Hide');
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
{
|
||||
"name" : "xunfeiAi",
|
||||
"name" : "农业咨询",
|
||||
"appid" : "__UNI__9620511",
|
||||
"description" : "",
|
||||
"versionName" : "1.0.0",
|
||||
|
|
|
@ -3,16 +3,10 @@
|
|||
{
|
||||
"path": "pages/index/index",
|
||||
"style": {
|
||||
"navigationBarTitleText": "讯飞AI",
|
||||
"navigationBarTitleText": "农业咨询",
|
||||
"bounce": "none"
|
||||
// "softinputMode": "adjustResize"
|
||||
}
|
||||
}, {
|
||||
"path": "pages/index/chat",
|
||||
"style": {
|
||||
"navigationBarTitleText": "讯飞星火",
|
||||
"bounce": "none"
|
||||
}
|
||||
}
|
||||
],
|
||||
"globalStyle": {
|
||||
|
|
|
@ -7,7 +7,7 @@
|
|||
<view class="talk-list">
|
||||
<view v-for="(item,index) in talkList" :key="index" :id="`msg-${item.id}`">
|
||||
<view class="item flex_col" :class=" item.type == 1 ? 'push':'pull' ">
|
||||
<image :src="item.pic" mode="aspectFill" class="pic"></image>
|
||||
<image :src="item.type==1?avatar:item.pic" mode="aspectFill" class="pic"></image>
|
||||
<view v-if="talkList.length-1==index" class="content multiline-text">
|
||||
<!-- <rich-text :nodes="item.content"></rich-text> -->
|
||||
<bing-math v-if="c_content!=''" :key="`math-${item.id}`" class="bing-math" :latex="c_content"></bing-math>
|
||||
|
@ -65,6 +65,7 @@
|
|||
content: '',
|
||||
c_content: '',
|
||||
n_content: '',
|
||||
avatar: '/static/avatar.png', // 用户头像
|
||||
params: [], // 发送的消息内容
|
||||
timer: '',
|
||||
socketTask: {},
|
||||
|
@ -94,6 +95,13 @@
|
|||
})
|
||||
})
|
||||
},
|
||||
onLoad() {
|
||||
let avatar = uni.getStorageSync('avatar');
|
||||
avatar ? this.avatar = avatar : null;
|
||||
uni.$on('MPinfo', (e) => {
|
||||
this.avatar = e.avatar;
|
||||
})
|
||||
},
|
||||
beforeDestroy() {
|
||||
// #ifdef APP-PLUS
|
||||
uni.offKeyboardHeightChange();
|
||||
|
@ -273,8 +281,8 @@
|
|||
// this.c_content = '';
|
||||
// this.n_content = '';
|
||||
this.socketTask.close({
|
||||
code: 500, // APP端存在BUG,正常关闭的code为1000,无法正常关闭,需要将code换为其他值
|
||||
complete: (res)=>{
|
||||
code: 500, // APP端存在BUG,正常关闭的code为1000,无法正常关闭,需要将code换为其他值
|
||||
complete: (res) => {
|
||||
this.showStop = false;
|
||||
console.log('主动断开', res);
|
||||
this.wsLiveFlag = false;
|
||||
|
@ -299,15 +307,16 @@
|
|||
"id": new Date().getTime(),
|
||||
"content": this.content,
|
||||
"type": 1,
|
||||
"pic": "/static/avatar.png"
|
||||
"pic": this.avatar
|
||||
}
|
||||
console.log(data);
|
||||
this.TEXT = this.content;
|
||||
this.talkList.push(data);
|
||||
this.talkList.push({
|
||||
"id": new Date().getTime(),
|
||||
"content": '',
|
||||
"type": 2,
|
||||
"pic": "/static/avatar.png"
|
||||
"pic": "/static/icon/ny.png"
|
||||
});
|
||||
this.n_content = '';
|
||||
this.c_content = '';
|
||||
|
@ -330,8 +339,9 @@
|
|||
let realThis = this;
|
||||
this.socketTask = uni.connectSocket({
|
||||
//url: encodeURI(encodeURI(myUrl).replace(/\+/g, '%2B')),
|
||||
url: 'wss://chat.lihaink.cn/chat' + '?timestamp=' + Date.now(),
|
||||
url: `wss://chat.lihaink.cn/chat?type=农业咨询×tamp=${Date.now()}`,
|
||||
method: 'GET',
|
||||
token: '',
|
||||
success: res => {
|
||||
console.log(res, "ws成功连接...")
|
||||
realThis.wsLiveFlag = true;
|
||||
|
@ -382,7 +392,7 @@
|
|||
console.log('收到API返回的内容:', res.data);
|
||||
let obj = JSON.parse(res.data)
|
||||
// console.log("我打印的"+obj.payload);
|
||||
if(!realThis.wsLiveFlag) return ;
|
||||
if (!realThis.wsLiveFlag) return;
|
||||
let dataArray = obj.payload.choices.text;
|
||||
for (let i = 0; i < dataArray.length; i++) {
|
||||
this.talkList[this.talkList.length - 1].content += dataArray[i].content;
|
||||
|
|
Before Width: | Height: | Size: 16 KiB After Width: | Height: | Size: 13 KiB |
BIN
static/iat.png
Before Width: | Height: | Size: 5.0 KiB |
Before Width: | Height: | Size: 5.1 KiB |
BIN
static/ise.png
Before Width: | Height: | Size: 10 KiB |
Before Width: | Height: | Size: 11 KiB |
BIN
static/logo.png
Before Width: | Height: | Size: 3.9 KiB |
BIN
static/tts.png
Before Width: | Height: | Size: 5.1 KiB |
Before Width: | Height: | Size: 5.2 KiB |