video-block.vue 6.5 KB

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