index.vue 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485
  1. <template>
  2. <view>
  3. <view class="cell-infos ddflex">
  4. <view class="cell">
  5. <view :style="'transform: rotate('+rotate+'deg);'">
  6. <image :style="'width: '+width+'rpx;height:'+height+'rpx;'" src="../../static/pages/images/cell.png" class="cell-bg"></image>
  7. <view class="cell-q">
  8. <view :class="'cell-qs'+(soc>50?' full':'')" :style="'height:'+ soc+'%'"></view>
  9. </view>
  10. </view>
  11. <view class="soc-label" v-if="showsoc">
  12. {{soc}}%
  13. </view>
  14. </view>
  15. </view>
  16. </view>
  17. </template>
  18. <script>
  19. const app = getApp();
  20. const req = require("../../utils/request.js");
  21. export default {
  22. components: {},
  23. props: {
  24. soc:{
  25. type:Number,
  26. default:0
  27. },
  28. width:{
  29. type:Number,
  30. default:68
  31. },
  32. height:{
  33. type:Number,
  34. default:132
  35. },
  36. showsoc:{
  37. type:Boolean,
  38. default:false
  39. },
  40. rotate:{
  41. type:Number,
  42. default:0
  43. }
  44. },
  45. data() {
  46. return {
  47. systems: {},
  48. isTop: 0,
  49. }
  50. },
  51. onLoad(options) {
  52. },
  53. onShow() {
  54. },
  55. methods: {
  56. },
  57. mounted() {
  58. const systemInfo = uni.getSystemInfoSync();
  59. // px转换到rpx的比例
  60. let pxToRpxScale = 750 / systemInfo.windowWidth;
  61. let systems = {
  62. ktxStatusHeight: systemInfo.statusBarHeight * pxToRpxScale, // 状态栏的高度
  63. navigationHeight: 44 * pxToRpxScale // 导航栏的高度
  64. };
  65. systems.barHeight = systems.ktxStatusHeight + systems.navigationHeight;
  66. this.systems = systems;
  67. },
  68. onPageScroll: function(e) {
  69. if (e.scrollTop > this.systems.barHeight) {
  70. this.isTop = 1;
  71. } else {
  72. this.isTop = 0;
  73. }
  74. }
  75. }
  76. </script>
  77. <style>
  78. @import "./index.css";
  79. </style>