message.vue 87 KB

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