site-more.vue 7.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233
  1. <template>
  2. <ax-body>
  3. <image src="@/static/img/page-bg01.png" class="page-background"></image>
  4. <view class="body" :style="{'--list-height':`${listHeight}px`}">
  5. <view class="title">{{stationInfo.name}}</view>
  6. <!-- <view class="subtitle" v-html="stationInfo.parkTips"></view> -->
  7. <view class="subtitle">充电减免2小时停车费,超出时长部分计时收费</view>
  8. <!-- 面包屑 -->
  9. <view class="crumbs">
  10. <view class="item"><view class="value">{{getStatusNum(1)}}</view><view class="name">空闲</view></view>
  11. <view class="item"><view class="value">{{getStatusNum(2)}}</view><view class="name">占用</view></view>
  12. <view class="item"><view class="value">{{getStatusNum(0)}}</view><view class="name">离线</view></view>
  13. </view>
  14. <!-- 数据切换 -->
  15. <view id="switch" class="switch" @click="another = !another" :class="{another}">
  16. <view class="contet">
  17. <view class="text">电站价格</view>
  18. <view class="text">充电终端</view>
  19. </view>
  20. <view class="bg"></view>
  21. </view>
  22. <!-- 终端列表 -->
  23. <view v-if="another" class="terminals list">
  24. <view v-for="(item,index) in deviceList" :key="index" @click="goTerminal(item)" class="terminal-item">
  25. <view class="state" :class="[getSatesObj(item).color]">
  26. <view class="cake">
  27. <image src="@/static/img/site-icon01.svg" class="icon"></image>
  28. <view class="name">{{getSatesObj(item).name}}</view>
  29. </view>
  30. </view>
  31. <view class="info">
  32. <view class="name">{{item.deviceName}}</view>
  33. <view class="subinfo">电类分类:{{getdeviceTypeName(item.eType)}}</view>
  34. <view class="subinfo">终端编号:{{item.deviceNo}}</view>
  35. </view>
  36. </view>
  37. </view>
  38. <!-- 价格列表 -->
  39. <view v-else class="prices list">
  40. <view v-for="(item,index) in prices.data" :key="index" class="price" :class="{active:prices.index==index}">
  41. <view class="header">
  42. <view class="icon">{{getPriceLable(item.timeType)}}</view>
  43. <view class="value">{{item.time}}</view>
  44. </view>
  45. <view class="info">
  46. <view class="row">
  47. <view class="name">抵扣券电价</view>
  48. <view ><text class="value" >{{(item.price).toFixed(4)}}</text><text class="unit" >{{item.unit}}</text></view>
  49. </view>
  50. <!-- <view class="row">
  51. <view class="name">服务费</view>
  52. <view><text class="value">{{(item.addServicePrice+item.servicePrice).toFixed(4)}}</text><text class="unit">{{item.unit}}</text></view>
  53. </view> -->
  54. </view>
  55. <!-- <view class="footer">
  56. <view>合计充电价</view>
  57. <view>{{item.price.toFixed(4)}} {{item.unit}}</view>
  58. </view> -->
  59. </view>
  60. </view>
  61. </view>
  62. <view id="underside" class="underside">
  63. <view class="scan" @click="sacn()">扫码充电</view>
  64. <ax-ios-indicator min="10"></ax-ios-indicator>
  65. </view>
  66. </ax-body>
  67. </template>
  68. <script>
  69. export default {
  70. onLoad(opts) {
  71. this.another = !Boolean(opts.show);
  72. this.getStationsInfo(opts.stationId);
  73. },
  74. mounted() {
  75. this.$app.act.selectorQuery(this,'#switch,#underside',true).then(res=>{
  76. const s = res.find(i=>i.id=='switch');
  77. const u = res.find(i=>i.id=='underside');
  78. const w = uni.getWindowInfo();
  79. this.listHeight = w.windowHeight - s.top - s.height - u.height;
  80. });
  81. },
  82. data() {
  83. return {
  84. another: false,
  85. listHeight: 0,
  86. prices:{
  87. index: 0,
  88. data: []
  89. },
  90. stationInfo : {},
  91. deviceList: [],//该站点桩列表
  92. nowPriceTime: {},//当前费用时段信息
  93. }
  94. },
  95. methods: {
  96. getStationsInfo(stationId){
  97. if(!stationId){
  98. return;
  99. }
  100. this.$api.base("post","/chargeApi/getStationsInfo",{"stationId":stationId},{}).then(res=>{
  101. this.deviceList = res.devices;
  102. this.prices.data = res.prices;
  103. this.nowPriceTime = res.nowPriceTime;
  104. this.stationInfo = res.stationInfo;
  105. //当前的价格时间断的下标
  106. for(var i = 0; i < this.prices.data.length; i++){
  107. if(this.nowPriceTime.id == this.prices.data[i].id){
  108. this.prices.index = i;
  109. break
  110. }
  111. }
  112. })
  113. },
  114. //获取桩状态的数量
  115. getStatusNum(status){
  116. var num = 0;
  117. //设备状态 0:离网1:空闲2:占用(未充电)3:占用(充电中)4:占用(预约锁定)255:故障
  118. for(var i = 0; i < this.deviceList.length; i++){
  119. var device = this.deviceList[i];
  120. if(status == 2){
  121. if(device.deviceStatus == 2 || device.deviceStatus == 3 || device.deviceStatus == 4){
  122. num++;
  123. continue;
  124. }
  125. }
  126. if(device.deviceStatus == status){
  127. num++;
  128. }
  129. }
  130. return num;
  131. },
  132. getSatesObj(item){
  133. //{name:'离线',color:'grey'},{name:'空闲',color:'green'},{name:'占用',color:'blue'}
  134. var obj = {};
  135. if(item.deviceStatus == 2 || item.deviceStatus == 4){
  136. obj = {name:'占用',color:'blue'};
  137. }else if(item.deviceStatus == 3){
  138. obj = {name:'充电中',color:'orange'};
  139. }else if(item.deviceStatus == 0){
  140. obj = {name:'离线',color:'grey'};
  141. }else if(item.deviceStatus == 1){
  142. obj = {name:'空闲',color:'green'};
  143. }else if(item.deviceStatus == 255){
  144. obj = {name:'故障',color:'err'};
  145. }
  146. return obj;
  147. },
  148. //获取充电桩设备类型
  149. getdeviceTypeName(type){
  150. //电类型 1:直流设备;2:交流设备3:交直流一体设备;4:无线设备;5:其他
  151. var str = "";
  152. switch(type){
  153. case "1":
  154. str = "直流设备";
  155. break
  156. case "2":
  157. str = "交流设备";
  158. break
  159. case "3":
  160. str = "交直流一体设备";
  161. break
  162. case "4":
  163. str = "无线设备";
  164. break
  165. case "5":
  166. str = "其他";
  167. break
  168. }
  169. return str;
  170. },
  171. //映射 峰 平 谷
  172. getPriceLable(type){
  173. //时间类型 1 谷 2 平 3 峰
  174. var str = "";
  175. switch (type){
  176. case 1:
  177. str = "谷";
  178. break;
  179. case 2:
  180. str = "平";
  181. break;
  182. case 3:
  183. str = "峰";
  184. break;
  185. }
  186. return str;
  187. },
  188. settitle(title){
  189. uni.setNavigationBarTitle({title});
  190. },
  191. // 跳转充电终端
  192. goTerminal(item){
  193. //设备状态 0:离网1:空闲2:占用(未充电)3:占用(充电中)4:占用(预约锁定)255:故障
  194. if(item.deviceStatus == 0 || item.deviceStatus == 255 ){
  195. return;
  196. }
  197. this.$app.url.goto('/pages/terminal/terminal?deviceId='+item.id+"&deviceStatus="+item.deviceStatus);
  198. },
  199. //扫一扫
  200. sacn(){
  201. this.$app.act.scan().then(res=>{
  202. var paramObj = this.getUrlParams(res.result);
  203. if(!paramObj || !paramObj.connectorCode){
  204. this.$app.popup.alert("二维码不正确。","温馨提示!");
  205. return;
  206. }
  207. this.getDeviceInfo(paramObj.connectorCode);
  208. })
  209. },
  210. getUrlParams(url) {
  211. const paramsRegex = /[?&]+([^=&]+)=([^&]*)/gi;
  212. const params = {};
  213. let match;
  214. while (match = paramsRegex.exec(url)) {
  215. params[match[1]] = match[2];
  216. }
  217. return params;
  218. },
  219. //通过充电桩编码(sn)获取设备详情
  220. getDeviceInfo(sn){
  221. this.$api.base("post","/chargeApi/checkDevicesBySn",{"sn":sn},{}).then(res=>{
  222. console.log("设备信息:",res)
  223. this.goTerminal(res.device);
  224. })
  225. }
  226. }
  227. }
  228. </script>
  229. <style scoped>
  230. @import url("site-more.css");
  231. </style>