chargerecord.vue 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125
  1. <template>
  2. <view class="container">
  3. <view class="list-item">
  4. <view class="item" v-for="item in chargeList">
  5. <view class="item-header">
  6. <view class="item-title">
  7. {{item.deviceId}}
  8. </view>
  9. <view class="item-status">
  10. <uni-tag type="success" style="background: #0E9F9B" text="充电完成" v-if="item.status == 1"></uni-tag>
  11. <uni-tag type="success" text="正在充电" v-if="item.status == 0"></uni-tag>
  12. </view>
  13. </view>
  14. <view class="item-body">
  15. <view class="item-time">充电时间:{{item.createTime}}</view>
  16. <view class="item-time" v-if="item.status == 1">结束时间:{{item.endTime}}</view>
  17. </view>
  18. </view>
  19. <uni-load-more @clickLoadMore="getMore" :content-text="contentText" :status="startText"></uni-load-more>
  20. </view>
  21. </view>
  22. </template>
  23. <script>
  24. import { listCharge } from '@/api/device/chargerecord.js'
  25. import i18 from '@/utils/i18.js'
  26. export default {
  27. data() {
  28. return {
  29. startText:"more",
  30. search:{
  31. pageNum:1,
  32. pageSize:6,
  33. reasonable:true,
  34. },
  35. contentText: {
  36. contentdown: i18('点击查看更多'),
  37. contentrefresh: i18('加载中'),
  38. contentnomore: i18('没有更多'),
  39. },
  40. chargeList: [],
  41. }
  42. },
  43. onShow(){
  44. uni.setNavigationBarTitle({
  45. title: this.$t('page.chargerecord')
  46. })
  47. },
  48. methods: {
  49. i18(text){
  50. return i18(text)
  51. },
  52. getMore(){
  53. this.search.pageNum++;
  54. this.chargeRecord();
  55. },
  56. chargeRecord() {
  57. this.startText = "loading"
  58. listCharge(this.search).then(res=>{
  59. if(res.data.length == 0){
  60. this.$modal.showToast("没有更多数据了");
  61. this.startText = "no-more"
  62. }else{
  63. this.startText = "more"
  64. this.chargeList = this.chargeList.concat(res.data);
  65. }
  66. })
  67. }
  68. },
  69. created() {
  70. this.chargeRecord();
  71. }
  72. }
  73. </script>
  74. <style>
  75. .container {
  76. background: rgb(249, 252, 255);
  77. inset: 0;
  78. position: absolute;
  79. }
  80. .list-item {
  81. margin: 0vw;
  82. }
  83. .item {
  84. box-shadow: 0px 5px 27px 0px rgba(195, 195, 195, 0.4);
  85. border-radius: 4px;
  86. background: #FFFFFF;
  87. margin: 4vw;
  88. padding: 4vw;
  89. }
  90. .item-title {
  91. display: inline-block;
  92. float: left;
  93. }
  94. .item-status {
  95. display: inline-block;
  96. float: right;
  97. }
  98. .item-header {
  99. border-bottom: 1px solid lightgray;
  100. height: 5vh;
  101. }
  102. .item-body {
  103. padding-top: 4vw;
  104. }
  105. .item-time {
  106. color: #545454;
  107. font-size: 12px;
  108. margin-bottom: 4px
  109. }
  110. </style>