index.vue 4.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209
  1. <template>
  2. <view class="listbox" :style="colorStyle">
  3. <view class="item" v-for="(item,ind) in list">
  4. <view class="acea-row">
  5. <image class="img" src="../static/cart.png" mode="scaleToFill"></image>
  6. <view class="title line2">
  7. {{item.machine_name}}
  8. </view>
  9. </view>
  10. <view class="machine ">
  11. <view class="acea-row row-between">
  12. <view class="it">
  13. 当前位置:{{item.address?item.address:'未定位'}}
  14. </view>
  15. <view class="status">
  16. 电量:{{item.residue}}%
  17. </view>
  18. </view>
  19. </view>
  20. <view class="machine acea-row row-between-wrapper">
  21. <view class="acea-row row-left">
  22. <view class="it">
  23. 编号:
  24. </view>
  25. <view class="code">
  26. {{item.machine_no}}
  27. </view>
  28. </view>
  29. <view class="acea-row row-rightss" v-if="item.plate_number">
  30. <view class="it">
  31. 车牌号:
  32. </view>
  33. <view class="code">
  34. {{item.plate_number}}
  35. </view>
  36. </view>
  37. </view>
  38. <view v-if="item.status==0" class="text_red tip ">
  39. 关锁
  40. </view>
  41. <view v-if="item.status==1" class="text_blue tip">
  42. 开锁
  43. </view>
  44. <view v-if="item.status==2" class="text_greed tip">
  45. 解锁
  46. </view>
  47. </view>
  48. <view class="loadingicon acea-row row-center-wrapper font-color-white" v-if="list.length > 0">
  49. <text class="loading iconfont icon-jiazai " :hidden="loading == false"></text>
  50. {{ loadTitle }}
  51. </view>
  52. <view v-if="list.length == 0">
  53. <emptyPage v-if="!loading" :title="$t(`暂无车辆`)"></emptyPage>
  54. <view class="loadingicon acea-row row-center-wrapper">
  55. <text class="loading iconfont icon-jiazai" :hidden="loading == false"></text>
  56. </view>
  57. </view>
  58. </view>
  59. </template>
  60. <script>
  61. import {
  62. toLogin
  63. } from '@/libs/login.js';
  64. import {
  65. getMyCar,
  66. } from '@/api/rent.js';
  67. import {
  68. mapGetters
  69. } from "vuex";
  70. import colors from '@/mixins/color.js';
  71. import emptyPage from '@/components/emptyPage.vue';
  72. export default {
  73. mixins: [colors],
  74. components: {
  75. emptyPage,
  76. },
  77. data() {
  78. return {
  79. loading: false, //是否加载中
  80. loadend: false, //是否加载完毕
  81. loadTitle: this.$t(`加载更多`), //提示语
  82. list: [],
  83. page: 1,
  84. limit: 20,
  85. };
  86. },
  87. computed: mapGetters(['isLogin']),
  88. watch: {
  89. isLogin: {
  90. handler: function(newV, oldV) {
  91. if (newV) {
  92. this.getList();
  93. }
  94. },
  95. deep: true
  96. }
  97. },
  98. onLoad(options) {
  99. this.id = options.id
  100. if (this.isLogin) {
  101. this.getList();
  102. } else {
  103. toLogin();
  104. }
  105. },
  106. methods: {
  107. getList: function() {
  108. let that = this;
  109. if (that.loadend) return;
  110. if (that.loading) return;
  111. that.loading = true;
  112. that.loadTitle = that.$t(`加载更多`);
  113. getMyCar({
  114. page: that.page,
  115. limit: that.limit
  116. })
  117. .then(res => {
  118. let list = res.data || [];
  119. let loadend = list.length < that.limit;
  120. that.list = that.$util.SplitArray(list, that.list);
  121. that.$set(that, 'list', that.list);
  122. that.loadend = loadend;
  123. that.loading = false;
  124. that.loadTitle = loadend ? that.$t(`没有更多内容啦~`) : that.$t(`加载更多`);
  125. that.page = that.page + 1;
  126. console.log(that.list);
  127. })
  128. .catch(err => {
  129. that.loading = false;
  130. that.loadTitle = that.$t(`加载更多`);
  131. });
  132. },
  133. },
  134. onReachBottom: function() {
  135. this.getList();
  136. },
  137. // 滚动监听
  138. onPageScroll(e) {
  139. // 传入scrollTop值并触发所有easy-loadimage组件下的滚动监听事件
  140. uni.$emit('scroll');
  141. },
  142. }
  143. </script>
  144. <style scoped lang="scss">
  145. .item {
  146. position: relative;
  147. background-color: var(--view-theme-16);
  148. padding: 30rpx;
  149. border-radius: 10rpx;
  150. margin-bottom: 20rpx;
  151. overflow: hidden;
  152. .title {
  153. font-weight: bold;
  154. font-size: $uni-font-size-lg;
  155. color: #fff;
  156. padding-left: 10rpx;
  157. }
  158. .machine {
  159. font-size: $uni-font-size-sm;
  160. color: #999999;
  161. margin-top: 20rpx;
  162. .code {
  163. color: var(--view-priceColor);
  164. background-color: rgba(#75EFFA, 0.2);
  165. padding: 5rpx 10rpx;
  166. border-radius: 10rpx;
  167. }
  168. }
  169. .img {
  170. width: 40rpx;
  171. height: 40rpx;
  172. }
  173. .tip {
  174. position: absolute;
  175. top: 0;
  176. right: 0;
  177. padding: 5rpx 20rpx;
  178. font-size: 20rpx;
  179. border-bottom-left-radius: 10rpx;
  180. &.text_greed {
  181. color: #49D8A8;
  182. background-color: rgba(#49D8A8, 0.2);
  183. }
  184. &.text_red {
  185. color: rgba(254, 92, 45, 1);
  186. background-color: rgba(rgba(254, 92, 45, 1), 0.2);
  187. }
  188. &.text_blue {
  189. color: #1db0fc;
  190. background-color: rgba(#1db0fc, 0.2);
  191. }
  192. }
  193. }
  194. .listbox {
  195. padding: 30rpx;
  196. min-height: 100vh;
  197. background-color: var(--view-theme);
  198. }
  199. </style>