batteryDetail.vue 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. <template>
  2. <view class="battery-detail-main">
  3. <navBar :name="$t('电池信息')" bgColor="#CFD1DE"></navBar>
  4. <view class=" quantity-count">{{electricQuantity || 0}}<text class="quantity-text">%</text></view>
  5. <view v-for="(item,index) of list" :key="index" class="battery-list-view">
  6. <view class="battery-list flex-row flex-between">
  7. <view class="battery-name">No.{{index + 1}}{{ $t('电池') }}</view>
  8. <view class="battery-id">MAC ID:{{item.battery_sn}}</view>
  9. </view>
  10. <view class="flex-row flex-around">
  11. <view class="battery-device-info">
  12. <view class="quantity-info">{{item.electric_quantity || 0}} <text class="quantity-text-1">%</text></view>
  13. <view class="battery-info-text">{{ $t('剩余电量') }}</view>
  14. </view>
  15. <view class="battery-device-info">
  16. <view class="quantity-info">{{(item.voltage).toFixed(2) || 0}}<text class="quantity-text-1"></text></view>
  17. <view class="battery-info-text">{{ $t('电压') }}</view>
  18. </view>
  19. <view class="battery-device-info">
  20. <view class="quantity-info">{{item.battery_temp[0] || 0}} <text class="quantity-text-1">℃</text></view>
  21. <view class="battery-info-text">{{ $t('温度') }}</view>
  22. </view>
  23. </view>
  24. </view>
  25. </view>
  26. </template>
  27. <script>
  28. const http = require('../../common/request.js');
  29. const config = require('../../common/config_gyq.js');
  30. export default {
  31. data() {
  32. return {
  33. electricQuantity:0,
  34. car_sn:'',
  35. list:[]
  36. };
  37. }
  38. /**
  39. * 生命周期函数--监听页面加载
  40. */
  41. ,
  42. onLoad: function(options) {
  43. this.car_sn = uni.getStorageSync('car_info').car_sn || '';
  44. this.batteryListFn()
  45. },
  46. methods: {
  47. async batteryListFn(){
  48. let {data} = await http.postApi(config.API_CAR_BATTERY_LIST,{car_sn:this.car_sn})
  49. let electric_quantity = 0
  50. data.data.list.map(item=>{
  51. electric_quantity += Number(item.electric_quantity)
  52. })
  53. console.log((electric_quantity / data.data.list.length).toFixed(0))
  54. this.electricQuantity = (electric_quantity / data.data.list.length).toFixed(0) || 0
  55. this.electricQuantity = this.electricQuantity != 'NaN' ? this.electricQuantity : 0
  56. this.list = data.data.list
  57. }
  58. }
  59. };
  60. </script>
  61. <style>
  62. @import './batteryDetail.css';
  63. </style>