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