修改ai助手列表

This commit is contained in:
Leo_Ding 2025-07-22 16:32:04 +08:00
parent b069cdb4d1
commit 87badbbb68
2 changed files with 43 additions and 65 deletions

View File

@ -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,

View File

@ -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);
}
}
}