more.vue 6.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230
  1. <template>
  2. <view>
  3. <uni-nav-bar id="nav-bar" status-bar="true" @clickLeft="onBack()" title="我的设备" color="#000000" fixed="true" :border="false">
  4. <view slot="left">
  5. <view class=" flex align-center margin-left">
  6. <image class="p-left-arrow" src="../../../static/p-left-arrow.png"></image>
  7. </view>
  8. </view>
  9. </uni-nav-bar>
  10. <view class="card-view text-center">
  11. <view class="plan-w" style="margin-top: 34px;">
  12. <view class="plan-w-child">
  13. <image src="../../../static/moreBg.png"></image>
  14. </view>
  15. </view>
  16. <view class="plan-Tip flex justify-center align-center">
  17. <view class="plan-Tip-child make-text-bPurple flex align-center justify-between">
  18. <view class="flex" style="margin-left: 80rpx;">
  19. <image style="width:48rpx;height: 48rpx;" src="../../../static/wifi_on.png"></image>
  20. <view class="padding-left text-16px">在线设备</view>
  21. </view>
  22. <view class=" text-16px" style="margin-right: 80rpx;">{{cIndex==-1?0:1}} 台</view>
  23. </view>
  24. </view>
  25. <view class="button-fav" @tap="onNavToDevices">
  26. <image style="width: 72rpx;height: 72rpx; margin-right: 12rpx;" src="../../../static/add_w.png"></image>
  27. 添加设备
  28. </view>
  29. </view>
  30. <!-- 添加设备部分 -->
  31. <view class="card-view">
  32. <view class="text-left padding margin-xs">
  33. <text class="text-black text-bold ">我的设备</text>
  34. </view>
  35. <!-- @tap="onDevice(item,$event)" -->
  36. <view class="container-device">
  37. <view class="width-device flex align-center " v-for="(item,index) in BLEDeviceList" :key="index"
  38. :data-index="index">
  39. <!-- <view style="position: relative; height: 100%;">
  40. <image src="/static/deviceBg.png" class="data-png-64" mode="aspectFit"></image>
  41. <image src="/static/trampolineS.png" class="data-png-add" mode="aspectFit"></image>
  42. </view>
  43. <view class="flex-sub text-center">
  44. <image src="/static/wifi_on.png" class="data-png-32" mode="aspectFit"></image>
  45. <view class="text-gray">{{item.cname}}</view>
  46. </view>
  47. <view style="position: absolute;right: 0;top: 0;" @tap.stop="onCloseDevice(item,$event)" :data-index="index">
  48. <image src="/static/d_on.png" class="data-png-26" mode="aspectFit"></image>
  49. </view> -->
  50. <view style="position: relative; height: 100%;">
  51. <image :src="index == cIndex ? '/static/deviceBg.png' : '/static/deviceBg_off.png'" class="data-png-64" mode="aspectFit"></image>
  52. <image src="/static/trampolineS.png" class="data-png-add" mode="aspectFit"></image>
  53. </view>
  54. <view class="flex-sub text-center">
  55. <image :src="index == cIndex ? '/static/wifi_on.png' : '/static/wifi_off.png'" class="data-png-32" mode="aspectFit"></image>
  56. <view class="text-gray">{{ item.cname }}</view>
  57. </view>
  58. <!-- @tap.stop="onCloseDevice(item, $event)" :data-index="index" -->
  59. <!-- <view style="position: absolute;right: 0;top: 0;" >
  60. <image :src="index == cIndex ? '/static/d_on.png' : '/static/d_off.png'" class="data-png-26" mode="aspectFit"></image>
  61. </view> -->
  62. </view>
  63. </view>
  64. </view>
  65. </view>
  66. </template>
  67. <script>
  68. import config from '../../../common/config.js'
  69. import date from '../../../util/util-js/date.js'
  70. import reqUtil from '../../../util/util-js/requstUtil.js'
  71. import picker from "@/components/slambb-picker/slambb-picker.vue";
  72. import pickerData from '@/components/slambb-picker/picker.js';
  73. import {
  74. mapState
  75. } from 'vuex'
  76. export default {
  77. computed: mapState(['planData', 'BLEDeviceList']),
  78. components: {
  79. picker,
  80. },
  81. data() {
  82. return {
  83. cIndex: -1
  84. }
  85. },
  86. onShow() {
  87. },
  88. onLoad: function(option) { //option为object类型,会序列化上个页面传递的参数
  89. console.log(option);
  90. this.cIndex = option.index;
  91. },
  92. methods: {
  93. onNavToDevices() {
  94. uni.navigateTo({
  95. url: '../devices/devices?newsid=' + 11,
  96. success: res => {},
  97. fail: () => {},
  98. complete: () => {}
  99. });
  100. },
  101. onBack() {
  102. uni.navigateBack({
  103. delta: 1
  104. })
  105. },
  106. onCloseDevice(item, e) {
  107. //如果不是连接状态,则删除
  108. if (e.currentTarget.dataset.index != this.cIndex) {
  109. uni.showModal({
  110. title: '设备状态',
  111. content: '是否删除设备',
  112. ConfirmColor: '#A488DC',
  113. success: res => {
  114. if (res.confirm) {
  115. // this.$store.state.BLEDeviceList.splice(e.currentTarget.dataset.index, 1)
  116. this.$store.commit('deleteBLEDevice', e.currentTarget.dataset.index);
  117. }
  118. }
  119. });
  120. return;
  121. }
  122. uni.showModal({
  123. title: '设备状态',
  124. content: '是否关闭设备绑定',
  125. /**
  126. * 如果需要强制,不显示取消按钮
  127. */
  128. showCancel: true,
  129. ConfirmColor: '#A488DC',
  130. success: res => {
  131. if (res.confirm) {
  132. // this.$store.state.BLEDeviceList.splice(e.currentTarget.dataset.index, 1)
  133. // this.$store.commit('deleteBLEDevice', e.currentTarget.dataset.index);
  134. BLE.closeBLEConnection(item.deviceId);
  135. if (this.cIndex == e.currentTarget.dataset.index) {
  136. this.cIndex = -1;
  137. }
  138. }
  139. }
  140. });
  141. }
  142. }
  143. }
  144. </script>
  145. <style>
  146. .plan-w {
  147. position: relative;
  148. /* width: 464rpx; */
  149. height: 464rpx;
  150. }
  151. .plan-w-child {
  152. position: absolute;
  153. left: 0;
  154. right: 0;
  155. top: 0;
  156. bottom: 0;
  157. margin: auto;
  158. width: 488rpx;
  159. height: 372rpx;
  160. display: flex;
  161. flex-direction: column;
  162. justify-content: center;
  163. align-items: center;
  164. }
  165. .plan-Tip {
  166. height: 90rpx;
  167. /* margin: 60rpx 0; */
  168. margin-bottom: 60rpx;
  169. }
  170. .plan-Tip-child {
  171. background-color: #f5f5ff;
  172. border-radius: 20px;
  173. width: 614rpx;
  174. height: 90rpx;
  175. /* margin-top: 60rpx; */
  176. }
  177. .button-fav {
  178. background-color: rgba(153, 150, 252, 255);
  179. color: #FFFFFF;
  180. /* border-radius: 10px; */
  181. /* width: 184rpx; */
  182. height: 122rpx;
  183. display: flex;
  184. justify-content: center;
  185. text-align: center;
  186. align-items: center;
  187. font-size: 17px;
  188. }
  189. .data-png-add {
  190. position: absolute;
  191. left: 0;
  192. top: 0;
  193. right: 0;
  194. bottom: 0;
  195. margin: auto;
  196. width: 34px;
  197. height: 37px;
  198. }
  199. </style>