index.vue 6.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256
  1. <template>
  2. <view class="tabPage" :style="{'min-height':h+'px', 'padding-top':mt+'px'}">
  3. <cus-header title='首页' :titleStyle="{color:'transparent'}" :showback='false' bgColor='transparent'></cus-header>
  4. <image class="topbg" :src="imgBase+'home/home_top_bg.png'" mode="widthFix"></image>
  5. <div class="header">
  6. <div class="top">
  7. <div class="left">
  8. <div class="title">
  9. <text>谷锐特</text>
  10. <u-icon name="arrow-right" color="#FFFFFF" size="32"></u-icon>
  11. </div>
  12. <div class="tip">{{time}},天气{{weatherInfo.weather||''}}</div>
  13. </div>
  14. <div class="right" @tap="tuTurn('/pages/my/info')">
  15. <image :src="avatar"></image>
  16. </div>
  17. </div>
  18. <div class="weather">
  19. <div class="item line">
  20. <div class="text">{{deviceNum}}<span></span></div>
  21. <p>运行设备</p>
  22. </div>
  23. <div class="item line">
  24. <div class="text">{{weatherInfo.temperature||''}}<span>℃</span></div>
  25. <p>温度</p>
  26. </div>
  27. <div class="item">
  28. <div class="text">{{weatherInfo.humidity||''}}<span>%</span></div>
  29. <p>湿度</p>
  30. </div>
  31. </div>
  32. </div>
  33. <div class="boxs">
  34. <div class="box" @tap="tuTurn('/pagesHome/video/index')">
  35. <image :src="imgBase+'home/home_icon_spjk.png'"></image>
  36. <text>视频监控</text>
  37. </div>
  38. <div class="box" @tap="tuTurn('/pagesHome/airConditioner/index')">
  39. <image :src="imgBase+'home/home_icon_zhkt.png'"></image>
  40. <text>智慧空调</text>
  41. </div>
  42. <div class="box" @tap="tuTurn('/pagesHome/entranceGuard/index')">
  43. <image :src="imgBase+'home/home_icon_mjgl.png'"></image>
  44. <text>门禁管理</text>
  45. </div>
  46. <div class="box" @tap="tuTurn('/pagesHome/energyMeter/index')">
  47. <image :src="imgBase+'home/home_icon_db.png'"></image>
  48. <text>电表</text>
  49. </div>
  50. <div class="box" @tap="tuTurn('/pagesHome/energyConsumption/index')">
  51. <image :src="imgBase+'home/home_icon_nhfx.png'"></image>
  52. <text>能耗分析</text>
  53. </div>
  54. <div class="box" @tap="tuTurn('/pagesHome/employee/index')">
  55. <image :src="imgBase+'home/home_icon_yggl.png'"></image>
  56. <text>员工管理</text>
  57. </div>
  58. </div>
  59. <Tabbar :tabbarIndex="0"></Tabbar>
  60. </view>
  61. </template>
  62. <script>
  63. var amapFile = require('@/utils/amap-wx.130.js');
  64. var myAmapFun = new amapFile.AMapWX({key:'f83be04fc5f239edfa9f1201e4bc7c47'});
  65. import Tabbar from '@/components/CusTabbar/index.vue'
  66. export default {
  67. components:{
  68. Tabbar
  69. },
  70. data(){
  71. return {
  72. avatar:this.$imgBase+'home/home_avator.png',
  73. time:'早上好',
  74. deviceNum:0,
  75. weatherInfo:{}
  76. }
  77. },
  78. onShow() {
  79. this.avatar = JSON.parse(uni.getStorageSync('userInfo')||'{}')?.headUrl;
  80. },
  81. onLoad() {
  82. this.getTime();
  83. this.getWeather();
  84. },
  85. methods:{
  86. getTime(){
  87. let hours = new Date().getHours()+1;
  88. if(hours<=8) this.time = '早上好';
  89. else if(hours<=11) this.time = '上午好';
  90. else if(hours<=13) this.time = '中午好';
  91. else if(hours<=18) this.time = '下午好';
  92. else if(hours<=24) this.time = '晚上好';
  93. },
  94. getWeather(){
  95. myAmapFun.getWeather({
  96. success:res=>{
  97. this.weatherInfo = res.liveData;
  98. },
  99. fail:err=>{
  100. uni.showModal({
  101. title:'天气',
  102. content:JSON.stringify(err)
  103. })
  104. }
  105. })
  106. },
  107. tuTurn(url){
  108. if(!url) return
  109. uni.navigateTo({ url });
  110. }
  111. }
  112. }
  113. </script>
  114. <style scoped lang="less">
  115. .tabPage{
  116. width: 100%;
  117. padding: 0 0 188rpx;
  118. box-sizing: border-box;
  119. background: #F4F8FB;
  120. .topbg{
  121. width: 100%;
  122. position: fixed;
  123. top: 0;
  124. left: 0;
  125. z-index: 0;
  126. }
  127. .header{
  128. width: 100%;
  129. position: relative;
  130. .top{
  131. width: 100%;
  132. padding: 26rpx 40rpx 0;
  133. box-sizing: border-box;
  134. display: flex;
  135. align-items: center;
  136. justify-content: space-between;
  137. .left{
  138. .title{
  139. display: flex;
  140. align-items: center;
  141. text{
  142. font-family: PingFang-SC, PingFang-SC;
  143. font-weight: bold;
  144. font-size: 48rpx;
  145. color: #FFFFFF;
  146. line-height: 48rpx;
  147. text-align: left;
  148. letter-spacing: 2rpx;
  149. margin-right: 20rpx;
  150. }
  151. }
  152. .tip{
  153. font-family: PingFangSC, PingFang SC;
  154. font-weight: 400;
  155. font-size: 24rpx;
  156. color: #FFFFFF;
  157. line-height: 30rpx;
  158. text-align: left;
  159. margin-top: 20rpx;
  160. }
  161. }
  162. .right{
  163. width: 90rpx;
  164. height: 90rpx;
  165. background: #FFFFFF;
  166. padding: 2rpx;
  167. box-sizing: border-box;
  168. border-radius: 50%;
  169. image{
  170. width: 100%;
  171. height: 100%;
  172. border-radius: 50%;
  173. }
  174. }
  175. }
  176. .weather{
  177. width: 100%;
  178. margin-top: 50rpx;
  179. display: flex;
  180. .item{
  181. width: calc(100% / 3);
  182. display: flex;
  183. flex-direction: column;
  184. align-items: center;
  185. position: relative;
  186. &::after{
  187. content: '';
  188. width: 1rpx;
  189. height: 64rpx;
  190. background: #CCCCCC;
  191. position: absolute;
  192. top:10rpx;
  193. right: 0;
  194. }
  195. .text{
  196. font-family: PingFang-SC, PingFang-SC;
  197. font-weight: bold;
  198. font-size: 44rpx;
  199. color: #FFFFFF;
  200. line-height: 44rpx;
  201. span{
  202. font-weight: 400;
  203. font-size: 20rpx;
  204. }
  205. }
  206. p{
  207. font-family: PingFangSC, PingFang SC;
  208. font-weight: 400;
  209. font-size: 24rpx;
  210. color: #FFFFFF;
  211. line-height: 24rpx;
  212. text-align: center;
  213. margin-top: 16rpx;
  214. }
  215. }
  216. }
  217. }
  218. .boxs{
  219. width: calc(100% - 48rpx);
  220. margin: 38rpx 24rpx 0;
  221. display: flex;
  222. justify-content: space-between;
  223. flex-wrap: wrap;
  224. position: relative;
  225. .box{
  226. width: calc(50% - 11rpx);
  227. padding: 40rpx 22rpx;
  228. box-sizing: border-box;
  229. background: #FFFFFF;
  230. border-radius: 8rpx;
  231. display: flex;
  232. align-items: center;
  233. margin-top: 20rpx;
  234. image{
  235. width: 90rpx;
  236. height: 88rpx;
  237. }
  238. text{
  239. font-family: PingFang-SC, PingFang-SC;
  240. font-weight: bold;
  241. font-size: 30rpx;
  242. color: #333333;
  243. line-height: 30rpx;
  244. padding-left: 24rpx;
  245. }
  246. }
  247. }
  248. }
  249. </style>