123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495 |
- <template>
- <div class="chat-room">
- <!-- {{$route.params.id}} -->
- <div class="mini-wrap moblie-wrap">
- <div class="mini-body">
- <div class="box">
- <back-bar :title="isPrivate ? group.privateName : group.groupName">
- <span v-if="!isPrivate" class="group-set-icon el-icon-more"></span>
- </back-bar>
- <chat-pin v-bind="pinMsg" @pinMsgClose="pinMsgClose" @scrollToView="scrollToView"></chat-pin>
- <div class="box-bd" ref="msgBox">
- <div ref="scrollWrap"
- @scroll.prevent="handleScroll"
- class="scroller"
- >
- <div ref="msgWrap" class="msg-wrap">
- <div class="msg-top-more" v-if="lockEnd">
- <em>没有更多了</em>
- </div>
- <div class="msg-top-load" v-if="lockMore && !lockEnd">
- <i class="msg-loading-icon"></i>
- </div>
- <template v-if="group.chatList.length">
- <msg-item v-for="(item ,key) in group.pinList"
- :key="'pin' + key"
- v-bind="item"
- @quoteMsg="quoteMsg"
- @deleteMsg="deleteMsg"
- >
- </msg-item>
- </template>
- <msg-item v-for="item in group.chatList"
- :key="item.hash"
- v-bind="item"
- :msgItem="item"
- @quoteMsg="quoteMsg"
- @deleteMsg="deleteMsg"
- ></msg-item>
- </div>
- </div>
- <at-me :atList="atList" class="mini" @scrollToMsg="scrollToMsg"></at-me>
- <div class="msg-unread"
- @click="doSetRead"
- v-if="unreadNums > 0 && enableScroll && !isBottom">
- <em><i class="el-icon-d-arrow-right"></i>{{unreadNums}}条未读消息</em>
- </div>
- </div>
- <div class="box-ft">
- <chat-at
- ref="chatAt"
- v-if="atShow"
- @atperson="atPerson"
- :curInd="atInd"
- :filterList="filterMembers">
- </chat-at>
- <div class="input-con">
- <div class="more-icon" @click.stop="handleMoreClick"></div>
- <form class="input-wrap" @submit="handleSend">
- <textarea
- @keydown.up.prevent="handleUp"
- @keydown.down.prevent="handleDown"
- @keydown.left="handleLeft"
- @keydown.right="handleRight"
- @keydown.delete="handleDel"
- @keydown.esc="handleEsc"
- cols="1"
- ref="chatInput"
- rows="1"
- @keydown.enter="handleKeyDown"
- placeholder="Write a message"
- v-model="inputMsg"
- @focus="handleFocus"
- @blur="handleBlur"
- />
- </form>
- <div class="emoji-icon" @click.stop="handleEmojiClick"></div>
- <div class="btn-send" @click="handleSend">发送</div>
- </div>
- <div class="tool-wrap" @click.stop v-show="toolShow">
- <div class="tool-item">
- <div class="icon-box" @click="$packetSend">
- <i class="packet-icon"></i>
- </div>
- <span class="type">红包</span>
- </div>
- <div class="tool-item">
- <div class="icon-box">
- <i class="picture-icon"></i>
- <input type="file" ref="inputFile1" name="res" accept="image/*" @change="handleFile">
- </div>
- <span class="type">图片</span>
- </div>
- <div class="tool-item">
- <div class="icon-box">
- <i class="audio-icon"></i>
- <input type="file" ref="inputFile2" name="res" accept="audio/*" @change="handleFile">
- </div>
- <span class="type">音频</span>
- </div>
- <div class="tool-item">
- <div class="icon-box">
- <i class="video-icon"></i>
- <input type="file" ref="inputFile3" name="res" accept="video/*" @change="handleFile">
- </div>
- <span class="type">视频</span>
- </div>
- </div>
- <div class="emoji-wrap" v-if="emojiShow">
- <emoji-list @addEmoji="addEmoji"></emoji-list>
- </div>
- </div>
- </div>
- </div>
- </div>
- </div>
- </template>
- <script>
- // import { mapState, mapMutations, mapActions } from 'vuex'
- import backBar from '@/components/backBar'
- import msgItem from '@/components/msgItem'
- import emojiList from '@/components/emoji'
- import chatAt from '@/components/chatAt'
- import atMe from '@/components/chatAt/atme'
- import chatPin from '@/components/chatPin'
- import { chatAtMixin, chatInputMixin } from '@/mixins'
- import { chatMixin, inputMixin } from '@/mixins/chat'
- // import API from '@/api'
- export default {
- name: 'h5ChatRoom',
- mixins: [chatAtMixin, chatInputMixin, chatMixin, inputMixin],
- components: {
- msgItem,
- emojiList,
- chatAt,
- chatPin,
- atMe,
- backBar
- },
- data () {
- return {
- emojiShow: false,
- toolShow: false
- }
- },
- methods: {
- handleEmojiClick () {
- this.toolShow = false
- this.emojiShow = !this.emojiShow
- },
- handleMoreClick () {
- this.emojiShow = false
- this.toolShow = !this.toolShow
- }
- }
- }
- </script>
- <style lang="scss" scoped>
- @charset "UTF-8";
- $chatBg: #34363c;
- $chatContBg: #eeeeee;
- $chatUiFont: #ffffff;
- $offsetBottom: 5px;
- $offsetRight: 5px;
- .group-set-icon{
- position: absolute;
- right: 0;
- top: 0;
- height: px2rem(90);
- width: px2rem(100);
- text-align: center;
- font-size: px2rem(42);
- line-height: px2rem(90);
- }
- .mini-wrap{
- z-index: 123456789;
- height: 100%;
- }
- .mini-body{
- height: 100%;
- box-sizing: border-box;
- }
- .box{
- position: relative;
- height: 100%;
- display: flex;
- flex-direction: column;
- }
- .chat-room{
- position: absolute;
- top: 0;
- left: 0;
- width: 100%;
- height: 100%;
- }
- .box-bd{
- height: 0;
- flex: 1;
- position: relative;
- background: $chatContBg;
- .msg-unread{
- position: absolute;
- width: 120px;
- left: 50%;
- bottom: 10px;
- border-radius: 20px;
- background: rgba(#000000, 0.5);
- padding: 0 5px;
- text-align: center;
- line-height: 32px;
- margin-left: -65px;
- cursor: pointer;
- &:hover{
- background: rgba(#000000, 0.3);
- }
- em{
- color: #ffffff;
- font-size: 14px;
- }
- i{
- transform: rotate(90deg);
- margin-right: 5px;
- }
- }
- }
- .scroller{
- height: 100%;
- overflow-y: scroll;
- &::-webkit-scrollbar {
- width: 8px;
- height: 6px;
- }
- &::-webkit-scrollbar-thumb {
- border-radius: 3px;
- -moz-border-radius: 3px;
- -webkit-border-radius: 3px;
- background-color: rgba($color: #8d8a8a, $alpha: 0.2);
- }
- &::-webkit-scrollbar-track {
- background-color: transparent;
- }
- }
- .box-ft{
- position: relative;
- background: $chatContBg;
- border-top: 1px solid #d6d6d6;
- .input-con{
- position: relative;
- display: flex;
- align-items: flex-end;
- background-color: #fafafa;
- padding: 6px 0;
- }
- .input-wrap{
- flex: 1;
- padding: 10px 0;
- background-color: #ffffff;
- border-radius: 4px;
- }
- .more-icon{
- width: 38px;
- height: 38px;
- background: url('../../../assets/more-icon.png') center center no-repeat;
- background-size: 22px 22px;
- cursor: pointer;
- &:hover{
- opacity: .6;
- }
- }
- .emoji-icon{
- width: 38px;
- height: 38px;
- background: url('../../../assets/m-face-icon.png') center center no-repeat;
- background-size: 22px 22px;
- cursor: pointer;
- &:hover{
- opacity: .6;
- }
- }
- .btn-send{
- margin-right: 4px;
- font-size: 12px;
- color: #ffffff;
- padding: 0 10px;
- height: 28px;
- line-height: 28px;
- margin-bottom: 3px;
- background: #2b9ff6;
- border-radius: 3px;
- cursor: pointer;
- &:hover{
- opacity: 0.8;
- }
- }
- form{
- @include flex(1);
- }
- textarea {
- display: block;
- width: 100%;
- height: 18px;
- max-height: 175px;
- font-size: 14px;
- color: #000000;
- line-height: 16px;
- padding: 1px;
- padding-left: 8px;
- margin: 0;
- border: none;
- outline: none;
- background: none;
- box-sizing: border-box;
- resize: none;
- }
- .emoji-wrap{
- position: absolute;
- left: 0;
- right: 0;
- bottom: 52px;
- background: #ffffff;
- box-shadow: 1px 1px 50px rgba(0,0,0,.3);
- z-index: 10;
- }
- .input-ctrl{
- span{
- width: 120px;
- margin: 4px auto;
- height: 30px;
- line-height: 30px;
- color: #ffffff;
- font-size: 12px;
- text-align: center;
- display: block;
- background-image: -webkit-linear-gradient( 90deg, rgb(25,145,235) 0%, rgb(46,161,248) 100%);
- border-radius: 3px;
- &.enable{
- cursor: pointer;
- &:hover{
- opacity: 0.7;
- }
- }
- }
- }
- }
- .msg-wrap{
- margin-bottom: 16px;
- }
- .msg-top-more{
- margin-top: 10px;
- text-align: center;
- i{
- font-size: 30px;
- }
- em{
- font-size: 12px;
- line-height: 20px;
- color: #999999;
- }
- }
- .msg-loading-icon{
- display: block;
- background: url('../../../assets/loading-icon.png') no-repeat;
- background-size: 100%;
- width: 16px;
- height: 16px;
- margin: 12px auto;
- animation: rotate 2s linear infinite;
- }
- .tool-wrap{
- background-color: #f6f6f6;
- display: flex;
- padding: 16px 0;
- .tool-item{
- flex: 1;
- text-align: center;
- }
- .type{
- font-size: 14px;
- color: #666666;
- }
- .icon-box{
- width: 58px;
- height: 58px;
- margin: 0 auto;
- cursor: pointer;
- background-color: #ffffff;
- border-radius: 6px;
- border: 1px solid #efefef;
- box-sizing: border-box;
- margin-bottom: 6px;
- display: flex;
- justify-content: center;
- align-items: center;
- position: relative;
- &:hover{
- opacity: .8;
- }
- input[type=file] {
- opacity: 0;
- position: absolute;
- top: 0;
- left: 0;
- width: 100%;
- height: 100%;
- cursor: pointer;
- z-index: 4;
- }
- i{
- display: inline-block;
- }
- .packet-icon{
- background: url('../../../assets/packet-icon.png') no-repeat;
- background-size: 100%;
- width: 21px;
- height: 26px;
- }
- .picture-icon{
- background: url('../../../assets/pic-icon.png') no-repeat;
- background-size: 100%;
- width: 27px;
- height: 21px;
- }
- .audio-icon{
- background: url('../../../assets/audio-icon.png') no-repeat;
- background-size: 100%;
- width: 18px;
- height: 26px;
- }
- .video-icon{
- background: url('../../../assets/video-icon.png') no-repeat;
- background-size: 100%;
- width: 30px;
- height: 18px;
- }
- }
- }
- // 手机端适配
- .moblie-wrap{
- .box-hd{
- height: 30px;
- }
- .box-ft{
- .emoji-wrap{
- bottom: 54px;
- }
- .btn-send{
- height: 36px;
- line-height: 36px;
- padding: 0 10px;
- font-size: 16px;
- margin-bottom: 0;
- }
- .input-ctrl span {
- height: 40px;
- line-height: 40px;
- font-size: 16px;
- }
- .input-con{
- padding: 8px 0;
- align-items: center;
- }
- .input-wrap{
- padding: 10px 0;
- margin: 0 6px;
- .textarea{
- height: 26px;
- line-height: 20px;
- }
- }
- .more-icon{
- background-size: 30px 30px;
- }
- .emoji-icon{
- background-size: 30px 30px;
- margin-right: 4px;
- }
- }
- }
- </style>
|