site-more.vue 8.0 KB

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