修改ai助手列表
This commit is contained in:
parent
b069cdb4d1
commit
87badbbb68
@ -46,6 +46,7 @@
|
||||
|
||||
<script>
|
||||
import uniIcons from '@dcloudio/uni-ui/lib/uni-icons/uni-icons.vue'
|
||||
import {IMAGE_BASE_URL,BASE_URL} from '@/utils/config';
|
||||
export default {
|
||||
components: {
|
||||
uniIcons
|
||||
@ -57,7 +58,7 @@
|
||||
isTyping: false,
|
||||
isFocus: false,
|
||||
showDate: true,
|
||||
myAvatar: require('../../static/imgs/ai/shanshiguanjia.png'),
|
||||
myAvatar: require('../../static/imgs/index/nav.png'),
|
||||
currentChat: {
|
||||
name: '张婷婷',
|
||||
avatar: require('../../static/imgs/ai/chuandaguwen.png'),
|
||||
@ -69,7 +70,7 @@
|
||||
abortController: null, // 用于取消请求
|
||||
isStreaming: false, // 标记是否正在接收流
|
||||
userId: null,
|
||||
serverUrl:'',
|
||||
serviceUrl:'',
|
||||
apiKey:'',
|
||||
aiId:null,
|
||||
aiName:''
|
||||
@ -77,25 +78,27 @@
|
||||
}
|
||||
},
|
||||
onLoad(options) {
|
||||
this.serverUrl=options.serverUrl
|
||||
this.serviceUrl=options.serviceUrl
|
||||
this.apiKey=options.apiKey
|
||||
this.aiId=options.id
|
||||
this.currentChat.avatar=options.icon
|
||||
uni.setNavigationBarTitle({
|
||||
title: options.name
|
||||
})
|
||||
},
|
||||
mounted() {
|
||||
try {
|
||||
const value = wx.getStorageSync('userId')
|
||||
console.log(value)
|
||||
if (value === undefined || value === null||value=='') {
|
||||
const userInfo = wx.getStorageSync('userInfo')
|
||||
if (userInfo === undefined || userInfo === null||userInfo=='') {
|
||||
const defaultValue=this.generateMiniProgramUUID()
|
||||
wx.setStorageSync('userId', defaultValue)
|
||||
this.userId=defaultValue
|
||||
this.myAvatar=require('../../static/imgs/index/nav.png')
|
||||
}else{
|
||||
this.userId=userInfo.id
|
||||
this.myAvatar=userInfo.avatar||require('../../static/imgs/index/nav.png')
|
||||
}
|
||||
this.userId=value
|
||||
} catch (e) {
|
||||
console.log(e)
|
||||
const defaultValue=this.generateMiniProgramUUID()
|
||||
wx.setStorageSync('userId', defaultValue)
|
||||
this.userId=defaultValue
|
||||
@ -159,7 +162,7 @@
|
||||
return new Promise((resolve, reject) => {
|
||||
// 使用uni.request进行流式请求
|
||||
uni.request({
|
||||
url: this.serverUrl,
|
||||
url: this.serviceUrl,
|
||||
method: 'POST',
|
||||
data: {
|
||||
'query':inputParams,
|
||||
|
||||
@ -3,13 +3,12 @@
|
||||
<view class="aiHelper">
|
||||
|
||||
<view class="aiHelperContainer">
|
||||
|
||||
<view class="aiHelperTitle" :style="{'background-image': `url(${aiHelperTitleBackground})`}">{{aiHelperTitle}}</view>
|
||||
<view class="aiBox">
|
||||
<view class="aiType" v-for="(item,index) in aiType" :key="item.id" @click="goAiType(item)">
|
||||
<view class="aiTypeContainer" :style="{'background-image': `url(${item.background})`}">
|
||||
|
||||
<view class="aiLeft" :style="{'background-image': `url(${item.imgPath})`}">
|
||||
|
||||
<view class="aiLeft" :style="{'background-image': `url(${item.imagePath})`}">
|
||||
<view class="aiLeftTitle">{{item.name}}</view>
|
||||
</view>
|
||||
<view class="aiRight">
|
||||
@ -30,6 +29,8 @@
|
||||
|
||||
<script>
|
||||
import Footer from '@/components/footer_common.vue';
|
||||
import {get,post} from '@/utils/request';
|
||||
import {IMAGE_BASE_URL,BASE_URL} from '@/utils/config';
|
||||
export default{
|
||||
name:'aiHelper',
|
||||
components:{Footer},
|
||||
@ -37,65 +38,39 @@
|
||||
return{
|
||||
aiHelperTitle:'AI智能助手',
|
||||
aiHelperTitleBackground:'../../static/imgs/ai/title.png',
|
||||
aiType:[
|
||||
// {
|
||||
// id:1,
|
||||
// name:'政策解读',
|
||||
// path:'policy',
|
||||
// description:['您好,','我是政策解读助手!'].join('\n'),
|
||||
// // text:'致力于将复杂的政策文件转化为通俗易懂的信息。我会结合政策背景、核心条款和实际案例,为您提供清晰、中立的解读,帮助您快速抓住重点,规避风险,把握机遇。',
|
||||
// imgPath:'../../static/imgs/ai/zhengceijiedu.png',
|
||||
// background:'../../static/imgs/ai/zhengceijiedu-background.png',
|
||||
// serverUrl:''
|
||||
// },
|
||||
{
|
||||
id:2,
|
||||
name:'膳食管家',
|
||||
path:'diet',
|
||||
description:['您好,','我是你的膳食管家!'].join('\n'),
|
||||
// text:['近来处于换季期,结合润燥、增强免疫力和营养均衡的原则,帮助身体适应气候变化,以下是我为您推荐的食谱:',
|
||||
// '🌟早餐推荐(温暖脾胃,补充能量)',
|
||||
// '1、南瓜小米红枣粥',
|
||||
// '搭配:水煮蛋 + 凉拌菠菜......'].join('\n'),
|
||||
imgPath:'../../static/imgs/ai/shanshiguanjia.png',
|
||||
background:'../../static/imgs/ai/shanshiguanjia-background.png',
|
||||
serverUrl:'http://36.212.197.253:81/v1/chat-messages',
|
||||
apiKey:'app-GPvdbxhckU9MBbc2c0FOYSJC'
|
||||
},
|
||||
{
|
||||
id:3,
|
||||
name:'穿搭顾问',
|
||||
path:'outfits',
|
||||
description:['您好,','我是你的穿搭顾问!'].join('\n'),
|
||||
// text:['🌤️ 今日天气穿搭指南 🌡️',
|
||||
// '根据实时气象数据为您定制穿衣方案,助您舒适应对天气变化!',
|
||||
// '通用公式',
|
||||
// '气温+降水+风力 = 基础穿搭',
|
||||
// '活动场景±体感偏好 = 细节调整......'].join('\n'),
|
||||
imgPath:'../../static/imgs/ai/chuandaguwen.png',
|
||||
background:'../../static/imgs/ai/chuandaguwen-background.png',
|
||||
serverUrl:'http://36.212.197.253:81/v1/workflows/run',
|
||||
apiKey:'app-fHYFvXZz1MUGLPEoK4lx8qWz'
|
||||
},
|
||||
{
|
||||
id:4,
|
||||
name:'生活咨询',
|
||||
path:'lifeCounseling',
|
||||
description:['您好,','我是你的生活小助手!'].join('\n'),
|
||||
// text:'需要帮孩子制定假期计划?或是突然遇到水管漏水?随时告诉我,立刻为你支招!',
|
||||
imgPath:'../../static/imgs/ai/shenghuozixun.png',
|
||||
background:'../../static/imgs/ai/shenghuozixun-background.png',
|
||||
serverUrl:'http://36.212.197.253:81/v1/chat-messages',
|
||||
apiKey:'app-7BhHLjrLWenhsnFk1g4rW9F9'
|
||||
},
|
||||
],
|
||||
aiType:[],
|
||||
}
|
||||
},
|
||||
mounted() {
|
||||
this.getData();
|
||||
},
|
||||
methods:{
|
||||
goAiType(item){
|
||||
uni.navigateTo({
|
||||
url: `/pages/chat/chatPage?serverUrl=${item.serverUrl}&apiKey=${item.apiKey}&id=${item.id}&name=${item.name}`
|
||||
url: `/pages/chat/chatPage?serviceUrl=${item.serviceUrl}&apiKey=${item.apiKey}&id=${item.id}&name=${item.name}&icon=${item.icon}`
|
||||
});
|
||||
},
|
||||
async getData(){
|
||||
let params = {
|
||||
current: 1,
|
||||
pageSize: 10,
|
||||
};
|
||||
try {
|
||||
const res = await get('/api/v1/apps/ai_request', params);
|
||||
if (!res || !res.success) {
|
||||
throw new Error('获取AI助手失败');
|
||||
}
|
||||
if(res.data.length>0){
|
||||
res.data.forEach((item)=>{
|
||||
item.background=IMAGE_BASE_URL+item.background
|
||||
item.imagePath=IMAGE_BASE_URL+item.imagePath
|
||||
item.icon=IMAGE_BASE_URL+item.icon
|
||||
})
|
||||
}
|
||||
this.aiType=res.data
|
||||
} catch (err) {
|
||||
console.error('获取AI助手失败:', err);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user