uni-im-msg-list.vue 24.6 KB
Newer Older
DCloud_JSON's avatar
DCloud_JSON 已提交
1 2 3
<template>
  <view class="root">
    <uni-im-list v-if="visibleMsgList.length" class="uni-im-list" :scrollTop="scrollTop" :scroll-into-view="scrollIntoView" :paddingBottom="paddingBottom" ref="uni-im-list" @scroll="onScroll" @scrolltolower="onScrollToLower">
4
     <template v-for="(msg,index) in visibleMsgList" :key="msg.unique_id || msg._id">
DCloud_JSON's avatar
DCloud_JSON 已提交
5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34
		 <uni-im-list-item :ref="'item-'+index">
		   <view v-if="index === 0" class="data-state-tip-box" @appear="beforeLoadMore">
       <uni-im-load-state v-if="canAnchor || !isMpPlatform" :status="hasMore?'loading':'noMore'" 
          :contentText='{"contentrefresh": "正在加载历史消息","contentnomore": "没有更多历史消息"}'></uni-im-load-state>
			 <template v-else>
			   <button v-if="hasMore" class="loadMore-btn" size="mini" @click="beforeLoadMore" :loading="loadMoreIng">{{loadMoreIng ? '加载中':'点击加载更多'}}</button>
			   <text v-else class="data-state-tip-text">没有更多历史消息</text>
			 </template>
		   </view>
		 
		   <view :class="['item',msg.type]" :id="'item-'+index" @click="clickItem">
			 <label class="msg-box" :class="{'active-msg':msg._id === activeMsgId || msg.unique_id === activeMsgId}" @click="checkMsg(msg)">
			   <template v-if="chooseMore">
				 <checkbox :checked="checkedMsgList.find(i=>i._id == msg._id) != undefined" class="checkbox" />
				 <view class="mask"></view>
			   </template>
			   <!-- <text style="width: 750rpx;text-align: center;border: 1px solid #000;">{{'item-'+index}}</text> -->
			   <uni-im-msg :msg="msg" :id="msg._id" :self="current_uid() == msg.from_uid" :index="index" @appear="msgOnAppear(msg._id)"
				 @putChatInputContent="putChatInputContent" :equalPrevTime="equalPrevTime(index)" 
				 :avatar_file="conversation.avatar_file" @showMsgById="showMsgById" @showControl="showControl" 
				 @loadMore="loadMore" @chatInputContentAddcallUser="chatInputContentAddcallUser" @retriesSendMsg="retriesSendMsg" 
				 @viewMsg="viewMsg" :ref="'uni-im-msg'" class="uni-im-msg"
			   >
			   </uni-im-msg>
			 </label>
		   </view>
		 </uni-im-list-item>
     </template>
      <template v-slot:floating-block>
        <view v-if="hasNewMsg" class="new-msg-bar" @click="showLast">
35
          <uni-icons type="pulldown" size="18" color="#007fff"></uni-icons>
DCloud_JSON's avatar
DCloud_JSON 已提交
36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55
          <text>有新消息</text>
        </view>
      </template>
    </uni-im-list>
    <uni-im-load-state v-else :status="hasMore?'loading':'noMore'" class="mg-15" :contentText='{"contentrefresh": "加载中","contentnomore": "- 没有聊天记录 -"}'></uni-im-load-state>

    <!-- <view class="slider-box">
			val:{{val}} scrollTop:{{scrollTop}}
			<slider value="1" @change="sliderChange" min="1" max="14" step="1" />
		</view> -->
    <!-- <view style="position: fixed;top: 100px;width: 500rpx;">
			paddingBottom:{{paddingBottom}}
			scrollTop:{{scrollTop}}
			visibleMsgList.length:{{visibleMsgList.length}}
			scrollIntoView:{{scrollIntoView}}
			<button @click="showLast">showLast</button>
		</view> -->

    <view v-if="call_list.length" class="showCallMe" @click="showCallMe">@回复我({{call_list.length}})</view>

56
    <uni-popup @change="$event.show?'':closeGroupNotification()" ref="group-notification-popup" type="center" class="group-notification-popup">
DCloud_JSON's avatar
DCloud_JSON 已提交
57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163
      <uni-im-group-notification ref="group-notification"></uni-im-group-notification>
    </uni-popup>

    <!-- #ifdef H5 -->
    <uni-im-view-msg ref="view-msg"></uni-im-view-msg>
    <!-- #endif -->
  </view>
</template>

<script>
/**
 * uni-im-msg-list 组件,渲染一个会话列表。
 * 
 * 内部使用 {@link module:uni-im-list} 组件实现列表功能,使用 {@link module:uni-im-msg} 组件实现每条消息的渲染。
 * 
 * @module
 * @see module:chat
 * @see module:uni-im-list
 * @see module:uni-im-list-item
 */
  import uniIm from '@/uni_modules/uni-im/sdk/index.js';
  import {
    store as uniIdStore
  } from '@/uni_modules/uni-id-pages/common/store';

  import uniImList from './components/uni-im-list/uni-im-list';
  import uniImListItem from './components/uni-im-list-item/uni-im-list-item';

  // 一页多少条数据
  let pageLimit = 30
  // 当前页面滚动条高度
  let currentScrollTop = 0

  // 跟踪卷滚条的位置,以判定当前卷滚条是否为贴底状态
  class ScrollTracker {
    position = 0
    at_bottom = false
    scroll(position) {
      // scrolltolower 事件触发后仍会有 scroll 事件,
      // 所以只要位置在递增就仍然是贴底状态,
      // 如果逆向变化则脱离贴底状态。
      if (this.position > position) {
        this.at_bottom = false
      }
      this.position = position
    }
    reachBottom() {
      this.at_bottom = true
    }
    isAtBottom() {
      return this.at_bottom
    }
  }
  
  let intersectionObserver = null;
  let appearObj = {};

  export default {
    components: {
      uniImList,
      uniImListItem
    },
    emits:['checkedMsgList','chatInputContentAddcallUser','showControl','clickItem','retriesSendMsg','putChatInputContent'],
    computed: {
      ...uniIm.mapState(['systemInfo', 'isWidescreen']),
      loadState() {
        return this.hasMore ? '正在加载历史消息' : '没有更多历史消息'
      },
      hasMore() {
        return this.conversation.hasMore
      },
      visibleMsgList() {
        const msgList = this.conversation.msgList || []
        // 过滤掉,撤回消息的指令型消息 、 群头像更新(指令型)消息
        const visibleMsgList = uniIm.utils.filterMsgList(msgList)
        // 返回倒数 laterRenderIndex 条消息,实现懒渲染
                                    .slice(-this.laterRenderIndex)
        this.$nextTick(() => {
          uniIm.utils.throttle(this.setIntersectionObserver, 1000);
        })
        return visibleMsgList
      },
      canAnchor() {
        // #ifdef APP-NVUE
        return true
        // #endif
        
        // #ifndef APP-NVUE
        const {
          browserName,
          model
        } = this.systemInfo
        return browserName != "safari" && !model.includes("iPhone")
        // #endif
      },
      isMpPlatform() {
        // #ifdef MP
        return true
        // #endif
        // #ifndef MP
        return false
        // #endif
      }
    },
    data() {
      return {
        val: 0,
164 165 166 167 168 169
        conversation: {
          has_unread_group_notification: false,
          group_info: {
            notification: false
          }
        },
DCloud_JSON's avatar
DCloud_JSON 已提交
170 171 172 173 174 175 176 177 178 179 180 181 182 183 184
        scrollIntoView: "",
        scrollTop: 0,
        scrollTracker: new ScrollTracker(),
        hasNewMsg: false,
        call_list: [],
        activeMsgId: "",
        loadMoreIng: false,
		// 延迟渲染,避免页面卡顿
        laterRenderIndex: pageLimit
      }
    },
    watch: {
      'conversation.call_list'(call_list) {
        this.call_list = call_list
      },
185 186 187
      'conversation.has_unread_group_notification': {
        async handler(hasUnreadGroupNotification) {
          const group_notification = this.conversation?.group_info?.notification
188
          const conversation_id = this.conversationId
DCloud_JSON's avatar
DCloud_JSON 已提交
189
          // 弹出群公告
190 191
          if (hasUnreadGroupNotification && group_notification && group_notification.content) {
            await uniIm.utils.sleep(1000)
192 193 194 195
            // TODO 临时解决,公告还没弹出来就切换会话,导致弹出多次
            if(conversation_id !== this.conversationId){
              return
            }
DCloud_JSON's avatar
DCloud_JSON 已提交
196 197 198
            // 判断列表中是否已经渲染了此群公告,是则 call 当前用户。否则弹框提示
            let groupNotificationMsg = [...this.visibleMsgList].reverse().find(msg => msg.action ===
              'update-group-info-notification')
199
            // console.log('groupNotificationMsg', groupNotificationMsg,this.visibleMsgList);
200
            
DCloud_JSON's avatar
DCloud_JSON 已提交
201 202
            if (groupNotificationMsg) {
              this.conversation.call_list.push(groupNotificationMsg._id)
203
              this.closeGroupNotification()
DCloud_JSON's avatar
DCloud_JSON 已提交
204 205 206
            } else {
              this.$refs["group-notification-popup"].open()
              this.$nextTick(() => {
207
                this.$refs["group-notification"].notification = group_notification
DCloud_JSON's avatar
DCloud_JSON 已提交
208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388
              })
            }
          }
        },
        immediate: true
      }
    },
    props: {
      paddingBottom: {
        default: ''
      },
      conversationId: {
        default () {
          return false
        }
      },
      chooseMore: {
        default: false
      },
      checkedMsgList: {
        default () {
          return []
        }
      }
    },
    async mounted() {
      // for (var i = 0; i < 10; i++) {
      // 	this.msgList.unshift({
      // 		t:i
      // 	})
      // }
    },
    destroyed() {
      // console.log('destroyed')
      if (intersectionObserver){
        intersectionObserver.disconnect()
      }
    },
    methods: {
      async init() {
        if (intersectionObserver){
          intersectionObserver.disconnect()
        }
        this.conversation = await uniIm.conversation.get(this.conversationId)
        // init data --start
        this.scrollIntoView = ''
        this.scrollTop = 0
        this.laterRenderIndex = pageLimit
        currentScrollTop = 0

        if (!this.conversation.isInit) {
          this.conversation.hasMore = true
          await this.loadMore()
          this.conversation.isInit = true
          if (this.conversation.hasMore && this.visibleMsgList.length < pageLimit) {
            console.log('不满一屏时,再loadMore一次');
            await this.loadMore()
          }
        }

        // #ifndef APP
        // app端会自动固定在底部,其他端需要执行一次显示最后一条
        this.$nextTick(() => {
          this.showLast(300)
          // TODO 延迟300毫秒 临时解决,未知情况下$nextTick后仍然不能滚到最后一条的问题
          setTimeout(() => {
            this.showLast(300)
          }, 300);
        })
        // #endif
      },
      async loadMore(callback) {
        let datas = []
        if(this.laterRenderIndex < this.conversation.msgList.length){
          let oldVisibleMsgList = JSON.parse(JSON.stringify(this.visibleMsgList))
          await this.canHoldScrollDo(()=>{
            this.laterRenderIndex += pageLimit
          })
          await this.$nextTick()
          // 新加载到的数据为:oldVisibleMsgList和this.visibleMsgList的差集
          datas = this.visibleMsgList.filter(i => !oldVisibleMsgList.some(j => j._id == i._id))
          // console.log('beforeLoadMore 懒渲染=>',this.laterRenderIndex,this.conversation.msgList.length);
        }else{
          datas = await this.conversation.msgManager.getHistory()
          // console.error(`加载到${datas.length}条,历史聊天数据`);
          // console.log('加载到历史聊天数据:', datas);
          if (datas.length === 0) {
            this.conversation.hasMore = false
          } else {
            await this.insertMsg(datas)
          }
        }
        if (typeof callback === 'function') {
          // 为兼容 web pc端特殊场景 不能使用$nextTick
          setTimeout(() => {
            callback(datas)
          }, 0)
        }
        return datas
      },
      async beforeLoadMore() {
        if (!this.loadMoreIng && this.hasMore && currentScrollTop < 30) {
          this.loadMoreIng = true
          await this.loadMore()
          this.loadMoreIng = false
        }
      },
      msgOnAppear(msgId){
        uniIm.utils.throttle(()=>{
          let index = this.visibleMsgList.findIndex(i => i._id == msgId)
          if (index == -1) {
            return //因为是异步的,可能已经被销毁了替换了新对象
          }
        }, 1000);
      },
      async setIntersectionObserver() {
        // console.log('setIntersectionObserver');
        if (intersectionObserver) {
          // console.log('intersectionObserver存在','执行销毁');
          intersectionObserver.disconnect()
        }
        intersectionObserver = uni.createIntersectionObserver(this, { observeAll: true });
        intersectionObserver.relativeTo('.uni-im-list .scroll-view', { top: -50, bottom: -50 })
          .observe('.uni-im-msg', (res) => {
            const msgId = res.id
            const msgRef = this.$refs['uni-im-msg'].find(item => item.msg._id == msgId)
            if (!msgRef) {
              // console.log('找不到msgRef', msgId);
              return
            }
            const isAppear = appearObj[msgId] || false;
            if (res.intersectionRatio > 0 && !isAppear) {
              appearObj[msgId] = true;
              msgRef.onAppear()
              this.msgOnAppear(msgId)
              // console.error('出现了',msgRef.msg.body)

              // 调用扩展点,通知消息列表某条消息进入显示区。
              uniIm.extensions.invokeExts('msg-appear', msgRef.msg, {
                user_id: uniCloud.getCurrentUserInfo().uid,
                isInternalUser: this.uniIDHasRole('staff'),
              })
            } else if (!res.intersectionRatio > 0 && isAppear) {
              appearObj[msgId] = false;
              msgRef.onDisappear()
              // console.error('消失了',msgRef.msg.body)

              // 调用扩展点,通知消息列表某条消息离开显示区。
              uniIm.extensions.invokeExts('msg-disappear', msgRef.msg, {
                user_id: uniCloud.getCurrentUserInfo().uid,
                isInternalUser: this.uniIDHasRole('staff'),
              })
            }
          })
      },
      viewMsg(msgList) {
        this.$refs['view-msg'].open(msgList);
      },
      async onScroll(e) {
        this.scrollTracker.scroll(e.detail.scrollTop)
        this.onScroll.end = false

        if (this.onScroll.timeoutId) {
          clearTimeout(this.onScroll.timeoutId)
        }
        this.onScroll.timeoutId = setTimeout(() => {
          this.onScroll.end = true
        }, 500)

        currentScrollTop = e.detail.scrollTop
        // #ifndef APP-NVUE
        // 移动端 safari内核浏览器有滚动锚定问题,需要通过点击点击“加载按钮”加载历史消息
        if (!this.canAnchor && this.isMpPlatform) {
          return
        }
        // #endif

        await this.beforeLoadMore()
      },
      async onScrollToLower() {
        this.scrollTracker.reachBottom()
389
        this.hasNewMsg = false
DCloud_JSON's avatar
DCloud_JSON 已提交
390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578
      },
      async canHoldScrollDo(fn){
        return new Promise((resolve) => {
          // #ifdef APP-NVUE
          fn()
          resolve()
          // #endif
          
          // #ifndef APP-NVUE
          let tryIndex = 0
          const tryInsert = () => {
            tryIndex++
            if (tryIndex > 100) {
              console.error("防止未意料的情况下“死循环”限制最多尝试100次");
              // 防止死循环,最多尝试100次
              fn()
              return resolve()
            }
            const msgListIsNoFull = this.visibleMsgList.length < 10
            if (msgListIsNoFull || currentScrollTop > 9 || !this.canAnchor) {
              if (!this.canAnchor) {
                if (this.visibleMsgList.length && this.onScroll.end === false) {
                  return setTimeout(() => {
                    tryInsert()
                  }, 500)
                }
                fn()
                this.scrollTop = currentScrollTop
                this.$nextTick(async () => {
                  let itemScrollTop = await this.getItemScrollTopByIndex(pageLimit - 1)
                  // console.log('itemScrollTop',itemScrollTop);
                  if (this.isWidescreen) {
                    itemScrollTop -= 110
                  } else {
                    itemScrollTop -= 30
                  }
                  this.scrollTop = itemScrollTop
                  currentScrollTop = itemScrollTop
                })
              } else {
                fn()
              }
              resolve()
            } else {
              // console.error('不能插入',currentScrollTop);
              this.scrollTop = currentScrollTop
              this.$nextTick(async () => {
                this.scrollTop = 10
                currentScrollTop = 10
                tryInsert()
              })
            }
          }
          tryInsert()
          // #endif
        })
      },
      /**
       * @description 防止非app-nvue端,部分情况下在顶部插入消息时滚动锚定生效的问题
       */
      async insertMsg(data) {
        // 重新获取会话对象,防止web pc端 切换太快引起的会话对象指向错误
        const conversation = await uniIm.conversation.get(data[0].conversation_id)
        this.canHoldScrollDo(()=>{
          conversation.msgList.unshift(...data)
          // 有新消息插入laterRenderIndex的值重新设置
          this.laterRenderIndex += data.length
        })
      },
      equalPrevTime(index) {
        if (index === 0) {
          return false
        } else if (index == this.visibleMsgList.length - 1) {
          return false
        } else {
          const getFriendlyTime = (msg) => {
            return uniIm.utils.toFriendlyTime(msg.create_time || msg.client_create_time)
          }
          return getFriendlyTime(this.visibleMsgList[index]) == getFriendlyTime(this.visibleMsgList[index - 1])
        }
      },
      async showCallMe() {
        let msgId = this.conversation.call_list.pop()
        console.log('msgId', msgId)
        this.showMsgById(msgId)
      },
      showLast(duration = 300) {
        let mLength = this.visibleMsgList.length
        this.showMsgByIndex(mLength - 1, duration)
        this.hasNewMsg = false
        this.scrollTracker.reachBottom()
      },
      notifyNewMsg() {
        this.hasNewMsg = true
        if (this.scrollTracker.isAtBottom()) {
          this.showLast()
        }
      },
      // #ifndef APP-NVUE
      async getItemScrollTopByIndex(index) {
        return await new Promise((resolve, rejece) => {
          const query = uni.createSelectorQuery().in(this);
          query.select('#item-' + index).boundingClientRect(data => {
            if (!data) {
              return console.log('找不到 showMsgByIndex #item-' + index);
            }
            let val = currentScrollTop + data.top + data.height
            if (val < 0) {
              val = 0
            }
            resolve(val)
          }).exec()
        })
      },
      // #endif
      async showMsgByIndex(index, duration = 300) {
        if (index == -1) {
          return
        }
        // #ifdef APP-NVUE
        let target = this.$refs['item-' + index][0];
        // console.log('滚动到第', index, target);
        const nativePluginDom = uni.requireNativePlugin('dom')
        nativePluginDom.scrollToElement(target, {
          // animated: duration != 0,
          // offset: 999
        });
        // #endif

        // #ifndef APP-NVUE
        let listHeight = this.systemInfo.windowHeight
        // #ifdef H5
        if (uniIm.isWidescreen) {
          listHeight = document.querySelector('.uni-im-list uni-scroll-view').clientHeight
          // console.log('listHeight',listHeight)
        } else {
          listHeight -= 44
        }
        // #endif

        const itemScrollTop = await this.getItemScrollTopByIndex(index)
        const val = itemScrollTop - listHeight * 0.7 + parseInt(this.paddingBottom)

        // 赋值为当前滚动条的高度
        this.scrollTop = currentScrollTop
        // 设置一个新值触发视图更新 -> 滚动
        this.$nextTick(async () => {
          this.scrollTop = val
          currentScrollTop = val
        })
        // #endif
      },
      // 测试专用
      async sliderChange(e) {
        let index = e.detail.value
        console.log(index)
        this.val = index
        this.showMsgByIndex(index)
      },
      async showMsgById(msgId) {
        // 找到消息的索引
        let index = this.visibleMsgList.findIndex(i => i._id == msgId)
        if (index === -1) {
          // 如果找不到,先加载更多,再找
          uni.showLoading();
          const {_findIndex} = this.showMsgById
          if (!_findIndex) {
            this.showMsgById._findIndex = 0
          } else if (_findIndex > 30) {
            uni.hideLoading()
            this.showMsgById._findIndex = false
            return console.error('防止特殊情况下死循环,不加载30屏以外的引用数据');
          }
          this.showMsgById._findIndex++
          await this.loadMore()
          this.showMsgById._findIndex = false
          await uniIm.utils.sleep(300)
          uni.hideLoading()
          return await this.showMsgById(msgId)
        }
        
        this.activeMsgId = msgId
        setTimeout(() => {
          this.activeMsgId = ''
        }, 2000);
        this.showMsgByIndex(index)

        // 如果是显示群公告,则设置未读的群公告内容为 false
        if (this.visibleMsgList[index].action === "update-group-info-notification") {
579
          this.closeGroupNotification()
DCloud_JSON's avatar
DCloud_JSON 已提交
580 581 582
        }

      },
583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600
      closeGroupNotification() {
        // console.log('######关闭群公告',this.conversationId)
        
        const db = uniCloud.database();
        
        db.collection('uni-im-conversation')
        .where({
          id:this.conversationId,
          user_id: uniCloud.getCurrentUserInfo().uid
        })
        .update({
          has_unread_group_notification: false
        }).then(res => {
          this.conversation.has_unread_group_notification = false
          // console.log('关闭群公告成功', res)
        }).catch(err => {
          console.error('关闭群公告失败', err)
        })
DCloud_JSON's avatar
DCloud_JSON 已提交
601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771
      },
      isChecked(msg) {
        return this.checkedMsgList.some(i => i._id === msg._id)
      },
      checkMsg(msg) {
        if (!this.chooseMore) {
          return
        }
        let checkedMsgList = this.checkedMsgList
        if (this.isChecked(msg)) {
          checkedMsgList.splice(checkedMsgList.findIndex(i => i._id === msg._id), 1)
        } else {
          checkedMsgList.push(msg)
        }
        this.$emit('update:checkedMsgList', checkedMsgList)
      },
      //当前用户自己的uid
      current_uid() {
        return uniCloud.getCurrentUserInfo().uid;
      },
      showControl(e) {
        this.$emit('showControl', e)
      },
      chatInputContentAddcallUser(e) {
        this.$emit('chatInputContentAddcallUser', e)
      },
      retriesSendMsg(e) {
        this.$emit('retriesSendMsg', e)
      },
      clickItem() {
        this.$emit('clickItem')
      },
      putChatInputContent(msgBody) {
        this.$emit('putChatInputContent', msgBody)
      }
    }
  }

</script>

<style lang="scss" scoped>
  .root,
  .uni-im-list {
    flex: 1;
    background-color: transparent;
  }

  .item {
	  margin:10px 0;
    // border: solid 1px #0055ff;
  }

  .mg-15 {
    margin: 15px;
  }

  .data-state-tip-box {
    // height: 35px;
    align-items: center;
    justify-content: center;
    flex-direction: row;
    color: #999999;
    margin-bottom: -5px;
    margin-top: 10px;
  }

  .data-state-tip-text {
    height: 36px;
    line-height: 36px;
    font-size: 12px;
    margin: 0 5px;
    color: #999999;
  }

  /* #ifndef APP-NVUE */
  .data-state-tip-icon {
    justify-content: center;
    align-items: center;
    display: flex;
    animation: rotation 1s linear infinite;
  }

  @keyframes rotation {
    0% {
      transform: rotate(0deg);
    }

    100% {
      transform: rotate(360deg);
    }
  }

  /* #endif */

  /* #ifdef H5 */
  .loadMore-btn {
    font-size: 14px;
    color: #666;
  }

  .loadMore-btn::after {
    display: none;
  }

  /* #endif */
  .msg-box {
    position: relative;
    transition-property: background-color;
    transition-duration: 2s;
    flex-direction: row;
  }

  .msg-box .checkbox {
    margin: 30px 0 0 10px;
    // transform: translateX(20px);
  }

  .msg-box .mask {
    position: absolute;
    top: 0;
    left: 0;
    z-index: 999;
    width: 100%;
    height: 100%;
  }

  .active-msg {
    background-color: #f9f9f9;
  }

  .slider-box {
    border: 1px solid #000;
    position: fixed;
    width: 750rpx;
    height: 55px;
    top: 60px;
    right: 0;
    z-index: 999;
    background-color: #FFF;
  }

  .showCallMe {
    background-color: #62caf8;
    border-radius: 50px;
    padding: 2px 15px;
    font-size: 12px;
    color: #FFF;
    position: fixed;
    right: 5px;
    top: 10px;
    /* #ifdef H5 */
    top: 55px;
    cursor: pointer;

    @media screen and (min-device-width:960px) {
      top: calc(7vh + 20px);
      right: 30px;
      font-size: 16px;
    }

    /* #endif */
  }

  .group-notification-popup {
    z-index: 9999;
  }

  .new-msg-bar {
    position: absolute;
    display: flex;
    flex-direction: row;
DCloud_JSON's avatar
DCloud_JSON 已提交
772
    align-items: flex-start;
773
    right: 40px;
DCloud_JSON's avatar
DCloud_JSON 已提交
774 775 776
    bottom: 10px;
    font-size: 12px;
    background-color: white;
777
    color: #007fff;
DCloud_JSON's avatar
DCloud_JSON 已提交
778
    padding: 5px 8px 5px 5px;
779
    border-radius: 15px 15px 15px 15px;
DCloud_JSON's avatar
DCloud_JSON 已提交
780 781 782 783 784 785
    /* #ifdef H5 */
    pointer-events: auto;
    cursor: pointer;
    /* #endif */
  }
</style>