switchCharge.vue 3.1 KB

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