index.vue 1.2 KB

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