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.

536 lines
13 KiB

<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">
<view class="concell" @click="tabSelect(0)">
<image class="cimg" src="/static/image/jl.png"></image>
<view class="ctxt" :class="tabCurrentIndex==0?'cur1':''">教练</view>
</view>
<view class="concell" @click="tabSelect(1)">
<image class="cimg" src="/static/image/kff.png"></image>
<view class="ctxt" :class="tabCurrentIndex==1?'cur2':''">客服</view>
</view>
<view class="concell" @click="tabSelect(2)">
<image class="cimg" src="/static/image/gw.png"></image>
<view class="ctxt" :class="tabCurrentIndex==2?'cur3':''">课程顾问</view>
</view>
<view class="concell" @click="tabSelect(3)">
<image class="cimg" src="/static/image/dzh.png"></image>
<view class="ctxt" :class="tabCurrentIndex==3?'cur4':''">店长</view>
</view>
<view class="concell" @click="tabSelect(4)">
<image class="cimg" src="/static/image/ql.png"></image>
<view class="ctxt" :class="tabCurrentIndex==4?'cur5':''" >群聊</view>
</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">
<image class="img" :src="info.img" mode="aspectFill"></image>
</view>
<view class="lright">
<view class="pname">{{info.name}}</view>
</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 {
messageText:'', //错误提示框
msgType :'error',
tabCurrentIndex:0,
imgurl:uni.$http.baseUrl,
list:[
{
id:0,
name:'教练',
loadStatus:'loadmore',
grouplist:[
// {
// id:1,
// name:"教练A",
// img:"/static/image/jl.png"
// },
]
},
{
id:1,
name:'客服',
loadStatus:'loadmore',
grouplist:[
// {
// id:1,
// name:"商城客服-伽伽",
// img:"/static/image/kff.png"
// },
]
},
{
id:2,
name:'课程顾问',
loadStatus:'more',
grouplist:[
// {
// id:1,
// name:"顾问1",
// img:"/static/image/gw.png"
// },
]
},
{
id:3,
name:'店长',
loadStatus:'more',
grouplist:[
// {
// id:1,
// name:"顾问1",
// img:"/static/image/dzh.png"
// },
]
},
{
id:4,
name:'群聊',
loadStatus:'loadmore',
grouplist:[
// {
// id:1,
// name:"群聊1",
// img:"/static/image/ql.png"
// },
]
}
],
page:{
// pageNum:'1',
// pageSize: '10'
}
}
},
onLoad(options) {
// 未选择门店,则退出至首页选择门店
if(myCache('myshopid')){
}
this.loadData();
},
onShow(){
// this.loadData();
},
onPullDownRefresh() {
console.log('onPullDownRefresh');
setTimeout(()=>{
uni.stopPullDownRefresh()
},500);
},
onReachBottom() {
console.log('onReachBottom');
// 暂不分页
this.loadData();
},
methods: {
addContacts(){
},
gotoBack(){
// 返回
uni.navigateBack({
delta: 1
});
},
changeTime(date) {
return dateTime.dateTime(date);
},
gotoGroup(info){
if(this.tabCurrentIndex==0){
// 教练
var data=encodeURIComponent(JSON.stringify(info));
uni.navigateTo({
url: `/pages/teacher/chat?data=${data}`
});
}
else if(this.tabCurrentIndex==1){
// 客服
var data=encodeURIComponent(JSON.stringify(info));
uni.navigateTo({
url: `/pages/product/service?data=${data}`
});
}
else if(this.tabCurrentIndex==2){
// 顾问
var data=encodeURIComponent(JSON.stringify(info));
uni.navigateTo({
url: `/pages/product/service?data=${data}`
});
}
else if(this.tabCurrentIndex==3){
// 群聊
var data=encodeURIComponent(JSON.stringify(info));
uni.navigateTo({
url: `/pages/product/service?data=${data}`
});
}
},
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")
{
// 教练、客服、顾问、店长列表
if(this.tabCurrentIndex==0||this.tabCurrentIndex==1||this.tabCurrentIndex==2||this.tabCurrentIndex==3){
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=[];
// 教练列表
if(res.data&&res.data.customerService&&res.data.customerService.length>0){
res.data.customerService.forEach(cell => {
this.list[0].grouplist.push({
id: cell.friendId,
name: cell.friendNickName,
img: cell.friendHeadImage?cell.friendHeadImage:'/static/image/ql.png'
})
});
this.$forceUpdate();
}
// 客服列表
if(res.data&&res.data.coach&&res.data.coach.length>0){
res.data.coach.forEach(cell => {
this.list[1].grouplist.push({
id: cell.friendId,
name: cell.friendNickName,
img: cell.friendHeadImage?cell.friendHeadImage:'/static/image/kff.png'
})
});
this.$forceUpdate();
}
// 顾问列表
if(res.data&&res.data.adviser&&res.data.adviser.length>0){
res.data.adviser.forEach(cell => {
this.list[2].grouplist.push({
id: cell.friendId,
name: cell.friendNickName,
img: cell.friendHeadImage?cell.friendHeadImage:'/static/image/gw.png'
})
});
this.$forceUpdate();
}
// 店长列表
if(res.data&&res.data.storeManager&&res.data.storeManager.length>0){
res.data.storeManager.forEach(cell => {
this.list[3].grouplist.push({
id: cell.friendId,
name: cell.friendNickName,
img: cell.friendHeadImage?cell.friendHeadImage:'/static/image/dzh.png'
})
});
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 => {
this.list[this.tabCurrentIndex].grouplist.push({
id: cell.id,
name: cell.name,
img: cell.headImage?cell.headImage:'/static/image/ql.png'
})
});
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;
background-color: #89965f;
.text-center {
width: 100%;
text-align: center;
}
.edit {
position: absolute;
top: 50%;
transform: translateY(-50%);
right: 30rpx;
font-size: 32rpx;
}
}
.hcon{
width: 100%;
background-color: #89965f;
margin: 0;
padding: 26rpx 30rpx;
display: flex;
color: #fff;
font-size: 36rpx;
.leftarr{
background-color: rgba(255, 255,255, 0.3);
padding: 5rpx;
border-radius: 10rpx;
width: 60rpx;
}
}
.concon{
display: flex;
flex-direction: row;
background: #fff;
padding: 30rpx 20rpx 20rpx 20rpx;
margin: 0;
align-items: center;
justify-content: center;
.concell{
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
width: 20%;
.cimg{
width: 100rpx;
height: 100rpx;
}
.ctxt{
font-size: 28rpx;
color: #333;
margin-top: 16rpx;
}
.cur1{
color:#ff7530;
font-size: 30rpx;
font-weight: 600;
}
.cur2{
color:#46a0fb;
font-size: 30rpx;
font-weight: 600;
}
.cur3{
color:#5bd171;
font-size: 30rpx;
font-weight: 600;
}
.cur5{
color:#d4237a;
font-size: 30rpx;
font-weight: 600;
}
.cur4{
color:#fca600;
font-size: 30rpx;
font-weight: 600;
}
}
}
.wrapcon{
margin: 400rpx 0 0 0;
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{
width: 100rpx;
height: 100rpx;
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;
background: #89965f;
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;
color: #89965f;
}
</style>