You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

590 lines
15 KiB

3 months ago
<template>
<view class="page">
<view class="page-header" :style="{ paddingTop: geStatusBarHeight() + 'px'}">
<view class="hcon">
<view class="leftarr">
<uni-icons type="back" size="24" color="#fff" @tap="gotoBack"></uni-icons>
</view>
<view class="text-center">通讯录</view>
<!-- <uni-icons type="personadd" size="30" color="#ffffff" @click="$u.throttle(addContacts(), 2000)"></uni-icons> -->
</view>
<view class="concon">
3 weeks ago
<!-- coach -->
<view v-if="ifxy" class="concell" @click="tabSelect(0)">
3 months ago
<image class="cimg" src="/static/image/jl.png"></image>
3 weeks ago
<view class="ctxt" :class="list[tabCurrentIndex].id=='coach'?'cur1':''">教练</view>
3 months ago
</view>
3 weeks ago
<!-- customerService -->
<view v-if="ifxy" class="concell" @click="tabSelect(1)">
3 months ago
<image class="cimg" src="/static/image/kff.png"></image>
3 weeks ago
<view class="ctxt" :class="list[tabCurrentIndex].id=='customerService'?'cur2':''">客服</view>
3 months ago
</view>
3 weeks ago
<!-- adviser -->
<view v-if="ifxy" class="concell" @click="tabSelect(2)">
3 months ago
<image class="cimg" src="/static/image/gw.png"></image>
3 weeks ago
<view class="ctxt" :class="list[tabCurrentIndex].id=='adviser'?'cur3':''">课程顾问</view>
3 months ago
</view>
3 weeks ago
<!-- storeManager -->
<view v-if="ifxy" class="concell" @click="tabSelect(3)">
3 months ago
<image class="cimg" src="/static/image/dzh.png"></image>
3 weeks ago
<view class="ctxt" :class="list[tabCurrentIndex].id=='storeManager'?'cur4':''">店长</view>
3 months ago
</view>
3 weeks ago
<!-- consumer -->
<view v-if="!ifxy" class="concell" @click="tabSelect(5)">
<image class="cimg" src="/static/image/xy.png"></image>
<view class="ctxt" :class="list[tabCurrentIndex].id=='consumer'?'cur6':''">学员</view>
</view>
<!-- groupchat -->
3 months ago
<view class="concell" @click="tabSelect(4)">
<image class="cimg" src="/static/image/ql.png"></image>
3 weeks ago
<view class="ctxt" :class="list[tabCurrentIndex].id=='groupchat'?'cur5':''" >群聊</view>
3 months ago
</view>
</view>
</view>
<view class="wrapcon">
<!-- 列表 -->
<view v-if="list[tabCurrentIndex].grouplist.length==0 && list[tabCurrentIndex].loadStatus=='nomore'" class="nodata">
暂无数据..
</view>
<view class="listcell">
<view class="lcon" v-for="(info, index) in list[tabCurrentIndex].grouplist" :key="index" @click="gotoGroup(info)">
<view class="limg">
3 weeks ago
<image class="img" :src="info.friendHeadImage?info.friendHeadImage:(tabCurrentIndex==0?'/static/image/kff.png':(tabCurrentIndex==1?'/static/image/gw.png':(tabCurrentIndex==2?'/static/image/gw.png':(tabCurrentIndex==3?'/static/image/dzh.png':'/static/image/ql.png'))))" mode="aspectFill"></image>
3 months ago
</view>
<view class="lright">
3 weeks ago
<view class="pname">{{info.friendNickName}}</view>
3 months ago
</view>
</view>
</view>
<u-loadmore v-if="list[tabCurrentIndex].grouplist.length==0 && list[tabCurrentIndex].loadStatus=='loading'"
:status="list[tabCurrentIndex].loadStatus" :marginTop="20"></u-loadmore>
</view>
<!-- 提示信息弹窗 -->
<uni-popup ref="message" type="message">
<uni-popup-message :type="msgType" :message="messageText" :duration="2000"></uni-popup-message>
</uni-popup>
</view>
</template>
<script>
import { myCache } from '../../utils/utils.js';
import dateTime from '@/common/dateTime.js';
export default {
data() {
return {
3 weeks ago
userid:"",
userName:"",
3 months ago
messageText:'', //错误提示框
msgType :'error',
tabCurrentIndex:0,
imgurl:uni.$http.baseUrl,
list:[
{
3 weeks ago
id:"coach",
3 months ago
name:'教练',
loadStatus:'loadmore',
3 weeks ago
grouplist:[]
3 months ago
},
{
3 weeks ago
id:"customerService",
3 months ago
name:'客服',
loadStatus:'loadmore',
3 weeks ago
grouplist:[]
3 months ago
},
{
3 weeks ago
id:"adviser",
3 months ago
name:'课程顾问',
loadStatus:'more',
3 weeks ago
grouplist:[]
3 months ago
},
{
3 weeks ago
id:"storeManager",
3 months ago
name:'店长',
loadStatus:'more',
3 weeks ago
grouplist:[]
3 months ago
},
{
3 weeks ago
id:"groupchat",
3 months ago
name:'群聊',
loadStatus:'loadmore',
3 weeks ago
grouplist:[]
},
{
id:"consumer",
name:'学员',
loadStatus:'loadmore',
grouplist:[]
},
3 months ago
],
3 weeks ago
ifxy:false,
3 months ago
}
},
onLoad(options) {
3 weeks ago
var userInfo=myCache('userInfo');
this.userid = userInfo.userId? userInfo.userId:'';
this.userName = userInfo.nickName?userInfo.nickName:"";
var roleId=userInfo&&userInfo.roleId?userInfo.roleId:[];
if(roleId.length<1){
this.ifxy=true;
this.$forceUpdate();
}
roleId.forEach(cell=>{
if(cell=='107'&&roleId.length<2){
this.ifxy=true;
this.$forceUpdate();
}
else{
this.ifxy=false;
this.$forceUpdate();
}
});
if(this.ifxy){
this.tabCurrentIndex=0;
this.$forceUpdate();
}
else{
this.tabCurrentIndex=5;
this.$forceUpdate();
3 months ago
}
3 weeks ago
// 未选择门店,则退出至首页选择门店
if(myCache('myshopid')){}
3 months ago
this.loadData();
},
onShow(){
// this.loadData();
},
onPullDownRefresh() {
console.log('onPullDownRefresh');
setTimeout(()=>{
uni.stopPullDownRefresh()
},500);
},
onReachBottom() {
console.log('onReachBottom');
// 暂不分页
this.loadData();
},
methods: {
3 weeks ago
// 新增通讯录
addContacts(){},
3 months ago
gotoBack(){
// 返回
uni.navigateBack({
delta: 1
});
},
3 weeks ago
// 跳转聊天框
gotoGroup(item){
console.log(item);
// 直接跳转到聊天框
var timestamp = new Date().getTime();
var info={
chatId: "privatechat-" + this.userid +"-"+ item.friendId,
chatType: (this.tabCurrentIndex==0?"coach":(this.tabCurrentIndex==1?"customerService":(this.tabCurrentIndex==2?"adviser":
(this.tabCurrentIndex==3?"storeManager":(this.tabCurrentIndex==4?"groupchat":(this.tabCurrentIndex==5?"consumer":"")))))),
chatName: item.friendNickName,
chatAvatar: item.friendHeadImage,
chatTime: timestamp,
userid: this.userid,
friendId: item.friendId, // 会话对象
minId: null, // 已读消息的最大id
sort: this.tabCurrentIndex==4?"groupchat":"privatechat", // privatechat 私聊 groupchat 群聊
from: "message" // yh 用户咨询进入聊天框message 从消息进入聊天框
}
// id:"coach",
// name:'教练',
// id:"customerService",
// name:'客服',
// id:"adviser",
// name:'课程顾问',
// id:"storeManager",
// name:'店长',
// id:"groupchat",
// name:'群聊',
// id:"consumer",
// name:'学员',
console.log(info);
3 months ago
if(this.tabCurrentIndex==0){
// 教练
var data=encodeURIComponent(JSON.stringify(info));
uni.navigateTo({
3 weeks ago
url: `/pages/chat/chat?data=${data}`
3 months ago
});
}
else if(this.tabCurrentIndex==1){
// 客服
var data=encodeURIComponent(JSON.stringify(info));
uni.navigateTo({
3 weeks ago
url: `/pages/chat/chat?data=${data}`
3 months ago
});
}
else if(this.tabCurrentIndex==2){
// 顾问
var data=encodeURIComponent(JSON.stringify(info));
uni.navigateTo({
3 weeks ago
url: `/pages/chat/chat?data=${data}`
3 months ago
});
}
else if(this.tabCurrentIndex==3){
3 weeks ago
// 店长
var data=encodeURIComponent(JSON.stringify(info));
uni.navigateTo({
url: `/pages/chat/chat?data=${data}`
});
}
else if(this.tabCurrentIndex==4){
3 months ago
// 群聊
var data=encodeURIComponent(JSON.stringify(info));
uni.navigateTo({
3 weeks ago
url: `/pages/chat/groupchat?data=${data}`
});
}
else if(this.tabCurrentIndex==5){
// 学员
var data=encodeURIComponent(JSON.stringify(info));
uni.navigateTo({
url: `/pages/chat/chat?data=${data}`
3 months ago
});
}
},
loadData(){
// 底部数据加载
if(this.list[this.tabCurrentIndex].loadStatus=="loadmore") {
this.list[this.tabCurrentIndex].loadStatus="loading";
setTimeout(() => {
this.getgroupsmembers();
}, 300);
}
},
tabSelect(index) {
this.tabCurrentIndex = index;
// 加载
this.loadData();
},
// 获取群聊
async getgroupsmembers(){
if(this.list[this.tabCurrentIndex].loadStatus!=="nomore")
{
// 教练、客服、顾问、店长列表
3 weeks ago
if(this.tabCurrentIndex==0||this.tabCurrentIndex==1||this.tabCurrentIndex==2||this.tabCurrentIndex==3||this.tabCurrentIndex==5){
3 months ago
const {data: res} = await uni.$http.get('/api/friend/list');
this.list[0].loadStatus="nomore";
this.list[0].grouplist=[];
this.list[1].loadStatus="nomore";
this.list[1].grouplist=[];
this.list[2].loadStatus="nomore";
this.list[2].grouplist=[];
this.list[3].loadStatus="nomore";
this.list[3].grouplist=[];
3 weeks ago
this.list[5].loadStatus="nomore";
this.list[5].grouplist=[];
3 months ago
// 教练列表
3 weeks ago
if(res.data&&res.data.coach&&res.data.coach.length>0){
this.list[0].grouplist=res.data.coach;
3 months ago
this.$forceUpdate();
}
// 客服列表
3 weeks ago
if(res.data&&res.data.customerService&&res.data.customerService.length>0){
this.list[1].grouplist=res.data.customerService;
3 months ago
this.$forceUpdate();
}
// 顾问列表
if(res.data&&res.data.adviser&&res.data.adviser.length>0){
3 weeks ago
this.list[2].grouplist=res.data.adviser;
3 months ago
this.$forceUpdate();
}
// 店长列表
if(res.data&&res.data.storeManager&&res.data.storeManager.length>0){
3 weeks ago
this.list[3].grouplist=res.data.storeManager;
this.$forceUpdate();
}
// 学员列表
if(res.data&&res.data.consumer&&res.data.consumer.length>0){
this.list[5].grouplist=res.data.consumer;
3 months ago
this.$forceUpdate();
}
}
// 群聊
if(this.tabCurrentIndex==4){
const {data: res} = await uni.$http.get('/api/group/list');
this.list[this.tabCurrentIndex].loadStatus="nomore";
this.list[this.tabCurrentIndex].grouplist=[];
if(res.data&&res.data.length>0){
res.data.forEach(cell => {
3 weeks ago
this.list[this.tabCurrentIndex].grouplist.push({...cell,
friendNickName: cell.name,
friendHeadImage: cell.headImage?cell.headImage:'/static/image/ql.png'
3 months ago
})
});
this.$forceUpdate();
}
}
}
},
// 获取状态栏高度
geStatusBarHeight(){
return uni.getSystemInfoSync()['statusBarHeight'];
},
// 获取导航栏高度
getNavBarHeight(){
return 45+uni.getSystemInfoSync()['statusBarHeight'];
},
}
}
</script>
<style lang="scss" scoped>
.page{
padding: 0;
position: relative;
background-image: url('@/static/image/bg.jpg');
background-attachment: fixed;
background-size: cover;
background-position: center center;
min-height: calc(100vh - var(--window-top) - var(--window-bottom));
}
.page-header {
position: fixed;
width: 100%;
z-index: 999;
3 months ago
background-color: #00a89b;
3 weeks ago
3 months ago
.edit {
position: absolute;
top: 50%;
transform: translateY(-50%);
right: 30rpx;
font-size: 32rpx;
}
}
.hcon{
width: 100%;
3 months ago
background-color: #00a89b;
3 months ago
margin: 0;
3 weeks ago
padding: 0 30rpx;
height: 100rpx;
3 months ago
display: flex;
3 weeks ago
flex-direction: row;
3 months ago
color: #fff;
font-size: 36rpx;
3 weeks ago
align-items: center;
3 months ago
.leftarr{
background-color: rgba(255, 255,255, 0.3);
border-radius: 10rpx;
width: 60rpx;
3 weeks ago
height: 60rpx;
display: flex;
align-items: center;
justify-content: center;
}
.text-center {
display: flex;
flex: 1;
width: 100%;
align-items: center;
justify-content: center;
3 months ago
}
}
.concon{
display: flex;
flex-direction: row;
background: #fff;
3 weeks ago
padding: 20rpx 0;
3 months ago
margin: 0;
3 weeks ago
height: 190rpx;
3 months ago
align-items: center;
3 weeks ago
justify-content: left;
3 months ago
.concell{
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
width: 20%;
.cimg{
3 weeks ago
width: 90rpx;
height: 90rpx;
3 months ago
}
.ctxt{
font-size: 28rpx;
color: #333;
margin-top: 16rpx;
}
.cur1{
color:#ff7530;
3 weeks ago
font-size: 32rpx;
3 months ago
font-weight: 600;
}
.cur2{
color:#46a0fb;
3 weeks ago
font-size: 32rpx;
3 months ago
font-weight: 600;
}
.cur3{
color:#5bd171;
3 weeks ago
font-size: 32rpx;
3 months ago
font-weight: 600;
}
.cur5{
color:#d4237a;
3 weeks ago
font-size: 32rpx;
font-weight: 600;
}
.cur6{
color:#00a89b;
font-size: 32rpx;
3 months ago
font-weight: 600;
}
.cur4{
color:#fca600;
3 weeks ago
font-size: 32rpx;
3 months ago
font-weight: 600;
}
}
}
.wrapcon{
3 weeks ago
margin: 370rpx 0 0 0;
/* #ifdef H5 */
margin: 300rpx 0 0 0;
/* #endif */
3 months ago
padding: 0;
width: 100%;
position: relative;
min-height: calc(100vh - 350rpx);
/* #ifdef H5 */
min-height: calc(100vh - var(--window-top) - var(--window-bottom) - 350rpx);
/* #endif */
overflow-y: auto;
}
.listcell{
margin: 0;
.lcon{
background: #fff;
margin-bottom: 20rpx;
padding-top: 20rpx;
padding-bottom: 20rpx;
opacity: 1;
display: flex;
flex-direction: row;
align-items: center;
.limg{
width: 120rpx;
height: 120rpx;
margin-right: 24rpx;
margin-left: 24rpx;
display: flex;
flex-direction: row;
flex-wrap: wrap;
align-items: center;
justify-content: center;
border-radius: 50%;
.img{
3 weeks ago
width: 80rpx;
height: 80rpx;
3 months ago
border-radius: 10rpx;
}
}
.lright{
display: flex;
flex: 1;
flex-direction: column;
}
.lrow{
display: flex;
flex-direction: row;
margin-bottom: 20rpx;
margin-right: 20rpx;
}
.pname{
display: flex;
flex: 1;
line-height: 50rpx;
font-size: 32rpx;
font-family: PingFang SC, PingFang SC;
font-weight: 600;
color: #000000;
}
.ptime{
line-height: 50rpx;
font-size: 24rpx;
font-family: PingFang SC, PingFang SC;
font-weight: 500;
color: #595959;
}
.pnr{
display: flex;
flex: 1;
font-size: 24rpx;
font-family: PingFang SC, PingFang SC;
font-weight: 400;
color: #595959;
}
.lnum{
background-color: #de0000;
padding: 0 10rpx;
min-width: 32rpx;
height: 32rpx;
line-height: 28rpx;
color: #fff;
font-size: 24rpx;
border-radius: 28rpx;
}
}
}
.tips{
margin-top: 20rpx;
margin-bottom: 20rpx;
width: 100%;
line-height: 44rpx;
font-size: 26rpx;
font-family: PingFang SC, PingFang SC;
font-weight: 400;
color: #595959;
text-align: center;
}
.submitcon{
margin-top: 200rpx;
display: flex;
align-items: center;
justify-content: center;
}
.bbtn{
margin: 20rpx 10rpx 54rpx;
font-size: 32rpx;
font-family: PingFang SC-Medium, PingFang SC;
font-weight: 500;
color: #FCFCFD;
width: 560rpx;
height: 76rpx;
line-height: 76rpx;
3 months ago
background: #00a89b;
3 months ago
box-shadow: 0rpx 12rpx 64rpx 2rpx rgba(137,150,95,0.4);
border-radius: 10rpx;
opacity: 1;
&::after{
border:none;
}
}
.nodata{
background-image: url('../../static/image/nomsg.png');
background-repeat: no-repeat;
background-position: center center;
background-size: 100% auto;
height: 220rpx;
width: 168rpx;
margin: 100rpx auto;
padding-top: 180rpx;
text-align: center;
font-size: 28rpx;
3 months ago
color: #00a89b;
3 months ago
}
</style>