deviceList.vue 5.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268
  1. <template>
  2. <view>
  3. <u-navbar title="我的设备"></u-navbar>
  4. <view class="deviceDropdown">
  5. <u-dropdown>
  6. <u-dropdown-item v-model="value1" @change="change1" title="充电桩类型" :options="options1"></u-dropdown-item>
  7. <u-dropdown-item v-model="value2" @change="change2" title="所属站点" :options="options2"></u-dropdown-item>
  8. <u-dropdown-item v-model="value3" @change="change3" title="运行状态" :options="options3"></u-dropdown-item>
  9. </u-dropdown>
  10. </view>
  11. <view class="deviceList"
  12. >
  13. <view style="text-align: center;margin-top: 100px" v-if="!list.length">
  14. <img src="@/assets/img/blankpage.png">
  15. <view>查询为空</view>
  16. </view>
  17. <view v-for="(item ,index) in list" :key="item.id"
  18. @click="gotoUrl('pagesFinance/user/deviceDetails?id='+item.id)"
  19. :class="{
  20. 'deviceList-bg1':item.type==1,
  21. 'deviceList-bg2':item.type==2,
  22. 'deviceList-bg3':item.type==0
  23. }"
  24. class="deviceList-item " >
  25. <view class="deviceList-head">{{item.name}}</view>
  26. <view class="deviceList-main">{{item.deviceNo}}</view>
  27. <view class="deviceList-foot">
  28. <view class="deviceList-label">{{ options0[item.type].label}}</view>
  29. <view class="deviceList-label"
  30. :style="item.online?'':'color:red'"
  31. >{{item.online?'在线':'离线'}}</view>
  32. <view class="deviceList-label">{{item.roleName}}</view>
  33. </view>
  34. </view>
  35. <u-divider v-if="list.length == recordsTotal" color="#B6BDC3" style="margin-top:20px;" bg-color="#f4f0f0">已经到底了</u-divider>
  36. <!-- <view class="deviceList-item deviceList-bg2">
  37. <view class="deviceList-head">荆鹏软件园充电站</view>
  38. <view class="deviceList-main">A0001</view>
  39. <view class="deviceList-foot">
  40. <view class="deviceList-label">直流快充</view>
  41. <view class="deviceList-label">正常运行</view>
  42. <view class="deviceList-label">市场服务 70%</view>
  43. </view>
  44. </view>
  45. <view class="deviceList-item deviceList-bg3">
  46. <view class="deviceList-head">荆鹏软件园充电站</view>
  47. <view class="deviceList-main">A0001</view>
  48. <view class="deviceList-foot">
  49. <view class="deviceList-label">直流快充</view>
  50. <view class="deviceList-label">正常运行</view>
  51. <view class="deviceList-label">市场服务 70%</view>
  52. </view>
  53. </view> -->
  54. </view>
  55. </view>
  56. </template>
  57. <script>
  58. import * as API from '@/apis/finance.js'
  59. export default {
  60. data() {
  61. return {
  62. form: {
  63. },
  64. startDate:'',
  65. endDate:'',
  66. pageIndex: 1,
  67. recordsTotal: 0,
  68. list: [],
  69. value1: -1,
  70. value2: -1,
  71. value3: -1,
  72. stationList:[],
  73. options0: [
  74. {
  75. label: '全部',
  76. value: -1,
  77. },
  78. {
  79. label: '自行车充电',
  80. value: 0,
  81. },
  82. {
  83. label: '交流慢充',
  84. value: 2,
  85. },
  86. {
  87. label: '直流快充',
  88. value: 1,
  89. }
  90. ],
  91. options1: [{
  92. label: '全部',
  93. value: '-1',
  94. },
  95. {
  96. label: '自行车充电',
  97. value: 0,
  98. },
  99. {
  100. label: '交流慢充',
  101. value: 2,
  102. },
  103. {
  104. label: '直流快充',
  105. value: 1,
  106. }
  107. ],
  108. options2: [
  109. ],
  110. options3: [
  111. {
  112. label: '全部',
  113. value: -1,
  114. },
  115. {
  116. label: '在线',
  117. value: 1,
  118. },
  119. {
  120. label: '离线',
  121. value: 0,
  122. },
  123. ],
  124. }
  125. },
  126. onReachBottom() {
  127. if (this.list.length < this.recordsTotal) {
  128. this.myLoadmore();
  129. }
  130. },
  131. methods: {
  132. change1(e){
  133. this.form.type=e
  134. if(e==-1){
  135. this.form.type=""
  136. }
  137. this.getList(true)
  138. },
  139. change2(e){
  140. this.form.stationId=e
  141. if(e==-1){
  142. this.form.stationId=""
  143. }
  144. this.getList(true)
  145. },
  146. change3(e){
  147. this.form.onlineStatus=e
  148. if(e==-1){
  149. this.form.onlineStatus=""
  150. }
  151. this.getList(true)
  152. },
  153. getStation() {
  154. API.stationList().then((res) => {
  155. this.options2.push({
  156. label: '全部',
  157. value:-1,
  158. })
  159. this.stationList = res.data.stationList
  160. this.stationList.forEach(item=>{
  161. this.options2.push({
  162. label: item.name,
  163. value: item.id,
  164. })
  165. })
  166. }).catch(error => {
  167. uni.showToast({
  168. title: error
  169. })
  170. })
  171. },
  172. myLoadmore() {
  173. this.pageIndex += 1;
  174. this.getList()
  175. },
  176. getList(bl) {
  177. uni.showLoading({
  178. title: "加载中",
  179. mask: true,
  180. })
  181. if (bl) {
  182. this.list = [];
  183. this.pageIndex = 1;
  184. }
  185. this.form.pageIndex= this.pageIndex
  186. API.devicesList(this.form).then((res) => {
  187. this.list = [
  188. ...this.list,
  189. ...res.data.data
  190. ];
  191. this.recordsTotal = res.data.recordsTotal
  192. uni.hideLoading()
  193. }).catch(error => {
  194. uni.showToast({
  195. title: error
  196. })
  197. })
  198. },
  199. onReady() {
  200. this.getStation()
  201. this.getList()
  202. }
  203. }
  204. }
  205. </script>
  206. <style>
  207. page{
  208. background-color: #F7F7F7;
  209. }
  210. </style>
  211. <style lang="scss" scoped>
  212. .deviceDropdown{
  213. background-color: #fff;
  214. }
  215. .deviceList-item{
  216. margin: 16px;
  217. border-radius: 8px;
  218. .deviceList-head{
  219. font-size: 16px;
  220. padding: 8px 16px;
  221. }
  222. .deviceList-main{
  223. font-size: 28px;
  224. padding: 0px 16px;
  225. font-weight: bold;
  226. }
  227. .deviceList-foot{
  228. display: flex;
  229. align-items: center;
  230. flex-wrap: wrap;
  231. padding: 16px;
  232. .deviceList-label{
  233. background-color: #F0F2F4 ;
  234. padding: 4px 10px;
  235. margin-right: 8px;
  236. border-radius: 4px;
  237. }
  238. }
  239. }
  240. .deviceList-bg1{
  241. background:url(../../assets/img/charging_type_fast.png) no-repeat #fff;
  242. background-size:100%;
  243. }
  244. .deviceList-bg2{
  245. background:url(../../assets/img/charging_type_slow.png) no-repeat #fff;
  246. background-size:100%;
  247. }
  248. .deviceList-bg3{
  249. background:url(../../assets/img/charging_type_bike.png) no-repeat #fff;
  250. background-size:100%;
  251. }
  252. </style>