list.nvue 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198
  1. <template>
  2. <view class="page">
  3. <image class="content-bg" src="/static/device/devicebg.png" mode="scaleToFill"></image>
  4. <view class="status-bar" :style="{height: statusBarHeight + 'px'}"></view>
  5. <view class="custom-head">
  6. <text class="head-placeholder"> </text>
  7. <text class="head-title">我的设备</text>
  8. <text class="head-add" @click="goAddDevice">+</text>
  9. </view>
  10. <text class="section-title">已添加设备</text>
  11. <view class="device-list">
  12. <!-- 设备卡片 -->
  13. <view class="device-card" v-for="(item, index) in list" :key="index" @click="goDeviceInfo(item)">
  14. <image class="device-icon" src="/static/device/device1.png" mode="heightFix"></image>
  15. <text class="device-name">{{item.name}}</text>
  16. <text class="device-status"></text>
  17. </view>
  18. <!-- 添加设备卡片 -->
  19. <view class="device-card add-card" @click="goAddDevice">
  20. <text class="add-title">添加设备</text>
  21. <view class="add-icon-wrap">
  22. <view class="add-icon-circle">
  23. <text class="add-icon-text">+</text>
  24. </view>
  25. <text class="add-tip">去添加</text>
  26. </view>
  27. </view>
  28. </view>
  29. <ay-toast ref="ayToast" />
  30. </view>
  31. </template>
  32. <script>
  33. import ayToast from '@/components/ay-toast/ay-toast.nvue'
  34. export default {
  35. components: {
  36. ayToast
  37. },
  38. data() {
  39. return {
  40. statusBarHeight: 44,
  41. list: []
  42. }
  43. },
  44. onShow() {
  45. const sysInfo = uni.getSystemInfoSync()
  46. this.statusBarHeight = sysInfo.statusBarHeight || 44
  47. this.init()
  48. },
  49. onPullDownRefresh() {
  50. uni.stopPullDownRefresh()
  51. this.init()
  52. },
  53. methods: {
  54. init() {
  55. // 从本地存储读取设备列表
  56. try {
  57. const data = uni.getStorageSync('deviceList')
  58. if (data && data.length > 0) {
  59. this.list = data
  60. } else {
  61. this.list = []
  62. }
  63. } catch (e) {
  64. this.list = []
  65. }
  66. },
  67. goAddDevice() {
  68. // TODO: 跳转添加设备页面
  69. this.$toastRef.text('添加设备')
  70. },
  71. goDeviceInfo(item) {
  72. // TODO: 跳转设备详情
  73. this.$toastRef.text('设备: ' + item.name)
  74. }
  75. }
  76. }
  77. </script>
  78. <style>
  79. .page {
  80. flex: 1;
  81. position: relative;
  82. }
  83. .content-bg {
  84. position: absolute;
  85. left: 0;
  86. top: 0;
  87. width: 750rpx;
  88. height: 1400rpx;
  89. }
  90. .status-bar {
  91. background-color: rgba(0,0,0,0);
  92. }
  93. .custom-head {
  94. flex-direction: row;
  95. justify-content: space-between;
  96. align-items: center;
  97. height: 88rpx;
  98. padding-left: 54rpx;
  99. padding-right: 54rpx;
  100. }
  101. .head-placeholder {
  102. width: 36rpx;
  103. }
  104. .head-title {
  105. font-weight: bold;
  106. font-size: 32rpx;
  107. color: #545F71;
  108. }
  109. .head-add {
  110. width: 36rpx;
  111. height: 36rpx;
  112. border-width: 2px;
  113. border-style: solid;
  114. border-color: #545F71;
  115. border-radius: 36rpx;
  116. text-align: center;
  117. line-height: 32rpx;
  118. font-size: 26rpx;
  119. font-weight: bold;
  120. color: #545F71;
  121. }
  122. .section-title {
  123. font-size: 32rpx;
  124. color: #545F71;
  125. margin-left: 38rpx;
  126. margin-bottom: 38rpx;
  127. margin-top: 20rpx;
  128. }
  129. .device-list {
  130. flex-direction: row;
  131. flex-wrap: wrap;
  132. justify-content: space-between;
  133. padding-left: 38rpx;
  134. padding-right: 38rpx;
  135. }
  136. .device-card {
  137. width: 324rpx;
  138. height: 300rpx;
  139. background-color: #FFFFFF;
  140. border-radius: 24rpx;
  141. margin-bottom: 26rpx;
  142. align-items: center;
  143. padding-top: 40rpx;
  144. }
  145. .device-icon {
  146. width: 156rpx;
  147. height: 156rpx;
  148. }
  149. .device-name {
  150. margin-top: 36rpx;
  151. font-weight: bold;
  152. font-size: 28rpx;
  153. color: #545F71;
  154. }
  155. .device-status {
  156. font-size: 24rpx;
  157. color: #999999;
  158. margin-top: 10rpx;
  159. }
  160. .add-card {
  161. align-items: flex-start;
  162. padding-left: 40rpx;
  163. padding-top: 40rpx;
  164. }
  165. .add-title {
  166. font-weight: bold;
  167. font-size: 28rpx;
  168. color: #545F71;
  169. margin-bottom: 48rpx;
  170. }
  171. .add-icon-wrap {
  172. align-items: center;
  173. width: 244rpx;
  174. }
  175. .add-icon-circle {
  176. width: 60rpx;
  177. height: 60rpx;
  178. background-color: #C3DFDB;
  179. border-radius: 60rpx;
  180. justify-content: center;
  181. align-items: center;
  182. }
  183. .add-icon-text {
  184. font-size: 42rpx;
  185. color: #389588;
  186. font-weight: bold;
  187. margin-top: -4rpx;
  188. }
  189. .add-tip {
  190. text-align: center;
  191. margin-top: 8rpx;
  192. font-size: 24rpx;
  193. color: #999999;
  194. }
  195. </style>