video-block.vue 6.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276
  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. mine_code: "",
  43. list: [],
  44. loading_text: 1,
  45. base_url: "",
  46. // 视频流方式
  47. url: ""
  48. };
  49. },
  50. onLoad(option) {
  51. console.log(option)
  52. uni.setNavigationBarTitle({
  53. title: option.name
  54. })
  55. this.mine_code = uni.getStorageSync('mine_code')
  56. // 内外网
  57. if (this.mine_code.indexOf('_neiwang') == -1) {
  58. this.base_url = "http://video.nxjiewei.com:8011/api"
  59. } else {
  60. this.base_url = "http://n.video.nxjiewei.com:8011/api"
  61. }
  62. if (this.mine_code.indexOf('jinjiaqu') != -1) {
  63. this.url = "/camera/getrtsp"
  64. } else {
  65. this.url = "/camera/get_hik_rtsp"
  66. }
  67. this.get_camera(option.mine_id, option.parent_id)
  68. },
  69. methods: {
  70. get_camera(mine_id, parent_id) {
  71. uni.request({
  72. method: "POST",
  73. header: {
  74. "Content-Type": "multipart/form-data",
  75. 'Content-Type': 'application/json;charset=UTF-8',
  76. 'Content-Type': 'application/x-www-form-urlencoded',
  77. "Access-Control-Max-Age": "86400",
  78. "Authorization": uni.getStorageSync('video_type') + ' ' + uni.getStorageSync('video_token')
  79. },
  80. url: this.base_url + "/camera/getlist?mine_id=" + mine_id + "&parent_id=" + parent_id,
  81. // 内网
  82. // url: "http://n.video.nxjiewei.com:8011/api/camera/getlist?mine_id=" + mine_id + "&parent_id=" + parent_id,
  83. success: res => {
  84. console.log(res.data.content.data)
  85. this.list = res.data.content.data
  86. }
  87. })
  88. },
  89. go_video(item) {
  90. this.$refs.popup_loading.open()
  91. let loading_inter = setInterval(() => {
  92. console.log(this.loading_text)
  93. if (this.loading_text == 5) {
  94. this.loading_text = 5
  95. } else {
  96. this.loading_text++
  97. }
  98. }, 1600)
  99. uni.request({
  100. method: "POST",
  101. url: this.base_url + this.url,
  102. header: {
  103. "Content-Type": "multipart/form-data",
  104. 'Content-Type': 'application/json;charset=UTF-8',
  105. 'Content-Type': 'application/x-www-form-urlencoded',
  106. "Authorization": uni.getStorageSync('video_type') + ' ' + uni.getStorageSync('video_token')
  107. },
  108. data: {
  109. camera_id: item.camera_id,
  110. parent_id: item.parent_id
  111. },
  112. success: res => {
  113. // uni.hideLoading()
  114. clearInterval(loading_inter)
  115. this.loading_text = 1
  116. this.$refs.popup_loading.close()
  117. console.log(res)
  118. if (res.data.content.data) {
  119. let url = res.data.content.data.url
  120. console.log(url, item.camera_name)
  121. uni.navigateTo({
  122. url: "../video/video",
  123. success: (res) => {
  124. // 通过eventChannel向被打开页面传送数据
  125. res.eventChannel.emit('acceptDataFromOpenerPage', {
  126. url: url,
  127. title: item.camera_name
  128. })
  129. }
  130. })
  131. } else {
  132. clearInterval(loading_inter)
  133. this.loading_text = 1
  134. this.$refs.popup_loading.close()
  135. uni.showToast({
  136. icon: "none",
  137. title: "取流失败!"
  138. })
  139. }
  140. },
  141. fail() {
  142. clearInterval(loading_inter)
  143. this.loading_text = 1
  144. this.$refs.popup_loading.close()
  145. uni.showToast({
  146. icon: "none",
  147. title: "取流失败!"
  148. })
  149. }
  150. })
  151. },
  152. popup() {
  153. // this.$refs.popup.open()
  154. }
  155. }
  156. }
  157. </script>
  158. <style lang="scss">
  159. page {
  160. background-color: #F2FAF7;
  161. box-sizing: border-box;
  162. padding: 20rpx 15rpx;
  163. }
  164. .list {
  165. .item {
  166. background-color: #FFFFFF;
  167. width: 350rpx;
  168. box-sizing: border-box;
  169. padding: 15rpx;
  170. margin-right: 20rpx;
  171. margin-bottom: 20rpx;
  172. float: left;
  173. .img {
  174. position: relative;
  175. .tip {
  176. position: absolute;
  177. top: 0;
  178. right: 0;
  179. background-color: #00c800;
  180. padding: 2rpx 8rpx;
  181. font-size: 24rpx;
  182. color: #FFFFFF;
  183. }
  184. image {
  185. width: 320rpx;
  186. height: 220rpx;
  187. }
  188. }
  189. .name {
  190. display: flex;
  191. align-items: center;
  192. justify-content: space-between;
  193. .text {
  194. width: 240rpx;
  195. font-size: 28rpx;
  196. white-space: nowrap;
  197. overflow: hidden;
  198. text-overflow: ellipsis;
  199. }
  200. .icon {
  201. image {
  202. width: 76rpx;
  203. height: 24rpx;
  204. }
  205. }
  206. }
  207. }
  208. .item:nth-child(2n) {
  209. margin-right: 0;
  210. }
  211. }
  212. .loading {
  213. width: 400rpx;
  214. text-align: center;
  215. image {
  216. width: 228rpx;
  217. height: 228rpx;
  218. }
  219. .box {
  220. position: relative;
  221. margin-top: 40rpx;
  222. width: 400rpx;
  223. height: 50rpx;
  224. border-radius: 50rpx;
  225. border: 1rpx solid #FFFFFF;
  226. overflow: hidden;
  227. .line {
  228. z-index: -999;
  229. position: absolute;
  230. top: 0;
  231. left: 0;
  232. height: 50rpx;
  233. width: 10rpx;
  234. background-color: #00A1E9;
  235. }
  236. .text {
  237. z-index: 999;
  238. line-height: 50rpx;
  239. font-size: 28rpx;
  240. -webkit-text-stroke: 1rpx #fff;
  241. }
  242. }
  243. }
  244. </style>