switchCharge.vue 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141
  1. <template>
  2. <view>
  3. <u-navbar title="切换充电桩"
  4. :autoBack="false"
  5. :custom-back="selectBtn">
  6. <view class="slot-wrap">
  7. <view class="navbar-left"></view>
  8. <view class="navbar-right" @click="selectBtn"><span>确定</span></view>
  9. </view>
  10. </u-navbar>
  11. <view class="chargeList">
  12. <template v-for="(item,i) in list">
  13. <view class="chargeList-item "
  14. @click="select=item.id"
  15. :class="{
  16. 'active':item.id==select,
  17. }"
  18. :key="i">
  19. <view class="chargeList-item-row">
  20. <u-icon name="qichexiangguan-chongdianzhan" custom-prefix="custom-icon" color="#1677ff" size="40"></u-icon>
  21. <p>名称</p>
  22. <span>{{item.name}}</span>
  23. </view>
  24. <view class="chargeList-item-row">
  25. <u-icon name="shoujichongdian" custom-prefix="custom-icon" color="#1677ff" size="40"></u-icon>
  26. <p>空闲</p>
  27. <span>{{item.availableNumOfChannel}}</span>
  28. </view>
  29. <!-- <view class="chargeList-item-row">
  30. <u-icon name="juli" custom-prefix="custom-icon" color="#1677ff" size="40"></u-icon>
  31. <p>距离</p>
  32. <span>荆鹏软件园1号充电桩</span>
  33. </view>
  34. <view class="chargeList-item-row">
  35. <u-icon name="dizhi" custom-prefix="custom-icon" color="#1677ff" size="40"></u-icon>
  36. <p>地址</p>
  37. <span>荆鹏软件园1号充电桩</span>
  38. </view> -->
  39. </view>
  40. </template>
  41. </view>
  42. </view>
  43. </template>
  44. <script>
  45. import * as API from '@/apis/index.js'
  46. export default {
  47. data() {
  48. return {
  49. list:[
  50. ],
  51. select:'',
  52. }
  53. },
  54. onLoad(op) {
  55. this.select=op.id;
  56. },
  57. methods: {
  58. selectBtn(){
  59. //uni.navigateBack()
  60. uni.redirectTo({
  61. url:'/pages/charge/index?id='+this.select
  62. })
  63. },
  64. getList(){
  65. uni.showLoading({
  66. title:"加载中",mask:true,
  67. })
  68. var data={
  69. };
  70. API.chargingDeviceData(data).then((res) => {
  71. this.list=[
  72. ...this.list,
  73. ...res.data.data
  74. ];
  75. this.recordsTotal=res.data.recordsTotal
  76. uni.hideLoading()
  77. }).catch(error => {
  78. uni.showToast({
  79. title:error
  80. })
  81. })
  82. }
  83. },onReady(){
  84. this.getList()
  85. },
  86. }
  87. </script>
  88. <style>
  89. page{
  90. background-color: #f7f7f7;
  91. }
  92. </style>
  93. <style lang="scss" scoped>
  94. .slot-wrap {
  95. display: flex;
  96. align-items: center;
  97. justify-content: space-between;
  98. flex: 1;
  99. }
  100. .navbar-right {
  101. display: flex;
  102. margin-right: 20rpx;
  103. align-items: center;
  104. color:#1677ff;
  105. }
  106. .chargeList-item{
  107. background-color: #fff;
  108. padding: 15px;
  109. margin: 10px;
  110. border-radius: 10px;
  111. .chargeList-item-row{
  112. display: flex;
  113. align-items: center;
  114. margin-bottom: 10px;
  115. &:last-child{
  116. margin-bottom: 0;
  117. }
  118. p{
  119. color:#999;
  120. margin: 0 10px;
  121. }
  122. }
  123. }
  124. .chargeList-item.active{
  125. border: 1px solid #1677ff;
  126. }
  127. </style>