From f4a4c7709e09bb7c31f802ea8187d1e117efda2b Mon Sep 17 00:00:00 2001
From: liuyg <376836862@qq.com>
Date: Thu, 12 Aug 2021 09:48:16 +0800
Subject: [PATCH] 视频

---
 pages/home/home.vue              |   32 +++
 components/submit/submit.vue     |  225 ++++++++++++----------
 pages.json                       |   36 +-
 App.vue                          |   84 ++++++++
 pages/videoCall/videoCall.nvue   |  115 +++++++++--
 pages/groupChat/groupChat.vue    |    6 
 store/index.js                   |    4 
 static/images/chatroom/phone.png |    0 
 components/contacts/contacts.vue |    2 
 main.js                          |    2 
 pages/groupChat/chating.vue      |   13 
 store/mutations.js               |   37 +++
 store/actions.js                 |    5 
 13 files changed, 403 insertions(+), 158 deletions(-)

diff --git a/App.vue b/App.vue
index 7a4e426..79c0309 100644
--- a/App.vue
+++ b/App.vue
@@ -4,6 +4,14 @@
 		data() {
 			return {
 				login: '',
+
+				show: true,
+				name: 'a',
+				list: [{
+					"name": 'tip',
+					"msg": 'The first content!'
+				}],
+				content: '123456'
 			}
 		},
 		methods: {
@@ -25,14 +33,84 @@
 						url: 'pages/loging/loging?id=1',
 					})
 				}
-			}
+			},
+			//发送消息
+			send: function() {
+				if (this.content) {
+					this.list.push({
+						"name": this.name,
+						"msg": this.content
+					})
+					console.log(this.list)
+					this.socket.emit('sendMessage', {
+						"name": this.name,
+						"msg": this.content
+					});
+					this.content = ''
+					uni.pageScrollTo({
+						duration: 0,
+						scrollTop: this.list.length * 100
+					})
+				} else {
+					uni.showToast({
+						title: '请输入内容',
+						icon: 'none'
+					})
+				}
+			},
+			//提交姓名
+			onSubmitName: function() {
+				console.log(this.name)
+				if (this.name) {
+					this.show = false
+					this.socket.emit('newPeople', this.name);
+				}
+			},
 		},
 		watch: {},
-		mounted() {},
+		mounted() {
+			// 加载长连接服务器
+			// this.socket.on('connect', () => {
+			// 	console.log('connection created.');
+			// 	// that.onSubmitName();
+			// });
+
+
+			
+		},
 		onLaunch: function() { //初始化完成时触发(全局只触发一次)
+			var that = this;
 			if (WxStorage.get("init") == '') {
 				WxStorage.set("init", 'false');
-				console.log('第一次进入')
+				console.log('第一次进入');
+				
+				// uni.connectSocket({
+				// 	url: 'ws://192.168.0.111:9034/websocket'
+				// });
+				
+				// uni.onSocketOpen(function(res) {
+				// 	socketOpen = true;
+				// 	sendSocketMessage();
+				// });
+				
+				// function sendSocketMessage() {
+				// 	var data = {
+				// 				type: that.$store.state.puserName,
+				// 				id: that.$store.state.puserID
+				// 			}
+				// 	if (socketOpen) {
+				// 		uni.sendSocketMessage({
+				// 			data: JSON.stringify(data)
+				// 		});
+				// 	}
+				// }
+
+				// 加载长连接服务器
+				// this.socket.on('connect', () => {
+				// 	console.log('connection created.');
+				// 	that.onSubmitName();
+				// });
+
 			}
 			// this.judgeAdmin();
 		},
diff --git a/components/contacts/contacts.vue b/components/contacts/contacts.vue
index 28acda7..67163ba 100644
--- a/components/contacts/contacts.vue
+++ b/components/contacts/contacts.vue
@@ -76,7 +76,7 @@
 				var datas = this.Pdata;
 				//alert(datas.name)
 				uni.navigateTo({
-					url: '/pages/groupChat/chating?chatID=' + datas.id.toString()
+					url: '/pages/groupChat/chating?chatID=' + datas.id.toString() + '&data=' + JSON.stringify(datas)
 				});
 			},
 			onClose() { //触摸遮罩事件
diff --git a/components/submit/submit.vue b/components/submit/submit.vue
index 1098c75..d2cd28e 100644
--- a/components/submit/submit.vue
+++ b/components/submit/submit.vue
@@ -3,85 +3,65 @@
 		<view class="submit">
 			<view class="submit-chat">
 				<view class="bt-img">
-					<image src="../../static/images/chatroom/voice.png" 
-								 mode=""
-								 @tap="records"/>
+					<image src="../../static/images/chatroom/voice.png" mode="" @tap="records" />
 				</view>
-				<textarea auto-height="true" 
-									class="chat-send btn" 
-									:class="{displaynone: isrecord}"
-									@input="inputs"
-									v-model="msg"
-									@focus="focus"/>
-				<view class="record btn"
-							:class="{displaynone: !isrecord}"
-							@touchstart="touchstart"
-							@touchend="touchend"
-							@touchmove="touchmove"
-							>
+				<textarea auto-height="true" class="chat-send btn" :class="{displaynone: isrecord}" @input="inputs"
+					v-model="msg" @focus="focus" />
+				<view class="record btn" :class="{displaynone: !isrecord}" @touchstart="touchstart" @touchend="touchend"
+					@touchmove="touchmove">
 					按住说话
 				</view>
 				<view class="bt-img">
-					<image src="../../static/images/chatroom/emoji.png" 
-								 mode=""
-								 @tap="emoji"/>
+					<image src="../../static/images/chatroom/emoji.png" mode="" @tap="emoji" />
 				</view>
 				<view class="bt-img">
-					<image src="../../static/images/chatroom/add.png" 
-								 mode=""
-								 @tap="more"/>
+					<image src="../../static/images/chatroom/add.png" mode="" @tap="more" />
 				</view>
 			</view>
-			<view class="emoji"
-						:class="{ displaynone: !isemoji }">
+			<view class="emoji" :class="{ displaynone: !isemoji }">
 				<view class="emoji-send">
-					<view class="emoji-send-del"
-								@tap="emojiBack">
-								删除
+					<view class="emoji-send-del" @tap="emojiBack">
+						删除
 					</view>
-					<view class="emoji-send-bt"
-								@tap="emojiSend">
-								发送
+					<view class="emoji-send-bt" @tap="emojiSend">
+						发送
 					</view>
 				</view>
-				<emoji @emotion="emotion"
-							 :height="260" />
+				<emoji @emotion="emotion" :height="260" />
 			</view>
-			
-			<view class="more"
-						:class="{ displaynone: !ismore }">
-				<view class="more-list" 
-							@tap="sendImg('album')">
-					<image src="../../static/images/chatroom/photo.png"/>
+
+			<view class="more" :class="{ displaynone: !ismore }">
+				<view class="more-list" @tap="sendImg('album')">
+					<image src="../../static/images/chatroom/photo.png" />
 					<text class="more-list-title">图片</text>
 				</view>
-				<view class="more-list"
-							@tap="sendImg('camera')">
-					<image src="../../static/images/chatroom/camera.png"/>
+				<view class="more-list" @tap="sendImg('camera')">
+					<image src="../../static/images/chatroom/camera.png" />
 					<text class="more-list-title">拍照</text>
 				</view>
 				<view class="more-list">
-					<image src="../../static/images/chatroom/file.png"/>
+					<image src="../../static/images/chatroom/file.png" />
 					<text class="more-list-title">文件</text>
 				</view>
-				<view class="more-list"
-							@tap="chooseLocation()">
-					<image src="../../static/images/chatroom/location.png"/>
+				<view class="more-list" @tap="chooseLocation()">
+					<image src="../../static/images/chatroom/location.png" />
 					<text class="more-list-title">位置</text>
 				</view>
-				<view class="more-list">
-					<image src="../../static/images/chatroom/vedio.png"/>
+				<view class="more-list" @click="openAudio('Mains')">
+					<image src="../../static/images/chatroom/phone.png" />
+					<text class="more-list-title">语音</text>
+				</view>
+				<view class="more-list" @click="openVideo('Mains')">
+					<image src="../../static/images/chatroom/vedio.png" />
 					<text class="more-list-title">视频</text>
 				</view>
 			</view>
 		</view>
-		
+
 		<!-- 录制语音遮罩 -->
-		<view class="voice-bg"
-					:class="{displaynone: !voicebg}">
+		<view class="voice-bg" :class="{displaynone: !voicebg}">
 			<view class="voice-bg-len">
-				<view class="voice-bg-time"
-							:style="{width:vlength/0.6 + '%'}">
+				<view class="voice-bg-time" :style="{width:vlength/0.6 + '%'}">
 					{{ vlength }} "
 				</view>
 			</view>
@@ -92,10 +72,11 @@
 
 <script>
 	import emoji from './emoji/emoji.vue'
-	
+
 	const recorderManager = uni.getRecorderManager()
-	
+
 	export default {
+		props: ['names'],
 		data() {
 			return {
 				isrecord: false,
@@ -108,10 +89,10 @@
 				pageY: 0,
 			};
 		},
-		components:{
+		components: {
 			emoji,
 		},
-		methods:{
+		methods: {
 			// 获取高度
 			_getElementHeight() {
 				const query = uni.createSelectorQuery().in(this);
@@ -154,34 +135,34 @@
 			inputs(e) {
 				let chatm = e.detail.value
 				let pos = chatm.indexOf('\n')
-				if(pos != -1 && chatm.length > 1) {
-					this.send(this.msg,0)
-				}
-				setTimeout(() => {
-					this._getElementHeight()
-				},10)
-			},
-			// 输入框聚焦
-			focus(){
-				this.isemoji = false;
-				this.ismore = false;
-				setTimeout(() => {
-					this._getElementHeight()
-				},10)
-			},
-			// 表情内发送
-			emojiSend() {
-				if(this.msg.length > 0) {
+				if (pos != -1 && chatm.length > 1) {
 					this.send(this.msg, 0)
 				}
 				setTimeout(() => {
 					this._getElementHeight()
-				},10)
+				}, 10)
+			},
+			// 输入框聚焦
+			focus() {
+				this.isemoji = false;
+				this.ismore = false;
+				setTimeout(() => {
+					this._getElementHeight()
+				}, 10)
+			},
+			// 表情内发送
+			emojiSend() {
+				if (this.msg.length > 0) {
+					this.send(this.msg, 0)
+				}
+				setTimeout(() => {
+					this._getElementHeight()
+				}, 10)
 			},
 			// 表情退格
 			emojiBack() {
-				if(this.msg.length > 0){
-					this.msg = this.msg.substring(0, this.msg.length-1)
+				if (this.msg.length > 0) {
+					this.msg = this.msg.substring(0, this.msg.length - 1)
 				}
 			},
 			// 发送消息
@@ -196,14 +177,14 @@
 				}, 0)
 				setTimeout(() => {
 					this._getElementHeight()
-				},10)
+				}, 10)
 			},
 			// 发送图片
 			sendImg(e) {
 				let count = 9;
-				if(e == 'album') {
+				if (e == 'album') {
 					count = 9
-				}else {
+				} else {
 					count = 1
 				}
 				uni.chooseImage({
@@ -212,14 +193,14 @@
 					sourceType: [e],
 					success: (res) => {
 						const filePath = res.tempFilePaths
-						for (let i in filePath){
+						for (let i in filePath) {
 							this.send(filePath[i], 1)
 						}
 					}
 				})
 				setTimeout(() => {
 					this._getElementHeight()
-				},10)
+				}, 10)
 			},
 			// 音频处理
 			touchstart(e) {
@@ -230,7 +211,7 @@
 				this.timer = setInterval(() => {
 					this.vlength = startIndex
 					startIndex++
-					if(startIndex > 60) {
+					if (startIndex > 60) {
 						clearInterval(this.timer)
 						this.touchend();
 					}
@@ -245,15 +226,15 @@
 						voice: res.tempFilePath,
 						time: this.vlength
 					}
-					if(this.voicebg){
+					if (this.voicebg) {
 						this.send(data, 2);
-					}					
+					}
 					this.vlength = 0
 					this.voicebg = false
 				})
 			},
 			touchmove(e) {
-				if(this.pageY - e.changedTouches[0].pageY > 200) {
+				if (this.pageY - e.changedTouches[0].pageY > 200) {
 					this.voicebg = false
 				}
 			},
@@ -274,7 +255,42 @@
 						console.log('经度' + res.longitude)
 					}
 				})
+			},
+			//开始音频
+			openAudio(val) { //Mains
+				// console.log(this.names)
+				uni.navigateTo({
+					url: '../videoCall/videoCall?state=' + val + '&type=audio'
+				});
+			},
+			//接收音频
+			receiveAudio(val) { //Receiver
+				uni.navigateTo({
+					url: '../videoCall/videoCall?state=' + val + '&type=audio'
+				});
+			},
+			//开始视频
+			openVideo(val) { //Mains
+				uni.navigateTo({
+					url: '../videoCall/videoCall?state=' + val + '&type=video' + '&myname=' + this.names[0] +
+						'&toname=' + this.names[1]
+				});
+			},
+			//接收视频
+			receiveVideo(val, room) { //Receiver
+				uni.navigateTo({
+					url: '../videoCall/videoCall?state=' + val + '&type=video' + '&room=' + room
+				});
 			}
+		},
+		mounted() {
+			// uni.onSocketMessage(function(res) {
+			// 	console.log(res.data)
+			// 	if (res.data.type == 'video') {
+			// 		this.receiveVideo('Receiver', );
+			// 	}
+			// 	// console.log('收到服务器内容:' + res.data);
+			// });
 		}
 	}
 </script>
@@ -290,21 +306,21 @@
 		z-index: 1002;
 		padding-bottom: env(safe-area-inset-bottom);
 	}
-	
+
 	.submit-chat {
 		width: 100%;
 		display: flex;
 		align-items: flex-end;
 		box-sizing: border-box;
 		padding: 14rpx 10rpx;
-		
+
 		image {
 			width: 56rpx;
 			height: 56rpx;
 			margin: 0 10rpx;
 			flex: auto;
 		}
-		
+
 		.btn {
 			flex: auto;
 			background-color: #fff;
@@ -313,29 +329,30 @@
 			max-height: 160rpx;
 			margin: 0 10rpx;
 		}
-		
+
 		.chat-send {
 			line-height: 44rpx !important;
 		}
-		
+
 		.record {
 			text-align: center;
 			font-size: $uni-font-size-lg;
 			color: $uni-text-color-grey;
 			font-weight: bold;
 		}
-		
+
 	}
+
 	.displaynone {
 		display: none;
 	}
-	
+
 	.emoji {
 		width: 100%;
 		height: 460rpx;
 		background: rgba(236, 237, 238, 1);
 		box-shadow: 0 -1rpx 0 0 rgba(0, 0, 0, 1);
-		
+
 		.emoji-send {
 			width: 260rpx;
 			height: 104rpx;
@@ -345,19 +362,19 @@
 			right: 0;
 			padding-top: 24rpx;
 			display: flex;
-			
+
 			.emoji-send-bt {
 				flex: 1;
 				height: 80rpx;
 				margin: 0 32rpx 0 20rpx;
-				background: rgba(255, 228, 49 ,1);
+				background: rgba(255, 228, 49, 1);
 				border-radius: 240rpx;
 				font-size: 32rpx;
 				text-align: center;
 				line-height: 80rpx;
 				border-radius: 12rpx;
 			}
-			
+
 			.emoji-send-del {
 				flex: 1;
 				height: 80rpx;
@@ -371,6 +388,7 @@
 			}
 		}
 	}
+
 	.more {
 		width: 100%;
 		height: 436rpx;
@@ -379,7 +397,7 @@
 		bottom: env(safe-area-inset-bottom);
 		padding: 0 20rpx;
 		box-sizing: border-box;
-		
+
 		.more-list {
 			width: 25%;
 			text-align: center;
@@ -393,7 +411,7 @@
 				background: rgba(255, 255, 255, 1);
 				border-radius: 24rpx;
 			}
-			
+
 			.more-list-title {
 				color: rgba(30, 40, 50, .5);
 				line-height: 34rpx;
@@ -402,7 +420,7 @@
 			}
 		}
 	}
-	
+
 	.voice-bg {
 		height: 100%;
 		width: 100%;
@@ -412,7 +430,7 @@
 		bottom: 0;
 		z-index: 1001;
 		// position: relative;
-		
+
 		.voice-bg-len {
 			height: 84rpx;
 			width: 600rpx;
@@ -425,6 +443,7 @@
 			background: rgba(255, 255, 255, .2);
 			border-radius: 42rpx;
 			text-align: center;
+
 			.voice-bg-time {
 				display: inline-block;
 				line-height: 84rpx;
@@ -433,15 +452,15 @@
 				min-width: 120rpx;
 			}
 		}
-		
+
 		.voice-del {
 			position: absolute;
 			bottom: 148rpx;
 			margin-bottom: env(safe-area-inset-bottom);
 			width: 100%;
 			text-align: center;
-			 color: #fff;
-			 font-size: $uni-font-size-base;
+			color: #fff;
+			font-size: $uni-font-size-base;
 		}
 	}
 </style>
diff --git a/main.js b/main.js
index d682d1a..fafec06 100644
--- a/main.js
+++ b/main.js
@@ -24,6 +24,8 @@
 import httpInstall from '@/http/install.js'
 Vue.use(httpInstall, app)
 
+
+ 
 // 公共函数
 import globalFunc from '@/utils/func.js'
 Vue.use(globalFunc, app);
diff --git a/pages.json b/pages.json
index 88fc3c4..d2d8881 100644
--- a/pages.json
+++ b/pages.json
@@ -3,22 +3,22 @@
 		"^u-(.*)": "@/uview-ui/components/u-$1/u-$1.vue"
 	},
 	"pages": [
-		{
-			"path": "pages/home/home",
-			"style": {
-				"navigationBarTitleText": "首页",
-				"enablePullDownRefresh": false,
-				"navigationStyle": "custom"
-			}
-		},
 		// {
-		// 	"path": "pages/login/login-account",
+		// 	"path": "pages/home/home",
 		// 	"style": {
-		// 		"navigationBarTitleText": "登录",
+		// 		"navigationBarTitleText": "首页",
 		// 		"enablePullDownRefresh": false,
 		// 		"navigationStyle": "custom"
 		// 	}
 		// },
+		{
+			"path": "pages/login/login-account",
+			"style": {
+				"navigationBarTitleText": "登录",
+				"enablePullDownRefresh": false,
+				"navigationStyle": "custom"
+			}
+		},
 		{
 			"path": "pages/registerUser/registerUser",
 			"name": "loging",
@@ -32,14 +32,14 @@
 				// }
 			}
 		},
-		// {
-		// 	"path": "pages/home/home",
-		// 	"style": {
-		// 		"navigationBarTitleText": "首页",
-		// 		"enablePullDownRefresh": false,
-		// 		"navigationStyle": "custom"
-		// 	}
-		// },
+		{
+			"path": "pages/home/home",
+			"style": {
+				"navigationBarTitleText": "首页",
+				"enablePullDownRefresh": false,
+				"navigationStyle": "custom"
+			}
+		},
 		{
 			"path": "pages/service/service",
 			"style": {
diff --git a/pages/groupChat/chating.vue b/pages/groupChat/chating.vue
index df1f507..bd837b0 100644
--- a/pages/groupChat/chating.vue
+++ b/pages/groupChat/chating.vue
@@ -125,7 +125,7 @@
 		</view>
 		<!-- <view class="padbt"></view> -->
 	</scroll-view>
-	<submit @inputs="inputs" 
+	<submit @inputs="inputs"  :names="name"
 					@heights="heights"/>
 	</view>
 </template>
@@ -156,7 +156,9 @@
 				loading: '',                  // 滚动事件
 				isload: true,
 				isanimation: true,
-				begainloading: true
+				begainloading: true,
+				
+				name: []//视频 双方id
 			};
 		},
 		components:{
@@ -166,6 +168,9 @@
 			this.recipientId = option.chatID;
 			this._getMsg(this.nowpage)
 			// this.nextPage()
+			var data = JSON.parse(option.data)
+			console.log(data,55555555555555555555555)
+			this.name = ['wo',data.id];
 		},
 		methods:{
 			// 返回键
@@ -209,7 +214,7 @@
 				var that = this;
 				that.senId = WxStorage.get("ids");
 				uni.request({
-					url:"http://s16s652780.51mypc.cn/api/chat-records/getSingleMessagePage",
+					url:"http://223.82.109.183:2082/api/chat-records/getSingleMessagePage",
 					method:"get",
 					data:{
 						senderId: that.senId,
@@ -332,7 +337,7 @@
 				}
 				
 				uni.request({
-					url:"http://s16s652780.51mypc.cn/api/chat-records/insertSingleChat",
+					url:"http://223.82.109.183:2082/api/chat-records/insertSingleChat",
 					method:"post",
 					data:{
 						senderId: that.senId,
diff --git a/pages/groupChat/groupChat.vue b/pages/groupChat/groupChat.vue
index df243ff..a809011 100644
--- a/pages/groupChat/groupChat.vue
+++ b/pages/groupChat/groupChat.vue
@@ -139,7 +139,7 @@
 				var that = this;
 				if(this.current == 0){
 					uni.request({
-						url:"http://s16s652780.51mypc.cn/api/chat-records/getChatListPage",
+						url:"http://223.82.109.183:2082/api/chat-records/getChatListPage",
 						method:"get",
 						data:{
 							senderId: WxStorage.get("ids")
@@ -157,7 +157,7 @@
 					});
 				}else if(this.current == 1){
 					uni.request({
-						url:"http://s16s652780.51mypc.cn/api/chatgroup/selectList",
+						url:"http://223.82.109.183:2082/api/chatgroup/selectList",
 						method:"POST",
 						data:{
 							senderId: WxStorage.get("ids")
@@ -175,7 +175,7 @@
 					})
 				}else if(this.current == 2){
 					uni.request({
-						url:"http://s16s652780.51mypc.cn/api//blade-user/pages?current=1&size=9999",
+						url:"http://223.82.109.183:2082/api/blade-user/pages?current=1&size=9999",
 						method:"get",
 						data:{
 							senderId: WxStorage.get("ids")
diff --git a/pages/home/home.vue b/pages/home/home.vue
index 03866a3..2448c9e 100644
--- a/pages/home/home.vue
+++ b/pages/home/home.vue
@@ -144,7 +144,37 @@
 				serviceButton: []
 			};
 		},
+		mounted() {
+			var socketOpen = false;
+			//websocket连接
+			// uni.connectSocket({
+			// 	url: 'ws://192.168.0.111:9034/websocket'
+			// });
+			
+			// uni.onSocketOpen(function(res) {
+			// 	socketOpen = true;
+			// 	sendSocketMessage();
+			// });
+			
+			// function sendSocketMessage() {
+			// 	var data = {
+			// 				type: 'my',
+			// 				id: '1415922341221867522'
+			// 			}
+			// 	if (socketOpen) {
+			// 		uni.sendSocketMessage({
+			// 			data: JSON.stringify(data)
+			// 		});
+			// 	}
+			// }
+			
+			// uni.onSocketMessage(function(res) {
+			// 	console.log('收到服务器内容:' + res.data);
+			// });
+			
+		},
 		onLoad() {
+			
 			// 后续将改为与后端联动
 			// 加载banner数据
 			fakePosition().then(data => {
@@ -183,7 +213,7 @@
 		methods: {
 			openVideo(val){
 				uni.navigateTo({
-				    url: '../videoCall/videoCall?state=' + val
+				    url: '../videoCall/videoCall?state=' + val + '&type=video'
 				});
 			},
 			changePicker(e) {
diff --git a/pages/videoCall/videoCall.nvue b/pages/videoCall/videoCall.nvue
index a55874f..8ec3ad0 100644
--- a/pages/videoCall/videoCall.nvue
+++ b/pages/videoCall/videoCall.nvue
@@ -4,7 +4,7 @@
 		<view class="index" v-if="!videoShow">
 			<view class="Mains" v-if="isMain">
 				<view class="Mains-t">
-					<text class="activetext">正在呼叫{{MainName}}</text>
+					<text class="activetext">正在呼叫{{toName}}</text>
 					<u-loading size="36" mode="flower"></u-loading>
 				</view>
 				<!-- 挂断 -->
@@ -15,7 +15,8 @@
 			</view>
 			<view class="Receiver" v-if="!isMain">
 				<view class="Mains-t">
-					<text class="activetext">是否接收来自{{userName}}的视频请求</text>
+					<text class="activetext">是否接收来自{{formName}}的{{Otype}}请求</text>
+					<text class="activetext">接受进入{{channel}}</text>
 					<u-loading size="36" mode="flower"></u-loading>
 				</view>
 				<view class="i-control">
@@ -34,7 +35,7 @@
 		</view>
 
 		<!-- 视频 -->
-		<view class="vedioWatch" v-else>
+		<view class="vedioWatch" v-if="videoShow && Otype == 'video'">
 
 			<view class="video_bg">
 				<image class="video_bg_img" src="../../static/BG.png" mode=""></image>
@@ -98,6 +99,61 @@
 				<!-- </view> -->
 			</view>
 		</view>
+
+		<!-- 音频 -->
+		<view class="vedioWatch" v-if="videoShow && Otype == 'audio'">
+			<view class="video_bg">
+				<image class="video_bg_img" src="../../static/BG.png" mode=""></image>
+				<!-- <text class="activetext" v-if="videoShowBg"></text> -->
+				<!-- 	<view class="video_bg video_bg_text">
+			
+					<text class="activetext">{{promptText}}</text>
+				</view> -->
+			</view>
+			<!-- 文字提示 -->
+			<view class="Mains-t">
+				<text class="activetext">语音通话中</text>
+				<u-loading size="36" mode="flower"></u-loading>
+			</view>
+			
+			
+			<!-- 音视频基本开关 -->
+			<view class="videoshow_control position">
+				<!-- 音频开关 -->
+				<view class="open" @click="audioSwitchFn" v-if="role == 1">
+					<image class="video_bg_img" src="../../static/au_in.png" mode="" v-if="audioSwitch == 'open'">
+					</image>
+					<image class="video_bg_img" src="../../static/au_on.png" mode="" v-else></image>
+					<text class="open_text">音频</text>
+				</view>
+
+				<!-- 挂断 -->
+				<view class="open" @click="phoneFn">
+					<image class="video_bg_img" src="../../static/over.png" mode=""></image>
+					<text class="open_text">挂断</text>
+
+				</view>
+
+				<!-- 视频开关 -->
+				<!-- <view class="open" @click="vedioSwitchFn" v-if="role == 1">
+					<image class="video_bg_img" src="../../static/vi_on.png" mode="" v-if="vedioSwitch == 'open'">
+					</image>
+					<image class="video_bg_img" src="../../static/vi_in.png" mode="" v-else></image>
+					<text class="open_text">视频</text>
+				</view> -->
+
+				<!-- 	<scroll-view scroll-y="true" style="height: 500px;padding: 20px;">
+					<view v-for="(item,value) in closeArray" :key='item+value'>{{item}}</view>
+				</scroll-view> -->
+			</view>
+			<!-- 提示文字 -->
+			<view class="video_bg video_bg_text" v-if="promptText">
+				<!-- <view class="video_bg video_bg_text"> -->
+				<text class="activetext">{{promptText}}</text>
+				<!-- </view> -->
+			</view>
+
+		</view>
 		<uni-popup ref="popup" type="center">
 			<uni-popup-message :type="popupType" :message="popupMessage" :duration="2000"></uni-popup-message>
 		</uni-popup>
@@ -147,30 +203,44 @@
 
 
 				isMain: true,
-				userName: '111'
+				userName: '111',
+				toName: '',
+				Otype: '',
+				
+				formName:''
 			}
 		},
 		// 页面初始加载(仅执行一次)
 		onReady() {
 			// 初始化
-			this.channel = 2554;
+			// this.channel = 2554;
 			this.init();
 		},
 		onLoad(option) {
+			console.log(option)
+			if (option.type) {
+				this.Otype = option.type;
+			} else {
+				return
+			}
 			console.log(option.state);
 			if (option.state == "Mains") {
 				this.isMain = true;
-				this.userName = 'faqiren';
+				// this.userName = 'faqiren';
+				this.userName = option.myname;
+				this.toName = option.toname;
 				setTimeout(res => {
-					// this.join();
 					//发起请求  给后端双方姓名
-					
+
 					//得到返回值   开始视频  或者拒绝视频
-					
-					
-				}, 2000)
+					this.join();
+
+
+				}, 5000)
 			} else if (option.state == "Receiver") {
 				this.userName = 'jieshouren';
+				this.formName = 'wo';
+				this.channel = option.room;
 				this.isMain = false;
 			}
 		},
@@ -288,24 +358,25 @@
 			phoneFnMain() {
 				// RtcModule.leaveChannel((res) => {});
 				console.log("等待时候挂断");
-				uni.navigateBack();
+				// uni.navigateBack();
 				this.closeAll();
 			},
-			joinit(){//接受进入视频
+			joinit() { //接受进入视频
 				// 传输接受的值
-				
+
 				// 开始进入视频通话
-				},
+				this.join();
+			},
 			//拒绝进入视频
 			comeBack() {
-				
-				
+
+
 				// 传输拒绝的值
-				
-				
+
+
 				console.log("拒绝进入视频");
 				uni.navigateBack();
-				
+
 				// RtcModule.leaveChannel((res) => {});
 				// this.closeAll();
 			},
@@ -492,9 +563,9 @@
 				// console.log('成功关闭')
 				// uni.navigateBack();
 				RtcModule.destroyRtc((res) => {
-								console.log("页面销毁", res.code);
+					console.log("页面销毁", res.code);
 					console.log('成功关闭')
-					uni.navigateBack();
+					// uni.navigateBack();
 				});
 				// }
 				// });
diff --git a/static/images/chatroom/phone.png b/static/images/chatroom/phone.png
new file mode 100644
index 0000000..922f59e
--- /dev/null
+++ b/static/images/chatroom/phone.png
Binary files differ
diff --git a/store/actions.js b/store/actions.js
index 0b22b92..76526ca 100644
--- a/store/actions.js
+++ b/store/actions.js
@@ -17,12 +17,12 @@
 			],
 			pasw = md5(data.pass),
 			// url = 'http://223.82.109.183:2080/api/blade-auth/oauth/token?tenantId=000000&username=' + data.name +
-			url = 'http://192.168.0.108:81/blade-auth/oauth/token?tenantId=000000&username=' + data.name +
+			url = store.state.piAPI + '/blade-auth/oauth/token?tenantId=000000&username=' + data.name +
 			' &password=' + pasw + '&grant_type=password&scope=all&type=account';
 		// url ='http://192.168.0.109:82/blade-auth/oauth/token';
 		// url ='http://192.168.0.109:82/blade-auth/oauth/token?tenantId=000000&username=admin&password=93369e86dc5fa854a0eaf75558c4039d&grant_type=password';
 		// url ='http://web.byisf.com/api/blade-auth/oauth/token?tenantId=000000&username=admin&password=93369e86dc5fa854a0eaf75558c4039d&grant_type=password&scope=all';
-		// console.log(url);
+		console.log(store.state.piAPI);
 		wx.request({ //uniapp 自带axios
 			url: url, //仅为示例,并非真实接口地址。
 			// data: d,
@@ -45,6 +45,7 @@
 			// 	// dataType: 'JSON',
 			success: (res) => {
 				if (res.statusCode == 200) {
+					console.log(res)
 					if (res.data.error_code == "400") {
 						uni.showToast({
 							title: '密码错误,请重试',
diff --git a/store/index.js b/store/index.js
index 9a8d199..aece5cf 100644
--- a/store/index.js
+++ b/store/index.js
@@ -17,6 +17,7 @@
 const store = new Vuex.Store({
 	// 下面这些值仅为示例,使用过程中请删除
 	state: {
+		
 		// 如果上面从本地获取的lifeData对象下有对应的属性,就赋值给state中对应的变量
 		userInfo: lifeData.userInfo ? lifeData.userInfo : {
 			avatar: '',
@@ -33,8 +34,9 @@
 		},
 		logPath: '',
 		// piAPI: 'http://223.82.109.183:2080/api',
+		piAPI: 'http://223.82.109.183:2082/api',
 		// piAPI: 'http://localhost:82/',
-		piAPI: 'http://192.168.0.108:81',
+		// piAPI: 'http://192.168.0.108:81',
 		puserName: '',
 		puserID: '',
 		puserIphone:'',
diff --git a/store/mutations.js b/store/mutations.js
index 497af5c..664665e 100644
--- a/store/mutations.js
+++ b/store/mutations.js
@@ -46,6 +46,43 @@
 			state.puserID = data.userID;
 			state.avatar = data.avatar;
 		}
+		
+		uni.connectSocket({
+			url: 'ws://192.168.0.111:9034/websocket'
+		});
+		var socketOpen = false;
+		uni.onSocketOpen(function(res) {
+			socketOpen = true;
+			console.log('持续连接成功')
+			sendSocketMessage();
+		});
+		
+		function sendSocketMessage() {
+			var data = {
+						// type: state.puserName,
+						id: state.puserID,
+						type: 'login'
+					}
+			if (socketOpen) {
+				uni.sendSocketMessage({
+					data: JSON.stringify(data)
+				});
+			}
+		}
+		
+		uni.onSocketMessage(function(res) {
+			console.log(res.data);
+			var data  = JSON.parse(res.data)
+			// if (data.type == 'video') {
+				// this.receiveVideo('Receiver', );
+				console.log('进入接受 跳转',data.type)
+				uni.navigateTo({
+					url: '../videoCall/videoCall?state=Receiver&type=' + data.type +'&room=' + data.roomId
+				});
+			// }
+			// console.log('收到服务器内容:' + res.data);
+		});
+		
 		//储存用户
 		WxStorage.set("init", "true");
 		WxStorage.set("name", data.userName);

--
Gitblit v1.9.3