message.vue 84 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075
  1. <template>
  2. <view class="page" :style="{overflow: 'hidden','--custom-font-size': custom_font_size+'px'}">
  3. <!-- #ifdef APP-PLUS -->
  4. <serving-view :list_id="list_id" @setState="setSeringState" :show="showServing" :state="servingState"
  5. @closeServing="showServing = false" ref="serving"></serving-view>
  6. <!-- #endif -->
  7. <view class="page-content">
  8. <view class="gong-gao-content" v-if="msgList.type == 1">
  9. <view class="member-image-logo">
  10. <view class="member-content" v-for="(item,i) in memberPhotos" :key="i">
  11. <image class="img-logo" :src="staticPhoto+ item.photo" @tap="toUserDetail(item)"></image>
  12. </view>
  13. <view class="jiazai" v-if="memberPhotos.length >=5" @tap="group_info">
  14. <image src="/static/theme/default/jiazai.png"></image>
  15. </view>
  16. </view>
  17. <view class="gong-gao-content-info" v-if="0">
  18. <view class="iconfont-im icon-gonggao gong-gao-content-info-icon"></view>
  19. <text-scroll :text="notice" ref="scrollNotice"></text-scroll>
  20. </view>
  21. <!--<view class="member-image-logo">-->
  22. <!--<image src="https://im.smiaoshen.com/static/photo/default_man/300.jpg"></image>-->
  23. <!--</view>-->
  24. </view>
  25. <view class="content">
  26. <scroll-view class="msg-list" :style="{height:scrollHeight}" scroll-y="true"
  27. :scroll-with-animation="scrollAnimation" :scroll-into-view="scrollToView"
  28. @scrolltoupper="loadHistory" :upper-threshold="30" id="scrollview" :scroll-top="scrollTop"
  29. @scroll="scrollEven" @touchstart="hideDrawer(3)">
  30. <!--<view class="loading"-->
  31. <!--v-if="isHistoryLoading">-->
  32. <!--<view class="spinner">-->
  33. <!--<view class="rect1"></view>-->
  34. <!--<view class="rect2"></view>-->
  35. <!--<view class="rect3"></view>-->
  36. <!--<view class="rect4"></view>-->
  37. <!--<view class="rect5"></view>-->
  38. <!--</view>-->
  39. <!--</view>-->
  40. <uni-load-more status="noMore" v-if="noMore && !(isHistoryLoading)" />
  41. <view class="row" v-for="(row,index) in msgList.list" :key="index" :id="'msg' + row.msg.id">
  42. <!-- 系统消息 -->
  43. <block v-if="row.type==1">
  44. <view :class="['system',msgList.type == 1 && index == 0 ? 'sys':'']"
  45. :style="{padding:'10upx 0',marginBottom:'10upx'}">
  46. <!-- 文字消息-->
  47. <view v-if="row.msg.type==0 && row.msg.content && row.msg.content.text" class="text">
  48. {{row.msg.content.text}}
  49. </view>
  50. <!-- 领取红包消息 -->
  51. <view v-if="row.msg.type==5" class="red-envelope" style="letter-spacing:4upx;">
  52. <image src="/static/img/red-envelope-chat.png" :lazy-load="true" />
  53. <!-- {{row.msg}} -->
  54. <block
  55. v-if="row.msg.content.rid_user_id == my_data.id && row.msg.content.user_id == my_data.id">
  56. 我领取了自己发出的
  57. </block>
  58. <block
  59. v-else-if="row.msg.content.rid_user_id != my_data.id && row.msg.content.user_id == my_data.id">
  60. 我领取了{{row.msg.content.rid_nickname}}发出的
  61. </block>
  62. <block
  63. v-else-if="row.msg.content.rid_user_id == my_data.id && row.msg.content.user_id != my_data.id">
  64. {{row.msg.content.nickname}}领取了我发出的
  65. </block>
  66. <block v-else>
  67. {{row.msg.content.nickname}}领取了{{row.msg.content.rid_nickname}}发出的
  68. </block>
  69. <text style="color: red;" @tap="toDetails(row.msg.content.rid)">红包</text>
  70. </view>
  71. </view>
  72. </block>
  73. <block
  74. v-if="row.type == 0 && (index == 0 || (row.msg.time - msgList.list[index - 1].msg.time > 300))">
  75. <view class="system" style="margin-bottom: 10upx">
  76. <!-- 文字消息 -->
  77. <view class="text" style="color: #ffffff;border-radius:12px;font-weight:600">
  78. {{ timestampFormat(row.msg.time + '') }}
  79. </view>
  80. </view>
  81. </block>
  82. <!-- 用户消息 -->
  83. <block v-if="row.type==0">
  84. <!-- 自己发出的消息 -->
  85. <view class="my" v-if="row.msg.user_info.uid == my_data.id ">
  86. <!-- 左-消息 -->
  87. <view class="left"
  88. @longtap="msgAction(row.msg.id +'',row.msg.user_info.uid + '',row.msg.content,row.msg.type)"
  89. :id="row.msg.id">
  90. <image v-if="row.msg.time<=nowReadTime" src="/static/img/read.png" mode="widthFix"
  91. style="width: 30upx;margin-right: 10upx;"></image>
  92. <image v-else src="/static/img/unread.png" mode="widthFix"
  93. style="width: 30upx;margin-right: 10upx;">
  94. </image>
  95. <!-- 文字消息 非图片-->
  96. <view v-if="row.msg.type==0 && !isImage(row.msg.content.text)" class="bubble">
  97. <rich-text :nodes="row.msg.content.text ? getHtml(row.msg.content.text) : ' '"
  98. space="true" selectable="true" />
  99. </view>
  100. <!-- 文字消息 图片链接 -->
  101. <view v-if="row.msg.type==0 && isImage(row.msg.content.text)" class="bubble"
  102. @tap="showPic2(row.msg.content.text)">
  103. <image :src="row.msg.content.text" :style="{'width':'200px','height':'200px'}"
  104. mode="widthFix" :lazy-load="true" />
  105. </view>
  106. <!-- 语言消息 -->
  107. <view v-if="row.msg.type==1" class="bubble voice" @tap="playVoice(row.msg)"
  108. :class="playMsgid == row.msg.id?'play':''">
  109. <view class="length">{{row.msg.content.length}}</view>
  110. <view class="icon my-voice"></view>
  111. </view>
  112. <!-- 图片消息 -->
  113. <view v-if="row.msg.type==2" class="bubble img" @tap="showPic1(row.msg)">
  114. <image :src="(staticPath + list_id + '/' + row.msg.content.url)"
  115. :style="{'width': row.msg.content.w+'px','height': row.msg.content.h+'px'}"
  116. mode="widthFix" :lazy-load="true" />
  117. </view>
  118. <!-- 视频消息 -->
  119. <view v-if="row.msg.type==3" class="bubble img">
  120. <image :src=" staticPath + row.msg.content.full_movie"
  121. style="width: 320px;height: 240px">
  122. </image>
  123. <image class="bubble-bofang" src="/static/theme/default/my/bofang.png"
  124. style="width: 50px;height: 50px;" @tap="autoVideo(row.msg)"></image>
  125. </view>
  126. <!-- 红包 -->
  127. <view v-if="row.msg.type==5" class="bubble red-envelope"
  128. @tap="openRedEnvelope(row.msg,index)">
  129. <image src="/static/img/red-envelope.png" :lazy-load="true"
  130. :style="{'opacity':(receive_list.indexOf(row.msg.content.rid))< 0 ? 1 : 0.6}">
  131. </image>
  132. <view class="tis">
  133. {{(receive_list.indexOf(row.msg.content.rid)) <0?'恭喜发财,大吉大利':'已领取'}}
  134. </view>
  135. <view class="blessing">
  136. <view class="info">
  137. {{row.msg.content.blessing}}
  138. </view>
  139. <view class="has-get-red">
  140. 点击打开红包
  141. </view>
  142. <!--{{row.msg.content.blessing}}-->
  143. </view>
  144. </view>
  145. <!-- 在线视频 -->
  146. <view v-if="row.msg.type==6" class="bubble">
  147. <view> {{row.msg.content.text}}
  148. </view>
  149. <text style="margin-left:2px" class="iconfont-im">&#xe619;
  150. </text>
  151. </view>
  152. <!-- 在线音频-->
  153. <view v-if="row.msg.type==7" class="bubble">
  154. <view> {{row.msg.content.text}}
  155. </view>
  156. <text style="margin-left:2px" class="iconfonts">&#xe60b;
  157. </text>
  158. </view>
  159. <!--卡片-->
  160. <view v-if="row.msg.type==8" class="send-card" @tap="getCard(row.msg)">
  161. <view class="send-card-content">
  162. <image :src="staticPhoto+row.msg.content.face" :lazy-load="true"
  163. style="width: 85upx;height: 85upx;"></image>
  164. <text>{{row.msg.content.nickname}}</text>
  165. </view>
  166. <view class="send-card-content-text">
  167. <text>名片</text>
  168. </view>
  169. </view>
  170. <!--戳一戳-->
  171. <view v-if="row.msg.type==9" class="bubble img">
  172. <image src="/static/theme/default/chuoyichuo.gif" :lazy-load="true"
  173. style="height: 70px;width: 130px;" mode="heightFix" />
  174. </view>
  175. <!-- 位置-->
  176. <view v-if="row.msg.type==10" class="bubble" @tap="openMap(row.msg.content)">
  177. <view class="address-flex">
  178. <view class="address-name">
  179. <text>{{row.msg.content && row.msg.content.name}}</text>
  180. <text
  181. class="text-gray">{{row.msg.content && row.msg.content.address}}</text>
  182. </view>
  183. <image class="fun-icon" src="../../static/theme/default/position.png"
  184. mode="widthFix"></image>
  185. </view>
  186. </view>
  187. <!-- 文件 -->
  188. <view v-if="row.msg.type==11" class="bubble"
  189. @tap="downFile(staticPath+ list_id+'/' + row.msg.content.url)">
  190. <view class="address-flex">
  191. <view class="address-name">
  192. <text>{{row.msg.content && row.msg.content.name}}</text>
  193. <text
  194. class="text-gray">{{row.msg.content && row.msg.content.length}}kb</text>
  195. </view>
  196. <image class="fun-icon" src="../../static/theme/default/file.png"
  197. mode="widthFix"></image>
  198. </view>
  199. </view>
  200. </view>
  201. <!-- 右-头像 -->
  202. <view class="right" @tap="goDetails(row.msg.user_info.uid,row)">
  203. <image
  204. :src="(row.msg.is_niming == 1) ? '/static/theme/default/my/niming.png' : myPhoto"
  205. :lazy-load="true" style="border-radius: 10px;" @error="imageError2" />
  206. </view>
  207. </view>
  208. <!-- 别人发出的消息 -->
  209. <view class="other" v-if="row.msg.user_info.uid != my_data.id">
  210. <!-- 左-头像 -->
  211. <view class="left">
  212. <image @longtap="showAction(row)" @tap="goDetails(row.msg.user_info.uid,row)"
  213. :src="(row.msg.is_niming == 1)? '/static/theme/default/my/niming.png' : (staticPhoto + row.msg.user_info.face)"
  214. :lazy-load="true" style="border-radius: 10px;" :data-id="index"
  215. @error="imageError" class="u-logo"/>
  216. <view class="action" v-if="row.showAction">
  217. <view class="action-item" @click="addFriendChat(row)">
  218. @TA
  219. </view>
  220. <view class="action-line">
  221. </view>
  222. <view class="action-item" @click="selectMember(row)">
  223. 禁言
  224. </view>
  225. <view class="action-line">
  226. </view>
  227. <view class="action-item" @click="selectRemoveMember(row)">
  228. 踢出
  229. </view>
  230. </view>
  231. </view>
  232. <!-- 右-用户名称-时间-消息 -->
  233. <view class="right"
  234. @longtap="msgAction(row.msg.id +'',row.msg.user_info.uid + '',row.msg.content,row.msg.type)">
  235. <!-- <view class="username">
  236. <view class="name">{{row.msg.user_info.username}}</view> <view class="time">{{row.msg.time}}</view>
  237. </view> -->
  238. <!-- 文字消息 -->
  239. <view v-if="row.msg.type==0 && !isImage(row.msg.content.text)" class="bubble">
  240. <rich-text :nodes="row.msg.content.text ? getHtml(row.msg.content.text) : ' '"
  241. space="true" />
  242. </view>
  243. <!-- 文字消息 图片链接 -->
  244. <view v-if="row.msg.type==0 && isImage(row.msg.content.text)" class="bubble"
  245. @tap="showPic2(row.msg.content.text)">
  246. <image :src="row.msg.content.text" :style="{'width':'200px','height':'auto'}"
  247. mode="widthFix" :lazy-load="true" />
  248. </view>
  249. <!-- 语音消息 -->
  250. <view v-if="row.msg.type==1" class="bubble voice" @tap="playVoice(row.msg)"
  251. :class="playMsgid == row.msg.id?'play':''">
  252. <view class="icon other-voice"></view>
  253. <view class="length">{{row.msg.content.length}}</view>
  254. </view>
  255. <!-- 图片消息 -->
  256. <view v-if="row.msg.type==2" class="bubble img" @tap="showPic1(row.msg)">
  257. <image :src="(staticPath + list_id + '/' + row.msg.content.url)"
  258. :style="{'width': row.msg.content.w+'px','height': row.msg.content.h+'px'}"
  259. mode="widthFix" :lazy-load="true" />
  260. </view>
  261. <!-- 视频消息 -->
  262. <view v-if="row.msg.type==3" class="bubble img">
  263. <image :src="staticPath + row.msg.content.full_movie"
  264. style="width: 320px;height: 240px"></image>
  265. <image class="bubble-bofang-left" src="/static/theme/default/my/bofang.png"
  266. style="width: 50px;height: 50px;" @tap="autoVideo(row.msg)"></image>
  267. </view>
  268. <!-- 红包 -->
  269. <view v-if="row.msg.type==5" class="bubble red-envelope"
  270. @tap="openRedEnvelope(row.msg,index)">
  271. <image src="/static/img/red-envelope-o.png" :lazy-load="true"
  272. :style="{'opacity':(receive_list.indexOf(row.msg.content.rid))< 0 ? 1 : 0.6}">
  273. </image>
  274. <view class="tis">
  275. {{(receive_list.indexOf(row.msg.content.rid)) <0?'恭喜发财,大吉大利':'已领取'}}
  276. </view>
  277. <view class="blessing">
  278. <view class="info">
  279. {{row.msg.content.blessing}}
  280. </view>
  281. <view class="has-get-red">
  282. 点击打开红包
  283. </view>
  284. <!--{{row.msg.content.blessing}}-->
  285. </view>
  286. </view>
  287. <view v-if="row.msg.type==6" class="bubble">
  288. <text style="margin-right:2px" class="iconfont-im">&#xe619;
  289. </text>
  290. {{row.msg.content.text}}
  291. </view>
  292. <view v-if="row.msg.type==7" class="bubble">
  293. <text style="margin-right:2px" class="iconfonts">&#xe60b;
  294. </text>
  295. {{row.msg.content.text}}
  296. </view>
  297. <view v-if="row.msg.type==8" class="send-card" @tap="getCard(row.msg)">
  298. <view class="send-card-content">
  299. <image :src="staticPhoto+row.msg.content.face" :lazy-load="true"
  300. style="width: 85upx;height: 85upx;"></image>
  301. <text>{{row.msg.content.nickname}}</text>
  302. </view>
  303. <view class="send-card-content-text">
  304. <text>名片</text>
  305. </view>
  306. </view>
  307. <!-- 戳一戳 -->
  308. <view v-if="row.msg.type==9" class="bubble img" @tap="showPic(row.msg)">
  309. <image src="/static/theme/default/youchuo.gif" :lazy-load="true"
  310. style="width: 70px;height: 70px;" />
  311. </view>
  312. <!-- 位置-->
  313. <view v-if="row.msg.type==10" class="bubble" @tap="openMap(row.msg.content)">
  314. <view class="address-flex">
  315. <view class="address-name">
  316. <text>{{row.msg.content && row.msg.content.name}}</text>
  317. <text
  318. class="text-gray">{{row.msg.content && row.msg.content.address}}</text>
  319. </view>
  320. <image class="fun-icon" src="../../static/theme/default/position.png"
  321. mode="widthFix"></image>
  322. </view>
  323. </view>
  324. <!-- 文件 -->
  325. <view v-if="row.msg.type==11" class="bubble"
  326. @tap="downFile(staticPath+ list_id+'/' + row.msg.content.url)">
  327. <view class="address-flex">
  328. <view class="address-name">
  329. <text>{{row.msg.content && row.msg.content.name}}</text>
  330. <text
  331. class="text-gray">{{row.msg.content && row.msg.content.length}}kb</text>
  332. </view>
  333. <image class="fun-icon" src="../../static/theme/default/file.png"
  334. mode="widthFix"></image>
  335. </view>
  336. </view>
  337. </view>
  338. </view>
  339. </block>
  340. </view>
  341. </scroll-view>
  342. </view>
  343. <!-- 抽屉栏 -->
  344. <view class="popup-layer" :class="popupLayerClass" @touchmove.stop.prevent="discard">
  345. <!-- 表情 -->
  346. <swiper class="emoji-swiper" :class="{hidden:hideEmoji}" :indicator-dots="true" duration="150">
  347. <swiper-item v-for="(page,pid) in emojiList" :key="pid">
  348. <view v-for="(em,eid) in page" :key="eid" @tap="addEmoji(em)">
  349. <image :src="'/static/img/emoji/' + em.url" :lazy-load="true" />
  350. </view>
  351. </swiper-item>
  352. </swiper>
  353. <!-- 更多功能 相册-拍照-红包 -->
  354. <swiper class="more-layer" style="height:50vw" :indicator-dots="true" indicator-active-color="#51c9c3"
  355. :class="{hidden:hideMore || !hideEmoji}" duration="150">
  356. <swiper-item>
  357. <view class="list">
  358. <!-- <view class="list-box" @tap="videoCall(1)" v-if="msgList.type == 0">
  359. <image class="fun-icon" src="../../static/theme/default/message/concat.png"
  360. mode="heightFix">
  361. <view class="tool_text">视频通话</view>
  362. </view> -->
  363. <!-- <view class="list-box" @tap="videoCall(2)" v-if="msgList.type == 0">
  364. <image class="fun-icon" src="../../static/theme/default/message/voice.png"
  365. mode="heightFix">
  366. <view class="tool_text">语音通话</view>
  367. </view> -->
  368. <view class="list-box" @tap="chooseImage">
  369. <image class="fun-icon" src="../../static/theme/default/Image.png" mode="heightFix">
  370. </image>
  371. <view class="tool_text">相册</view>
  372. </view>
  373. <view class="list-box" @tap="camera">
  374. <image class="fun-icon" src="../../static/theme/default/shooting_icon.png"
  375. mode="heightFix">
  376. </image>
  377. <view class="tool_text">拍摄</view>
  378. </view>
  379. <!-- <view class="list-box" @tap="video">
  380. <image class="fun-icon" src="../../static/theme/default/message/video.png"
  381. mode="heightFix">
  382. </image>
  383. <view class="tool_text">视频</view>
  384. </view>
  385. <view class="list-box" @tap="handRedEnvelopes">
  386. <image class="fun-icon" src="../../static/theme/default/envelope_icon.png"
  387. mode="heightFix">
  388. </image>
  389. <view class="tool_text">红包</view>
  390. </view> -->
  391. <view class="list-box" @tap="video">
  392. <image class="fun-icon" src="../../static/theme/default/message/video.png"
  393. mode="heightFix">
  394. </image>
  395. <view class="tool_text">视频</view>
  396. </view>
  397. <view class="list-box" @tap="handRedEnvelopes">
  398. <image class="fun-icon" src="../../static/theme/default/envelope_icon.png"
  399. mode="heightFix">
  400. </image>
  401. <view class="tool_text">红包</view>
  402. </view>
  403. </view>
  404. <view class="list" style="margin-top: 8upx;">
  405. <view class="list-box" @tap="chooseChuo">
  406. <image class="fun-icon" src="../../static/theme/default/tool_icon.png" mode="heightFix">
  407. </image>
  408. <view class="tool_text">戳一戳</view>
  409. </view>
  410. <view class="list-box" @tap="sendPos">
  411. <image class="fun-icon" src="../../static/theme/default/location_icon.png"
  412. mode="heightFix">
  413. </image>
  414. <view class="tool_text2">位置</view>
  415. </view>
  416. <!-- <view class="list-box" @tap="videoCall(1)" v-if="msgList.type == 0">
  417. <image class="fun-icon" src="../../static/theme/default/message/concat.png"
  418. mode="heightFix">
  419. <view class="tool_text">视频通话</view>
  420. </view>
  421. <view class="list-box" @tap="videoCall(2)" v-if="msgList.type == 0">
  422. <image class="fun-icon" src="../../static/theme/default/message/voice.png"
  423. mode="heightFix">
  424. <view class="tool_text">语音通话</view>
  425. </view> -->
  426. <view class="list-box" @tap="sayCall()" v-if="msgList.type == 1 && 0">
  427. <text class="iconfont-im icon-niming" style="font-size:50upx;">
  428. </text>
  429. <view class="tool_text">{{niming_msg}}</view>
  430. </view>
  431. <view class="list-box" @tap="zhendong" v-if="msgList.type == 1 && is_main">
  432. <view class="iconfont-im icon-zhendong"></view>
  433. <view class="tool_text2">振动</view>
  434. </view>
  435. <view class="list-box" @tap="showQiang()"
  436. v-if="msgList.type == 1 && vendor_status && is_main">
  437. <text class="iconfont-im icon-qiang" style="font-size:50upx;">
  438. </text>
  439. <view class="tool_text">发包</view>
  440. </view>
  441. <view class="list-box" @tap="chooseCard">
  442. <image class="fun-icon" src="../../static/theme/default/contact_icon.png"
  443. mode="heightFix">
  444. </image>
  445. <view class="tool_text2">名片</view>
  446. </view>
  447. <view class="list-box" @tap="chooseLike">
  448. <image class="fun-icon" src="../../static/theme/default/collection_icon.png"
  449. mode="heightFix">
  450. </image>
  451. <view class="tool_text">收藏</view>
  452. </view>
  453. </view>
  454. </swiper-item>
  455. <swiper-item>
  456. <view class="list">
  457. <view class="list-box" @tap="chooseFile">
  458. <image class="fun-icon" src="../../static/theme/default/file_icon.png" mode="heightFix">
  459. </image>
  460. <view class="tool_text">文件</view>
  461. </view>
  462. </view>
  463. </swiper-item>
  464. </swiper>
  465. </view>
  466. <view class="input-box" v-if="msgList.is_msg">
  467. <view
  468. style="text-align: center !important;width:750upx;line-height: 100upx;border-top: #c9c9c9 solid 2upx;">
  469. 全员禁言中...
  470. </view>
  471. </view>
  472. <!-- @touchmove.stop.prevent="discard" -->
  473. <!-- 底部输入栏 -->
  474. <view class="input-box" :class="popupLayerClass" v-else>
  475. <!-- H5下不能录音,输入栏布局改动一下 -->
  476. <!-- #ifndef H5 -->
  477. <view class="voice">
  478. <view class="icon" :class="isVoice?'jianpan':'yuyin'" @tap="switchVoice"></view>
  479. </view>
  480. <!-- #endif -->
  481. <!-- #ifdef H5 -->
  482. <view class="more" @tap="showMore">
  483. <view class="icon add"></view>
  484. </view>
  485. <!-- #endif -->
  486. <view class="textbox">
  487. <view class="voice-mode" :class="[isVoice?'':'hidden',recording?'recording':'']"
  488. @touchstart="voiceBegin" @touchmove.stop.prevent="voiceIng" @touchend="voiceEnd"
  489. @touchcancel="voiceCancel">
  490. {{voiceTis}}
  491. </view>
  492. <view class="text-mode" :class="isVoice?'hidden':''">
  493. <view class="box">
  494. <textarea auto-height="true" confirm-type="search" @confirm="sendText" @input="inputText"
  495. :value="textMsg" @focus="textareaFocus" :maxlength="-1" :show-confirm-bar="false"
  496. style="max-height: 190upx;overflow:auto;border: 1px solid black; border-radius: 17px;padding-top: 4px;padding-bottom: 4px; " />
  497. </view>
  498. <view class="em" @tap="chooseEmoji">
  499. <view class="icon biaoqing"></view>
  500. </view>
  501. </view>
  502. </view>
  503. <!-- #ifndef H5 -->
  504. <view :class="iconShow" @tap="showMore">
  505. <view class="icon add"></view>
  506. </view>
  507. <!-- #endif -->
  508. <view class="send" :class="sendMsgClass" @tap="sendText">
  509. <view class="btn">发送</view>
  510. </view>
  511. </view>
  512. </view>
  513. <view v-show="showVedio" class="showVedio">
  514. <!-- <video :src="videoPath"
  515. style="height: 100%;width: 100%"
  516. id="myVideo"
  517. object-fit="fill"
  518. airplay="allow" /> -->
  519. <video autoplay="true" object-fit="fill" page-gesture="true" controls="false"
  520. style="height: 100%;width: 100%" id="myVideo" :src="videoPath" @error="videoErrorCallback">
  521. <!-- <cover-view
  522. @tap="showVedio = false"> -->
  523. <cover-image @tap="showVedio = false" src="/static/theme/default/my/close.png" class="cloneBut">
  524. </cover-image>
  525. <!-- </cover-view> -->
  526. </video>
  527. </view>
  528. <!-- #ifndef H5 -->
  529. <!-- 录音UI效果 -->
  530. <view class="record" :class="recording?'':'hidden'">
  531. <view class="ing" :class="willStop?'hidden':''">
  532. <view class="icon luyin2"></view>
  533. </view>
  534. <view class="cancel" :class="willStop?'':'hidden'">
  535. <view class="icon chehui"></view>
  536. </view>
  537. <view class="tis" :class="willStop?'change':''">{{recordTis}}</view>
  538. </view>
  539. <!-- #endif -->
  540. <!-- 红包弹窗 -->
  541. <view class="windows" :class="windowsState">
  542. <!-- 遮罩层 -->
  543. <view class="mask" @touchmove.stop.prevent="discard" @tap="closeRedEnvelope"></view>
  544. <view class="layer" @touchmove.stop.prevent="discard">
  545. <view class="open-redenvelope">
  546. <view class="top">
  547. <view class="close-btn">
  548. <view class="icon close" @tap="closeRedEnvelope"></view>
  549. </view>
  550. <image :src="staticPhoto+redenvelopeData.face" :lazy-load="true"></image>
  551. </view>
  552. <view class="from">来自{{redenvelopeData.from}}的红包</view>
  553. <view class="blessing">{{redenvelopeData.blessing}}</view>
  554. <view class="money" @tap="openRed(redenvelopeData)">
  555. <image :class="luckbtn" src="/static/theme/default/my/red_2.png"
  556. style="width: 180upx; height: 180upx;">
  557. </image>
  558. </view>
  559. <view class="showDetails" @tap="toDetails(redenvelopeData.rid)">
  560. 查看领取详情
  561. <view class="icon to"></view>
  562. </view>
  563. </view>
  564. </view>
  565. </view>
  566. <uni-popup ref="popup2" :show="videPoup" position="bottom" mode="666">
  567. <view class="video-but-view">
  568. <button class="video-but" type="primary" @tap="videoBut('video')" :loading="videoLoading">视频聊天</button>
  569. <button class="video-but" type="primary" @tap="videoBut('voice')" :loading="voiceLoading">语音聊天</button>
  570. <button type="default" @click="videPoup=false">取消</button>
  571. </view>
  572. </uni-popup>
  573. <uni-popup ref="popup" type="confirm">
  574. <uni-popup-confirm title="温馨提示" :content="popuMsg" @confirm="confirm"> </uni-popup-confirm>
  575. </uni-popup>
  576. <uni-popup ref="qiang" type="qiang">
  577. <uni-popup-qiang title="开启发包" :status="miaoqiang + ''" :content="popuMsg" @confirm="goQiang">
  578. </uni-popup-qiang>
  579. </uni-popup>
  580. <!-- 上传文件 -->
  581. <nk-select-file v-model="showUploadFile" @confirm="uploadAFile"></nk-select-file>
  582. <uni-popup ref="popup_friends" type="bottom">
  583. <view class="popup_friends" :style="{height:popHeight+'px'}">
  584. <view class="popup_friends-top">
  585. </view>
  586. <select-friend :list_id="list_id" @close="closeFriends">
  587. </select-friend>
  588. </view>
  589. </uni-popup>
  590. </view>
  591. </template>
  592. <script>
  593. import uniLoadMore from "../../components/uni-ui/uni-load-more/uni-load-more.vue";
  594. import emoj_data from "../../static/js/message/emoji_data.js";
  595. import _get from "../../common/_get";
  596. import _hook from "../../common/_hook";
  597. import _action from "../../common/_action";
  598. import _data from "../../common/_data";
  599. import htmlParser from "../../common/html-parser";
  600. import uniPopup from "../../components/uni-popup/uni-popup.vue";
  601. import uniPopupConfirm from "../../components/uni-popup/uni-popup-confirm.vue";
  602. import uniPopupQiang from "../../components/uni-popup/uni-popup-qiang.vue";
  603. import textScroll from "../../components/textScroll/textScroll.vue";
  604. import nkSelectFile from "@/components/nk-select-file/nk-select-file.vue";
  605. import {
  606. mapState,
  607. mapMutations
  608. } from "vuex";
  609. import selectFriend from "./select_friend.vue";
  610. import {
  611. genTestUserSig
  612. } from "@/debug/GenerateTestUserSig.js";
  613. export default {
  614. components: {
  615. uniLoadMore,
  616. uniPopup,
  617. uniPopupConfirm,
  618. uniPopupQiang,
  619. textScroll,
  620. nkSelectFile,
  621. selectFriend,
  622. },
  623. data() {
  624. return {
  625. servingState: 3,
  626. onLine: false,
  627. showServing: false,
  628. memberPhotos: [],
  629. is_main: 0,
  630. nowReadTime: 1635013026,
  631. redTimer: null,
  632. notice: "",
  633. scrollInfo: {
  634. input_box_height1: 0,
  635. input_box_height2: 0,
  636. totall_height: 0,
  637. },
  638. scrollHeight: "0px",
  639. niming_msg: "匿名",
  640. videoContext: null,
  641. videoPath: "",
  642. showVedio: false,
  643. receive_list: [],
  644. luckbtn: "",
  645. scrollTop: 0,
  646. chat_id: "",
  647. //文字消息
  648. videPoup: false,
  649. videPlay: false,
  650. voiceLoading: false,
  651. videoLoading: false,
  652. textMsg: "",
  653. //消息列表
  654. isHistoryLoading: false,
  655. scrollAnimation: false,
  656. scrollToView: "",
  657. msgList: {
  658. show_name: "",
  659. list: [],
  660. type: 0,
  661. is_msg: 0,
  662. is_action: 0,
  663. },
  664. msgImgList: [],
  665. noMore: 0,
  666. isVoice: false,
  667. voiceTis: "按住 说话",
  668. recordTis: "手指上滑 取消发送",
  669. recording: false,
  670. willStop: false,
  671. initPoint: {
  672. identifier: 0,
  673. Y: 0,
  674. },
  675. recordTimer: null,
  676. recordLength: 0,
  677. // #ifdef APP-PLUS
  678. // call: uni.requireNativePlugin("TUICallingUniPlugin-TUICallingModule"),
  679. // call: uni.requireNativePlugin('TencentCloud-TUICallKit'),
  680. // #endif
  681. playMsgid: null,
  682. VoiceTimer: null,
  683. // 抽屉参数
  684. popupLayerClass: "",
  685. // more参数
  686. hideMore: true,
  687. //表情定义
  688. hideEmoji: true,
  689. emojiList: emoj_data.emoji_list,
  690. //表情图片图床名称 ,由于我上传的第三方图床名称会有改变,所以有此数据来做对应,您实际应用中应该不需要
  691. //onlineEmoji: emoj_data.online_emoji,
  692. //红包相关参数
  693. windowsState: "",
  694. redenvelopeData: {
  695. rid: null, //红包ID
  696. from: null,
  697. face: null,
  698. blessing: null,
  699. money: null,
  700. index: null,
  701. },
  702. list_id: 0,
  703. my_data: {},
  704. style: {
  705. pageHeight: 0,
  706. contentViewHeight: 0,
  707. footViewHeight: 90,
  708. mitemHeight: 0,
  709. },
  710. call_ret: false,
  711. my_photo: "",
  712. callType: 1, //默认视频,
  713. popuMsg: "",
  714. payTimer: false,
  715. type: "",
  716. Keyboard: 0,
  717. miaoqiang: 0,
  718. vendor_status: 0,
  719. doubleClick: false,
  720. doubleTime: {
  721. firstTime: "",
  722. towTime: "",
  723. flag: true,
  724. timer: null,
  725. },
  726. group_state: null,
  727. isOnline: 2, // (0表示离线,1表示在线)
  728. showUploadFile: false, //上传文件
  729. send_user_id: "", //@好友的信息
  730. popHeight: "", //todo弹出选择好友高度
  731. members: [], //群成员
  732. };
  733. },
  734. onBackPress(options) {
  735. console.log(options);
  736. uni.navigateTo({
  737. url: "/pages/chat/index",
  738. });
  739. return false;
  740. },
  741. onLoad(option) {
  742. // 监听语音视频通话事件
  743. // #ifdef APP-PLUS
  744. // uni.$TUICallingEvent.addEventListener("onCallStart", (data) => {
  745. // console.log("onCallStart" + JSON.stringify(data));
  746. // console.log("onCallStart" + data.roomID);
  747. // });
  748. // uni.$TUICallingEvent.addEventListener("onCallEnd", (data) => {
  749. // console.log("onCallEnd" + JSON.stringify(data));
  750. // data.time = data.totalTime;
  751. // // _get.cancelCall(data, function(res) {});
  752. // });
  753. // uni.$TUICallingEvent.addEventListener("onCallSucceed", (data) => {
  754. // console.log("onCallSucceed" + JSON.stringify(data));
  755. // });
  756. // uni.$TUICallingEvent.addEventListener("onCallFailed", (data) => {
  757. // console.log("onCallFailed" + JSON.stringify(data));
  758. // data.time = data.totalTime;
  759. // // _get.cancelCall(data, function(res) {});
  760. // });
  761. // #endif
  762. this.list_id = option.list_id;
  763. if ("chat_id" in option) {
  764. this.chat_id = option.chat_id;
  765. }
  766. if ("trans" in option) {
  767. uni.showToast({
  768. title: "转发成功",
  769. icon: "none",
  770. ducation: 2000,
  771. });
  772. }
  773. //注册事件
  774. // 注册发送音频事件
  775. this.regOnStartEvent((e) => {
  776. this.recordBegin(e);
  777. });
  778. // 注册发送音频事件
  779. this.regSendVoiceEvent((e) => {
  780. this.recordEnd(e);
  781. });
  782. // 注册发送音频事件
  783. this.regVudioEndEvent((e) => {
  784. this.playMsgid = null;
  785. });
  786. // //语音自然播放结束
  787. // this.AUDIO.onEnded((res) => {
  788. // this.playMsgid = null;
  789. // });
  790. //
  791. // // #ifndef H5
  792. // //录音开始事件
  793. // this.RECORDER.onStart((e) => {
  794. // this.recordBegin(e);
  795. // })
  796. // //录音结束事件
  797. // this.RECORDER.onStop((e) => {
  798. // this.recordEnd(e);
  799. // })
  800. // //#endif
  801. },
  802. onUnload() {
  803. /** 这里只保留最新的15条会话记录,以保证初次加载性能 */
  804. let _this = this;
  805. let chat_data = this.msgList;
  806. chat_data.list = chat_data.list.slice(-15);
  807. _data.localData(this.list_id, chat_data);
  808. /** 去除当前会话的list_id */
  809. _data.localData("message_list_id", "");
  810. /** 暂停语音播放 */
  811. // this.AUDIO.pause();
  812. /** 移除监听事件 */
  813. uni.$off("data_chat_data_unshift");
  814. uni.$off("data_chat_data_push");
  815. uni.$off("data_chat_data");
  816. uni.$off("data_user_info");
  817. uni.$off("data_chat_data_delete");
  818. uni.$off("update_text_msg");
  819. uni.$off("memberJoinRoom");
  820. uni.$off("closeVoiceRoom");
  821. clearInterval(_this.timer);
  822. clearInterval(_this.redTimer);
  823. if (_data.data("voice_room_type")) {
  824. _this.$refs.serving.xiaMai(_this.list_id);
  825. } else {
  826. _this.$refs.serving && _this.$refs.serving.closeVoiceRoom();
  827. }
  828. },
  829. mounted() {
  830. let _this = this;
  831. if (this.chat_id) {
  832. this.$nextTick(() => {
  833. this.scrollToView = "msg" + this.chat_id;
  834. });
  835. }
  836. setTimeout(function() {
  837. _this.getScrollContentHeight("hide", 0);
  838. }, 400);
  839. },
  840. created() {},
  841. onShow() {
  842. this.initData();
  843. },
  844. computed: {
  845. ...mapState({
  846. RECORD: (state) => state.audio.RECORD,
  847. AUDIO: (state) => state.audio.AUDIO,
  848. RecordTime: (state) => state.audio.RecordTime,
  849. KeyboardH: (state) => state.common.KeyboardHeight,
  850. custom_font_size: (state) => state.common.custom_font_size,
  851. }),
  852. getServingText() {
  853. return _data.data("dragInfo").state == 1 ? "下麦" : "上麦";
  854. },
  855. myPhoto() {
  856. return this.my_photo;
  857. },
  858. imgRan() {
  859. return Math.random();
  860. },
  861. staticPath() {
  862. return _data.staticChat();
  863. },
  864. staticVideoImg() {
  865. return _data.staticVideoImg();
  866. },
  867. staticPhoto() {
  868. return _data.staticPhoto();
  869. },
  870. sendMsgClass() {
  871. // #ifdef H5
  872. return this.isVoice ? "hidden" : "";
  873. // #endif
  874. return (this.isVoice ? "hidden" : "") || this.textMsg.length ?
  875. "" :
  876. "hidden";
  877. },
  878. iconShow() {
  879. return this.textMsg.length ? "hidden" : "more";
  880. },
  881. systemClass() {
  882. return this.msgList.type == 1 ? "sys" : "";
  883. },
  884. },
  885. onReady: function(res) {
  886. let _this = this;
  887. if (_this.msgList.type == 1) {
  888. // setTimeout(function () {
  889. // _this.$refs.scrollNotice.textScroll()
  890. // },300);
  891. }
  892. },
  893. methods: {
  894. ...mapMutations([
  895. "regSendVoiceEvent",
  896. "regOnStartEvent",
  897. "regVudioEndEvent",
  898. ]),
  899. // 消息是否是图片
  900. isImage(con) {
  901. // console.log("con",con);
  902. // 如果是图片,则转换成图片
  903. let reg =
  904. /^https?:\/\/(.+\/)+.+(\.(gif|png|jpg|jpeg|webp|svg|psd|bmp|tif))$/i;
  905. let reg2 = RegExp(/data:image\/.*;base64,/);
  906. if (reg.test(con) || reg2.test(con)) {
  907. return true;
  908. } else {
  909. return false;
  910. }
  911. },
  912. // 选择要禁言的人
  913. selectMember(row) {
  914. console.log("row", row);
  915. let user_id = row.msg.user_info.uid + "";
  916. if (user_id) {
  917. let i = this.members.indexOf(user_id);
  918. if (i > -1) {
  919. this.members.splice(i, 1);
  920. } else {
  921. this.members.push(user_id);
  922. }
  923. }
  924. let _this = this;
  925. _this.$httpSend({
  926. path: "/im/message/setGroupAdmin",
  927. data: {
  928. users: JSON.stringify(_this.members),
  929. list_id: _this.list_id,
  930. type: 2,
  931. },
  932. success_action: true,
  933. success(res) {
  934. row.showAction = false;
  935. _this.$forceUpdate();
  936. // 禁言
  937. uni.showToast({
  938. title: res.msg,
  939. duration: 2000,
  940. });
  941. },
  942. });
  943. },
  944. // 选择要剔出的人
  945. selectRemoveMember(row) {
  946. console.log("row", row);
  947. let user_id = row.msg.user_info.uid;
  948. if (user_id) {
  949. let i = this.members.indexOf(user_id);
  950. if (i > -1) {
  951. this.members.splice(i, 1);
  952. } else {
  953. this.members.push(user_id);
  954. }
  955. }
  956. let _this = this;
  957. _this.$httpSend({
  958. path: "/im/message/removeChat",
  959. data: {
  960. users: JSON.stringify(_this.members),
  961. list_id: _this.list_id,
  962. },
  963. success_action: true,
  964. success(res) {
  965. row.showAction = false;
  966. _this.$forceUpdate();
  967. uni.showToast({
  968. title: res.msg,
  969. duration: 2000,
  970. icon: "none",
  971. });
  972. },
  973. });
  974. },
  975. // 所有群成员
  976. getGroupMembers(row) {
  977. let _this = this;
  978. _this.$httpSend({
  979. path: "/im/message/getGroupAdmin",
  980. data: {
  981. list_id: this.list_id,
  982. type: 2,
  983. },
  984. success(data) {
  985. _this.members = data.user_ids;
  986. console.log("_this.members", _this.members);
  987. row.showAction = true;
  988. _this.$forceUpdate();
  989. },
  990. });
  991. },
  992. // todo 长按显示面板
  993. showAction(row) {
  994. this.msgList.list.map((item) => {
  995. item.showAction = false;
  996. });
  997. this.getGroupMembers(row);
  998. },
  999. // todo 长按头像@好友
  1000. addFriendChat(msg) {
  1001. msg.showAction = false;
  1002. this.textMsg = this.textMsg + "@" + msg.msg.user_info.name + " ";
  1003. if (!this.send_user_id) {
  1004. this.send_user_id = msg.msg.user_info.uid;
  1005. } else {
  1006. this.send_user_id = this.send_user_id + "," + msg.msg.user_info.uid;
  1007. }
  1008. },
  1009. closeFriends() {
  1010. this.$refs.popup_friends.close();
  1011. },
  1012. // 初始化数据
  1013. initData() {
  1014. _hook.routeSonHook();
  1015. _get.getUserInfo({});
  1016. // todo 选择@好友高度
  1017. this.popHeight = uni.getSystemInfoSync().windowHeight;
  1018. let _this = this;
  1019. /** 先移除监听事件(避免重复触发消息) */
  1020. uni.$off("remove_member");
  1021. uni.$off("group_delete_chat");
  1022. uni.$off("chat_del");
  1023. uni.$off("data_chat_data_unshift");
  1024. uni.$off("data_chat_data_push");
  1025. uni.$off("data_chat_data");
  1026. uni.$off("data_user_info");
  1027. uni.$off("data_chat_data_delete");
  1028. uni.$off("update_text_msg");
  1029. uni.$off("memberJoinRoom");
  1030. uni.$off("closeVoiceRoom");
  1031. uni.$off("newReadTime");
  1032. clearInterval(_this.timer);
  1033. clearInterval(_this.redTimer);
  1034. _this.getReadTime();
  1035. uni.$on("newReadTime", function(time) {
  1036. console.log('newReadTime:成功');
  1037. _this.nowReadTime = time;
  1038. });
  1039. _this.my_photo = _data.data("cache").local_photo;
  1040. let chat_data = _data.localData(_this.list_id);
  1041. _this.my_data = _data.data("user_info");
  1042. /* 重新获取对话内容 */
  1043. _get.getChatData({
  1044. send_data: {
  1045. list_id: _this.list_id,
  1046. time: 0,
  1047. is_up: 1,
  1048. },
  1049. is_action_data: 1,
  1050. });
  1051. console.log(chat_data,'chat_data+++++++');
  1052. if (chat_data && chat_data.list.length) {
  1053. _this.scrollAnimation = false;
  1054. // TODO 图片列表
  1055. console.log(chat_data);
  1056. let msg = "";
  1057. if (chat_data.online == 1) {
  1058. msg = "(在线)";
  1059. } else {
  1060. msg = "(离线)";
  1061. }
  1062. uni.setNavigationBarTitle({
  1063. title: chat_data.show_name + (chat_data.type == 1 ? "" : msg),
  1064. });
  1065. _this.addMsgImgList(chat_data.list);
  1066. chat_data.list = _this.msgDataHandle(chat_data.list);
  1067. _this.msgList = chat_data;
  1068. _this.receive_list = _this.msgList.receive_list;
  1069. /** 滚动到指定位置 */
  1070. setTimeout(function() {
  1071. _this.$nextTick(function() {
  1072. _this.scrollTop = new Date().getTime();
  1073. // console.log("11111111111111111111111111111")
  1074. // _this.scrollToView = 'msg' + data[data.length - 1].msg.id;
  1075. });
  1076. }, 400);
  1077. /** 如果是群聊要实时检测群有无禁言 */
  1078. _this.type = chat_data.type;
  1079. if (chat_data.type == 1) {
  1080. _this.getGroupSteate();
  1081. }
  1082. }
  1083. console.log('添加当前的会话',this.list_id);
  1084. /** 添加当前的会话list_id */
  1085. _data.localData("message_list_id", this.list_id);
  1086. console.log('_data',_data);
  1087. console.log('监听会话数据变化的会话');
  1088. /** 监听会话数据变化 */
  1089. uni.$on("data_chat_data_unshift", function(data) {
  1090. console.log('会话数据有变化');
  1091. data = _this.msgDataHandle(data);
  1092. _this.scrollAnimation = false;
  1093. let position_id = _this.msgList.list[0].msg.id;
  1094. _this.msgList.list.unshift(...data);
  1095. /** 滚动到指定位置 */
  1096. _this.$nextTick(function() {
  1097. _this.scrollToView = "msg" + position_id;
  1098. });
  1099. // TODO 图片列表
  1100. console.log("图片列表++++++", _this.msgList);
  1101. });
  1102. /** 监听会话数据变化 */
  1103. uni.$on("data_chat_data_push", function(data) {
  1104. _this.setReadTime();
  1105. /** 保持页面15条数据,提升性能 */
  1106. _this.noMore = 0;
  1107. data = _this.msgDataHandle(data);
  1108. _this.scrollAnimation = true;
  1109. _this.msgList.list = data;
  1110. // TODO 图片列表
  1111. console.log("图片列表-----", _this.msgList);
  1112. _this.receive_list = _this.msgList.receive_list;
  1113. /** 滚动到指定位置 */
  1114. setTimeout(function() {
  1115. _this.$nextTick(function() {
  1116. // _this.scrollTop =(new Date()).getTime();
  1117. _this.scrollTop = new Date().getTime();
  1118. // _this.scrollToView = 'msg' + data[data.length - 1].msg.id;
  1119. });
  1120. }, 400);
  1121. });
  1122. /** 监听撤回消息 */
  1123. uni.$on("data_chat_data_delete", function(list) {
  1124. _this.msgList.list = list;
  1125. // TODO 图片列表
  1126. console.log("图片列表", _this.msgList);
  1127. });
  1128. /** 监听会话数据变化 */
  1129. uni.$on("data_chat_data", function(data) {
  1130. let msg = "";
  1131. if (data.online == 1) {
  1132. msg = "(在线)";
  1133. } else {
  1134. msg = "(离线)";
  1135. }
  1136. uni.setNavigationBarTitle({
  1137. title: data.show_name + (_this.msgList.type == 1 ? "" : msg),
  1138. });
  1139. data.list = _this.msgDataHandle(data.list);
  1140. _this.scrollAnimation = false;
  1141. _this.msgList = data;
  1142. // TODO 图片列表
  1143. console.log("图片列表+++++", _this.msgList);
  1144. _this.receive_list = _this.msgList.receive_list;
  1145. if (_this.msgList.type == 1) {
  1146. _this.getGroupSteate();
  1147. }
  1148. /** 滚动到指定位置 */
  1149. _this.$nextTick(function() {
  1150. // _this.scrollTop =(new Date()).getTime();
  1151. // _this.scrollToView = 'msg' + data.list[data.list.length - 1].msg.id;
  1152. _this.scrollTop = new Date().getTime();
  1153. });
  1154. });
  1155. /** 监听新的个人数据 */
  1156. uni.$on("data_user_info", function(data) {
  1157. _this.my_data = data;
  1158. _this.my_photo = _data.staticPhoto() + _this.my_data.photo;
  1159. });
  1160. //监听键盘高度变化
  1161. uni.onKeyboardHeightChange((res) => {
  1162. console.log("软键盘高度变化", res);
  1163. _this.Keyboard = res.height;
  1164. if (res.height) {
  1165. //todo @好友软键盘高度变化
  1166. this.popHeight = uni.getSystemInfoSync().windowHeight - res.height;
  1167. _this.getScrollContentHeight("show", 0);
  1168. } else {
  1169. this.popHeight = uni.getSystemInfoSync().windowHeight;
  1170. _this.getScrollContentHeight("hide", 0);
  1171. }
  1172. });
  1173. uni.$on("update_text_msg", function(res) {
  1174. _this.textMsg += res.msg;
  1175. //todo @好友 如果消息不为空,
  1176. _this.$refs.popup_friends.close();
  1177. if (!_this.send_user_id) {
  1178. _this.send_user_id = res.user_id;
  1179. } else {
  1180. _this.send_user_id = _this.send_user_id + "," + res.user_id;
  1181. }
  1182. });
  1183. uni.$on("memberJoinRoom", function(res) {
  1184. _this.$refs.serving.memberJoin(_this.list_id, function() {
  1185. _this.onLine = true;
  1186. _this.showServing = true;
  1187. });
  1188. });
  1189. uni.$on("closeVoiceRoom", function(res) {
  1190. _this.$refs.serving.closeVoiceRoom();
  1191. });
  1192. _get.getMemberPhotos({
  1193. list_id: _this.list_id,
  1194. },
  1195. function(ret) {
  1196. _this.memberPhotos = ret;
  1197. console.log("群成员通话", _this.memberPhotos);
  1198. }
  1199. );
  1200. // 监听清空消息
  1201. uni.$on("chat_del", function(res) {
  1202. uni.showModal({
  1203. title: "提示",
  1204. showCancel: false,
  1205. content: "消息被清空",
  1206. success: function(res) {},
  1207. });
  1208. _this.msgList = [];
  1209. });
  1210. // 监听消息清空
  1211. uni.$on("group_delete_chat", function(list_id) {
  1212. _this.msgList = [];
  1213. _get.getChatData({
  1214. send_data: {
  1215. list_id: _this.list_id,
  1216. time: 0,
  1217. is_up: 1,
  1218. },
  1219. is_action_data: 1,
  1220. });
  1221. });
  1222. // 监听踢出会员重新获取消息
  1223. uni.$on("remove_member", function(list_id) {
  1224. _this.msgList = [];
  1225. _data.localData(list_id, null);
  1226. _this.initData();
  1227. });
  1228. //收到信息 回传
  1229. this.setReadTime();
  1230. },
  1231. // 选择收藏
  1232. chooseLike() {
  1233. this.hideDrawer(1); //隐藏抽屉
  1234. uni.navigateTo({
  1235. url: "/pages/my/store?choose_collect=1",
  1236. });
  1237. },
  1238. // 下载文件
  1239. downFile(file) {
  1240. uni.downloadFile({
  1241. url: file,
  1242. success: (data) => {
  1243. if (data.statusCode === 200) {
  1244. console.log("下载成功");
  1245. uni.saveFile({
  1246. tempFilePath: data.tempFilePath,
  1247. success(res) {
  1248. uni.showModal({
  1249. title: "下载成功",
  1250. content: "文件已保存:" + res.savedFilePath,
  1251. success: (res_) => {},
  1252. });
  1253. },
  1254. });
  1255. }
  1256. },
  1257. });
  1258. },
  1259. // 打开地图
  1260. openMap(pos) {
  1261. uni.openLocation({
  1262. latitude: pos.latitude,
  1263. longitude: pos.longitude,
  1264. name: pos.name,
  1265. address: pos.address,
  1266. });
  1267. },
  1268. uploadAFile(data) {
  1269. console.log("data", data);
  1270. let _this = this;
  1271. for (let i = 0; i < data.length; i++) {
  1272. let msg = {
  1273. url: data[i].url,
  1274. name: data[i].name,
  1275. length: parseInt(data[i].sizeMB * 1024),
  1276. };
  1277. _this.sendMsg(msg, 11);
  1278. }
  1279. },
  1280. // 上传文件
  1281. chooseFile() {
  1282. const _this = this;
  1283. _this.hideDrawer(1); //隐藏抽屉
  1284. // #ifdef H5
  1285. uni.chooseFile({
  1286. success: function(res) {
  1287. console.log("res", res);
  1288. console.log("size", parseInt(res.tempFiles[0].size / 1024));
  1289. console.log(JSON.stringify(res.tempFilePaths));
  1290. for (let i = 0; i < res.tempFilePaths.length; i++) {
  1291. let msg = {
  1292. url: res.tempFilePaths[i],
  1293. name: res.tempFiles[i].name,
  1294. length: parseInt(res.tempFiles[i].size / 1024),
  1295. };
  1296. _this.sendMsg(msg, 11);
  1297. }
  1298. },
  1299. });
  1300. // #endif
  1301. // #ifdef APP-PLUS
  1302. this.showUploadFile = true;
  1303. // #endif
  1304. },
  1305. // 戳一戳
  1306. chooseChuo() {
  1307. this.sendChuoYiChuoMsg();
  1308. },
  1309. // 发送位置
  1310. sendPos() {
  1311. let _this = this;
  1312. uni.chooseLocation({
  1313. success: function(res) {
  1314. console.log("位置名称:" + res.name);
  1315. console.log("详细地址:" + res.address);
  1316. console.log("纬度:" + res.latitude);
  1317. console.log("经度:" + res.longitude);
  1318. let msg = {
  1319. latitude: res.latitude,
  1320. longitude: res.longitude,
  1321. name: res.name,
  1322. address: res.address,
  1323. };
  1324. _this.sendMsg(msg, 10);
  1325. },
  1326. });
  1327. },
  1328. getHtml(content) {
  1329. return htmlParser(content);
  1330. },
  1331. inputText(e) {
  1332. //截取最后一位
  1333. let str = e.detail.value;
  1334. // todo @好友
  1335. if (str === "") {
  1336. this.send_user_id = "";
  1337. }
  1338. let length1 = str.length;
  1339. let key = str.substr(length1 - 1, 1);
  1340. if (
  1341. key &&
  1342. key == "@" &&
  1343. this.msgList.type == 1 &&
  1344. length1 > this.textMsg.length
  1345. ) {
  1346. this.textMsg = str;
  1347. console.log("跳转到群成员列表");
  1348. // TODO群成员弹窗
  1349. // 关闭输入框
  1350. uni.hideKeyboard();
  1351. this.$refs.popup_friends.open();
  1352. // uni.navigateTo({
  1353. // url: '/pages/chat/group_list?list_id=' + this.list_id,
  1354. // animationType: "slide-in-bottom"
  1355. // });
  1356. return true;
  1357. }
  1358. this.textMsg = str;
  1359. },
  1360. getScrollContentHeight(type = "show", not_return = 1) {
  1361. let _this = this;
  1362. let query = uni.createSelectorQuery();
  1363. query.select(".more-layer").boundingClientRect();
  1364. query.select(".input-box").boundingClientRect();
  1365. uni.getSystemInfo({
  1366. success: function(res) {
  1367. _this.scrollInfo.totall_height = res.windowHeight;
  1368. query.exec((data) => {
  1369. _this.scrollInfo.input_box_height1 = data[0].height || 0;
  1370. _this.scrollInfo.input_box_height2 = data[1].height || 0;
  1371. _this.autoHeight(type, not_return);
  1372. });
  1373. },
  1374. });
  1375. },
  1376. autoHeight(type, not_return) {
  1377. let _this = this;
  1378. if (type == "show") {
  1379. if (this.Keyboard) {
  1380. this.scrollHeight =
  1381. _this.scrollInfo.totall_height -
  1382. _this.Keyboard -
  1383. _this.scrollInfo.input_box_height2 +
  1384. "px";
  1385. } else {
  1386. this.scrollHeight =
  1387. _this.scrollInfo.totall_height -
  1388. _this.scrollInfo.input_box_height1 -
  1389. _this.scrollInfo.input_box_height2 +
  1390. "px";
  1391. }
  1392. } else {
  1393. //content高度 = 屏幕高度-tool高度
  1394. uni.getSystemInfo({
  1395. success: function(res) {
  1396. res.windowHeight = res.windowHeight;
  1397. if (_this.Keyboard) {
  1398. _this.scrollHeight =
  1399. res.windowHeight -
  1400. _this.scrollInfo.Keyboard -
  1401. _this.scrollInfo.input_box_height2 +
  1402. "px";
  1403. } else {
  1404. _this.scrollHeight =
  1405. res.windowHeight - _this.scrollInfo.input_box_height2 + "px";
  1406. }
  1407. },
  1408. });
  1409. // this.scrollHeight = '100%'
  1410. }
  1411. if (not_return == 0) {
  1412. this.$nextTick(() => {
  1413. _this.scrollTop = new Date().getTime();
  1414. });
  1415. }
  1416. },
  1417. getGroupSteate() {
  1418. let _this = this;
  1419. this.$httpSend({
  1420. path: "/im/action/groupState",
  1421. data: {
  1422. list_id: _this.list_id,
  1423. },
  1424. success(res) {
  1425. _this.msgList.is_msg = res.is_msg;
  1426. _this.msgList.is_action = res.is_action;
  1427. _this.msgList.is_niming = res.is_niming;
  1428. _this.niming_msg = res.is_niming == 0 ? "匿名" : "退出匿名";
  1429. _this.miaoqiang = res.miaoqiang;
  1430. _this.vendor_status = res.vendor_status;
  1431. _this.notice = res.notice;
  1432. _this.is_main = res.is_main;
  1433. _this.group_state = res;
  1434. if (_this.miaoqiang && _this.is_main && res.qiang_time > 0) {
  1435. _this.autoFaRed(res.qiang_time);
  1436. }
  1437. if (res.voice_room_state) {
  1438. //有人发起语音则自动加入
  1439. //加入视频
  1440. _this.$refs.serving.memberJoin(_this.list_id, function() {
  1441. _this.onLine = true;
  1442. });
  1443. }
  1444. },
  1445. });
  1446. },
  1447. videoErrorCallback() {},
  1448. autoVideo(msg) {
  1449. this.showVedio = true;
  1450. this.videoPath =
  1451. _data.staticChat() + this.list_id + "/" + msg.content.url;
  1452. },
  1453. getCard(msg) {
  1454. if (msg.content.user_id != undefined) {
  1455. uni.navigateTo({
  1456. url: "/pages/details/index?in=1&user_id=" + msg.content.user_id,
  1457. });
  1458. }
  1459. },
  1460. chooseCard() {
  1461. uni.navigateTo({
  1462. url: "./message/card_list?list_id=" + this.list_id,
  1463. });
  1464. },
  1465. imageError(e) {
  1466. // this.my_photo = _data.staticPhoto() + '/default_photo_path.png';
  1467. let index = e.currentTarget.dataset.id;
  1468. //替换index对应的图片
  1469. this.msgList.list[index].msg.user_info.face = "/default_photo_path.png";
  1470. },
  1471. imageError2(e) {
  1472. this.my_photo = _data.staticPhoto() + "/default_photo_path.png";
  1473. },
  1474. scrollToDom() {
  1475. let that = this;
  1476. let query = uni.createSelectorQuery();
  1477. query.select("#msg" + that.chat_id).boundingClientRect();
  1478. query.select("#scrollview").boundingClientRect();
  1479. query.exec((res) => {
  1480. that.style.mitemHeight = 0;
  1481. let rect = res[0];
  1482. that.style.mitemHeight = that.style.mitemHeight + rect.height + 40;
  1483. if (that.style.mitemHeight > that.style.contentViewHeight - 100) {
  1484. //判断子元素高度是否大于显示高度
  1485. that.scrollTop =
  1486. that.style.mitemHeight - that.style.contentViewHeight; //用子元素的高度减去显示的高度就获益获得序言滚动的高度
  1487. }
  1488. });
  1489. },
  1490. //
  1491. //发起视频聊天
  1492. videoBut(type) {
  1493. console.log("发起通话->", type);
  1494. let data = {};
  1495. if (type == "voice") {
  1496. data.callType = 1
  1497. } else {
  1498. data.callType = 2
  1499. }
  1500. let arr = [];
  1501. this.memberPhotos.forEach(item => {
  1502. arr.push(item.user_id.toString());
  1503. })
  1504. data.user_ids = arr;
  1505. console.log("发起通话数据", data);
  1506. this.sendCall(data);
  1507. return;
  1508. let content_type = 6;
  1509. this.call_ret = false;
  1510. if (type === "voice") {
  1511. this.voiceLoading = true;
  1512. content_type = 7;
  1513. } else {
  1514. this.videoLoading = true;
  1515. }
  1516. let _this = this;
  1517. this.$httpSend({
  1518. path: "/im/message/sendVideo",
  1519. data: {
  1520. list_id: this.list_id,
  1521. content_type: content_type,
  1522. _token: uni.getStorageSync("token"),
  1523. },
  1524. success_action: true,
  1525. success(res) {
  1526. if (res.err === 0) {
  1527. console.log("通话数据",res);
  1528. //图片转化
  1529. res.data.myavatar = _this.staticPhoto + res.data.myavatar;
  1530. res.data.avatar = _this.staticPhoto + res.data.avatar;
  1531. _this.getVideo(res.data);
  1532. } else {}
  1533. },
  1534. });
  1535. },
  1536. // 发起腾讯通话
  1537. sendCall(data) {
  1538. console.log('开始发起腾讯通话');
  1539. let my_id = this.my_data.id;
  1540. let user_id = '';
  1541. data.user_ids.forEach(item => {
  1542. if (item != my_id) {
  1543. user_id = item;
  1544. }
  1545. })
  1546. console.log("开始打电话",data);
  1547. console.log(uni.$TUICalling,'uni.$TUICalling');
  1548. uni.$TUICalling.call({
  1549. type: data.callType,
  1550. userID: user_id,
  1551. },
  1552. (res) => {
  1553. console.log(JSON.stringify(res));
  1554. }
  1555. );
  1556. // uni.$TUICalling.groupCall({
  1557. // type: data.callType,
  1558. // groupID: "",
  1559. // userIDList: data.user_ids,
  1560. // },
  1561. // (res) => {
  1562. // console.log(JSON.stringify(res));
  1563. // }
  1564. // );
  1565. },
  1566. //调用视频/音频
  1567. getVideo(data) {
  1568. this.sendCall(data);
  1569. return;
  1570. data.usersig = genTestUserSig(data.userid).userSig;
  1571. console.log("调用传参", data);
  1572. console.log("_this.call", _this.call);
  1573. console.log("调用腾讯云data", data);
  1574. let _this = this;
  1575. _this.call.groupCall({
  1576. type: data.callType == "voice" ? 1 : 2,
  1577. groupID: "",
  1578. userIDList: data.user_ids,
  1579. },
  1580. (ret) => {
  1581. this.doubleClick = false;
  1582. console.log(data);
  1583. console.log(ret);
  1584. console.log("9909090909090");
  1585. if (ret) {
  1586. _this.videPoup = false;
  1587. _this.voiceLoading = false;
  1588. if (ret.code == 5 && !_this.payTimer) {
  1589. console.log("发起付费");
  1590. //先扣一次
  1591. _get.payVideoAamount({
  1592. list_id: _this.list_id,
  1593. },
  1594. function(res) {
  1595. console.log(res);
  1596. },
  1597. function(res) {
  1598. console.log(res);
  1599. }
  1600. );
  1601. _this.payTimer = setInterval(function() {
  1602. _get.payVideoAamount({
  1603. list_id: _this.list_id,
  1604. },
  1605. function(res) {
  1606. console.log(res);
  1607. },
  1608. function(res) {
  1609. console.log(res);
  1610. clearInterval(_this.payTimer); //取消收费
  1611. _this.payTimer = false;
  1612. }
  1613. );
  1614. }, 60000);
  1615. }
  1616. if (ret.code == 1 && ret.time != undefined) {
  1617. //对方或者自己取消
  1618. data.time = ret.time;
  1619. data.ret_code = ret.code;
  1620. console.log(JSON.stringify(data));
  1621. _get.cancelCall(data, function(res) {});
  1622. }
  1623. }
  1624. }
  1625. );
  1626. },
  1627. // 发起视频通话
  1628. videoCall(type) {
  1629. let _this = this;
  1630. _this.callType = type;
  1631. console.log('kaishi');
  1632. //
  1633. console.log("确认开始->")
  1634. _this.confirm();
  1635. // this.videPoup = true
  1636. // this.hideDrawer();
  1637. },
  1638. confirm() {
  1639. // if (this.doubleClick) return false;
  1640. // this.doubleClick = true;
  1641. if (this.callType == 1) {
  1642. this.videoBut("video");
  1643. } else {
  1644. this.videoBut("voice");
  1645. }
  1646. this.$refs.popup.close();
  1647. },
  1648. msgDataHandle(data, type) {
  1649. for (let i = 0, j = data.length, msg_img; i < j; i++) {
  1650. if (data[i].type == 0 && data[i].msg.type == 2) {
  1651. msg_img =
  1652. this.staticPath +
  1653. this.list_id +
  1654. "/" +
  1655. data[i].msg.content.url.replace("_thumb", "");
  1656. if (type) {
  1657. this.msgImgList.unshift(msg_img);
  1658. } else {
  1659. this.msgImgList.push(msg_img);
  1660. }
  1661. data[i].msg.content = this.setPicSize(data[i].msg.content);
  1662. } else if (data[i].type == 0 && data[i].msg.type == 0) {
  1663. data[i].msg.content.text = this.replaceEmoji(
  1664. data[i].msg.content.text
  1665. );
  1666. }
  1667. }
  1668. // console.log("this.msgImgList",this.msgImgList);
  1669. return data;
  1670. },
  1671. // 所有图片列表
  1672. addMsgImgList(data) {
  1673. this.msgImgList = [];
  1674. for (let i = 0, j = data.length, msg_img; i < j; i++) {
  1675. if (data[i].type == 0 && data[i].msg.type == 2) {
  1676. this.msgImgList.push(
  1677. this.staticPath +
  1678. this.list_id +
  1679. "/" +
  1680. data[i].msg.content.url.replace("_thumb", "")
  1681. );
  1682. }
  1683. }
  1684. },
  1685. timestampFormat(time) {
  1686. return _action.timestampFormat(time);
  1687. },
  1688. msgAction(id, user_id, content, type) {
  1689. let _this = this;
  1690. // switch (_this.msgList.type) {
  1691. // case 0:
  1692. // if (user_id != _this.my_data.id) {
  1693. // return;
  1694. // }
  1695. // break;
  1696. // case 1:
  1697. // if (_this.msgList.is_action == 0 && user_id != _this.my_data.id) {
  1698. // return;
  1699. // }
  1700. // break;
  1701. // default:
  1702. // return;
  1703. // break;
  1704. // }
  1705. uni.showActionSheet({
  1706. itemList: ["撤回", "收藏", "转发", "复制"],
  1707. success: function(res) {
  1708. switch (res.tapIndex) {
  1709. case 0:
  1710. _this.$httpSend({
  1711. path: "/im/message/withdraw",
  1712. data: {
  1713. list_id: _this.list_id,
  1714. type: _this.msgList.type,
  1715. msg_id: id,
  1716. },
  1717. success_action: true,
  1718. success(res) {
  1719. uni.showToast({
  1720. title: res.msg,
  1721. icon: "none",
  1722. duration: 1500,
  1723. });
  1724. },
  1725. });
  1726. break;
  1727. case 1:
  1728. console.log("收藏");
  1729. console.log("收藏文件", {
  1730. list_id: _this.list_id,
  1731. type: _this.msgList.type,
  1732. msg_id: id,
  1733. });
  1734. _this.$httpSend({
  1735. path: "/im/vendor/saveStore",
  1736. data: {
  1737. list_id: _this.list_id,
  1738. type: _this.msgList.type,
  1739. msg_id: id,
  1740. },
  1741. success_action: true,
  1742. success(res) {
  1743. uni.showToast({
  1744. title: res.msg,
  1745. icon: "none",
  1746. duration: 1500,
  1747. });
  1748. },
  1749. });
  1750. break;
  1751. case 2:
  1752. console.log("转发");
  1753. let datas = {
  1754. list_id: _this.list_id,
  1755. type: _this.msgList.type,
  1756. msg_id: id,
  1757. };
  1758. uni.setStorageSync("data_msg", JSON.stringify(datas));
  1759. uni.navigateTo({
  1760. url: "../push/sendallsome?type=" +
  1761. type +
  1762. "&content=" +
  1763. JSON.stringify(content),
  1764. });
  1765. break;
  1766. //收藏
  1767. case 3:
  1768. console.log("复制", content);
  1769. if (type == 0) {
  1770. let reg = /<\/?.+?\/?>/g;
  1771. let str = content.text;
  1772. str = str.replace(reg, "");
  1773. uni.setClipboardData({
  1774. data: str,
  1775. success: function() {
  1776. uni.showToast({
  1777. icon: "none",
  1778. title: "复制成功",
  1779. });
  1780. },
  1781. fail: function() {
  1782. uni.showToast({
  1783. icon: "none",
  1784. title: "复制失败",
  1785. });
  1786. },
  1787. });
  1788. } else {
  1789. uni.showToast({
  1790. icon: "none",
  1791. title: "不支持该类消息复制",
  1792. });
  1793. }
  1794. break;
  1795. default:
  1796. break;
  1797. }
  1798. },
  1799. fail: function(res) {
  1800. //console.log(res.errMsg);
  1801. },
  1802. });
  1803. },
  1804. copyToClipboard(str) {
  1805. const el = document.createElement("textarea");
  1806. el.value = str;
  1807. el.setAttribute("readonly", "");
  1808. el.style.position = "absolute";
  1809. el.style.left = "-9999px";
  1810. document.body.appendChild(el);
  1811. const selected =
  1812. document.getSelection().rangeCount > 0 ?
  1813. document.getSelection().getRangeAt(0) :
  1814. false;
  1815. el.select();
  1816. document.execCommand("copy");
  1817. document.body.removeChild(el);
  1818. if (selected) {
  1819. document.getSelection().removeAllRanges();
  1820. document.getSelection().addRange(selected);
  1821. }
  1822. },
  1823. goDetails(user_id, row) {
  1824. /** 如果是群聊,没有权限的话,查看不了其他会员信息 */
  1825. if (
  1826. this.msgList.type == 1 &&
  1827. (this.msgList.is_action == 0 || row.msg.is_niming == 1)
  1828. ) {
  1829. uni.showToast({
  1830. title: "没有权限查看",
  1831. icon: "none",
  1832. duration: 1000,
  1833. });
  1834. return;
  1835. }
  1836. uni.navigateTo({
  1837. url: "../details/index?user_id=" + user_id,
  1838. });
  1839. },
  1840. // 接受消息(筛选处理)
  1841. screenMsg(msg) {
  1842. //从长连接处转发给这个方法,进行筛选处理
  1843. if (msg.type == 2) {
  1844. //已读信息
  1845. this.nowReadTime = msg.msg.time;
  1846. } else if (msg.type == 1) {
  1847. // 系统消息
  1848. switch (msg.msg.type) {
  1849. case 0:
  1850. this.addSystemTextMsg(msg);
  1851. break;
  1852. case 5:
  1853. this.addSystemRedEnvelopeMsg(msg);
  1854. break;
  1855. }
  1856. } else if (msg.type == 0) {
  1857. // 用户消息
  1858. switch (msg.msg.type) {
  1859. case 0:
  1860. this.addTextMsg(msg);
  1861. break;
  1862. case 1:
  1863. this.addVoiceMsg(msg);
  1864. break;
  1865. case 2:
  1866. this.addImgMsg(msg);
  1867. break;
  1868. case 5:
  1869. this.addRedEnvelopeMsg(msg);
  1870. break;
  1871. }
  1872. //console.log('用户消息');
  1873. //非自己的消息震动
  1874. if (msg.msg.user_info.uid != this.my_data.id) {
  1875. //console.log('振动');
  1876. uni.vibrateLong();
  1877. }
  1878. //收到信息 回传
  1879. this.setReadTime();
  1880. }
  1881. let _this = this;
  1882. this.$nextTick(function() {
  1883. // 滚动到底
  1884. _this.scrollTop = new Date().getTime();
  1885. });
  1886. },
  1887. getReadTime() {
  1888. var _this = this;
  1889. this.$httpSend({
  1890. path: "/im/message/getListTime",
  1891. data: {
  1892. list_id: this.list_id,
  1893. },
  1894. success_action: true,
  1895. success(res) {
  1896. console.log('getReadTime:成功');
  1897. _this.nowReadTime = res.read_time;
  1898. },
  1899. });
  1900. },
  1901. setReadTime() {
  1902. this.$httpSend({
  1903. path: "/im/message/setListTime",
  1904. data: {
  1905. list_id: this.list_id,
  1906. },
  1907. success_action: true,
  1908. success(res) {
  1909. // console.log(res)
  1910. },
  1911. });
  1912. },
  1913. //触发滑动到顶部(加载历史信息记录)
  1914. loadHistory() {
  1915. if (this.isHistoryLoading || this.noMore) {
  1916. return;
  1917. }
  1918. let _this = this;
  1919. this.isHistoryLoading = true; //参数作为进入请求标识,防止重复请求
  1920. _get.getChatData({
  1921. send_data: {
  1922. list_id: _this.list_id,
  1923. time: _this.msgList.list[0].msg.time,
  1924. is_up: 0,
  1925. },
  1926. callback(data) {
  1927. if (data.list.length < 15) {
  1928. _this.noMore = 1;
  1929. }
  1930. _this.isHistoryLoading = false;
  1931. },
  1932. is_action_data: 0,
  1933. });
  1934. },
  1935. //处理图片尺寸,如果不处理宽高,新进入页面加载图片时候会闪
  1936. setPicSize(content) {
  1937. // 让图片最长边等于设置的最大长度,短边等比例缩小,图片控件真实改变,区别于aspectFit方式。
  1938. let maxW = uni.upx2px(350); //350是定义消息图片最大宽度
  1939. let maxH = uni.upx2px(350); //350是定义消息图片最大高度
  1940. if (content.w > maxW || content.h > maxH) {
  1941. let scale = content.w / content.h;
  1942. content.w = scale > 1 ? maxW : maxH * scale;
  1943. content.h = scale > 1 ? maxW / scale : maxH;
  1944. let url_array = content.url.split(".");
  1945. if (content.url.indexOf("_thumb.") == -1) {
  1946. content.url = url_array[0] + "_thumb." + url_array[1];
  1947. }
  1948. }
  1949. return content;
  1950. },
  1951. //更多功能(点击+弹出)
  1952. showMore() {
  1953. this.isVoice = false;
  1954. this.hideEmoji = true;
  1955. if (this.hideMore) {
  1956. this.hideMore = false;
  1957. this.openDrawer();
  1958. } else {
  1959. this.hideDrawer();
  1960. }
  1961. },
  1962. // 打开抽屉
  1963. openDrawer() {
  1964. let _this = this;
  1965. this.popupLayerClass = "showLayer";
  1966. this.hideMore = false;
  1967. setTimeout(function() {
  1968. console.log("scorll...");
  1969. _this.getScrollContentHeight("show", 0);
  1970. }, 150);
  1971. },
  1972. // 隐藏抽屉
  1973. hideDrawer(not_return = 0, type = "hide") {
  1974. //判断时间
  1975. if (not_return == 3) {
  1976. let time = new Date().getTime();
  1977. if (this.doubleTime.flag) {
  1978. this.doubleTime.firstTime = time;
  1979. this.doubleTime.flag = false;
  1980. } else {
  1981. this.doubleTime.towTime = time;
  1982. this.doubleTime.flag = true;
  1983. }
  1984. let timeBucket = this.doubleTime.towTime - this.doubleTime.firstTime;
  1985. console.log("timeBucket:", timeBucket);
  1986. if (timeBucket < 200 && this.doubleTime.flag) {
  1987. //第二次进来
  1988. clearTimeout(this.timer);
  1989. this.doubleTime.towTime = "";
  1990. this.doubleTime.firstTime = "";
  1991. // this.sendChuoYiChuoMsg();
  1992. // this.textMsg = '[戳一戳]'
  1993. // this.sendMsg(this.textMsg, 0);
  1994. // this.textMsg = ''
  1995. // //发送戳一戳
  1996. return false;
  1997. }
  1998. let _this = this;
  1999. this.timer = setTimeout(function() {
  2000. _this.toHideDrawer(not_return, type);
  2001. }, 280);
  2002. } else {
  2003. this.toHideDrawer(not_return, type);
  2004. }
  2005. },
  2006. sendChuoYiChuoMsg() {
  2007. _get.sendChuoYiChuoMsg({
  2008. list_id: this.list_id,
  2009. },
  2010. function() {}
  2011. );
  2012. },
  2013. toHideDrawer(not_return = 0, type = "hide") {
  2014. this.popupLayerClass = "";
  2015. setTimeout(() => {
  2016. this.hideMore = true;
  2017. this.hideEmoji = true;
  2018. this.getScrollContentHeight(type, not_return);
  2019. }, 150);
  2020. },
  2021. // 选择图片发送
  2022. chooseImage() {
  2023. this.getImage("album");
  2024. },
  2025. //拍照发送
  2026. camera() {
  2027. this.getImage("camera");
  2028. },
  2029. //拍摄视频发送
  2030. video() {
  2031. uni.chooseVideo({
  2032. success: (res) => {
  2033. let min = parseInt(res.size / 60),
  2034. sec = res.size % 60;
  2035. min = min < 10 ? "0" + min : min;
  2036. sec = sec < 10 ? "0" + sec : sec;
  2037. let msg = {
  2038. url: res.tempFilePath,
  2039. length: min + ":" + sec,
  2040. };
  2041. this.sendMsg(msg, 3);
  2042. },
  2043. });
  2044. },
  2045. //发红包
  2046. handRedEnvelopes() {
  2047. // this.hideDrawer(1);
  2048. console.log(111);
  2049. let url =
  2050. "message/hand?list_id=" +
  2051. this.list_id +
  2052. "&msg_type=" +
  2053. this.msgList.type;
  2054. if (this.vendor_status)
  2055. url =
  2056. "message/hand_pin?list_id=" +
  2057. this.list_id +
  2058. "&msg_type=" +
  2059. this.msgList.type;
  2060. uni.navigateTo({
  2061. url: url,
  2062. });
  2063. },
  2064. //转账
  2065. transfers() {
  2066. //TODO跳转到转账页面
  2067. },
  2068. //选照片 or 拍照
  2069. getImage(type) {
  2070. this.hideDrawer(1);
  2071. uni.chooseImage({
  2072. sourceType: [type],
  2073. sizeType: ["original", "compressed"], //可以指定是原图还是压缩图,默认二者都有
  2074. success: (res) => {
  2075. for (let i = 0; i < res.tempFilePaths.length; i++) {
  2076. uni.getImageInfo({
  2077. src: res.tempFilePaths[i],
  2078. success: (image) => {
  2079. //console.log(image.width);
  2080. //console.log(image.height);
  2081. let msg = {
  2082. url: res.tempFilePaths[i],
  2083. w: image.width,
  2084. h: image.height,
  2085. };
  2086. this.sendMsg(msg, 2);
  2087. },
  2088. });
  2089. }
  2090. },
  2091. });
  2092. },
  2093. // 选择表情
  2094. chooseEmoji() {
  2095. this.hideMore = true;
  2096. if (this.hideEmoji) {
  2097. this.hideEmoji = false;
  2098. this.openDrawer();
  2099. } else {
  2100. this.hideDrawer();
  2101. }
  2102. },
  2103. //添加表情
  2104. addEmoji(em) {
  2105. this.textMsg += em.alt;
  2106. },
  2107. //获取焦点,如果不是选表情ing,则关闭抽屉
  2108. textareaFocus() {
  2109. let _this = this;
  2110. _this.hideDrawer(0, "show");
  2111. return;
  2112. if (_this.popupLayerClass == "showLayer" && this.hideMore == false) {
  2113. _this.hideDrawer();
  2114. }
  2115. },
  2116. // 发送文字消息
  2117. sendText() {
  2118. this.hideDrawer(1); //隐藏抽屉
  2119. if (!this.textMsg) {
  2120. return;
  2121. }
  2122. this.sendMsg("", 0);
  2123. //清空输入框
  2124. this.textMsg = "";
  2125. },
  2126. //替换表情符号为图片
  2127. replaceEmoji(str) {
  2128. str = str ? str : "";
  2129. let replacedStr = str.replace(/\[([^(\]|\[)]*)\]/g, (item, index) => {
  2130. // console.log("item: " + item);
  2131. for (let i = 0; i < this.emojiList.length; i++) {
  2132. let row = this.emojiList[i];
  2133. for (let j = 0; j < row.length; j++) {
  2134. let EM = row[j];
  2135. if (EM.alt == item) {
  2136. //在线表情路径,图文混排必须使用网络路径,请上传一份表情到你的服务器后再替换此路径
  2137. //比如你上传服务器后,你的100.gif路径为https://www.xxx.com/emoji/100.gif 则替换onlinePath填写为https://www.xxx.com/emoji/
  2138. let imgstr =
  2139. '<img style="width:22px;height:22px;" src="' +
  2140. _data.data("static_url") +
  2141. "/static/emoji/" +
  2142. EM.url +
  2143. '">';
  2144. // console.log("imgstr: " + imgstr);
  2145. return imgstr;
  2146. }
  2147. }
  2148. }
  2149. });
  2150. // display: flex;
  2151. // return '<div style="align-items: center;word-break:break-all;">' + replacedStr + '</div>';
  2152. return replacedStr;
  2153. },
  2154. showQiang() {
  2155. this.$refs.qiang.open();
  2156. },
  2157. autoFaRed(num) {
  2158. let _this = this;
  2159. let time = num * 1000;
  2160. if (time <= 0) return false;
  2161. if (_this.timer) clearInterval(_this.redTimer);
  2162. _this.redTimer = setInterval(function() {
  2163. _get.autoBigRed({
  2164. list_id: _this.list_id,
  2165. },
  2166. function() {}
  2167. );
  2168. }, num * 1000);
  2169. },
  2170. goQiang(e) {
  2171. let _this = this;
  2172. e.list_id = _this.list_id;
  2173. _get.updateMiaoqiang(e, function(res) {
  2174. _this.miaoqiang = e.status;
  2175. console.log(e);
  2176. if (e.status == 1) {
  2177. console.log("发包.......");
  2178. _this.autoFaRed(e.num);
  2179. } else {
  2180. clearInterval(_this.redTimer);
  2181. }
  2182. setTimeout(function() {
  2183. uni.showToast({
  2184. title: "操作成功",
  2185. duration: 2000,
  2186. });
  2187. _this.$refs.qiang.close();
  2188. }, 500);
  2189. });
  2190. },
  2191. // 发送消息
  2192. sendMsg(content, type) {
  2193. // uni.showLoading();
  2194. let _this = this,
  2195. sendMsg = content;
  2196. ((callback) => {
  2197. switch (type) {
  2198. /** 文字/表情消息 */
  2199. case 0:
  2200. let msg = this.textMsg.replace(/</g, "&lt;");
  2201. sendMsg = {
  2202. text: msg,
  2203. };
  2204. // todo @好友
  2205. if (_this.send_user_id) {
  2206. sendMsg.user_id = _this.send_user_id;
  2207. }
  2208. callback();
  2209. break;
  2210. /** 语音/图片/视频/文件 */
  2211. case 1:
  2212. case 2:
  2213. case 3:
  2214. case 4:
  2215. uni.showLoading({
  2216. title: "发送中",
  2217. });
  2218. _this.$httpSendFile({
  2219. type: 0,
  2220. local_url: sendMsg.url,
  2221. data: {
  2222. list_id: _this.list_id,
  2223. },
  2224. success(data) {
  2225. console.log("数据", data);
  2226. uni.hideLoading();
  2227. sendMsg.url = data.save_name;
  2228. sendMsg.full_url = data.full_url;
  2229. sendMsg.full_movie = data.full_movie;
  2230. if ("save_gif_path" in data)
  2231. sendMsg.save_pic_path = data.save_gif_path;
  2232. console.log("success");
  2233. callback();
  2234. },
  2235. });
  2236. break;
  2237. /** 红包消息 */
  2238. case 5:
  2239. break;
  2240. case 10:
  2241. // 地图
  2242. sendMsg = content;
  2243. callback();
  2244. break;
  2245. case 11:
  2246. // 文件
  2247. uni.showLoading({
  2248. title: "发送中",
  2249. });
  2250. _this.$httpSendFile({
  2251. type: 0,
  2252. local_url: sendMsg.url,
  2253. data: {
  2254. list_id: _this.list_id,
  2255. },
  2256. success(data) {
  2257. console.log("数据");
  2258. uni.hideLoading();
  2259. sendMsg.url = data.save_name;
  2260. sendMsg.full_url = data.full_url;
  2261. sendMsg.full_movie = data.full_movie;
  2262. if ("save_gif_path" in data)
  2263. sendMsg.save_pic_path = data.save_gif_path;
  2264. console.log("success");
  2265. callback();
  2266. },
  2267. });
  2268. break;
  2269. default:
  2270. break;
  2271. }
  2272. })(() => {
  2273. //todo @好友 发送后清空user_id
  2274. _this.send_user_id = "";
  2275. _this.$httpSend({
  2276. path: "/im/message/textMsg",
  2277. data: {
  2278. list_id: _this.list_id,
  2279. content_type: type,
  2280. content: JSON.stringify(sendMsg),
  2281. },
  2282. success_action: true,
  2283. success(res) {
  2284. // uni.hideLoading();
  2285. switch (res.err) {
  2286. case 0:
  2287. if (type == 1) {
  2288. _action.playVoice("/static/voice/voice.mp3");
  2289. }
  2290. break;
  2291. case 1:
  2292. uni.showModal({
  2293. title: "好友提示",
  2294. confirmText: "发送好友申请",
  2295. content: res.msg,
  2296. success: function(res) {
  2297. if (res.confirm) {
  2298. uni.navigateTo({
  2299. url: "../friend/apply?user_id=" +
  2300. _data.localData(_this.list_id)
  2301. .obj_id +
  2302. "&is_type=0",
  2303. });
  2304. }
  2305. },
  2306. });
  2307. break;
  2308. case 2:
  2309. uni.showModal({
  2310. content: res.msg,
  2311. });
  2312. let data = _data.localData(data.list_id);
  2313. data.is_msg = 1;
  2314. _this.msgList.is_msg = 1;
  2315. _data.localData(data.list_id, data);
  2316. break;
  2317. default:
  2318. break;
  2319. }
  2320. console.log("重新获取聊天内容。。。。。。。。。");
  2321. _get.getChatData({
  2322. send_data: {
  2323. list_id: _this.list_id,
  2324. time: 0,
  2325. is_up: 1,
  2326. },
  2327. is_action_data: 1,
  2328. });
  2329. },
  2330. });
  2331. });
  2332. },
  2333. // 添加文字消息到列表
  2334. addTextMsg(msg) {
  2335. this.msgList.list.push(msg);
  2336. },
  2337. // 添加语音消息到列表
  2338. addVoiceMsg(msg) {
  2339. this.msgList.list.push(msg);
  2340. },
  2341. // 添加图片消息到列表
  2342. addImgMsg(msg) {
  2343. this.msgImgList.push(
  2344. this.staticPath +
  2345. this.list_id +
  2346. "/" +
  2347. msg.content.url.replace("_thumb", "")
  2348. );
  2349. msg.msg.content = this.setPicSize(msg.msg.content);
  2350. this.msgList.list.push(msg);
  2351. console.log("this.msgImgList", this.msgImgList);
  2352. console.log("this.msgList", this.msgList);
  2353. },
  2354. addRedEnvelopeMsg(msg) {
  2355. this.msgList.push(msg);
  2356. },
  2357. // 添加系统文字消息到列表
  2358. addSystemTextMsg(msg) {
  2359. this.msgList.list.push(msg);
  2360. },
  2361. // 添加系统红包消息到列表
  2362. addSystemRedEnvelopeMsg(msg) {
  2363. this.msgList.list.push(msg);
  2364. },
  2365. openRed(params) {
  2366. let _this = this;
  2367. _this.luckbtn = "luckbtn";
  2368. uni.showLoading({
  2369. title: "加载中...",
  2370. });
  2371. //TODO 判断是哪种红包
  2372. if (this.vendor_status == 1) {
  2373. _get.getLeiHongBao(
  2374. params,
  2375. function(ret) {
  2376. _this.receive_list.push(params.rid);
  2377. _this.msgList.receive_list = _this.receive_list;
  2378. _data.localData(_this.list_id, _this.msgList);
  2379. console.log(ret);
  2380. uni.$emit("data_user_info", ret);
  2381. _data.data("user_info", ret);
  2382. setTimeout(function() {
  2383. _this.luckbtn = "";
  2384. _this.closeRedEnvelope();
  2385. _this.toDetails(params.rid);
  2386. }, 1000);
  2387. },
  2388. function(ret) {
  2389. setTimeout(function() {
  2390. _this.luckbtn = "";
  2391. _this.closeRedEnvelope();
  2392. _this.toDetails(params.rid);
  2393. }, 1000);
  2394. }
  2395. );
  2396. } else {
  2397. _get.getHongBao(
  2398. params,
  2399. function(ret) {
  2400. _this.receive_list.push(params.rid);
  2401. _this.msgList.receive_list = _this.receive_list;
  2402. _data.localData(_this.list_id, _this.msgList);
  2403. console.log(ret);
  2404. uni.$emit("data_user_info", ret);
  2405. _data.data("user_info", ret);
  2406. setTimeout(function() {
  2407. _this.luckbtn = "";
  2408. _this.closeRedEnvelope();
  2409. _this.toDetails(params.rid);
  2410. }, 1000);
  2411. },
  2412. function(ret) {
  2413. setTimeout(function() {
  2414. _this.luckbtn = "";
  2415. _this.closeRedEnvelope();
  2416. _this.toDetails(params.rid);
  2417. }, 1000);
  2418. }
  2419. );
  2420. }
  2421. uni.hideLoading();
  2422. },
  2423. // 打开红包
  2424. openRedEnvelope(msg, index) {
  2425. if (this.receive_list.indexOf(msg.content.rid) >= 0) {
  2426. this.toDetails(msg.content.rid);
  2427. return true;
  2428. }
  2429. this.windowsState = "show";
  2430. this.redenvelopeData = msg.content;
  2431. this.redenvelopeData.index = index;
  2432. return true;
  2433. },
  2434. // 关闭红包弹窗
  2435. closeRedEnvelope() {
  2436. this.windowsState = "hide";
  2437. setTimeout(() => {
  2438. this.windowsState = "";
  2439. }, 200);
  2440. },
  2441. sendSystemMsg(content, type) {
  2442. let lastid = this.msgList.list[this.msgList.list.length - 1].msg.id;
  2443. lastid++;
  2444. let row = {
  2445. type: "system",
  2446. msg: {
  2447. id: lastid,
  2448. type: type,
  2449. content: content,
  2450. },
  2451. };
  2452. this.screenMsg(row);
  2453. },
  2454. //领取详情
  2455. toDetails(rid) {
  2456. uni.navigateTo({
  2457. url: "message/details?rid=" + rid + "&list_id=" + this.list_id,
  2458. });
  2459. },
  2460. // 预览图片
  2461. showPic(msg) {
  2462. console.log("msg预览1", msg);
  2463. let url =
  2464. this.staticPath +
  2465. this.list_id +
  2466. "/" +
  2467. msg.content.url.replace("_thumb", "");
  2468. uni.previewImage({
  2469. indicator: "none",
  2470. urls: [url],
  2471. });
  2472. },
  2473. // 预览图片
  2474. showPic1(msg) {
  2475. console.log("msg预览2类型图片", msg);
  2476. let url =
  2477. this.staticPath +
  2478. this.list_id +
  2479. "/" +
  2480. msg.content.url.replace("_thumb", "");
  2481. uni.previewImage({
  2482. current: url,
  2483. indicator: "none",
  2484. urls: this.msgImgList,
  2485. });
  2486. },
  2487. // 预览文字图片链接
  2488. showPic2(url) {
  2489. console.log("msg预览3", url);
  2490. uni.previewImage({
  2491. indicator: "none",
  2492. urls: [url],
  2493. });
  2494. },
  2495. // 播放语音
  2496. playVoice(msg) {
  2497. console.log("播放语音", msg);
  2498. this.AUDIO.stop();
  2499. let _this = this;
  2500. if (this.playMsgid == msg.id) {
  2501. this.playMsgid = null;
  2502. } else {
  2503. this.playMsgid = msg.id;
  2504. // this.AUDIO.obeyMuteSwitch = false;
  2505. // todo修复语音
  2506. let url = this.staticPath + msg.content.full_url;
  2507. _this.AUDIO.src = url;
  2508. _this.$nextTick(function() {
  2509. _this.AUDIO.play();
  2510. });
  2511. // this.AUDIO.src = (this.staticPath + msg.content.url + '?_=' + Math.random());
  2512. }
  2513. },
  2514. // 录音开始
  2515. voiceBegin(e) {
  2516. if (e.touches.length > 1) {
  2517. return;
  2518. }
  2519. this.initPoint.Y = e.touches[0].clientY;
  2520. this.initPoint.identifier = e.touches[0].identifier;
  2521. // this.RECORDER.start({ format: "mp3" });//录音开始,
  2522. // 开始录音
  2523. this.RECORD.start({
  2524. format: "mp3",
  2525. });
  2526. },
  2527. //录音开始UI效果
  2528. recordBegin(e) {
  2529. /** 暂停语音播放 */
  2530. this.AUDIO.pause();
  2531. this.recording = true;
  2532. this.voiceTis = "松开 结束";
  2533. },
  2534. // 录音被打断
  2535. voiceCancel() {
  2536. this.recording = false;
  2537. this.voiceTis = "按住 说话";
  2538. this.recordTis = "手指上滑 取消发送";
  2539. this.willStop = true; //不发送录音
  2540. this.RECORD.stop(); //录音结束
  2541. },
  2542. // 录音中(判断是否触发上滑取消发送)
  2543. voiceIng(e) {
  2544. if (!this.recording) {
  2545. return;
  2546. }
  2547. let touche = e.touches[0];
  2548. //上滑一个导航栏的高度触发上滑取消发送
  2549. if (this.initPoint.Y - touche.clientY >= uni.upx2px(100)) {
  2550. this.willStop = true;
  2551. this.recordTis = "松开手指 取消发送";
  2552. } else {
  2553. this.willStop = false;
  2554. this.recordTis = "手指上滑 取消发送";
  2555. }
  2556. },
  2557. // 结束录音
  2558. voiceEnd(e) {
  2559. if (!this.recording) {
  2560. return;
  2561. }
  2562. this.recording = false;
  2563. this.voiceTis = "按住 说话";
  2564. this.recordTis = "手指上滑 取消发送";
  2565. this.RECORD.stop(); //录音结束
  2566. },
  2567. //录音结束(回调文件)
  2568. recordEnd(e) {
  2569. if (!this.willStop) {
  2570. //console.log("e: " + JSON.stringify(e));
  2571. let msg = {
  2572. length: 0,
  2573. url: e.tempFilePath,
  2574. };
  2575. console.log(JSON.stringify(msg));
  2576. let min = parseInt(this.RecordTime / 60);
  2577. let sec = this.RecordTime % 60;
  2578. min = min < 10 ? "0" + min : min;
  2579. sec = sec < 10 ? "0" + sec : sec;
  2580. if (min > 0 || sec > 0) {
  2581. msg.length = min + ":" + sec;
  2582. this.sendMsg(msg, 1);
  2583. }
  2584. } else {
  2585. console.log("取消发送录音");
  2586. }
  2587. this.willStop = false;
  2588. },
  2589. // 切换语音/文字输入
  2590. switchVoice() {
  2591. this.hideDrawer(1);
  2592. this.isVoice = this.isVoice ? false : true;
  2593. },
  2594. discard() {
  2595. return;
  2596. },
  2597. sayCall() {
  2598. let status = 0; //默认关闭匿名
  2599. console.log("this.msgList.is_niming:", this.msgList.is_niming);
  2600. if (this.msgList.is_niming == 0) {
  2601. uni.showLoading({
  2602. title: "匿名开启中...",
  2603. });
  2604. status = 1;
  2605. }
  2606. let _this = this;
  2607. _get.updateUserSayType({
  2608. list_id: this.list_id,
  2609. status: status,
  2610. },
  2611. function() {
  2612. if (_this.msgList.is_niming == 0) {
  2613. uni.showToast({
  2614. title: "开启成功",
  2615. image: "/static/theme/default/my/niming.png",
  2616. duration: 2000,
  2617. });
  2618. _this.msgList.is_niming = 1;
  2619. _this.niming_msg = "退出匿名";
  2620. } else {
  2621. _this.msgList.is_niming = 0;
  2622. _this.niming_msg = "匿名";
  2623. }
  2624. _this.textareaFocus(); //隐藏抽屉
  2625. },
  2626. function(ret) {
  2627. uni.showToast({
  2628. title: ret.msg,
  2629. icon: "none",
  2630. duration: 2000,
  2631. });
  2632. }
  2633. );
  2634. },
  2635. scrollEven(e) {},
  2636. zhendong() {
  2637. _get.zhendong({
  2638. list_id: this.list_id,
  2639. },
  2640. function(res) {},
  2641. function(res) {
  2642. uni.showToast({
  2643. title: res.msg,
  2644. duration: 2000,
  2645. icon: "none",
  2646. });
  2647. }
  2648. );
  2649. },
  2650. group_info() {
  2651. uni.navigateTo({
  2652. url: "./message/more?list_id=" +
  2653. this.list_id +
  2654. "&type=" +
  2655. this.msgList.type,
  2656. });
  2657. },
  2658. toUserDetail(item) {
  2659. if (this.msgList.type == 1 && this.msgList.is_action == 0) {
  2660. uni.showToast({
  2661. title: "没有权限查看",
  2662. icon: "none",
  2663. duration: 1000,
  2664. });
  2665. return;
  2666. }
  2667. uni.navigateTo({
  2668. url: "../details/index?user_id=" +
  2669. item.user_id +
  2670. "&type=1&list_id=" +
  2671. this.list_id +
  2672. "&is_action=" +
  2673. this.is_action,
  2674. });
  2675. },
  2676. getServing() {
  2677. //判断权限
  2678. if (
  2679. this.msgList.type == 1 &&
  2680. this.msgList.is_action == 0 &&
  2681. this.group_state &&
  2682. this.group_state.can_shangmai == 0
  2683. ) {
  2684. uni.showToast({
  2685. title: "此群被设置为只有群主和管理员才能上麦",
  2686. icon: "none",
  2687. duration: 1000,
  2688. });
  2689. return;
  2690. }
  2691. let _this = this;
  2692. if (this.onLine) {
  2693. //在房间里直开启
  2694. _this.showServing = true;
  2695. console.log("onLine.....");
  2696. this.$refs.serving.joinOnline(this.list_id);
  2697. return true;
  2698. }
  2699. console.log("_this.servingState:", _this.servingState);
  2700. if (_this.servingState == 1) {
  2701. //下麦
  2702. _this.showServing = false;
  2703. _this.$refs.serving.xiaMai(this.list_id);
  2704. } else {
  2705. //上麦
  2706. console.log("joinRoom....");
  2707. _this.showServing = true;
  2708. this.$refs.serving.joinRoom(this.list_id);
  2709. }
  2710. },
  2711. setSeringState(detail) {
  2712. console.log("this.servingState:", JSON.stringify(detail));
  2713. this.servingState = detail.state;
  2714. },
  2715. },
  2716. watch: {},
  2717. onNavigationBarButtonTap(e) {
  2718. uni.navigateTo({
  2719. url: "./message/more?list_id=" + this.list_id + "&type=" + this.msgList.type,
  2720. });
  2721. },
  2722. };
  2723. </script>
  2724. <style lang="scss">
  2725. @import "@/static/css/chat/style.scss";
  2726. .other {
  2727. .left {
  2728. position: relative;
  2729. .u-logo {
  2730. width: 90rpx !important;
  2731. height: 90rpx !important;
  2732. flex-shrink: 0;
  2733. }
  2734. .action {
  2735. width: 160rpx;
  2736. background: #fff;
  2737. border-radius: 10rpx;
  2738. box-shadow: 0 0 10rpx 0 rgba(0, 0, 0, 0.2);
  2739. position: absolute;
  2740. z-index: 10;
  2741. top: 100rpx;
  2742. left: 0;
  2743. display: flex;
  2744. flex-direction: column;
  2745. align-items: center;
  2746. box-sizing: border-box;
  2747. padding: 0 30rpx;
  2748. .action-line {
  2749. height: 2rpx;
  2750. width: 100rpx;
  2751. margin: 6rpx auto;
  2752. background-color: #ddd;
  2753. }
  2754. .action-item {
  2755. font-size: 24rpx;
  2756. display: flex;
  2757. align-items: center;
  2758. height: 54rpx;
  2759. }
  2760. }
  2761. }
  2762. }
  2763. .popup_friends {
  2764. background-color: rgba(0, 0, 0, 0.3);
  2765. height: 100vh;
  2766. box-sizing: border-box;
  2767. display: flex;
  2768. flex-direction: column;
  2769. justify-content: flex-end;
  2770. }
  2771. .popup_friends-top {
  2772. height: 200rpx;
  2773. flex-shrink: 0;
  2774. /* #ifdef H5 */
  2775. height: 500rpx;
  2776. /* #endif */
  2777. }
  2778. .text-gray {
  2779. color: gray;
  2780. }
  2781. .address-name {
  2782. display: flex;
  2783. flex-direction: column;
  2784. }
  2785. .address-flex {
  2786. display: flex;
  2787. align-items: center;
  2788. }
  2789. .fun-icon {
  2790. width: 100rpx;
  2791. height: 100rpx;
  2792. margin: 10rpx;
  2793. }
  2794. .more-layer {
  2795. // height: 800rpx;
  2796. }
  2797. .send-card {
  2798. width: 700rpx;
  2799. height: 200rpx;
  2800. display: flex;
  2801. max-width: 70%;
  2802. min-height: 25px;
  2803. border-radius: 5px;
  2804. font-size: 14px;
  2805. background-color: #fff;
  2806. flex-direction: column;
  2807. color: #333;
  2808. }
  2809. .send-card-content {
  2810. display: flex;
  2811. justify-content: flex-start;
  2812. align-items: center;
  2813. padding: 20upx;
  2814. height: 100%;
  2815. border-bottom: 2px solid #e1e1e1;
  2816. }
  2817. .send-card-content text {
  2818. margin-left: 20upx;
  2819. }
  2820. .send-card-content-text {
  2821. display: flex;
  2822. justify-content: center;
  2823. flex-direction: column;
  2824. height: 100%;
  2825. margin-left: 20upx;
  2826. }
  2827. .video-but-view {
  2828. padding: 20upx;
  2829. border-radius: 10upx 10upx 0 0;
  2830. .video-but {
  2831. margin-bottom: 18upx;
  2832. background: #817e7e;
  2833. color: #fff;
  2834. }
  2835. }
  2836. .box textarea {
  2837. padding-left: 5px;
  2838. }
  2839. .list .list-box {
  2840. width: 25%;
  2841. display: flex;
  2842. align-items: center;
  2843. flex-direction: column;
  2844. }
  2845. .luckbtn {
  2846. -webkit-transform: rotateY(360deg);
  2847. animation: rotation 0.4s linear infinite;
  2848. -moz-animation: rotation 0.4s linear infinite;
  2849. -webkit-animation: rotation 0.4s linear infinite;
  2850. -o-animation: rotation 0.4s linear infinite;
  2851. }
  2852. @-webkit-keyframes rotation {
  2853. from {
  2854. -webkit-transform: rotateY(0deg);
  2855. }
  2856. to {
  2857. -webkit-transform: rotateY(360deg);
  2858. }
  2859. }
  2860. .bubble-bofang {
  2861. position: absolute;
  2862. right: 215upx;
  2863. }
  2864. .bubble-bofang-left {
  2865. position: absolute;
  2866. left: 215upx;
  2867. }
  2868. .showVedio {
  2869. width: 100%;
  2870. height: 100%;
  2871. position: absolute;
  2872. left: 0;
  2873. right: 0;
  2874. top: 0;
  2875. bottom: 0;
  2876. z-index: 300;
  2877. }
  2878. .cloneBut {
  2879. position: relative;
  2880. text-align: right;
  2881. font-size: 24px;
  2882. color: red;
  2883. margin-left: 10px;
  2884. margin-top: 10px;
  2885. height: 30px;
  2886. width: 30px;
  2887. }
  2888. .cloneBut-img {
  2889. position: absolute;
  2890. width: 30px;
  2891. }
  2892. ::-webkit-scrollbar {
  2893. width: 0;
  2894. height: 0;
  2895. color: transparent;
  2896. }
  2897. .gong-gao-content {
  2898. position: fixed;
  2899. /*height: 30px;*/
  2900. width: 100%;
  2901. z-index: 2;
  2902. /*padding: 10rpx 10rpx;*/
  2903. }
  2904. .gong-gao-content-info {
  2905. display: flex;
  2906. align-items: center;
  2907. background-color: #e0e0e0;
  2908. height: 100%;
  2909. }
  2910. .gong-gao-content-info-icon {
  2911. font-size: 20px;
  2912. margin-right: 20rpx;
  2913. margin-left: 20rpx;
  2914. }
  2915. .sys:nth-child(1) {
  2916. margin-top: 50px;
  2917. }
  2918. .member-image-logo {
  2919. display: flex;
  2920. justify-content: flex-start;
  2921. align-items: center;
  2922. padding-top: 10px;
  2923. box-shadow: inset 0px 15px 15px -23px #000;
  2924. background-color: #ffffff;
  2925. overflow-x: auto;
  2926. }
  2927. .member-content {
  2928. white-space: nowrap;
  2929. text-align: center;
  2930. }
  2931. .img-logo {
  2932. width: 40px !important;
  2933. height: 40px !important;
  2934. border-radius: 10px;
  2935. display: inline-block;
  2936. padding: 0 5px;
  2937. }
  2938. .jiazai {
  2939. margin-right: 20px;
  2940. }
  2941. .jiazai image {
  2942. width: 40rpx;
  2943. height: 40rpx;
  2944. }
  2945. </style>