message.vue 76 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280
  1. <template>
  2. <view class="page"
  3. style="overflow: hidden;">
  4. <!-- #ifdef APP-PLUS -->
  5. <serving-view :list_id="list_id" @setState="setSeringState" :show="showServing" :state="servingState" @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">
  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"
  27. :style="{height:scrollHeight}"
  28. scroll-y="true"
  29. :scroll-with-animation="scrollAnimation"
  30. :scroll-into-view="scrollToView"
  31. @scrolltoupper="loadHistory"
  32. :upper-threshold="30"
  33. id="scrollview"
  34. :scroll-top="scrollTop"
  35. @scroll="scrollEven"
  36. @touchstart="hideDrawer(3)"
  37. >
  38. <!--<view class="loading"-->
  39. <!--v-if="isHistoryLoading">-->
  40. <!--<view class="spinner">-->
  41. <!--<view class="rect1"></view>-->
  42. <!--<view class="rect2"></view>-->
  43. <!--<view class="rect3"></view>-->
  44. <!--<view class="rect4"></view>-->
  45. <!--<view class="rect5"></view>-->
  46. <!--</view>-->
  47. <!--</view>-->
  48. <uni-load-more status="noMore"
  49. v-if="noMore && !(isHistoryLoading)" />
  50. <view class="row"
  51. v-for="(row,index) in msgList.list"
  52. :key="index"
  53. :id="'msg' + row.msg.id">
  54. <!-- 系统消息 -->
  55. <block v-if="row.type==1">
  56. <view :class="['system',msgList.type == 1 && index == 0 ? 'sys':'']" :style="{padding:'10upx 0',marginBottom:'10upx'}">
  57. <!-- 文字消息 -->
  58. <view v-if="row.msg.type==0"
  59. class="text">
  60. {{row.msg.content.text}}
  61. </view>
  62. <!-- 领取红包消息 -->
  63. <view v-if="row.msg.type==5"
  64. class="red-envelope"
  65. style="letter-spacing:4upx;">
  66. <image src="/static/img/red-envelope-chat.png"
  67. :lazy-load="true" />
  68. <!-- {{row.msg}} -->
  69. <block v-if="row.msg.content.rid_user_id == my_data.id && row.msg.content.user_id == my_data.id">
  70. 我领取了自己发出的
  71. </block>
  72. <block v-else-if="row.msg.content.rid_user_id != my_data.id && row.msg.content.user_id == my_data.id">
  73. 我领取了{{row.msg.content.rid_nickname}}发出的
  74. </block>
  75. <block v-else-if="row.msg.content.rid_user_id == my_data.id && row.msg.content.user_id != my_data.id">
  76. {{row.msg.content.nickname}}领取了我发出的
  77. </block>
  78. <block v-else>
  79. {{row.msg.content.nickname}}领取了{{row.msg.content.rid_nickname}}发出的
  80. </block>
  81. <text style="color: red;"
  82. @tap="toDetails(row.msg.content.rid)">红包</text>
  83. </view>
  84. </view >
  85. </block>
  86. <block v-if="row.type == 0 && (index == 0 || (row.msg.time - msgList.list[index - 1].msg.time > 300))">
  87. <view class="system" style="margin-bottom: 10upx">
  88. <!-- 文字消息 -->
  89. <view class="text"
  90. style="color: #ffffff;border-radius:12px;font-weight:600">
  91. {{ timestampFormat(row.msg.time + '') }}
  92. </view>
  93. </view>
  94. </block>
  95. <!-- 用户消息 -->
  96. <block v-if="row.type==0">
  97. <!-- 自己发出的消息 -->
  98. <view class="my"
  99. v-if="row.msg.user_info.uid == my_data.id">
  100. <!-- 左-消息 -->
  101. <view class="left"
  102. @longtap="msgAction(row.msg.id +'',row.msg.user_info.uid + '',row.msg.type,row.msg.content)"
  103. :id="row.msg.id">
  104. <!-- 文字消息 -->
  105. <view v-if="row.msg.type==0"
  106. class="bubble">
  107. <view v-if="row.msg.content.text" class="" v-html="setEnter(row.msg.content.text)">
  108. </view>
  109. <!-- <rich-text :nodes="row.msg.content.text ? getHtml(row.msg.content.text) : ' '" space="true" selectable="true"/> -->
  110. </view>
  111. <!-- 语言消息 -->
  112. <view v-if="row.msg.type==1"
  113. class="bubble voice"
  114. @tap="playVoice(row.msg)"
  115. :class="playMsgid == row.msg.id?'play':''">
  116. <view class="length">{{row.msg.content.length}}</view>
  117. <view class="icon my-voice"></view>
  118. </view>
  119. <!-- 图片消息 -->
  120. <view v-if="row.msg.type==2"
  121. class="bubble img"
  122. @tap="showPic(row.msg)">
  123. <image :src="(staticPath + row.msg.content.url)"
  124. :style="{'width': row.msg.content.w+'px','height': row.msg.content.h+'px'}"
  125. :lazy-load="true" />
  126. </view>
  127. <!-- 视频消息 -->
  128. <view v-if="row.msg.type==3"
  129. class="bubble img">
  130. <image :src=" staticPath + row.msg.content.save_pic_path"
  131. style="width: 320px;height: 240px"></image>
  132. <image class="bubble-bofang"
  133. src="/static/theme/default/my/bofang.png"
  134. style="width: 50px;height: 50px;"
  135. @tap="autoVideo(row.msg)"></image>
  136. </view>
  137. <!-- 红包 -->
  138. <view v-if="row.msg.type==5"
  139. class="bubble red-envelope"
  140. @tap="openRedEnvelope(row.msg,index)">
  141. <image src="/static/img/red-envelope.png"
  142. :lazy-load="true" :style="{'opacity':(receive_list.indexOf(row.msg.content.rid))< 0 ? 1 : 0.6}"></image>
  143. <view class="tis">
  144. {{(receive_list.indexOf(row.msg.content.rid)) <0?'恭喜发财,大吉大利':'已领取'}}
  145. </view>
  146. <view class="blessing">
  147. <view class="info">
  148. {{row.msg.content.blessing}}
  149. </view>
  150. <view class="has-get-red">
  151. 点击打开红包
  152. </view>
  153. <!--{{row.msg.content.blessing}}-->
  154. </view>
  155. </view>
  156. <!-- 在线视频 -->
  157. <view v-if="row.msg.type==6"
  158. class="bubble">
  159. <view> {{row.msg.content.text}}
  160. </view>
  161. <text style="margin-left:2px"
  162. class="iconfont-im">&#xe619;
  163. </text>
  164. </view>
  165. <!-- 在线音频-->
  166. <view v-if="row.msg.type==7"
  167. class="bubble">
  168. <view> {{row.msg.content.text}}
  169. </view>
  170. <text style="margin-left:2px"
  171. class="iconfonts">&#xe60b;
  172. </text>
  173. </view>
  174. <!--卡片-->
  175. <view v-if="row.msg.type==8"
  176. class="send-card"
  177. @tap="getCard(row.msg)">
  178. <view class="send-card-content">
  179. <image :src="staticPhoto+row.msg.content.face"
  180. :lazy-load="true"
  181. style="width: 85upx;height: 85upx;"></image>
  182. <text>{{row.msg.content.nickname}}</text>
  183. </view>
  184. <view class="send-card-content-text">
  185. <text>名片</text>
  186. </view>
  187. </view>
  188. <!--戳一戳-->
  189. <view v-if="row.msg.type==9"
  190. class="bubble img"
  191. @tap="showPic(row.msg)">
  192. <image src="/static/theme/default/zuochuo.gif"
  193. :lazy-load="true"
  194. style="width: 70px;height: 70px;"/>
  195. </view>
  196. </view>
  197. <!-- 右-头像 -->
  198. <view class="right"
  199. @tap="goDetails(row.msg.user_info.uid,row)">
  200. <image :src="(row.msg.is_niming == 1) ? '/static/theme/default/my/niming.png' : myPhoto"
  201. :lazy-load="true"
  202. style="border-radius: 10px;"
  203. @error="imageError2" />
  204. </view>
  205. </view>
  206. <!-- 别人发出的消息 -->
  207. <view class="other"
  208. v-if="row.msg.user_info.uid != my_data.id">
  209. <!-- 左-头像 -->
  210. <view class="left"
  211. @tap="goDetails(row.msg.user_info.uid,row)">
  212. <image :src="(row.msg.is_niming == 1)? '/static/theme/default/my/niming.png' : (staticPhoto + row.msg.user_info.face)"
  213. :lazy-load="true"
  214. style="border-radius: 10px;"
  215. :data-id="index"
  216. @error="imageError" />
  217. </view>
  218. <!-- 右-用户名称-时间-消息 -->
  219. <view class="right"
  220. @longtap="msgAction(row.msg.id +'',row.msg.user_info.uid + '',row.msg.type,row.msg.content)">
  221. <!-- <view class="username">
  222. <view class="name">{{row.msg.user_info.username}}</view> <view class="time">{{row.msg.time}}</view>
  223. </view> -->
  224. <!-- 文字消息 -->
  225. <view v-if="row.msg.type==0"
  226. class="bubble">
  227. <view v-if="row.msg.content.text" class="" v-html="setEnter(row.msg.content.text)">
  228. </view>
  229. <!-- <rich-text :nodes="row.msg.content.text ? getHtml(row.msg.content.text) : ' '" space="true" /> -->
  230. </view>
  231. <!-- 语音消息 -->
  232. <view v-if="row.msg.type==1"
  233. class="bubble voice"
  234. @tap="playVoice(row.msg)"
  235. :class="playMsgid == row.msg.id?'play':''">
  236. <view class="icon other-voice"></view>
  237. <view class="length">{{row.msg.content.length}}</view>
  238. </view>
  239. <!-- 图片消息 -->
  240. <view v-if="row.msg.type==2"
  241. class="bubble img"
  242. @tap="showPic(row.msg)">
  243. <image :src="(staticPath + row.msg.content.url)"
  244. :style="{'width': row.msg.content.w+'px','height': row.msg.content.h+'px'}"
  245. :lazy-load="true" />
  246. </view>
  247. <!-- 视频消息 -->
  248. <view v-if="row.msg.type==3"
  249. class="bubble img">
  250. <image :src="staticPath + row.msg.content.save_pic_path"
  251. style="width: 320px;height: 240px"></image>
  252. <image class="bubble-bofang-left"
  253. src="/static/theme/default/my/bofang.png"
  254. style="width: 50px;height: 50px;"
  255. @tap="autoVideo(row.msg)"></image>
  256. </view>
  257. <!-- 红包 -->
  258. <view v-if="row.msg.type==5"
  259. class="bubble red-envelope"
  260. @tap="openRedEnvelope(row.msg,index)">
  261. <image src="/static/img/red-envelope-o.png"
  262. :lazy-load="true" :style="{'opacity':(receive_list.indexOf(row.msg.content.rid))< 0 ? 1 : 0.6}"></image>
  263. <view class="tis">
  264. {{(receive_list.indexOf(row.msg.content.rid)) <0?'恭喜发财,大吉大利':'已领取'}}
  265. </view>
  266. <view class="blessing">
  267. <view class="info">
  268. {{row.msg.content.blessing}}
  269. </view>
  270. <view class="has-get-red">
  271. 点击打开红包
  272. </view>
  273. <!--{{row.msg.content.blessing}}-->
  274. </view>
  275. </view>
  276. <view v-if="row.msg.type==6"
  277. class="bubble">
  278. <text style="margin-right:2px"
  279. class="iconfont-im">&#xe619;
  280. </text>
  281. {{row.msg.content.text}}
  282. </view>
  283. <view v-if="row.msg.type==7"
  284. class="bubble">
  285. <text style="margin-right:2px"
  286. class="iconfonts">&#xe60b;
  287. </text>
  288. {{row.msg.content.text}}
  289. </view>
  290. <view v-if="row.msg.type==8"
  291. class="send-card"
  292. @tap="getCard(row.msg)">
  293. <view class="send-card-content">
  294. <image :src="staticPhoto+row.msg.content.face"
  295. :lazy-load="true"
  296. style="width: 85upx;height: 85upx;"></image>
  297. <text>{{row.msg.content.nickname}}</text>
  298. </view>
  299. <view class="send-card-content-text">
  300. <text>名片</text>
  301. </view>
  302. </view>
  303. <view v-if="row.msg.type==9"
  304. class="bubble img"
  305. @tap="showPic(row.msg)">
  306. <image src="/static/theme/default/youchuo.gif"
  307. :lazy-load="true"
  308. style="width: 70px;height: 70px;"/>
  309. </view>
  310. </view>
  311. </view>
  312. </block>
  313. </view>
  314. </scroll-view>
  315. </view>
  316. <!-- 抽屉栏 -->
  317. <view class="popup-layer"
  318. :class="popupLayerClass"
  319. @touchmove.stop.prevent="discard">
  320. <!-- 表情 -->
  321. <swiper class="emoji-swiper"
  322. :class="{hidden:hideEmoji}"
  323. indicator-dots="true"
  324. duration="150">
  325. <swiper-item v-for="(page,pid) in emojiList"
  326. :key="pid">
  327. <view v-for="(em,eid) in page"
  328. :key="eid"
  329. @tap="addEmoji(em)">
  330. <image :src="'/static/img/emoji/' + em.url"
  331. :lazy-load="true" />
  332. </view>
  333. </swiper-item>
  334. </swiper>
  335. <!-- 更多功能 相册-拍照-红包 -->
  336. <view class="more-layer"
  337. :class="{hidden:hideMore}">
  338. <view class="list">
  339. <view class="list-box"
  340. @tap="chooseImage">
  341. <view class="icon tupian2"></view>
  342. <view class="tool_text">相册</view>
  343. </view>
  344. <view class="list-box"
  345. @tap="camera">
  346. <view class="icon paizhao"></view>
  347. <view class="tool_text">拍摄</view>
  348. </view>
  349. <view class="list-box"
  350. @tap="video">
  351. <view class="icon paizhao"></view>
  352. <view class="tool_text">视频</view>
  353. </view>
  354. <view class="list-box"
  355. @tap="handRedEnvelopes">
  356. <view class="icon hongbao"></view>
  357. <view class="tool_text">红包</view>
  358. </view>
  359. </view>
  360. <view class="list"
  361. style="margin-top: 8upx;">
  362. <view class="list-box"
  363. @tap="chooseCard">
  364. <view class="iconfont-im iconmingpian"></view>
  365. <view class="tool_text2">名片</view>
  366. </view>
  367. <view class="list-box"
  368. @tap="camera"
  369. v-if="0">
  370. <view class="iconfont-im iconlocation"></view>
  371. <view class="tool_text2">位置</view>
  372. </view>
  373. <!--#ifndef H5-->
  374. <view class="list-box"
  375. @tap="videoCall(1)" v-if="msgList.type == 0">
  376. <text class="iconfonts"
  377. style="font-size:50upx;">&#xe61f;
  378. </text>
  379. <view class="tool_text">视频通话</view>
  380. </view>
  381. <view class="list-box"
  382. @tap="videoCall(2)" v-if="msgList.type == 0">
  383. <text class="iconfont-im icon-voice"
  384. style="font-size:50upx;">
  385. </text>
  386. <view class="tool_text">语音通话</view>
  387. </view>
  388. <!-- #endif -->
  389. <view class="list-box"
  390. @tap="sayCall()" v-if="msgList.type == 1 && 0">
  391. <text class="iconfont-im icon-niming"
  392. style="font-size:50upx;">
  393. </text>
  394. <view class="tool_text">{{niming_msg}}</view>
  395. </view>
  396. <view class="list-box"
  397. @tap="zhendong" v-if="msgList.type == 1 && is_main">
  398. <view class="iconfont-im icon-zhendong"></view>
  399. <view class="tool_text2">振动</view>
  400. </view>
  401. <view class="list-box"
  402. @tap="showQiang()" v-if="msgList.type == 1 && vendor_status && is_main">
  403. <text class="iconfont-im icon-qiang"
  404. style="font-size:50upx;">
  405. </text>
  406. <view class="tool_text">发包</view>
  407. </view>
  408. </view>
  409. </view>
  410. </view>
  411. <view class="input-box"
  412. v-if="msgList.is_msg">
  413. <view style="text-align: center !important;width:750upx;line-height: 100upx;border-top: #c9c9c9 solid 2upx;">
  414. 全员禁言中...
  415. </view>
  416. </view>
  417. <!-- @touchmove.stop.prevent="discard" -->
  418. <!-- 底部输入栏 -->
  419. <view class="input-box"
  420. :class="popupLayerClass"
  421. v-else>
  422. <!-- H5下不能录音,输入栏布局改动一下 -->
  423. <!-- #ifndef H5 -->
  424. <view class="voice">
  425. <view class="icon"
  426. :class="isVoice?'jianpan':'yuyin'"
  427. @tap="switchVoice"></view>
  428. </view>
  429. <!-- #endif -->
  430. <!-- #ifdef H5 -->
  431. <view class="more"
  432. @tap="showMore">
  433. <view class="icon add"></view>
  434. </view>
  435. <!-- #endif -->
  436. <view class="textbox">
  437. <view class="voice-mode"
  438. :class="[isVoice?'':'hidden',recording?'recording':'']"
  439. @touchstart="voiceBegin"
  440. @touchmove.stop.prevent="voiceIng"
  441. @touchend="voiceEnd"
  442. @touchcancel="voiceCancel">
  443. {{voiceTis}}
  444. </view>
  445. <view class="text-mode"
  446. :class="isVoice?'hidden':''">
  447. <view class="box">
  448. <textarea auto-height="true"
  449. @input="inputText"
  450. :value="textMsg"
  451. @focus="textareaFocus"
  452. :maxlength="-1"
  453. :show-confirm-bar="false"
  454. style="max-height: 190upx;overflow:auto;border: 1px solid black; border-radius: 17px;padding-top: 4px;padding-bottom: 4px; " />
  455. </view>
  456. <view class="em" @tap="chooseEmoji">
  457. <view class="icon biaoqing"></view>
  458. </view>
  459. </view>
  460. </view>
  461. <!-- #ifndef H5 -->
  462. <view :class="iconShow" @tap="showMore">
  463. <view class="icon add"></view>
  464. </view>
  465. <!-- #endif -->
  466. <view class="send" :class="sendMsgClass" @tap="sendText">
  467. <view class="btn">发送</view>
  468. </view>
  469. </view>
  470. </view>
  471. <view v-show="showVedio"
  472. class="showVedio">
  473. <!-- <video :src="videoPath"
  474. style="height: 100%;width: 100%"
  475. id="myVideo"
  476. object-fit="fill"
  477. airplay="allow" /> -->
  478. <video autoplay="true"
  479. object-fit="fill"
  480. page-gesture="true"
  481. controls="false"
  482. style="height: 100%;width: 100%"
  483. id="myVideo"
  484. :src="videoPath"
  485. @error="videoErrorCallback">
  486. <!-- <cover-view
  487. @tap="showVedio = false"> -->
  488. <cover-image @tap="showVedio = false"
  489. src="/static/theme/default/my/close.png"
  490. class="cloneBut"></cover-image>
  491. <!-- </cover-view> -->
  492. </video>
  493. </view>
  494. <!-- #ifndef H5 -->
  495. <!-- 录音UI效果 -->
  496. <view class="record" :class="recording?'':'hidden'">
  497. <view class="ing" :class="willStop?'hidden':''">
  498. <view class="icon luyin2"></view>
  499. </view>
  500. <view class="cancel" :class="willStop?'':'hidden'">
  501. <view class="icon chehui"></view>
  502. </view>
  503. <view class="tis" :class="willStop?'change':''">{{recordTis}}</view>
  504. </view>
  505. <!-- #endif -->
  506. <!-- 红包弹窗 -->
  507. <view class="windows" :class="windowsState">
  508. <!-- 遮罩层 -->
  509. <view class="mask" @touchmove.stop.prevent="discard" @tap="closeRedEnvelope"></view>
  510. <view class="layer" @touchmove.stop.prevent="discard">
  511. <view class="open-redenvelope">
  512. <view class="top">
  513. <view class="close-btn">
  514. <view class="icon close" @tap="closeRedEnvelope"></view>
  515. </view>
  516. <image :src="staticPhoto+redenvelopeData.face" :lazy-load="true"></image>
  517. </view>
  518. <view class="from">来自{{redenvelopeData.from}}的红包</view>
  519. <view class="blessing">{{redenvelopeData.blessing}}</view>
  520. <view class="money" @tap="openRed(redenvelopeData)">
  521. <image :class="luckbtn" src="/static/theme/default/my/red_2.png" style="width: 180upx; height: 180upx;"></image>
  522. </view>
  523. <view class="showDetails" @tap="toDetails(redenvelopeData.rid)">
  524. 查看领取详情
  525. <view class="icon to"></view>
  526. </view>
  527. </view>
  528. </view>
  529. </view>
  530. <uni-popup ref="popup2" :show="videPoup" position="bottom" mode="666">
  531. <view class="video-but-view">
  532. <button class="video-but" type="primary" @tap="videoBut('video')" :loading="videoLoading">视频聊天</button>
  533. <button class="video-but" type="primary" @tap="videoBut('voice')" :loading="voiceLoading">语音聊天</button>
  534. <button type="default" @click="videPoup=false">取消</button>
  535. </view>
  536. </uni-popup>
  537. <uni-popup ref="popup" type="confirm">
  538. <uni-popup-confirm title="温馨提示" :content="popuMsg" @confirm = "confirm"> </uni-popup-confirm>
  539. </uni-popup>
  540. <uni-popup ref="qiang" type="qiang">
  541. <uni-popup-qiang title="开启发包" :status="miaoqiang + ''" :content="popuMsg" @confirm = "goQiang"> </uni-popup-qiang>
  542. </uni-popup>
  543. <view id="copyH5" style="display: none;">
  544. </view>
  545. </view>
  546. </template>
  547. <script>
  548. import uniLoadMore from "../../components/uni-ui/uni-load-more/uni-load-more.vue";
  549. import emoj_data from '../../static/js/message/emoji_data.js';
  550. import _get from '../../common/_get';
  551. import _hook from '../../common/_hook';
  552. import _action from '../../common/_action';
  553. import _data from '../../common/_data';
  554. import htmlParser from '../../common/html-parser';
  555. import uniPopup from '../../components/uni-popup/uni-popup.vue';
  556. import uniPopupConfirm from '../../components/uni-popup/uni-popup-confirm.vue';
  557. import uniPopupQiang from '../../components/uni-popup/uni-popup-qiang.vue';
  558. import textScroll from '../../components/textScroll/textScroll.vue'
  559. import { mapState,mapMutations } from 'vuex'
  560. export default {
  561. components: {
  562. uniLoadMore,
  563. uniPopup,
  564. uniPopupConfirm,
  565. uniPopupQiang,
  566. textScroll
  567. },
  568. data () {
  569. return {
  570. servingState:3,
  571. onLine:false,
  572. showServing:false,
  573. memberPhotos:[],
  574. is_main:0,
  575. redTimer:null,
  576. notice:'',
  577. scrollInfo:{
  578. input_box_height1:0,
  579. input_box_height2:0,
  580. totall_height:0,
  581. },
  582. scrollHeight:"0px",
  583. niming_msg:'匿名',
  584. videoContext: null,
  585. videoPath: '',
  586. showVedio: false,
  587. receive_list: [],
  588. luckbtn: '',
  589. scrollTop: 0,
  590. chat_id: '',
  591. //文字消息
  592. videPoup: false,
  593. videPlay: false,
  594. voiceLoading: false,
  595. videoLoading: false,
  596. textMsg: '',
  597. //消息列表
  598. isHistoryLoading: false,
  599. scrollAnimation: false,
  600. scrollToView: '',
  601. msgList: {
  602. show_name: '',
  603. list: [],
  604. type: 0,
  605. is_msg: 0,
  606. is_action: 0,
  607. },
  608. msgImgList: [],
  609. noMore: 0,
  610. isVoice: false,
  611. voiceTis: '按住 说话',
  612. recordTis: "手指上滑 取消发送",
  613. recording: false,
  614. willStop: false,
  615. initPoint: { identifier: 0, Y: 0 },
  616. recordTimer: null,
  617. recordLength: 0,
  618. // #ifdef APP-PLUS
  619. call: uni.requireNativePlugin('Html5App-TencentCall'),
  620. // #endif
  621. playMsgid: null,
  622. VoiceTimer: null,
  623. // 抽屉参数
  624. popupLayerClass: '',
  625. // more参数
  626. hideMore: true,
  627. //表情定义
  628. hideEmoji: true,
  629. emojiList: emoj_data.emoji_list,
  630. //表情图片图床名称 ,由于我上传的第三方图床名称会有改变,所以有此数据来做对应,您实际应用中应该不需要
  631. //onlineEmoji: emoj_data.online_emoji,
  632. //红包相关参数
  633. windowsState: '',
  634. redenvelopeData: {
  635. rid: null, //红包ID
  636. from: null,
  637. face: null,
  638. blessing: null,
  639. money: null,
  640. index: null
  641. },
  642. list_id: 0,
  643. my_data: {},
  644. style: {
  645. pageHeight: 0,
  646. contentViewHeight: 0,
  647. footViewHeight: 90,
  648. mitemHeight: 0
  649. },
  650. call_ret: false,
  651. my_photo: '',
  652. callType: 1, //默认视频,
  653. popuMsg: '',
  654. payTimer: false,
  655. type:'',
  656. Keyboard:0,
  657. miaoqiang:0,
  658. vendor_status:0,
  659. doubleClick:false,
  660. doubleTime:{
  661. firstTime:'',
  662. towTime:'',
  663. flag:true,
  664. timer:null,
  665. },
  666. group_state:null
  667. };
  668. },
  669. onBackPress (options) {
  670. console.log(options)
  671. uni.navigateTo({ url: '/pages/chat/index' });
  672. return false;
  673. },
  674. onLoad (option) {
  675. this.list_id = option.list_id;
  676. if ("chat_id" in option) {
  677. this.chat_id = option.chat_id;
  678. }
  679. if ("trans" in option) {
  680. uni.showToast({
  681. title:'转发成功',
  682. icon:'none',
  683. ducation:2000,
  684. });
  685. }
  686. //注册事件
  687. // 注册发送音频事件
  688. this.regOnStartEvent((e)=>{
  689. this.recordBegin(e);
  690. });
  691. // 注册发送音频事件
  692. this.regSendVoiceEvent((e)=>{
  693. this.recordEnd(e);
  694. });
  695. // 注册发送音频事件
  696. this.regVudioEndEvent((e)=>{
  697. this.playMsgid = null;
  698. });
  699. // //语音自然播放结束
  700. // this.AUDIO.onEnded((res) => {
  701. // this.playMsgid = null;
  702. // });
  703. //
  704. // // #ifndef H5
  705. // //录音开始事件
  706. // this.RECORDER.onStart((e) => {
  707. // this.recordBegin(e);
  708. // })
  709. // //录音结束事件
  710. // this.RECORDER.onStop((e) => {
  711. // this.recordEnd(e);
  712. // })
  713. // #endif
  714. },
  715. onUnload () {
  716. /** 这里只保留最新的15条会话记录,以保证初次加载性能 */
  717. let _this = this;
  718. let chat_data = this.msgList;
  719. chat_data.list = chat_data.list.slice(-15);
  720. _data.localData(this.list_id, chat_data);
  721. /** 去除当前会话的list_id */
  722. _data.localData('message_list_id', '');
  723. /** 暂停语音播放 */
  724. // this.AUDIO.pause();
  725. /** 移除监听事件 */
  726. uni.$off('data_chat_data_unshift');
  727. uni.$off('data_chat_data_push');
  728. uni.$off('data_chat_data');
  729. uni.$off('data_user_info');
  730. uni.$off('data_chat_data_delete');
  731. uni.$off('update_text_msg');
  732. uni.$off('memberJoinRoom');
  733. uni.$off('closeVoiceRoom');
  734. clearInterval(_this.timer)
  735. clearInterval(_this.redTimer);
  736. if(_data.data('voice_room_type')){
  737. _this.$refs.serving.xiaMai(_this.list_id);
  738. }else {
  739. _this.$refs.serving && _this.$refs.serving.closeVoiceRoom();
  740. }
  741. },
  742. mounted () {
  743. let _this = this
  744. if (this.chat_id) {
  745. this.$nextTick(() => {
  746. this.scrollToView = "msg" + this.chat_id
  747. })
  748. }
  749. setTimeout(function () {
  750. _this.getScrollContentHeight('hide',0);
  751. },400)
  752. },
  753. created () {
  754. },
  755. onShow() {
  756. _hook.routeSonHook();
  757. let _this = this;
  758. /** 先移除监听事件(避免重复触发消息) */
  759. uni.$off('data_chat_data_unshift');
  760. uni.$off('data_chat_data_push');
  761. uni.$off('data_chat_data');
  762. uni.$off('data_user_info');
  763. uni.$off('data_chat_data_delete');
  764. uni.$off('update_text_msg');
  765. uni.$off('memberJoinRoom');
  766. uni.$off('closeVoiceRoom');
  767. clearInterval(_this.timer)
  768. clearInterval(_this.redTimer)
  769. _this.my_photo = _data.data('cache').local_photo;
  770. let chat_data = _data.localData(_this.list_id);
  771. _this.my_data = _data.data('user_info');
  772. if (chat_data && chat_data.list.length) {
  773. _this.scrollAnimation = false;
  774. console.log('chat_data.show_name',chat_data.show_name)
  775. uni.setNavigationBarTitle({
  776. title: chat_data.show_name,
  777. });
  778. _this.addMsgImgList(chat_data.list);
  779. chat_data.list = _this.msgDataHandle(chat_data.list);
  780. _this.msgList = chat_data;
  781. console.log('111');
  782. // console.log(chat_data);
  783. console.log('222');
  784. _this.receive_list = _this.msgList.receive_list
  785. /** 滚动到指定位置 */
  786. // setTimeout(function () {
  787. // _this.$nextTick(function () {
  788. // _this.scrollTop =(new Date()).getTime();
  789. // // _this.scrollToView = 'msg' + data[data.length - 1].msg.id;
  790. // });
  791. // },400)
  792. /** 如果是群聊要实时检测群有无禁言 */
  793. _this.type = chat_data.type;
  794. if (chat_data.type == 1) {
  795. _this.getGroupSteate();
  796. }
  797. } else {
  798. _get.getChatData({
  799. send_data: {
  800. list_id: _this.list_id,
  801. time: 0,
  802. is_up: 1,
  803. },
  804. is_action_data: 1,
  805. });
  806. }
  807. /** 添加当前的会话list_id */
  808. _data.localData('message_list_id', this.list_id);
  809. /** 监听会话数据变化 */
  810. uni.$on('data_chat_data_unshift', function (data) {
  811. data = _this.msgDataHandle(data);
  812. _this.scrollAnimation = false;
  813. let position_id = _this.msgList.list[0].msg.id;
  814. _this.msgList.list.unshift(...data);
  815. /** 滚动到指定位置 */
  816. _this.$nextTick(function () {
  817. _this.scrollToView = 'msg' + position_id;
  818. });
  819. });
  820. /** 监听会话数据变化 */
  821. uni.$on('data_chat_data_push', function (data) {
  822. /** 保持页面15条数据,提升性能 */
  823. _this.noMore = 0;
  824. data = _this.msgDataHandle(data);
  825. _this.scrollAnimation = true;
  826. _this.msgList.list = data;
  827. _this.receive_list = _this.msgList.receive_list;
  828. /** 滚动到指定位置 */
  829. setTimeout(function () {
  830. _this.$nextTick(function () {
  831. // _this.scrollTop =(new Date()).getTime();
  832. _this.scrollTop =(new Date()).getTime();
  833. // _this.scrollToView = 'msg' + data[data.length - 1].msg.id;
  834. });
  835. },400)
  836. });
  837. /** 监听撤回消息 */
  838. uni.$on('data_chat_data_delete', function (list) {
  839. _this.msgList.list = list;
  840. });
  841. /** 监听会话数据变化 */
  842. uni.$on('data_chat_data', function (data) {
  843. uni.setNavigationBarTitle({
  844. title: data.show_name,
  845. });
  846. data.list = _this.msgDataHandle(data.list);
  847. _this.scrollAnimation = false;
  848. _this.msgList = data;
  849. _this.receive_list = _this.msgList.receive_list;
  850. if ( _this.msgList.type == 1) {
  851. _this.getGroupSteate();
  852. }
  853. /** 滚动到指定位置 */
  854. _this.$nextTick(function () {
  855. // _this.scrollTop =(new Date()).getTime();
  856. // _this.scrollToView = 'msg' + data.list[data.list.length - 1].msg.id;
  857. _this.scrollTop =(new Date()).getTime();
  858. });
  859. });
  860. /** 监听新的个人数据 */
  861. uni.$on('data_user_info', function (data) {
  862. _this.my_data = data;
  863. _this.my_photo = _data.staticPhoto() +_this.my_data.photo
  864. });
  865. //监听键盘高度变化
  866. uni.onKeyboardHeightChange(res => {
  867. _this.Keyboard = res.height;
  868. console.log("_this.Keyboard",_this.Keyboard)
  869. if(res.height){
  870. //
  871. _this.getScrollContentHeight("show",0);
  872. }else{
  873. _this.getScrollContentHeight("hide",0);
  874. }
  875. });
  876. uni.$on('update_text_msg',function (res) {
  877. _this.textMsg +=res.msg
  878. });
  879. uni.$on('memberJoinRoom',function (res) {
  880. _this.$refs.serving.memberJoin(_this.list_id,function () {
  881. _this.onLine = true;
  882. _this.showServing = true;
  883. })
  884. })
  885. uni.$on('closeVoiceRoom',function (res) {
  886. _this.$refs.serving.closeVoiceRoom()
  887. })
  888. _get.getMemberPhotos({list_id:_this.list_id},function (ret) {
  889. _this.memberPhotos = ret
  890. });
  891. },
  892. computed: {
  893. ...mapState({
  894. RECORD:state=>state.audio.RECORD,
  895. AUDIO:state=>state.audio.AUDIO,
  896. RecordTime:state=>state.audio.RecordTime,
  897. KeyboardH:state=>state.common.KeyboardHeight
  898. }),
  899. getServingText(){
  900. return _data.data('dragInfo').state == 1 ? '下麦' : '上麦';
  901. },
  902. myPhoto () {
  903. return this.my_photo;
  904. },
  905. imgRan () {
  906. return Math.random();
  907. },
  908. staticPath () {
  909. return _data.staticChat() + this.list_id + '/';
  910. },
  911. staticVideoImg () {
  912. return _data.staticVideoImg()
  913. },
  914. staticPhoto () {
  915. return _data.staticPhoto();
  916. },
  917. sendMsgClass () {
  918. // #ifdef H5
  919. return (this.isVoice ? 'hidden' : '');
  920. // #endif
  921. return (this.isVoice ? 'hidden' : '') || this.textMsg.length ? '' : 'hidden';
  922. },
  923. iconShow () {
  924. return this.textMsg.length ? 'hidden' : 'more';
  925. },
  926. systemClass(){
  927. return this.msgList.type == 1 ? 'sys':'';
  928. }
  929. },
  930. onReady: function (res) {
  931. let _this = this;
  932. if(_this.msgList.type == 1){
  933. // setTimeout(function () {
  934. // _this.$refs.scrollNotice.textScroll()
  935. // },300);
  936. }
  937. },
  938. methods: {
  939. ...mapMutations(['regSendVoiceEvent','regOnStartEvent','regVudioEndEvent']),
  940. getHtml(content){
  941. return htmlParser(content);
  942. },
  943. setEnter(content){
  944. content=content.replace(/%&回车%&/g,"<br>")
  945. return content
  946. },
  947. inputText(e){
  948. //截取最后一位
  949. let str = e.detail.value;
  950. let length1 = str.length;
  951. let key = str.substr( length1-1,1);
  952. if(key && key == '@' && this.msgList.type== 1 && length1 > this.textMsg.length){
  953. this.textMsg = str;
  954. console.log('跳转到群成员列表');
  955. uni.navigateTo({url:'/pages/chat/group_list?list_id='+this.list_id});
  956. return true;
  957. }
  958. this.textMsg = str;
  959. },
  960. getScrollContentHeight(type = 'show',not_return = 1){
  961. let _this = this;
  962. let query = uni.createSelectorQuery();
  963. query.select('.more-layer').boundingClientRect();
  964. query.select('.input-box').boundingClientRect();
  965. uni.getSystemInfo({
  966. success:function (res) {
  967. console.log("windowHeight:",res.windowHeight);
  968. _this.scrollInfo.totall_height = res.windowHeight;
  969. query.exec(data => {
  970. _this.scrollInfo.input_box_height1 = data[0].height || 0;
  971. _this.scrollInfo.input_box_height2 = data[1].height || 0;
  972. _this.autoHeight(type,not_return)
  973. })
  974. }
  975. })
  976. },
  977. autoHeight(type,not_return){
  978. let _this = this;
  979. let addr = this;
  980. if(type == 'show'){
  981. if(this.Keyboard){
  982. // console.log(" _this.scrollInfo.totall_height:", _this.scrollInfo.totall_height);
  983. console.log(" _this.Keyboard:", _this.Keyboard);
  984. // console.log(" _this.scrollInfo.input_box_height2:", _this.scrollInfo.input_box_height2);
  985. this.scrollHeight = ( _this.scrollInfo.totall_height - _this.Keyboard-_this.scrollInfo.input_box_height2) + 'px';
  986. }else {
  987. this.scrollHeight = ( _this.scrollInfo.totall_height - _this.scrollInfo.input_box_height1-_this.scrollInfo.input_box_height2) + 'px';
  988. }
  989. }else {
  990. //content高度 = 屏幕高度-tool高度
  991. uni.getSystemInfo({
  992. success: function (res) {
  993. res.windowHeight = res.windowHeight,
  994. addr = res.windowHeight;
  995. if(_this.Keyboard){
  996. _this.scrollHeight = (res.windowHeight - _this.scrollInfo.Keyboard - _this.scrollInfo.input_box_height2) + 'px'
  997. }else{
  998. _this.scrollHeight = (res.windowHeight - _this.scrollInfo.input_box_height2) + 'px'
  999. }
  1000. }
  1001. });
  1002. // this.scrollHeight = '100%'
  1003. }
  1004. switch(uni.getSystemInfoSync().platform){
  1005. case 'android':
  1006. if(not_return == 0){
  1007. this.$nextTick(() => {
  1008. _this.scrollTop =(new Date()).getTime();
  1009. })
  1010. }
  1011. break;
  1012. case 'ios':
  1013. if(not_return == 0&&type == 'hide'){
  1014. this.$nextTick(() => {
  1015. _this.scrollTop = addr+200;
  1016. })
  1017. }else if(not_return == 0&&type == 'show'){
  1018. this.$nextTick(() => {
  1019. _this.scrollTop = (new Date()).getTime()*2;
  1020. })
  1021. }
  1022. break;
  1023. }
  1024. /* if(not_return == 0){
  1025. this.$nextTick(() => {
  1026. _this.scrollTop =(new Date()).getTime();
  1027. })
  1028. } else if(not_return == 1) {
  1029. this.$nextTick(() => {
  1030. _this.scrollTop = addr+200;
  1031. })
  1032. } */
  1033. /* if(not_return == 0){
  1034. console.log('执行高度调整', addr)
  1035. this.$nextTick(() => {
  1036. _this.scrollTop =(new Date()).getTime();
  1037. })
  1038. } */
  1039. },
  1040. getGroupSteate(){
  1041. let _this = this;
  1042. this.$httpSend({
  1043. path: '/im/action/groupState',
  1044. data: { list_id: _this.list_id },
  1045. success (res) {
  1046. console.log("_this.vendor_status",_this.vendor_status)
  1047. _this.msgList.is_msg = res.is_msg;
  1048. _this.msgList.is_action = res.is_action;
  1049. _this.msgList.is_niming = res.is_niming;
  1050. _this.niming_msg = res.is_niming == 0 ? '匿名' : '退出匿名';
  1051. _this.miaoqiang = res.miaoqiang;
  1052. _this.vendor_status = res.vendor_status;
  1053. _this.notice = res.notice;
  1054. _this.is_main = res.is_main;
  1055. _this.group_state = res
  1056. console.log("_this.qiang_time:",res.qiang_time)
  1057. if(_this.miaoqiang && _this.is_main && res.qiang_time > 0){
  1058. _this.autoFaRed(res.qiang_time)
  1059. }
  1060. if(res.voice_room_state){ //有人发起语音则自动加入
  1061. //加入视频
  1062. _this.$refs.serving.memberJoin(_this.list_id,function () {
  1063. _this.onLine = true;
  1064. });
  1065. }
  1066. }
  1067. });
  1068. },
  1069. videoErrorCallback () {
  1070. },
  1071. autoVideo (msg) {
  1072. console.log(msg)
  1073. this.showVedio = true;
  1074. this.videoPath = _data.staticChat() + this.list_id + "/" + msg.content.url;
  1075. },
  1076. getCard (msg) {
  1077. console.log(msg.content)
  1078. console.log(msg.content.user_id)
  1079. if (msg.content.user_id != undefined) {
  1080. uni.navigateTo({
  1081. url: '/pages/details/index?in=1&user_id=' + msg.content.user_id
  1082. })
  1083. }
  1084. },
  1085. chooseCard () {
  1086. uni.navigateTo({
  1087. url: './message/card_list?list_id=' + this.list_id
  1088. });
  1089. },
  1090. imageError (e) {
  1091. // this.my_photo = _data.staticPhoto() + '/default_photo_path.png';
  1092. console.log("图片加载失败!", e.detail);
  1093. let index = e.currentTarget.dataset.id;
  1094. //替换index对应的图片
  1095. console.log(this.msgList.list[index].msg.user_info.face)
  1096. this.msgList.list[index].msg.user_info.face = '/default_photo_path.png';
  1097. },
  1098. imageError2 (e) {
  1099. this.my_photo = _data.staticPhoto() + '/default_photo_path.png';
  1100. },
  1101. scrollToDom () {
  1102. let that = this;
  1103. let query = uni.createSelectorQuery();
  1104. query.select('#msg' + that.chat_id).boundingClientRect();
  1105. query.select('#scrollview').boundingClientRect();
  1106. query.exec((res) => {
  1107. that.style.mitemHeight = 0;
  1108. console.log(res);
  1109. let rect = res[0];
  1110. that.style.mitemHeight = that.style.mitemHeight + rect.height + 40;
  1111. if (that.style.mitemHeight > (that.style.contentViewHeight - 100)) { //判断子元素高度是否大于显示高度
  1112. that.scrollTop = that.style.mitemHeight - that.style.contentViewHeight //用子元素的高度减去显示的高度就获益获得序言滚动的高度
  1113. }
  1114. });
  1115. },
  1116. //
  1117. //发起视频聊天
  1118. videoBut (type) {
  1119. let content_type = 6;
  1120. this.call_ret = false;
  1121. if (type === 'voice') {
  1122. this.voiceLoading = true;
  1123. content_type = 7;
  1124. } else {
  1125. this.videoLoading = true
  1126. }
  1127. let _this = this
  1128. console.log("content_type",content_type);
  1129. this.$httpSend({
  1130. path: '/im/message/sendVideo',
  1131. data: { list_id: this.list_id, content_type: content_type, _token: uni.getStorageSync('token') },
  1132. success_action: true,
  1133. success (res) {
  1134. if (res.err === 0) {
  1135. //图片转化
  1136. res.data.myavatar = _this.staticPhoto + res.data.myavatar;
  1137. res.data.avatar = _this.staticPhoto + res.data.avatar;
  1138. _this.getVideo(res.data);
  1139. } else {
  1140. }
  1141. console.log(res.data)
  1142. }
  1143. });
  1144. },
  1145. //调用视频/音频
  1146. getVideo (data) {
  1147. let _this = this;
  1148. // #ifdef APP-PLUS
  1149. _this.call.openCall(
  1150. {
  1151. type: 1,
  1152. ...data
  1153. }, ret => {
  1154. this.doubleClick = false;
  1155. if (ret) {
  1156. _this.videPoup = false;
  1157. _this.voiceLoading = false;
  1158. console.log(JSON.stringify(ret))
  1159. if(ret.code == 5 && !_this.payTimer){
  1160. console.log('发起付费');
  1161. //先扣一次
  1162. _get.payVideoAamount({list_id:_this.list_id},function(res){
  1163. console.log(res);
  1164. },function(res){
  1165. console.log(res);
  1166. })
  1167. _this.payTimer = setInterval(function () {
  1168. _get.payVideoAamount({list_id:_this.list_id},function(res){
  1169. console.log(res);
  1170. },function(res){
  1171. console.log(res);
  1172. clearInterval(_this.payTimer);//取消收费
  1173. _this.payTimer = false;
  1174. })
  1175. },60000);
  1176. }
  1177. if (ret.code == 1 && ret.time != undefined) { //对方或者自己取消
  1178. data.time = ret.time;
  1179. data.ret_code = ret.code;
  1180. console.log(JSON.stringify(data));
  1181. _get.cancelCall(data, function (res) {
  1182. });
  1183. }
  1184. }
  1185. });
  1186. // #endif
  1187. },
  1188. // 发起视频通话
  1189. videoCall (type) {
  1190. //判断是否开启语音和视频计费
  1191. let _this = this;
  1192. _this.callType = type;
  1193. _get.getVedioPayConfig({}, function (ret) {
  1194. let msg1 = '在线视频通话每分钟' + ret.vedio + '元';
  1195. let msg2 = '在线语音通话每分钟' + ret.voice + '元';
  1196. _this.popuMsg = msg1;
  1197. let amount = _this.type == 1 ? ret.vedio : ret.voice;
  1198. if(_this.my_data.money < amount) {
  1199. uni.showToast({
  1200. title:"账号余额不足以支付1分钟在线"+(_this.type == 1 ? '视频' : '语音')+'通话',
  1201. duration:3000,
  1202. icon:"none"
  1203. })
  1204. return false;
  1205. }
  1206. if (type == 2) _this.popuMsg = msg2
  1207. if (ret.vedio > 0 || ret.voice > 0) {
  1208. _this.$refs.popup.open();
  1209. return true;
  1210. }
  1211. _this.confirm()
  1212. })
  1213. // this.videPoup = true
  1214. // this.hideDrawer();
  1215. },
  1216. confirm () {
  1217. if(this.doubleClick) return false;
  1218. this.doubleClick = true;
  1219. if (this.callType == 1) {
  1220. this.videoBut('video');
  1221. } else {
  1222. this.videoBut('voice');
  1223. }
  1224. this.$refs.popup.close();
  1225. },
  1226. msgDataHandle (data, type) {
  1227. for (let i = 0, j = data.length, msg_img; i < j; i++) {
  1228. if (data[i].type == 0 && data[i].msg.type == 2) {
  1229. msg_img = this.staticPath + data[i].msg.content.url.replace('_thumb.', '.');
  1230. if (type) {
  1231. this.msgImgList.unshift(msg_img);
  1232. } else {
  1233. this.msgImgList.push(msg_img);
  1234. }
  1235. data[i].msg.content = this.setPicSize(data[i].msg.content);
  1236. } else if (data[i].type == 0 && data[i].msg.type == 0) {
  1237. data[i].msg.content.text = this.replaceEmoji(data[i].msg.content.text);
  1238. }
  1239. }
  1240. return data;
  1241. },
  1242. addMsgImgList (data) {
  1243. for (let i = 0, j = data.length, msg_img; i < j; i++) {
  1244. if (data[i].type == 0 && data[i].msg.type == 2) {
  1245. this.msgImgList.push(this.staticPath + data[i].msg.content.url.replace('_thumb.', '.'));
  1246. }
  1247. }
  1248. },
  1249. timestampFormat (time) {
  1250. return _action.timestampFormat(time);
  1251. },
  1252. msgAction (id, user_id,type,content) {
  1253. let _this = this;
  1254. // switch (_this.msgList.type) {
  1255. // case 0:
  1256. // if (user_id != _this.my_data.id) {
  1257. // return;
  1258. // }
  1259. // break;
  1260. // case 1:
  1261. // if (_this.msgList.is_action == 0 && user_id != _this.my_data.id) {
  1262. // return;
  1263. // }
  1264. // break;
  1265. // default:
  1266. // return;
  1267. // break;
  1268. // }
  1269. var itemList=type==0?['撤回','收藏','复制']:['撤回','收藏']
  1270. uni.showActionSheet({
  1271. itemList: itemList,
  1272. success: function (res) {
  1273. switch (res.tapIndex) {
  1274. case 0:
  1275. _this.$httpSend({
  1276. path: '/im/message/withdraw',
  1277. data: { list_id: _this.list_id, type: _this.msgList.type, msg_id: id, },
  1278. success_action: true,
  1279. success (res) {
  1280. uni.showToast({
  1281. title: res.msg,
  1282. icon: 'none',
  1283. duration: 1500
  1284. });
  1285. }
  1286. });
  1287. break;
  1288. case 1:
  1289. console.log("收藏");
  1290. _this.$httpSend({
  1291. path: '/im/vendor/saveStore',
  1292. data: { list_id: _this.list_id, type: _this.msgList.type, msg_id: id, },
  1293. success_action: true,
  1294. success (res) {
  1295. uni.showToast({
  1296. title: res.msg,
  1297. icon: 'none',
  1298. duration: 1500
  1299. });
  1300. }
  1301. });
  1302. break;
  1303. //收藏
  1304. case 2://复制
  1305. // #ifdef APP-PLUS
  1306. uni.setClipboardData({
  1307. data: content.text.match(/<div[\s\S]*;">([\s\S]*)<\/div\>/)[1].replace(/<\/div\>/g,"")
  1308. });
  1309. // #endif
  1310. // #ifdef H5
  1311. var oInput = document.createElement('input');
  1312. oInput.value = content.text.match(/<div[\s\S]*;">([\s\S]*)<\/div\>/)[1].replace(/<\/div\>/g,"");
  1313. document.body.appendChild(oInput);
  1314. oInput.select(); // 选择对象
  1315. document.execCommand("Copy");
  1316. // #endif
  1317. break;
  1318. default:
  1319. break;
  1320. }
  1321. },
  1322. fail: function (res) {
  1323. //console.log(res.errMsg);
  1324. }
  1325. });
  1326. },
  1327. goDetails (user_id,row) {
  1328. /** 如果是群聊,没有权限的话,查看不了其他会员信息 */
  1329. if (this.msgList.type == 1 && (this.msgList.is_action == 0 || row.msg.is_niming == 1)) {
  1330. uni.showToast({
  1331. title: '没有权限查看',
  1332. icon: 'none',
  1333. duration: 1000
  1334. });
  1335. return;
  1336. }
  1337. uni.navigateTo({
  1338. url: ('../details/index?user_id=' + user_id),
  1339. })
  1340. },
  1341. // 接受消息(筛选处理)
  1342. screenMsg (msg) {
  1343. //从长连接处转发给这个方法,进行筛选处理
  1344. if (msg.type == 1) {
  1345. // 系统消息
  1346. switch (msg.msg.type) {
  1347. case 0:
  1348. this.addSystemTextMsg(msg);
  1349. break;
  1350. case 5:
  1351. this.addSystemRedEnvelopeMsg(msg);
  1352. break;
  1353. }
  1354. } else if (msg.type == 0) {
  1355. // 用户消息
  1356. switch (msg.msg.type) {
  1357. case 0:
  1358. this.addTextMsg(msg);
  1359. break;
  1360. case 1:
  1361. this.addVoiceMsg(msg);
  1362. break;
  1363. case 2:
  1364. this.addImgMsg(msg);
  1365. break;
  1366. case 5:
  1367. this.addRedEnvelopeMsg(msg);
  1368. break;
  1369. }
  1370. //console.log('用户消息');
  1371. //非自己的消息震动
  1372. if (msg.msg.user_info.uid != this.my_data.id) {
  1373. //console.log('振动');
  1374. uni.vibrateLong();
  1375. }
  1376. }
  1377. let _this =this
  1378. this.$nextTick(function () {
  1379. // 滚动到底
  1380. _this.scrollTop =(new Date()).getTime();
  1381. });
  1382. },
  1383. //触发滑动到顶部(加载历史信息记录)
  1384. loadHistory () {
  1385. if (this.isHistoryLoading || this.noMore) {
  1386. return;
  1387. }
  1388. let _this = this;
  1389. this.isHistoryLoading = true; //参数作为进入请求标识,防止重复请求
  1390. _get.getChatData({
  1391. send_data: {
  1392. list_id: _this.list_id,
  1393. time: _this.msgList.list[0].msg.time,
  1394. is_up: 0,
  1395. },
  1396. callback (data) {
  1397. if (data.list.length < 15) {
  1398. _this.noMore = 1;
  1399. }
  1400. _this.isHistoryLoading = false;
  1401. },
  1402. is_action_data: 0,
  1403. });
  1404. },
  1405. //处理图片尺寸,如果不处理宽高,新进入页面加载图片时候会闪
  1406. setPicSize (content) {
  1407. // 让图片最长边等于设置的最大长度,短边等比例缩小,图片控件真实改变,区别于aspectFit方式。
  1408. let maxW = uni.upx2px(350);//350是定义消息图片最大宽度
  1409. let maxH = uni.upx2px(350);//350是定义消息图片最大高度
  1410. if (content.w > maxW || content.h > maxH) {
  1411. let scale = content.w / content.h;
  1412. content.w = scale > 1 ? maxW : maxH * scale;
  1413. content.h = scale > 1 ? maxW / scale : maxH;
  1414. let url_array = content.url.split('.');
  1415. if (content.url.indexOf('_thumb.') == -1) {
  1416. content.url = url_array[0] + '_thumb.' + url_array[1];
  1417. }
  1418. }
  1419. return content;
  1420. },
  1421. //更多功能(点击+弹出)
  1422. showMore () {
  1423. this.isVoice = false;
  1424. this.hideEmoji = true;
  1425. if (this.hideMore) {
  1426. this.hideMore = false;
  1427. this.openDrawer();
  1428. } else {
  1429. this.hideDrawer();
  1430. }
  1431. },
  1432. // 打开抽屉
  1433. openDrawer () {
  1434. let _this = this;
  1435. this.popupLayerClass = 'showLayer';
  1436. this.hideMore = false;
  1437. setTimeout(function () {
  1438. console.log("scorll...")
  1439. _this.getScrollContentHeight('show',0);
  1440. },150)
  1441. },
  1442. // 隐藏抽屉
  1443. hideDrawer (not_return =0,type="hide") {
  1444. //判断时间
  1445. if(not_return == 3){
  1446. let time = (new Date()).getTime();
  1447. if(this.doubleTime.flag){
  1448. this.doubleTime.firstTime = time
  1449. this.doubleTime.flag = false;
  1450. }else {
  1451. this.doubleTime.towTime = time
  1452. this.doubleTime.flag = true;
  1453. }
  1454. let timeBucket = this.doubleTime.towTime - this.doubleTime.firstTime;
  1455. console.log('timeBucket:',timeBucket)
  1456. if(timeBucket < 200 && this.doubleTime.flag){
  1457. //第二次进来
  1458. clearTimeout(this.timer);
  1459. this.doubleTime.towTime = '';
  1460. this.doubleTime.firstTime = '';
  1461. this.sendChuoYiChuoMsg();
  1462. // this.textMsg = '[戳一戳]'
  1463. // this.sendMsg(this.textMsg,0);
  1464. // this.textMsg = ''
  1465. // //发送戳一戳
  1466. return false;
  1467. }
  1468. let _this = this;
  1469. this.timer = setTimeout(function () {
  1470. _this.toHideDrawer(not_return,type)
  1471. },280)
  1472. }else {
  1473. this.toHideDrawer(not_return,type)
  1474. }
  1475. },
  1476. sendChuoYiChuoMsg(){
  1477. _get.sendChuoYiChuoMsg({list_id:this.list_id},function () {
  1478. })
  1479. },
  1480. toHideDrawer(not_return =0,type="hide") {
  1481. this.popupLayerClass = '';
  1482. setTimeout(() => {
  1483. this.hideMore = true;
  1484. this.hideEmoji = true;
  1485. this.getScrollContentHeight(type,not_return);
  1486. }, 150);
  1487. },
  1488. // 选择图片发送
  1489. chooseImage () {
  1490. this.getImage('album');
  1491. },
  1492. //拍照发送
  1493. camera () {
  1494. this.getImage('camera');
  1495. },
  1496. // 位置
  1497. Position(){
  1498. uni.getLocation({
  1499. type: 'wgs84 ',
  1500. success: function (res) {
  1501. console.log('经度:' + res.longitude);
  1502. console.log('纬度:' + res.latitude);
  1503. let msg = { url: 'https://apis.map.qq.com/ws/staticmap/v2/?center='+res.latitude+','+res.longitude+'&zoom=10&size=600*300&maptype=roadmap&key=R7WBZ-F4DL4-DW3UP-DZIEC-7DZNZ-OOF4A' };
  1504. this.sendMsg(msg, 2);
  1505. },fail:function(err){
  1506. console.log(err)
  1507. }
  1508. });
  1509. },
  1510. //拍摄视频发送
  1511. video () {
  1512. uni.chooseVideo({
  1513. success: (res) => {
  1514. let min = parseInt(res.size / 60),
  1515. sec = res.size % 60;
  1516. min = min < 10 ? '0' + min : min;
  1517. sec = sec < 10 ? '0' + sec : sec;
  1518. let msg = { url: res.tempFilePath, length: (min + ':' + sec) };
  1519. this.sendMsg(msg, 3);
  1520. }
  1521. })
  1522. },
  1523. //发红包
  1524. handRedEnvelopes () {
  1525. // this.hideDrawer(1);
  1526. console.log(111)
  1527. let url = 'message/hand?list_id=' + this.list_id+'&msg_type='+this.msgList.type;
  1528. if(this.vendor_status)url = 'message/hand_pin?list_id=' + this.list_id+'&msg_type='+this.msgList.type;;
  1529. uni.navigateTo({
  1530. url: url
  1531. });
  1532. },
  1533. //转账
  1534. transfers () {
  1535. //TODO跳转到转账页面
  1536. },
  1537. //选照片 or 拍照
  1538. getImage (type) {
  1539. this.hideDrawer(1);
  1540. uni.chooseImage({
  1541. sourceType: [type],
  1542. sizeType: ['original', 'compressed'], //可以指定是原图还是压缩图,默认二者都有
  1543. success: (res) => {
  1544. for (let i = 0; i < res.tempFilePaths.length; i++) {
  1545. uni.getImageInfo({
  1546. src: res.tempFilePaths[i],
  1547. success: (image) => {
  1548. //console.log(image.width);
  1549. //console.log(image.height);
  1550. let msg = { url: res.tempFilePaths[i], w: image.width, h: image.height };
  1551. this.sendMsg(msg, 2);
  1552. }
  1553. });
  1554. }
  1555. }
  1556. });
  1557. },
  1558. // 选择表情
  1559. chooseEmoji () {
  1560. this.hideMore = true;
  1561. if (this.hideEmoji) {
  1562. this.hideEmoji = false;
  1563. this.openDrawer();
  1564. } else {
  1565. this.hideDrawer();
  1566. }
  1567. },
  1568. //添加表情
  1569. addEmoji (em) {
  1570. this.textMsg += em.alt;
  1571. },
  1572. //获取焦点,如果不是选表情ing,则关闭抽屉
  1573. textareaFocus () {
  1574. let _this = this;
  1575. _this.hideDrawer(0,'show');
  1576. return;
  1577. if (_this.popupLayerClass == 'showLayer' && this.hideMore == false) {
  1578. _this.hideDrawer();
  1579. }
  1580. },
  1581. // 发送文字消息
  1582. sendText () {
  1583. this.hideDrawer(1);//隐藏抽屉
  1584. if (!this.textMsg) {
  1585. return;
  1586. }
  1587. this.sendMsg('', 0);
  1588. //清空输入框
  1589. this.textMsg = '';
  1590. },
  1591. //替换表情符号为图片
  1592. replaceEmoji (str) {
  1593. let replacedStr = str.replace(/\[([^(\]|\[)]*)\]/g, (item, index) => {
  1594. // console.log("item: " + item);
  1595. for (let i = 0; i < this.emojiList.length; i++) {
  1596. let row = this.emojiList[i];
  1597. for (let j = 0; j < row.length; j++) {
  1598. let EM = row[j];
  1599. if (EM.alt == item) {
  1600. //在线表情路径,图文混排必须使用网络路径,请上传一份表情到你的服务器后再替换此路径
  1601. //比如你上传服务器后,你的100.gif路径为https://www.xxx.com/emoji/100.gif 则替换onlinePath填写为https://www.xxx.com/emoji/
  1602. let imgstr = '<img style="width:22px;height:22px;" src="' + _data.data('static_url') + '/static/emoji/' + EM.url + '">';
  1603. // console.log("imgstr: " + imgstr);
  1604. return imgstr;
  1605. }
  1606. }
  1607. }
  1608. });
  1609. // display: flex;
  1610. return '<div style="align-items: center;word-break:break-all;">' + replacedStr + '</div>';
  1611. },
  1612. showQiang(){
  1613. this.$refs.qiang.open();
  1614. },
  1615. autoFaRed(num){
  1616. let _this = this;
  1617. let time = num * 1000;
  1618. if(time <=0) return false;
  1619. if(_this.timer) clearInterval(_this.redTimer);
  1620. _this.redTimer = setInterval(function () {
  1621. _get.autoBigRed({list_id:_this.list_id},function () {})
  1622. },num * 1000)
  1623. },
  1624. goQiang(e){
  1625. let _this = this;
  1626. e.list_id = _this.list_id;
  1627. _get.updateMiaoqiang(e,function (res) {
  1628. _this.miaoqiang = e.status;
  1629. console.log(e)
  1630. if(e.status == 1){
  1631. console.log('发包.......')
  1632. _this.autoFaRed(e.num)
  1633. }else {
  1634. clearInterval(_this.redTimer);
  1635. }
  1636. setTimeout(function () {
  1637. uni.showToast({
  1638. title: '操作成功',
  1639. duration: 2000
  1640. });
  1641. _this.$refs.qiang.close();
  1642. },500)
  1643. });
  1644. },
  1645. // 发送消息
  1646. sendMsg (content, type) {
  1647. // uni.showLoading();
  1648. let _this = this,
  1649. sendMsg = content;
  1650. ((callback) => {
  1651. switch (type) {
  1652. /** 文字/表情消息 */
  1653. case 0:
  1654. let msg = this.textMsg.replace(/</g, '&lt;');
  1655. msg = JSON.parse(JSON.stringify(msg).replace(/\\n/g, '%&回车%&'))
  1656. sendMsg = { text: msg };
  1657. callback();
  1658. break;
  1659. /** 语音/图片/视频/文件 */
  1660. case 1:
  1661. case 2:
  1662. case 3:
  1663. case 4:
  1664. uni.showLoading({ title: '发送中' })
  1665. _this.$httpSendFile({
  1666. type: 0,
  1667. local_url: sendMsg.url,
  1668. data: {
  1669. 'list_id': _this.list_id,
  1670. },
  1671. success (data) {
  1672. uni.hideLoading();
  1673. sendMsg.url = data.save_name;
  1674. if ('save_gif_path' in data) sendMsg.save_pic_path = data.save_gif_path;
  1675. console.log('success');
  1676. callback();
  1677. }
  1678. });
  1679. break;
  1680. /** 红包消息 */
  1681. case 5:
  1682. break;
  1683. default:
  1684. break;
  1685. }
  1686. })(() => {
  1687. _this.$httpSend({
  1688. path: '/im/message/textMsg',
  1689. data: {
  1690. list_id: _this.list_id,
  1691. content_type: type,
  1692. content: JSON.stringify(sendMsg),
  1693. },
  1694. success_action: true,
  1695. success (res) {
  1696. // uni.hideLoading();
  1697. switch (res.err) {
  1698. case 0:
  1699. if (type == 1) {
  1700. _action.playVoice('/static/voice/voice.mp3');
  1701. }
  1702. break;
  1703. case 1:
  1704. uni.showModal({
  1705. title: '好友提示',
  1706. confirmText: '发送好友申请',
  1707. content: res.msg,
  1708. success: function (res) {
  1709. if (res.confirm) {
  1710. uni.navigateTo({
  1711. url: ('../friend/apply?user_id=' + _data.localData(_this.list_id).obj_id + '&is_type=0'),
  1712. });
  1713. }
  1714. }
  1715. });
  1716. break;
  1717. case 2:
  1718. uni.showModal({
  1719. content: res.msg,
  1720. });
  1721. let data = _data.localData(data.list_id);
  1722. data.is_msg = 1;
  1723. _this.msgList.is_msg = 1;
  1724. _data.localData(data.list_id, data);
  1725. break;
  1726. default:
  1727. break;
  1728. }
  1729. }
  1730. });
  1731. });
  1732. },
  1733. // 添加文字消息到列表
  1734. addTextMsg (msg) {
  1735. this.msgList.list.push(msg);
  1736. },
  1737. // 添加语音消息到列表
  1738. addVoiceMsg (msg) {
  1739. this.msgList.list.push(msg);
  1740. },
  1741. // 添加图片消息到列表
  1742. addImgMsg (msg) {
  1743. this.msgImgList.push(this.staticPath + msg.msg.content.url);
  1744. msg.msg.content = this.setPicSize(msg.msg.content);
  1745. this.msgList.list.push(msg);
  1746. },
  1747. addRedEnvelopeMsg (msg) {
  1748. this.msgList.push(msg);
  1749. },
  1750. // 添加系统文字消息到列表
  1751. addSystemTextMsg (msg) {
  1752. this.msgList.list.push(msg);
  1753. },
  1754. // 添加系统红包消息到列表
  1755. addSystemRedEnvelopeMsg (msg) {
  1756. this.msgList.list.push(msg);
  1757. },
  1758. openRed (params) {
  1759. let _this = this;
  1760. _this.luckbtn = "luckbtn";
  1761. uni.showLoading({
  1762. title: '加载中...'
  1763. });
  1764. //TODO 判断是哪种红包
  1765. if(this.vendor_status == 1){
  1766. _get.getLeiHongBao(params, function (ret) {
  1767. _this.receive_list.push(params.rid);
  1768. _this.msgList.receive_list = _this.receive_list;
  1769. _data.localData(_this.list_id, _this.msgList);
  1770. console.log(ret);
  1771. uni.$emit('data_user_info', ret);
  1772. _data.data('user_info', ret);
  1773. setTimeout(function () {
  1774. _this.luckbtn = "";
  1775. _this.closeRedEnvelope();
  1776. _this.toDetails(params.rid);
  1777. }, 1000)
  1778. }, function (ret) {
  1779. setTimeout(function () {
  1780. _this.luckbtn = "";
  1781. _this.closeRedEnvelope();
  1782. _this.toDetails(params.rid);
  1783. }, 1000);
  1784. });
  1785. }else {
  1786. _get.getHongBao(params, function (ret) {
  1787. _this.receive_list.push(params.rid);
  1788. _this.msgList.receive_list = _this.receive_list;
  1789. _data.localData(_this.list_id, _this.msgList);
  1790. console.log(ret);
  1791. uni.$emit('data_user_info', ret);
  1792. _data.data('user_info', ret);
  1793. setTimeout(function () {
  1794. _this.luckbtn = "";
  1795. _this.closeRedEnvelope();
  1796. _this.toDetails(params.rid);
  1797. }, 1000)
  1798. }, function (ret) {
  1799. setTimeout(function () {
  1800. _this.luckbtn = "";
  1801. _this.closeRedEnvelope();
  1802. _this.toDetails(params.rid);
  1803. }, 1000);
  1804. });
  1805. }
  1806. uni.hideLoading();
  1807. },
  1808. // 打开红包
  1809. openRedEnvelope (msg, index) {
  1810. if (this.receive_list.indexOf(msg.content.rid) >= 0) {
  1811. this.toDetails(msg.content.rid);
  1812. return true;
  1813. }
  1814. this.windowsState = 'show';
  1815. this.redenvelopeData = msg.content;
  1816. this.redenvelopeData.index = index;
  1817. return true;
  1818. },
  1819. // 关闭红包弹窗
  1820. closeRedEnvelope () {
  1821. this.windowsState = 'hide';
  1822. setTimeout(() => {
  1823. this.windowsState = '';
  1824. }, 200)
  1825. },
  1826. sendSystemMsg (content, type) {
  1827. let lastid = this.msgList.list[this.msgList.list.length - 1].msg.id;
  1828. lastid++;
  1829. let row = { type: "system", msg: { id: lastid, type: type, content: content } };
  1830. this.screenMsg(row);
  1831. },
  1832. //领取详情
  1833. toDetails (rid) {
  1834. uni.navigateTo({
  1835. url: 'message/details?rid=' + rid + '&list_id=' + this.list_id
  1836. })
  1837. },
  1838. // 预览图片
  1839. showPic (msg) {
  1840. uni.previewImage({
  1841. indicator: "none",
  1842. current: this.staticPath + msg.content.url.replace('_thumb', ''),
  1843. urls: this.msgImgList
  1844. });
  1845. },
  1846. // 播放语音
  1847. playVoice (msg) {
  1848. console.log('播放语音')
  1849. this.AUDIO.stop();
  1850. let _this = this;
  1851. if (this.playMsgid == msg.id) {
  1852. this.playMsgid = null;
  1853. } else {
  1854. this.playMsgid = msg.id;
  1855. // this.AUDIO.obeyMuteSwitch = false;
  1856. let url = this.staticPath + msg.content.url;
  1857. _this.AUDIO.src = url;
  1858. _this.$nextTick(function () {
  1859. _this.AUDIO.play();
  1860. });
  1861. // this.AUDIO.src = (this.staticPath + msg.content.url + '?_=' + Math.random());
  1862. }
  1863. },
  1864. // 录音开始
  1865. voiceBegin (e) {
  1866. if (e.touches.length > 1) {
  1867. return;
  1868. }
  1869. this.initPoint.Y = e.touches[0].clientY;
  1870. this.initPoint.identifier = e.touches[0].identifier;
  1871. // this.RECORDER.start({ format: "mp3" });//录音开始,
  1872. // 开始录音
  1873. this.RECORD.start({
  1874. format:"mp3"
  1875. });
  1876. },
  1877. //录音开始UI效果
  1878. recordBegin (e) {
  1879. /** 暂停语音播放 */
  1880. this.AUDIO.pause();
  1881. this.recording = true;
  1882. this.voiceTis = '松开 结束';
  1883. },
  1884. // 录音被打断
  1885. voiceCancel () {
  1886. this.recording = false;
  1887. this.voiceTis = '按住 说话';
  1888. this.recordTis = '手指上滑 取消发送'
  1889. this.willStop = true;//不发送录音
  1890. this.RECORD.stop();//录音结束
  1891. },
  1892. // 录音中(判断是否触发上滑取消发送)
  1893. voiceIng (e) {
  1894. if (!this.recording) {
  1895. return;
  1896. }
  1897. let touche = e.touches[0];
  1898. //上滑一个导航栏的高度触发上滑取消发送
  1899. if (this.initPoint.Y - touche.clientY >= uni.upx2px(100)) {
  1900. this.willStop = true;
  1901. this.recordTis = '松开手指 取消发送'
  1902. } else {
  1903. this.willStop = false;
  1904. this.recordTis = '手指上滑 取消发送'
  1905. }
  1906. },
  1907. // 结束录音
  1908. voiceEnd (e) {
  1909. if (!this.recording) {
  1910. return;
  1911. }
  1912. this.recording = false;
  1913. this.voiceTis = '按住 说话';
  1914. this.recordTis = '手指上滑 取消发送'
  1915. this.RECORD.stop();//录音结束
  1916. },
  1917. //录音结束(回调文件)
  1918. recordEnd (e) {
  1919. if (!this.willStop) {
  1920. //console.log("e: " + JSON.stringify(e));
  1921. let msg = {
  1922. length: 0,
  1923. url: e.tempFilePath
  1924. };
  1925. console.log(JSON.stringify(msg))
  1926. let min = parseInt(this.RecordTime / 60);
  1927. let sec = this.RecordTime % 60;
  1928. min = min < 10 ? '0' + min : min;
  1929. sec = sec < 10 ? '0' + sec : sec;
  1930. if (min > 0 || sec > 0) {
  1931. msg.length = min + ':' + sec;
  1932. this.sendMsg(msg, 1);
  1933. }
  1934. } else {
  1935. console.log('取消发送录音');
  1936. }
  1937. this.willStop = false;
  1938. },
  1939. // 切换语音/文字输入
  1940. switchVoice () {
  1941. this.hideDrawer(1);
  1942. this.isVoice = this.isVoice ? false : true;
  1943. },
  1944. discard () {
  1945. return;
  1946. },
  1947. sayCall(){
  1948. let status = 0; //默认关闭匿名
  1949. console.log('this.msgList.is_niming:',this.msgList.is_niming)
  1950. if(this.msgList.is_niming == 0){
  1951. uni.showLoading({'title':'匿名开启中...'});
  1952. status = 1;
  1953. }
  1954. let _this = this;
  1955. _get.updateUserSayType({list_id:this.list_id,status:status},function () {
  1956. if(_this.msgList.is_niming == 0){
  1957. uni.showToast({'title':'开启成功','image':'/static/theme/default/my/niming.png',duration:2000});
  1958. _this.msgList.is_niming = 1;
  1959. _this.niming_msg = '退出匿名';
  1960. }else {
  1961. _this.msgList.is_niming = 0;
  1962. _this.niming_msg = '匿名';
  1963. }
  1964. _this.textareaFocus();//隐藏抽屉
  1965. },function (ret) {
  1966. uni.showToast({'title':ret.msg,icon:'none',duration:2000})
  1967. });
  1968. },
  1969. scrollEven(e){
  1970. },
  1971. zhendong(){
  1972. _get.zhendong({list_id:this.list_id},function (res) {
  1973. },function (res) {
  1974. uni.showToast({title:res.msg,duration:2000,icon:'none'})
  1975. })
  1976. },
  1977. group_info(){
  1978. uni.navigateTo({
  1979. url: './message/more?list_id=' + this.list_id + '&type=' + this.msgList.type,
  1980. });
  1981. },
  1982. toUserDetail(item){
  1983. if (this.msgList.type == 1 && (this.msgList.is_action == 0)) {
  1984. uni.showToast({
  1985. title: '没有权限查看',
  1986. icon: 'none',
  1987. duration: 1000
  1988. });
  1989. return;
  1990. }
  1991. uni.navigateTo({
  1992. url: ('../details/index?user_id=' + item.user_id+'&type=1&list_id='+this.list_id+"&is_action="+this.is_action),
  1993. });
  1994. },
  1995. getServing(){
  1996. //判断权限
  1997. if (this.msgList.type == 1 && (this.msgList.is_action == 0) && this.group_state && this.group_state.can_shangmai == 0) {
  1998. uni.showToast({
  1999. title: '此群被设置为只有群主和管理员才能上麦',
  2000. icon: 'none',
  2001. duration: 1000
  2002. });
  2003. return;
  2004. }
  2005. let _this = this;
  2006. if(this.onLine){ //在房间里直开启
  2007. _this.showServing = true;
  2008. console.log("onLine.....")
  2009. this.$refs.serving.joinOnline(this.list_id);
  2010. return true;
  2011. }
  2012. console.log("_this.servingState:",_this.servingState)
  2013. if(_this.servingState == 1){
  2014. //下麦
  2015. _this.showServing = false;
  2016. _this.$refs.serving.xiaMai(this.list_id);
  2017. }else {
  2018. //上麦
  2019. console.log("joinRoom....")
  2020. _this.showServing = true;
  2021. this.$refs.serving.joinRoom(this.list_id);
  2022. }
  2023. },
  2024. setSeringState(detail){
  2025. console.log("this.servingState:",JSON.stringify(detail))
  2026. this.servingState = detail.state
  2027. }
  2028. },
  2029. watch: {},
  2030. onNavigationBarButtonTap (e) {
  2031. uni.navigateTo({
  2032. url: './message/more?list_id=' + this.list_id + '&type=' + this.msgList.type,
  2033. });
  2034. }
  2035. }
  2036. </script>
  2037. <style lang="scss">
  2038. @import "@/static/css/chat/style.scss";
  2039. .send-card {
  2040. width: 700rpx;
  2041. height: 200rpx;
  2042. display: flex;
  2043. max-width: 70%;
  2044. min-height: 25px;
  2045. border-radius: 5px;
  2046. font-size: 14px;
  2047. background-color: #fff;
  2048. flex-direction: column;
  2049. color: #333;
  2050. }
  2051. .send-card-content {
  2052. display: flex;
  2053. justify-content: flex-start;
  2054. align-items: center;
  2055. padding: 20upx;
  2056. height: 100%;
  2057. border-bottom: 2px solid #e1e1e1;
  2058. }
  2059. .send-card-content text {
  2060. margin-left: 20upx;
  2061. }
  2062. .send-card-content-text {
  2063. display: flex;
  2064. justify-content: center;
  2065. flex-direction: column;
  2066. height: 100%;
  2067. margin-left: 20upx;
  2068. }
  2069. .video-but-view {
  2070. padding: 20upx;
  2071. border-radius: 10upx 10upx 0 0;
  2072. .video-but {
  2073. margin-bottom: 18upx;
  2074. background: #817e7e;
  2075. color: #fff;
  2076. }
  2077. }
  2078. .box textarea {
  2079. padding-left: 5px;
  2080. }
  2081. .list .list-box {
  2082. width: 25%;
  2083. display: flex;
  2084. align-items: center;
  2085. flex-direction: column;
  2086. }
  2087. .luckbtn {
  2088. -webkit-transform: rotateY(360deg);
  2089. animation: rotation 0.4s linear infinite;
  2090. -moz-animation: rotation 0.4s linear infinite;
  2091. -webkit-animation: rotation 0.4s linear infinite;
  2092. -o-animation: rotation 0.4s linear infinite;
  2093. }
  2094. @-webkit-keyframes rotation {
  2095. from {
  2096. -webkit-transform: rotateY(0deg);
  2097. }
  2098. to {
  2099. -webkit-transform: rotateY(360deg);
  2100. }
  2101. }
  2102. .bubble-bofang {
  2103. position: absolute;
  2104. right: 215upx;
  2105. }
  2106. .bubble-bofang-left {
  2107. position: absolute;
  2108. left: 215upx;
  2109. }
  2110. .showVedio {
  2111. width: 100%;
  2112. height: 100%;
  2113. position: absolute;
  2114. left: 0;
  2115. right: 0;
  2116. top: 0;
  2117. bottom: 0;
  2118. z-index: 300;
  2119. }
  2120. .cloneBut {
  2121. position: relative;
  2122. text-align: right;
  2123. font-size: 24px;
  2124. color: red;
  2125. margin-left: 10px;
  2126. margin-top: 10px;
  2127. height: 30px;
  2128. width: 30px;
  2129. }
  2130. .cloneBut-img {
  2131. position: absolute;
  2132. width: 30px;
  2133. }
  2134. ::-webkit-scrollbar{
  2135. width: 0;
  2136. height: 0;
  2137. color: transparent;
  2138. }
  2139. .gong-gao-content{
  2140. position: fixed;
  2141. /*height: 30px;*/
  2142. width: 100%;
  2143. z-index: 2;
  2144. /*padding: 10rpx 10rpx;*/
  2145. }
  2146. .gong-gao-content-info{
  2147. display: flex;
  2148. align-items: center;
  2149. background-color: #e0e0e0;
  2150. height: 100%;
  2151. }
  2152. .gong-gao-content-info-icon{
  2153. font-size: 20px;
  2154. margin-right: 20rpx;
  2155. margin-left: 20rpx;
  2156. }
  2157. .sys:nth-child(1){
  2158. margin-top: 50px;
  2159. }
  2160. .member-image-logo{
  2161. display: flex;
  2162. justify-content: flex-start;
  2163. align-items: center;
  2164. padding-top: 10px;
  2165. box-shadow:inset 0px 15px 15px -23px #000;
  2166. background-color: #ffffff;
  2167. overflow-x: auto;
  2168. }
  2169. .member-content{
  2170. white-space: nowrap;
  2171. text-align: center;
  2172. }
  2173. .img-logo{
  2174. width: 40px !important;
  2175. height: 40px !important;
  2176. border-radius: 10px;
  2177. display: inline-block;
  2178. padding:0 5px;
  2179. }
  2180. .jiazai{
  2181. margin-right: 20px;
  2182. }
  2183. .jiazai image{
  2184. width: 40rpx;
  2185. height: 40rpx;
  2186. }
  2187. </style>