site-more.vue 7.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245
  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" v-if="!isOperation">
  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="operation-price-box" v-else>
  51. <view class="operation-price">
  52. <text class="operation-symbol">¥</text>
  53. <text>1.2099</text>
  54. </view>
  55. <view class="mini-text">元/度</view>
  56. <view class="operation-price-btn">
  57. 企业专享价
  58. </view>
  59. <view class="ordinary-price">{{(item.price).toFixed(4)}}</view>
  60. </view>
  61. <!-- <view class="row">
  62. <view class="name">服务费</view>
  63. <view><text class="value">{{(item.addServicePrice+item.servicePrice).toFixed(4)}}</text><text class="unit">{{item.unit}}</text></view>
  64. </view> -->
  65. </view>
  66. <!-- <view class="footer">
  67. <view>合计充电价</view>
  68. <view>{{item.price.toFixed(4)}} {{item.unit}}</view>
  69. </view> -->
  70. </view>
  71. </view>
  72. </view>
  73. <view id="underside" class="underside">
  74. <view class="scan" @click="sacn()">扫码充电</view>
  75. <ax-ios-indicator min="10"></ax-ios-indicator>
  76. </view>
  77. </ax-body>
  78. </template>
  79. <script>
  80. export default {
  81. onLoad(opts) {
  82. this.another = !Boolean(opts.show);
  83. this.getStationsInfo(opts.stationId);
  84. },
  85. mounted() {
  86. this.$app.act.selectorQuery(this,'#switch,#underside',true).then(res=>{
  87. const s = res.find(i=>i.id=='switch');
  88. const u = res.find(i=>i.id=='underside');
  89. const w = uni.getWindowInfo();
  90. this.listHeight = w.windowHeight - s.top - s.height - u.height;
  91. });
  92. },
  93. data() {
  94. return {
  95. isOperation:false,
  96. another: false,
  97. listHeight: 0,
  98. prices:{
  99. index: 0,
  100. data: []
  101. },
  102. stationInfo : {},
  103. deviceList: [],//该站点桩列表
  104. nowPriceTime: {},//当前费用时段信息
  105. }
  106. },
  107. methods: {
  108. getStationsInfo(stationId){
  109. if(!stationId){
  110. return;
  111. }
  112. this.$api.base("post","/chargeApi/getStationsInfo",{"stationId":stationId},{}).then(res=>{
  113. this.deviceList = res.devices;
  114. this.prices.data = res.prices;
  115. this.nowPriceTime = res.nowPriceTime;
  116. this.stationInfo = res.stationInfo;
  117. //当前的价格时间断的下标
  118. for(var i = 0; i < this.prices.data.length; i++){
  119. if(this.nowPriceTime.id == this.prices.data[i].id){
  120. this.prices.index = i;
  121. break
  122. }
  123. }
  124. })
  125. },
  126. //获取桩状态的数量
  127. getStatusNum(status){
  128. var num = 0;
  129. //设备状态 0:离网1:空闲2:占用(未充电)3:占用(充电中)4:占用(预约锁定)255:故障
  130. for(var i = 0; i < this.deviceList.length; i++){
  131. var device = this.deviceList[i];
  132. if(status == 2){
  133. if(device.deviceStatus == 2 || device.deviceStatus == 3 || device.deviceStatus == 4){
  134. num++;
  135. continue;
  136. }
  137. }
  138. if(device.deviceStatus == status){
  139. num++;
  140. }
  141. }
  142. return num;
  143. },
  144. getSatesObj(item){
  145. //{name:'离线',color:'grey'},{name:'空闲',color:'green'},{name:'占用',color:'blue'}
  146. var obj = {};
  147. if(item.deviceStatus == 2 || item.deviceStatus == 4){
  148. obj = {name:'占用',color:'blue'};
  149. }else if(item.deviceStatus == 3){
  150. obj = {name:'充电中',color:'orange'};
  151. }else if(item.deviceStatus == 0){
  152. obj = {name:'离线',color:'grey'};
  153. }else if(item.deviceStatus == 1){
  154. obj = {name:'空闲',color:'green'};
  155. }else if(item.deviceStatus == 255){
  156. obj = {name:'故障',color:'err'};
  157. }
  158. return obj;
  159. },
  160. //获取充电桩设备类型
  161. getdeviceTypeName(type){
  162. //电类型 1:直流设备;2:交流设备3:交直流一体设备;4:无线设备;5:其他
  163. var str = "";
  164. switch(type){
  165. case "1":
  166. str = "直流设备";
  167. break
  168. case "2":
  169. str = "交流设备";
  170. break
  171. case "3":
  172. str = "交直流一体设备";
  173. break
  174. case "4":
  175. str = "无线设备";
  176. break
  177. case "5":
  178. str = "其他";
  179. break
  180. }
  181. return str;
  182. },
  183. //映射 峰 平 谷
  184. getPriceLable(type){
  185. //时间类型 1 谷 2 平 3 峰
  186. var str = "";
  187. switch (type){
  188. case 1:
  189. str = "谷";
  190. break;
  191. case 2:
  192. str = "平";
  193. break;
  194. case 3:
  195. str = "峰";
  196. break;
  197. }
  198. return str;
  199. },
  200. settitle(title){
  201. uni.setNavigationBarTitle({title});
  202. },
  203. // 跳转充电终端
  204. goTerminal(item){
  205. //设备状态 0:离网1:空闲2:占用(未充电)3:占用(充电中)4:占用(预约锁定)255:故障
  206. if(item.deviceStatus == 0 || item.deviceStatus == 255 ){
  207. return;
  208. }
  209. this.$app.url.goto('/pages/terminal/terminal?deviceId='+item.id+"&deviceStatus="+item.deviceStatus);
  210. },
  211. //扫一扫
  212. sacn(){
  213. this.$app.act.scan().then(res=>{
  214. var paramObj = this.getUrlParams(res.result);
  215. if(!paramObj || !paramObj.connectorCode){
  216. this.$app.popup.alert("二维码不正确。","温馨提示!");
  217. return;
  218. }
  219. this.getDeviceInfo(paramObj.connectorCode);
  220. })
  221. },
  222. getUrlParams(url) {
  223. const paramsRegex = /[?&]+([^=&]+)=([^&]*)/gi;
  224. const params = {};
  225. let match;
  226. while (match = paramsRegex.exec(url)) {
  227. params[match[1]] = match[2];
  228. }
  229. return params;
  230. },
  231. //通过充电桩编码(sn)获取设备详情
  232. getDeviceInfo(sn){
  233. this.$api.base("post","/chargeApi/checkDevicesBySn",{"sn":sn},{}).then(res=>{
  234. console.log("设备信息:",res)
  235. this.goTerminal(res.device);
  236. })
  237. }
  238. }
  239. }
  240. </script>
  241. <style scoped>
  242. @import url("site-more.css");
  243. </style>