Prechádzať zdrojové kódy

接口联调完成(文件上传接口有问题)

htc 3 dní pred
rodič
commit
e308a3f2f6

+ 203 - 0
components/deviceBox/index.vue

@@ -0,0 +1,203 @@
+<template>
+	<div class="l_box box">
+		<div class="l_top adfacjb">
+			<div class="lt_l">{{item.alias||item.board||''}}</div>
+			<div class="lt_r adfac">
+				<image src="http://106.54.209.120:8188/static/wifi_on_mini.png" v-if="item.state===1"></image>
+				<image src="http://106.54.209.120:8188/static/wifi_off_mini.png" v-else></image>
+				<image src="http://106.54.209.120:8188/static/online_mini.png" v-if="item.state===1"></image>
+				<image src="http://106.54.209.120:8188/static/offline_mini.png" v-else></image>
+				<div class="ltr_zt" :class="{'zx':item.state===1,'lx':item.state===0}">{{item.state===1?'在线':'离线'}}</div>
+			</div>
+		</div>
+		<div class="l_content">
+			<div class="lc_role adfac">
+				<image class="lcr_l" src="http://106.54.209.120:8188/static/avatar_default.png"></image>
+				<div class="lcr_r">
+					<p>{{item.agent.agentName||''}}</p>
+					<div class="text">角色模板:{{item.roleModelName}}</div>
+					<div class="text">绑定时间:{{item.createDate}}</div>
+				</div>
+			</div>
+			<div class="lc_info">
+				{{}}
+			</div>
+			<div class="lc_btns adfac">
+				<div class="lcb_pre" @tap="editRole(item)">角色编辑</div>
+				<div class="lcb_pre" @tap="changeWifi(item)">配置网络</div>
+				<div class="lcb_pre" @tap="unbindDevice(item)">解绑设备</div>
+			</div>
+		</div>
+	</div>
+</template>
+
+<script>
+	export default {
+		props:{
+			item:{
+				typeof:Object
+			},
+			showInfo:{
+				typeof:Boolean,
+				default:false
+			}
+		},
+		data(){
+			return {
+				
+			}
+		},
+		methods:{
+			editRole(item){
+				this.$emit('editRole');
+				uni.navigateTo({
+					url:`/pagesRole/addRole?agentId=${item.agentId}&deviceId=${item.id}`
+				})
+			},
+			changeWifi(item){
+				uni.navigateTo({
+					url:'/pagesMy/wifi'
+				})
+			},
+			unbindDevice(item){
+				uni.showModal({
+					title:'温馨提示',
+					content:'确定要解绑该设备吗?',
+					success: (res) => {
+						this.$api.post('/device/unbind',{deviceId:item.id}).then(res=>{
+							if(res.data.code!==0) return this.$showToast(res.data.msg)
+							this.$showToast('解绑成功');
+							setTimeout(()=>{
+								this.$emit('unbindSuccess')
+							},1000)
+						})
+					}
+				})
+			}
+		}
+	}
+</script>
+
+<style scoped lang="less">
+	.box{
+		position: relative;
+		width: calc(100% - 60rpx);
+		background: #FFFFFF;
+		box-shadow: 0rpx 4rpx 20rpx 0rpx rgba(0,0,0,0.04);
+		border-radius: 32rpx;
+		border: 1rpx solid #D9F159;
+		box-sizing: border-box;
+	}
+	
+	.l_box{
+		width: 100%;
+		padding: 49rpx 30rpx 40rpx;
+		margin-top: 20rpx;
+		.l_top{
+			.lt_l{
+				font-family: PingFang-SC, PingFang-SC;
+				font-weight: bold;
+				font-size: 32rpx;
+				color: #111111;
+				line-height: 40rpx;
+			}
+			.lt_r{
+				image{
+					width: 42rpx;
+					height: 42rpx;
+					margin-right: 34rpx;
+				}
+				.ltr_zt{
+					font-family: PingFangSC, PingFang SC;
+					font-weight: 400;
+					font-size: 26rpx;
+					line-height: 37rpx;
+					padding-left: 22rpx;
+					position: relative;
+					&::before{
+						content: '';
+						width: 12rpx;
+						height: 12rpx;
+						border-radius: 50%;
+						position: absolute;
+						left: 0;
+						top: 50%;
+						margin-top: -6rpx;
+					}
+					&.zx{
+						color: #1B50FF;
+						&::before{
+							background: #1B50FF;
+						}
+					}
+					&.lx{
+						color: #C7C7C7;
+						&::before{
+							background: #C7C7C7;
+						}
+					}
+				}
+			}
+		}
+		.l_content{
+			border-top: 1rpx solid #E2E2E2;
+			margin-top: 37rpx;
+			padding-top: 36rpx;
+			overflow: hidden;
+			.lc_role{
+				.lcr_l{
+					width: 148rpx;
+					height: 148rpx;
+					border-radius: 50%;
+				}
+				.lcr_r{
+					width: calc(100% - 148rpx);
+					padding-left: 30rpx;
+					box-sizing: border-box;
+					p{
+						font-family: PingFang-SC, PingFang-SC;
+						font-weight: bold;
+						font-size: 32rpx;
+						color: #111111;
+						line-height: 32rpx;
+						overflow: hidden;
+						white-space: nowrap;
+						text-overflow: ellipsis;
+					}
+					.text{
+						font-family: PingFangSC, PingFang SC;
+						font-weight: 400;
+						font-size: 24rpx;
+						color: #7C8592;
+						line-height: 24rpx;
+						margin-top: 24rpx;
+					}
+				}
+			}
+			.lc_info{
+				margin-top: 36rpx;
+				font-family: PingFangSC, PingFang SC;
+				font-weight: 400;
+				font-size: 24rpx;
+				color: #7C8592;
+				line-height: 40rpx;
+			}
+			.lc_btns{
+				margin-top: 62rpx;
+				margin-left: -1rpx;
+				overflow: hidden;
+				.lcb_pre{
+					width: calc(100% / 3);
+					height: 37rpx;
+					border-left: 1rpx solid #72832B;
+					font-family: PingFang-SC, PingFang-SC;
+					font-weight: bold;
+					font-size: 26rpx;
+					color: #72832B;
+					line-height: 37rpx;
+					text-align: center;
+				}
+			}
+		}
+	}
+</style>

+ 2 - 2
http/baseApi.js

@@ -1,5 +1,5 @@
-// const BaseApi = 'https://glt.ringzle.com:8033/witcarbon-app/app' //线上
-const BaseApi = 'http://192.168.2.16:8003/xiaozhi-app/app' //严总
+const BaseApi = 'https://transcend.ringzle.com/xiaozhi-app/app' //线上
+// const BaseApi = 'http://192.168.2.16:8003/xiaozhi-app/app' //严总
 
 export {
 	BaseApi

+ 9 - 2
manifest.json

@@ -102,7 +102,10 @@
     "quickapp" : {},
     /* 小程序特有相关 */
     "mp-weixin" : {
-        "appid" : "wxb9a6bbfcc8449c16",
+        "appid" : "wxb9a6bbfcc8449c16",
+		"networkTimeout": {
+		    "request": 30000
+		},
         "setting" : {
             "urlCheck" : false,
             "es6" : false,
@@ -121,7 +124,11 @@
             "scope.userLocation" : {
                 "desc" : "获取WiFi列表进行设备连接"
             }
-        }
+        },
+		// 允许使用本地IP(关键配置)
+		"android": {
+			"allowLocalNetworking": true
+		}
     },
     "mp-alipay" : {
         "usingComponents" : true

+ 2 - 1
pages.json

@@ -9,7 +9,8 @@
 		{
 			"path": "pages/home",
 			"style": {
-				"navigationStyle": "custom"
+				"navigationStyle": "custom",
+				"enablePullDownRefresh": true
 			}
 		},
 		{

+ 37 - 35
pages/home.vue

@@ -3,38 +3,9 @@
 		<image class="topbg" src="http://106.54.209.120:8188/static/home_topbg.png"></image>
 		<template v-if="list.length">
 			<div class="list" :style="{'margin-top':(360-mt-61)+'px'}">
-				<u-list @scrolltolower="scrolltolower">
+				<u-list>
 					<u-list-item v-for="(item, index) in list" :key="index">
-						<div class="l_box box">
-							<div class="l_top adfacjb">
-								<div class="lt_l">我的设备:{{1}}</div>
-								<div class="lt_r adfac">
-									<image src="http://106.54.209.120:8188/static/wifi_on_mini.png" v-if="index===0"></image>
-									<image src="http://106.54.209.120:8188/static/wifi_off_mini.png" v-else></image>
-									<image src="http://106.54.209.120:8188/static/online_mini.png" v-if="index===0"></image>
-									<image src="http://106.54.209.120:8188/static/offline_mini.png" v-else></image>
-									<div class="ltr_zt" :class="{'zx':index===0,'lx':index===1}">{{index===0?'在线':'离线'}}</div>
-								</div>
-							</div>
-							<div class="l_content">
-								<div class="lc_role adfac">
-									<image class="lcr_l" src="http://106.54.209.120:8188/static/avatar_default.png"></image>
-									<div class="lcr_r">
-										<p>{{'角色昵称'}}</p>
-										<div class="text">角色模板:{{'英语老师'}}</div>
-										<div class="text">绑定时间:{{'2025-05-25'}}</div>
-									</div>
-								</div>
-								<div class="lc_info">
-									{{'一个充满活力与好奇心的年轻人。性格开朗乐观,对生活充满热情。你喜欢在公园等自由自在的地方与朋友们一起探索乐趣…'}}
-								</div>
-								<div class="lc_btns adfac">
-									<div class="lcb_pre">角色编辑</div>
-									<div class="lcb_pre">更换网络</div>
-									<div class="lcb_pre">解绑设备</div>
-								</div>
-							</div>
-						</div>
+						<device-box :item="item" :showInfo="true" @unbindSuccess="unbindSuccess"></device-box>
 					</u-list-item>
 				</u-list>
 			</div>
@@ -54,22 +25,53 @@
 <script>
 	import cusTabbar from '@/components/CusTabbar/index.vue'
 	import bindDevice from '@/components/bindDevice/index.vue'
+	import deviceBox from '@/components/deviceBox/index.vue'
 	export default {
 		components:{
 			cusTabbar,
-			bindDevice
+			bindDevice,
+			deviceBox
 		},
 		data(){
 			return {
-				list:[]
+				list:[],
+				modelMap:new Map()
 			}
 		},
+		async onShow() {
+			await this.getAgentModelList()
+			this.getDeviceList();
+		},
 		methods:{
+			getAgentModelList(){
+				return new Promise((resolve,reject)=>{
+					this.$api.get('/agent/template').then(res=>{
+						if(res.data.code!==0) return this.$showToast(res.data.msg)
+						if(res.data.data.length){
+							let map = new Map();
+							res.data.data.forEach(l=>{
+								map.set(l.systemPrompt,l)
+							})
+							this.modelMap = map;
+						}
+						resolve()
+					})
+				})
+			},
+			getDeviceList(){
+				this.$api.get(`/device/bind/${null}`).then(res=>{
+					if(res.data.code!==0) return this.$showToast(res.data.msg)
+					this.list = res.data.data;
+					this.list.forEach(l=>{
+						l.roleModelName = this.modelMap.get(l.agent.systemPrompt).agentName;
+					})
+				})
+			},
 			addDevice(){
 				this.$refs.bdRef.show = true;
 			},
-			scrolltolower(){
-				
+			unbindSuccess(){
+				this.getDeviceList();
 			}
 		}
 	}

+ 0 - 6
pages/login.vue

@@ -32,12 +32,6 @@
 			},
 			decryptPhoneNumber(e){
 				if(!this.agree) return this.$showToast('请勾选协议和政策');
-				uni.reLaunch({
-					url:'/pages/home'
-				})
-				uni.setStorageSync('userInfo',JSON.stringify({id:1,mobile:'13888888888',username:'龙傲天'}))
-				return 
-				
 				if(e.detail.code) this.wxLogin(e.detail.code);
 			},
 			wxLogin(code){

+ 10 - 4
pages/my.vue

@@ -1,10 +1,10 @@
 <template>
 	<view class="tabPage" :style="{'min-height':h+'px', 'padding-top':mt+'px'}">
 		<cus-header title='我的' :showback="false" bgColor='transparent'></cus-header>
-		<image class="topbg" src="../static/my_topbg.png"></image>
+		<image class="topbg" src="http://106.54.209.120:8188/static/my_topbg.png"></image>
 		<div class="info adffcacjc">
-			<image src="../static/my_avatat_default.png"></image>
-			<p>{{'187 **** 8769'}}</p>
+			<image src="http://106.54.209.120:8188/static/my_avatat_default.png"></image>
+			<p>{{username}}</p>
 		</div>
 		<div class="items">
 			<div class="item adfacjb" @tap="toTurn('/pagesMy/device')">
@@ -55,7 +55,13 @@
 		},
 		data(){
 			return {
-				
+				username:''
+			}
+		},
+		onShow() {
+			if(uni.getStorageSync('userInfo')){
+				let username = JSON.parse(uni.getStorageSync('userInfo')).username;
+				this.username = username.replace(/^(.{3})(?:\d+)(.{4})$/, "$1 **** $2");
 			}
 		},
 		methods:{

+ 89 - 35
pages/role.vue

@@ -1,7 +1,6 @@
 <template>
 	<view class="tabPage" :style="{'min-height':h+'px', 'padding-top':mt+'px'}">
 		<cus-header title='角色' :showback="false" bgColor='transparent'></cus-header>
-		<template v-if="list.length">
 			<div class="query adfacjb">
 				<div class="ql adfac">
 					<image src="http://106.54.209.120:8188/static/query_mini.png"></image>
@@ -9,40 +8,43 @@
 				</div>
 				<div class="qr" @tap="addRole"> + 新增角色</div>
 			</div>
-			<div class="list" :style="{'height':'calc(100vh - '+(mt+156)+'px)'}">
-				<u-swipe-action>
-			        <u-swipe-action-item   v-for="(item, index) in list" :key="index"
-			          :options="options" @click="e=>deleteRole(item,e)" :ref="'swipeAction' + index" :threshold="5"
-			        >
-						<view class="swipe-action u-border-top u-border-bottom">
-							<view class="swipe-action__content">
-							  <div class="l_item adfacjb">
-								<div class="li_l adfac">
-									<image :src="'http://106.54.209.120:8188/static/role_avatar0.png'"></image>
-									<div class="lil_info">
-										<p>{{'词语接龙'}}</p>
-										<div class="tip">
-											<u--text :lines="2" :text="'擅长词语接龙,规范词汇,助你锻炼词汇量与反应能力'" size="24rpx" color="#A6A6A6" :bold="true" lineHeight="40rpx"></u--text>
+			<template v-if="list.length">
+				<div class="list" :style="{'height':'calc(100vh - '+(mt+156)+'px)'}">
+					<u-swipe-action>
+						<u-swipe-action-item   v-for="(item, index) in list" :key="index"
+						  :options="options" @click="e=>deleteRole(item,e)" :ref="'swipeAction' + index" :threshold="5"
+						>
+							<view class="swipe-action u-border-top u-border-bottom">
+								<view class="swipe-action__content">
+								  <div class="l_item adfacjb">
+									<div class="li_l adfac">
+										<image :src="item.img"></image>
+										<div class="lil_info">
+											<p>{{item.agentName}}</p>
+											<div class="tip">
+												<u--text :lines="2" :text="item.systemPrompt" size="24rpx" color="#A6A6A6" :bold="true" lineHeight="40rpx"></u--text>
+											</div>
 										</div>
 									</div>
-								</div>
-								<div class="li_r">配置到设备</div>
-							  </div>
+									<div class="li_r" @tap="toBindDevice(item)">配置到设备</div>
+								  </div>
+								</view>
 							</view>
-						</view>
-			        </u-swipe-action-item>
-			    </u-swipe-action>
-			</div>
-		</template>
-		<template v-else>
-			<div class="empty adffcacjc" :style="{'height':'calc(100vh - '+(mt+106)+'px)'}">
-				<image src="http://106.54.209.120:8188/static/empty_device.png"></image>
-				<p>请先绑定设备</p>
-				<div class="zt_btn" @tap="addDevice"> + 添加新设备</div>
-			</div>
-		</template>
+						</u-swipe-action-item>
+					</u-swipe-action>
+				</div>
+			</template>
+			<template v-else>
+				<div class="empty adffcacjc" :style="{'height':'calc(100vh - '+(mt+156)+'px)'}">
+					<image src="http://106.54.209.120:8188/static/empty_device.png"></image>
+					<p>暂未创建角色</p>
+				</div>
+			</template>
 		<cus-tabbar :tabbarIndex="1"></cus-tabbar>
 		<bind-device ref="bdRef"></bind-device>
+		<u-picker :itemHeight="88" title="已绑设备" :show="show" :columns="deviceList" keyName="board"
+			@cancel="show=false" @confirm="confirm" :immediateChange="true" style="height: 500rpx;">
+		</u-picker>
 	</view>
 </template>
 
@@ -56,16 +58,39 @@
 		},
 		data(){
 			return {
-				list:[1,1],
+				list:[],
+				deviceList:[],
+				show:false,
 				options: [{
 					text: '删除',
 					style: {
 						backgroundColor: '#f56c6c'
 					}
 				}],
+				agentId: "",
+				deviceId: ""
 			}
 		},
+		onShow() {
+			this.getAgentList();
+			this.getDeviceList();
+		},
 		methods:{
+			getAgentList(){
+				this.$api.get('/agent/list').then(res=>{
+					if(res.data.code!==0) return this.$showToast(res.data.msg)
+					this.list = res.data.data;
+					this.list.forEach((l,i)=>{
+						l.img = `http://106.54.209.120:8188/static/role_avatar${i%3}.png`;
+					})
+				})
+			},
+			getDeviceList(){
+				this.$api.get(`/device/bindOther/null`).then(res=>{
+					if(res.data.code!==0) return this.$showToast(res.data.msg)
+					this.deviceList = [res.data.data];
+				})
+			},
 			addDevice(){
 				this.$refs.bdRef.show = true;
 			},
@@ -75,18 +100,47 @@
 				})
 			},
 			deleteRole(item,e){
-				console.log(e,item);
+				let that = this;
 				uni.showModal({
 					content:'删除角色设备将自动解绑需重新添加,您确定删除吗?',
 					success: (res) => {
 						if(res.confirm){
-							this.list.forEach((d, i) => {
-								this.$refs['swipeAction' + i][0].closeHandler();
+							that.$api.del('/agent/'+item.id).then(res=>{
+								if(res.data.code!==0) return that.$showToast(res.data.msg)
+								that.list.forEach((d, i) => {
+									that.$refs['swipeAction' + i][0].closeHandler();
+								})
+								that.getAgentList();
 							})
 						}
 					}
 				})
-			}
+			},
+			toBindDevice(item){
+				this.agentId = item.id;
+				if(item.deviceCount>0){
+					uni.showModal({
+						title:'温馨提示',
+						content:'当前角色已绑定设备,是否继续配置设备?',
+						success: (res) => {
+							if(res.confirm){
+								this.show = true;
+							}
+						}
+					})
+				}else this.show = true
+			},
+			confirm(e){
+				this.show = false;
+				this.deviceId = e.value[0].id;
+				this.$api.post('/agent/agentSetDevice',{agentId:this.agentId,deviceId:this.deviceId}).then(res=>{
+					if(res.data.code!==0) return this.$showToast(res.data.msg)
+					this.$showToast('配置成功')
+					setTimeout(()=>{
+						this.getAgentList();
+					},1000)
+				})
+			},
 		}
 	}
 </script>

+ 54 - 47
pagesMy/device.vue

@@ -3,35 +3,9 @@
 		<cus-header title='设备管理'></cus-header>
 		<template v-if="list.length">
 			<div class="list" :style="{'height':'calc(100vh - '+(mt+100)+'px)'}">
-				<u-list @scrolltolower="scrolltolower">
+				<u-list>
 					<u-list-item v-for="(item, index) in list" :key="index">
-						<div class="l_box box">
-							<div class="l_top adfacjb">
-								<div class="lt_l">我的设备:{{1}}</div>
-								<div class="lt_r adfac">
-									<image src="http://106.54.209.120:8188/static/wifi_on_mini.png" v-if="index===0"></image>
-									<image src="http://106.54.209.120:8188/static/wifi_off_mini.png" v-else></image>
-									<image src="http://106.54.209.120:8188/static/online_mini.png" v-if="index===0"></image>
-									<image src="http://106.54.209.120:8188/static/offline_mini.png" v-else></image>
-									<div class="ltr_zt" :class="{'zx':index===0,'lx':index===1}">{{index===0?'在线':'离线'}}</div>
-								</div>
-							</div>
-							<div class="l_content">
-								<div class="lc_role adfac">
-									<image class="lcr_l" src="http://106.54.209.120:8188/static/avatar_default.png"></image>
-									<div class="lcr_r">
-										<p>{{'角色昵称'}}</p>
-										<div class="text">角色模板:{{'英语老师'}}</div>
-										<div class="text">绑定时间:{{'2025-05-25'}}</div>
-									</div>
-								</div>
-								<div class="lc_btns adfac">
-									<div class="lcb_pre">角色编辑</div>
-									<div class="lcb_pre">更换网络</div>
-									<div class="lcb_pre" @tap="unbindDevice">解绑设备</div>
-								</div>
-							</div>
-						</div>
+						<device-box :item="item" @unbindSuccess="unbindSuccess"></device-box>
 					</u-list-item>
 				</u-list>
 			</div>
@@ -50,42 +24,74 @@
 </template>
 
 <script>
+	import deviceBox from '@/components/deviceBox/index.vue'
 	export default {
+		components:{
+			deviceBox
+		},
 		data(){
 			return {
 				list:[]
 			}
 		},
+		async onShow() {
+			await this.getAgentModelList()
+			this.getList();
+		},
 		methods:{
-			scrolltolower(){
-				
+			getAgentModelList(){
+				return new Promise((resolve,reject)=>{
+					this.$api.get('/agent/template').then(res=>{
+						if(res.data.code!==0) return this.$showToast(res.data.msg)
+						if(res.data.data.length){
+							let map = new Map();
+							res.data.data.forEach(l=>{
+								map.set(l.systemPrompt,l)
+							})
+							this.modelMap = map;
+						}
+						resolve()
+					})
+				})
 			},
 			getList(){
-				
+				this.$api.get(`/device/bind/${null}`).then(res=>{
+					if(res.data.code!==0) return this.$showToast(res.data.msg)
+					this.list = res.data.data;
+					this.list.forEach(l=>{
+						l.roleModelName = this.modelMap.get(l.agent.systemPrompt).agentName;
+					})
+				})
 			},
 			scanBindDevice(){
-				
+				let that = this;
+				uni.scanCode({
+					success: (res) => {
+						let result = JSON.parse(res.result);
+						if(res.errMsg==='scanCode:ok'){
+							that.$api.post('/device/bindAdd',{
+								...result,
+								"type": "",
+								"userId": 0,
+								"agentId": ""
+							}).then(res=>{
+								if(res.data.code!==0) return that.$showToast(res.data.msg)
+								that.$showToast('绑定成功')
+								setTimeout(()=>{
+									this.getList();
+								},1500)
+							})
+						}
+					}
+				})
 			},
 			wifiBindDevice(){
-				this.list = [1,1,1,1];
 				uni.navigateTo({
 					url:'/pagesMy/deviceAdd'
 				})
 			},
-			unbindDevice(){
-				uni.showModal({
-					title:'温馨提示',
-					content:'确定要解绑该设备吗?',
-					success: (res) => {
-						this.$api.post('/device/unbind',{deviceId:item.id}).then(res=>{
-							if(res.data.code!==0) return this.$showToast(res.data.msg)
-							this.$showToast('解绑成功');
-							setTimeout(()=>{
-								this.getList();
-							},1000)
-						})
-					}
-				})
+			unbindSuccess(){
+				this.getList();
 			}
 		}
 	}
@@ -93,6 +99,7 @@
 
 <style scoped lang="less">
 	.page{
+		background: #FFFFFF;
 		padding: 0 21rpx 172rpx;
 		box-sizing: border-box;
 		

+ 19 - 9
pagesMy/feedback.vue

@@ -22,7 +22,7 @@
 		<div class="box">
 			<div class="title adfac">问题描述<span>*</span></div>
 			<div class="desc">
-				<u-textarea height="160rpx" v-model="dto.desc" placeholder="尽量详细描述您遇到的问题、具体位置及体现形式等" border="none"></u-textarea>
+				<u-textarea height="160rpx" v-model="dto.suggestion" placeholder="尽量详细描述您遇到的问题、具体位置及体现形式等" border="none"></u-textarea>
 			</div>
 		</div>
 		<div class="box">
@@ -39,7 +39,7 @@
 		<div class="box lxfs adfacjb">
 			<div class="title">联系方式</div>
 			<div class="contact">
-				<u-input v-model="dto.contact" placeholder="手机号/QQ号/微信号,方便与您联系" border="none"></u-input>
+				<u-input v-model="dto.phone" placeholder="手机号/QQ号/微信号,方便与您联系" border="none"></u-input>
 			</div>
 		</div>
 		<div class="zt_btn" @tap="submit">提交</div>
@@ -54,9 +54,9 @@
 				tidx:1,
 				dto:{
 					type:1,
-					desc:'',
-					photo:'',
-					contact:''
+					suggestion:'',
+					pics:'',
+					phone:''
 				},
 				fileList:[],
 			}
@@ -98,8 +98,8 @@
 			},
 			uploadFilePromise(url) {
 				return new Promise((resolve, reject) => {
-				  let a = uni.uploadFile({
-					url: baseApi.BaseApi + '/uploadFile',
+				  uni.uploadFile({
+					url: baseApi.BaseApi + '/sys/oss/uploadFile',
 					filePath: url,
 					name: "file",
 					success: (res) => {
@@ -110,12 +110,22 @@
 								resolve(data.data);
 							}, 1000);
 						}
-					},
+					}
 				  });
 				});
 			},
 			submit(){
-				if(!this.dto.desc) return this.$showToast('请输入问题描述')
+				if(!this.dto.suggestion) return this.$showToast('请输入问题描述');
+				if(this.fileList.length) this.dto.pics = this.fileList[0].url;
+				this.$api.post('/sys/suggest/save',this.dto).then(res=>{
+					if(res.data.code!==0) return this.$showToast(res.data.msg)
+					this.$showToast('提交成功~');
+					setTimeout(()=>{
+						uni.reLaunch({
+							url:'/pages/my'
+						})
+					},1500)
+				})
 			}
 		}
 	}

+ 17 - 61
pagesMy/wifi.vue

@@ -35,9 +35,9 @@
 	export default {
 		data(){
 			return {
-				openWifi:false,
+				openWifi:true,
 				wifiList:[],
-				myWifi:'111'
+				myWifi:''
 			}
 		},
 		watch:{
@@ -51,29 +51,27 @@
 		},
 		onLoad() {
 			this.getCurrentWifi();
+			this.dealWifi(true)
 		},
 		methods:{
 			getCurrentWifi(){
+				let that = this;
 				wx.startWifi({
 					success(res){
 						wx.getConnectedWifi({
 							success(res){
-								
+								if(res.errCode===0){
+									that.myWifi = res.wifi?.SSID;
+								}
+							},
+							fail: (err) => {
+								if(err.errMsg.indexOf('getConnectedWifi:fail:wifi is disable')>-1) that.$showToast('WiFi未开启')
 							}
 						})
-					},
-					fail: (err) => {
-						console.log(err,'err');
-						if(err.errMsg.indexOf('wifi is disable')>-1) that.$showToast('WiFi未开启')
 					}
 				})
 			},
 			dealWifi(flag){
-				uni.navigateTo({
-					url:'/pagesMy/wifiSet'
-				})
-				return
-				
 				let that = this;
 				if(flag){
 					uni.showLoading({
@@ -97,15 +95,8 @@
 											uni.hideLoading();
 										})
 									})
-								},
-								fail(err) {
-									console.log(err,'err')
 								}
 							})
-						},
-						fail: (err) => {
-							console.log(err,'err');
-							if(err.errMsg.indexOf('wifi is disable')>-1) that.$showToast('WiFi未开启')
 						}
 					})
 				}else{
@@ -113,54 +104,19 @@
 				} 
 			},
 			toSet(item){
+				let that = this;
 				if(item.SSID.indexOf('Xiaozhi-')>-1){
 					uni.connectWifi({
 						SSID: item.SSID,
 						password: '',
 						success: (resu) => {
-							console.log(resu,'resu');
-							wx.request({
-								url:'http://192.168.4.1/scan',
-								success:res=>{
-									console.log(res,'res');
-									wx.request({
-										url:'http://192.168.4.1/submit',
-										method:'POST',
-										data:{
-											ssid:'传秀科技',
-											password:'cx868688'
-										},
-										success:res2=>{
-											console.log(res2,'res2');
-											wx.request({
-												url:'http://192.168.4.1/reboot',
-												method:'POST',
-												success:res3=>{
-													console.log(res3,'res3');
-												},
-												fail:err3=>{
-													console.log(err3,'err3');
-												}
-											})
-										},
-										fail:err2=>{
-											console.log(err2,'err2');
-										}
+							if(resu.errCode===0){
+								setTimeout(()=>{
+									uni.navigateTo({
+										url:'/pagesMy/wifiSet'
 									})
-								},
-								fail:err=>{
-									console.log(err,'err');
-								}
-							})
-							
-							// setTimeout(()=>{
-							// 	uni.navigateTo({
-							// 		url:'/pages/wifiSet'
-							// 	})
-							// },1500)
-						},
-						fail: (err) => { 
-							console.log(err,'err');
+								},2000)
+							}
 						}
 					});
 				}else this.$showToast('请选择Xiaozhi开头的热点')

+ 64 - 96
pagesMy/wifiSet.vue

@@ -23,7 +23,7 @@
 		<div class="box">
 			<div class="b_title">从下面列表选择2.4GWiFi:</div>
 			<div class="b_wifi adfac" v-for="(item,index) in wifi2gList" :key="index" @tap="toCode(item)">
-				<text>{{item.SSID}}</text>
+				<text>{{item.ssid}}</text>
 				<image src="http://106.54.209.120:8188/static/lock.png"></image>
 			</div>
 		</div>
@@ -47,6 +47,7 @@
 				wifi2gList:[],
 				show:false,
 				tcp:'',
+				flag:true
 			}
 		},
 		onLoad() {
@@ -57,112 +58,79 @@
 				uni.showLoading({
 					title:'获取WiFi列表中'
 				})
-				try{
-					// wx.request({
-					// 	url:'http://192.168.4.1/scan',
-					// 	success:res=>{
-					// 		console.log(res,'res');
-					// 		uni.hideLoading();
-					// 	},
-					// 	fail:err=>{
-					// 		console.log(err,'err');
-					// 		uni.hideLoading();
-					// 	}
-					// })
-				}catch(e){
-					console.log(e,'e');
-					uni.hideLoading();
-				}
-				// let that = this;
-				// wx.startWifi({
-				// 	complete (res) {
-				// 		wx.getWifiList({
-				// 			success(res2) {
-				// 				wx.onGetWifiList(res3=> {
-				// 					let temp = [];
-				// 					res3.wifiList.forEach(w=>{
-				// 						if(w.SSID&&w.SSID.indexOf('Xiaozhi-')<0){
-				// 							let exit = temp.find(t=>t.SSID===w.SSID);
-				// 							if(!exit) temp = [...temp,w]
-				// 						}
-				// 					})
-				// 					that.$nextTick(()=>{
-				// 						that.wifi2gList = temp;
-				// 						that.$forceUpdate();
-				// 						uni.hideLoading();
-				// 					})
-				// 				})
-				// 			},
-				// 			fail(err) {
-				// 				console.log(err,'err')
-				// 			}
-				// 		})
-				// 	}
-				// })
+				let that = this;
+				wx.request({
+					url:'http://192.168.4.1/scan',
+					success:res=>{
+						uni.hideLoading();
+						if(res.errMsg==='request:ok'){
+							let temp = [];
+							res.data.forEach(w=>{
+								if(w.ssid&&w.ssid.indexOf('Xiaozhi')<0){
+									let exit = temp.find(t=>t.ssid===w.ssid);
+									if(!exit) temp = [...temp,w]
+								}
+							})
+							that.$nextTick(()=>{
+								that.wifi2gList = temp;
+								that.$forceUpdate();
+								uni.hideLoading();
+							})
+						}
+					},
+					fail:err=>{
+						uni.hideLoading();
+					}
+				})
 			},
 			toConnectWiFi(){
-				uni.navigateTo({
-					url:'/pagesMy/wifiSuccess'
+				if(!this.wifiPwd) return this.$showToast('请输入密码')
+				if(!this.flag) return
+				this.flag  = false;
+				uni.showLoading({
+					title:'联网中...'
 				})
-				return
-				
-				console.log(111);
-				console.log(this.wifiSSID,'this.wifiSSID');
-				console.log(this.wifiPwd,'this.wifiPwd');
-				uni.connectWifi({
-					SSID: this.wifiSSID,
-					password: this.wifiPwd,
-					success: (res) => { 
-						console.log(res,'res');
-						this.show = false;
-						this.$showToast('网络连接成功,开始TCP链接');
-						this.connectTCP();
+				let that = this;
+				wx.request({
+					url:'http://192.168.4.1/submit',
+					method:'POST',
+					data:{
+						ssid:this.wifiSSID,
+						password:this.wifiPwd
+					},
+					success:res2=>{
+						if(res2.errMsg!=='request:ok') return that.$showToast('设备联网失败')
+						wx.request({
+							url:'http://192.168.4.1/reboot',
+							method:'POST',
+							success:res3=>{
+								if(res3.errMsg!=='request:ok') return that.$showToast('设备重启失败')
+								that.flag = true;
+								uni.hideLoading();
+								that.$showToast('联网成功,设备即将重启')
+								setTimeout(()=>{
+									uni.reLaunch({
+										url:'/pages/home'
+									})
+								},1500)
+							},
+							fail:err3=>{
+								that.flag = true;
+								uni.hideLoading();
+							}
+						})
 					},
-					fail: (err) => { 
-						console.log(err,'err');
-						this.show = true;
+					fail:err2=>{
+						that.flag = true;
+						uni.hideLoading();
 					}
-				});
-			},
-			toTryAgain(){
-				this.toConnectWiFi();
-			},
-			// 链接TCP
-			connectTCP() {
-				console.log(222);
-				try{
-					this.tcp = wx.createTCPSocket();
-					this.tcp.connect({
-					  address: '192.168.4.1',
-					  // port: 8266,
-					});
-					this.$nextTick(()=>{
-						this.sendDataTCP();
-					})
-				}catch(e){
-					console.log(e,'e');
-					this.$showModal(JSON.stringify(e))
-				}
-			},
-			// 发送命令-账号密码
-			sendDataTCP() {
-				console.log(333);
-				this.tcp.write(`AT+CJWAP=${this.wifiSSID},${this.wifiPwd}`);
-				this.$nextTick(()=>{
-					this.sendRST();
 				})
 			},
-			// 发送命令-重启
-			sendRST(){
-				console.log(444);
-				this.tcp.write('AT+RST');
-				this.$showToast('配置成功,设备已重启')
-			},
 			close(){
 				this.show = false;
 			},
 			toCode(item){
-				this.wifiSSID = item.SSID;
+				this.wifiSSID = item.ssid;
 			}
 		}
 	}

+ 62 - 40
pagesRole/addRole.vue

@@ -1,8 +1,8 @@
 <template>
 	<view class="page" :style="{'min-height':h+'px', 'padding-top':mt+'px'}">
-		<cus-header title='创建角色' bgColor="transparent"></cus-header>
+		<cus-header :title='title' bgColor="transparent"></cus-header>
 		<div class="box">
-			<div class="title adfac">角色形象<span>*</span></div>
+			<div class="title adfac">角色形象</div>
 			<div class="upload">
 				<div class="sc">
 					<u-upload width="188rpx" height="188rpx"
@@ -22,7 +22,7 @@
 		</div>
 		<div class="box adfacjb">
 			<div class="title">角色昵称<span>*</span></div>
-			<input type="text" placeholder="请输入角色昵称" placeholder-class="ph">
+			<input type="text" v-model="agentDto.agentName" placeholder="请输入角色昵称" placeholder-class="ph">
 		</div>
 		<div class="box adfacjb" @tap="selectModel">
 			<div class="title">角色模板<span>*</span></div>
@@ -36,16 +36,16 @@
 				<div class="title">设备描述</div>
 				<div class="tip">回显不可编辑</div>
 			</div>
-			<div class="desc">{{''}}</div>
+			<div class="desc">{{deviceMemo||''}}</div>
 		</div>
 		<div class="box adfacjb">
 			<div class="title">音色<span>*</span></div>
-			<div class="right adfac">
+			<div class="right adfac" @tap="show=true">
 				<div class="mtext" :class="{'active':voiceText!=='请选择音色'}">{{voiceText}}</div>
 				<image src="http://106.54.209.120:8188/static/arrow_right.png"></image>
 			</div>
 		</div>
-		<div class="zt_btn">创建角色</div>
+		<div class="zt_btn" @tap="comfirmSure">{{agentId?'编辑角色':'创建角色'}}</div>
 		<u-picker :itemHeight="88" title="角色音色" :show="show" :columns="voiceList" keyName="name"
 			@cancel="show=false" @confirm="confirm" :immediateChange="true" style="height: 500rpx;">
 		</u-picker>
@@ -57,20 +57,39 @@
 	export default {
 		data(){
 			return {
+				title:'创建角色',
 				modelText:'请选择角色模版',
 				voiceText:'请选择音色',
 				fileList:[],
 				show:false,
 				voiceList:[],
+				deviceMemo:'',
 				modelMap:new Map(),
+				agentId:'',
+				deviceId:'',
 				agentDto:{
-					
+					"agentName": "",
+					"asrModelId": "",
+					"vadModelId": "",
+					"llmModelId": "",
+					"ttsModelId": "",
+					"ttsVoiceId": "",
+					"memModelId": "",
+					"intentModelId": "",
+					"systemPrompt": "",
+					"langCode": "",
+					"language": "",
+					"deviceId": ""
 				}
 			}
 		},
-		async onLoad() {
-			await this.getAgentModelList()
-			this.getModelVoiceList()
+		onLoad(option) {
+			if(option.agentId){
+				this.title = '编辑角色';
+				this.agentId = option.agentId;
+				this.deviceId = option.deviceId;
+				this.getDetail();
+			} 
 		},
 		methods:{
 			// 删除图片
@@ -106,8 +125,8 @@
 			},
 			uploadFilePromise(url) {
 				return new Promise((resolve, reject) => {
-				  let a = uni.uploadFile({
-					url: baseApi.BaseApi + '/uploadFile',
+				  uni.uploadFile({
+					url: baseApi.BaseApi + '/sys/oss/uploadFile',
 					filePath: url,
 					name: "file",
 					success: (res) => {
@@ -122,38 +141,19 @@
 				  });
 				});
 			},
-			changeModel(item,index){
-				this.midx = index;
-				this.agentDto = this.modelMap.get(item.agentName);
-				this.getModelVoiceList()
-			},
 			selectModel(){
 				uni.navigateTo({
 					url:'/pagesRole/roleModel',
 					events:{
 						selectRoleModel:data=>{
-							console.log(data,'data');
+							this.agentDto = {...this.agentDto,...data};
+							this.modelText = data.agentName||'';
+							this.deviceMemo = data.systemPrompt||'';
+							this.getModelVoiceList();
 						}
 					}
 				})
 			},
-			getAgentModelList(){
-				return new Promise((resolve,reject)=>{
-					this.$api.get('/agent/template').then(res=>{
-						if(res.data.code!==0) return this.$showToast(res.data.msg)
-						this.list = res.data.data;
-						if(this.list.length){
-							this.agentDto = {...this.agentDto,...this.list[0]}
-							let map = new Map();
-							this.list.forEach(l=>{
-								map.set(l.agentName,l)
-							})
-							this.modelMap = map;
-						}
-						resolve();
-					})
-				})
-			},
 			getModelVoiceList(){
 				this.$api.get(`/models/${this.agentDto.ttsModelId}/voices`).then(res=>{
 					if(res.data.code!==0) return this.$showToast(res.data.msg)
@@ -167,17 +167,38 @@
 				this.voiceText = e.value[0].name;
 			},
 			comfirmSure(){
+				if(!this.agentDto.agentName) return this.$showToast('请输入角色昵称')
+				if(this.agentDto.modelText==='请选择角色模版') return this.$showToast('请选择角色模板')
+				if(this.agentDto.voiceText==='请选择音色') return this.$showToast('请选择音色')
+				
 				let dto = JSON.parse(JSON.stringify(this.agentDto));
-				this.$api.post('/agent',dto).then(res=>{
+				if(this.agentId) dto.deviceId = this.deviceId;
+				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.$showToast(this.agentId?'编辑成功':'创建成功');
 					setTimeout(()=>{
-						uni.reLaunch({
-							url:'/pages/home'
-						})
+						let url = this.agentId?'/pages/home':'/pages/role'
+						uni.reLaunch({ url })
 					},1500)
 				})
 			},
+			getDetail(){
+				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};
+					this.deviceMemo = this.agentDto.systemPrompt;
+					this.getModelVoiceList();
+					this.getAgentModelList();
+				})
+			},
+			getAgentModelList(){
+				this.$api.get('/agent/template').then(res=>{
+					if(res.data.code!==0) return this.$showToast(res.data.msg)
+					if(res.data.data.length){
+						this.modelText = res.data.data.find(d=>d.systemPrompt===this.agentDto.systemPrompt)?.agentName;
+					}
+				})
+			},
 		}
 	}
 </script>
@@ -194,6 +215,7 @@
 	.page{
 		background: #F7F6F9;
 		padding: 0 30rpx 30rpx;
+		box-sizing: border-box;
 		.box{
 			background: #FFFFFF;
 			border-radius: 24rpx;

+ 25 - 7
pagesRole/roleModel.vue

@@ -5,14 +5,14 @@
 		<div class="list">
 			<div class="pre" v-for="(item,index) in list" :key="index" :class="{'active':midx===index}" @tap="changeModel(item,index)">
 				<image src="http://106.54.209.120:8188/static/selected_dh.png" v-if="midx===index"></image>
-				{{item}}
+				{{item.agentName}}
 			</div>
 		</div>
 		<div class="adffcacjc">
 			<image src="http://106.54.209.120:8188/static/avatar_default.png"></image>
-			<p>{{'湾湾小何'}}</p>
+			<p>{{agentDto.agentName||''}}</p>
 		</div>
-		<div class="desc">{{'你是一个充满活力与好奇心的年轻。以性格开朗乐观,对生活充满热情。你喜欢在公园等自然环境中放松自己,思考人生。你很善于观察,总能发现一些别人忽略的小美好。你和我在公园偶然相遇,之后我们时常一起在公园漫步、聊天,分享生活中的喜怒哀乐。你总是能给我带来积极的能量和独特的见解。'}}</div>
+		<div class="desc">{{agentDto.systemPrompt||''}}</div>
 		<div class="zt_btn" @tap="confirm">确认选择</div>
 	</view>
 </template>
@@ -22,17 +22,35 @@
 		data(){
 			return {
 				midx:0,
-				list:['湾湾小何','星际游子','英语老师','好奇男孩','汪汪队长']
+				list:[],
+				agentDto:null,
+				modelMap:new Map()
 			}
 		},
+		onLoad() {
+			this.getAgentModelList()
+		},
 		methods:{
+			getAgentModelList(){
+				this.$api.get('/agent/template').then(res=>{
+					if(res.data.code!==0) return this.$showToast(res.data.msg)
+					this.list = res.data.data;
+					if(this.list.length){
+						this.agentDto = this.list[0];
+						let map = new Map();
+						this.list.forEach(l=>{
+							map.set(l.agentName,l)
+						})
+						this.modelMap = map;
+					}
+				})
+			},
 			changeModel(item,index){
 				this.midx = index;
+				this.agentDto = this.modelMap.get(item.agentName);
 			},
 			confirm(){
-				this.getOpenerEventChannel().emit('selectRoleModel', {
-					
-				})
+				this.getOpenerEventChannel().emit('selectRoleModel',this.agentDto)
 				uni.navigateBack();
 			}
 		}