switchCharge.vue 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148
  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. if(this.select){
  69. }else{
  70. uni.showToast({
  71. title:'链接超时,请重新扫码'
  72. })
  73. return
  74. }
  75. var data={
  76. deviceId:this.select
  77. };
  78. API.chargingDeviceData(data).then((res) => {
  79. this.list=[
  80. ...this.list,
  81. ...res.data.data
  82. ];
  83. this.recordsTotal=res.data.recordsTotal
  84. uni.hideLoading()
  85. }).catch(error => {
  86. uni.showToast({
  87. title:error
  88. })
  89. })
  90. }
  91. },onReady(){
  92. this.getList()
  93. },
  94. }
  95. </script>
  96. <style>
  97. page{
  98. background-color: #f7f7f7;
  99. }
  100. </style>
  101. <style lang="scss" scoped>
  102. .slot-wrap {
  103. display: flex;
  104. align-items: center;
  105. justify-content: space-between;
  106. flex: 1;
  107. }
  108. .navbar-right {
  109. display: flex;
  110. margin-right: 20rpx;
  111. align-items: center;
  112. color:#1677ff;
  113. }
  114. .chargeList-item{
  115. background-color: #fff;
  116. padding: 15px;
  117. margin: 10px;
  118. border-radius: 10px;
  119. .chargeList-item-row{
  120. display: flex;
  121. align-items: center;
  122. margin-bottom: 10px;
  123. &:last-child{
  124. margin-bottom: 0;
  125. }
  126. p{
  127. color:#999;
  128. margin: 0 10px;
  129. }
  130. }
  131. }
  132. .chargeList-item.active{
  133. border: 1px solid #1677ff;
  134. }
  135. </style>