index.vue 6.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258
  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.wea||''}},共有{{deviceNum}}个设备正在运行</div> -->
  13. <div class="tip">{{time}},天气{{weatherInfo.wea||''}}</div>
  14. </div>
  15. <div class="right" @tap="tuTurn('/pages/my/info')">
  16. <image :src="avatar"></image>
  17. </div>
  18. </div>
  19. <div class="weather">
  20. <div class="item line">
  21. <div class="text">{{weatherInfo.air_level||''}}</div>
  22. <p>空气质量</p>
  23. </div>
  24. <div class="item line">
  25. <div class="text">{{weatherInfo.tem||''}}<span>℃</span></div>
  26. <p>温度</p>
  27. </div>
  28. <div class="item">
  29. <div class="text">{{weatherInfo.humidity||''}}<span>%</span></div>
  30. <p>湿度</p>
  31. </div>
  32. </div>
  33. </div>
  34. <div class="boxs">
  35. <div class="box" @tap="tuTurn('/pagesHome/video/index')">
  36. <image :src="imgBase+'home/home_icon_spjk.png'"></image>
  37. <text>视频监控</text>
  38. </div>
  39. <div class="box" @tap="tuTurn('/pagesHome/airConditioner/index')">
  40. <image :src="imgBase+'home/home_icon_zhkt.png'"></image>
  41. <text>智慧空调</text>
  42. </div>
  43. <div class="box" @tap="tuTurn('/pagesHome/entranceGuard/index')">
  44. <image :src="imgBase+'home/home_icon_mjgl.png'"></image>
  45. <text>门禁管理</text>
  46. </div>
  47. <div class="box" @tap="tuTurn('/pagesHome/energyMeter/index')">
  48. <image :src="imgBase+'home/home_icon_db.png'"></image>
  49. <text>电表</text>
  50. </div>
  51. <div class="box" @tap="tuTurn('/pagesHome/energyConsumption/index')">
  52. <image :src="imgBase+'home/home_icon_nhfx.png'"></image>
  53. <text>能耗分析</text>
  54. </div>
  55. <div class="box" @tap="tuTurn('/pagesHome/employee/index')">
  56. <image :src="imgBase+'home/home_icon_yggl.png'"></image>
  57. <text>员工管理</text>
  58. </div>
  59. </div>
  60. <Tabbar :tabbarIndex="0"></Tabbar>
  61. </view>
  62. </template>
  63. <script>
  64. var amapFile = require('@/utils/amap-wx.130.js');
  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. // uni.request({
  96. // url:'http://gfeljm.tianqiapi.com/free/v2030?appid=31449887&appsecret=7F6JCrvB&adcode=340100000000',
  97. // success:res=>{
  98. // this.weatherInfo = res.data;
  99. // this.weatherInfo.humidity = this.weatherInfo.humidity.replace('%','')
  100. // }
  101. // })
  102. var myAmapFun = new amapFile.AMapWX({key:'f83be04fc5f239edfa9f1201e4bc7c47'});
  103. myAmapFun.getWeather({
  104. success: function(data) {
  105. console.log(data);
  106. }
  107. })
  108. },
  109. tuTurn(url){
  110. if(!url) return
  111. uni.navigateTo({ url });
  112. }
  113. }
  114. }
  115. </script>
  116. <style scoped lang="less">
  117. .tabPage{
  118. width: 100%;
  119. padding: 0 0 188rpx;
  120. box-sizing: border-box;
  121. background: #F4F8FB;
  122. .topbg{
  123. width: 100%;
  124. position: fixed;
  125. top: 0;
  126. left: 0;
  127. z-index: 0;
  128. }
  129. .header{
  130. width: 100%;
  131. position: relative;
  132. .top{
  133. width: 100%;
  134. padding: 26rpx 40rpx 0;
  135. box-sizing: border-box;
  136. display: flex;
  137. align-items: center;
  138. justify-content: space-between;
  139. .left{
  140. .title{
  141. display: flex;
  142. align-items: center;
  143. text{
  144. font-family: PingFang-SC, PingFang-SC;
  145. font-weight: bold;
  146. font-size: 48rpx;
  147. color: #FFFFFF;
  148. line-height: 48rpx;
  149. text-align: left;
  150. letter-spacing: 2rpx;
  151. margin-right: 20rpx;
  152. }
  153. }
  154. .tip{
  155. font-family: PingFangSC, PingFang SC;
  156. font-weight: 400;
  157. font-size: 24rpx;
  158. color: #FFFFFF;
  159. line-height: 30rpx;
  160. text-align: left;
  161. margin-top: 20rpx;
  162. }
  163. }
  164. .right{
  165. width: 90rpx;
  166. height: 90rpx;
  167. background: #FFFFFF;
  168. padding: 2rpx;
  169. box-sizing: border-box;
  170. border-radius: 50%;
  171. image{
  172. width: 100%;
  173. height: 100%;
  174. border-radius: 50%;
  175. }
  176. }
  177. }
  178. .weather{
  179. width: 100%;
  180. margin-top: 50rpx;
  181. display: flex;
  182. .item{
  183. width: calc(100% / 3);
  184. display: flex;
  185. flex-direction: column;
  186. align-items: center;
  187. position: relative;
  188. &::after{
  189. content: '';
  190. width: 1rpx;
  191. height: 64rpx;
  192. background: #CCCCCC;
  193. position: absolute;
  194. top:10rpx;
  195. right: 0;
  196. }
  197. .text{
  198. font-family: PingFang-SC, PingFang-SC;
  199. font-weight: bold;
  200. font-size: 44rpx;
  201. color: #FFFFFF;
  202. line-height: 44rpx;
  203. span{
  204. font-weight: 400;
  205. font-size: 20rpx;
  206. }
  207. }
  208. p{
  209. font-family: PingFangSC, PingFang SC;
  210. font-weight: 400;
  211. font-size: 24rpx;
  212. color: #FFFFFF;
  213. line-height: 24rpx;
  214. text-align: center;
  215. margin-top: 16rpx;
  216. }
  217. }
  218. }
  219. }
  220. .boxs{
  221. width: calc(100% - 48rpx);
  222. margin: 38rpx 24rpx 0;
  223. display: flex;
  224. justify-content: space-between;
  225. flex-wrap: wrap;
  226. position: relative;
  227. .box{
  228. width: calc(50% - 11rpx);
  229. padding: 40rpx 22rpx;
  230. box-sizing: border-box;
  231. background: #FFFFFF;
  232. border-radius: 8rpx;
  233. display: flex;
  234. align-items: center;
  235. margin-top: 20rpx;
  236. image{
  237. width: 90rpx;
  238. height: 88rpx;
  239. }
  240. text{
  241. font-family: PingFang-SC, PingFang-SC;
  242. font-weight: bold;
  243. font-size: 30rpx;
  244. color: #333333;
  245. line-height: 30rpx;
  246. padding-left: 24rpx;
  247. }
  248. }
  249. }
  250. }
  251. </style>