messagemore.vue 75 KB

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