video-block.vue 6.3 KB

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