videoList.vue 6.0 KB

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