12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604 |
- <template>
- <view class="app">
- <view id="app-top">
- <uni-nav-bar statusBar backgroundColor="#f8f8f8" left-icon="left" @clickLeft="utils.navigateBack()" fixed >
- <view slot="right" @tap="tapMore">
- <image style="width: 30px;" src="/static/chat/chat-more.png" mode="widthFix"></image>
- </view>
- <view class="fx-r fx-bc fx-ac" style="width: 100%;">
- <view class="fx-r fx-bc fx-ac" v-if="isNetwork">
- <u-loading-icon size="18"></u-loading-icon>
- <text style="font-size: 14px;margin-left: 4px;">链接中..</text>
- </view>
- <text v-else style="text-overflow: ellipsis;white-space: nowrap;overflow: hidden;font-size: 14px;">
- {{chatUser == null ? '加载中..' : ( chatUser.name + '(' + chatUser.count + ')') }}
- </text>
- </view>
- </uni-nav-bar>
- </view>
- <view class="pop-alert" v-if="remindAr.length > 0" @tap="tapReminClose">
- <u-alert type="error" :description="getRemind()"></u-alert>
- <view class="t"><u-icon name="close"></u-icon></view>
- </view>
-
- <scroll-view class="wechat-body" :style="'height:calc(100vh - ' + barheight + 'px - ' + fotInputheight + 'px - ' + inputBottom + 'px)'" scroll-y="true" @scrolltoupper="tapTupper" :scroll-with-animation="scrollAnimation" :scroll-into-view="'view_' + scrollMsgId">
- <view class="loading fx-r fx-ac fx-bc" v-if="loaData.isLoad">
- <image src="/static/chat/xloading.png"></image>
- </view>
- <view style="height: 10px;"></view>
- <view class="chat-item" :id="'view_' + item.msgId" v-for="(item,index) in data">
- <view class='fx-h fx-bc fx-ac' v-if="item.isShowTime == 1">
- <view class="msg-time">{{utils.timeLastdate(item.time,true)}}</view>
- </view>
- <!-- 文字内容 -->
- <chatMsg v-if="item.type =='text'" @longUserItem="tapLongUserItem" @userItem="tapUserItem" @longItem="tapLongItem" @rsend="tapRsend(item.msgId)" :item="item"></chatMsg>
- <!--发送图片-->
- <chatImg v-if="item.type =='img'" @longUserItem="tapLongUserItem" @userItem="tapUserItem" @longItem="tapLongItem" @openImg="tapOpenImg" @rsend="tapRsend(item.msgId)" :item="item"></chatImg>
- <!--发送红包-->
- <chatRed :key="theKey" @userItem="tapUserItem" v-if="item.type =='red_envelope'" @redItem="tapRedItem" :item="item"></chatRed>
- <!--语音消息-->
- <chatVoice v-if="item.type =='voice'" @longUserItem="tapLongUserItem" @userItem="tapUserItem" @rsend="tapRsend(item.msgId)" :item="item"></chatVoice>
- <!--群公告-->
- <chatGroupMsg v-if="item.type =='group_text'" @userItem="tapUserItem" @rsend="tapRsend(item.msgId)" :item="item"></chatGroupMsg>
- <!--红包情况-->
- <chatTip v-if="['red_envelope_tip','tip','group_del','withdraw'].indexOf(item.type) >= 0" :item="item"></chatTip>
- </view>
- </scroll-view>
-
- <view class="foot-view-info" id="foot-view-info">
- <view class="foot-view fx-r fx-bc">
- <image class="icon" src="/static/chat/voice.svg" @tap="tapRecord"></image>
- <textarea auto-height @input="tapInput" class="fx-g1" v-model="msg" :focus="focus" @focus="tapFoucus" :confirm-hold="true" :hold-keyboard="true" :adjust-position="false" @blur="tapBlur" ></textarea>
- <image @tap="tapCkFace(true)" class="icon" src="/static/chat/face.svg" v-if="!isFace"></image>
- <image @tap="tapCkFace(false)" class="icon" src="/static/chat/cmore.svg" v-else></image>
- <image @tap="tapOpenGroup" class="icon" style="width: 28px;height: 28px;" v-if="msg == ''" src="/static/chat/cadd.svg"></image>
- <view class="send-btn" @tap="tapSend" v-else>发送</view>
- </view>
- <!--表情-->
- <view class="face-view" :hidden="!isFace">
- <swiper class="swiper" circular :indicator-dots="true">
- <swiper-item v-for="item in faceAr">
- <view class="face-items fx-r fx-bc">
- <view class="item fx-h fx-bc fx-ac" v-for="(item2,index) in item">
- <image @tap="tapFaceSet(item2)" :src="'../../static/face/face_' + item2.key + '.png'" mode="widthFix"></image>
- </view>
- </view>
- </swiper-item>
- </swiper>
- </view>
-
- <recording ref="recording" @end="tapRecordH5"></recording>
-
- <!--收藏-->
- <view class="group-view" :hidden="!isGroup">
- <scroll-view scroll-y>
- <view class="group-items fx-r fx-bc" >
- <view class="item fx-h fx-bc fx-ac" @tap="tapPhoto">
- <view class="item-bg fx-h fx-bc fx-ac"><image src="../../static/chat/chat-phone.svg"></image></view>
- <view class="text">相册</view>
- </view>
-
- <view class="item fx-h fx-bc fx-ac" @tap="tapCamera">
- <view class="item-bg fx-h fx-bc fx-ac"><image src="../../static/chat/chat-camera.svg"></image></view>
- <view class="text">拍摄</view>
- </view>
-
- <view class="item fx-h fx-bc fx-ac" @tap="tapOpen" :data-url="'./redpack/red?groupId=' + groupId + '&type=chat_group'">
- <view class="item-bg fx-h fx-bc fx-ac"><image src="../../static/chat/chat-reg.svg"></image></view>
- <view class="text">红包</view>
- </view>
-
- <view class="item fx-h fx-bc fx-ac" @tap="tapCollectList">
- <view class="item-bg fx-h fx-bc fx-ac"><image src="../../static/chat/chat-collect.svg"></image></view>
- <view class="text">收藏</view>
- </view>
-
- </view>
- </scroll-view>
- </view>
- </view>
-
- <view class="red-lq fx-h fx-bc fx-ac" v-if="isOpenRed">
- <view class="bg fx-h fx-bc">
- <image class="bg-img" src="../../static/chat/group_award_background.png" ></image>
- <view class="red-close" @tap="isOpenRed = false">
- <u-icon name="close" color="#ffffff" size="18"></u-icon>
- </view>
-
- <view class="red-tip fx-h fx-bc">
- <image :src="utils.getAvatar(lqRed.sendUser.avatar,'chat')" mode="aspectFill"></image>
- <text>{{lqRed.sendUser.nickname}}的红包</text>
- </view>
-
- <view class="red-lv" v-if="lqRed.state == 1" :class="redAnim" @tap="tapOpenLv">
- <image src="../../static/chat/open_group_award_icon.png" mode="widthFix"></image>
- </view>
-
- <view class="red-lm" v-if="lqRed.state == 2" >
- <view class="red-sm">手慢了,红包派完了</view>
- <view class="red-look" @tap="tapOpen" :data-url="'redpack/look?id=' + lqRed.data.id" >查看红包详情></view>
- </view>
-
- </view>
-
-
- </view>
-
-
- <view class="pop-win" v-if="isPopAt">
- <view class="bg" @tap="tapHidePopAt"></view>
- <view class="pop-body" :style="{transform : isPopAt2 ? 'translateY(0)' : 'translateY(100%)'}">
- <view class="key_main fx-h">
- <view class="nav-top">
- <u-icon name="arrow-down" @tap="tapHidePopAt"></u-icon>
- <view class="title">请选择提醒的人</view>
- </view>
- <view class="search-view">
- <u--input
- placeholder="搜索联系人"
- prefixIcon="search"
- clearable
- border="none"
- prefixIconStyle="font-size: 22px;color: #909399"
- v-model="popKeyword"
- @input="tapPopKeyWord"
- ></u--input>
- </view>
-
- <scroll-view class="pop-win-scroll" scroll-y :scroll-into-view="toView" scroll-with-animation='true' show-scrollbar="false" >
- <view class="item fx-r fx-bc" @tap="taopPopItem(item2)" v-for="(item2,index2) in chatUserList">
- <image :src="item2.avatar" mode="aspectFill"></image>
- <view class="info fx-h fx-ac">
- <rich-text class="title" :nodes="getRanValue(item2.nickname)"></rich-text>
- </view>
- </view>
-
- <view class="loading fx-r fx-ac fx-bc" v-if="user.isFrite && !user.isFoot">
- <image src="/static/chat/xloading.png"></image>
- <text>正在载入更多...</text>
- </view>
- <view class="loading complete" :hidden="!user.isFoot">已加载全部</view>
- </scroll-view>
-
- </view>
- </view>
- </view>
-
- <view class="mb2-tip" v-if="showOpen">
- <view class="bg" @tap="showOpen = false"></view>
- <view class="pop-view" :style="'left:' + showLeft+ 'px;top:' + showTop + 'px'">
- <view class="pop-lv"></view>
- <view v-if="showData.type == 'text'">
- <view class="item fx-r fx-bc" @tap="tapCopy">复制</view>
- <view class="item fx-r fx-bc" @tap="tapAddCollection">收藏</view>
- <view class="item fx-r fx-bc" @tap="tapZf">转发</view>
- <view class="item fx-r fx-bc" v-if="showData.sendUser.uid == user.uid && (utils.strtotime() - showData.time ) < 60 * 5" @tap="tapWithdraw">撤回</view>
- </view>
-
- <view v-if="showData.type == 'img'">
- <view class="item fx-r fx-bc" @tap="tapAddCollection">收藏</view>
- <view class="item fx-r fx-bc" @tap="tapDown">下载图片</view>
- <view class="item fx-r fx-bc" @tap="tapZf">转发</view>
-
- <view class="item fx-r fx-bc" v-if="showData.sendUser.uid == user.uid && (utils.strtotime() - showData.time ) < 60 * 5" @tap="tapWithdraw">撤回</view>
- </view>
-
- <view v-if="showData.type == 'voice'">
- <view class="item fx-r fx-bc" @tap="tapAddCollection">收藏</view>
- <view class="item fx-r fx-bc" @tap="tapZf">转发</view>
- <view class="item fx-r fx-bc" v-if="showData.sendUser.uid == user.uid && (utils.strtotime() - showData.time ) < 60 * 2" @tap="tapWithdraw">撤回</view>
- </view>
-
- </view>
- </view>
-
- </view>
- </template>
- <style lang="scss">
- .pop-win{position: fixed;width: 100%;height: 100%;left: 0;top: 0;}
- .pop-win .bg{position: absolute;width: 100%;height: 100%;left: 0;top: 0;background: rgba(0, 0, 0, 0.5);}
- .pop-body{width:100vw;height: 100vh;position: fixed;bottom: 0px;top:0px;left:0px;right:0px;z-index:100;display: flex;flex-direction: column;justify-content: flex-end;transform: translateY(100%);transition:all 0.4s;}
- .key_main{ width:100vw;height: 900rpx;background: #fff;box-sizing: border-box;display: flex;flex-direction: column;}
- .key_main .nav-top{height: 40px;position: relative;}
- .key_main .nav-top .title{text-align: center;font-size: 14px;color: #000;line-height: 40px;}
- .key_main .u-icon{position: absolute;left: 10px;top: 20px;}
- .key_main .search-view{height: 40px;padding: 10px;}
- .key_main scroll-view{height:calc(100% - 90px);}
-
- .pop-win-scroll .item{background: #fff;padding:0 10px;position: relative;}
- .pop-win-scroll .item:active{background: #f1f1f1;}
- .pop-win-scroll .item image{width: 40px;height: 40px;border-radius: 50%;}
- .pop-win-scroll .item .info{width: calc(100% - 70px);margin-left: 10px;font-size: 14px;color:#787878;border-bottom: 1px solid #f1f1f1;height: 60px;}
- .pop-win-scroll .item .flg{background: #ff5857;width: 20px;height: 20px;border-radius: 50%;font-size: 10px;text-align: center;line-height: 20px;color: #fff;}
- .pop-win-scroll .item:last-child .info{border-bottom: 0;}
- .pop-win-scroll .letter{padding: 10px;background: #F8F6F6;}
-
-
-
-
- .red-lq{position: fixed;height: 100%;width: 100%;background: rgba(0, 0, 0, 0.5);left: 0;top: 0;z-index: 10;}
- .red-lq .bg{position: relative;width: 100%;}
- .red-lq .bg image.bg-img{width: 80%;height: 70vh;}
- .red-tip{position: absolute;color: #ffdfb0;margin-top: 30px;font-weight: 14px;}
- .red-tip image{width: 50px;height: 50px;border-radius: 50px;}
- .red-tip text{margin-top: 10px;}
- .red-lq .red-close{position: absolute;left: 55px;top: 14px;}
-
-
- .red-lv{position: absolute;bottom: 25%;}
- .red-lv image{width: 100px;}
- .anim-rotate {
- transform-style: preserve-3d;
- animation: rotate 1s linear infinite;
- }
- @keyframes rotate{
- 0%{
- transform: rotateY(0deg);
- }
- 100%{
- transform: rotateY(360deg);
- }
- }
- .red-lm{position: absolute;bottom: 15%;font-size: 14px;color: #ffdfb0;}
- .red-look{padding: 6px 0; }
-
-
-
- .wechat-body{background: #F1F1F1;position: relative;}
- .foot-view{padding:10px;background: #fff;width: calc(100% - 20px);bottom: 0;min-height: 40px;}
- .foot-view .icon{width: 30px;height: 30px;margin: 0px 4px;}
- .foot-view textarea{width: auto;background: #f1f1f1;border-radius: 6px;height: 20px;margin: 0px 4px;padding: 10px 10px;font-size: 14px;}
-
- .foot-view-info{background: #fff;}
-
- .msg-time{font-size: 14px;color: #ccc;}
- .send-btn{background: $ic-appcolor;color: #fff;font-size: 12px;padding:6px 10px;border-radius: 6px;margin-left: 2px ;}
- .send-btn:active{background: #dddddd;}
- .face-view{width: 100%;z-index: 9;background: #fff;height: 250px;}
- .face-view swiper{height: 250px;}
- .face-view .face-items{padding: 10px;}
- .face-view .face-items .item{width: 12.5%;height: calc((100vw - 20px) / 8 );}
- .face-view .face-items .item image{width: 50%;}
-
-
- .group-view{width: 100%;z-index: 9;background: #F1F1F1;}
- .group-view scroll-view{height: 100%;}
- .group-view .group-items{padding: 10px;}
- .group-view .group-items .item{width: 25%;padding: 10px 0;}
- .group-view .group-items .item .item-bg{width: 50px;height:50px;background: #fff;border-radius: 10px;}
- .group-view .group-items .item .item-bg image{width: 20px;height: 20px;}
- .group-view .group-items .item .text{font-size: 12px;margin-top: 4px;color: $ic-default-text;}
-
- .mb2-tip{position: fixed;width: 100%;height: 100%;top: 0;left: 0;z-index: 999;}
- .mb2-tip .bg{width: 100%;height: 100%;top: 0;left: 0;position: absolute;}
- .mb2-tip .pop-view{position: absolute;background: #fff;border-radius: 6px;border: 1px solid #f1f1f1;padding: 10px 20px;top: 56px;z-index: 9;left: 20px;}
- .mb2-tip .pop-view .item{padding:10px 0;}
- .mb2-tip .pop-view .item:active{background: #f1f1f1;}
-
- .pop-alert{position: relative;}
- .pop-alert .t{position: absolute;z-index: 99;top: 10px;right: 10px;}
- </style>
-
- <script>
- import {mapState,mapMutations } from 'vuex';
- import chatMsg from "@/components/tm-public/chat/msg.vue";
- import chatImg from "@/components/tm-public/chat/cimg.vue";
- import chatRed from "@/components/tm-public/chat/red.vue";
- import chatTip from "@/components/tm-public/chat/tip.vue";
- import chatRedTranfer from "@/components/tm-public/chat/redTransfer.vue";
- import chatRedEnvelopeTransfer from "@/components/tm-public/chat/redEnvelopeTransfer.vue";
- import chatRedEnvelopeTransferRefund from "@/components/tm-public/chat/redEnvelopeTransferRefund.vue";
- import chatGroupMsg from "@/components/tm-public/chat/chatGroupMsg.vue";
- import chatVoice from "@/components/tm-public/chat/voice.vue";
-
- // #ifdef H5
- import recording from '@/components/tm-public/recording/recordingH5.vue';//H5
- // #endif
-
- // #ifdef APP
- import recording from '@/components/tm-public/recording/recordingApp.vue';//APP
- // #endif
-
- import Message from "@/library/socket/Message.js";
- import face from "@/library/utils/Face.js";
- var LetterList = ['A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z','#'];
- const inputHeight = 260;
- export default {
- computed: mapState(['user','sysData']),
- components:{
- chatMsg,
- chatImg,
- chatRed,
- chatTip,
- chatRedTranfer,
- chatRedEnvelopeTransfer,
- chatRedEnvelopeTransferRefund,
- chatGroupMsg,
- chatVoice,
- recording
- },
- data() {
- return {
- isNetwork : false,
- data : [],
- chatUser : null,
- msg : "",
- barheight : 0,
- groupId : 0,
- usercode : "",
-
-
- showOpen : false,
- showData : {},
- showLeft : "",
- showTop : "",
- theKey : 0,
-
- inputBottom : 0,
- keyHeight : 0,
- isShowTop : false,
- scrollMsgId : "",
- showInput : false,
- scrollAnimation : false,
- focus : false,
- isFace : false,
- faceAr : [],
- isGroup : false,
- loaData:{
- isFrite : true,
- isFoot : false,
- isLoad : false,
- page : 1,
- },
- tempFilePaths : [],
- redAnim : "",
- isOpenRed : false,
- lqRed : {},
- redLqBack : [],
- fotInputheight : 0,
-
- /**提醒人**/
- isPopAt : false,
- isPopAt2 : false,
- toView : "",
- chatUserList: [],
- letter : [],
- popKeyword : "",
- popItemIn : [],
- msgId : "",
- nid : 0,
- userGroup : {
- isFirst:false,
- isLoad:false,
- isFoot:false,
- page:1
- },
- mbAr : {},
- remindAr : []
- }
- },
-
- onLoad(option){
- this.groupId = option.groupId;
- this.usercode = option.usercode || "";
- this.msgId = option.msgId || "";
- this.nid = option.nid || 0;
- var strRed = uni.getStorageSync("chat_red_" + this.groupId);
- if(strRed != null && strRed != '') {
- this.redLqBack = JSON.parse(strRed);
- }
- this.$nextTick(() => {
- uni.createSelectorQuery().select("#app-top").boundingClientRect(res=>{
- this.barheight = res == null ? 40 : (res.height + 10);
- if(this.$device.platform == 'ios') {
- this.barheight = res.height + 60;
- }
- }).exec();
- uni.createSelectorQuery().select("#foot-view-info").boundingClientRect(res=>{
- this.fotInputheight = res.height;
- }).exec();
- });
- uni.$on('socketMessage',this.socketMessage);
- uni.$on('redTransferCheck',this.redTransferCheck);
- uni.$on('chatClear',this.chatClear);
- uni.$on('chatDel',this.chatDel);
- uni.$on('glRkName',this.glRkName);
- uni.$on('socketOpen',this.socketOpen);
- uni.$on('socketClose',this.socketClose);
-
- let faceAr = [];
- let nI = 0;
- let index = 0;
- faceAr[0] = [];
- for(let i in face.face) {
- if(nI <= faceAr.length && index == 0) {
- faceAr[nI] = [];
- }
- faceAr[nI].push({
- key : i,
- value : face.face[i].value
- });
- index ++;
- if(index >= 40) {
- index = 0;
- nI++;
- }
- }
- this.faceAr = faceAr;
- this.getInit();
- },
- onUnload() {
- uni.$off('socketMessage',this.socketMessage);
- uni.$off('redTransferCheck',this.redTransferCheck);
- uni.$off('chatClear',this.chatClear);
- uni.$off('chatDel',this.chatDel);
- uni.$off('glRkName',this.glRkName);
- uni.$off('socketOpen',this.socketOpen);
- uni.$off('socketClose',this.socketClose);
- },
-
- onShow() {
- this.onKeyboardHeight();
- this.isNetwork = !this.webSocket.socketOpen;
- },
-
- methods: {
- ...mapMutations(['checkUserLogin','setSys','setTxbagenum']),
- /**
- * 基本数据
- */
- getInit:function(){
- this
- .request
- .post("chatGroupInit",{groupId:this.groupId})
- .then(res=>{
- if(res.code == 200) {
- this.chatUser = res.data;
- this.getData(true);
- this.chatRead(true);
- } else {
- uni.navigateBack({ delta:1});
- uni.showModal({title: '系统提示',content:res.msg,showCancel: false});
- }
- })
- .catch(err=>{
- uni.navigateBack({ delta:1});
- uni.showModal({title: '系统提示',content:"加载失败",showCancel: false});
- });
-
- this
- .request
- .post("GroupRemind",{groupId:this.groupId})
- .then(res => {
- if(res.code == 200) {
- this.remindAr = res.data;
- }
- })
- .catch(err=>{});
-
- },
-
- /**
- *
- */
- getData:function(isPull = false){
- if(this.user == null){
- return;
- }
- this
- .request
- .post("chatMsg",{group_id:this.groupId,page:this.loaData.page,nid:this.nid})
- .then(res=>{
- if(res.code == 200) {
- this.loaData.isLoad = false;
- this.isDisabled = false;
- if (isPull) {
- this.data = res.data.list;
- if(res.data.list.length > 0)
- if(this.msgId != '') {
- this.setScrollInto(this.msgId);
- } else {
- this.setScrollInto(res.data.list[res.data.list.length - 1].msgId);
- }
- } else {
- this.getDescData(res.data.list,'down');
- }
- if (res.data.list.length != res.data.pageSize) {
- this.loaData.isFoot = true;
- }
- this.loaData.isFrite = false;
- this.getwcTime();
- } else {
- uni.showModal({title: '系统提示',content: res.msg,showCancel: false});
- }
- });
- },
-
- /**
- * 上拉加载
- */
- tapTupper:function(){
- if(this.loaData.isFoot || this.loaData.isLoad || this.loaData.isFrite) {
- return;
- }
- this.loaData.isLoad = true;
- this.loaData.page ++;
- this.getData();
- },
-
- /**
- * 得到焦点
- * @param {Object} e
- */
- tapFoucus:function(e){
- this.showInput = true;
- var bfn = ()=>{
- this.isFace = false;
- this.isGroup = false;
- this.isRecord = false;
- this.$refs['recording'].hide();
- //this.inputBottom = 0;
- this.lastScrollInto();
- };
- setTimeout(()=>{
- bfn()
- },100);
- },
- /**
- * 失去焦点
- * @param {Object} e
- */
- tapBlur:function(e){
- setTimeout(()=>{
- this.showInput = false;
- },100);
- },
-
-
- onKeyboardHeight: function() {
- uni.onKeyboardHeightChange(res => {
- this.$set(this,'inputBottom',res.height);
- if(res.height > this.keyHeight) this.keyHeight = res.height;
- });
- },
- /**
- * 计算时间
- */
- getwcTime:function(){
- var time = 0;
- for(var i in this.data){
- var d = this.data[i];
- if(time == 0 || (d.time - time) > 3 * 60) {
- this.data[i].isShowTime = 1;
- time = d.time;
- } else {
- this.data[i].isShowTime = 0;
- }
- if(['red_envelope_transfer','red_envelope'].indexOf(d.type) >= 0) {
- if(this.redLqBack.indexOf(this.data[i].msgId) >= 0) {
- d.isReceiveRed = true;
- this.$set(this.data,i,d);
- } else {
- this.data[i].isReceiveRed = false;
- }
- } else {
- this.data[i].isReceiveRed = false;
- }
- }
- this.theKey ++;
- },
-
- /**
- *
- * @param {Object} data
- */
- getDescData:function(data,desc = 'down'){
- var msgId = "";
- if(desc == 'down') {
- if(this.data.length > 0) {
- msgId = this.data[0].msgId;
- }
- var newData = [];
- for(var i in data) {
- var d = data[i];
- if(!this.findData(d.msgId)) {
- newData.push(d);
- }
- }
- this.$forceUpdate();
- this.data = newData.concat(this.data);
- this.scrollAnimation = false;
- this.setScrollInto(msgId);
- }
- //
- if(desc == 'up') {
- var newData = [];
- for(var i in data) {
- var d = data[i];
- if(!this.findData(d.msgId)) {
- newData.push(d);
- msgId = d.msgId;
- }
- }
- this.$forceUpdate();
- this.data = this.data.concat(newData);
- this.scrollAnimation = true;
- this.setScrollInto(msgId);
- }
- },
-
- /**
- * 设置滚动位置
- * @param {Object} msgId
- */
- setScrollInto:function(msgId){
- if(msgId == "") return ;
- setTimeout(()=>{ this.scrollMsgId = msgId; },200);
- },
-
- /**
- * 弹出上去到底
- */
- lastScrollInto:function(){
- this.scrollMsgId = "1";
- if(this.data.length <= 2) return;
- setTimeout(()=>{
- this.scrollMsgId = this.data[this.data.length - 1].msgId;
- },200);
- },
- /**
- * 打开图片
- * @param {Object} img
- */
- tapOpenImg:function(img) {
- var imgs = [];
- for(var i in this.data) {
- if(this.data[i].type == 'img') imgs.push(this.data[i].data);
- }
- uni.previewImage({current:img,urls:imgs});
- },
- /**
- * 查询重复数据
- * @param {Object} msgId
- */
- findData:function(msgId) {
- for(var i in this.data) {
- if(this.data[i].msgId == msgId) return true;
- }
- return false;
- },
- /**
- * 发送消息
- */
- tapSend:function(){
- if(this.msg == '') {
- return;
- }
- var bb = this.msg.match(/\@(.*?) /g);
- var ddAr = [];
- for(var i in bb) {
- var nickname = bb[i].trim();
- nickname = nickname.substr(1,nickname.length - 1);
- for(var i in this.chatUserList) {
- if(this.chatUserList[i].nickname == nickname) {
- ddAr.push(this.chatUserList[i].uid);
- }
- }
- }
- //消息发送
- var msgId = this.webSocket.createMsgId();
- var sendPack = {};
- sendPack.data = this.msg;
- sendPack.type = "text";
- sendPack.chat_id = "";
- sendPack.f_uid = "";
- sendPack.msg_id = msgId;
- sendPack.group_id = this.groupId;
- sendPack.remind_id = ddAr.length > 0 ? ddAr.join(',') : '';
- var mess = new Message(JSON.stringify(sendPack),"groupChat",true,1,true);
- mess.id = msgId;
-
- //消息添加
- var data = {};
- data.chat = this.chatUser.chat;
- data.sendUser = {
- nickname : this.chatUser.meUser.nickname,
- avatar : this.user.avatar,
- uid : this.user.uid
- };
- data.group_type = 'group_chat';
- data.type = 'text';
- data.data = this.msg;
- data.is_remind = 0;
- data.isSend = 0;
- data.time = this.utils.strtotime();
- data.nid = 0;
- data.msgId = msgId;
- var bool = this.webSocket.send(mess,(res)=>{
- for(var i in this.data) {
- if(this.data[i].msgId == msgId) {
- this.$set(this.data[i],'isSend',1);
- this.chatRead();
- break;
- }
- }
- },err=>{
- for(var i in this.data) {
- if(this.data[i].msgId == msgId) {
- this.$set(this.data[i],'isSend',-1);
- break;
- }
- }
- });
- this.data.push(data);
- this.getwcTime();
- this.setScrollInto(msgId);
- this.msg = '';
- },
- tapRsend:function(msgId){
- var item = null;
- for(var i in this.data) {
- if(this.data[i].msgId == msgId) {
- this.$set(this.data[i],'isSend',0);
- item =this.data[i];
- break;
- }
- }
- if(item == null) return;
- var sendPack = {};
- sendPack.data = item.data;
- sendPack.type = item.type;
- sendPack.chat_id = "";
- sendPack.f_uid = "";
- sendPack.msg_id = item.msgId;
- sendPack.group_id = this.groupId;
- sendPack.remind_id = "";
- var mess = new Message(JSON.stringify(sendPack),"groupChat",true,1,true);
- mess.id = data.msgId;
-
- var bool = this.webSocket.send(mess,(res)=>{
- let isSend = false;
- if(this.utils.isJSON(res)) {
- let rAr = JSON.parse(res);
- if(rAr.code == 1) {
- isSend = true;
- } else {
- this.utils.Tip(rAr.msg);
- }
- }
-
- for(var i in this.data) {
- if(this.data[i].msgId == msgId) {
- this.$set(this.data[i],'isSend',isSend ? 1 : -1);
- if(isSend) this.chatRead();
- break;
- }
- }
- },err=>{
- for(var i in this.data) {
- if(this.data[i].msgId == msgId) {
- this.$set(this.data[i],'isSend',-1);
- break;
- }
- }
- });
-
- },
-
- /**
- * 选择相机
- */
- tapPhoto:function(){
-
- // #ifdef APP-PLUS
- this.$store.dispatch('permission/requestPermissions', 'WRITE_EXTERNAL_STORAGE').then(res => {
- console.log(res);
- if(res !== 1) return;
- uni.chooseImage({
- count: 10,
- sizeType: ['compressed'], // 原图还是压缩图
- sourceType: ['album'], // 相册还是相机
- success: (res)=> {
- var tempFilePaths = res.tempFilePaths;//图片列表
- this.upFileImg(tempFilePaths);
- }
- });
- });
- return;
- // #endif
- uni.chooseImage({
- count: 10,
- sizeType: ['compressed'], // 原图还是压缩图
- sourceType: ['album'], // 相册还是相机
- success: (res)=> {
- var tempFilePaths = res.tempFilePaths;//图片列表
- this.upFileImg(tempFilePaths);
- }
- });
- },
- /**
- * 选择拍摄
- */
- tapCamera:function(){
-
- // #ifdef APP-PLUS
- this.$store.dispatch('permission/requestPermissions', 'WRITE_EXTERNAL_STORAGE').then(res => {
- console.log(res);
- if(res !== 1) return;
- uni.chooseImage({
- count: 1,
- sizeType: ['compressed'],
- sourceType: ['camera'],
- success:(res) => {
- var tempFilePaths = res.tempFilePaths;
- this.upFileImg(tempFilePaths);
- }
- });
- });
- return;
- // #endif
-
- uni.chooseImage({
- count: 1,
- sizeType: ['compressed'],
- sourceType: ['camera'],
- success:(res) => {
- var tempFilePaths = res.tempFilePaths;
- this.upFileImg(tempFilePaths);
- }
- });
- },
-
-
- /**
- * 切换表情
- */
- tapCkFace:function(bool){
- var bfn = ()=>{
- this.isFace = bool;
- if(bool){
- this.isGroup = false;
- this.isRecord = false;
- this.$refs['recording'].hide();
- this.inputBottom = this.keyHeight > 0 ? this.keyHeight : inputHeight;
- this.lastScrollInto();
- } else {
- this.inputBottom = 0;
- }
- uni.hideKeyboard();
- };
- if(this.showInput) {
- setTimeout(()=>{
- bfn()
- },100);
- } else {
- bfn();
- }
- },
- /**
- * 切换更多
- */
- tapOpenGroup:function(){
- this.isFace = false;
- this.isRecord = false;
- this.$refs['recording'].hide();
- var bfn = ()=>{
- this.isGroup = ! this.isGroup;
- if(this.isGroup){
- this.inputBottom = this.keyHeight > 0 ? this.keyHeight : inputHeight;
- this.lastScrollInto();
- } else {
- this.inputBottom = 0;
- }
- uni.hideKeyboard();
- };
- if(this.showInput) {
- setTimeout(()=>{
- bfn()
- },100);
- } else {
- bfn();
- }
- },
- /**
- * 设置face
- * @param {Object} index
- */
- tapFaceSet:function(item) {
- console.log(item);
- this.msg += item.value;
- },
-
- /**
- * 通讯数据
- * @param {Object} res
- */
- socketMessage:function(res){
- if(res.code == null) return;
- var uData = JSON.parse(res.data);
- if(this.groupId == uData.group_id) {
- for(var i in this.data) {
- if(this.data[i].msgId == uData.msgId) return;
- }
-
- if(uData.is_remind == 1) {
- let isAdd = true;
- for(let i in this.remindAr) {
- if(this.remindAr[i].uid == uData.sendUser.uid) {
- isAdd = false;
- }
- }
-
- if(isAdd) {
- this.remindAr.push({
- uid : uData.sendUser.uid,
- nickname : uData.sendUser.nickname
- });
- }
- }
-
- if(uData.type == "withdraw") {
- for(var i in this.data) {
- if(uData.data == this.data[i].msgId) {
- this.$delete(this.data,i);
- }
- }
- }
-
- if(!this.getRepeat(this.data,uData.msgId)) {
- this.data.push(uData);
- setTimeout(()=>{ this.scrollMsgId = uData.msgId; },200);
- this.chatRead();
- }
- }
- },
- /**
- * 网络链接成功
- */
- socketOpen:function(){
- this.isNetwork = false;
- },
- /**
- * 网络关闭 | 需重新链接
- */
- socketClose:function(){
- //console.log('xxx');
- this.isNetwork = true;
- },
-
- /**
- * 清理数据
- * @param {Object} group_id
- */
- chatClear:function(group_id){
- if(group_id == this.groupId) {
- this.data = [];
- this.$forceUpdate();
- }
- },
- /**
- * 清理数据
- * @param {Object} group_id
- */
- chatDel:function(group_id){
- uni.navigateBack({fail:1});
- },
-
- /**
- * 上传图片
- * @param {Object} tempFilePaths
- */
- upFileImg:function(tempFilePaths) {
- var msgId = "";
- for (var i in tempFilePaths) {
- msgId = this.webSocket.createMsgId();
- var data = {};
- data.chat = this.chatUser.chat;
- data.sendUser = {
- nickname : this.chatUser.meUser.nickname,
- avatar : this.user.avatar,
- uid : this.user.uid
- };
- data.group_type = 'group_chat';
- data.type = "img";
- data.data = tempFilePaths[i];
- data.is_remind = 0;
- data.isSend = 0;
- data.time = this.utils.strtotime();
- data.nid = 0;
- data.msgId = msgId;
- this.data.push(data);
- this.tempFilePaths.push(data);
- }
- this.upActionImg();
- setTimeout(()=>{
- this.scrollMsgId = msgId;
- },200);
- this.getwcTime()
- },
- /**
- * 上传图片
- * @param {Object} data
- */
- upActionImg:function() {
-
- if(this.tempFilePaths.length <= 0) {
- this.isUpImg = false;
- return;
- }
- this.isUpImg = true;
- var tmpData = this.tempFilePaths[0];
- this
- .request
- .post(this.request.getApi("qiniu"),{type:"jpg"})
- .then(res=>{
- uni.uploadFile({
- url: 'https://up-z0.qiniup.com',
- filePath: tmpData.data,
- name: 'file',
- formData: {
- 'key': res.data.mk_str,
- 'token': res.data.token
- },
- success: (uploadFileRes) => {
- var sendPack = {};
- sendPack.data = res.data.url;
- sendPack.type = "img";
- sendPack.chat_id = "";
- sendPack.f_uid = "";
- sendPack.group_id = this.groupId;
- sendPack.msg_id = tmpData.msgId;
-
- this.webSocket.send((new Message(JSON.stringify(sendPack),"groupChat",true,1,true)),
- (res) => {
- var data = JSON.parse(res);
- if(data.code == 1) {
- this.inUpAction(tmpData.msgId,1);
- this.chatRead();
- } else {
- this.inUpAction(tmpData.msgId,-1);
- }
- },
- error=>{
- this.inUpAction(tmpData.msgId,-1);
- });
- },
- fail:()=>{
- this.inUpAction(msgId,-1);
- }
- });
- })
- .catch(err=>{
- this.inUpAction(msgId,-1);
- });
- },
- /**
- * 执行状态
- */
- inUpAction:function(msgId,type) {
- for(var i in this.data) {
- if(this.data[i].msgId == msgId) this.$set(this.data[i],"isSend",type);
- }
- this.tempFilePaths.splice(0,1);
- this.upActionImg();
- },
- /**
- * 打开
- * @param {Object} ev
- */
- tapOpen: function(ev) {
- let url = ev.currentTarget.dataset.url;
- this.utils.navigateTo(url);
- },
- /**
- * 领取红包页面
- * @param {Object} ev
- */
- tapRedItem:function(ev){
- this.lqRed.data = JSON.parse(ev.data);
- console.log(this.lqRed);
- uni.showLoading({ title:"加载中.." });
- this.lqRed.sendUser = ev.sendUser;
- this.lqRed.msgId = ev.msgId;
- this.lqRed.state = 1;
- this
- .request
- .post("chatRedEvelope",{id:this.lqRed.data.id})
- .then(res=>{
- uni.hideLoading();
- if(res.code == 200) {
- console.log(res);
- if(!res.data.is_receive && this.user.uid != ev.data.send_uid) {
- this.isOpenRed = true;
- } else {
- this.redTransferCheck(this.lqRed.msgId);
- uni.navigateTo({ url:"redpack/look?id=" + this.lqRed.data.id});
- }
- } else {
- uni.hideLoading();
- uni.showModal({title: '系统提示',content: res.msg,showCancel: false});
- }
- })
- .catch(err=>{
- uni.hideLoading();
- uni.showModal({title: '系统提示',content: "加载失败",showCancel: false});
- });
- },
- /**
- * 确认领取红包
- */
- tapOpenLv:function(){
- this.redAnim = "anim-rotate";
- this
- .request
- .post("drwReceive",{
- id : this.lqRed.data.id
- })
- .then(res=>{
- this.redAnim = "";
- if(res.code == 200) {
-
- if(res.data.status == 200) {
- this.isOpenRed = false;
- let music = uni.createInnerAudioContext();
- music.src = "/static/img/red_receive.mp3";
- music.play();
- this.redTransferCheck(this.lqRed.msgId);
- uni.navigateTo({ url:"redpack/look?id=" + this.lqRed.data.id});
- }
-
- if(res.data.status == 100) {
- this.lqRed.state = 2;
- this.redTransferCheck(this.lqRed.msgId);
-
- }
-
- } else {
- uni.showModal({title: '系统提示',content:res.msg,showCancel: false});
- }
- })
- .catch(err=>{
- this.redAnim = "";
- uni.showModal({title: '系统提示',content:"领取失败,请重新尝试!",showCancel: false});
- });
-
- },
- /**
- * 验证码
- *
- */
- tapZc:function(){
- uni.navigateTo({
- url:"redpack/groupUserSend?groupId=" + this.groupId + "&type=transfer"
- });
- },
- /**
- * 打开转账数据
- * @param {Object} ev
- */
- tapRedTransferItem:function(ev){
- var data = JSON.parse(ev.data);
- uni.navigateTo({
- url:"redpack/transferLook?id=" + data.id + "&msgId=" + ev.msgId
- });
- },
- /**
- * 转账阅读
- * @param {Object} msgId
- */
- redTransferCheck:function(msgId){
- this.redMsg(msgId);
- setTimeout(()=>{this.getwcTime();},200);
- },
- /**
- * 红包阅读/存
- * @param {Object} msgId
- */
- redMsg:function(msgId){
- for(var i in this.redLqBack) {
- if(this.redLqBack[i] == msgId) return;
- }
- this.redLqBack.push(msgId);
- if(this.redLqBack.length > 500) {
- this.redLqBack.splice(0,10);
- }
- uni.setStorage({
- key : "chat_red_" + this.groupId,
- data : JSON.stringify(this.redLqBack)
- })
- },
- tapInput:function(ev){
- var value = ev.detail.value;
- if(value == '') return;
- if(value[value.length - 1] == '@') {
- this.isPopAt = true;
- setTimeout(()=>{
- this.isPopAt2 = true;
- },200);
- this.userGroup.page = 1;
- this.tapLxInit(true);
- uni.hideKeyboard();
- }
- //var bb = value.match(/\@(.*?) /g);
- },
- tapHidePopAt:function(){
- this.isPopAt2 = false;
- setTimeout(()=>{
- this.isPopAt = false;
- },200);
- },
- /**
- * 搜索观察家
- */
- tapPopKeyWord:function(){
- this.page = {page:1,isLoad:false,isFoot:false};
- if(this.mbAr[this.popKeyword] != null) {
- this.data = this.mbAr[this.popKeyword];
- } else {
- this.tapLxInit(true);
- }
- },
- /**
- * 遍历字符串
- */
- getRanValue:function(str) {
- let value = str;
- if (value.indexOf(this.popKeyword)!==-1) {
- let reg = new RegExp(this.popKeyword, 'gi')
- return value.replace(reg, `<font style="color:#2fbec0">${this.popKeyword}</font>`)
- } else {
- return value
- }
- },
- /**
- * 点击事件
- */
- taopPopItem:function(item){
- this.msg += item.nickname + " ";
- this.tapHidePopAt();
- this.focus = true;
- },
-
- tapLongUserItem:function(item){
- this.msg += "@"+item.data.sendUser.nickname + " ";
- this.chatUserList.push({
- uid : item.data.sendUser.uid,
- nickname : item.data.sendUser.nickname
- });
- },
-
-
-
- /**
- * 获取提醒人数据
- */
- tapLxInit:function(isPull){
- uni.showLoading({ title:"加载中.."});
- this
- .request
- .post("chatGroupUser",{
- groupId : this.groupId,
- page : this.userGroup.page,
- keyword : this.popKeyword
-
- })
- .then(res=>{
- uni.hideLoading();
- if(res.code == 200) {
- this.userGroup.isFrite = true;
- this.userGroup.isLoad = false;
- if(isPull) {
- this.chatUserList = res.data.list;
- } else {
- this.chatUserList = this.chatUserList.concat(res.data.list);
- }
- //是否到底
- if(res.data.list.length != res.data.pageSize) {
- this.userGroup.isFoot = true;
- }
-
- if(this.userGroup.page == 1 && this.popKeyword != ''){
- this.mbAr[this.popKeyword] = res.data.list;
- }
- } else {
- this.utils.Tip(res.msg);
- }
- })
- .catch(err=>{
- console.log(err);
- uni.hideLoading();
- this.utils.Tip("加载失败");
- });
-
- },
- /**
- * 更多
- */
- tapMore:function(){
- uni.navigateTo({
- url:"group/info/groupInfo?groupId=" + this.groupId
- })
- },
- chatRead:function(bool = false){
- this
- .request
- .post("chatRead",{groupId:this.groupId})
- .then(res=>{
- if(res.code == 200) {
- uni.$emit('chatRead',{groupId:this.groupId,bool:bool});
- } else {
- uni.showModal({title: '系统提示',content: res.msg,showCancel: false});
- }
- });
- },
- /**
- * 查看收藏
- */
- tapCollectList:function(){
-
- uni.navigateTo({
- url:"collection/collect?groupId=" + this.groupId + "&nickname=" + encodeURIComponent(this.chatUser.name) + "&avatar="
- + (this.chatUser.img == '' ? '/static/img/logo.png' : encodeURIComponent(this.chatUser.img))
- });
- },
- /**
- * 长安效果
- */
- tapLongItem:function(ev){
- var index = ev.dom.currentTarget.dataset.id;
- var left = ev.dom.touches[0].pageX;
- var top = ev.dom.touches[0].clientY;
- var leftW = this.$device.screenWidth - left;
- var topW = this.$device.screenHeight - top;
- this.showLeft = leftW < 190 ? (left - (190 - leftW)): left;
- this.showTop = topW < 250 ? (top - (250 - topW)) : top;
- this.showOpen = true;
- this.showData = ev.data;
- },
-
- /**
- * 复制内容
- */
- tapCopy:function(){
- this.showOpen = false;
- uni.setClipboardData({
- data: this.showData.data,
- success: data => {
- this.utils.showAlert({
- title: "复制成功!",
- icon: "none",
- mask: true
- })
- },
- fail: err => {
- this.utils.showAlert({
- title: "复制失败,请重新复制",
- icon: "none",
- mask: true
- })
- },
- });
- },
- tapAddCollection:function(){
- this.showOpen = false;
- uni.showLoading({ title:"操作中.." });
- this
- .request
- .post("collectAdd",{
- msg_id : this.showData.msgId,
- data : this.showData.data,
- nickname : this.showData.user.nickname
- })
- .then(res=>{
- uni.hideLoading();
- if( res.code== 200){
- this.utils.Tip("操作成功");
- } else {
- uni.showModal({title: '系统提示',content: res.msg,showCancel: false});
- }
- })
- .catch(err=>{
- uni.hideLoading();
- uni.showModal({title: '系统提示',content:"操作失败!",showCancel: false});
- })
-
- },
- tapDown:function(){
- this.showOpen = false;
- uni.downloadFile({
- url : this.showData.data,
- success:(resFile)=>{
- if (resFile.statusCode === 200) {
- uni.saveImageToPhotosAlbum({
- filePath: resFile.tempFilePath,
- success: (res)=> {
- this.utils.Tip("保存图片成功");
- },
- fail:(res)=> {
- this.utils.showAlert("保存失败,请重新操作");
- },
- complete: function(res) {},
- })
- } else {
- this.isDown = false;
- this.utils.showAlert("保存失败,请重新操作");
- }
- },
- fail:()=>{
- this.isDown = false;
- this.utils.showAlert("保存失败,请重新操作");
- }
- });
- },
- tapRecord:function(){
- this.isRecord = !this.isRecord;
- if(this.isRecord) {
- this.isGroup = false;
- this.isFace = false;
- this.inputBottom = 150;
- this.$refs['recording'].open();
- } else {
- this.inputBottom = 0;
- this.$refs['recording'].hide();
- }
- },
-
- /**
- * @param {Object} pm
- */
- tapRecordH5:function(recAr){
- uni.showLoading({ title:"发送中.."});
- this
- .request
- .post("chatUpVoice",recAr)
- .then( res => {
- uni.hideLoading();
- if(res.code == 200) {
- var msgId = this.webSocket.createMsgId();
- //消息添加
- var data = {};
- data.chat = this.chatUser.chat;
- data.sendUser = {
- nickname : this.chatUser.meUser.nickname,
- avatar : this.user.avatar,
- uid : this.user.uid
- };
- data.group_type = 'group_chat';
- data.type = 'voice';
- data.data = JSON.stringify({time:recAr.duration,filePath:res.data.msgFile});
- data.is_remind = 0;
- data.isSend = 0;
- data.time = this.utils.strtotime();
- data.nid = 0;
- data.msgId = msgId;
- this.data.push(data);
- this.getwcTime();
- this.setScrollInto(msgId);
-
- var sendPack = {};
- sendPack.data = JSON.stringify({time:recAr.duration,filePath:res.data.msgFile});
- sendPack.type = "voice";
- sendPack.chat_id = "";
- sendPack.f_uid = "";
- sendPack.group_id = this.groupId;
- sendPack.msg_id = msgId;
-
- this.webSocket.send((new Message(JSON.stringify(sendPack),"groupChat",true,1,true)),
- (res) => {
- var data = JSON.parse(res);
- if(data.code == 1) {
- this.inUpAction(msgId,1);
- this.chatRead();
- } else {
- this.inUpAction(msgId,-1);
- }
- },
- error=>{
- this.inUpAction(msgId,-1);
- });
- } else {
- uni.showModal({title: '系统提示',content:res.msg,showCancel: false});
- }
-
- })
- .catch(err=>{
- console.log(err);
- uni.hideLoading();
- uni.showModal({title: '系统提示',content:"发送失败,请重新尝试!",showCancel: false});
- });
- },
- /**
- * 撤回
- */
- tapWithdraw:function(){
- this.showOpen = false;
- uni.showLoading({ title:"撤回中..."});
- this
- .request
- .post("withdraw",{groupId : this.groupId,msg_id:this.showData.msgId})
- .then(res=>{
- uni.hideLoading();
- if(res.code == 200) {
- for(var i in this.data) {
- if(this.data[i].msgId == this.showData.msgId) {
- var data = this.data[i];
- data.type = "tip";
- data.data = "你撤回了一条消息";
- this.$set(this.data,i,data);
- }
- }
- } else {
- this.utils.Tip(res.msg);
- }
- })
- .catch(err=>{
- uni.hideLoading();
- this.utils.Tip("加载失败");
- });
-
- },
- /**
- * 我要转发
- */
- tapZf:function(){
- this.showOpen = false;
- uni.navigateTo({
- url:"transmit?msgId=" + this.showData.msgId + "&data=" + this.showData.data + "&type=" + this.showData.type
- });
- },
- /**
- * 查看用户信息
- */
- tapUserItem:function(uid){
- uni.navigateTo({
- url:"/pages/chat/friend/info?usercode=" + uid
- })
- },
- glRkName:function(data){
- if(this.groupId == data.groupId) {
- this.getData(true);
- }
- },
- /**
- * 是否判断重复msgId
- */
- getRepeat:function(data,msgId){
- for(var i in data) {
- if(data[i].msgId == msgId) return true;
- }
- return false;
- },
-
- tapReminClose:function(){
- this.remindAr = [];
- //更新提醒时间
- this.request.post("GroupRemindOk",{groupId : this.groupId}).then(res=>{}).catch(err=>{});
- },
-
- /**
- * @你
- */
- getRemind:function(){
- let reStr = "";
- for(let i in this.remindAr) {
- let d = this.remindAr[i];
- if(reStr == "") {
- reStr += d.nickname + "@你";
- } else {
- reStr += "," + d.nickname + "@你";
- }
- }
- return reStr;
- }
-
-
-
- }
- }
- </script>
- <style>
- </style>
|