<!-- 工作台 -->
|
<template>
|
<view class="work">
|
<!-- 自定义顶部导航栏 -->
|
<!-- <navBarTop :title="'聊天室'"></navBarTop> -->
|
|
<u-navbar style="position: relative;" :is-fixed="false" :border-bottom="false" :is-back="false" title="好友"
|
:background="{ background: '#0BB9C8' }" title-color="#fff">
|
<u-icon @click="addFriend" slot="right" class="message-icon" mode="widthFix" name="plus" color="#fff">
|
</u-icon>
|
</u-navbar>
|
|
<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="swiperBoxPeo" :style="{ height: swiperHeight + 'px' }" :current="current" @change="tabsChange">
|
|
<swiper-item class="swiper-item" v-for="(item, indexs) in list" :key="indexs">
|
|
<scroll-view scroll-y :scroll-top="scrollTop" style="width: 100%;height: 100%;"
|
:refresher-enabled="refresherFlag" :refresher-threshold="threshold" :refresher-triggered="triggered"
|
@refresherrefresh="refreshing" @refresherrestore="refresherrestore">
|
|
<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="applys" @click="toFriendRequest">
|
<view class="head-wrap">
|
<image src="../../static/apply.png" class="head" />
|
<view v-if=false class="tip">233</view>
|
</view>
|
<view class="content-wrap">
|
<text class="name">好友申请</text>
|
<text class="mess">若人生只如初见</text>
|
</view>
|
<view class="data-wrap">
|
<text class="data"></text>
|
</view>
|
</view>
|
<view class="inTmain">
|
<contacts v-for="(item,index) in dataListTXL" :key="index" :Pdata="item"
|
:fromW="indexs" @refreshTask="refreshTask"></contacts>
|
</view>
|
</div>
|
</div>
|
</view>
|
<view v-if="indexs == 2" class="main">
|
<div>
|
<div class="m-main">
|
|
<view class="applys" @click="newGroup">
|
<view class="head-wraps">
|
<image src="../../static/qunzhu.png" class="head" />
|
<view v-if=false class="tip">233</view>
|
</view>
|
<view class="content-wrap">
|
<text class="name">群组创建</text>
|
<text class="mess">何事秋风悲画扇</text>
|
</view>
|
<view class="data-wrap">
|
<text class="data"></text>
|
</view>
|
</view>
|
|
<!-- <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>
|
|
</scroll-view>
|
|
</swiper-item>
|
|
</swiper>
|
|
</view>
|
</template>
|
|
<script>
|
import WxStorage from "../../static/lib/wxStorage.js"
|
import axios from '../../static/lib/axios.js'
|
import contacts from '../../components/contacts/contacts.vue'
|
import navBarTop from '../../components/nav-bar-top/nav-bar-top.vue';
|
export default {
|
components: {
|
navBarTop,
|
contacts
|
},
|
data() {
|
return {
|
list: [{
|
name: '正在聊天'
|
},
|
{
|
name: '好友'
|
},
|
{
|
name: '群组'
|
}
|
],
|
swiperHeight: 0,
|
zhanwei: '', //因为小程序中底部和顶部栏占位置,uniapp中不占位置
|
current: 0,
|
show: true,
|
dataListP: [],
|
dataListQZ: [],
|
dataListTXL: [],
|
fromW: '',
|
onTop: false, //是否吸顶
|
rect: '', //页面滚动距离
|
menutop: '', //组件距离顶部的距离
|
titleTop: '', //
|
hello: false,
|
userName: '',
|
scrollTop: 0,
|
threshold: 50,
|
triggered: false,
|
isRefreshing: false, // 是否在刷新中
|
refresherFlag: true,
|
}
|
},
|
activated() {
|
this.beginObj();
|
this.getdataList(0);
|
},
|
onReady() {
|
let that = this;
|
uni.getSystemInfo({
|
success(e) {
|
console.log(e);
|
let {
|
windowWidth,
|
windowHeight,
|
safeArea
|
} = e;
|
const query = uni.createSelectorQuery().in(that);
|
query
|
.select('#swiperBoxPeo')
|
.boundingClientRect(data => {
|
|
that.swiperHeight = (safeArea.bottom - data.top);
|
|
})
|
.exec();
|
}
|
});
|
},
|
methods: {
|
|
|
refreshing() {
|
|
if (this.isRefreshing) {
|
return;
|
}
|
this.isRefreshing = true;
|
//界面下拉触发,triggered可能不是true,要设为true
|
if (!this.triggered) {
|
this.triggered = true;
|
}
|
|
this.dataListP = [];
|
this.dataListQZ = [];
|
this.dataListTXL = [];
|
|
this.getdataList()
|
},
|
|
refresherrestore() {
|
|
|
|
},
|
|
change(index) {
|
this.current = index;
|
},
|
tabsChange(e) {
|
this.current = e.detail.current;
|
this.getdataList();
|
},
|
beginObj() {
|
this.titleTop = '2.6rem';
|
this.zhanwei = '3rem';
|
//#ifdef MP-WEIXIN
|
console.log('uni-app小程序中')
|
this.titleTop = '0';
|
this.zhanwei = '0';
|
//#endif
|
},
|
onClick(e) {
|
console.log(e, 777878)
|
},
|
getdataList() {
|
var that = this;
|
if (this.current == 0) {
|
uni.request({
|
url: this.$store.state.piAPI + "/chat-records/getChatListPage",
|
method: "get",
|
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 = "https://gimg2.baidu.com/image_search/src=http%3A%2F%2F5b0988e595225.cdn.sohucs.com%2Fimages%2F20191109%2F1d3d4d82715444c4b8284f65e3feed10.jpeg&refer=http%3A%2F%2F5b0988e595225.cdn.sohucs.com&app=2002&size=f9999,10000&q=a80&n=0&g=0n&fmt=jpeg?sec=1632484198&t=1f4086a5894cbf83b311fa37c276405c";
|
}
|
}
|
that.dataListP = resdata;
|
|
that.scrollTop = 0;
|
|
setTimeout(() => {
|
that.triggered = false; //触发onRestore,并关闭刷新图标 正常应该放在请求成功得接口里
|
that.isRefreshing = false;
|
}, 1000)
|
|
}
|
});
|
} else if (this.current == 1) {
|
uni.request({
|
url: this.$store.state.piAPI + "/friend/page?current=1&size=9999",
|
method: "get",
|
data: {
|
applicant: WxStorage.get("ids")
|
},
|
success: (res) => {
|
var resdata = res.data.data.records;
|
for (var i = 0; i < resdata.length; i++) {
|
|
if (resdata[i].avatar == null || resdata[i].avatar == "") {
|
resdata[i].avatar = "https://gimg2.baidu.com/image_search/src=http%3A%2F%2F5b0988e595225.cdn.sohucs.com%2Fimages%2F20191109%2F1d3d4d82715444c4b8284f65e3feed10.jpeg&refer=http%3A%2F%2F5b0988e595225.cdn.sohucs.com&app=2002&size=f9999,10000&q=a80&n=0&g=0n&fmt=jpeg?sec=1632484198&t=1f4086a5894cbf83b311fa37c276405c";
|
}
|
}
|
|
that.dataListTXL = resdata;
|
|
that.scrollTop = 0;
|
|
setTimeout(() => {
|
that.triggered = false; //触发onRestore,并关闭刷新图标 正常应该放在请求成功得接口里
|
that.isRefreshing = false;
|
}, 1000)
|
|
}
|
})
|
} else if (this.current == 2) {
|
|
uni.request({
|
url: this.$store.state.piAPI + "/chatgroup/selectList",
|
method: "GET",
|
data: {
|
id: WxStorage.get("ids")
|
},
|
contentType: "application/x-www-form-urlencoded",
|
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 = "../../static/images/people.png";
|
}
|
}
|
that.dataListQZ = resdata;
|
|
that.scrollTop = 0;
|
|
setTimeout(() => {
|
that.triggered = false; //触发onRestore,并关闭刷新图标 正常应该放在请求成功得接口里
|
that.isRefreshing = false;
|
}, 1000)
|
|
}
|
});
|
}
|
},
|
refreshTask() {
|
this.getdataList(1);
|
},
|
toFriendRequest() {
|
uni.navigateTo({
|
url: '/pages/groupChat/friendrequest?'
|
});
|
},
|
addFriend() {
|
uni.navigateTo({
|
url: '/pages/groupChat/addFriend?'
|
});
|
},
|
newGroup() {
|
uni.navigateTo({
|
url: '/pages/groupChat/newGroup/newGroup?'
|
});
|
}
|
},
|
mounted() {
|
|
|
},
|
onShow() {
|
this.beginObj();
|
this.getdataList(0);
|
},
|
onPageScroll(e) {
|
this.rect = e.scrollTop
|
},
|
watch: {
|
rect() {
|
if (this.rect >= this.menutop) {
|
this.onTop = true
|
} else {
|
this.onTop = false
|
}
|
}
|
},
|
onLoad: function(options) {
|
this.userName = options.login;
|
// if(options.txlType == 2){
|
// this.current = 0;
|
// }
|
|
}
|
}
|
</script>
|
|
<style lang="scss" scoped>
|
.work {
|
width: 100%;
|
height: 100%;
|
padding: 0;
|
box-sizing: border-box;
|
|
.hello {
|
position: absolute;
|
top: 0;
|
left: 25%;
|
width: 50%;
|
height: 2rem;
|
border-radius: 20rem;
|
color: #fff;
|
background-color: rgba($color: #000000, $alpha: 0.5);
|
display: flex;
|
align-items: center;
|
justify-content: center;
|
}
|
|
.center {
|
padding-top: 0.5rem;
|
display: flex;
|
align-items: center;
|
justify-content: space-around;
|
|
.left,
|
.right {
|
display: flex;
|
align-items: center;
|
justify-content: center;
|
flex-direction: column;
|
|
image {
|
width: 4rem;
|
height: 4rem;
|
}
|
}
|
}
|
|
.main {
|
margin-top: 0.225rem;
|
|
.m-title {
|
width: 100%;
|
height: 2rem;
|
display: flex;
|
align-items: center;
|
justify-content: space-around;
|
padding-top: 0.8rem;
|
padding-bottom: 0.5rem;
|
// border: 1px solid #B3E19D;
|
box-sizing: border-box;
|
|
.m-t {
|
padding-bottom: 0.5rem;
|
box-sizing: border-box;
|
}
|
}
|
|
.m-titletop {
|
width: 95%;
|
height: 2.2rem;
|
display: flex;
|
align-items: center;
|
justify-content: space-around;
|
padding-top: 0.8rem;
|
padding-bottom: 0.5rem;
|
// border: 1px solid #B3E19D;
|
box-sizing: border-box;
|
position: fixed;
|
background-color: #fff;
|
z-index: 3;
|
border-bottom: 1px solid rgba($color: #000000, $alpha: 0.3);
|
|
.m-t {
|
padding-bottom: 0.5rem;
|
box-sizing: border-box;
|
}
|
|
}
|
|
.m-main {
|
box-sizing: border-box;
|
|
.main {
|
padding: 0 16px;
|
}
|
}
|
}
|
}
|
|
.message-icon {
|
font-size: 28px;
|
margin-right: 27rpx;
|
}
|
|
.top-bar {
|
background-color: rgba(255, 255, 255, .96);
|
// background-color: #42B983;
|
box-shadow: 0px 1px 0px 0px rgba(0, 0, 0, .1);
|
}
|
|
.applys {
|
display: flex;
|
// margin: 40rpx 0;
|
margin: 16rpx 32rpx !important;
|
height: 130rpx;
|
align-items: center;
|
border-bottom: 1px solid rgba(0, 0, 0, .1);
|
|
&:active {
|
background-color: rgba(243, 244, 246, 1);
|
}
|
|
.head-wrap {
|
position: relative;
|
|
|
image {
|
width: 96rpx;
|
height: 96rpx;
|
border-radius: 20upx;
|
background-color: rgba(255, 228, 49, 1);
|
}
|
|
.tip {
|
position: absolute;
|
top: -6rpx;
|
left: 68rpx;
|
height: 36rpx;
|
min-width: 20rpx;
|
min-height: 20rpx;
|
background-color: rgba(255, 93, 91, 1);
|
border-radius: 18rpx;
|
padding: 0 6rpx;
|
font-size: 24upx;
|
color: rgba(255, 228, 49, 1);
|
line-height: 36rpx;
|
text-align: center;
|
}
|
}
|
|
.head-wraps {
|
position: relative;
|
|
|
image {
|
width: 96rpx;
|
height: 96rpx;
|
border-radius: 20upx;
|
background-color: rgba(85, 170, 255, 1.0);
|
}
|
|
.tip {
|
position: absolute;
|
top: -6rpx;
|
left: 68rpx;
|
height: 36rpx;
|
min-width: 20rpx;
|
min-height: 20rpx;
|
background-color: rgba(255, 93, 91, 1);
|
border-radius: 18rpx;
|
padding: 0 6rpx;
|
font-size: 24upx;
|
color: rgba(255, 228, 49, 1);
|
line-height: 36rpx;
|
text-align: center;
|
}
|
}
|
|
.content-wrap {
|
margin-left: 32rpx;
|
flex: 1;
|
|
.name {
|
display: block;
|
color: rgba(39, 40, 50, 1);
|
font-size: 36rpx;
|
font-weight: 400;
|
line-height: 50rpx;
|
}
|
|
.mess {
|
display: block;
|
color: rgba(39, 40, 50, .6);
|
font-size: 28upx;
|
line-height: 40rpx;
|
display: -webkit-box;
|
-webkit-box-orient: vertical;
|
-webkit-line-clamp: 1;
|
overflow: hidden;
|
}
|
}
|
|
.data-wrap {
|
|
justify-content: right;
|
|
.data {
|
font-size: 24upx;
|
color: rgba(39, 40, 50, 0.4);
|
line-height: 50rpx;
|
}
|
}
|
}
|
|
.swiper-item {
|
overflow-y: auto !important;
|
}
|
|
.tab {
|
margin-bottom: 10rpx;
|
}
|
</style>
|