Преглед на файлове

角色头像上传和编辑

htc преди 2 дни
родител
ревизия
8410496158
променени са 3 файла, в които са добавени 8 реда и са изтрити 5 реда
  1. 1 1
      components/deviceBox/index.vue
  2. 3 3
      pages/role.vue
  3. 4 1
      pagesRole/addRole.vue

+ 1 - 1
components/deviceBox/index.vue

@@ -12,7 +12,7 @@
 		</div>
 		<div class="l_content">
 			<div class="lc_role adfac">
-				<image class="lcr_l" src="https://transcend.ringzle.com/xiaozhi-app/profile/2025/05/29/24380873-b8d7-413c-8d9d-d997fe13685d.png"></image>
+				<image class="lcr_l" :src="item.agent.avatar||'https://transcend.ringzle.com/xiaozhi-app/profile/2025/05/29/24380873-b8d7-413c-8d9d-d997fe13685d.png'"></image>
 				<div class="lcr_r">
 					<p>{{item.agent.agentName||''}}</p>
 					<div class="text">角色模板:{{item.roleModelName||''}}</div>

+ 3 - 3
pages/role.vue

@@ -18,7 +18,7 @@
 								<view class="swipe-action__content">
 								  <div class="l_item adfacjb" @tap.stop="showDetail(item)">
 									<div class="li_l adfac">
-										<image :src="item.img"></image>
+										<image :src="item.avatar||item.img"></image>
 										<div class="lil_info">
 											<p>{{item.agentName}}</p>
 											<div class="tip">
@@ -92,7 +92,6 @@
 		},
 		onShow() {
 			this.getAgentList();
-			this.getDeviceList();
 		},
 		methods:{
 			queryRole(){
@@ -109,7 +108,7 @@
 				})
 			},
 			getDeviceList(){
-				this.$api.get(`/device/bindOther/null`).then(res=>{
+				this.$api.get(`/device/bindOther/${this.agentId}`).then(res=>{
 					if(res.data.code!==0) return this.$showToast(res.data.msg)
 					this.deviceList = [res.data.data];
 				})
@@ -156,6 +155,7 @@
 			toBindDevice(item){
 				this.agentId = item.id;
 				this.show = true;
+				this.getDeviceList();
 				// if(item.deviceCount>0){
 				// 	uni.showModal({
 				// 		title:'温馨提示',

+ 4 - 1
pagesRole/addRole.vue

@@ -2,7 +2,7 @@
 	<view class="page" :style="{'min-height':h+'px', 'padding-top':mt+'px'}">
 		<cus-header :title='title' bgColor="transparent" :backUrl="backUrl"></cus-header>
 		<div class="box">
-			<div class="title adfac">角色形象</div>
+			<div class="title adfac">角色形象<span>*</span></div>
 			<div class="upload">
 				<div class="sc">
 					<u-upload width="188rpx" height="188rpx"
@@ -186,6 +186,7 @@
 				this.voiceText = e.value[0].name;
 			},
 			comfirmSure(){
+				if(this.fileList.length===0) return this.$showToast('请上传角色头像')
 				if(!this.agentDto.agentName) return this.$showToast('请输入角色昵称')
 				if(this.agentDto.voiceText==='请选择音色') return this.$showToast('请选择音色')
 				
@@ -201,6 +202,7 @@
 				dto.chatHistoryConf = 1;
 				dto.langCode = 'zh';
 				dto.language = '中文';
+				if(this.fileList.length) dto.avatar = this.fileList[0].url;
 				this.$api.post(this.agentId?`/agent/update/${this.agentId}`:'/agent',dto).then(res=>{
 					if(res.data.code!==0) return this.$showToast(res.data.msg)
 					this.$showToast(this.agentId?'编辑成功':'创建成功');
@@ -213,6 +215,7 @@
 				this.$api.get(`/agent/${this.agentId}`).then(res=>{
 					if(res.data.code!==0) return this.$showToast(res.data.msg)
 					this.agentDto = {...this.agentDto,...res.data.data};
+					if(this.agentDto.avatar) this.fileList.push({url:this.agentDto.avatar});
 					if(this.agentDto.systemPrompt) this.showta = true;
 					this.getModelVoiceList();
 				})