videoList.vue 6.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248
  1. <template>
  2. <view class="">
  3. <view v-if="loadingStatus" class="loadingMask">Loading...</view>
  4. <view class="cu-list menu-avatar">
  5. <view v-if="!this.openId&&!this.onLineVideoList.length" class="text-center margin-top-lg">加载中...</view>
  6. <view v-if="!this.matchedDeviceList.length&&this.onLineVideoList.length" class="text-center margin-top-lg">暂无数据</view>
  7. <view class="cu-item" :class="modalName=='move-box-'+ index?'move-cur':''" v-for="(item,index) in matchedDeviceList"
  8. :key="index" :data-target="'move-box-' + index">
  9. <view v-if="item.ALIVEVALUE==3" class="cu-avatar round lg" style="opacity:.7">
  10. <image class="image-bg" src="/static/video-icon-on.png"/>
  11. </view>
  12. <view v-else class="cu-avatar round lg" style="opacity:.7">
  13. <image class="image-bg" src="/static/video-icon-off.png"/>
  14. </view>
  15. <view v-if="item.ALIVEVALUE==3" @tap="open_video(item)">
  16. <view class="content">
  17. <view class="">{{item.DEVICE}}</view>
  18. </view>
  19. <view class="nav-right num">
  20. <view class="online">
  21. 在线
  22. <text class="icon iconfont margin-right-xs margin-left-lg">&#xe629;</text>
  23. </view>
  24. </view>
  25. </view>
  26. <view v-else>
  27. <view class="content">
  28. <view class="">{{item.DEVICE}}</view>
  29. </view>
  30. <view class="nav-right num">
  31. <view class="offline">
  32. 离线
  33. <text class="icon iconfont margin-right-xs margin-left-lg">&#xe629;</text>
  34. </view>
  35. </view>
  36. </view>
  37. </view>
  38. </view>
  39. <input type="hidden" v-model="openId" style="opacity:0">
  40. </view>
  41. </template>
  42. <script>
  43. export default {
  44. data() {
  45. return {
  46. d: {
  47. CMD: 1
  48. },
  49. deviceData: [],
  50. onLineVideoList: [],
  51. matchedDeviceList: [],
  52. modalName: null,
  53. openId: '',
  54. reCount: 0,
  55. count: 0,
  56. loadingStatus: false
  57. };
  58. },
  59. onLoad: function(option) {
  60. // this.companyCode = option.companyCode
  61. // this.deviceType = option.deviceType
  62. this.getDeviceManage({
  63. 'company_code':uni.getStorageSync('selectedCode')
  64. })
  65. this.chk_video()
  66. },
  67. computed: {
  68. },
  69. methods: {
  70. chk_video() {
  71. uni.request({
  72. url: 'https://fire.usky.cn:8443/YtIoT/cgi-bin/demo2.cgi',
  73. data: 'queryJson:' + JSON.stringify({
  74. CMD: 1
  75. }),
  76. method: 'post',
  77. header: {
  78. 'Content-Type': 'application/x-www-form-urlencoded;charset=UTF-8'
  79. },
  80. success: (res) => {
  81. this.onLineVideoList = res.data.RESULT.LIST;
  82. // console.log('this.onLineVideoList');
  83. // console.log(this.onLineVideoList)
  84. // console.log('this.openId')
  85. // console.log(this.openId)
  86. if (this.openId.length > 0) {
  87. console.log('doododododododo')
  88. for (var n = 0; n < this.onLineVideoList.length; n++) {
  89. if (this.openId == this.onLineVideoList[n].DEVICE) {
  90. this.reCount++;
  91. if (this.onLineVideoList[n].ONAIR) {
  92. if ((++this.count) > 2) {
  93. // var mask = document.getElementById('videomask');
  94. // if (mask != undefined) {
  95. // removeDIV('videomask');
  96. // }
  97. this.loadingStatus = false;
  98. uni.navigateTo({
  99. url: '/pages/videoList/videoDetail/videoDetail?deviceCode=' + this.onLineVideoList[n].DEVICE,
  100. });
  101. } else {
  102. setTimeout(this.chk_video, 5000);
  103. }
  104. } else {
  105. if (this.reCount > 7) {
  106. // var mask = document.getElementById('videomask');
  107. // if (mask != undefined) {
  108. // removeDIV('videomask');
  109. // }
  110. this.loadingStatus = false;
  111. // alert('远程摄像头链接超时,请稍后再试')
  112. uni.showToast({
  113. title: "远程摄像头链接超时,请稍后再试",
  114. icon: "none"
  115. });
  116. // $("#myPopup").popup("open");
  117. break;
  118. }
  119. setTimeout(this.chk_video, 5000);
  120. }
  121. }
  122. }
  123. } else {
  124. for (var i = 0; i < this.onLineVideoList.length; i++) {
  125. for (var j = 0; j < this.deviceData.length; j++) {
  126. if (this.onLineVideoList[i].DEVICE == this.deviceData[j].owner_code) {
  127. this.matchedDeviceList.push({
  128. "DEVICE": this.onLineVideoList[i].DEVICE,
  129. "ALIVEVALUE": this.onLineVideoList[i].ALIVEVALUE,
  130. "ONAIR": this.onLineVideoList[i].ONAIR
  131. })
  132. }
  133. }
  134. }
  135. console.log('this.matchedDeviceList')
  136. console.log(this.matchedDeviceList)
  137. }
  138. }
  139. });
  140. },
  141. open_video(item) {
  142. // alert( item.DEVICE);
  143. if (this.openId != item.DEVICE) {
  144. this.openId = item.DEVICE
  145. }
  146. console.log('this.openId')
  147. console.log(this.openId)
  148. console.log('this.onLineVideoList')
  149. console.log(this.onLineVideoList)
  150. for (var n = 0; n < this.onLineVideoList.length; n++) {
  151. if (this.onLineVideoList[n].DEVICE == this.openId) {
  152. if (this.onLineVideoList[n].ONAIR) {
  153. uni.navigateTo({
  154. url: '/pages/videoList/videoDetail/videoDetail?deviceType=2&companyCode=' + uni.getStorageSync('selectedCode') + '&deviceCode=' + item.DEVICE +
  155. '',
  156. });
  157. return;
  158. }
  159. }
  160. }
  161. this.count = 0;
  162. this.reCount = 0;
  163. this.loadingStatus = true;
  164. // alert('一些loading操作')
  165. uni.request({
  166. url: 'https://fire.usky.cn:8443/YtIoT/cgi-bin/demo2.cgi',
  167. data: 'queryJson:' + JSON.stringify({
  168. CMD: 3,
  169. BODY: {
  170. DEVICE: item.DEVICE,
  171. ACTION: 1,
  172. IDX: 7
  173. }
  174. }),
  175. method: 'post',
  176. header: {
  177. 'Content-Type': 'application/x-www-form-urlencoded;charset=UTF-8'
  178. },
  179. success: (res) => {
  180. setTimeout(this.chk_video, 5000);
  181. }
  182. });
  183. },
  184. async getDeviceManage(ming = {}) {
  185. const res = await this.$myRequest({
  186. url: 'VideoMonitoring/getVideoList',
  187. data: ming
  188. })
  189. this.deviceData = res.data.data;
  190. console.log(this.deviceData)
  191. },
  192. }
  193. }
  194. </script>
  195. <style lang="scss">
  196. .loadingMask {
  197. width: 100%;
  198. height: 100%;
  199. position: absolute;
  200. left: 0;
  201. background: rgba(0, 0, 0, .3);
  202. z-index: 1000;
  203. color: #000;
  204. justify-content: center;
  205. align-items: center;
  206. display: flex;
  207. text-align: center;
  208. padding-top: 100rpx;
  209. font-size: 34rpx;
  210. }
  211. </style>