videoList.vue 6.2 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. 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:this.companyCode==2?'http://124.71.175.91:80/cgi-bin/demo2.cgi': '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. console.log(this.count)
  89. if ((++this.count) > 0) {
  90. // var mask = document.getElementById('videomask');
  91. // if (mask != undefined) {
  92. // removeDIV('videomask');
  93. // }
  94. this.loadingStatus = false;
  95. uni.navigateTo({
  96. url: '/pages/videoDetail/videoDetail?deviceType=2&companyCode=' + this.companyCode + '&deviceCode=' +
  97. this.onLineVideoList[n].DEVICE +
  98. '',
  99. });
  100. } else {
  101. setTimeout(this.chk_video, 5000);
  102. }
  103. } else {
  104. if (this.reCount > 7) {
  105. // var mask = document.getElementById('videomask');
  106. // if (mask != undefined) {
  107. // removeDIV('videomask');
  108. // }
  109. this.loadingStatus = false;
  110. // alert('远程摄像头链接超时,请稍后再试')
  111. uni.showToast({
  112. title: "远程摄像头链接超时,请稍后再试",
  113. icon: "none"
  114. });
  115. // $("#myPopup").popup("open");
  116. break;
  117. }
  118. setTimeout(this.chk_video, 5000);
  119. }
  120. }
  121. }
  122. } else {
  123. // console.log(this.onLineVideoList)
  124. // console.log(this.deviceData)
  125. for (var i = 0; i < this.onLineVideoList.length; i++) {
  126. for (var j = 0; j < this.deviceData.length; j++) {
  127. if (this.onLineVideoList[i].DEVICE == this.deviceData[j].deviceCode) {
  128. this.matchedDeviceList.push({
  129. "DEVICE": this.onLineVideoList[i].DEVICE,
  130. "ALIVEVALUE": this.onLineVideoList[i].ALIVEVALUE,
  131. "ONAIR": this.onLineVideoList[i].ONAIR
  132. })
  133. }
  134. }
  135. }
  136. // console.log('this.matchedDeviceList.length')
  137. // console.log(this.matchedDeviceList.length)
  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. });
  153. return;
  154. }
  155. }
  156. }
  157. this.count = 0;
  158. this.reCount = 0;
  159. this.loadingStatus = true
  160. // alert('一些loading操作')
  161. uni.request({
  162. url:this.companyCode==2?'http://124.71.175.91:80/cgi-bin/demo2.cgi': 'https://fire.usky.cn:8443/YtIoT/cgi-bin/demo2.cgi',
  163. data: 'queryJson:' + JSON.stringify({
  164. CMD: 3,
  165. BODY: {
  166. DEVICE: item.DEVICE,
  167. ACTION: 1,
  168. IDX: 7
  169. }
  170. }),
  171. method: 'post',
  172. header: {
  173. 'Content-Type': 'application/x-www-form-urlencoded;charset=UTF-8'
  174. },
  175. success: (res) => {
  176. setTimeout(this.chk_video, 5000);
  177. }
  178. });
  179. },
  180. async getDeviceManage(ming = {}) {
  181. const res = await this.$myRequest({
  182. url: 'OperationMonitoring/getDeviceList',
  183. data: ming
  184. })
  185. this.deviceData = res.data.data;
  186. // console.log('this.deviceData')
  187. // console.log(this.deviceData)
  188. },
  189. }
  190. }
  191. </script>
  192. <style lang="scss">
  193. .loadingMask {
  194. width: 100%;
  195. height: 100%;
  196. position: absolute;
  197. left: 0;
  198. background: rgba(0, 0, 0, .3);
  199. z-index: 1000;
  200. color: #000;
  201. justify-content: center;
  202. align-items: center;
  203. display: flex;
  204. text-align: center;
  205. padding-top: 100rpx;
  206. font-size: 34rpx;
  207. }
  208. </style>