1 Star 0 Fork 100

linzl / BBBUG Frontend

forked from BBBUG / BBBUG Frontend 
加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
克隆/下载
index.php 200.95 KB
一键复制 编辑 原始数据 按行查看 历史
Hamm 提交于 2020-10-09 16:06 . add: 来自linu 来自Linus的IE嘲讽
12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849285028512852285328542855285628572858285928602861286228632864286528662867286828692870287128722873287428752876287728782879288028812882288328842885288628872888288928902891289228932894289528962897289828992900290129022903290429052906290729082909291029112912291329142915291629172918291929202921292229232924292529262927292829292930293129322933293429352936293729382939294029412942294329442945294629472948294929502951295229532954295529562957295829592960296129622963296429652966296729682969297029712972297329742975297629772978297929802981298229832984298529862987298829892990299129922993299429952996299729982999300030013002300330043005300630073008300930103011301230133014301530163017301830193020302130223023302430253026302730283029303030313032303330343035303630373038303930403041304230433044304530463047304830493050305130523053305430553056305730583059306030613062306330643065306630673068306930703071307230733074307530763077307830793080308130823083308430853086308730883089309030913092309330943095309630973098309931003101310231033104310531063107310831093110311131123113311431153116311731183119312031213122312331243125312631273128312931303131313231333134313531363137313831393140314131423143314431453146314731483149315031513152315331543155315631573158315931603161316231633164316531663167316831693170317131723173317431753176317731783179318031813182318331843185318631873188318931903191319231933194319531963197319831993200320132023203320432053206320732083209321032113212321332143215321632173218321932203221322232233224322532263227322832293230323132323233323432353236323732383239324032413242324332443245324632473248324932503251325232533254325532563257325832593260326132623263326432653266326732683269327032713272327332743275327632773278327932803281328232833284328532863287328832893290329132923293329432953296329732983299330033013302330333043305330633073308330933103311331233133314331533163317331833193320332133223323332433253326332733283329333033313332333333343335333633373338333933403341334233433344334533463347334833493350335133523353335433553356335733583359336033613362336333643365336633673368336933703371337233733374337533763377337833793380338133823383338433853386338733883389339033913392339333943395339633973398339934003401340234033404340534063407340834093410341134123413341434153416341734183419342034213422342334243425342634273428342934303431343234333434343534363437343834393440344134423443344434453446344734483449345034513452345334543455345634573458345934603461346234633464346534663467346834693470347134723473347434753476347734783479348034813482348334843485348634873488348934903491349234933494
<?php
require 'common.php';
$domain = strtolower($_SERVER['HTTP_HOST']);
$room_id = 888;
$room_title = 'BBBUG音乐聊天室';
$room_desc = 'BBBUG.COM,一个划水音乐聊天室,超多小哥哥小姐姐都在这里一起听歌、划水聊天、技术分享、表情包斗图,欢迎你的加入!';
$room_keyword = '划水聊天室,音乐聊天室,一起听歌,程序员,摸鱼聊天室,佛系聊天,交友水群,程序猿,斗图,表情包';
$room_notice = '欢迎来到BBBUG音乐聊天室!';
$room_url = '';
if(true){ //开发调试可直接改为false 跳过域名处理业务
if (strpos($domain, 'bbbug.com') !== false || strpos($domain, 'hamm.cn') !== false) {
//我方域名
if (strpos($domain, '.hamm.cn') !== false) {
header('Location: https://404.hamm.cn');die;
}
if ($domain != 'bbbug.com') {
//是 *.bbbug.com
$subDomain = str_replace('.bbbug.com', '', $domain);
if ($subDomain != 'bbbug.com') {
$result = curlHelper('https://api.bbbug.com/api/room/getRoomByDomain?room_domain=' . $subDomain);
$arr = json_decode($result['body'], true);
if ($arr['code'] == 200) {
$room_id = $arr['data']['room_id'];
$room_title = $arr['data']['room_name'];
$room_notice = $arr['data']['room_notice'];
$room_desc = $arr['data']['room_name'] . ',超多小哥哥小姐姐都在这里一起听歌、划水聊天、技术分享、表情包斗图,欢迎你的加入!';
$room_keyword = $arr['data']['room_name'] . ',划水聊天室,音乐聊天室,一起听歌,程序员,摸鱼聊天室,佛系聊天,交友水群,程序猿,斗图,表情包';
$room_url = $arr['data']['room_url'];
}else{
//没有查询到cname
header('Location: https://bbbug.com');die;
}
}
}
} else {
$cname = dns_get_record($domain, DNS_CNAME);
if (count($cname) > 0) {
$subDomain = str_replace('.bbbug.com', '', $cname[0]['target']);
if ($subDomain != $cname[0]['target']) {
$result = curlHelper('https://api.bbbug.com/api/room/getRoomByDomain?room_domain=' . $subDomain);
$arr = json_decode($result['body'], true);
if ($arr['code'] == 200) {
$room_id = $arr['data']['room_id'];
$room_title = $arr['data']['room_name'];
$room_notice = $arr['data']['room_notice'];
$room_desc = $arr['data']['room_name'] . ',超多小哥哥小姐姐都在这里一起听歌、划水聊天、技术分享、表情包斗图,欢迎你的加入!';
$room_keyword = $arr['data']['room_name'] . ',划水聊天室,音乐聊天室,一起听歌,程序员,摸鱼聊天室,佛系聊天,交友水群,程序猿,斗图,表情包';
$room_url = $arr['data']['room_url'];
}
}
} else {
//没有查询到cname
header('Location: https://404.hamm.cn');die;
}
}
}
$redirectUrl = ($_SERVER['HTTP_X_FORWARDED_PROTO'] ?? $_SERVER['REQUEST_SCHEME']) . "://" . $_SERVER['HTTP_HOST'];
if($room_url){
$redirectUrl = $room_url;
}
setcookie('localhost',$redirectUrl,time()+3600,'/','bbbug.com');
if (strpos($_SERVER['HTTP_USER_AGENT'], "Triden")) {
die('<center><h1>屌毛,你的浏览器不配访问bbbug.com</h1><hr><h4>Sorry but fuck your internet explore!</h4><br><br><br><img src="images/linus.jpg" height="300px"/></center>');
}
?>
<!DOCTYPE html>
<html>
<head>
<title><?php echo htmlspecialchars($room_title); ?></title>
<meta charset="UTF-8">
<meta name='Keywords' content="<?php echo htmlspecialchars($room_keyword); ?>">
<meta name='Description' content="<?php echo htmlspecialchars($room_desc); ?>">
<meta name="viewport"
content="width=device-width,initial-scale=1.0,minimum-scale=1.0;maximum-scale=1.0, user-scalable=no" />
<meta name="format-detection" content="telephone=no" />
<meta name="apple-mobile-web-app-capable" content="yes" />
<meta name="apple-mobile-web-app-title" content="Hamm">
<meta name="apple-mobile-web-app-status-bar-style" content="light">
<meta name="MobileOptimized" content="480">
<meta name="HandheldFriendly" content="True">
<link rel="stylesheet" href="css/element.css">
<link rel="stylesheet" href="//at.alicdn.com/t/font_666204_trcuv9ja6ip.css">
<link rel="stylesheet" href="css/vue.preview.css">
<link rel="stylesheet" href="css/main.css?<?php echo time(); ?>">
<script>
var _hmt = _hmt || [];
(function () {
var hm = document.createElement("script");
hm.src = "https://hm.baidu.com/hm.js?499e3708baf422896ff8f6c2fc7cfd75";
var s = document.getElementsByTagName("script")[0];
s.parentNode.insertBefore(hm, s);
})();
</script>
<style>
#main {
position: fixed;
left: 0;
right: 0;
top: 0;
bottom: 0;
}
</style>
</head>
<body>
<div id="app" v-cloak>
<div id="main" v-loading.fullscreen.lock="loading" contextmenu.prevent="doContextMenu($event)">
<!-- 房间主面板 -->
<el-card class="box-card singe chat_room" shadow="never" v-if="room.roomInfo">
<!-- <div class="top_area">
<el-link>资料</el-link>
<el-link>设置</el-link>
</div> -->
<div slot="header" class="clearfix">
<span>
<el-tag size="mini" type="info"
style="margin: 0px 5px;color:#333;font-weight:bolder;font-size:14px;cursor:pointer;" :title="'房间积分: '+room.roomInfo.room_score+'分'" v-if="room.roomInfo.room_single==0">
ID:{{room.room_id}}
</el-tag>
<i class="iconfont room_icon icon-xiaoxi2" v-if="room.roomInfo.room_type==0"
title="文字聊天房"></i>
<i class="iconfont room_icon icon-changyongtubiao-mianxing-61" v-if="room.roomInfo.room_type==1"
title="点歌音乐房"></i>
<i class="iconfont room_icon icon-shezhi3" v-if="room.roomInfo.room_type==2"
title="猜歌游戏房"></i>
<i class="iconfont room_icon icon-book" v-if="room.roomInfo.room_type==3" title="有声故事房"></i>
<i class="iconfont room_icon icon-icon_voice" v-if="room.roomInfo.room_type==4"
title="房主电台房"></i>
<i class="iconfont room_icon icon-video" v-if="room.roomInfo.room_type==5"
title="虎牙直播房"></i>
<b class="hideWhenScreenSmall">{{room.roomInfo.room_name}}
<i class="room_icon el-icon-lock" v-if="room.roomInfo.room_public==1" title="密码房间"></i></b>
<el-link @click="doShowSettingBox"
v-if="room.roomInfo.room_user==userInfo.user_id || userInfo.user_admin">管理
</el-link>
</span>
<span style="float: right; padding: 3px 0" class="rightMenu">
<el-button-group style="text-align: right;">
<el-button size="mini" @click="doShowRankDialog" style="color:orangered"
v-html="title.rank_list" class="hideWhenScreenSmall" v-if="room.roomInfo.room_single==0"></el-button>
<el-button size="mini" @click="chat_room.dialog.showOnlineBox = true;doShowOnlineList()"
v-html="'在线 (<font color=red style=\'font-weight:bolder;\'>'+chat_room.data.onlineList.length+'</font>)'">
</el-button>
<el-button size="mini" v-clipboard:copy="copyString" v-clipboard:success="onCopySuccess" v-html="title.invate_person">
</el-button>
<el-button size="mini" @click="doGetRoomList"
v-html="title.exit_room" v-if="userInfo.user_id>0 && room.roomInfo.room_single==0"></el-button>
<el-button size="mini" @click="doShowLoginBox" style="color:orangered" v-html="title.login"
v-if="userInfo.user_id<0"></el-button>
</el-button-group>
<el-dropdown @command="handleSettingCommand">
<el-button size="mini" v-html="title.my_setting"></el-button>
<el-dropdown-menu slot="dropdown">
<el-dropdown-item command="doEditMyProfile" v-if="userInfo.user_id>0">
修改资料
</el-dropdown-item>
<!-- <el-dropdown-item v-clipboard:copy="copyString" v-clipboard:success="onCopySuccess">
邀请朋友
</el-dropdown-item> -->
<el-dropdown-item command="doShowQrcode" class="hideWhenScreenSmall" v-if="room.roomInfo.room_single==0">
穿梭手机
</el-dropdown-item>
<el-dropdown-item command="clearHistory" divided>
清理记录
</el-dropdown-item>
<el-dropdown-item command="switchNotification">{{config.notification?'关闭通知':'打开通知'}}
</el-dropdown-item>
<el-dropdown-item command="doLogout" v-if="userInfo.user_id>0">退出登录
</el-dropdown-item>
<el-dropdown-item command="contactUs" divided>
合作接入
</el-dropdown-item>
</el-dropdown-menu>
</el-dropdown>
</span>
</div>
<div class="chat_room_box">
<div class="chat_room_history" id="chat_room_history" @click="hideAllDialog"
@scroll="scrollEvent($event)">
<div v-for="(item,index) in chat_room.list">
<div v-if="item.type!='system'" @mouseover="item.active=1" @mouseout="item.active=0" v-bind:key="'msgid-'+(item.message_id||0)" :id="'msgid_'+item.message_id || 0" style="padding:10px 0px 0px 0px;">
<div :class="[item.user.user_id==userInfo.user_id?'item mine':'item']" >
<!-- <img src="images/ajx.png" style="position: absolute;left:-4px;top:-4px;width:50px;height:50px;"/> -->
<div class="head">
<el-dropdown trigger="click" @command="commandUserHead" :index="index">
<img :src="http2https(item.user.user_head)" onerror="this.src='images/nohead.jpg'"
:class="[room.roomInfo.room_type==1&&chat_room.song&&item.user.user_id==chat_room.song.user.user_id?'love':'']"
:title="[room.roomInfo.room_type==1&&chat_room.song&&item.user.user_id==chat_room.song.user.user_id?'正在播放Ta点的歌曲':'']" />
<!-- @mouseover="doGetUserInfoById(item.user.user_id)"
@mouseout="chat_room.data.hisUserInfo={};chat_room.dialog.showUserProfile=false;" -->
<el-dropdown-menu slot="dropdown">
<el-dropdown-item :command="beforeHandleUserCommand(item.user,'at')"
v-if="item.user.user_id!=userInfo.user_id">@Ta
</el-dropdown-item>
<el-dropdown-item
:command="beforeHandleUserCommand(item.user, 'profile')">资料
</el-dropdown-item>
<el-dropdown-item
:command="beforeHandleUserCommand(item.user, 'sendSong')">送歌
</el-dropdown-item>
<el-dropdown-item :command="beforeHandleUserCommand(item, 'pullback')"
v-if="(item.user.user_id==userInfo.user_id || userInfo.user_admin || userInfo.user_id==room.roomInfo.room_user)">
撤回
</el-dropdown-item>
<el-dropdown-item
:command="beforeHandleUserCommand(item.user, 'removeBan')"
v-if="userInfo.user_admin || userInfo.user_id == room.roomInfo.room_user">
解禁
</el-dropdown-item>
<el-dropdown-item
:command="beforeHandleUserCommand(item.user, 'shutdown')"
v-if="item.user.user_id !=userInfo.user_id &&(userInfo.user_id==room.roomInfo.room_user || userInfo.user_admin)">
禁言
</el-dropdown-item>
<el-dropdown-item
:command="beforeHandleUserCommand(item.user, 'songdown')"
v-if="item.user.user_id !=userInfo.user_id &&(userInfo.user_id==room.roomInfo.room_user || userInfo.user_admin)">
禁歌
</el-dropdown-item>
</el-dropdown-menu>
</el-dropdown>
</div>
<div class="body">
<div class="user">
<i class="iconfont icon-apple1 user_device" title="iOS客户端在线"
v-if="item.user.user_device=='iPhone' || item.user.user_device=='iPad' || item.user.user_device=='iPod'"></i>
<i class="iconfont icon-apple1 user_device" title="Mac在线"
v-if="item.user.user_device=='MacOS'"></i>
<i class="iconfont icon-windows-fill user_device" title="Windows在线"
v-if="item.user.user_device=='Windows'"></i>
<i class="iconfont icon-android1 user_device" title="Android在线"
v-if="item.user.user_device=='Android'"></i>
<i class="iconfont user_sex icon-xingbie-nv" title="女生"
v-if="item.user.user_sex==0"></i><i
class="iconfont user_sex icon-xingbie-nan" title="男生"
v-if="item.user.user_sex==1"></i> {{urldecode(item.user.user_name)}}
<el-tag size="mini" type="warning" class="isAdmin" title="管理员"
v-if="item.user.user_admin"></el-tag>
<el-tag size="mini" type="success" class="isAdmin" title="房主"
v-if="!item.user.user_admin&&item.user.user_id == room.roomInfo.room_user"></el-tag>
<a :href="replaceProfileLink(item.user.app_url,item.user.user_extra)"
target="_blank" v-if="item.user.app_id>1">
<el-tag size="mini" type="info" class="isAdmin" title="来自第三方应用登录">
{{item.user.app_name}}</el-tag>
</a>
<span title="国庆快乐·中国牛逼" v-if="item.user.user_icon" style="cursor:pointer;font-size:12px;background-color:#F06557;color:yellow;text-align:center;line-height:14px;padding:1px 3px;border-radius:3px;display:inline-block;"><i class="iconfont icon-icon_star_fill" style="font-size:14px;"></i></font>
</div>
<div v-if="item.sha=='loading'" class="love-fast"
style="position:absolute;right:30px;bottom:14px;color:#666;font-size:16px;font-weight:bolder">
<i class="iconfont icon-loading "></i></div>
<!-- 非@的普通消息 -->
<pre class="content" style="white-space: pre-wrap;"
v-if="item.type=='text' && item.user.user_id!=userInfo.user_id && (!item.at || item.at.user_id != userInfo.user_id)">{{urldecode(item.content)}}</pre>
<!-- @我的消息 -->
<pre class="content"
style="white-space: pre-wrap;;background-color: #666;color:white;"
v-if="item.type=='text' && item.user.user_id!=userInfo.user_id && item.at && item.at.user_id == userInfo.user_id">{{urldecode(item.content)}}</pre>
<!-- 我是girl -->
<pre class="content"
style="white-space: pre-wrap;background-color: #66CBFF;color:black;"
v-if="item.type=='text' && item.user.user_id==userInfo.user_id && item.user.user_sex==1">{{urldecode(item.content)}}</pre>
<!-- 我是boy -->
<pre class="content"
style="white-space: pre-wrap;background-color: #FE9898;color:white;"
v-if="item.type=='text' && item.user.user_id==userInfo.user_id && item.user.user_sex==0">{{urldecode(item.content)}}</pre>
<div class="content img" v-if="item.type=='img'">
<img :src="getImageUrl(urldecode(item.content))"
:large="getImageUrl(urldecode(item.resource))" :preview="item.resource"
onerror="this.src='images/error.jpg'" title="点击查看大图" />
</div>
<div class="content link" v-if="item.type=='link'"
style="padding:10px 20px;background-color:#f5f5f5;border:1px solid #eee;cursor:pointer;"
title="点击访问" @click="openWebUrl(item.link)">
<div class="title">{{item.title}}</div>
<div class="desc">
<img class="img" src="images/nohead.jpg" @error="item.img = false;"
data='' :data="item.img"
onload="this.src=this.attributes.data.value;this.onload=null"
v-if="item.img" />
<i class="img el-icon-link" style="font-size:32px;"
v-if="!item.img"></i> {{item.desc}}
</div>
<div class="url">{{item.link}}</div>
</div>
<div class="content link" v-if="item.type=='jump'"
style="padding:10px 20px;background-color:#e1f3d8;border:none;cursor:pointer;min-width:200px;"
title="点击进入房间" @click="doChangeTo(item.jump)">
<div class="title">{{item.jump.room_name}}</div>
<div class="desc" style="padding-left:0px;">
{{item.jump.room_notice}}
</div>
<div class="url">ID:
<font color=orangered>{{item.jump.room_id}}</font>
<span v-if="item.jump.room_public">加密房间</span>
<span v-if="!item.jump.room_public">公开房间</span>
</div>
</div>
</div>
<div v-if="item.time" class="time" style="cursor:pointer;" @click="doReply(item)">
<div class="quote" v-if="item.at && item.at.message" @click.stop="scrollToChat(item.at.message.message_id)">{{item.at.message.type=='text'?item.at.message.content:'[图片]'}}</div>{{friendlyTime(item.time)}}
<a style="margin-left:5px;color:orangered;pointer-events: none;" v-if="item.active">回复</a>
</div>
</div>
</div>
<div v-if="item.type=='system'" class="system"><span
:style="{backgroundColor:item.bgColor||'#eee',color:item.color||'#999'}">{{(item.content)}}</span>
</div>
</div>
<el-button class="scroll-to-bottom" size="mini" v-if="showScrollToBottomBtn" @click="scrollToBottom">回到底部</el-button>
</div>
<el-alert :title="systemTips.msg" v-if="systemTips.msg" :type="systemTips.type" effect="dark">
</el-alert>
<div class="chat_room_toolbar">
<el-button-group class="">
<el-button size="mini" title="上传图片">
<el-upload :action="[apiUrl+'attach/uploadimage']" :show-file-list="false"
:on-success="handleImageUploadSuccess" :before-upload="doUploadBefore"
:data="baseData">图片
</el-upload>
</el-button>
<el-button size="mini"
@click="hideAllDialog();chat_room.data.searchImageList = emojiList;chat_room.dialog.searchImageBox=true;"
title="点击搜索表情">
表情</el-button>
<el-button size="mini"
v-if="room.roomInfo.room_type==1 && !(room.roomInfo.room_addsong==1 && room.roomInfo.room_user!=userInfo.user_id && !userInfo.user_admin)"
@click="hideAllDialog();chat_room.dialog.searchSongBox=!chat_room.dialog.searchSongBox;doSearchSong()"
title="点击打开歌曲搜索">
点歌</el-button>
<el-button size="mini"
v-if="room.roomInfo.room_type==4 && room.roomInfo.room_user==userInfo.user_id "
@click="hideAllDialog();chat_room.dialog.searchSongBox=!chat_room.dialog.searchSongBox;doSearchSong()"
title="点击打开歌曲搜索">
搜索</el-button>
<el-button size="mini"
v-if="room.roomInfo.room_type==4 && room.roomInfo.room_user!=userInfo.user_id && room.roomInfo.room_addsong==0"
@click="hideAllDialog();chat_room.dialog.searchSongBox=!chat_room.dialog.searchSongBox;doSearchSong()"
title="点击打开歌曲搜索">
点歌</el-button>
<el-button size="mini" @click="doShowSongList" v-if="room.roomInfo.room_type==1"
title="当前已点的歌单列表">已点
</el-button>
<el-button size="mini" @click="doShowSongList" v-if="room.roomInfo.room_type==4 && room.roomInfo.room_addsong==0"
title="当前已点的歌单列表">已点
</el-button>
<el-button size="mini" @click="doShowMySongList('count')" v-if="room.roomInfo.room_type==1"
title="我点过的歌">
我的
</el-button>
<el-button size="mini" @click="doShowMySongList('count')" v-if="room.roomInfo.room_type==4 && (room.roomInfo.room_user!=userInfo.user_id) && room.roomInfo.room_addsong==0"
title="我点过的歌">
我的
</el-button>
<el-button size="mini" @click="doShowMySongList('recent')"
v-if="room.roomInfo.room_type==4 && room.roomInfo.room_user==userInfo.user_id"
title="我的歌单">
歌单
</el-button>
<el-button size="mini" @click="doGameMusicPass"
v-if="room.roomInfo.room_type==2 && (room.roomInfo.room_user == userInfo.user_id || userInfo.user_admin)">
PASS
</el-button>
<el-button size="mini" @click="doShowVoiceSearchBox"
v-if="room.roomInfo.room_type==3 && (room.roomInfo.room_user == userInfo.user_id || userInfo.user_admin)">
声音库
</el-button>
</el-button-group>
<div v-if="((room.roomInfo.room_type==1||room.roomInfo.room_type==2||room.roomInfo.room_type==4) && chat_room.song) || (room.roomInfo.room_type==3 && chat_room.voice)"
class="player_body" id="player_body" ref="player_body" title="综合考虑,我还是安安静静待在这里吧">
<img class="player_bg" :src="chat_room.song.song.pic"
v-if="room.roomInfo.room_type==1||room.roomInfo.room_type==2||room.roomInfo.room_type==4" />
<img class="player_bg" :src="chat_room.voice.pic" v-if="room.roomInfo.room_type==3" />
<div class="player_img" v-if="room.roomInfo.room_type==1"><img
:title="(room.roomInfo.room_user==userInfo.user_id || userInfo.user_admin || chat_room.song.user.user_id == userInfo.user_id)?'切歌':'不喜欢'"
@mouseover.stop="player.nextButton=true" @mouseout.stop="player.nextButton=false"
:src="urldecode(chat_room.song.song.pic)"
onerror="this.src='images/nohead.jpg';this.onerror=null;" width="100%" height="100%"
:class="player_body.isMoving?'':'love'"
@click="(room.roomInfo.room_user==userInfo.user_id || userInfo.user_admin || chat_room.song.user.user_id == userInfo.user_id)?doPassTheSong():doDontLikeTheSong()" />
<i style="pointer-events: none;text-shadow:0px 0px 3px rgba(0,0,0,0.9)"
class="iconfont icon-guanbi1" v-if="player.nextButton"></i>
</div>
<div class="player_img" v-if="room.roomInfo.room_type==2"><img
:src="chat_room.song.song.pic" width="100%" height="100%"
:class="player_body.isMoving?'':'love'" />
</div>
<div class="player_img" v-if="room.roomInfo.room_type==3"><img :src="chat_room.voice.pic"
width="100%" height="100%" :class="player_body.isMoving?'':'love'" />
</div>
<div class="player_img"
v-if="room.roomInfo.room_type==4 && (room.roomInfo.room_user==userInfo.user_id || userInfo.user_admin)">
<img title="切歌" @mouseover.stop="player.nextButton=true"
@mouseout.stop="player.nextButton=false" :src="urldecode(chat_room.song.song.pic)"
onerror="this.src='images/nohead.jpg';this.onerror=null;" width="100%" height="100%"
:class="player_body.isMoving?'':'love'" @click="doPassTheSong()" />
<i style="pointer-events: none;text-shadow:0px 0px 3px rgba(0,0,0,0.9)"
class="iconfont icon-guanbi1" v-if="player.nextButton"></i>
</div>
<div class="player_img"
v-if="room.roomInfo.room_type==4 && !(room.roomInfo.room_user==userInfo.user_id || userInfo.user_admin)">
<img @mouseover.stop="player.nextButton=true" @mouseout.stop="player.nextButton=false"
:src="urldecode(chat_room.song.song.pic)"
onerror="this.src='images/nohead.jpg';this.onerror=null;" width="100%" height="100%"
:class="player_body.isMoving?'':'love'" />
</div>
<div class="player_title">
<marquee scrollamount="1"
v-if="room.roomInfo.room_type==1 || room.roomInfo.room_type==2 || room.roomInfo.room_type==4">
{{chat_room.song.song.name}}
- {{chat_room.song.song.singer}}
</marquee>
<marquee scrollamount="1" v-if="room.roomInfo.room_type==3">
《{{chat_room.voice.name}}》({{chat_room.voice.part}})
</marquee>
<i class=" iconfont" @click="doSwitchMusic" @mouseover="doShowVoiceBar" title="音乐开关"
style='font-weight:normal' :style="volume==0?'color:#999':'color:#fff'"
:class="volume==0?'icon-changyongtubiao-xianxingdaochu-zhuanqu-40':'icon-changyongtubiao-xianxingdaochu-zhuanqu-39'"></i>
</div>
<div class="player_name" @click="chat_room.at=chat_room.song.user" title="点击@点歌人"
v-if="room.roomInfo.room_type==1">
<span v-if="!chat_room.song.at">点歌人 {{urldecode(chat_room.song.user.user_name)}}</span>
<span v-if="chat_room.song.at">{{urldecode(chat_room.song.user.user_name)}} 送给
{{urldecode(chat_room.song.at.user_name)}}</span>
</div>
<div class="player_name" @click="chat_room.at=chat_room.song.user" title="点击@点歌人"
v-if="room.roomInfo.room_type==4">
<span>{{urldecode(chat_room.song.user.user_name)}}的音乐播放器</span>
</div>
<div class="player_name" v-if="room.roomInfo.room_type==2">
请在聊天框发送歌名参与游戏
</div>
<div class="player_name" v-if="room.roomInfo.room_type==3">
当前房间为一起听书听故事房间
</div>
<div style="margin-left:60px;">
<el-progress :percentage="chat_room.songPercent" :format="formatProgress"
color="rgba(255,255,255,0.6)">
</el-progress>
</div>
</div>
<el-slider v-model="volume" @change="doVolumeChanged" vertical height="70px" step="5"
class="volume" v-if="player.voiceBar">
</el-slider>
</div>
<div class="chat_room_input">
<textarea @click="hideAllDialog" v-model="chat_room.message" @keydown.13="doEnterDown"
@keydown.8="doDelete" class="chat_room_message" :placeholder="ChatPlaceHolder"
:disabled="room.roomInfo.room_sendmsg==1 && room.roomInfo.room_user!=userInfo.user_id && !userInfo.user_admin?true:false"></textarea>
<el-dropdown class="chat_room_send" split-button size="small" @click="doSendMessage"
@command="handleSendButtonCommand">
{{ctrlEnabled?'发送(Ctrl+Enter)':'发送(Enter)'}}
<el-dropdown-menu slot="dropdown">
<el-dropdown-item command="enter">按Enter发送</el-dropdown-item>
<el-dropdown-item command="ctrl_enter">按Ctrl+Enter发送</el-dropdown-item>
</el-dropdown-menu>
</el-dropdown>
<el-tag class="at_box" size="small" closable @close="chat_room.at=null" type="danger"
v-if="chat_room.at" :style="{marginBottom:lrcString?'20px':'0'}">
@{{urldecode(chat_room.at.user_name)}}</el-tag>
<div class="lrcbox" v-if="lrcString">{{lrcString}}</div>
</div>
<div v-if="room.roomInfo && room.roomInfo.room_type==5" :class="chat_room.isVideoFullScreen?'video_player video_player_full':'video_player'">
<iframe :src="'https://hy.hamm.cn/iframe/'+getHuyaId(room.roomInfo.room_huya)" height="261px" width="400px" frameborder="0"></iframe>
<span @click="chat_room.isVideoFullScreen=!chat_room.isVideoFullScreen;">全屏</span>
</div>
<div v-if="room.roomInfo && room.roomInfo.room_pet" style="position:fixed;left:10px;top:80px;z-index:0;">
<img :src="'images/dog/'+room.roomInfo.room_pet+'.png'" style="max-width:200px;" :title="room.roomInfo.room_name+'的宠物挂件'"/>
</div>
</div>
<el-dialog title="修改资料" :visible.sync="chat_room.dialog.editMyProfile" :modal-append-to-body='false'>
<el-form status-icon>
<div style="text-align: center;margin-bottom: 20px;">
<el-upload :action="[apiUrl+'attach/uploadHead']" :show-file-list="false"
:on-success="handleProfileHeadUploadSuccess" :before-upload="doUploadBefore"
:data="baseData">
<img :src="chat_room.form.editMyProfile.user_head"
onerror="this.src='images/nohead.jpg'"
style="border-radius: 100%;width:80px;height:80px;" />
</el-upload>
<div>ID:
<font color=orangered style="margin-left:5px;font-weight: bolder;">
{{userInfo.user_id}}</font>
</div>
</div>
<el-form-item label="昵称" label-width="40px">
<el-input size="medium" autocomplete="off" placeholder="请输入你的昵称"
v-model="chat_room.form.editMyProfile.user_name"></el-input>
</el-form-item>
<el-form-item label="性别">
<el-select size="medium" v-model="chat_room.form.editMyProfile.user_sex"
placeholder="请选择你的性别" class="allLine" style="margin-left:40px;">
<el-option v-for="(item,index) in sexList" :label="item.title" :value="item.value">
</el-option>
</el-select>
</el-form-item>
<el-form-item label="签名" label-width="40px">
<el-input size="medium" autocomplete="off" placeholder="请输入你的签名"
v-model="chat_room.form.editMyProfile.user_remark"></el-input>
</el-form-item>
<el-form-item label="密码" label-width="40px">
<el-input size="medium" autocomplete="off" placeholder="你的密码,不修改请留空"
v-model="chat_room.form.editMyProfile.user_password"></el-input>
</el-form-item>
</el-form>
<span slot="footer" class="dialog-footer">
<el-button type="primary" @click="doSaveMyProfile">保存</el-button>
</span>
</el-dialog>
<el-dialog title="房间设置" :visible.sync="chat_room.dialog.editMyRoom" :modal-append-to-body='false' top="50px">
<el-form status-icon >
<el-form-item label="房间名称" label-width="70px">
<el-input size="small" autocomplete="off" placeholder=""
v-model="chat_room.form.editMyRoom.room_name"></el-input>
</el-form-item>
<el-form-item label="房间公告" label-width="70px">
<el-input size="small" autocomplete="off" placeholder=""
v-model="chat_room.form.editMyRoom.room_notice"></el-input>
</el-form-item>
<el-form-item label="二级域名" label-width="70px">
<el-input size="small" autocomplete="off" placeholder="填写二级域名前缀"
v-model="chat_room.form.editMyRoom.room_domain" v-if="chat_room.form.editMyRoom.room_domain_edit || !chat_room.form.editMyRoom.room_domain" >
<el-button slot="prepend">
https://
</el-button>
<el-button slot="append">
.bbbug.com
</el-button>
</el-input>
<div v-if="!chat_room.form.editMyRoom.room_domain_edit && chat_room.form.editMyRoom.room_domain"><a target="_blank" style="text-decoration:none;color:#666;" :href="'https://'+chat_room.form.editMyRoom.room_domain+'.bbbug.com'">https://{{chat_room.form.editMyRoom.room_domain}}.bbbug.com</a> <a style="text-decoration:none;color:orangered;cursor:pointer;" @click="chat_room.form.editMyRoom.room_domain_edit=true">修改</a></div>
</el-form-item>
<el-form-item label="房间权限">
<el-select size="small" v-model="chat_room.form.editMyRoom.room_public"
placeholder="请选择房间权限类别" class="allLine" style="margin-left:70px;">
<el-option v-for="(item,index) in chat_room.data.room_public" :label="item.title"
:value="item.value"></el-option>
</el-select>
</el-form-item>
<el-form-item label="房间密码" label-width="70px" v-if="chat_room.form.editMyRoom.room_public==1">
<el-input size="small" autocomplete="off" placeholder=""
v-model="chat_room.form.editMyRoom.room_password"></el-input>
</el-form-item>
<el-form-item label="全员禁言">
<el-select size="small" v-model="chat_room.form.editMyRoom.room_sendmsg"
placeholder="请选择是否全员禁言" class="allLine" style="margin-left:70px;">
<el-option v-for="(item,index) in chat_room.data.room_sendmsg" :label="item.title"
:value="item.value"></el-option>
</el-select>
</el-form-item>
<el-form-item label="房间类型">
<el-select size="small" v-model="chat_room.form.editMyRoom.room_type" placeholder="请选择房间类型"
class="allLine" style="margin-left:70px;">
<el-option v-for="(item,index) in room_create.typeList" :label="item.title"
:value="item.value"></el-option>
</el-select>
</el-form-item>
<el-form-item label="机器点歌" v-if="chat_room.form.editMyRoom.room_type==1">
<el-select size="small" v-model="chat_room.form.editMyRoom.room_robot"
placeholder="请选择机器人是否点歌" class="allLine" style="margin-left:70px;">
<el-option v-for="(item,index) in chat_room.data.room_robot" :label="item.title"
:value="item.value"></el-option>
</el-select>
</el-form-item>
<el-form-item label="开启点歌" v-if="chat_room.form.editMyRoom.room_type==1 || chat_room.form.editMyRoom.room_type==4">
<el-select size="small" v-model="chat_room.form.editMyRoom.room_addsong"
placeholder="请选择是否开启点歌" class="allLine" style="margin-left:70px;">
<el-option v-for="(item,index) in chat_room.data.room_addsong" :label="item.title"
:value="item.value"></el-option>
</el-select>
</el-form-item>
<el-form-item label="循环方式" v-if="chat_room.form.editMyRoom.room_type==4">
<el-select size="small" v-model="chat_room.form.editMyRoom.room_playone"
placeholder="请选择歌曲播放循环方式" class="allLine" style="margin-left:70px;">
<el-option v-for="(item,index) in chat_room.data.room_playone" :label="item.title"
:value="item.value"></el-option>
</el-select>
</el-form-item>
<el-form-item label="虎牙地址" label-width="70px" v-if="chat_room.form.editMyRoom.room_type==5">
<el-input size="small" autocomplete="off" placeholder=""
v-model="chat_room.form.editMyRoom.room_huya"></el-input>
</el-form-item>
</el-form>
<span slot="footer" class="dialog-footer">
<el-button type="primary" @click="doSaveRoomInfo">保存设置</el-button>
</span>
</el-dialog>
<el-dialog :visible.sync="chat_room.dialog.showUserProfile" :modal="false"
custom-class="showUserProfile">
<div
style="position: relative;box-shadow:0px 0px 20px rgba(0,0,0,0.5);border-radius:10px;background-color: white;height:150px;">
<img :src="getImageUrl(chat_room.data.hisUserInfo.user_head)"
onerror="this.src='images/nohead.jpg'"
style="border-radius: 100%;width:80px;height:80px;position: absolute;left:10px;top:10px;" />
<div style="position: absolute;left:100px;top:20px;">
<div style="font-size:18px;font-weight: bold;color:#333;">
<font color=orangered style="font-weight: bolder;">
{{chat_room.data.hisUserInfo.user_id}}</font>
<i class="iconfont user_sex icon-xingbie-nv" title="女生"
v-if="chat_room.data.hisUserInfo.user_sex==0"
style="font-size: 16px; font-weight: normal;"></i><i
class="iconfont user_sex icon-xingbie-nan" title="男生"
v-if="chat_room.data.hisUserInfo.user_sex==1"
style="font-size: 16px; font-weight: normal;"></i>
{{urldecode(chat_room.data.hisUserInfo.user_name)}}
<el-tag size="mini" type="warning" class="isAdmin" title="管理员"
v-if="chat_room.data.hisUserInfo.user_admin"></el-tag>
<el-tag size="mini" type="success" class="isAdmin" title="房主"
v-if="!chat_room.data.hisUserInfo.user_admin&&chat_room.data.hisUserInfo.user_id == room.roomInfo.room_user"></el-tag>
<a :href="replaceProfileLink(chat_room.data.hisUserInfo.app_url,chat_room.data.hisUserInfo.user_extra)"
target="_blank" v-if="chat_room.data.hisUserInfo.app_id>1">
<el-tag size="mini" type="info" class="isAdmin" title="来自第三方应用登录">
{{chat_room.data.hisUserInfo.app_name}}</el-tag>
</a>
</div>
<div style="font-size:14px;color:#999;margin-top:5px;">
{{chat_room.data.hisUserInfo.user_remark}}</div>
</div>
<div
style="font-size:12px;color:#999;margin-top:10px;position: absolute;left:10px;right:10px;bottom:10px;">
点歌
<font color=orangered style="font-weight: bolder;font-size:14px;">
{{chat_room.data.hisUserInfo.user_song}}</font>首 发言
<font color=orangered style="font-weight: bolder;font-size:14px;">
{{chat_room.data.hisUserInfo.user_chat}}</font>条 斗图
<font color=orangered style="font-weight: bolder;font-size:14px;">
{{chat_room.data.hisUserInfo.user_img}}</font>张 猜歌
<font color=orangered style="font-weight: bolder;font-size:14px;">
{{chat_room.data.hisUserInfo.user_gamesongscore}}</font>
<br> 无敌顶歌
<font color=orangered style="font-weight: bolder;font-size:14px;">
{{chat_room.data.hisUserInfo.push_count}}</font>次 霸王切歌
<font color=orangered style="font-weight: bolder;font-size:14px;">
{{chat_room.data.hisUserInfo.pass_count}}</font>
</div>
</div>
</el-dialog>
<el-popover placement="top-start" popper-class="searchImageBox" trigger="manual"
v-model="chat_room.dialog.searchImageBox">
<el-input v-model="chat_room.form.searchImageBox.keyword" placeholder="输入关键词搜索表情包" clearable
@keydown.13.native="doSearchImage">
<el-button slot="append" icon="el-icon-search" @click="doSearchImage" title="点击搜索">
</el-button>
</el-input>
<div class="list" v-loading="chat_room.loading.searchImageBox">
<img v-for="(item,index) in chat_room.data.searchImageList" v-key="item" :src="item"
title="发送这个表情" @click="doSendImage(item)" />
</div>
</el-popover>
<el-popover placement="top-start" popper-class="searchSongBox" trigger="manual"
v-model="chat_room.dialog.searchSongBox">
<el-input v-model="chat_room.form.searchSongBox.keyword" placeholder="输入歌名/歌手搜索歌曲" clearable
@keydown.13.native="doSearchSong">
<el-button slot="append" icon="el-icon-search" @click="doSearchSong" title="点击搜索">
</el-button>
</el-input>
<div class="list" v-loading="chat_room.loading.searchSongBox"
style="display:inline-block;max-height:300px;overflow-y:auto;" ref="searchSongBox">
<el-table :data="chat_room.data.searchSongList" stripe>
<el-table-column>
<template slot-scope="scope">
<span style="float:right;">
<el-button v-if="room.roomInfo.room_type==1" type="warning" circle size="small"
@click="doAddSong(scope.row)">
</el-button>
<el-button v-if="room.roomInfo.room_type==4 && (room.roomInfo.room_user==userInfo.user_id || userInfo.user_admin)" type="warning" circle size="small"
@click="doPlaySong(scope.row)">
</el-button>
<el-button v-if="room.roomInfo.room_type==4 && (room.roomInfo.room_user!=userInfo.user_id && !userInfo.user_admin)" type="warning" circle size="small"
@click="doAddSong(scope.row)">
</el-button>
</span>
<font color="#333">{{scope.row.name}}</font><br>
<font color="#999" style="font-size:12px;">歌手:{{scope.row.singer}}
</font>
</template>
</el-table-column>
</el-table>
</div>
<el-alert effect="dark" v-if="chat_room.songSendUser"
:title="'你正在为 '+urldecode(chat_room.songSendUser.user_name)+' 送歌'" type="info" close-text="取消"
style="padding-left: 3px;" @close="chat_room.songSendUser=false">
</el-alert>
</el-popover>
<el-popover placement="top-start" popper-class="searchSongBox" trigger="manual"
v-model="chat_room.dialog.searchVoiceBox">
<el-input v-model="chat_room.form.searchVoiceBox.keyword" placeholder="输入关键词搜索,如郭德纲相声集"
@keydown.13.native="chat_room.data.voiceBoxPage=1;doSearchVoice()">
<el-button slot="append" icon="el-icon-search"
@click="chat_room.data.voiceBoxPage=1;doSearchVoice()" title="点击搜索">
</el-button>
</el-input>
<div class="list" v-loading="chat_room.loading.searchVoiceBox" style="display:inline-block;max-height:300px;overflow-y:auto;" @scroll="doSearchVoiceBoxScroll($event)" ref="searchVoiceBox">
<el-table :data="chat_room.data.searchVoiceList" stripe
ref="searchVoiceBox"
id="searchVoiceBox">
<el-table-column>
<template slot-scope="scope">
<img :src="scope.row.pic"
style="width:40px;height:40px;position:absolute;left:10px;top:15px;" />
<el-button type="warning" circle size="small" @click="doPlayVoice(scope.row)"
style="float:right;">
</el-button>
<div style="margin-left:50px">
<font color="#333">{{scope.row.name}}</font><br>
<font color="#999" style="font-size:12px;">专辑:{{scope.row.part}}
</font>
</div>
</template>
</el-table-column>
</el-table>
</div>
</el-popover>
<el-popover placement="top-start" popper-class="searchSongBox" trigger="manual"
v-model="chat_room.dialog.mySongBox" :title="room.roomInfo.room_type==4?'你的私人歌单':'你最爱点的歌'">
<span style="position:absolute;right:20px;top:10px;">
<el-link
@click="chat_room.data.mySongListPage=1;doGetMySongList(room.roomInfo.room_type==4?'recent':'count');">
刷新</el-link>
</span>
<div class="list" v-loading="chat_room.loading.mySongBox"
style="display:inline-block;max-height:300px;overflow-y:auto;" ref="mySongBox" @scroll="doMySongBoxScroll">
<el-table :data="chat_room.data.mySongList" stripe>
<el-table-column>
<template slot-scope="scope">
<span style="float:right;">
<el-button type="danger" circle size="small" @click="doDeleteMySong(scope.row)">
</el-button>
<el-button type="warning" circle size="small" @click="doAddSong(scope.row)"
v-if="room.roomInfo.room_type==1">
</el-button>
<el-button type="warning" circle size="small" @click="doPlaySong(scope.row)"
v-if="room.roomInfo.room_type==4 && room.roomInfo.room_user==userInfo.user_id">
</el-button>
<el-button type="warning" circle size="small" @click="doAddSong(scope.row)"
v-if="room.roomInfo.room_type==4 && room.roomInfo.room_user!=userInfo.user_id">
</el-button>
</span>
<font color="#333">{{scope.row.name}}</font><br>
<font color="#999" style="font-size:12px;">歌手:{{scope.row.singer}}
播过:{{scope.row.played}}次
</font>
</template>
</el-table-column>
</el-table>
</div>
</el-popover>
<el-popover placement="top-start" popper-class="pickedSongBox"
:title="(room.roomInfo.room_type==1?'接下来要播放的歌曲 (':'等待房主播放的歌曲 (')+chat_room.data.pickedSongList.length+')'" trigger="manual"
v-model="chat_room.dialog.pickedSongBox">
<div class="list" v-loading="chat_room.loading.pickedSongBox">
<el-table :data="chat_room.data.pickedSongList" stripe style="display:inline-block;"
ref="pickedSongBox">
<el-table-column>
<template slot-scope="scope">
<span style="float:right;">
<el-button circle size="small" @click="doDeleteSong(scope.row)"
v-if="userInfo.user_id==room.roomInfo.room_user || userInfo.user_admin || scope.row.user.user_id == userInfo.user_id || (scope.row.at&&scope.row.at.user_id == userInfo.user_id)">
</el-button>
<el-button :type="scope.row.user.user_id==userInfo.user_id?'warning':'success'"
circle size="small" @click="doPushSongTop(scope.row)" v-if="room.roomInfo.room_type==1">
</el-button>
<el-button :type="scope.row.user.user_id==userInfo.user_id?'warning':'success'"
circle size="small" @click="doPushSongTop(scope.row)" v-if="room.roomInfo.room_type==4 && userInfo.user_id!=room.roomInfo.room_user && !userInfo.user_admin">
</el-button>
<el-button :type="scope.row.user.user_id==userInfo.user_id?'warning':'success'"
circle size="small" @click="doPlaySong(scope.row.song)" v-if="room.roomInfo.room_type==4 && (userInfo.user_id==room.roomInfo.room_user || userInfo.user_admin)">
</el-button>
</span>
<font style="font-size:16px;font-weight:bolder;"
:color="scope.row.user.user_id==userInfo.user_id||scope.row.at&&scope.row.at.user_id==userInfo.user_id?'orangered':'#333'">
No.{{scope.$index+1}}</font>
<font
:color="scope.row.user.user_id==userInfo.user_id||scope.row.at&&scope.row.at.user_id==userInfo.user_id?'orangered':'#333'">
{{scope.row.song.name}}</font><br>
 <font color="#999" style="font-size:12px;">
<span v-if="!scope.row.at">点歌人:{{urldecode(scope.row.user.user_name)}}</span>
<span v-if="scope.row.at">{{urldecode(scope.row.user.user_name)}} 送给
{{urldecode(scope.row.at.user_name)}} 的歌</span>
</font>
</template>
</el-table-column>
</el-table>
</div>
</el-popover>
<el-drawer title="在线面板" direction="rtl" ref="online_box" :visible.sync="chat_room.dialog.showOnlineBox"
:modal-append-to-body='false' :with-header="false" size="300px">
<div
style="overflow:hidden;overflow-y:scroll;position: absolute;top:0;bottom:0;width:300px;padding:20px;">
<div v-for="(item,index) in chat_room.data.onlineList" v-key="item" class="online_user">
<el-dropdown trigger="click" @command="commandUserHead" :index="index">
<el-image style="width: 40px; height: 40px" :src="http2https(item.user_head)"
onerror="this.src='images/nohead.jpg'"
:title="[room.roomInfo.room_type==1&&chat_room.song&&item.user_id==chat_room.song.user.user_id?'正在播放Ta点的歌曲':'']"
:class="[room.roomInfo.room_type==1&&chat_room.song&&item.user_id==chat_room.song.user.user_id?'headimg love':'headimg']">
</el-image>
<el-dropdown-menu slot="dropdown">
<el-dropdown-item :command="beforeHandleUserCommand(item,'at')">@Ta
</el-dropdown-item>
<el-dropdown-item :command="beforeHandleUserCommand(item, 'profile')">资料
</el-dropdown-item>
<el-dropdown-item :command="beforeHandleUserCommand(item, 'sendSong')">送歌
</el-dropdown-item>
<el-dropdown-item :command="beforeHandleUserCommand(item, 'removeBan')"
v-if="userInfo.user_admin || userInfo.user_id == room.roomInfo.room_user">解禁
</el-dropdown-item>
<el-dropdown-item :command="beforeHandleUserCommand(item, 'shutdown')"
v-if="userInfo.user_admin || userInfo.user_id == room.roomInfo.room_user">
禁言
</el-dropdown-item>
<el-dropdown-item :command="beforeHandleUserCommand(item, 'songdown')"
v-if="userInfo.user_admin || userInfo.user_id == room.roomInfo.room_user">
禁歌
</el-dropdown-item>
</el-dropdown-menu>
</el-dropdown>
<span style="display:inline-block;width:200px;">
<i class="iconfont icon-apple1 user_device" title="iOS客户端在线"
v-if="item.user_device=='iPhone' || item.user_device=='iPad' || item.user_device=='iPod'"></i>
<i class="iconfont icon-apple1 user_device" title="Mac在线"
v-if="item.user_device=='MacOS'"></i>
<i class="iconfont icon-windows-fill user_device" title="Windows在线"
v-if="item.user_device=='Windows'"></i>
<i class="iconfont icon-android1 user_device" title="Android在线"
v-if="item.user_device=='Android'"></i>
<i class="iconfont user_sex icon-xingbie-nv" title="女生" v-if="item.user_sex==0"></i><i
class="iconfont user_sex icon-xingbie-nan" title="男生" v-if="item.user_sex==1"></i>
<el-tag size="mini" type="info" class="from" v-if="item.user_shutdown">禁言</el-tag>
<el-tag size="mini" type="info" class="from" v-if="item.user_songdown">禁歌</el-tag>
{{urldecode(item.user_name)}}
<el-tag size="mini" type="warning" class="from" v-if="item.user_admin" title="管理员">
</el-tag>
<el-tag size="mini" type="success" class="from"
v-if="!item.user_admin&&item.user_id==room.roomInfo.room_user" title="房主"></el-tag>
<a :href="replaceProfileLink(item.app_url,item.user_extra)" target="_blank"
v-if="item.app_id>1">
<el-tag size="mini" type="info" class="isAdmin" title="来自第三方应用登录">
{{item.app_name}}</el-tag>
</a>
<br>
<span
style="font-size:12px;color:#999;text-overflow: ellipsis;width:210px;overflow:hidden;display:inline-block;">{{item.user_remark}}</span>
</span>
</div>
</div>
</el-drawer>
<!-- 房间列表开始 -->
<el-drawer title="房间面板" direction="rtl" ref="online_box" :visible.sync="room.showDialog"
:modal-append-to-body='false' :with-header="false" size="320px" box-card singe
custom-class="room_list">
<div class="room_header">
<span class="room_title">热门房间推荐</span>
<span style="float: right; padding: 3px 0">
<el-button-group>
<el-button size="mini" type="success" v-if="userInfo.user_id>0 && !userInfo.myRoom"
@click="doCreateRoom" v-html="title.create_room">
</el-button>
<el-button size="mini" type="success" v-if="userInfo.myRoom" @click="doEnterMyRoom"
v-html="title.my_room">
</el-button>
<!-- <el-button size="mini" type="danger" @click="do_logout" v-html="title.change_account">
</el-button> -->
</el-button-group>
</span>
<el-input style="margin-top:10px;" placeholder="输入房间ID" size="small" v-model="room.search_id"
class="input-with-select">
<el-button slot="append" icon="el-icon-search" @click="doSearchRoomById">进入</el-button>
</el-input>
</div>
<div class="room_body">
<div class="room_item" title="进入房间" v-for="(row,index) in room.list"
@click="doJoinRoomById(row.room_id)">
<!-- <i class="room_icon el-icon-medal"></i>
<i class="room_icon el-icon-map-location"></i> -->
<div class="room_name">
<i class="iconfont room_icon icon-xiaoxi2" v-if="row.room_type==0" title="文字聊天房"></i>
<i class="iconfont room_icon icon-changyongtubiao-mianxing-61" v-if="row.room_type==1"
title="点歌音乐房"></i>
<i class="iconfont room_icon icon-shezhi3" v-if="row.room_type==2" title="猜歌游戏房"></i>
<i class="iconfont room_icon icon-book" v-if="row.room_type==3" title="有声故事房"></i>
<i class="iconfont room_icon icon-icon_voice" v-if="row.room_type==4"
title="房主电台房"></i>
<i class="iconfont room_icon icon-video" v-if="row.room_type==5"
title="虎牙直播房"></i>
{{ row.room_name }}
</div>
<div class="room_id"><i class="room_icon el-icon-lock" v-if="row.room_public==1"
title="密码房间"></i><span>ID:{{row.room_id}}</span></div>
<img class="room_img" :src="http2https(row.user_head)" onerror="this.src='images/nohead.jpg'" />
<div class="room_master">
<div class="room_info">
<div class="room_user">
{{urldecode(row.user_name)}}
<!-- <el-tag size="mini" type="warning" class="isAdmin" title="管理员"
v-if="row.user_admin">管
</el-tag> -->
<font color=orangered style="font-weight: bolder;" v-if="row.room_online>0">
({{row.room_online}})</font>
</div>
<div class="room_notice">{{row.room_notice||"房间未填写公告"}}</div>
</div>
</div>
</div>
</div>
</el-drawer>
<!-- 房间列表结束 -->
<el-dialog title="周榜" :visible.sync="chat_room.dialog.showRankList" :modal-append-to-body='false' width="70%" show-close="false">
<div style="margin-top: 20px;position: absolute;right: 20px;top: 0px;background-color:white;">
<div v-if="chat_room.data.rankType=='人气'">* 听说长得好看的才会收到很多人送的歌</div>
<div v-if="chat_room.data.rankType=='点歌'">* 不知道歌好不好听,反正点的倒是挺多的...</div>
<div v-if="chat_room.data.rankType=='天狗'">* 不知道怎么想的,看着好看的就想给Ta送首歌...</div>
<div v-if="chat_room.data.rankType=='发言'">* 说这么多话的是大水逼无疑了...</div>
<div v-if="chat_room.data.rankType=='斗图'">* 听说表情包越多的人,心里越寂寞?</div>
<div v-if="chat_room.data.rankType=='切歌'">* 点的歌是有多难听,大家都不喜欢?</div>
<div v-if="chat_room.data.rankType=='顶歌'">* 我要听的,现在就要。</div>
</div>
<div style="overflow-x:hidden;overflow-y: auto;max-height:300px;" v-loading="chat_room.loading.showRankList" ref="showRankList">
<div v-for="(item,index) in chat_room.data.showRankList" v-key="item" class="rank_user">
<div class="rankNum" v-if="index==0 && chat_room.data.rankType=='人气'" style="color:orangered;font-size:14px;">人气王</span></div>
<div class="rankNum" v-if="index==0 && chat_room.data.rankType=='点歌'" style="color:orangered;font-size:14px;">情歌王</span></div>
<div class="rankNum" v-if="index==0 && chat_room.data.rankType=='天狗'" style="color:orangered;font-size:14px;">老天狗</span></div>
<div class="rankNum" v-if="index==0 && chat_room.data.rankType=='发言'" style="color:orangered;font-size:14px;">大水逼</span></div>
<div class="rankNum" v-if="index==0 && chat_room.data.rankType=='斗图'" style="color:orangered;font-size:14px;">风骚王</span></div>
<div class="rankNum" v-if="index==0 && chat_room.data.rankType=='切歌'" style="color:orangered;font-size:14px;">山歌王</span></div>
<div class="rankNum" v-if="index==0 && chat_room.data.rankType=='顶歌'" style="color:orangered;font-size:14px;">千斤顶</span></div>
<div class="rankNum" v-if="index<5 && index>0" style="color:orangered;">No.<span>{{index+1}}</span></div>
<div class="rankNum" v-if="index>=5 && index<9" style="color:#333;">No.<span>{{index+1}}</span></div>
<div class="rankNum" v-if="index>=9" style="color:#999;font-size:14px;">No.<span>{{index+1}}</span></div>
<el-image style="width: 40px; height: 40px;position:absolute;left:50px;top:0;" :src="getImageUrl(item.user_head)||'images/nohead.jpg'" @click="doGetUserInfoById(item.user_id)"
class='headimg'>
</el-image>
<div style="margin-left:100px;">
<div class="user_name">{{urldecode(item.user_name)}}</div>
<div class="user_remark">{{urldecode(item.user_remark)}}</div>
</div>
<span class="number" v-if="chat_room.data.rankType=='人气'">收到{{item.user_songrecv}}首</span>
<span class="number" v-if="chat_room.data.rankType=='点歌'">点歌{{item.user_song}}首</span>
<span class="number" v-if="chat_room.data.rankType=='天狗'">送出{{item.user_songsend}}首</span>
<span class="number" v-if="chat_room.data.rankType=='发言'">说{{item.user_chat}}句</span>
<span class="number" v-if="chat_room.data.rankType=='斗图'">发{{item.user_img}}张</span>
<span class="number" v-if="chat_room.data.rankType=='切歌'">被切{{item.user_pass}}首</span>
<span class="number" v-if="chat_room.data.rankType=='顶歌'">顶了{{item.user_push}}首</span>
</div>
</div>
<el-radio-group v-model="chat_room.data.rankType" size="mini" @change="doGetRankList" class="giftTips">
<el-radio-button label="人气"></el-radio-button>
<el-radio-button label="点歌"></el-radio-button>
<el-radio-button label="天狗"></el-radio-button>
<el-radio-button label="发言"></el-radio-button>
<el-radio-button label="斗图"></el-radio-button>
<el-radio-button label="切歌"></el-radio-button>
<el-radio-button label="顶歌"></el-radio-button>
</el-radio-group>
</el-dialog>
<!-- 创建房间开始 -->
<el-dialog :visible.sync="room_create.showPage" :modal-append-to-body='false' title="创建一个你的私人房间">
<el-form :model="room_create.form" ref="room_create_form" label-width="60px">
<el-form-item prop="room_name" label="名称" :rules="[
{ required: true, message: '不给你的房间起个牛逼的名字吗???', trigger: 'blur' },
]">
<el-input v-model="room_create.form.room_name" placeholder="给你的房间起个名字"></el-input>
</el-form-item>
<el-form-item prop="room_name" label="密码">
<el-input v-model="room_create.form.room_password" placeholder="房间密码,留空则无需密码可进入"></el-input>
</el-form-item>
<el-form-item prop="room_name" label="类型">
<el-select class="allLine" v-model="room_create.form.room_type" placeholder="选择一个房间类型吧">
<el-option v-for="item in room_create.typeList" :key="item.value" :label="item.title"
:value="item.value">
</el-option>
</el-select>
</el-form-item>
<el-form-item label="公告">
<el-input type="textarea" placeholder="输入进入房间的提示公告等信息"
v-model="room_create.form.room_notice">
</el-input>
</el-form-item>
<el-form-item class="submit-area">
<el-button type="primary" @click="doSubmitCreateRoom('room_create_form')">创建房间
</el-button>
</el-form-item>
</el-form>
</el-dialog>
<!-- 创建房间结束 -->
</el-card>
<!-- 房间主面板 -->
<!-- 登录页面开始 -->
<div class="login" v-if="login.showPage">
<el-form :model="login.form" ref="login_form" label-width="60px" class="login_form">
<div class="login_form_title">请先登录后快乐的玩耍吧~
<el-link class="login_guest" class='hideWhenScreenSmall' @click="doLogout">
游客
</el-link>
</div>
<el-form-item prop="user_account" label="账号" :rules="[
{ required: true, message: '账号必须填写才能登录啊...', trigger: 'blur' },
]">
<el-input v-model="login.form.user_account" placeholder="支持ID/邮箱登录"
@input="do_login_email_changed">
</el-input>
</el-form-item>
<el-form-item prop="user_password" label="密码" :rules="[
{ required: true, message: '不填写密码如何登录???', trigger: 'blur' }
]">
<el-input v-model="login.form.user_password" type="password" placeholder="登录密码或验证码"
@keydown.13.native="do_login_form_submit('login_form')">
<el-button slot="append" icon="el-icon-message" @click="doSendRandCode" title="发送验证码到邮箱">
</el-button>
</el-input>
</el-form-item>
<el-form-item class="submit-area" style="margin-left:10px;">
<span style="float:left;">
第三方:
<el-link
@click="location.replace('https://graph.qq.com/oauth2.0/authorize?client_id=<?php echo $config['qq']['oauth_id']; ?>&redirect_uri=https%3A%2F%2Fbbbug.com%2Foauth%2Fqq.php&response_type=code&state=<?php echo urlencode($redirectUrl);?>')">
QQ
</el-link>
<el-link v-if="room.roomInfo.room_single==0 && room.roomInfo.room_url==''" class='hideWhenScreenSmall'
@click="location.replace('https://gitee.com/oauth/authorize?client_id=<?php echo $config['gitee']['oauth_id']; ?>&redirect_uri=https%3A%2F%2Fbbbug.com%2Foauth%2Fgitee.php&response_type=code')">
码云
</el-link>
<el-link v-if="room.roomInfo.room_single==0 && room.roomInfo.room_url==''" class='hideWhenScreenSmall'
@click="location.replace('https://www.oschina.net/action/oauth2/authorize?client_id=<?php echo $config['oschina']['oauth_id']; ?>&redirect_uri=https%3A%2F%2Fbbbug.com%2Foauth%2Foschina.php&response_type=code')">
开源中国
</el-link>
</span>
<el-button type="primary" @click="do_login_form_submit('login_form')">立即登录</el-button>
</el-form-item>
</el-form>
</div>
<!-- 登录页面结束 -->
</div>
<audio :src="audioUrl" id="audio" ref="audio" autoplay="autoplay" control @playing="audioPlaying"
@canplay="audioCanPlay" @timeupdate="audioTimeUpdate" @ended="audioEnded" @error="audioError"
@loadeddata="audioLoaded"></audio>
<div class="lockscreen" v-if="lockScreenData.ifLockSystem">
<img :src="lockScreenData.musicHead" class="lockBg" />
<div class="lockImg"><img v-if="lockScreenData.musicHead" :src="lockScreenData.musicHead"
class="musicHead love" />
<div class="lockCover"></div>
<div class="lockBar"></div>
</div>
<div class="lockTitle">{{lockScreenData.musicString}}</div>
<div class="lockLrc">{{lockScreenData.nowMusicLrcText}}</div>
<div class="copyright" v-if="room.roomInfo">{{room.roomInfo.room_name}}</div>
</div>
</div>
<script src="js/vue-2.6.10.min.js"></script>
<script src="js/axios.min.js"></script>
<script src="js/element.js"></script>
<script src="js/vue-clipboard.min.js"></script>
<script src="js/vue.preview.js"></script>
<script src="js/scroll-helper.js"></script>
<style>
audio {
/* position: fixed;
left: -2000px;
top: -2000px; */
/* z-index:-1; */
}
</style>
<script>
Vue.use(vuePhotoPreview, {});
let placeholder = "来来来,说点什么吧...";
var BBBUG = new Vue({
el: '#app',
data() {
return {
systemTips: {
msg: false,
type: 'info',
timer: null,
},
emojiList:[],
guestUserInfo: {
myRoom: false,
user_admin: false,
user_head: "images/nohead.jpg",
user_id: -1,
user_name: "Ghost",
access_token: "45af3cfe44942c956e026d5fd58f0feffbd3a237",
},
timeDiff: 0, //与服务器时间偏移
apiUrl: "https://api.bbbug.com/api/",
audioUrl: "",
copyString: "",
ChatPlaceHolder: "",
userInfo: "",
lrcString: "",
ctrlEnabled: false,
sexList: [{
value: 0,
title: '女生',
}, {
value: 1,
title: '男生',
}],
player: {
nextButton: false,
voiceBar: false,
volumeChangeTimer: null
},
lockScreenData: {
ifLockSystem: false,
musicHead: "",
musicString: "",
nowMusicLrcText: ""
},
musicLrcObj: {},
volume: 50,
loading: false,
baseData: {
access_token: '',
plat: 'pc',
version: 10000,
},
config: {
notification: true,
lockScreen: false,
playMusic: true,
},
websocket: {
connection: null,
heartBeatTimer: null,
connectTimer: null,
hardStop: false,
isConnected: false,
},
title: {
my_room: "我的房间",
create_room: "创建房间",
change_account: "退出登录",
my_setting: "设置",
invate_person: "邀请",
my_profile: "我的",
ios_app: "手机版",
exit_room: "换房",
rank_list:'排行榜',
login: "登录"
},
chat_room: {
historyLoading:false,
historyMax:50,
songSendUser: false,
message: "",
at: null,
song: null,
voice: false,
songPercent: 0,
list: [],
isVideoFullScreen:false,
dialog: {
showRankList:false,
editMyProfile: false,
editMyRoom: false,
searchImageBox: false,
searchSongBox: false,
pickedSongBox: false,
showOnlineBox: false,
showUserProfile: false,
mySongBox: false,
searchVoiceBox: false,
showRankList:false,
},
loading: {
showRankList:true,
searchImageBox: false,
searchSongBox: true,
pickedSongBox: true,
mySongBox: true,
searchVoiceBox: true,
},
data: {
isLoadingVoiceBox:false,
isLoadingMySongBox:false,
rankType:'',
showRankList:[],
searchImageList: [],
searchSongList: [],
pickedSongList: [],
mySongList: [],
mySongListPage: 1,
voiceBoxPage:1,
searchVoiceList: [],
onlineList: [],
hisUserInfo: {},
room_addsong: [{
value: 0,
title: "所有人可点歌"
}, {
value: 1,
title: "仅房主可点歌"
}],
room_sendmsg: [{
value: 0,
title: "关闭全员禁言"
}, {
value: 1,
title: "开启全员禁言"
}],
room_public: [{
value: 0,
title: "公开房间"
}, {
value: 1,
title: "加密房间"
}],
room_robot: [{
value: 0,
title: "开启机器人点歌"
}, {
value: 1,
title: "关闭机器人点歌"
}],
room_playone: [{
value: 0,
title: "随机播放"
}, {
value: 1,
title: "单曲循环"
}],
},
form: {
editMyProfile: {
user_name: "",
user_head: "",
user_remark: "",
user_sex: 0,
user_password: ""
},
editMyRoom: {
room_name: "",
room_notice: "",
room_type: 0,
room_password: "",
room_addsong: 0,
room_sendmsg: 0,
room_robot: 0,
room_public: 0,
room_playone: 0,
room_domain:"",
room_domain_edit:false,
room_huya:"",
},
searchImageBox: {
keyword: ""
},
searchSongBox: {
keyword: ""
},
searchVoiceBox: {
keyword: "郭德纲相声",
page: 1
},
pickSong: null
},
},
room: {
search_id: "",
room_id: <?php echo $room_id; ?>,
roomInfo: false,
list: [],
showDialog: false,
},
room_create: {
cancelSearchImage: false,
typeList: [{
value: 0,
title: "文字聊天房"
}, {
value: 1,
title: "点歌音乐房"
}, {
value: 2,
title: "猜歌游戏房"
}, {
value: 3,
title: "有声故事房"
}, {
value: 4,
title: "房主电台房"
}, {
value: 5,
title: "虎牙直播房"
}],
form: {
room_name: "",
room_password: "",
room_public: 0,
room_type: 0,
room_notice: '',
}
},
login: {
validEmail: false,
form: {
user_account: "",
user_password: ""
},
showPage: false
},
isAudioCurrentTimeChanged: false,
iosCanPlay: false,
player_body: {
top: 'auto',
left: 'auto',
startX: 0,
startY: 0,
startLeft: 10,
startTop: 70,
isMoving: false
},
showScrollToBottomBtn: false,
}
},
created() {
let that = this;
},
mounted() {
let that = this;
// 重写notify,设置默认偏移
const notifyFunc = this.$notify;
that.$notify = function (obj) {
notifyFunc(
Object.assign({offset: 70}, obj)
)
}
document.addEventListener('paste', that.getClipboardFiles);
that.emojiList = [];
for(let i=1;i<=30;i++){
that.emojiList.push('https://bbbug.com/images/emoji/'+i+'.png');
}
that.chat_room.data.searchImageList = that.emojiList;
that.$alert('<?php echo $room_notice; ?>', 'Welcome', {
confirmButtonText: '确定',
callback: function () {
that.initAudioControllers();
if (that.baseData.access_token) {
that.getMyInfo(function (result) {
if (result) {
that.doJoinRoomById(that.room.room_id);
} else {
that.doLogout();
that.doJoinRoomById(that.room.room_id);
}
});
} else {
that.doLogout();
that.doJoinRoomById(that.room.room_id);
}
that.callParentFunction('noticeClicked', 'success');
}
});
that.volume = localStorage.getItem('volume') == null ? 50 : parseInt(localStorage.getItem('volume'));
if (that.volume == 0) {
that.config.playMusic = false;
} else {
that.config.playMusic = true;
}
that.request({
url: "system/time",
success(res) {
let serverTime = res.data.time;
that.timeDiff = parseInt(new Date().valueOf()) - serverTime;
console.log("timeDiff is : " + that.timeDiff + "ms");
},
});
window.onkeydown = function (e) {
switch (e.keyCode) {
case 27:
if ((that.room.roomInfo.room_type == 1 || that.room.roomInfo.room_type == 4) && that.chat_room.song) {
that.lockScreenData.ifLockSystem = !that.lockScreenData.ifLockSystem;
if (that.lockScreenData.ifLockSystem) {
document.title = '音乐播放器';
} else {
document.title = that.room.roomInfo.room_name;
}
}
e.preventDefault();
break;
default:
}
};
that.ctrlEnabled = localStorage.getItem('ctrlEnable') == 'ctrl_enter' ? true : false;
that.login.form.user_account = localStorage.getItem('user_account') || '';
that.baseData.access_token = localStorage.getItem('access_token') || '';
if(that.room.room_id == 888){
room_id = localStorage.getItem('room_id');
if(room_id){
that.room.room_id = parseInt(room_id);
}
}
},
updated() {
let that = this;
that.$previewRefresh();
},
methods: {
getHuyaId(str){
return str.replace('https://www.huya.com/','');
},
doGetRankList() {
var that = this;
that.chat_room.loading.showRankList = true;
let rankType = 'songrecv';
switch (that.chat_room.data.rankType) {
case '发言':
rankType = 'chat';
break;
case '斗图':
rankType = 'img';
break;
case '点歌':
rankType = 'song';
break;
case '切歌':
rankType = 'pass';
break;
case '顶歌':
rankType = 'push';
break;
case '天狗':
rankType = 'songsend';
break;
case '人气':
rankType = 'songrecv';
break;
default:
}
that.request({
url: "user/getRankList",
data: {
type: rankType
},
success:function(res){
that.$refs.showRankList.scrollTop =0;
that.chat_room.data.showRankList = res.data;
that.chat_room.loading.showRankList = false;
}
});
},
doShowRankDialog() {
this.chat_room.data.rankType = '人气';
this.chat_room.dialog.showRankList = true;
this.doGetRankList();
},
doContextMenu(e) {
return false;
},
doShowQrcode() {
this.$alert('<center><span class="item" style="color:red;font-size:14px;"><font color=black style="font-size:20px;">手机扫码立即穿梭</font><br><br><img width="200px" src="https://qr.hamm.cn?data=' + encodeURIComponent('https://bbbug.com/third?access_token=' + this.baseData.access_token) + '"/><br>请不要截图发给其他人,避免账号被盗</span></center>', {
dangerouslyUseHTMLString: true
});
},
isIos() {
return !!navigator.userAgent.match(/\(i[^;]+;( U;)? CPU.+Mac OS X/);;
},
doCreateRoom() {
let that = this;
that.room.showDialog = false;
that.room_create.showPage = true;
},
request(_data = {}) {
let that = this;
_data.loading && (that.loading = true);
axios.post(that.apiUrl + (_data.url || ""), that.getPostData(_data.data || {}))
.then(function (response) {
_data.loading && (that.loading = false);
switch (response.data.code) {
case 200:
if (_data.success) {
_data.success(response.data);
} else {
that.$message.success(response.data.msg);
}
break;
case 401:
if (_data.login) {
_data.login();
} else {
that.$confirm(response.data.msg, '无权访问', {
confirmButtonText: '登录',
cancelButtonText: '取消',
closeOnClickModal: false,
closeOnPressEscape: false,
type: 'warning'
}).then(function () {
that.doShowLoginBox();
}).catch(function () {
that.doLogout();
that.doJoinRoomById(that.room.room_id);
});
}
break;
default:
if (_data.error) {
_data.error(response.data);
} else {
that.$message.error(response.data.msg);
}
}
})
.catch(function (error) {
_data.loading && (that.loading = false);
console.log(error)
});
},
openWebUrl(url) {
window.open(url);
},
formatProgress(percentage) {
return '';
},
doShowVoiceBar() {
let that = this;
that.player.voiceBar = true;
clearTimeout(that.player.volumeChangeTimer);
that.player.volumeChangeTimer = setTimeout(function () {
that.player.voiceBar = false;
}, 3000);
},
doVolumeChanged() {
let that = this;
that.volume = parseInt(that.volume);
if (that.volume == 0) {
that.config.playMusic = false;
} else {
that.config.playMusic = true;
}
that.$refs.audio.volume = parseFloat(that.volume / 100);
localStorage.setItem('volume', that.volume);
localStorage.setItem('volume_old', that.volume);
clearTimeout(that.player.volumeChangeTimer);
that.player.volumeChangeTimer = setTimeout(function () {
that.player.voiceBar = false;
}, 3000);
},
onCopySuccess() {
this.$message.success('复制成功,快发给好友来一起嗨皮吧');
},
getRoomIdFromUrl() { //获取url里面的id参数
var arr = window.location.href.split('#');
if (arr.length == 2) {
return arr[1];
} else {
return false;
}
},
handleSendButtonCommand(cmd) {
if (cmd == 'enter') {
this.ctrlEnabled = false;
} else {
this.ctrlEnabled = true;
}
localStorage.setItem('ctrlEnable', cmd);
},
doReply(item){
let that = this;
that.chat_room.at = {
user_id:item.user.user_id,
user_name:item.user.user_name,
message:item
};
this.focusInput();
},
focusInput() {
const textarea = document.querySelector(".chat_room_message");
// 艾特后自动聚焦
textarea.focus();
},
commandUserHead(cmd) {
let that = this;
switch (cmd.command) {
case 'at':
that.chat_room.at = cmd.row;
that.chat_room.dialog.showOnlineBox =false;
this.focusInput();
break;
case 'pullback':
that.request({
url: "message/back",
data: {
message_id: cmd.row.message_id,
room_id: that.room.room_id
}
});
break;
case 'shutdown':
that.request({
url: "user/shutdown",
data: {
user_id: cmd.row.user_id,
room_id: that.room.room_id
}
});
break;
case 'songdown':
that.request({
url: "user/songdown",
data: {
user_id: cmd.row.user_id,
room_id: that.room.room_id
}
});
break;
case 'removeBan':
that.request({
url: "user/removeban",
data: {
user_id: cmd.row.user_id,
room_id: that.room.room_id
},
success(res) {
that.$message.success(res.msg);
that.doShowOnlineList();
}
});
break;
case 'profile':
that.doGetUserInfoById(cmd.row.user_id);
that.chat_room.dialog.showUserProfile = true;
that.chat_room.dialog.showOnlineBox =false;
break;
case 'sendSong':
that.chat_room.dialog.showOnlineBox =false;
that.doSendSongToUser(cmd.row);
that.doSearchSong();
break;
default:
that.$message.error('即将上线,敬请期待');
}
},
doSendSongToUser(user) {
let that = this;
that.chat_room.songSendUser = user;
that.hideAllDialog();
that.chat_room.dialog.searchSongBox = true;
},
beforeHandleUserCommand(row, command) {
return {
"row": row,
"command": command
}
},
replaceProfileLink(appUrl, userExtra) {
return appUrl.replace('#extra#', userExtra);
},
getMusicLrc() {
let that = this;
that.musicLrcObj = {};
that.request({
url: 'song/getLrc',
data: {
mid: that.chat_room.song.song.mid
},
success(res) {
that.musicLrcObj = (res.data);
// that.musicLrcObj = that.createLrcObj(res.data);
}
});
},
doGameMusicPass() {
let that = this;
that.musicLrcObj = {};
that.request({
url: '/song/gamePass',
data: {
room_id: that.room.room_id,
}
});
},
doGetRoomData() {
let that = this;
that.loading = true;
if (that.websocket.isConnected) {
that.websocket.hardStop = true;
that.websocket.connection.send('bye');
that.chat_room.song = false;
that.chat_room.voice = false;
that.audioUrl = '';
}
if (that.websocket.isConnected) {
setTimeout(function () {
that.doGetRoomData();
}, 1000);
return;
}
that.loading = false;
that.initNowRoomInfo(function (result) {
if (result) {
localStorage.setItem('room_id', that.room.room_id);
that.initWebsocket();
that.loadMessageHistory();
if (that.userInfo.user_needmotify && that.userInfo.user_app == 1) {
that.$confirm('完善资料并修改密码,下次就可以直接用密码登录啦!', '资料待完善', {
confirmButtonText: '去完善',
cancelButtonText: '取消',
closeOnClickModal: false,
closeOnPressEscape: false,
type: 'warning'
}).then(function () {
that.doEditMyProfile();
that.callParentFunction('noticeClicked', 'click_motify_info');
}).catch(function () {
that.callParentFunction('noticeClicked', 'click_cancel');
});
}
}
});
},
initAudioControllers() {
let that = this;
try {
if (that.isIos()) {
that.$refs.audio.play();
that.$refs.audio.pause();
} else {
that.$refs.audio.play();
}
} catch (error) {
console.log(error);
}
that.loading = false;
},
callParentFunction(type, msg) {
//触发父容器方法
if (self != top) {
window.parent.postMessage({
'type': type,
'msg': msg
}, '*');
}
},
getPostData(data) {
return Object.assign({}, this.baseData, data);
},
audioLoaded() {
let that = this;
that.$refs.audio.play();
},
audioEnded() {
let that = this;
that.audioUrl = "";
that.chat_room.song = null;
that.lrcString = '歌词加载中...';
that.copyString = '欢迎来' + that.room.roomInfo.room_name + "一起听歌聊天呀:\n" + location.href + that.room.room_id;
if(that.room.roomInfo.room_domain && that.room.roomInfo.room_domainstatus){
if(location.href.indexOf('bbbug.com')<0){
//使用的独立域名
that.copyString = '欢迎来' + that.room.roomInfo.room_name + "一起听歌聊天呀:\n" +location.href;
}else{
that.copyString = '欢迎来' + that.room.roomInfo.room_name + "一起听歌聊天呀:\nhttps://" + that.room.roomInfo.room_domain+".bbbug.com";
}
}
that.chat_room.songPercent = 0;
that.$refs.audio.currentTime = 0;
},
audioPlaying() {
let that = this;
that.nowPlaying = true;
that.lrcString = '歌词加载中...';
that.$refs.audio.volume = parseFloat(that.volume / 100);
// if (!that.isAudioCurrentTimeChanged) {
// let nowTimeStamps = parseInt((new Date().valueOf() - that.timeDiff) / 1000);
// let now = 0;
// switch (that.room.roomInfo.room_type) {
// case 1:
// case 2:
// case 4:
// now = parseFloat((nowTimeStamps - that.chat_room.song.since)).toFixed(2);
// if (now >= that.$refs.audio.duration && that.$refs.audio.duration > 0) {
// now = 0;
// }
// console.error('当前应播放' + now + 's');
// that.$refs.audio.currentTime = now < 0 ? 0 : now;
// break;
// case 3:
// now = parseFloat((nowTimeStamps - that.chat_room.voice.since)).toFixed(2);
// if (now >= that.$refs.audio.duration && that.$refs.audio.duration > 0) {
// now = 0;
// }
// console.error('当前应播放' + now + 's');
// that.$refs.audio.currentTime = now < 0 ? 0 : now;
// break;
// }
// }
if (that.chat_room.song) {
if (that.$refs.audio.duration > 0) {
let percent = parseInt(that.$refs.audio.currentTime / that.$refs.audio.duration * 100);
if (percent > 100) {
percent = 100;
}
if (percent < 0) {
percent = 0;
}
that.chat_room.songPercent = percent;
}
}
},
audioCanPlay() {
let that = this;
if (!that.isAudioCurrentTimeChanged) {
let nowTimeStamps = parseInt((new Date().valueOf() - that.timeDiff) / 1000);
let now = 0;
switch (that.room.roomInfo.room_type) {
case 1:
case 2:
case 4:
now = parseFloat((nowTimeStamps - that.chat_room.song.since)).toFixed(2);
if (now >= that.$refs.audio.duration && that.$refs.audio.duration > 0) {
now = 0;
}
// console.error('当前应播放' + now + 's');
that.$refs.audio.currentTime = now < 0 ? 0 : now;
break;
case 3:
now = parseFloat((nowTimeStamps - that.chat_room.voice.since)).toFixed(2);
if (now >= that.$refs.audio.duration && that.$refs.audio.duration > 0) {
now = 0;
}
console.error('当前应播放' + now + 's');
that.$refs.audio.currentTime = now < 0 ? 0 : now;
break;
}
}
that.isAudioCurrentTimeChanged = true;
if (that.isIos() && !that.iosCanPlay) {
that.$alert('播放器加载成功!', '加载成功', {
confirmButtonText: '确定',
callback: function () {
that.$refs.audio.play();
that.iosCanPlay = true;
}
});
} else {
that.$refs.audio.play();
}
},
audioError(e) {
let that = this;
if (that.audioUrl) {
that.$refs.audio.src = that.$refs.audio.src;
that.$refs.audio.load();
that.$refs.audio.play();
}
// console.log(e);
// that.$alert('很罕见的音频地址读取失败!', '读取失败', {
// confirmButtonText: '重试',
// callback: function () {
// that.doPlayMusic(that.chat_room.song);
// }
// });
},
audioTimeUpdate() {
let that = this;
if (that.$refs.audio.duration > 0 && that.$refs.audio.duration != NaN) {
that.chat_room.songPercent = parseInt(that.$refs.audio.currentTime / that.$refs.audio.duration * 100);
let lrcText = '';
if (that.room.roomInfo.room_type != 1 && that.room.roomInfo.room_type != 2 && that.room.roomInfo.room_type != 4) {
that.lrcString = '';
return false;
}
if (that.musicLrcObj) {
for (let i = 0; i < that.musicLrcObj.length; i++) {
if (i == that.musicLrcObj.length - 1) {
lrcText = (that.musicLrcObj[i].lineLyric);
} else {
if (that.$refs.audio.currentTime > that.musicLrcObj[i].time && that.$refs.audio.currentTime < that.musicLrcObj[i + 1].time) {
lrcText = (that.musicLrcObj[i].lineLyric);
break;
}
}
}
if (lrcText) {
that.lrcString = lrcText;
that.lockScreenData.nowMusicLrcText = lrcText;
return;
}
}
that.lrcString = '没有读取到歌词';
}
},
loadMessageHistory(){
let that = this;
if(that.chat_room.historyLoading){
return;
}
that.chat_room.historyLoading=true;
that.request({
url: "message/getMessageList",
data: {
room_id: that.room.room_id,
per_page:that.chat_room.historyMax,
},
success(res) {
that.chat_room.historyLoading=false;
that.chat_room.list = [];
for(let i=0;i<res.data.length;i++){
let _obj = false;
try{
_obj = JSON.parse(decodeURIComponent(res.data[i].message_content));
}catch(error){}
if(_obj){
if(_obj.at){
_obj.content = '@' + _obj.at.user_name + " " + _obj.content;
}
_obj.time = res.data[i].message_createtime;
that.chat_room.list.unshift(_obj);
}
}
that.addSystemMessage(that.room.roomInfo.room_notice ? that.room.roomInfo.room_notice : ('欢迎来到' + that.room.roomInfo.room_name + '!'));
that.autoScroll();
}
});
},
doGetUserInfoById(user_id) {
let that = this;
that.request({
url: "user/getUserInfo",
data: {
user_id: user_id
},
success(res) {
that.chat_room.data.hisUserInfo = res.data;
that.chat_room.dialog.showUserProfile = true;
}
});
},
checkRoomPassword(room_id, room_password, callback = false) {
let that = this;
that.request({
url: "room/getRoomInfo",
data: {
room_id: room_id,
room_password: room_password
},
success(res) {
if (callback) {
callback(true);
}
},
error(res) {
if (callback) {
callback(false, res.msg);
}
}
});
},
getMyInfo(callback = null) {
let that = this;
that.request({
url: "user/getMyInfo",
loading: true,
success(res) {
that.userInfo = res.data;
that.chat_room.data.hisUserInfo = res.data;
if (callback) {
callback(res);
}
},
login() {
if (callback) {
callback(false);
}
},
error() {
if (callback) {
callback(false);
}
}
});
},
addSystemMessage(msg, color = '#999', bgColor = '#eee') {
let that = this;
if (that.chat_room.list.length > that.chat_room.historyMax) {
that.chat_room.list.shift();
}
that.chat_room.list.push({
type: "system",
content: msg,
bgColor: bgColor,
color: color
});
that.autoScroll();
},
addSystemTips(msg, type = 'info') {
let that = this;
if (that.systemTips.msg) {
clearTimeout(that.systemTips.timer);
}
that.systemTips = {
msg: msg,
type: type
};
that.systemTips.timer = setTimeout(function () {
that.systemTips = {
msg: false,
type: type
};
}, 3000);
},
autoScroll() {
let that = this;
that.$nextTick(function () {
if (!that.config.lockScreen) {
let ele = document.getElementById('chat_room_history');
ele.scrollTop = ele.scrollHeight;
}
});
},
hideAllDialog() {
let that = this;
that.chat_room.dialog.editMyProfile = false;
that.chat_room.dialog.searchImageBox = false;
that.chat_room.dialog.searchSongBox = false;
that.chat_room.dialog.pickedSongBox = false;
that.chat_room.dialog.searchVoiceBox = false;
that.chat_room.dialog.mySongBox = false;
},
initNowRoomInfo(callback = false) {
let that = this;
that.request({
url: "room/getRoomInfo",
data: {
room_id: that.room.room_id
},
success(res) {
if (res.data.room_type != that.room.roomInfo.room_type) {
that.audioUrl = '';
that.chat_room.song = null;
}
that.room.roomInfo = res.data;
that.addSystemMessage(res.data.room_notice ? res.data.room_notice : ('欢迎来到' + res.data.room_name + '!'));
that.copyString = '欢迎来' + that.room.roomInfo.room_name + "一起听歌聊天呀:\n" + location.href + that.room.room_id;
if(that.room.roomInfo.room_domain && that.room.roomInfo.room_domainstatus){
if(location.href.indexOf('bbbug.com')<0){
//使用的独立域名
that.copyString = '欢迎来' + that.room.roomInfo.room_name + "一起听歌聊天呀:\n" +location.href;
}else{
that.copyString = '欢迎来' + that.room.roomInfo.room_name + "一起听歌聊天呀:\nhttps://" + that.room.roomInfo.room_domain+".bbbug.com";
}
}
document.title = res.data.room_name;
that.doShowOnlineList();
if (that.websocket.connection) {
that.websocket.connection.send('getNowSong');
}
if (that.room.roomInfo.room_sendmsg == 1 && that.room.roomInfo.room_user != that.userInfo.user_id && !that.userInfo.user_admin) {
that.ChatPlaceHolder = '全员禁言中,你暂时无法发言';
} else {
that.ChatPlaceHolder = placeholder;
}
if (callback) {
callback(true);
}
},
error(res) {
that.$message.error(res.msg);
switch(res.code){
case 301:
that.websocket.hardStop = true;
that.websocket.connection.send('bye');
that.$alert(res.msg, '房间封禁', {
confirmButtonText: '确定',
callback: function () {
that.doJoinRoomById(888);
}
});
break;
case 302:
that.websocket.hardStop = true;
that.websocket.connection.send('bye');
that.$alert(res.msg, '房间密码变更', {
confirmButtonText: '确定',
callback: function () {
that.doJoinRoomById(888);
}
});
break;
default:
that.$alert(res.msg, '进入失败', {
confirmButtonText: '确定',
callback: function () {
that.doJoinRoomById(888);
}
});
callback(false);
}
if (callback) {
callback(false);
}
}
});
},
doChangeTo(room) {
let that = this;
that.$confirm('你点击了一张快捷机票,是否确认进入 ' + room.room_name + ' ?', 'ID: ' + room.room_id, {
confirmButtonText: '进入',
cancelButtonText: '取消',
type: 'warning'
}).then(function () {
that.doJoinRoomById(room.room_id);
}).catch(function () { });
},
initWebsocket() {
let that = this;
that.request({
url: "room/getWebsocketUrl",
data: {
channel: that.room.room_id
},
success(res) {
that.websocket.params = res.data;
that.websocket.connection = new WebSocket("wss://websocket.bbbug.com/?account=" + res.data.account + "&channel=" + res.data.channel + "&ticket=" + res.data.ticket);
that.websocket.connection.onopen = function (evt) {
that.websocket.isConnected = true;
that.websocket.hardStop = false;
that.doWebsocketHeartBeat();
// that.chat_room.list.push({
// desc: "聊天室已支持绑定房间二级域名和第三方独立域名,快来看看吧>>>",
// img: "logo.png",
// key: "edc937ec77f8a6e786c1e1c5c9288f21c0316db5883754",
// link: "https://doc.bbbug.com/2883813.html",
// sha: "cbe2db8e9a6bad851cb4b94540a583c3bbf5ab78",
// title: "重要更新",
// type: "link",
// user: {
// app_id: 1,
// app_name: "BBBUG",
// app_url: "https://bbbug.com",
// user_admin: true,
// user_head: "https://api.bbbug.com/uploads/thumb/image/20200828/7e9ac63489f863a2e690fdb74931565b.jpg",
// user_id: 1,
// user_sex: 0,
// user_name: "机器人",
// user_remark: "别@我,我只是个测试帐号",
// }
// });
// that.chat_room.list.push({
// key: "edc937ec77f8a6e786c1e1c5c9288f21c0316db5883754",
// sha: "cbe2db8e9a6bad851cb4b94540a583c3bbf5ab78",
// content: "Hello World!",
// type: "text",
// user: {
// app_id: 1,
// app_name: "BBBUG",
// app_url: "https://bbbug.com",
// user_admin: true,
// user_head: "https://api.bbbug.com/uploads/thumb/image/20200828/7e9ac63489f863a2e690fdb74931565b.jpg",
// user_id: 1,
// user_name: "机器人",
// user_sex: 0,
// user_remark: "别@我,我只是个测试帐号",
// }
// });
};
that.websocket.connection.onmessage = function (event) {
that.messageController(event.data);
};
that.websocket.connection.onclose = function (event) {
that.websocket.isConnected = false;
if (!that.websocket.hardStop) {
that.doWebsocketError();
}
};
}
});
},
scrollEvent(e) {
let that = this;
if (e.currentTarget.scrollTop + e.currentTarget.clientHeight + 200 >= e.currentTarget.scrollHeight) {
that.config.lockScreen = false;
} else {
that.config.lockScreen = true;
}
// 聊天记录区域滚动相关处理
const func = scrollFuncs[e.target.id];
func && func(e, this);
},
scrollToBottom() {
scrollFuncs.scrollToBottom();
},
friendlyTime: function(time) {
var now = parseInt(Date.parse(new Date()) / 1000);
if (now - time <= 60) {
return '刚刚';
} else if (now - time > 60 && now - time <= 3600) {
return parseInt((now - time) / 60) + '分钟前'
} else if (now - time > 3600 && now - time <= 86400) {
return parseInt((now - time) / 3600) + '小时前'
} else if (now - time > 86400 && now - time <= 86400 * 7) {
return parseInt((now - time) / 86400) + '天前'
} else if (now - time > 86400 * 7 && now - time <= 86400 * 30) {
return parseInt((now - time) / 86400 / 7) + '周前'
} else if (now - time > 86400 * 30 && now - time <= 86400 * 30 * 12) {
return parseInt((now - time) / 86400 / 30) + '月前'
} else {
return parseInt((now - time) / 86400 / 365) + '年前'
}
},
scrollToChat: function(msgid) {
scrollFuncs.scrollToChat(msgid);
},
messageController(data) {
let that = this;
try {
let obj = {};
try{
obj = JSON.parse(decodeURIComponent(data));
}catch(e){
obj = JSON.parse(data);
}
if (that.chat_room.list.length > that.chat_room.historyMax) {
that.chat_room.list.shift();
}
obj.time = parseInt(new Date().valueOf()/1000);
switch (obj.type) {
case 'text':
if (obj.user.user_id == that.userInfo.user_id) {
for (let i = that.chat_room.list.length - 1; i >= 0; i--) {
if (that.chat_room.list[i].sha == 'loading') {
that.chat_room.list.splice(i, 1);
break;
}
}
}
if (obj.user.user_id == 10000) {
if (obj.content == 'clear') {
that.chat_room.list = [];
that.addSystemMessage("管理员" + that.urldecode(obj.user.user_name) + "清空了你的聊天记录", '#f00', '#eee');
return;
}
if (obj.content == 'reload') {
that.addSystemMessage("管理员" + that.urldecode(obj.user.user_name) + "刷新了你的页面", '#f00', '#eee');
location.replace(location.href);
return;
}
}
if (obj.at) {
if (obj.at.user_id == that.userInfo.user_id) {
if (that.config.notification) {
let isNotificated = false;
if (window.Notification && Notification.permission !== "denied") {
Notification.requestPermission(function (status) { // 请求权限
if (status === 'granted') {
// 弹出一个通知
var n = new Notification(that.urldecode(obj.user.user_name) + "@了你:", {
body: that.urldecode(obj.content),
icon: ""
});
isNotificated = true;
// 两秒后关闭通知
setTimeout(function () {
n.close();
}, 5000);
}
});
}
if (!isNotificated) {
that.$notify({
title: that.urldecode(obj.user.user_name) + "@了你:",
message: that.urldecode(obj.content) + `<span class="notify-at-goto" onclick="scrollFuncs.scrollToChat(${obj.message_id})">[查看]</span>`,
duration: 0,
dangerouslyUseHTMLString: true
// offset: 70,
});
}
}
}
obj.content = '@' + obj.at.user_name + " " + obj.content;
}else{
if(that.chat_room.isVideoFullScreen){
that.$notify({
title: that.urldecode(obj.user.user_name) + "说:",
message: that.urldecode(obj.content),
duration: 5000,
// offset: 70,
});
}
}
that.chat_room.list.push(obj);
break;
case 'link':
if (obj.user.user_id == that.userInfo.user_id) {
for (let i = that.chat_room.list.length - 1; i >= 0; i--) {
if (that.chat_room.list[i].sha == 'loading') {
that.chat_room.list.splice(i, 1);
break;
}
}
}
if (that.chat_room.list.length > that.chat_room.historyMax) {
that.chat_room.list.shift();
}
that.chat_room.list.push(obj);
that.autoScroll();
break;
case 'img':
case 'system':
case 'jump':
if (obj.user && obj.user.user_id == that.userInfo.user_id) {
for (let i = that.chat_room.list.length - 1; i >= 0; i--) {
if (that.chat_room.list[i].sha == 'loading') {
that.chat_room.list.splice(i, 1);
break;
}
}
}
if (that.chat_room.list.length > that.chat_room.historyMax) {
that.chat_room.list.shift();
}
that.chat_room.list.push(obj);
that.autoScroll();
break;
case 'join':
that.addSystemTips(obj.content);
break;
case 'addSong':
if (obj.at) {
that.addSystemMessage(that.urldecode(obj.user.user_name) + " 送了一首 《" + obj.song.name + "》(" + obj.song.singer + ") 给 " + that.urldecode(obj.at.user_name), '#409EFF', '#eee');
if (obj.at.user_id == that.userInfo.user_id) {
if (that.config.notification) {
let isNotificated = false;
if (window.Notification && Notification.permission !== "denied") {
Notification.requestPermission(function (status) { // 请求权限
if (status === 'granted') {
// 弹出一个通知
var n = new Notification(that.urldecode(obj.user.user_name) + "送了歌给你:", {
body: "" + obj.song.name + "》(" + obj.song.singer + ")",
icon: ""
});
isNotificated = true;
// 两秒后关闭通知
setTimeout(function () {
n.close();
}, 5000);
}
});
}
if (!isNotificated) {
that.$notify({
title: that.urldecode(obj.user.user_name) + "送了歌给你:",
message: "" + obj.song.name + "》(" + obj.song.singer + ")",
duration: 0
});
}
}
}
} else {
that.addSystemTips(that.urldecode(obj.user.user_name) + " 点了一首 《" + obj.song.name + "》(" + obj.song.singer + ")");
}
break;
case 'chat_bg':
that.addSystemMessage(that.urldecode(obj.user.user_name) + " 运气大爆发,触发了点歌背景墙特效(1小时内播放歌曲时有效)!", 'green', '#eee');
break;
case 'push':
that.addSystemMessage(that.urldecode(obj.user.user_name) + " 将歌曲 《" + obj.song.name + "》(" + obj.song.singer + ") 设为置顶候播放");
break;
case 'removeSong':
that.addSystemMessage(that.urldecode(obj.user.user_name) + " 将歌曲 《" + obj.song.name + "》(" + obj.song.singer + ") 从队列移除");
break;
case 'removeban':
that.addSystemMessage(that.urldecode(obj.user.user_name) + "" + that.urldecode(obj.ban.user_name) + " 解禁");
break;
case 'shutdown':
that.addSystemMessage(that.urldecode(obj.user.user_name) + " 禁止了用户 " + that.urldecode(obj.ban.user_name) + " 发言");
break;
case 'songdown':
that.addSystemMessage(that.urldecode(obj.user.user_name) + " 禁止了用户 " + that.urldecode(obj.ban.user_name) + " 点歌");
break;
case 'pass':
that.addSystemMessage(that.urldecode(obj.user.user_name) + " 切掉了当前播放的歌曲 《" + obj.song.name + "》(" + obj.song.singer + ") ", '#ff4500', '#eee');
break;
case 'passGame':
that.addSystemMessage(that.urldecode(obj.user.user_name) + " PASS了当前的歌曲 《" + obj.song.name + "》(" + obj.song.singer + ") ", '#ff4500', '#eee');
break;
case 'all':
that.addSystemMessage(obj.content, '#fff', '#666');
break;
case 'back':
for (let i = 0; i < that.chat_room.list.length; i++) {
if (parseInt(that.chat_room.list[i].message_id) == parseInt(obj.message_id)) {
that.chat_room.list.splice(i, 1);
break;
}
}
that.addSystemMessage(that.urldecode(obj.user.user_name) + " 撤回了一条消息");
break;
case 'playSong':
if (obj.song && (that.room.roomInfo.room_type == 1 || that.room.roomInfo.room_type == 2 || that.room.roomInfo.room_type == 4)) {
that.doPlayMusic(obj);
}
break;
case 'online':
that.chat_room.data.onlineList = obj.data;
break;
case 'roomUpdate':
that.initNowRoomInfo();
break;
case 'game_music_success':
that.addSystemMessage("恭喜 " + that.urldecode(obj.user.user_name) + " 猜中了《" + obj.song.name + "》(" + obj.song.singer + "),30s后开始新一轮游戏", '#ff4500', '#eee');
that.chat_room.song.song.pic = that.http2https(obj.song.pic);
that.chat_room.song.song.name = obj.song.name;
that.chat_room.song.song.singer = obj.song.singer;
break;
case 'story':
that.addSystemMessage('正在播放声音《' + obj.story.name + '》(' + obj.story.part + ')', '#409EFF', '#eee');
that.audioUrl = obj.story.play;
that.chat_room.voice = obj.story;
that.isAudioCurrentTimeChanged = false;
break;
default:
}
} catch (error) {
console.log(error)
}
that.autoScroll();
},
http2https(str){
return str.replace('http:','https:');
},
doPlayMusic(obj) {
let that = this;
// if (that.chat_room.song) {
// //is playing
// if (obj.song.mid == that.chat_room.song.song.mid && that.room.roomInfo.room_type != 4) {
// return;
// }
// }
that.chat_room.song = false;
that.audioUrl = "";
setTimeout(function(){
obj.song.pic = that.http2https(obj.song.pic);
console.log(that.chat_room.song);
that.chat_room.songPercent = 0;
that.chat_room.song = obj;
that.isAudioCurrentTimeChanged = false;
that.audioUrl = "https://api.bbbug.com/api/song/playurl?mid=" + obj.song.mid;
that.lockScreenData.musicHead = obj.song.pic || 'images/nohead.jpg';
that.lockScreenData.musicString = "" + obj.song.name + "》(" + obj.song.singer + ") ";
if (obj.at) {
that.addSystemMessage("正在播放 " + that.urldecode(obj.user.user_name) + " 送给 " + that.urldecode(obj.at.user_name) + " 的歌曲 《" + obj.song.name + "》(" + obj.song.singer + ") ", 'white', 'lightsalmon');
}
switch (that.room.roomInfo.room_type) {
case 1:
that.getMusicLrc();
if (obj.user.user_id == that.userInfo.user_id) {
if (that.config.notification) {
let isNotificated = false;
if (window.Notification && Notification.permission !== "denied") {
Notification.requestPermission(function (status) { // 请求权限
if (status === 'granted') {
// 弹出一个通知
var n = new Notification("正在播放你点的歌", {
body: "" + obj.song.name + "》(" + obj.song.singer + ") ",
icon: ""
});
isNotificated = true;
// 两秒后关闭通知
setTimeout(function () {
n.close();
}, 5000);
}
});
}
if (!isNotificated) {
that.$notify({
title: "正在播放你点的歌曲",
message: "" + obj.song.name + "》(" + obj.song.singer + ") ",
duration: 5
});
}
}
}
if (obj.at.user_id == that.userInfo.user_id) {
if (that.config.notification) {
let isNotificated = false;
if (window.Notification && Notification.permission !== "denied") {
Notification.requestPermission(function (status) { // 请求权限
if (status === 'granted') {
// 弹出一个通知
var n = new Notification("正在播放 " + that.urldecode(obj.user.user_name) + " 送你的歌", {
body: "" + obj.song.name + "》(" + obj.song.singer + ") ",
icon: ""
});
isNotificated = true;
// 两秒后关闭通知
setTimeout(function () {
n.close();
}, 5000);
}
});
}
if (!isNotificated) {
that.$notify({
title: "正在播放 " + that.urldecode(obj.user.user_name) + " 送你的歌",
message: "" + obj.song.name + "》(" + obj.song.singer + ") ",
duration: 5
});
}
}
}
that.copyString = that.room.roomInfo.room_name + " 正在播放《" + obj.song.name + "》(" + obj.song.singer + "),快来和大家一起听吧:\n" + location.href + that.room.room_id;
if(that.room.roomInfo.room_domain && that.room.roomInfo.room_domainstatus){
if(location.href.indexOf('bbbug.com')<0){
//使用的独立域名
that.copyString = that.room.roomInfo.room_name + " 正在播放《" + obj.song.name + "》(" + obj.song.singer + "),快来和大家一起听吧:\n" +location.href;
}else{
that.copyString = that.room.roomInfo.room_name + " 正在播放《" + obj.song.name + "》(" + obj.song.singer + "),快来和大家一起听吧:\nhttps://" + that.room.roomInfo.room_domain+".bbbug.com";
}
}
break;
case 2:
that.addSystemTips("仔细听,猜猜是什么歌曲(直接在聊天框输入答案发送即可)");
case 4:
that.getMusicLrc();
that.copyString = that.room.roomInfo.room_name + " 正在播放《" + obj.song.name + "》(" + obj.song.singer + "),快来和大家一起听吧:\n" + location.href + that.room.room_id;
if(that.room.roomInfo.room_domain && that.room.roomInfo.room_domainstatus){
if(location.href.indexOf('bbbug.com')<0){
//使用的独立域名
that.copyString = that.room.roomInfo.room_name + " 正在播放《" + obj.song.name + "》(" + obj.song.singer + "),快来和大家一起听吧:\n" +location.href;
}else{
that.copyString = that.room.roomInfo.room_name + " 正在播放《" + obj.song.name + "》(" + obj.song.singer + "),快来和大家一起听吧:\nhttps://" + that.room.roomInfo.room_domain+".bbbug.com";
}
}
}
},100);
},
getImageUrl(url) {
if (!url) {
return '';
}
if (url.indexOf('https://') > -1 || url.indexOf('http://') > -1) {
return url.replace('http:','https:');
} else {
return 'https://api.bbbug.com/uploads/' + url;
}
},
urldecode(str) {
try {
return decodeURIComponent(str);
} catch (error) {
return null;
}
},
handleProfileHeadUploadSuccess(res, file) {
var that = this;
if (res.code == 200) {
that.chat_room.form.editMyProfile.user_head = that.getImageUrl(res.data.attach_thumb);
} else {
that.$message.error(res.msg);
}
},
handleSettingCommand(cmd) {
let that = this;
switch (cmd) {
case 'doEditMyProfile':
that.doEditMyProfile();
break;
case 'doShowQrcode':
that.doShowQrcode();
break;
case 'clearHistory':
that.clearHistory();
break;
case 'contactUs':
window.open('https://doc.bbbug.com');
break;
case 'switchNotification':
that.config.notification = !that.config.notification;
if (that.config.notification) {
if (window.Notification && Notification.permission !== "denied") {
Notification.requestPermission(function (status) { // 请求权限
if (status === 'granted') {
var n = new Notification("通知已开启,你将收到@提醒和歌曲通知");
setTimeout(function () {
n.close();
}, 5000);
}
});
}
that.addSystemTips('通知已开启,你将收到@提醒和歌曲通知');
} else {
that.addSystemTips('通知已关闭,你将无法@提醒和歌曲通知');
}
break;
case 'doLogout':
that.doLogout();
break;
default:
}
},
doSwitchMusic() {
let that = this;
that.config.playMusic = !that.config.playMusic;
if (that.config.playMusic) {
that.addSystemTips('音乐已打开');
that.volume = parseInt(localStorage.getItem('volume_old')) || 50;
localStorage.setItem('volume', that.volume);
localStorage.setItem('volume_old', that.volume);
that.$refs.audio.volume = parseFloat(that.volume / 100);
} else {
that.addSystemTips('音乐已静音');
that.$refs.audio.volume = 0;
that.volume = 0;
localStorage.setItem('volume', that.volume);
}
},
clearHistory() {
var that = this;
that.$confirm('是否确认清空本地聊天记录?', '删除聊天记录', {
confirmButtonText: '删除',
cancelButtonText: '取消',
type: 'warning'
}).then(function () {
that.chat_room.list = [];
that.addSystemTips("历史聊天记录清理成功");
}).catch(function () { });
},
handleImageUploadSuccess(res, file) {
var that = this;
if (res.code == 200) {
that.request({
url: "message/send",
data: {
where: 'channel',
to: that.websocket.params.channel,
type: 'img',
msg: res.data.attach_thumb,
resource: res.data.attach_path,
},
success(res) {
that.chat_room.message = '';
}
});
} else {
that.$message.error(res.msg);
}
},
doPushSongTop(row) {
let that = this;
that.request({
url: "song/push",
data: {
room_id: that.room.room_id,
mid: row.song.mid
},
success(res) {
that.$message.success(res.msg);
that.doSongListUpdate();
}
});
},
doDeleteMySong(row) {
let that = this;
that.$confirm('是否确认将这首歌从歌单中删除?', '删除提醒', {
confirmButtonText: '删除',
cancelButtonText: '取消',
closeOnClickModal: false,
closeOnPressEscape: false,
type: 'warning'
}).then(function () {
that.request({
url: "song/deleteMySong",
data: {
room_id: that.room.room_id,
mid: row.mid
},
success(res) {
that.$message.success(res.msg);
that.doGetMySongList(that.room.roomInfo.room_type == 4 ? 'recent' : 'count');
}
});
}).catch(function () { });
},
doDeleteSong(row) {
let that = this;
that.$confirm('是否确认将这首歌从队列中移除?', '移除提醒', {
confirmButtonText: '移除',
cancelButtonText: '取消',
closeOnClickModal: false,
closeOnPressEscape: false,
type: 'warning'
}).then(function () {
that.request({
url: "song/remove",
data: {
room_id: that.room.room_id,
mid: row.song.mid
},
success(res) {
that.$message.success(res.msg);
that.doSongListUpdate();
}
});
}).catch(function () { });
},
doShowSongList() {
let that = this;
if (that.chat_room.dialog.pickedSongBox) {
that.chat_room.dialog.pickedSongBox = false;
} else {
that.hideAllDialog();
that.chat_room.dialog.pickedSongBox = true;
that.doSongListUpdate();
}
},
doShowMySongList(order) {
let that = this;
if (that.chat_room.dialog.mySongBox) {
that.chat_room.dialog.mySongBox = false;
} else {
that.hideAllDialog();
that.chat_room.dialog.mySongBox = true;
that.chat_room.data.mySongListPage = 1;
that.doGetMySongList(order);
}
},
doMySongBoxScroll(e){
let that = this;
if(that.chat_room.data.isLoadingMySongBox){
return;
}
if(e.target.scrollHeight - e.target.scrollTop < 300+50){
that.chat_room.data.mySongListPage++;
that.doGetMySongList(that.room.roomInfo.room_type==4?'recent':'count')
}
},
doGetMySongList(order) {
let that = this;
that.chat_room.loading.mySongBox = true;
that.chat_room.data.isLoadingMySongBox=true;
that.request({
url: "song/mySongList",
data: {
order: order,
page: that.chat_room.data.mySongListPage
},
success(res) {
that.chat_room.data.isLoadingMySongBox=false;
that.chat_room.loading.mySongBox = false;
if(that.chat_room.data.mySongListPage == 1){
that.chat_room.data.mySongList = res.data;
that.$refs.mySongBox.scrollTop =0;
}else{
for(let i=0;i<res.data.length;i++){
that.chat_room.data.mySongList.push(res.data[i]);
}
}
},error(){
that.chat_room.data.isLoadingMySongBox=false;
}
});
},
doSongListUpdate() {
let that = this;
that.chat_room.loading.pickedSongBox = true;
that.request({
url: "song/songList",
data: {
room_id: that.room.room_id,
},
success(res) {
that.chat_room.loading.pickedSongBox = false;
that.chat_room.data.pickedSongList = res.data;
}
});
},
doSaveRoomInfo() {
let that = this;
that.request({
url: "room/saveMyRoom",
data: Object.assign({}, that.chat_room.form.editMyRoom, {
room_id: that.room.room_id
}),
success(res) {
that.$message.success(res.msg);
that.chat_room.dialog.editMyRoom = false;
}
});
},
doSendImage(url) {
let that = this;
that.request({
url: "message/send",
data: {
where: 'channel',
to: that.websocket.params.channel,
type: 'img',
msg: url,
resource: url,
},
success(res) {
// this.$message.success('表情发送成功');
that.chat_room.dialog.searchImageBox=false;
}
});
},
doAddSong(row) {
let that = this;
that.chat_room.form.pickSong = row;
that.request({
url: "song/addSong",
data: {
mid: row.mid,
at: that.chat_room.songSendUser.user_id,
room_id: that.room.room_id
},
success(res) {
that.chat_room.songSendUser = false;
that.$message.success(res.msg);
}
});
},
doPlaySong(row) {
let that = this;
that.chat_room.form.pickSong = row;
that.request({
url: "song/playSong",
data: {
mid: row.mid,
room_id: that.room.room_id
},
success(res) {
that.$message.success(res.msg);
that.doSongListUpdate();
}
});
},
doSearchImage() {
let that = this;
if (!that.chat_room.form.searchImageBox.keyword) {
return;
}
that.chat_room.loading.searchImageBox = true;
axios.post(that.apiUrl + 'attach/search', {
keyword: that.chat_room.form.searchImageBox.keyword
})
.then(function (response) {
that.chat_room.data.searchImageList = response.data.data;
that.chat_room.loading.searchImageBox = false;
})
.catch(function (error) {
that.chat_room.loading.searchImageBox = false;
});
},
doPassTheSong() {
let that = this;
that.$confirm('是否确认切掉当前正在播放的歌曲?', '切歌提醒', {
confirmButtonText: '切歌',
cancelButtonText: '取消',
closeOnClickModal: false,
closeOnPressEscape: false,
type: 'warning'
}).then(function () {
that.request({
url: "song/pass",
// loading: true,
data: {
room_id: that.room.room_id,
mid: that.chat_room.song.song.mid
},
});
}).catch(function () { });
},
doDontLikeTheSong() {
let that = this;
that.request({
url: "song/pass",
// loading: true,
data: {
room_id: that.room.room_id,
mid: that.chat_room.song.song.mid
},
success(res) {
that.$message.success(res.msg);
that.addSystemTips('你选择了不喜欢这首歌,已自动静音,下首歌自动开启音乐.');
that.volume = 0;
that.config.playMusic = false;
that.$refs.audio.volume = 0;
}
});
},
doSearchSong() {
let that = this;
that.chat_room.loading.searchSongBox = true;
that.request({
url: "song/search",
data: {
keyword: that.chat_room.form.searchSongBox.keyword
},
success(res) {
that.$refs.searchSongBox.scrollTop =0;
that.chat_room.data.searchSongList = res.data;
that.chat_room.loading.searchSongBox = false;
},
error(res){
that.chat_room.loading.searchSongBox = false;
that.$message.error(res.msg);
}
});
},
doSearchVoiceBoxScroll(e){
let that = this;
if(that.chat_room.data.isLoadingVoiceBox){
return;
}
if(e.target.scrollHeight - e.target.scrollTop < 300+50){
that.chat_room.data.voiceBoxPage++;
that.doSearchVoice();
}
},
doShowVoiceSearchBox() {
let that = this;
that.chat_room.dialog.searchVoiceBox = !that.chat_room.dialog.searchVoiceBox;
if(that.chat_room.dialog.searchVoiceBox){
that.chat_room.data.voiceBoxPage=1;
that.doSearchVoice();
}
},
doSearchVoice() {
let that = this;
that.chat_room.loading.searchVoiceBox = true;
that.chat_room.data.isLoadingVoiceBox=true;
that.request({
url: "story/search",
data: {
keyword: that.chat_room.form.searchVoiceBox.keyword,
page:that.chat_room.data.voiceBoxPage,
},
success(res) {
that.chat_room.data.isLoadingVoiceBox=false;
that.chat_room.loading.searchVoiceBox = false;
if(that.chat_room.data.voiceBoxPage == 1){
that.$refs.searchVoiceBox.scrollTop =0;
that.chat_room.data.searchVoiceList = res.data;
}else{
for(let i=0;i<res.data.length;i++){
that.chat_room.data.searchVoiceList.push(res.data[i]);
}
}
},
error(res){
that.chat_room.loading.searchVoiceBox = false;
that.chat_room.data.isLoadingVoiceBox=false;
that.$message.error(res.msg);
}
});
},
doPlayVoice(row) {
let that = this;
that.$confirm('是否停掉当前正在播放的故事?', '播放提醒', {
confirmButtonText: '确定',
cancelButtonText: '取消',
closeOnClickModal: false,
closeOnPressEscape: false,
type: 'warning'
}).then(function () {
that.request({
url: "story/playStory",
loading: true,
data: {
mid: row.mid,
cid: row.cid,
room_id: that.room.room_id
},
success(res) {
that.$message.success(res.msg);
}
});
}).catch(function () { });
},
doSaveMyProfile() {
let that = this;
if (!that.chat_room.form.editMyProfile.user_name) {
this.$message.error('你确定不输入一个好听的名字吗???');
return;
}
that.request({
url: "user/updateMyInfo",
loading: true,
data: that.chat_room.form.editMyProfile,
success(res) {
that.getMyInfo();
that.$message.success(res.msg);
that.chat_room.dialog.editMyProfile = false;
}
});
},
doUploadBefore(file) {
const isJPG = file.type === 'image/jpeg' || file.type === 'image/png' || file.type === 'image/gif';
const isLt2M = file.size / 1024 / 1024 < 2;
if (!isJPG) {
this.$message.error('发送图片只能是 JPG/PNG/GIF 格式!');
}
if (!isLt2M) {
this.$message.error('发送图片大小不能超过 2MB!');
}
return isJPG && isLt2M;
},
getClipboardFiles(event) {
var that = this;
let items = event.clipboardData && event.clipboardData.items;
let file = null
if (items && items.length) {
// 检索剪切板items
for (var i = 0; i < items.length; i++) {
if (items[i].type.indexOf('image') !== -1) {
file = items[i].getAsFile()
}
}
}
if (file) {
if (that.doUploadBefore(file)) {
let param = new FormData();
param.append('file', file);
param.append('access_token', that.baseData.access_token);
param.append('plat', that.baseData.plat);
param.append('version', that.baseData.version);
let config = {
headers: {
'Content-Type': 'multipart/form-data'
}
}
// 添加请求头
axios.post(that.apiUrl + 'attach/uploadimage', param, config)
.then(function (res) {
if (res.data.code == 200) {
that.request({
url: "message/send",
data: {
where: 'channel',
to: that.websocket.params.channel,
type: 'img',
msg: res.data.data.attach_thumb,
resource: res.data.data.attach_path,
},
success(res) { }
});
} else {
that.$message.error(res.data.msg);
}
})
.catch(function (error) {
that.$message.error("上传图片发生错误");
});
}
}
return;
},
doDelete() {
},
doEnterDown(e) {
let that = this;
if (that.ctrlEnabled) {
//开启了ctrl+enter
if (window.event.ctrlKey) {
e.preventDefault();
that.doSendMessage();
}
} else {
e.preventDefault();
that.doSendMessage();
}
},
doShowOnlineList() {
let that = this;
that.request({
url: "user/online",
data: {
room_id: that.room.room_id,
},
success(res) {
that.chat_room.data.onlineList = res.data;
}
});
},
doShowSettingBox() {
let that = this;
that.chat_room.form.editMyRoom.room_name = that.room.roomInfo.room_name;
that.chat_room.form.editMyRoom.room_notice = that.room.roomInfo.room_notice;
that.chat_room.form.editMyRoom.room_type = that.room.roomInfo.room_type;
that.chat_room.form.editMyRoom.room_sendmsg = that.room.roomInfo.room_sendmsg;
that.chat_room.form.editMyRoom.room_addsong = that.room.roomInfo.room_addsong;
that.chat_room.form.editMyRoom.room_robot = that.room.roomInfo.room_robot;
that.chat_room.form.editMyRoom.room_public = that.room.roomInfo.room_public;
that.chat_room.form.editMyRoom.room_playone = that.room.roomInfo.room_playone;
that.chat_room.form.editMyRoom.room_domain = that.room.roomInfo.room_domain;
that.chat_room.form.editMyRoom.room_domain_edit = that.room.roomInfo.room_domain ? false: true;
that.chat_room.form.editMyRoom.room_password = '';
that.chat_room.form.editMyRoom.room_huya = that.room.roomInfo.room_huya;
that.chat_room.dialog.editMyRoom = true;
},
doEditMyProfile() {
let that = this;
that.chat_room.form.editMyProfile.user_name = that.urldecode(that.userInfo.user_name);
that.chat_room.form.editMyProfile.user_remark = that.userInfo.user_remark;
that.chat_room.form.editMyProfile.user_sex = that.userInfo.user_sex;
that.chat_room.form.editMyProfile.user_head = that.userInfo.user_head;
that.chat_room.form.editMyProfile.user_password = "";
that.chat_room.dialog.editMyProfile = true;
},
doSendMessage() {
let that = this;
if (!that.chat_room.message) {
return;
}
let msg = that.chat_room.message;
if (msg.indexOf("音量") == 0) {
let volume = parseInt(msg.replace(/音量/g, '').replace(/\/\//g, ''));
if (msg == '音量' + volume) {
if (volume < 0 || volume > 100) {
return;
} else {
that.volume = volume;
if (that.volume == 0) {
that.config.playMusic = false;
} else {
that.config.playMusic = true;
}
that.$refs.audio.volume = parseFloat(volume / 100);
this.addSystemTips("音量已经设置为" + volume + "%");
localStorage.setItem('volume', volume);
localStorage.setItem('volume_old', volume);
that.chat_room.message = '';
return;
}
}
}
that.chat_room.message = '';
if(that.userInfo.user_id>0){
that.chat_room.list.push({
key: "loading",
sha: "loading",
content: encodeURIComponent(msg),
type: "text",
user: that.userInfo
});
}
that.autoScroll();
that.request({
url: "message/send",
data: {
where: 'channel',
to: that.websocket.params.channel,
type: 'text',
at: that.chat_room.at,
msg: encodeURIComponent(msg)
},
success(res) {
that.chat_room.message = '';
that.chat_room.at = false;
for (let i = that.chat_room.list.length - 1; i >= 0; i--) {
if (that.chat_room.list[i].sha == 'loading') {
that.chat_room.list.splice(i, 1);
break;
}
}
},
error(res) {
that.$message.error(res.msg);
that.chat_room.message = msg;
for (let i = that.chat_room.list.length - 1; i >= 0; i--) {
if (that.chat_room.list[i].sha == 'loading') {
that.chat_room.list.splice(i, 1);
break;
}
}
}
});
},
doWebsocketHeartBeat() {
let that = this;
if (that.websocket.hardStop) {
return;
}
clearTimeout(that.websocket.heartBeatTimer);
that.websocket.heartBeatTimer = setTimeout(function () {
that.websocket.connection.send('heartBeat');
that.doWebsocketHeartBeat();
}, 30000);
},
doWebsocketError() {
let that = this;
if (that.websocket.hardStop) {
return;
}
console.log("连接已断开,10s后将自动重连");
clearTimeout(that.websocket.connectTimer);
that.websocket.connectTimer = setTimeout(function () {
that.initWebsocket();
}, 1000);
},
doGetRoomList() {
let that = this;
that.request({
url: "room/hotRooms",
success(res) {
that.room.list = res.data;
that.room.showDialog = true;
}
});
},
doSearchRoomById() {
let that = this;
let room_id = that.room.search_id;
if (!room_id) {
return;
}
that.doJoinRoomById(room_id);
},
doJoinRoomById(room_id) {
let that = this;
that.room.showDialog = false;
that.request({
url: "room/getRoomInfo",
data: {
room_id: room_id
},
success(res) {
let room = res.data;
that.room.room_id = room.room_id;
that.room.roomInfo = room;
// if(room.room_type==5){
// if(location.href.indexOf('https://')>=0){
// location.replace(location.href.replace('https://','http://'));
// return;
// }
// }else{
// if(location.href.indexOf('https://')<0 && location.href.indexOf('bbbug.com')>=0){
// location.replace(location.href.replace('http://','https://'));
// return;
// }
// }
that.doGetRoomData();
},
error(res) {
switch(res.code){
case 301:
that.$alert(res.msg, '房间封禁', {
confirmButtonText: '确定',
callback: function () {
if(!that.room.roomInfo){
that.doJoinRoomById(888);
}
}
});
break;
case 302:
that.$prompt('请输入该房间的密码后进入', '加密房间', {
confirmButtonText: '验证',
showClose: false,
closeOnClickModal: false,
closeOnPressEscape: false,
closeOnHashChange: false,
center: true,
showCancelButton: that.room.roomInfo ? true : false,
}).then(function (password) {
that.checkRoomPassword(room_id, password.value, function (result, msg) {
if (result) {
that.room.room_id = room_id;
localStorage.setItem('room_id', room_id);
that.lrcString = '';
that.lockScreenData.nowMusicLrcText = '';
that.doGetRoomData();
} else {
if (that.room.roomInfo) {
that.$alert(msg, '密码错误', {
confirmButtonText: '确定',
callback: function () { }
});
} else {
that.$confirm(msg, '密码错误', {
confirmButtonText: '重试',
cancelButtonText: '去大厅',
type: 'warning'
}).then(function () {
that.doJoinRoomById(room_id);
}).catch(function () {
that.doJoinRoomById(888);
});
}
}
});
}).catch(function (e) {
});
break;
default:
that.$confirm(res.msg, '进入失败', {
confirmButtonText: '重试',
cancelButtonText: '去大厅',
type: 'warning'
}).then(function () {
that.doJoinRoomById(room_id);
}).catch(function () {
that.doJoinRoomById(888);
});
}
},
});
},
doSubmitCreateRoom(formName) {
let that = this;
that.$refs[formName].validate(function (valid) {
if (valid) {
that.request({
url: "room/create",
loading: true,
data: that.room_create.form,
success(res) {
that.room_create.showPage=false;
that.getMyInfo();
that.$confirm('你的私人房间创建成功,是否立即进入?', '创建成功', {
confirmButtonText: '进入',
cancelButtonText: '返回列表',
type: 'warning'
}).then(function () {
that.doEnterMyRoom();
}).catch(function () { });
}
});
}
});
},
doEnterMyRoom() {
let that = this;
if (that.userInfo.myRoom) {
that.doJoinRoomById(that.userInfo.myRoom.room_id);
} else {
that.$message.error('你还没有创建自己的房间呀~');
}
},
doSendRandCode() {
let that = this;
that.request({
url: "sms/email",
loading: true,
data: {
email: that.login.form.user_account
},
success(res) {
that.$message.success(res.msg);
}
});
},
do_login_email_changed() {
let that = this;
if (that.login.form.user_account) {
that.login.validEmail = true;
} else {
that.login.validEmail = false;
}
},
do_login_form_submit(formName) {
let that = this;
that.$refs[formName].validate(function (valid) {
if (valid) {
that.request({
url: "user/login",
loading: true,
data: that.login.form,
success(res) {
that.baseData.access_token = res.data.access_token;
localStorage.setItem('access_token', that.baseData.access_token);
localStorage.setItem('user_account', that.login.form.user_account);
that.$message.success('登录成功!');
that.getMyInfo(function () {
that.login.showPage = false;
that.doJoinRoomById(that.room.room_id);
});
}
});
}
});
},
doLogout() {
let that = this;
that.userInfo = that.guestUserInfo;
that.baseData.access_token = that.guestUserInfo.access_token;
that.login.showPage = false;
},
doShowLoginBox() {
let that = this;
that.login.showPage = true;
},
createLrcObj(lrc) {
var oLRC = {
ti: "", //歌曲名
ar: "", //演唱者
al: "", //专辑名
by: "", //歌词制作人
offset: 0, //时间补偿值,单位毫秒,用于调整歌词整体位置
ms: [] //歌词数组{t:时间,c:歌词}
};
if (lrc.length == 0) {
return;
}
var lrcs = lrc.split('\n');
//用回车拆分成数组
for (var i in lrcs) {
//遍历歌词数组
lrcs[i] = lrcs[i].replace(/(^\s*)|(\s*$)/g, "");
//去除前后空格
var t = lrcs[i].substring(lrcs[i].indexOf("[") + 1, lrcs[i].indexOf("]"));
//取[]间的内容
var s = t.split(":");
//分离:前后文字
if (isNaN(parseInt(s[0]))) {
//不是数值
for (var i in oLRC) {
if (i != "ms" && i == s[0].toLowerCase()) {
oLRC[i] = s[1];
}
}
} else {
//是数值
var arr = lrcs[i].match(/\[(\d+:.+?)\]/g);
//提取时间字段,可能有多个
var start = 0;
for (var k in arr) {
start += arr[k].length; //计算歌词位置
}
var content = lrcs[i].substring(start); //获取歌词内容
if (!content) {
continue;
}
for (var k in arr) {
var t = arr[k].substring(1, arr[k].length - 1); //取[]间的内容
var s = t.split(":");
//分离:前后文字
oLRC.ms.push({
//对象{t:时间,c:歌词}加入ms数组
t: parseFloat((parseFloat(s[0]) * 60 + parseFloat(s[1])).toFixed(3)),
c: content
});
}
}
}
oLRC.ms.sort(function (a, b) {
//按时间顺序排序
return a.t - b.t;
});
return oLRC;
}
}
});
</script>
</body>
</html>
PHP
1
https://gitee.com/linzhil/ChatWEB.git
git@gitee.com:linzhil/ChatWEB.git
linzhil
ChatWEB
BBBUG Frontend
master

搜索帮助