site-more.vue 7.7 KB

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