index.vue 7.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319
  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>
  14. <div class="right">
  15. <image :src="avatar"></image>
  16. </div>
  17. </div>
  18. <div class="weather">
  19. <div class="item line">
  20. <div class="text">{{weatherInfo.air_level||''}}</div>
  21. <p>空气质量</p>
  22. </div>
  23. <div class="item line">
  24. <div class="text">{{weatherInfo.tem||''}}<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. <div class="left">
  36. <image :src="imgBase+'home/home_icon_spjk.png'"></image>
  37. <text>视频监控</text>
  38. </div>
  39. <div class="right">
  40. <div class="num">{{18}}</div>
  41. <div class="wz">设备</div>
  42. </div>
  43. </div>
  44. <div class="box" @tap="tuTurn('/pagesHome/airConditioner/index')">
  45. <div class="left">
  46. <image :src="imgBase+'home/home_icon_zhkt.png'"></image>
  47. <text>智慧空调</text>
  48. </div>
  49. <div class="right">
  50. <div class="num">{{18}}</div>
  51. <div class="wz">设备</div>
  52. </div>
  53. </div>
  54. <div class="box" @tap="tuTurn('/pagesHome/entranceGuard/index')">
  55. <div class="left">
  56. <image :src="imgBase+'home/home_icon_mjgl.png'"></image>
  57. <text>门禁管理</text>
  58. </div>
  59. <div class="right">
  60. <div class="num">{{18}}</div>
  61. <div class="wz">设备</div>
  62. </div>
  63. </div>
  64. <div class="box" @tap="tuTurn('/pagesHome/employee/index')">
  65. <div class="left">
  66. <image :src="imgBase+'home/home_icon_yggl.png'"></image>
  67. <text>员工管理</text>
  68. </div>
  69. <div class="right">
  70. <div class="num">{{18}}</div>
  71. <div class="wz">设备</div>
  72. </div>
  73. </div>
  74. <div class="box" @tap="tuTurn('/pagesHome/energyConsumption/index')">
  75. <div class="left">
  76. <image :src="imgBase+'home/home_icon_nhfx.png'"></image>
  77. <text>能耗分析</text>
  78. </div>
  79. <div class="right">
  80. <div class="num">{{18}}</div>
  81. <div class="wz">设备</div>
  82. </div>
  83. </div>
  84. <div class="box" @tap="tuTurn('/pagesHome/energyMeter/index')">
  85. <div class="left">
  86. <image :src="imgBase+'home/home_icon_db.png'"></image>
  87. <text>电表</text>
  88. </div>
  89. <div class="right">
  90. <div class="num">{{18}}</div>
  91. <div class="wz">设备</div>
  92. </div>
  93. </div>
  94. </div>
  95. <Tabbar :tabbarIndex="0"></Tabbar>
  96. </view>
  97. </template>
  98. <script>
  99. var amapFile = require('@/utils/amap-wx.130.js');
  100. import Tabbar from '@/components/CusTabbar/index.vue'
  101. export default {
  102. components:{
  103. Tabbar
  104. },
  105. data(){
  106. return {
  107. avatar:this.$imgBase+'home/home_avator.png',
  108. time:'早上好',
  109. deviceNum:0,
  110. weatherInfo:{}
  111. }
  112. },
  113. onLoad() {
  114. this.getTime();
  115. this.getWeather();
  116. },
  117. methods:{
  118. getTime(){
  119. let hours = new Date().getHours()+1;
  120. if(hours<=8) this.time = '早上好';
  121. else if(hours<=11) this.time = '上午好';
  122. else if(hours<=13) this.time = '中午好';
  123. else if(hours<=18) this.time = '下午好';
  124. else if(hours<=24) this.time = '晚上好';
  125. },
  126. getWeather(){
  127. uni.request({
  128. url:'http://gfeljm.tianqiapi.com/free/v2030?appid=31449887&appsecret=7F6JCrvB&adcode=340100000000',
  129. success:res=>{
  130. this.weatherInfo = res.data;
  131. this.weatherInfo.humidity = this.weatherInfo.humidity.replace('%','')
  132. }
  133. })
  134. var myAmapFun = new amapFile.AMapWX({key:'f83be04fc5f239edfa9f1201e4bc7c47key'});
  135. myAmapFun.getWeather({
  136. success: function(data) {
  137. console.log(data);
  138. }
  139. })
  140. },
  141. tuTurn(url){
  142. if(!url) return
  143. uni.navigateTo({ url });
  144. }
  145. }
  146. }
  147. </script>
  148. <style scoped lang="less">
  149. .tabPage{
  150. width: 100%;
  151. padding: 0 0 188rpx;
  152. box-sizing: border-box;
  153. background: #F4F8FB;
  154. .topbg{
  155. width: 100%;
  156. position: fixed;
  157. top: 0;
  158. left: 0;
  159. z-index: 0;
  160. }
  161. .header{
  162. width: 100%;
  163. position: relative;
  164. .top{
  165. width: 100%;
  166. padding: 26rpx 40rpx 0;
  167. box-sizing: border-box;
  168. display: flex;
  169. align-items: center;
  170. justify-content: space-between;
  171. .left{
  172. .title{
  173. display: flex;
  174. align-items: center;
  175. text{
  176. font-family: PingFang-SC, PingFang-SC;
  177. font-weight: bold;
  178. font-size: 48rpx;
  179. color: #FFFFFF;
  180. line-height: 48rpx;
  181. text-align: left;
  182. letter-spacing: 2rpx;
  183. margin-right: 20rpx;
  184. }
  185. }
  186. .tip{
  187. font-family: PingFangSC, PingFang SC;
  188. font-weight: 400;
  189. font-size: 24rpx;
  190. color: #FFFFFF;
  191. line-height: 30rpx;
  192. text-align: left;
  193. margin-top: 20rpx;
  194. }
  195. }
  196. .right{
  197. width: 90rpx;
  198. height: 90rpx;
  199. background: #FFFFFF;
  200. padding: 2rpx;
  201. box-sizing: border-box;
  202. border-radius: 50%;
  203. image{
  204. width: 100%;
  205. height: 100%;
  206. border-radius: 50%;
  207. }
  208. }
  209. }
  210. .weather{
  211. width: 100%;
  212. margin-top: 50rpx;
  213. display: flex;
  214. .item{
  215. width: calc(100% / 3);
  216. display: flex;
  217. flex-direction: column;
  218. align-items: center;
  219. position: relative;
  220. &::after{
  221. content: '';
  222. width: 1rpx;
  223. height: 64rpx;
  224. background: #CCCCCC;
  225. position: absolute;
  226. top:10rpx;
  227. right: 0;
  228. }
  229. .text{
  230. font-family: PingFang-SC, PingFang-SC;
  231. font-weight: bold;
  232. font-size: 44rpx;
  233. color: #FFFFFF;
  234. line-height: 44rpx;
  235. span{
  236. font-weight: 400;
  237. font-size: 20rpx;
  238. }
  239. }
  240. p{
  241. font-family: PingFangSC, PingFang SC;
  242. font-weight: 400;
  243. font-size: 24rpx;
  244. color: #FFFFFF;
  245. line-height: 24rpx;
  246. text-align: center;
  247. margin-top: 16rpx;
  248. }
  249. }
  250. }
  251. }
  252. .boxs{
  253. width: calc(100% - 48rpx);
  254. margin: 20rpx 24rpx 0;
  255. display: flex;
  256. justify-content: space-between;
  257. flex-wrap: wrap;
  258. position: relative;
  259. .box{
  260. width: calc(50% - 11rpx);
  261. padding: 36rpx 25rpx 40rpx 22rpx;
  262. box-sizing: border-box;
  263. background: #FFFFFF;
  264. border-radius: 8rpx;
  265. display: flex;
  266. justify-content: space-between;
  267. align-items: flex-end;
  268. margin-top: 20rpx;
  269. .left{
  270. display: flex;
  271. flex-direction: column;
  272. image{
  273. width: 90rpx;
  274. height: 88rpx;
  275. }
  276. text{
  277. font-family: PingFang-SC, PingFang-SC;
  278. font-weight: bold;
  279. font-size: 28rpx;
  280. color: #333333;
  281. line-height: 28rpx;
  282. text-align: left;
  283. margin-top: 24rpx;
  284. padding-left: 2rpx;
  285. }
  286. }
  287. .right{
  288. display: flex;
  289. flex-direction: column;
  290. align-items: center;
  291. .num{
  292. font-family: PingFangSC, PingFang SC;
  293. font-weight: 400;
  294. font-size: 32rpx;
  295. color: #333333;
  296. line-height: 32rpx;
  297. text-align: center;
  298. }
  299. .wz{
  300. font-family: PingFangSC, PingFang SC;
  301. font-weight: 400;
  302. font-size: 24rpx;
  303. color: #999999;
  304. line-height: 24rpx;
  305. text-align: center;
  306. margin-top: 24rpx;
  307. }
  308. }
  309. }
  310. }
  311. }
  312. </style>