|
|
@@ -1,22 +1,149 @@
|
|
|
<template>
|
|
|
- <view class="msg-box" :style="{ paddingTop: BarHeight + 'px' }">
|
|
|
- <!-- 顶部导航栏 -->
|
|
|
- <view class="nav-header">
|
|
|
- <view class="nav-left" @click="goSearch">
|
|
|
- <u-icon name="search" color="rgba(56, 58, 63, 1)" size="40"></u-icon>
|
|
|
+ <view>
|
|
|
+ <view class="msg-box" :style="{ paddingTop: BarHeight + 'px' }">
|
|
|
+ <!-- <view class="msg-box"> -->
|
|
|
+ <!-- 顶部导航栏 -->
|
|
|
+ <view class="nav-header">
|
|
|
+ <view class="nav-left">
|
|
|
+ <!-- <u-icon name="search" color="rgba(56, 58, 63, 1)" size="40"></u-icon> -->
|
|
|
+ </view>
|
|
|
+ <view class="nav-center">
|
|
|
+ <text class="nav-title">消息</text>
|
|
|
+ </view>
|
|
|
+ <view class="nav-right">
|
|
|
+ <!-- <u-icon name="bell" color="rgba(56, 58, 63, 1)" size="40" style="margin-right: 20rpx;"></u-icon> -->
|
|
|
+ <u-icon name="setting" color="rgba(56, 58, 63, 1)" size="40" v-if="isLogin" @click="showSettingsModal"></u-icon>
|
|
|
+ </view>
|
|
|
</view>
|
|
|
- <view class="nav-center">
|
|
|
- <text class="nav-title">消息</text>
|
|
|
+
|
|
|
+ <!-- 系统通知 -->
|
|
|
+ <view class="system-message-wrapper flex align-center" @click="goMsg">
|
|
|
+ <view class="system-message-image flex align-center justify-center">
|
|
|
+ <image src="/static/im/letter.svg" class="letter-icon"></image>
|
|
|
+ </view>
|
|
|
+ <view class="system-message-wrapper-r flex align-center justify-between">
|
|
|
+ <view class="flex align-center">
|
|
|
+ <text class="message-text">系统消息</text>
|
|
|
+ <text class="message-count" v-if="systemCount">{{ systemCount }}</text>
|
|
|
+ </view>
|
|
|
+ <view class="system-message-time" v-if="systemCount">{{ systemMessageTime || '' }}</view>
|
|
|
+ </view>
|
|
|
</view>
|
|
|
- <view class="nav-right">
|
|
|
- <u-icon name="bell" color="rgba(56, 58, 63, 1)" size="40" style="margin-right: 20rpx;"></u-icon>
|
|
|
- <u-icon name="setting" color="rgba(56, 58, 63, 1)" size="40" @click="showSettingsModal"></u-icon>
|
|
|
+
|
|
|
+ <!-- 搜索栏 -->
|
|
|
+ <view class="search-bar flex align-center" v-if="isLogin" @click="goSearch">
|
|
|
+ <image src="@/static/images/svg/search.svg" class="search-icon"></image>
|
|
|
+ 搜索聊天记录
|
|
|
+ </view>
|
|
|
+
|
|
|
+ <!-- tabs -->
|
|
|
+ <view class="tabs-wrapper flex align-center justify-between" v-if="isLogin">
|
|
|
+ <view
|
|
|
+ class="tab"
|
|
|
+ v-for="(tab, index) in prevTabs"
|
|
|
+ :class="{ 'active-tab': selectedTab == tab.type }"
|
|
|
+ :key="tab.type + index"
|
|
|
+ @click="changeTab(tab.type, 'fixed')">
|
|
|
+ {{ tab.name }}
|
|
|
+ <template v-if="userType == 1 && unreadCount && tab.type == 'unread'">({{ unreadCount }})</template>
|
|
|
+ </view>
|
|
|
+ <view
|
|
|
+ class="tab"
|
|
|
+ v-for="(tab, index) in midTabs"
|
|
|
+ :class="{ 'active-tab': selectedTab == tab.type }"
|
|
|
+ :key="tab.type + index"
|
|
|
+ @click="changeTab(tab.type)">{{ tab.name }}</view>
|
|
|
+ <view class="icon-wrapper">
|
|
|
+ <image src="/static/im/more.svg" class="more-icon" @click="showTabModal = true"></image>
|
|
|
+ <u-mask :show="showTabModal" @click="showTabModal = false">
|
|
|
+ <view class="tabs-list" :style="{ top: `calc(${BarHeight}px + 370rpx)` }">
|
|
|
+ <view class="tab-item" v-for="(tab, index) in endTabs" :key="tab.type + index" @click.stop="changeTab(tab.type)">{{ tab.name }}</view>
|
|
|
+ </view>
|
|
|
+ </u-mask>
|
|
|
+ </view>
|
|
|
</view>
|
|
|
+
|
|
|
+ <!-- 聊天列表 -->
|
|
|
+ <template v-if="chatList.length">
|
|
|
+ <scroll-view
|
|
|
+ class="scroll-view"
|
|
|
+ :style="{ height: `calc(100vh - 480rpx - ${BarHeight}px)` }"
|
|
|
+ :scroll-y="true"
|
|
|
+ :refresher-threshold="100"
|
|
|
+ :refresher-enabled="true"
|
|
|
+ :refresher-triggered="isRefreshing"
|
|
|
+ scroll-with-animation="true"
|
|
|
+ @refresherrefresh="handleRefresh">
|
|
|
+ <view class="list">
|
|
|
+ <view
|
|
|
+ class="chat-item flex justify-between"
|
|
|
+ v-for="item in chatList"
|
|
|
+ :key="item.chatConversationId"
|
|
|
+ @click="goIM(item)"
|
|
|
+ @longpress="confirmDelete(item)">
|
|
|
+ <view class="avatar-wrapper">
|
|
|
+ <image :src="item.avatar || '/static/logo.png'" mode="aspectFill" class="avatar"></image>
|
|
|
+ <view class="online-dot" v-if="item.onlineStatus == 'ONLINE'"></view>
|
|
|
+ </view>
|
|
|
+ <view class="chat-info-wrapper flex justify-between">
|
|
|
+ <view class="chat-info-wrapper-l">
|
|
|
+ <view class="chat-info-wrapper-l-t flex align-center">
|
|
|
+ <view class="user-name">{{ item.userName }}</view>
|
|
|
+ <view class="tip-wrapper">
|
|
|
+ <text class="text-tip" v-if="item.companyName">{{ item.companyName }}</text>
|
|
|
+ <text class="text-tip" style="margin: 0 6rpx;" v-if="item.companyName && item.stationName"> | </text>
|
|
|
+ <text class="text-tip" v-if="item.stationName">{{ item.stationName }}</text>
|
|
|
+ </view>
|
|
|
+ </view>
|
|
|
+ <view class="chat-info-wrapper-l-b">
|
|
|
+ <template v-if="item.messageType == 1">{{item.content}}</template>
|
|
|
+ <template v-else-if="item.messageType == 10">简历已发送</template>
|
|
|
+ <template v-else-if="item.messageType == 18">位置</template>
|
|
|
+ <template v-else-if="item.messageType == 9">简历请求</template>
|
|
|
+ <template v-else-if="item.messageType == 6">微信请求</template>
|
|
|
+ <template v-else-if="item.messageType == 5">手机号请求</template>
|
|
|
+ <template v-else-if="item.messageType == 2">[图片]</template>
|
|
|
+ <template v-else-if="item.messageType == 3">[语音]</template>
|
|
|
+ <template v-else-if="item.messageType == 7">[交换手机]</template>
|
|
|
+ <template v-else-if="item.messageType == 8">[交换微信]</template>
|
|
|
+ <template v-else-if="item.messageType == 12">{{item.content}}已拒绝</template>
|
|
|
+ <template v-else-if="item.messageType == 4">
|
|
|
+ <image
|
|
|
+ class="chat-listitem-text"
|
|
|
+ v-if="item.content && item.messageType === 4"
|
|
|
+ :src="ossUrl +item.content"
|
|
|
+ style="height: 40rpx;width: 40rpx;"
|
|
|
+ ></image>
|
|
|
+ </template>
|
|
|
+ <template v-else-if="item.messageType == 20">[视频通话]</template>
|
|
|
+ <template v-else-if="item.messageType == 21">[语音通话]</template>
|
|
|
+ <template v-else-if="item.messageType == 99">[面试邀约]</template>
|
|
|
+ <template v-else-if="item.messageType == 98">[{{item.content}}]</template>
|
|
|
+ <template v-else-if="item.messageType == 96 || item.messageType == 97">[{{item.content}}]</template>
|
|
|
+ <template v-else>[其他消息类型]</template>
|
|
|
+ </view>
|
|
|
+ </view>
|
|
|
+ <view class="chat-info-wrapper-r">
|
|
|
+ <view class="chat-info-wrapper-r-t">
|
|
|
+ <image src="/static/im/toUp.svg" class="up-icon" v-if="showIsTop(item)"></image>
|
|
|
+ </view>
|
|
|
+ <view class="chat-time" v-if="item.messageTime">{{ getMonthOrDay(item.messageTime) }}</view>
|
|
|
+ <view class="count-wrapper">
|
|
|
+ <view class="count" v-if="item.contentCount">{{ item.contentCount }}</view>
|
|
|
+ </view>
|
|
|
+ </view>
|
|
|
+ </view>
|
|
|
+ </view>
|
|
|
+ </view>
|
|
|
+ </scroll-view>
|
|
|
+ </template>
|
|
|
+
|
|
|
+ <empty v-if="!chatList.length" content='暂无消息'></empty>
|
|
|
</view>
|
|
|
|
|
|
- <view class="chat-title">聊天</view>
|
|
|
+ <!-- <view class="chat-title">聊天</view> -->
|
|
|
|
|
|
- <view v-if="msgList.length" class="margin-topW">
|
|
|
+ <!-- <view v-if="msgList.length" class="margin-topW">
|
|
|
<view class="flex padding-tb radius padding-lr-sm bg" @click="goMsg" v-for="(item,index) in msgList"
|
|
|
:key='index'>
|
|
|
<view>
|
|
|
@@ -36,35 +163,14 @@
|
|
|
</view>
|
|
|
</view>
|
|
|
</view>
|
|
|
- </view>
|
|
|
- <!-- <view class="margin-topW">
|
|
|
- <view class="flex padding-tb radius padding-lr-sm bg" @click="goChat">
|
|
|
- <view>
|
|
|
- <image style="width: 80rpx;height: 80rpx;border-radius: 80rpx;"
|
|
|
- src="../../static/images/msg/msgs.png"></image>
|
|
|
- </view>
|
|
|
- <view class="flex-sub margin-left-sm">
|
|
|
- <view class="flex justify-between">
|
|
|
- <view class="text-white">在线客服</view>
|
|
|
- <view v-if="userCount>0"
|
|
|
- style="height: 32rpx;width: 32rpx;border-radius: 100rpx;background-color: red;color: #FFF;text-align: center;">
|
|
|
- {{userCount}}
|
|
|
- </view>
|
|
|
- </view>
|
|
|
- <view>
|
|
|
- <view class="text-grey">联系在线客服</view>
|
|
|
- </view>
|
|
|
- </view>
|
|
|
- </view>
|
|
|
</view> -->
|
|
|
|
|
|
- <view v-if="chatList.length" class="margin-top-sm content ">
|
|
|
+ <!-- <view v-if="chatList.length" class="margin-top-sm content ">
|
|
|
<view class="radius padding-lr-sm bg" style="margin-top: 4rpx;" @click="goIM(item)" @longpress="confirmDelete(item)"
|
|
|
v-for="(item,index) in chatList" :key='index'>
|
|
|
<view class="flex padding-tb ">
|
|
|
<view class="avatar-container">
|
|
|
<u-image shape="circle" width='80rpx' height="80rpx" :src="item.avatar"></u-image>
|
|
|
- <!-- <view class="online-dot"></view> -->
|
|
|
</view>
|
|
|
<view class="flex-sub margin-left-sm" style="overflow: hidden;">
|
|
|
<view class="flex justify-between align-center">
|
|
|
@@ -110,33 +216,10 @@
|
|
|
</view>
|
|
|
</view>
|
|
|
</view>
|
|
|
- <!-- <view class="flex padding-tb" v-else>
|
|
|
- <view>
|
|
|
- <u-image shape="circle" width='80rpx' height="80rpx" :src="item.avatar"></u-image>
|
|
|
- </view>
|
|
|
- <view class="flex-sub margin-left-sm">
|
|
|
- <view class="flex justify-between">
|
|
|
- <view class="text-white">{{item.userName}}</view>
|
|
|
- <view class="text-grey">{{item.messageTime?item.messageTime:''}}</view>
|
|
|
- </view>
|
|
|
- <view class="flex justify-between">
|
|
|
- <view class="text-grey" v-if="item.messageType == 1">{{item.content}}</view>
|
|
|
- <view class="text-grey" v-else-if="item.messageType == 18">位置</view>
|
|
|
- <view class="text-grey" v-else-if="item.messageType == 9">简历请求</view>
|
|
|
- <view class="text-grey" v-else-if="item.messageType == 6">微信请求</view>
|
|
|
- <view class="text-grey" v-else-if="item.messageType == 5">手机号请求</view>
|
|
|
- <view class="text-grey" v-else>[图片]</view>
|
|
|
- <view v-if="item.contentCount"
|
|
|
- style="height: 32rpx;width: 32rpx;border-radius: 100rpx;background-color: red;color: #FFF;text-align: center;">
|
|
|
- {{item.contentCount}}
|
|
|
- </view>
|
|
|
- </view>
|
|
|
- </view>
|
|
|
- </view> -->
|
|
|
</view>
|
|
|
- </view>
|
|
|
+ </view> -->
|
|
|
|
|
|
- <empty v-if="!chatList.length" content='暂无消息'></empty>
|
|
|
+ <!-- <empty v-if="!chatList.length" content='暂无消息'></empty> -->
|
|
|
|
|
|
<!-- 消息设置弹窗 -->
|
|
|
<u-popup v-model="showSettings" mode="bottom" :mask-close-able="true" border-radius="20">
|
|
|
@@ -188,62 +271,172 @@
|
|
|
<script>
|
|
|
import empty from '../../components/empty.vue'
|
|
|
import configData from '../../common/config.js'
|
|
|
+
|
|
|
+ // 求职端tabs
|
|
|
+ // 显示:全部(固定)、未读(固定)、新招呼、仅沟通、有交换、有面试
|
|
|
+ const JobApplicationTab = [
|
|
|
+ {
|
|
|
+ type: '',
|
|
|
+ name: '全部'
|
|
|
+ },
|
|
|
+ {
|
|
|
+ type: 'unread',
|
|
|
+ name: '未读'
|
|
|
+ },
|
|
|
+ {
|
|
|
+ type: 'new',
|
|
|
+ name: '新招呼'
|
|
|
+ },
|
|
|
+ {
|
|
|
+ type: 'communicating',
|
|
|
+ name: '仅沟通'
|
|
|
+ },
|
|
|
+ {
|
|
|
+ type: 'exchanged',
|
|
|
+ name: '有交换'
|
|
|
+ },
|
|
|
+ {
|
|
|
+ type: 'interview',
|
|
|
+ name: '有面试'
|
|
|
+ },
|
|
|
+ ]
|
|
|
+
|
|
|
+ // 招聘端tabs
|
|
|
+ // 显示:全部(固定)、新招呼(固定)、沟通中、已约面、已获取简历、已交换电话、已交换微信、收藏
|
|
|
+ const RecruitmentTab = [
|
|
|
+ {
|
|
|
+ type: '',
|
|
|
+ name: '全部'
|
|
|
+ },
|
|
|
+ {
|
|
|
+ type: 'new',
|
|
|
+ name: '新招呼'
|
|
|
+ },
|
|
|
+ {
|
|
|
+ type: 'communicating',
|
|
|
+ name: '沟通中'
|
|
|
+ },
|
|
|
+ {
|
|
|
+ type: 'interview',
|
|
|
+ name: '已约面'
|
|
|
+ },
|
|
|
+ {
|
|
|
+ type: 'gotResume',
|
|
|
+ name: '已获取简历'
|
|
|
+ },
|
|
|
+ {
|
|
|
+ type: 'gotPhone',
|
|
|
+ name: '已交换电话'
|
|
|
+ },
|
|
|
+ {
|
|
|
+ type: 'gotWx',
|
|
|
+ name: '已交换微信'
|
|
|
+ },
|
|
|
+ {
|
|
|
+ type: 'collected',
|
|
|
+ name: '收藏'
|
|
|
+ },
|
|
|
+ ]
|
|
|
+
|
|
|
export default {
|
|
|
components: {
|
|
|
empty
|
|
|
},
|
|
|
data() {
|
|
|
return {
|
|
|
- BarHeight:'',
|
|
|
+ BarHeight: 0,
|
|
|
page: 1,
|
|
|
limit: 100,
|
|
|
chatList: [],
|
|
|
- userId: '',
|
|
|
msgList: [],
|
|
|
time: '',
|
|
|
messageCount: 0,
|
|
|
- userCount: 0,
|
|
|
+ // userCount: 0,
|
|
|
arr: [],
|
|
|
showModal: true,
|
|
|
showSettings: false, // 控制设置弹窗显示
|
|
|
notificationEnabled: true, // 消息通知开关状态
|
|
|
- ossUrl:configData.ossUrl
|
|
|
- }
|
|
|
- },
|
|
|
- onLoad() {
|
|
|
- if (uni.getStorageSync('userId')) {
|
|
|
- this.getChatList()
|
|
|
+ ossUrl:configData.ossUrl,
|
|
|
+ tabs: [],
|
|
|
+ selectedTab: '',
|
|
|
+ isRefreshing: false,
|
|
|
+ total: 0,
|
|
|
+ userType: null,
|
|
|
+ showTabModal: false,
|
|
|
+ systemCount: 0, // 系统消息数量
|
|
|
+ systemMessageTime: '', // 系统消息时间
|
|
|
+ refreshTime: '', // 更新时间戳
|
|
|
+ isLogin: false,
|
|
|
+ unreadCount: 0
|
|
|
}
|
|
|
-
|
|
|
},
|
|
|
- //下拉刷新
|
|
|
- onPullDownRefresh() {
|
|
|
- let that = this
|
|
|
- if (uni.getStorageSync('token')) {
|
|
|
- that.getweiduMsg();
|
|
|
- that.getChatList()
|
|
|
- that.getMsgList()
|
|
|
- that.$nextTick(function() {
|
|
|
- that.messageCount = uni.getStorageSync('messageCount')
|
|
|
- })
|
|
|
+ computed: {
|
|
|
+ prevTabs() {
|
|
|
+ return this.tabs.slice(0, 2)
|
|
|
+ },
|
|
|
+ midTabs() {
|
|
|
+ return this.tabs.slice(2, 4)
|
|
|
+ },
|
|
|
+ endTabs() {
|
|
|
+ return this.tabs.slice(4)
|
|
|
}
|
|
|
},
|
|
|
- onShow() {
|
|
|
+ onLoad() {
|
|
|
// #ifdef APP-PLUS
|
|
|
let systemInfo = uni.getSystemInfoSync();
|
|
|
this.BarHeight = systemInfo.statusBarHeight;
|
|
|
// #endif
|
|
|
- let that = this
|
|
|
- that.userId = uni.getStorageSync('userId')
|
|
|
- if (that.userId) {
|
|
|
- that.time = setInterval(function() {
|
|
|
- that.getweiduMsg();
|
|
|
- that.getChatList()
|
|
|
- that.getMsgList()
|
|
|
- that.$nextTick(function() {
|
|
|
- that.messageCount = uni.getStorageSync('messageCount')
|
|
|
- })
|
|
|
|
|
|
+ uni.$on('chatUnreadCount', (data) => {
|
|
|
+ if (this.userType === 1) {
|
|
|
+ this.unreadCount = data
|
|
|
+ }
|
|
|
+ })
|
|
|
+ },
|
|
|
+ onUnload() {
|
|
|
+ uni.$off('chatUnreadCount')
|
|
|
+ },
|
|
|
+ // //下拉刷新
|
|
|
+ // onPullDownRefresh() {
|
|
|
+ // let that = this
|
|
|
+ // if (uni.getStorageSync('token')) {
|
|
|
+ // that.getweiduMsg();
|
|
|
+ // that.getChatList()
|
|
|
+ // that.getMsgList()
|
|
|
+ // that.$nextTick(function() {
|
|
|
+ // that.messageCount = uni.getStorageSync('messageCount')
|
|
|
+ // })
|
|
|
+ // }
|
|
|
+ // },
|
|
|
+ onShow() {
|
|
|
+ if (uni.getStorageSync('token')) {
|
|
|
+ const userType = uni.getStorageSync('userType') || null
|
|
|
+ if (this.userType != userType) {
|
|
|
+ this.userType = userType
|
|
|
+ this.init()
|
|
|
+ } else {
|
|
|
+ // if (this.userType == 1) {
|
|
|
+ // this.getUnreadCount()
|
|
|
+ // }
|
|
|
+ this.getChatList()
|
|
|
+ this.getMsgList()
|
|
|
+ }
|
|
|
+
|
|
|
+ this.isLogin = true
|
|
|
+ this.time = setInterval(() => {
|
|
|
+ const newTime = (new Date()).getTime()
|
|
|
+ // 判断上一次请求是否大于3s
|
|
|
+ if (this.refreshTime + 3000 < newTime) {
|
|
|
+ // this.getweiduMsg();
|
|
|
+ // if (this.userType == 1) {
|
|
|
+ // this.getUnreadCount()
|
|
|
+ // }
|
|
|
+ this.getChatList()
|
|
|
+ this.getMsgList()
|
|
|
+ this.$nextTick(() => {
|
|
|
+ this.messageCount = uni.getStorageSync('messageCount')
|
|
|
+ })
|
|
|
+ }
|
|
|
}, 3000)
|
|
|
this.$Request.getT('/app/common/type/310').then(res => { //消息未读提醒
|
|
|
if (res.code == 0) {
|
|
|
@@ -266,20 +459,57 @@
|
|
|
}
|
|
|
}
|
|
|
})
|
|
|
- // #ifdef MP-WEIXIN
|
|
|
- if (this.showModal) {
|
|
|
- this.openMsg()
|
|
|
- }
|
|
|
- // #endif
|
|
|
+ // // #ifdef MP-WEIXIN
|
|
|
+ // if (this.showModal) {
|
|
|
+ // this.openMsg()
|
|
|
+ // }
|
|
|
+ // // #endif
|
|
|
} else {
|
|
|
- that.chatList = []
|
|
|
- that.msgList = []
|
|
|
+ this.isLogin = false
|
|
|
+ this.chatList = []
|
|
|
+ this.msgList = []
|
|
|
}
|
|
|
},
|
|
|
onHide() {
|
|
|
clearInterval(this.time)
|
|
|
},
|
|
|
methods: {
|
|
|
+ // 初始化
|
|
|
+ init() {
|
|
|
+ // if (this.userType == 1) {
|
|
|
+ // this.getUnreadCount()
|
|
|
+ // }
|
|
|
+ this.setTabs()
|
|
|
+ this.getChatList()
|
|
|
+ this.getMsgList()
|
|
|
+ },
|
|
|
+
|
|
|
+ // 设置tabs
|
|
|
+ setTabs() {
|
|
|
+ const userType = this.$queue.getData('userType')
|
|
|
+ if (userType == 1) {
|
|
|
+ this.tabs = JobApplicationTab
|
|
|
+ } else if (userType == 2) {
|
|
|
+ this.tabs = RecruitmentTab
|
|
|
+ }
|
|
|
+ },
|
|
|
+
|
|
|
+ changeTab(type, isFixed = '') {
|
|
|
+ if (!isFixed) {
|
|
|
+ const index = this.tabs.findIndex(tab => tab.type == type)
|
|
|
+ if (index > -1) {
|
|
|
+ const tabItem = this.tabs.splice(index, 1)
|
|
|
+ this.tabs.splice(2, 0, ...tabItem)
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if (this.showTabModal) {
|
|
|
+ this.showTabModal = false
|
|
|
+ }
|
|
|
+ this.selectedTab = type
|
|
|
+ this.page = 1
|
|
|
+ this.getChatList()
|
|
|
+ },
|
|
|
+
|
|
|
confirmDelete(item){
|
|
|
uni.showModal({
|
|
|
title: '提示',
|
|
|
@@ -305,6 +535,15 @@
|
|
|
}
|
|
|
});
|
|
|
},
|
|
|
+ // 显示置顶
|
|
|
+ showIsTop(item) {
|
|
|
+ if (this.userType == 1) {
|
|
|
+ return Boolean(item.isTop)
|
|
|
+ } else if (this.userType == 2) {
|
|
|
+ return Boolean(item.isTopQiye)
|
|
|
+ }
|
|
|
+ return false
|
|
|
+ },
|
|
|
//把时间转换为月日
|
|
|
getMonthOrDay(data) {
|
|
|
// 1️⃣ 手动解析字符串,避免 iOS 时区问题
|
|
|
@@ -349,69 +588,69 @@
|
|
|
|
|
|
return result;
|
|
|
},
|
|
|
- // 开启订阅消息
|
|
|
- openMsg() {
|
|
|
- console.log('订阅消息')
|
|
|
- var that = this
|
|
|
- uni.getSetting({
|
|
|
- withSubscriptions: true, //是否获取用户订阅消息的订阅状态,默认false不返回
|
|
|
- success(ret) {
|
|
|
- console.log(ret.subscriptionsSetting.itemSettings, '*************************************')
|
|
|
- // if (ret.subscriptionsSetting.itemSettings && Object.keys(ret.subscriptionsSetting.itemSettings).length == 2) {
|
|
|
- if (ret.subscriptionsSetting.itemSettings) {
|
|
|
- uni.setStorageSync('sendMsg', true)
|
|
|
- uni.openSetting({ // 打开设置页
|
|
|
- success(rea) {
|
|
|
- console.log(rea.authSetting)
|
|
|
- }
|
|
|
- });
|
|
|
- } else { // 用户没有点击“总是保持以上,不再询问”则每次都会调起订阅消息
|
|
|
- uni.setStorageSync('sendMsg', false)
|
|
|
- uni.showModal({
|
|
|
- title: '提示',
|
|
|
- content: '为了更好的体验,请绑定消息推送',
|
|
|
- confirmText: '确定',
|
|
|
- cancelText: '取消',
|
|
|
- confirmColor: '#016BF6',
|
|
|
- success: function(res) {
|
|
|
- if (res.confirm) {
|
|
|
- wx.requestSubscribeMessage({
|
|
|
- tmplIds: that.arr,
|
|
|
- success(re) {
|
|
|
- console.log(JSON.stringify(re),
|
|
|
- '++++++++++++++')
|
|
|
- var datas = JSON.stringify(re);
|
|
|
- if (datas.indexOf("accept") != -1) {
|
|
|
- console.log(re)
|
|
|
- // uni.setStorageSync('sendMsg', true)
|
|
|
- }
|
|
|
- },
|
|
|
- fail: (res) => {
|
|
|
- console.log(res)
|
|
|
- }
|
|
|
- })
|
|
|
- // uni.setStorageSync('sendMsg', true)
|
|
|
- console.log('确认')
|
|
|
- that.showModal = false
|
|
|
- } else if (res.cancel) {
|
|
|
- console.log('取消')
|
|
|
- // uni.setStorageSync('sendMsg', false)
|
|
|
- that.showModal = true
|
|
|
- }
|
|
|
- }
|
|
|
- })
|
|
|
- }
|
|
|
- }
|
|
|
- })
|
|
|
- },
|
|
|
- getweiduMsg() {
|
|
|
- this.$Request.get("/app/chats/userCount").then(res => {
|
|
|
- uni.stopPullDownRefresh()
|
|
|
- if (res.code == 0) {
|
|
|
- this.userCount = res.data
|
|
|
- }
|
|
|
- });
|
|
|
- },
|
|
|
+ // // 开启订阅消息
|
|
|
+ // openMsg() {
|
|
|
+ // console.log('订阅消息')
|
|
|
+ // var that = this
|
|
|
+ // uni.getSetting({
|
|
|
+ // withSubscriptions: true, //是否获取用户订阅消息的订阅状态,默认false不返回
|
|
|
+ // success(ret) {
|
|
|
+ // console.log(ret.subscriptionsSetting.itemSettings, '*************************************')
|
|
|
+ // // if (ret.subscriptionsSetting.itemSettings && Object.keys(ret.subscriptionsSetting.itemSettings).length == 2) {
|
|
|
+ // if (ret.subscriptionsSetting.itemSettings) {
|
|
|
+ // uni.setStorageSync('sendMsg', true)
|
|
|
+ // uni.openSetting({ // 打开设置页
|
|
|
+ // success(rea) {
|
|
|
+ // console.log(rea.authSetting)
|
|
|
+ // }
|
|
|
+ // });
|
|
|
+ // } else { // 用户没有点击“总是保持以上,不再询问”则每次都会调起订阅消息
|
|
|
+ // uni.setStorageSync('sendMsg', false)
|
|
|
+ // uni.showModal({
|
|
|
+ // title: '提示',
|
|
|
+ // content: '为了更好的体验,请绑定消息推送',
|
|
|
+ // confirmText: '确定',
|
|
|
+ // cancelText: '取消',
|
|
|
+ // confirmColor: '#016BF6',
|
|
|
+ // success: function(res) {
|
|
|
+ // if (res.confirm) {
|
|
|
+ // wx.requestSubscribeMessage({
|
|
|
+ // tmplIds: that.arr,
|
|
|
+ // success(re) {
|
|
|
+ // console.log(JSON.stringify(re),
|
|
|
+ // '++++++++++++++')
|
|
|
+ // var datas = JSON.stringify(re);
|
|
|
+ // if (datas.indexOf("accept") != -1) {
|
|
|
+ // console.log(re)
|
|
|
+ // // uni.setStorageSync('sendMsg', true)
|
|
|
+ // }
|
|
|
+ // },
|
|
|
+ // fail: (res) => {
|
|
|
+ // console.log(res)
|
|
|
+ // }
|
|
|
+ // })
|
|
|
+ // // uni.setStorageSync('sendMsg', true)
|
|
|
+ // console.log('确认')
|
|
|
+ // that.showModal = false
|
|
|
+ // } else if (res.cancel) {
|
|
|
+ // console.log('取消')
|
|
|
+ // // uni.setStorageSync('sendMsg', false)
|
|
|
+ // that.showModal = true
|
|
|
+ // }
|
|
|
+ // }
|
|
|
+ // })
|
|
|
+ // }
|
|
|
+ // }
|
|
|
+ // })
|
|
|
+ // },
|
|
|
+ // getweiduMsg() {
|
|
|
+ // this.$Request.get("/app/chats/userCount").then(res => {
|
|
|
+ // uni.stopPullDownRefresh()
|
|
|
+ // if (res.code == 0) {
|
|
|
+ // this.userCount = res.data
|
|
|
+ // }
|
|
|
+ // });
|
|
|
+ // },
|
|
|
//在线客服
|
|
|
goChat() {
|
|
|
// uni.navigateTo({
|
|
|
@@ -480,21 +719,29 @@
|
|
|
|
|
|
},
|
|
|
getChatList() {
|
|
|
+ this.refreshTime = (new Date()).getTime()
|
|
|
this.$Request.get("/app/chat/selectChatConversationPage", {
|
|
|
page: this.page,
|
|
|
- limit: this.limit
|
|
|
+ limit: this.limit,
|
|
|
+ type: this.selectedTab
|
|
|
}).then(res => {
|
|
|
- uni.stopPullDownRefresh()
|
|
|
+ // uni.stopPullDownRefresh()
|
|
|
if (res.code == 0) {
|
|
|
- this.chatList = res.data.list
|
|
|
+ this.chatList = this.page != 1 ? [...this.chatList, ...res.data.list] : res.data.list
|
|
|
+ this.total = res.data.totalCount
|
|
|
}
|
|
|
+ }).finally(() => {
|
|
|
+ this.refreshTime = (new Date()).getTime()
|
|
|
+ this.isRefreshing = false
|
|
|
});
|
|
|
},
|
|
|
getMsgList() {
|
|
|
- this.$Request.get("/app/message/selectMessageByUserIdLimit1").then(res => {
|
|
|
- uni.stopPullDownRefresh()
|
|
|
+ this.$Request.get("/app/message/selectMessageCountByUserId").then(res => {
|
|
|
+ // uni.stopPullDownRefresh()
|
|
|
if (res.code == 0) {
|
|
|
- this.msgList = res.data.list
|
|
|
+ // this.msgList = res.data.list
|
|
|
+ this.systemCount = res.data.count
|
|
|
+ this.systemMessageTime = res.data.lastTime
|
|
|
}
|
|
|
});
|
|
|
},
|
|
|
@@ -519,7 +766,6 @@
|
|
|
// #endif
|
|
|
let userId = '';
|
|
|
let userType = uni.getStorageSync('userType')
|
|
|
- console.log(e, 'aaaaaaaaa')
|
|
|
if (userType == 2) { //当前登录用户为企业
|
|
|
userId = e.userId
|
|
|
} else { //当前登录用户为用户
|
|
|
@@ -539,24 +785,7 @@
|
|
|
|
|
|
},
|
|
|
goMsg() {
|
|
|
- // #ifdef MP-WEIXIN
|
|
|
- if (uni.getStorageSync('sendMsg')) {
|
|
|
- // console.log('授权+1')
|
|
|
- wx.requestSubscribeMessage({
|
|
|
- tmplIds: this.arr,
|
|
|
- success(re) {
|
|
|
- // console.log(JSON.stringify(re), 111111111111)
|
|
|
- var datas = JSON.stringify(re);
|
|
|
- if (datas.indexOf("accept") != -1) {
|
|
|
- // console.log(re)
|
|
|
- }
|
|
|
- },
|
|
|
- fail: (res) => {
|
|
|
- // console.log(res)
|
|
|
- }
|
|
|
- })
|
|
|
- }
|
|
|
- // #endif
|
|
|
+ if (!this.isLogin) return
|
|
|
uni.navigateTo({
|
|
|
url: '/pages/msg/message'
|
|
|
})
|
|
|
@@ -591,14 +820,44 @@
|
|
|
uni.navigateTo({
|
|
|
url: '/pages/msg/search'
|
|
|
})
|
|
|
- }
|
|
|
+ },
|
|
|
+ // 刷新
|
|
|
+ handleRefresh() {
|
|
|
+ if (!uni.getStorageSync('token')) {
|
|
|
+ return this.isRefreshing = false
|
|
|
+ }
|
|
|
+ if (this.isRefreshing) return
|
|
|
+ this.isRefreshing = true
|
|
|
+ this.page = 1
|
|
|
+ this.getChatList()
|
|
|
+ this.getMsgList()
|
|
|
+ },
|
|
|
+ // // 加载更多
|
|
|
+ // loadMore() {
|
|
|
+ // console.log('加载更多')
|
|
|
+ // if (this.loading || this.chatList.length >= this.total || !uni.getStorageSync('token')) return
|
|
|
+ // this.page++
|
|
|
+ // this.getChatList()
|
|
|
+ // },
|
|
|
+
|
|
|
+ // // 获取未读消息数量
|
|
|
+ // getUnreadCount() {
|
|
|
+ // this.$Request.getT('/app/message/selectMessageCountByUserId')
|
|
|
+ // .then(res => {
|
|
|
+ // if (res.code == 0) {
|
|
|
+ // this.unreadCount = res.data.count
|
|
|
+ // }
|
|
|
+ // })
|
|
|
+ // }
|
|
|
}
|
|
|
}
|
|
|
</script>
|
|
|
|
|
|
-<style lang="scss">
|
|
|
+<style lang="scss" scoped>
|
|
|
.msg-box {
|
|
|
- // padding-top: 80rpx;
|
|
|
+ display: flex;
|
|
|
+ flex-direction: column;
|
|
|
+ font-family: DM Sans;
|
|
|
|
|
|
.chat-title {
|
|
|
background: linear-gradient(180deg, rgba(13, 39, 247, 1) 0%, rgb(191, 194, 201) 100%);
|
|
|
@@ -651,35 +910,255 @@
|
|
|
justify-content: flex-end;
|
|
|
align-items: center;
|
|
|
}
|
|
|
-
|
|
|
- .bg {
|
|
|
- background: #FFFFFF;
|
|
|
+
|
|
|
+ // 系统通知
|
|
|
+ .system-message-wrapper {
|
|
|
+ padding: 10rpx 0 0 32rpx;
|
|
|
+ .system-message-image {
|
|
|
+ width: 80rpx;
|
|
|
+ height: 80rpx;
|
|
|
+ background: linear-gradient(90.00deg, rgba(13, 39, 247, 1),rgba(19, 193, 234, 1));
|
|
|
+ border-radius: 50%;
|
|
|
+ margin-right: 32rpx;
|
|
|
+ .letter-icon {
|
|
|
+ width: 36rpx;
|
|
|
+ height: 28rpx;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ .system-message-wrapper-r {
|
|
|
+ flex: 1;
|
|
|
+ height: 100%;
|
|
|
+ padding: 20rpx 32rpx 20rpx 16rpx;
|
|
|
+ border-bottom: 1px solid rgba(235, 236, 240, 1);
|
|
|
+ .message-text {
|
|
|
+ color: rgba(21, 22, 26, 1);
|
|
|
+ font-size: 32rpx;
|
|
|
+ font-weight: 400;
|
|
|
+ }
|
|
|
+ .message-count {
|
|
|
+ min-width: 32rpx;
|
|
|
+ height: 32rpx;
|
|
|
+ line-height: 32rpx;
|
|
|
+ padding: 0 10rpx;
|
|
|
+ color: #fff;
|
|
|
+ font-size: 20rpx;
|
|
|
+ background: rgba(240, 35, 35, 1);
|
|
|
+ border-radius: 32rpx;
|
|
|
+ box-sizing: border-box;
|
|
|
+ margin-left: 20rpx;
|
|
|
+ }
|
|
|
+ .system-message-time {
|
|
|
+ color: rgba(189, 191, 198, 1);
|
|
|
+ font-size: 20rpx;
|
|
|
+ font-weight: 400;
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|
|
|
-
|
|
|
- .userNameleng {
|
|
|
- // width: 80%;
|
|
|
- flex: 1;
|
|
|
- overflow: hidden;
|
|
|
- white-space: nowrap;
|
|
|
- text-overflow: ellipsis;
|
|
|
- -o-text-overflow: ellipsis;
|
|
|
+
|
|
|
+ // 搜索栏
|
|
|
+ .search-bar {
|
|
|
+ border: 1px solid rgba(231, 230, 228, 1);
|
|
|
+ border-radius: 12rpx;
|
|
|
+ background: rgba(237, 237, 237, 1);
|
|
|
+ padding: 16rpx 24rpx;
|
|
|
+ color: rgba(188, 188, 188, 1);
|
|
|
+ font-size: 28rpx;
|
|
|
+ margin: 24rpx 32rpx 24rpx;
|
|
|
+ .search-icon {
|
|
|
+ width: 32rpx;
|
|
|
+ height: 32rpx;
|
|
|
+ margin-right: 16rpx;
|
|
|
+ }
|
|
|
}
|
|
|
-
|
|
|
- .avatar-container {
|
|
|
- position: relative;
|
|
|
- display: inline-block;
|
|
|
+
|
|
|
+ // tabs
|
|
|
+ .tabs-wrapper {
|
|
|
+ padding: 8rpx 32rpx;
|
|
|
+ margin-bottom: 16rpx;
|
|
|
+ .tab {
|
|
|
+ padding: 8rpx 24rpx;
|
|
|
+ border-radius: 50rpx;
|
|
|
+ background: rgba(0, 0, 0, 0.04);
|
|
|
+ color: rgba(102, 102, 102, 1);
|
|
|
+ font-size: 24rpx;
|
|
|
+ font-weight: 400;
|
|
|
+ line-height: 28rpx;
|
|
|
+ &.active-tab {
|
|
|
+ font-weight: 500;
|
|
|
+ color: rgba(1, 107, 246, 1);
|
|
|
+ background: rgba(1, 107, 246, 0.1);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ .icon-wrapper {
|
|
|
+ position: relative;
|
|
|
+ padding: 8rpx;
|
|
|
+ .more-icon {
|
|
|
+ width: 36rpx;
|
|
|
+ height: 36rpx;
|
|
|
+ }
|
|
|
+ .tabs-list {
|
|
|
+ position: absolute;
|
|
|
+ right: 30rpx;
|
|
|
+ width: 268rpx;
|
|
|
+ background: #fff;
|
|
|
+ border-radius: 4px;
|
|
|
+ box-shadow: 0px 3px 6px -4px rgba(0, 0, 0, 0.12),0px 6px 16px 0px rgba(0, 0, 0, 0.08),0px 9px 28px 8px rgba(0, 0, 0, 0.05);
|
|
|
+ z-index: 10;
|
|
|
+ .tab-item {
|
|
|
+ text-align: center;
|
|
|
+ color: rgba(102, 102, 102, 1);
|
|
|
+ font-size: 14px;
|
|
|
+ font-weight: 400;
|
|
|
+ line-height: 34px;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|
|
|
-
|
|
|
- .online-dot {
|
|
|
- position: absolute;
|
|
|
- bottom: 2rpx;
|
|
|
- right: 2rpx;
|
|
|
- width: 20rpx;
|
|
|
- height: 20rpx;
|
|
|
- background-color: #00FF00;
|
|
|
- border-radius: 50%;
|
|
|
- border: 2rpx solid #FFFFFF;
|
|
|
+
|
|
|
+ // 聊天列表
|
|
|
+ .scroll-view {
|
|
|
+ .chat-item {
|
|
|
+ padding-left: 32rpx;
|
|
|
+ padding-bottom: 16rpx;
|
|
|
+ margin-bottom: 20rpx;
|
|
|
+ .avatar-wrapper {
|
|
|
+ position: relative;
|
|
|
+ width: 96rpx;
|
|
|
+ height: 128rpx;
|
|
|
+ margin-right: 16rpx;
|
|
|
+ padding-top: 32rpx;
|
|
|
+ .avatar {
|
|
|
+ display: block;
|
|
|
+ width: 100%;
|
|
|
+ height: 100%;
|
|
|
+ border: 1px solid #eee;
|
|
|
+ border-radius: 50%;
|
|
|
+ }
|
|
|
+ .online-dot {
|
|
|
+ position: absolute;
|
|
|
+ right: 8rpx;
|
|
|
+ bottom: 0;
|
|
|
+ width: 16rpx;
|
|
|
+ height: 16rpx;
|
|
|
+ border: 1px solid rgba(255, 255, 255, 1);
|
|
|
+ background: rgba(0, 180, 42, 1);
|
|
|
+ border-radius: 50%;
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ .chat-info-wrapper {
|
|
|
+ flex: 1;
|
|
|
+ padding-right: 32rpx;
|
|
|
+ padding-bottom: 24rpx;
|
|
|
+ border-bottom: 1px solid rgba(235, 236, 240, 1);
|
|
|
+ .chat-info-wrapper-l {
|
|
|
+ flex: 1;
|
|
|
+ width: 400rpx;
|
|
|
+ padding-top: 28rpx;
|
|
|
+ }
|
|
|
+ .user-name {
|
|
|
+ // max-width: 130rpx;
|
|
|
+ max-width: 70%;
|
|
|
+ color: rgba(21, 22, 26, 1);
|
|
|
+ font-size: 32rpx;
|
|
|
+ font-weight: 400;
|
|
|
+ margin-right: 16rpx;
|
|
|
+ overflow: hidden;
|
|
|
+ text-overflow: ellipsis;
|
|
|
+ white-space: nowrap;
|
|
|
+ }
|
|
|
+ .tip-wrapper {
|
|
|
+ max-width: 70%;
|
|
|
+ overflow: hidden;
|
|
|
+ text-overflow: ellipsis;
|
|
|
+ white-space: nowrap;
|
|
|
+ }
|
|
|
+ .text-tip {
|
|
|
+ color: rgba(117, 119, 124, 1);
|
|
|
+ font-size: 20rpx;
|
|
|
+ font-weight: 400;
|
|
|
+ }
|
|
|
+ .chat-info-wrapper-l-b {
|
|
|
+ width: 100%;
|
|
|
+ color: rgba(117, 119, 124, 1);
|
|
|
+ font-size: 24rpx;
|
|
|
+ font-weight: 400;
|
|
|
+ line-height: 36rpx;
|
|
|
+ overflow: hidden;
|
|
|
+ text-overflow: ellipsis;
|
|
|
+ white-space: nowrap;
|
|
|
+ }
|
|
|
+
|
|
|
+ .chat-info-wrapper-r-t {
|
|
|
+ display: flex;
|
|
|
+ justify-content: flex-end;
|
|
|
+ width: 100%;
|
|
|
+ height: 40rpx;
|
|
|
+ .up-icon {
|
|
|
+ display: block;
|
|
|
+ width: 40rpx;
|
|
|
+ height: 40rpx;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ .chat-time {
|
|
|
+ color: rgba(189, 191, 198, 1);
|
|
|
+ font-size: 24rpx;
|
|
|
+ font-weight: 400;
|
|
|
+ line-height: 40rpx;
|
|
|
+ }
|
|
|
+ .count-wrapper {
|
|
|
+ display: flex;
|
|
|
+ justify-content: flex-end;
|
|
|
+ width: 100%;
|
|
|
+ height: 32rpx;
|
|
|
+ .count {
|
|
|
+ min-width: 32rpx;
|
|
|
+ line-height: 32rpx;
|
|
|
+ border-radius: 32rpx;
|
|
|
+ color: #fff;
|
|
|
+ font-size: 20rpx;
|
|
|
+ padding: 0 10rpx;
|
|
|
+ background: rgba(245, 63, 63, 1);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ &:last-child {
|
|
|
+ .chat-info-wrapper {
|
|
|
+ border-bottom: 0;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|
|
|
+
|
|
|
+ // .bg {
|
|
|
+ // background: #FFFFFF;
|
|
|
+ // }
|
|
|
+
|
|
|
+ // .userNameleng {
|
|
|
+ // // width: 80%;
|
|
|
+ // flex: 1;
|
|
|
+ // overflow: hidden;
|
|
|
+ // white-space: nowrap;
|
|
|
+ // text-overflow: ellipsis;
|
|
|
+ // -o-text-overflow: ellipsis;
|
|
|
+ // }
|
|
|
+
|
|
|
+ // .avatar-container {
|
|
|
+ // position: relative;
|
|
|
+ // display: inline-block;
|
|
|
+ // }
|
|
|
+
|
|
|
+ // .online-dot {
|
|
|
+ // position: absolute;
|
|
|
+ // bottom: 2rpx;
|
|
|
+ // right: 2rpx;
|
|
|
+ // width: 20rpx;
|
|
|
+ // height: 20rpx;
|
|
|
+ // background-color: #00FF00;
|
|
|
+ // border-radius: 50%;
|
|
|
+ // border: 2rpx solid #FFFFFF;
|
|
|
+ // }
|
|
|
}
|
|
|
|
|
|
// 设置弹窗样式
|