videoList.vue 6.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245
  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. 'company_code':uni.getStorageSync('selectedCode')
  60. })
  61. this.chk_video()
  62. },
  63. computed: {
  64. },
  65. methods: {
  66. chk_video() {
  67. uni.request({
  68. url: 'https://fire.usky.cn:8443/YtIoT/cgi-bin/demo2.cgi',
  69. data: 'queryJson:' + JSON.stringify({
  70. CMD: 1
  71. }),
  72. method: 'post',
  73. header: {
  74. 'Content-Type': 'application/x-www-form-urlencoded;charset=UTF-8'
  75. },
  76. success: (res) => {
  77. this.onLineVideoList = res.data.RESULT.LIST;
  78. // console.log('this.onLineVideoList');
  79. // console.log(this.onLineVideoList)
  80. // console.log('this.openId')
  81. // console.log(this.openId)
  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/videoList/videoDetail/videoDetail?deviceCode=' + this.onLineVideoList[n].DEVICE,
  96. });
  97. } else {
  98. setTimeout(this.chk_video, 5000);
  99. }
  100. } else {
  101. if (this.reCount > 7) {
  102. // var mask = document.getElementById('videomask');
  103. // if (mask != undefined) {
  104. // removeDIV('videomask');
  105. // }
  106. this.loadingStatus = false;
  107. // alert('远程摄像头链接超时,请稍后再试')
  108. uni.showToast({
  109. title: "远程摄像头链接超时,请稍后再试",
  110. icon: "none"
  111. });
  112. // $("#myPopup").popup("open");
  113. break;
  114. }
  115. setTimeout(this.chk_video, 5000);
  116. }
  117. }
  118. }
  119. } else {
  120. for (var i = 0; i < this.onLineVideoList.length; i++) {
  121. for (var j = 0; j < this.deviceData.length; j++) {
  122. if (this.onLineVideoList[i].DEVICE == this.deviceData[j].owner_code) {
  123. this.matchedDeviceList.push({
  124. "DEVICE": this.onLineVideoList[i].DEVICE,
  125. "ALIVEVALUE": this.onLineVideoList[i].ALIVEVALUE,
  126. "ONAIR": this.onLineVideoList[i].ONAIR
  127. })
  128. }
  129. }
  130. }
  131. console.log('this.matchedDeviceList')
  132. console.log(this.matchedDeviceList)
  133. }
  134. }
  135. });
  136. },
  137. open_video(item) {
  138. // alert( item.DEVICE);
  139. if (this.openId != item.DEVICE) {
  140. this.openId = item.DEVICE
  141. }
  142. console.log('this.openId')
  143. console.log(this.openId)
  144. console.log('this.onLineVideoList')
  145. console.log(this.onLineVideoList)
  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/videoList/videoDetail/videoDetail?deviceType=2&companyCode=' + uni.getStorageSync('selectedCode') + '&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: '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: 'VideoMonitoring/getVideoList',
  183. data: ming
  184. })
  185. this.deviceData = res.data.data;
  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>