videoList.vue 6.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237
  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. var _this=this
  63. setTimeout(function () {
  64. _this.chk_video()
  65. }, 100);
  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. if (this.openId.length > 0) {
  83. console.log('doododododododo')
  84. for (var n = 0; n < this.onLineVideoList.length; n++) {
  85. if (this.openId == this.onLineVideoList[n].DEVICE) {
  86. this.reCount++;
  87. if (this.onLineVideoList[n].ONAIR) {
  88. if ((++this.count) > 2) {
  89. // var mask = document.getElementById('videomask');
  90. // if (mask != undefined) {
  91. // removeDIV('videomask');
  92. // }
  93. this.loadingStatus = false;
  94. uni.navigateTo({
  95. url: '/pages/videoDetail/videoDetail?deviceType=2&companyCode=' + this.companyCode + '&deviceCode=' +
  96. this.onLineVideoList[n].DEVICE +
  97. '',
  98. });
  99. } else {
  100. setTimeout(this.chk_video, 5000);
  101. }
  102. } else {
  103. if (this.reCount > 7) {
  104. // var mask = document.getElementById('videomask');
  105. // if (mask != undefined) {
  106. // removeDIV('videomask');
  107. // }
  108. this.loadingStatus = false;
  109. // alert('远程摄像头链接超时,请稍后再试')
  110. uni.showToast({
  111. title: "远程摄像头链接超时,请稍后再试",
  112. icon: "none"
  113. });
  114. // $("#myPopup").popup("open");
  115. break;
  116. }
  117. setTimeout(this.chk_video, 5000);
  118. }
  119. }
  120. }
  121. } else {
  122. // console.log(this.onLineVideoList)
  123. // console.log(this.deviceData)
  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].deviceCode) {
  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.length')
  136. // console.log(this.matchedDeviceList.length)
  137. }
  138. }
  139. });
  140. },
  141. open_video(item) {
  142. if (this.openId != item.DEVICE) {
  143. this.openId = item.DEVICE
  144. }
  145. for (var n = 0; n < this.onLineVideoList.length; n++) {
  146. if (this.onLineVideoList[n].DEVICE == this.openId) {
  147. if (this.onLineVideoList[n].ONAIR) {
  148. uni.navigateTo({
  149. url: '/pages/videoDetail/videoDetail?deviceType=2&companyCode=' + this.companyCode + '&deviceCode=' + item.DEVICE +
  150. '',
  151. });
  152. return;
  153. }
  154. }
  155. }
  156. this.count = 0;
  157. this.reCount = 0;
  158. this.loadingStatus = true
  159. // alert('一些loading操作')
  160. uni.request({
  161. url: 'https://fire.usky.cn:8443/YtIoT/cgi-bin/demo2.cgi',
  162. data: 'queryJson:' + JSON.stringify({
  163. CMD: 3,
  164. BODY: {
  165. DEVICE: item.DEVICE,
  166. ACTION: 1,
  167. IDX: 7
  168. }
  169. }),
  170. method: 'post',
  171. header: {
  172. 'Content-Type': 'application/x-www-form-urlencoded;charset=UTF-8'
  173. },
  174. success: (res) => {
  175. setTimeout(this.chk_video, 5000);
  176. }
  177. });
  178. },
  179. async getDeviceManage(ming = {}) {
  180. const res = await this.$myRequest({
  181. url: 'OperationMonitoring/getDeviceList',
  182. data: ming
  183. })
  184. this.deviceData = res.data.data;
  185. // console.log('this.deviceData')
  186. // console.log(this.deviceData)
  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>