videoList.vue 6.3 KB

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