index.vue 4.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227
  1. <template>
  2. <view class="container">
  3. <!-- 天气控制 -->
  4. <view class="weather-section">
  5. <view
  6. v-for="(weather, index) in weathers"
  7. :key="index"
  8. :class="['weather-item', { active: currentWeather === weather.type }]"
  9. @click="handleWeatherChange(weather.type)"
  10. >
  11. <uni-icons :type="weather.icon" size="30" :color="currentWeather === weather.type ? '#ffffff' : '#333333'" />
  12. <text class="weather-text">{{ weather.name }}</text>
  13. </view>
  14. </view>
  15. <!-- 时区控制 -->
  16. <view class="time-section">
  17. <view
  18. v-for="(time, index) in times"
  19. :key="index"
  20. :class="['time-item', { active: currentTime === time.type }]"
  21. @click="handleTimeChange(time.type)"
  22. >
  23. <uni-icons :type="time.icon" size="24" :color="currentTime === time.type ? '#ffffff' : '#333333'" />
  24. <text class="time-text">{{ time.name }}</text>
  25. </view>
  26. </view>
  27. <!-- 模块控制 -->
  28. <view class="module-section">
  29. <view
  30. v-for="(module, index) in modules"
  31. :key="index"
  32. class="module-item"
  33. @click="handleModuleClick(module.type)"
  34. >
  35. <view class="module-icon">
  36. <uni-icons :type="module.icon" size="36" color="#2979ff" />
  37. </view>
  38. <text class="module-name">{{ module.name }}</text>
  39. <text class="module-status">{{ module.status }}</text>
  40. </view>
  41. </view>
  42. <view class="initialization">
  43. <button type="primary">
  44. 初始化选项
  45. </button>
  46. </view>
  47. </view>
  48. </template>
  49. <script lang="ts" setup>
  50. import { ref } from 'vue';
  51. // 天气类型
  52. type WeatherType = 'sunny' | 'foggy' | 'rainy' | 'snowy';
  53. const currentWeather = ref<WeatherType>('sunny');
  54. // 时间类型
  55. type TimeType = 'morning' | 'noon' | 'night';
  56. const currentTime = ref<TimeType>('morning');
  57. // 模块类型
  58. type ModuleType = 'overview' | 'security' | 'energy' | 'fire' | 'lamp' | 'passage';
  59. // 天气数据
  60. const weathers = [
  61. { type: 'sunny', name: '晴天', icon: 'sun' },
  62. { type: 'foggy', name: '雾天', icon: 'cloud' },
  63. { type: 'rainy', name: '雨天', icon: 'rain' },
  64. { type: 'snowy', name: '雪天', icon: 'snow' }
  65. ];
  66. // 时间数据
  67. const times = [
  68. { type: 'morning', name: '早上', icon: 'sun' },
  69. { type: 'noon', name: '中午', icon: 'sun-filled' },
  70. { type: 'night', name: '夜晚', icon: 'moon' }
  71. ];
  72. // 模块数据
  73. const modules = [
  74. { type: 'overview', name: '园区总览', icon: 'map', status: '运行正常' },
  75. { type: 'security', name: '智慧安防', icon: 'contact', status: '无异常' },
  76. { type: 'energy', name: '智慧能耗', icon: 'list', status: '节能运行' },
  77. { type: 'fire', name: '智慧消防', icon: 'fire', status: '系统正常' },
  78. { type: 'lamp', name: '智慧灯杆', icon: 'map-pin-ellipse', status: '照明正常' },
  79. { type: 'passage', name: '智慧通行', icon: 'staff', status: '通行顺畅' }
  80. ];
  81. // 处理天气变化
  82. const handleWeatherChange = (type: WeatherType) => {
  83. currentWeather.value = type;
  84. };
  85. // 处理时间变化
  86. const handleTimeChange = (type: TimeType) => {
  87. currentTime.value = type;
  88. };
  89. // 处理模块点击
  90. const handleModuleClick = (type: ModuleType) => {
  91. console.log('点击模块:', type);
  92. };
  93. </script>
  94. <style>
  95. page {
  96. height: 100%;
  97. }
  98. .container {
  99. min-height: 100%;
  100. padding: 30rpx;
  101. background-color: #f5f5f5;
  102. }
  103. .weather-section {
  104. display: flex;
  105. justify-content: space-between;
  106. padding: 20rpx;
  107. background-color: #ffffff;
  108. border-radius: 16rpx;
  109. margin-bottom: 30rpx;
  110. }
  111. .weather-item {
  112. display: flex;
  113. flex-direction: column;
  114. align-items: center;
  115. padding: 20rpx 30rpx;
  116. border-radius: 12rpx;
  117. transition: all 0.3s;
  118. }
  119. .weather-item.active {
  120. background-color: #2979ff;
  121. }
  122. .weather-text {
  123. margin-top: 10rpx;
  124. font-size: 14px;
  125. color: #333333;
  126. }
  127. .weather-item.active .weather-text {
  128. color: #ffffff;
  129. }
  130. .time-section {
  131. display: flex;
  132. justify-content: space-around;
  133. padding: 20rpx;
  134. background-color: #ffffff;
  135. border-radius: 16rpx;
  136. margin-bottom: 30rpx;
  137. }
  138. .time-item {
  139. display: flex;
  140. align-items: center;
  141. padding: 16rpx 40rpx;
  142. border-radius: 12rpx;
  143. transition: all 0.3s;
  144. }
  145. .time-item.active {
  146. background-color: #2979ff;
  147. }
  148. .time-text {
  149. margin-left: 10rpx;
  150. font-size: 14px;
  151. color: #333333;
  152. }
  153. .time-item.active .time-text {
  154. color: #ffffff;
  155. }
  156. .module-section {
  157. display: grid;
  158. grid-template-columns: repeat(2, 1fr);
  159. gap: 20rpx;
  160. }
  161. .module-item {
  162. background-color: #ffffff;
  163. border-radius: 16rpx;
  164. padding: 30rpx;
  165. display: flex;
  166. flex-direction: column;
  167. align-items: center;
  168. transition: transform 0.3s;
  169. }
  170. .module-item:active {
  171. transform: scale(0.98);
  172. }
  173. .module-icon {
  174. width: 80rpx;
  175. height: 80rpx;
  176. display: flex;
  177. justify-content: center;
  178. align-items: center;
  179. margin-bottom: 20rpx;
  180. }
  181. .module-name {
  182. font-size: 16px;
  183. color: #333333;
  184. margin-bottom: 10rpx;
  185. }
  186. .module-status {
  187. font-size: 12px;
  188. color: #666666;
  189. }
  190. .initialization{
  191. margin-top: 12px;
  192. }
  193. </style>