index.vue 9.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445
  1. <template>
  2. <view class="response_box">
  3. <view class="response_ul">
  4. <view class="response_list" v-for="item in list" @click="defail(item)">
  5. <view class="response_left">
  6. <u-badge numberType="overflow" shape="circle" :type="type" max="99" :value="item.unread"></u-badge>
  7. <!-- <image :src="item.img" mode=""></image> -->
  8. <image src="https://cdn.uviewui.com/uview/album/1.jpg" mode=""></image>
  9. </view>
  10. <view class="response_right">
  11. <view class="response_right_title">
  12. <view class="response_right_titleName">
  13. {{ item.real_name | name }}
  14. </view>
  15. <view class="response_right_titleTime">
  16. {{ item.msg_list[0].create_time }}
  17. </view>
  18. </view>
  19. <view class="response_right_text">
  20. {{ item.msg_list[0].msg_info | msgData}}
  21. </view>
  22. </view>
  23. </view>
  24. </view>
  25. <!-- 加载 -->
  26. <u-loading-page :loading="loading"></u-loading-page>
  27. <!-- 列表加载更多 -->
  28. <!-- 返回顶部 -->
  29. <u-back-top :scroll-top="scrollTop"></u-back-top>
  30. <!-- 顶部弹出框 - 视频通话提示框 -->
  31. <u-popup :safeAreaInsetTop="true" :closeOnClickOverlay="false" :customStyle="styleObj" :show="show" mode="top"
  32. :round="10" @close="close" @open="open">
  33. <view style="display: flex; justify-content: space-evenly; margin: 25rpx 0 0 0;">
  34. <view style="display: flex;">
  35. <view class="topUpImg">
  36. <image src="https://cdn.uviewui.com/uview/album/1.jpg" mode=""></image>
  37. </view>
  38. <view class="topUpTxt">
  39. <text>嚣张</text>
  40. <text>邀请你进行视频通话..</text>
  41. </view>
  42. </view>
  43. <view class="topUpBtn">
  44. <u-button @click="close()" type="error" style="border-radius: 50px; width: 50px; height: 50px;"
  45. size="mini" text="取消"></u-button>
  46. <u-button @click="open()" type="success"
  47. style="border-radius: 50px; width: 50px; height: 50px; margin: 0 0 0 15rpx;" size="mini"
  48. text="确定"></u-button>
  49. </view>
  50. </view>
  51. </u-popup>
  52. <!-- 测试 -->
  53. <image id="remoteVideo"></image>
  54. <!-- 测试 -->
  55. </view>
  56. </template>
  57. <script>
  58. import store from '@/store/index.js'; //需要引入store
  59. let App = getApp();
  60. var API = App.globalData.socketTask;
  61. // import permision from "@/zego-express-video-uniapp/permission.js";
  62. // // import ZegoExpressEngine from '@/zego-express-video-uniapp/lib/ZegoExpressEngine';
  63. // import {
  64. // ZegoScenario,
  65. // ZegoRoomState,
  66. // ZegoUpdateType,
  67. // // ZegoViewMode
  68. // } from '@/zego-express-video-uniapp/lib/ZegoExpressDefines'
  69. // import {
  70. // AppID,
  71. // AppSign
  72. // } from '@/zego-express-video-uniapp/KeyCenter.js'
  73. // import ZegoLocalView from '@/zego-express-video-uniapp/zego-view/ZegoLocalView';
  74. // import ZegoRemoteView from '@/zego-express-video-uniapp/zego-view/ZegoRemoteView';
  75. export default {
  76. components: {
  77. // ZegoLocalView: ZegoLocalView,
  78. // ZegoRemoteView: ZegoRemoteView
  79. },
  80. // 过滤
  81. filters: {
  82. name: function(val) {
  83. if (!val) return "";
  84. if (val.length > 7) {
  85. return val.slice(0, 7) + '...'
  86. }
  87. return val
  88. },
  89. msgData: function(val) {
  90. if (!val) return ""
  91. if (val.length > 21) {
  92. return val.slice(0, 21) + '...'
  93. }
  94. return val
  95. },
  96. },
  97. data() {
  98. return {
  99. loading: false, // 加载
  100. scrollTop: 0, // 返回顶部
  101. list: [],
  102. page: 0,
  103. // 消息通知
  104. type: "error",
  105. value: 99999,
  106. // 即构
  107. engine: undefined,
  108. videoObj: null,
  109. userid: "Uni" + Math.floor(Math.random() * 1000000).toString(),
  110. // 弹出框
  111. show: false,
  112. styleObj: {
  113. display: 'flex',
  114. backgroundColor: "#fff",
  115. height: '500px'
  116. },
  117. isPublishingStream: false,
  118. }
  119. },
  120. watch: {
  121. videoData(news, old) {
  122. console.log('触发了')
  123. console.log(news)
  124. if (news) {
  125. this.videoObj = news
  126. this.show = true
  127. }
  128. },
  129. },
  130. computed: {
  131. videoData() {
  132. return store.state.video
  133. },
  134. },
  135. methods: {
  136. loadmoreAxios() {
  137. console.log(this.list)
  138. },
  139. // 进入详情
  140. defail(data) {
  141. var that = this
  142. if (App.globalData.is_open_socket) {
  143. // websocket的服务器的原理是:发送一次消息,同时返回一组数据【否则服务器会进去死循环崩溃】
  144. // 进入详情前先发送已经阅读过消息
  145. var obj = {
  146. 'action': 'read', // 动作标识,必填
  147. 'send_user_id': data.user_id, // 接收人用户id, 非必填
  148. 'data': {}
  149. }
  150. API.send({
  151. data: JSON.stringify(obj),
  152. async success(res) {
  153. console.log("消息发送成功");
  154. },
  155. });
  156. uni.navigateTo({
  157. url: '/pages/response/details?data=' + JSON.stringify(data)
  158. })
  159. } else {
  160. console.log('没有进入')
  161. }
  162. },
  163. // 弹出框
  164. open() {
  165. console.log('open');
  166. uni.navigateTo({
  167. url: '/pages/response/video?videoObj=' + JSON.stringify(this.videoObj)
  168. })
  169. this.show = false
  170. },
  171. close() {
  172. this.show = false
  173. console.log('close');
  174. },
  175. // 视频通话弹框
  176. // videOpen() {
  177. // console.log('open');
  178. // },
  179. // videClose() {
  180. // console.log('close');
  181. // },
  182. // 推流 - 展示视图
  183. // onPublish() {
  184. // // 设置视频配置
  185. // ZegoExpressEngine.instance().setVideoConfig(this.videoObj.room_id);
  186. // if (this.isPublishingStream) {
  187. // this.engine.stopPreview();
  188. // this.engine.stopPublishingStream();
  189. // this.publishBtnName = "Start Publishing";
  190. // } else {
  191. // this.engine.startPreview();
  192. // this.engine.startPublishingStream(this.videoObj.room_id);
  193. // this.publishBtnName = "Stop Publishing";
  194. // }
  195. // this.isPublishingStream = !this.isPublishingStream;
  196. // },
  197. },
  198. async onLoad() {
  199. // uni.startPullDownRefresh(); // 开始刷新
  200. },
  201. onShow() {
  202. var that = this
  203. var a = App.globalData.list
  204. for (var i = 0; i < a.length; i++) {
  205. if (a[i].msg_list[0].im_id == 1) {
  206. a[i].msg_list.reverse()
  207. }
  208. }
  209. this.list = App.globalData.list; // 倒叙
  210. },
  211. // 下拉刷新
  212. onPullDownRefresh() {
  213. // console.log('刷新了')
  214. var that = this
  215. if (App.globalData.is_open_socket) {
  216. // websocket的服务器的原理是:发送一次消息,同时返回一组数据【否则服务器会进去死循环崩溃】
  217. var obj = {
  218. 'action': 'list', // 动作标识,必填
  219. 'send_user_id': '', // 接收人用户id, 非必填
  220. 'data': {}
  221. }
  222. API.send({
  223. data: JSON.stringify(obj),
  224. async success(res) {
  225. console.log("消息发送成功");
  226. },
  227. });
  228. } else {
  229. console.log('没有进入')
  230. }
  231. setTimeout(() => {
  232. uni.stopPullDownRefresh()
  233. }, 1000)
  234. },
  235. // 上拉加载
  236. onReachBottom() {
  237. console.log('加载了')
  238. },
  239. onPageScroll(e) {
  240. this.scrollTop = e.scrollTop;
  241. },
  242. }
  243. </script>
  244. <style lang="scss" scoped>
  245. page {
  246. background: #f7f7f7;
  247. padding: 25rpx 0 25rpx 0;
  248. overflow: hidden;
  249. }
  250. .response_box {
  251. background: #f7f7f7;
  252. .response_ul {
  253. // border: 1px solid #000;
  254. overflow-y: auto;
  255. // height: 1550rpx;
  256. height: 1450rpx;
  257. .response_list {
  258. position: relative;
  259. background: #FFF;
  260. border: 1px solid #e5e2e2;
  261. margin: 0 0 35rpx 0;
  262. padding: 20rpx 20rpx 20rpx 20rpx;
  263. display: flex;
  264. // 左
  265. .response_left {
  266. image {
  267. width: 110rpx;
  268. height: 110rpx;
  269. border-radius: 20rpx;
  270. }
  271. }
  272. // 右
  273. .response_right {
  274. margin: 8rpx 0 0 30rpx;
  275. width: 100%;
  276. .response_right_title {
  277. line-height: 50rpx;
  278. display: flex;
  279. justify-content: space-between;
  280. .response_right_titleName {}
  281. .response_right_titleTime {
  282. color: #999999;
  283. font-size: 25rpx;
  284. }
  285. }
  286. .response_right_text {
  287. color: #999999;
  288. font-size: 25rpx;
  289. line-height: 58rpx;
  290. }
  291. }
  292. }
  293. }
  294. .topUpImg {
  295. image {
  296. width: 110rpx;
  297. height: 110rpx;
  298. border-radius: 15rpx;
  299. }
  300. margin: 15rpx 0 0 15rpx;
  301. }
  302. .topUpTxt {
  303. margin: 45rpx 0 0 15rpx;
  304. text {
  305. color: #979994;
  306. font-size: 28rpx;
  307. display: block;
  308. }
  309. }
  310. .topUpBtn {
  311. display: flex;
  312. margin: 25rpx 0 0 0;
  313. }
  314. // 视频通话
  315. .video_you {
  316. position: relative;
  317. // border: 1px solid #000;
  318. width: 100%;
  319. height: 100%;
  320. overflow: hidden;
  321. }
  322. .video_me {
  323. // border: 1px solid #000;
  324. width: 200rpx;
  325. height: 300rpx;
  326. position: absolute;
  327. right: 0;
  328. top: 0;
  329. }
  330. .video_btn {
  331. // border: 1px solid;
  332. position: absolute;
  333. bottom: 0;
  334. left: 0;
  335. width: 100%;
  336. .video_imgList {
  337. display: flex;
  338. justify-content: space-evenly;
  339. .video_imgList1 {
  340. // border: 1px solid;
  341. // background: rgba(0, 0, 0, .5);
  342. .video_view {
  343. background: rgba(0, 0, 0, .5);
  344. border: 1px solid;
  345. border-radius: 50px;
  346. width: 50px;
  347. height: 50px;
  348. margin: 0 auto;
  349. image {
  350. width: 50rpx;
  351. height: 50rpx;
  352. margin: 24rpx 0 0 25rpx;
  353. }
  354. }
  355. view {
  356. color: #fff;
  357. font-size: 20rpx;
  358. }
  359. }
  360. .video_imgList2 {
  361. // border: 1px solid;
  362. // background: rgba(0, 0, 0, .5);
  363. .video_view {
  364. border: 1px solid;
  365. background: rgba(0, 0, 0, .5);
  366. margin: 0 auto;
  367. border-radius: 50px;
  368. width: 50px;
  369. height: 50px;
  370. image {
  371. width: 50rpx;
  372. height: 50rpx;
  373. margin: 24rpx 0 0 25rpx;
  374. }
  375. }
  376. view {
  377. color: #fff;
  378. font-size: 20rpx;
  379. }
  380. }
  381. }
  382. }
  383. }
  384. // uview 样式修改
  385. /deep/.u-badge--error {
  386. position: absolute;
  387. left: 105rpx;
  388. top: 15rpx;
  389. z-index: 10;
  390. }
  391. /deep/.u-slide-down-enter-active {
  392. height: 200rpx;
  393. }
  394. </style>