video-block.vue 5.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260
  1. <template>
  2. <view>
  3. <view class="list">
  4. <view class="item" v-for="(item,index) in list" :key="index" @click="go_video(item)">
  5. <view class="img">
  6. <image v-if="item.cover_picture" :src="item.cover_picture" mode="aspectFill"></image>
  7. <image v-else src="./icon/default.jpg" mode="aspectFill"></image>
  8. <view class="tip" v-if="item.camera_status == 1">在线</view>
  9. <view class="tip" v-if="item.camera_status == 2" style="background-color: #f30220;">不在线</view>
  10. </view>
  11. <view class="name">
  12. <view class="text">{{item.camera_name}}</view>
  13. <view class="icon" @click.stop="popup()">
  14. <image src="./icon/icon.png" mode=""></image>
  15. </view>
  16. </view>
  17. </view>
  18. </view>
  19. <view>
  20. <uni-popup ref="popup" type="center">
  21. </uni-popup>
  22. </view>
  23. <view class="loading">
  24. <uni-popup ref="popup_loading" :mask-click="false" type="center">
  25. <image src="./icon/loading.gif" mode="aspectFill"></image>
  26. <view class="box">
  27. <view class="line" :style="'width:' + (loading_text*19) + '%'"></view>
  28. <view class="text" v-if="loading_text == 1">发送请求中...</view>
  29. <view class="text" v-if="loading_text == 2">获取视频流...</view>
  30. <view class="text" v-if="loading_text == 3">视频流切片中...</view>
  31. <view class="text" v-if="loading_text == 4">网络传输中...</view>
  32. <view class="text" v-if="loading_text == 5">即将播放...</view>
  33. </view>
  34. </uni-popup>
  35. </view>
  36. </view>
  37. </template>
  38. <script>
  39. export default {
  40. data() {
  41. return {
  42. list: [],
  43. loading_text: 1
  44. };
  45. },
  46. onLoad(option) {
  47. console.log(option)
  48. uni.setNavigationBarTitle({
  49. title: option.name
  50. })
  51. this.get_camera(option.mine_id, option.parent_id)
  52. },
  53. methods: {
  54. get_camera(mine_id, parent_id) {
  55. uni.request({
  56. method: "POST",
  57. header: {
  58. "Content-Type":"multipart/form-data",
  59. 'Content-Type':'application/json;charset=UTF-8',
  60. 'Content-Type':'application/x-www-form-urlencoded',
  61. "Access-Control-Max-Age": "86400",
  62. "Authorization": uni.getStorageSync('video_type') + ' ' + uni.getStorageSync('video_token')
  63. },
  64. url: "http://video.nxjiewei.com:8011/api/camera/getlist?mine_id=" + mine_id + "&parent_id=" + parent_id,
  65. // 内网
  66. // url: "http://n.video.nxjiewei.com:8011/api/camera/getlist?mine_id=" + mine_id + "&parent_id=" + parent_id,
  67. success: res => {
  68. console.log(res.data.content.data)
  69. this.list = res.data.content.data
  70. }
  71. })
  72. },
  73. go_video(item) {
  74. this.$refs.popup_loading.open()
  75. let loading_inter = setInterval(() => {
  76. console.log(this.loading_text)
  77. if (this.loading_text == 5) {
  78. this.loading_text = 5
  79. } else {
  80. this.loading_text++
  81. }
  82. }, 1600)
  83. uni.request({
  84. method: "POST",
  85. // url: "http://video.nxjiewei.com:8011/api/camera/geturl",
  86. url: "http://video.nxjiewei.com:8011/api/camera/getrtsp",
  87. // 内网
  88. // url: "http://n.video.nxjiewei.com:8011/api/camera/getrtsp",
  89. header:{
  90. "Content-Type":"multipart/form-data",
  91. 'Content-Type':'application/json;charset=UTF-8',
  92. 'Content-Type':'application/x-www-form-urlencoded',
  93. "Authorization": uni.getStorageSync('video_type') + ' ' + uni.getStorageSync('video_token')
  94. },
  95. data: {
  96. camera_id: item.camera_id,
  97. parent_id: item.parent_id
  98. },
  99. success: res => {
  100. // uni.hideLoading()
  101. clearInterval(loading_inter)
  102. this.loading_text = 1
  103. this.$refs.popup_loading.close()
  104. console.log(res)
  105. if (res.data.content.data) {
  106. let url = res.data.content.data.url
  107. console.log(url, item.camera_name)
  108. uni.navigateTo({
  109. url: "../video/video",
  110. success: (res) => {
  111. // 通过eventChannel向被打开页面传送数据
  112. res.eventChannel.emit('acceptDataFromOpenerPage', {
  113. url: url,
  114. title: item.camera_name
  115. })
  116. }
  117. })
  118. } else {
  119. clearInterval(loading_inter)
  120. this.loading_text = 1
  121. this.$refs.popup_loading.close()
  122. uni.showToast({
  123. icon: "none",
  124. title: "取流失败!"
  125. })
  126. }
  127. },
  128. fail() {
  129. clearInterval(loading_inter)
  130. this.loading_text = 1
  131. this.$refs.popup_loading.close()
  132. uni.showToast({
  133. icon: "none",
  134. title: "取流失败!"
  135. })
  136. }
  137. })
  138. },
  139. popup() {
  140. // this.$refs.popup.open()
  141. }
  142. }
  143. }
  144. </script>
  145. <style lang="scss">
  146. page {
  147. background-color: #F2FAF7;
  148. box-sizing: border-box;
  149. padding: 20rpx 15rpx;
  150. }
  151. .list {
  152. .item {
  153. background-color: #FFFFFF;
  154. width: 350rpx;
  155. box-sizing: border-box;
  156. padding: 15rpx;
  157. margin-right: 20rpx;
  158. margin-bottom: 20rpx;
  159. float: left;
  160. .img {
  161. position: relative;
  162. .tip {
  163. position: absolute;
  164. top: 0;
  165. right: 0;
  166. background-color: #00c800;
  167. padding: 2rpx 8rpx;
  168. font-size: 24rpx;
  169. color: #FFFFFF;
  170. }
  171. image {
  172. width: 320rpx;
  173. height: 220rpx;
  174. }
  175. }
  176. .name {
  177. display: flex;
  178. align-items: center;
  179. justify-content: space-between;
  180. .text {
  181. width: 240rpx;
  182. font-size: 28rpx;
  183. white-space: nowrap;
  184. overflow: hidden;
  185. text-overflow: ellipsis;
  186. }
  187. .icon {
  188. image {
  189. width: 76rpx;
  190. height: 24rpx;
  191. }
  192. }
  193. }
  194. }
  195. .item:nth-child(2n) {
  196. margin-right: 0;
  197. }
  198. }
  199. .loading {
  200. width: 400rpx;
  201. text-align: center;
  202. image {
  203. width: 228rpx;
  204. height: 228rpx;
  205. }
  206. .box {
  207. position: relative;
  208. margin-top: 40rpx;
  209. width: 400rpx;
  210. height: 50rpx;
  211. border-radius: 50rpx;
  212. border: 1rpx solid #FFFFFF;
  213. overflow: hidden;
  214. .line {
  215. z-index: -999;
  216. position: absolute;
  217. top: 0;
  218. left: 0;
  219. height: 50rpx;
  220. width: 10rpx;
  221. background-color: #00A1E9;
  222. }
  223. .text {
  224. z-index: 999;
  225. line-height: 50rpx;
  226. font-size: 28rpx;
  227. -webkit-text-stroke: 1rpx #fff;
  228. }
  229. }
  230. }
  231. </style>