From 51f03f222c46da8b46c4c9712e61db40c2e1b6a5 Mon Sep 17 00:00:00 2001
From: zengh <123456>
Date: Sat, 03 Jul 2021 10:08:25 +0800
Subject: [PATCH] 聊天室

---
 pages/home/home.vue              |    2 
 components/contacts/contacts.vue |   51 ++++------------
 pages/alarm_list/alarm_list.vue  |    2 
 pages/groupChat/groupChat.vue    |  102 +++++++++++++++++++++++++++++----
 store/actions.js                 |    8 ++
 5 files changed, 112 insertions(+), 53 deletions(-)

diff --git a/components/contacts/contacts.vue b/components/contacts/contacts.vue
index 3640575..e0b9aeb 100644
--- a/components/contacts/contacts.vue
+++ b/components/contacts/contacts.vue
@@ -1,6 +1,18 @@
 <template>
-	<view class="pColumn">
-		<view class="inPColumn" >
+	<view class="pColumn" >
+		<view class="inPColumn" v-if="fromW == 0">
+			<view class="left" @click="chating">
+				<view class="top">
+					<view class="userImg">
+						<img class="img" :src=Pdata.avatar>
+					</view>
+					<view class="t-type">{{Pdata.recipientName}}</view>
+					<view class="t-id">{{Pdata.postTime}}</view>
+				</view>
+				<view class="bottom">{{Pdata.postMessage}}</view>
+			</view>
+		</view>
+		<view class="inPColumn" v-if="fromW == 1">
 			<view class="left" @click="chating">
 				<view class="top">
 					<view class="userImg">
@@ -31,30 +43,6 @@
 				this.bmainb = '0';
 				//#endif
 			},
-			receives() {
-				var url = this.$store.state.piAPI + "/alarm/alarm/APP-setAlarm",
-					Pid = this.Pdata.id,
-					id = this.$store.state.puserID, //警察id
-					name = this.$store.state.puserName, //警察id
-					data = {
-						id: Pid,
-						securityId: id,
-						alarmPeople: name
-					},
-					that = this;
-				// console.log(data);
-				wx.request({
-					url: url,
-					data: data,
-					header: {
-						"content-type": "application/x-www-form-urlencoded"
-					},
-					method: 'POST',
-					success(res) {
-						// console.log(res.data.msg);
-					}
-				})
-			},
 			chating(){
 			//发起聊天
 			var datas = this.Pdata;
@@ -68,17 +56,6 @@
 					popuShow: false
 				});
 			},
-			popupBY() {
-				this.receives();
-				// console.log('接收成功');
-				this.$emit('refreshTask', this.fromW)
-				// this.triggerEvent('myevent', this.data.fromW);
-				this.popuShow = false;
-			},
-			popupBN() {
-				// console.log('接收取消');
-				this.popuShow = false;
-			}
 		},
 		mounted() {
 			this.beginObj();
diff --git a/pages/alarm_list/alarm_list.vue b/pages/alarm_list/alarm_list.vue
index 6696bcc..8d73c9d 100644
--- a/pages/alarm_list/alarm_list.vue
+++ b/pages/alarm_list/alarm_list.vue
@@ -181,7 +181,7 @@
 			//获取警情数据
 			getAlarmData(tab) {
 				var that = this;
-				this.$store.state.puserID = 1370564873280430082;
+				// this.$store.state.puserID = 1370564873280430082;
 				if (this.$store.state.puserID) {
 					//获取全部的数据
 					uni.request({
diff --git a/pages/groupChat/groupChat.vue b/pages/groupChat/groupChat.vue
index fb7f4c1..8716b76 100644
--- a/pages/groupChat/groupChat.vue
+++ b/pages/groupChat/groupChat.vue
@@ -3,17 +3,37 @@
 	<view class="work">
 		<!-- 自定义顶部导航栏 -->
 		<!-- <navBarTop :title="'聊天室'"></navBarTop> -->
-		<view class="main">
-			<div>
-				<div class="m-main">
-					<!-- <view class="inTitle">{{Task}}</view> -->
-					<view class="inTmain">
-						<contacts v-for="(item,index) in dataListP" :key="index" :Pdata="item" :fromW="fromW"
-							@refreshTask="refreshTask"></contacts>
-					</view>
-				</div>
-			</div>
+		<view class="tab">
+			<u-tabs :list="list" :is-scroll="false" :current="current" active-color="#14B9C8" inactive-color="#595959"
+				height="100" @change="change"></u-tabs>
 		</view>
+		
+		<swiper id="swiperBox" :style="{ height: swiperHeight + 'px' }" :current="current" @change="tabsChange">
+			<swiper-item class="swiper-item" v-for="(item, indexs) in list" :key="indexs">
+				<view v-if="indexs == 0" class="main">
+					<div>
+						<div class="m-main">
+							<!-- <view class="inTitle">{{Task}}</view> -->
+							<view class="inTmain">
+								<contacts v-for="(item,index) in dataListP" :key="index" :Pdata="item" :fromW="indexs"
+									@refreshTask="refreshTask"></contacts>
+							</view>
+						</div>
+					</div>
+				</view>
+				<view v-if="indexs == 1" class="main">
+					<div>
+						<div class="m-main">
+							<!-- <view class="inTitle">{{Task}}</view> -->
+							<view class="inTmain">
+								<contacts v-for="(item,index) in dataListQZ" :key="index" :Pdata="item" :fromW="indexs"
+									@refreshTask="refreshTask"></contacts>
+							</view>
+						</div>
+					</div>
+				</view>
+			</swiper-item>
+		</swiper>
 		
 	</view>
 </template>
@@ -29,12 +49,22 @@
 		},
 		data() {
 			return {
+				list: [{
+						name: '正在聊天'
+					},
+					{
+						name: '群组'
+					},
+					{
+						name: '通讯录'
+					}
+				],
+				swiperHeight: 0,
 				zhanwei: '', //因为小程序中底部和顶部栏占位置,uniapp中不占位置
-				ingsDB: '#00d1ff 2px solid',
-				candoDB: '#fff 2px solid',
-				Task: '当前已接任务',
+				current: 0,
 				show: true,
 				dataListP: [],
+				dataListQZ: [],
 				fromW: '',
 				onTop: false, //是否吸顶
 				rect: '', //页面滚动距离
@@ -48,7 +78,52 @@
 		      this.beginObj();
 		      this.ingss();
 		    },
+			onReady() {
+				let that = this;
+				uni.getSystemInfo({
+					success(e) {
+						console.log(e);
+						let {
+							windowWidth,
+							windowHeight,
+							safeArea
+						} = e;
+						const query = uni.createSelectorQuery().in(that);
+						query
+							.select('#swiperBox')
+							.boundingClientRect(data => {
+								that.swiperHeight = safeArea.bottom - data.top;
+							})
+							.exec();
+					}
+				});
+			},
 		methods: {
+			change(index) {
+				this.current = index;
+			},
+			tabsChange(e) {
+				this.current = e.detail.current;
+				if(this.current == 1){
+					var that = this;
+					uni.request({
+						url:"http://s16s652780.51mypc.cn/api/chatgroup/selectList",
+						method:"POST",
+						data:{
+							senderId: WxStorage.get("ids")
+						},
+						success:(res)=> {
+							var resdata = res.data.data;
+							for (var i = 0; i < resdata.length; i++) {
+								if(resdata[i].avatar == null || resdata[i].avatar == ""){
+									resdata[i].avatar = "http://s16s652780.51mypc.cn/img/bg/qunz.png";
+								}
+							}
+							that.dataListQZ = resdata;
+						}
+					})
+				}
+			},
 			beginObj() {
 				this.titleTop = '2.6rem';
 				this.zhanwei = '3rem';
@@ -74,7 +149,6 @@
 				this.getdataList(1);
 			},
 			getdataList(need) {
-				this.fromW = need;
 				var that = this;
 				uni.request({
 					url:"http://s16s652780.51mypc.cn/api/chat-records/getChatListPage",
diff --git a/pages/home/home.vue b/pages/home/home.vue
index 9fddc13..736c9b8 100644
--- a/pages/home/home.vue
+++ b/pages/home/home.vue
@@ -86,7 +86,7 @@
 		<!-- 新闻模块 start -->
 		<view class="news">
 			<navigator hover-class="none" url="/pages/news/list" class="cell">
-				<view class="ctitle">新闻</view>
+				<view class="ctitle">温馨提示</view>
 				<view class="more">
 					更多
 					<u-icon name="arrow-right" color="#A6ABB5" size="16"></u-icon>
diff --git a/store/actions.js b/store/actions.js
index 1829450..a02a99b 100644
--- a/store/actions.js
+++ b/store/actions.js
@@ -44,6 +44,14 @@
 			// 	// dataType: 'JSON',
 			success: (res) => {
 				if (res.statusCode == 200) {
+					if(res.data.error_code == "400"){
+						uni.showToast({
+							title: '密码错误,请重试',
+							icon:'none',
+							duration: 2000
+						});
+						return;
+					}
 					store.commit('getUserData',res.data)
 					console.log(res.data,123542);
 					data.isit = true;

--
Gitblit v1.9.3