yiJianShengDian.vue 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980
  1. <template>
  2. <view class="content">
  3. <view class="box1">
  4. <view class="text-24 mgb-20">
  5. 剩余电量
  6. </view>
  7. <view class="text-52 text-2283ee">
  8. {{ powerNum }}%
  9. </view>
  10. <view class="mgt-16 text-20 text-666">
  11. 预计可用3小时0分钟
  12. </view>
  13. <view class="btn cursor" @click="savePower">
  14. 立即省电 ▶
  15. </view>
  16. </view>
  17. <view class="box2">
  18. <view class="title">能耗分析</view>
  19. <view class="statistics">
  20. </view>
  21. </view>
  22. </view>
  23. </template>
  24. <script setup>
  25. import { ref, onMounted } from "vue";
  26. import { onShow } from "@dcloudio/uni-app";
  27. const powerNum = ref(90)
  28. uni.getBatteryInfo({
  29. success: (res) => {
  30. powerNum.value = res.level
  31. },
  32. fail:(err)=>{
  33. console.log('err',err)
  34. }
  35. })
  36. // 立即省电
  37. const savePower = ()=>{
  38. }
  39. // onShow(()=>{
  40. // })
  41. </script>
  42. <style lang="scss" scoped>
  43. .content{
  44. height: 100vh;
  45. background: linear-gradient(to bottom, #a9d4ff, #cce6ff);
  46. padding: 28rpx;
  47. .box1{
  48. width: 100%;
  49. height: 300rpx;
  50. padding: 40rpx 30rpx 10rpx;
  51. border-radius: 30rpx;
  52. background: url('/static/image/index_banner.jpg') no-repeat;
  53. background-size: cover;
  54. position: relative;
  55. .btn{
  56. position: absolute;
  57. transform: translate(30%,0%);
  58. bottom: 10rpx;
  59. width: 400rpx;
  60. height: 68rpx;
  61. line-height: 68rpx;
  62. border-radius: 60rpx;
  63. text-align: center;
  64. color: #fff;
  65. background: linear-gradient(90deg, #03fedf, #2ed9fb);
  66. }
  67. }
  68. .box2{
  69. background-color: rgba(255,255,255,.6);
  70. margin-top: 40rpx;
  71. height: 500rpx;
  72. border-radius: 30rpx;
  73. }
  74. }
  75. </style>