site-more.vue 6.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224
  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.stationName }}</view>
  8. <!-- <view class="subtitle" v-html="stationInfo.parkTips"></view> -->
  9. <view class="subtitle">{{ stationInfo.tips || '' }}</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">
  16. <view class="value">{{ stationInfo.idleCount }}</view>
  17. <view class="name">空闲</view>
  18. </view>
  19. <view class="item">
  20. <view class="value">{{ stationInfo.occupiedCount }}</view>
  21. <view class="name">占用</view>
  22. </view>
  23. <view class="item">
  24. <view class="value">{{ stationInfo.offlineCount }}</view>
  25. <view class="name">离线</view>
  26. </view>
  27. </view>
  28. <!-- 数据切换 -->
  29. <view id="switch" class="switch" @click="another = !another" :class="{ another }">
  30. <view class="contet">
  31. <view class="text">电站价格</view>
  32. <view class="text">充电终端</view>
  33. </view>
  34. <view class="bg"></view>
  35. </view>
  36. <!-- 终端列表 -->
  37. <view v-if="another" class="terminals list">
  38. <view v-for="(item, index) in stationInfo.connectorList" :key="index" @click="goTerminal(item)"
  39. class="terminal-item">
  40. <view class="state" :class="[getSatesObj(item).color]">
  41. <view class="cake">
  42. <image src="@/static/img/site-icon01.svg" class="icon"></image>
  43. <view class="name">{{ formatStatusName(item.statusName) }}</view>
  44. </view>
  45. </view>
  46. <view class="info">
  47. <view class="name">{{ item.deviceName }}</view>
  48. <view class="subinfo">电类分类:{{ item.equipmentType }}</view>
  49. <view class="subinfo">终端编号:{{ item.connectorCode }}</view>
  50. </view>
  51. </view>
  52. </view>
  53. <!-- 价格列表 -->
  54. <view v-else class="prices list">
  55. <view v-for="(item, index) in prices.data.priceList" :key="index" class="price"
  56. :class="{ active: item.currentPeriod }">
  57. <view class="header">
  58. <view class="icon">{{ item.periodFlagName }}</view>
  59. <view class="value">{{ item.timePeriod }}</view>
  60. </view>
  61. <view class="info">
  62. <!-- v-if="user_info.firmId===null" -->
  63. <view class="row" v-if="!prices.data.hasEnterprisePrice">
  64. <view class="name">抵扣券电价</view>
  65. <view><text class="value">{{ item.totalPrice }}</text><text class="unit">元/度</text></view>
  66. </view>
  67. <view class="operation-price-box" v-else>
  68. <view class="operation-price">
  69. <text class="operation-symbol">¥</text>
  70. <text>{{ item.enterprisePrice }}</text>
  71. </view>
  72. <view class="mini-text">元/度</view>
  73. <view class="operation-price-btn">
  74. 企业专享价
  75. </view>
  76. <view class="ordinary-price">{{ item.elecPrice }}</view>
  77. </view>
  78. <!-- <view class="row">
  79. <view class="name">服务费</view>
  80. <view><text class="value">{{(item.addServicePrice+item.servicePrice).toFixed(4)}}</text><text class="unit">{{item.unit}}</text></view>
  81. </view> -->
  82. </view>
  83. <!-- <view class="footer">
  84. <view>合计充电价</view>
  85. <view>{{item.price.toFixed(4)}} {{item.unit}}</view>
  86. </view> -->
  87. </view>
  88. </view>
  89. </view>
  90. <view id="underside" class="underside">
  91. <view class="scan" @click="sacn()">扫码充电</view>
  92. <ax-ios-indicator min="10"></ax-ios-indicator>
  93. </view>
  94. </ax-body>
  95. </template>
  96. <script>
  97. export default {
  98. onLoad(opts) {
  99. this.another = !Boolean(opts.show);
  100. this.getStationsInfo(opts.stationId);
  101. this.getStationPriceList(opts.stationId);
  102. },
  103. mounted() {
  104. this.$app.act.selectorQuery(this, '#switch,#underside', true).then(res => {
  105. const s = res.find(i => i.id == 'switch');
  106. const u = res.find(i => i.id == 'underside');
  107. const w = uni.getWindowInfo();
  108. this.listHeight = w.windowHeight - s.top - s.height - u.height;
  109. });
  110. },
  111. data() {
  112. return {
  113. user_info: this.$app.storage.get('USER_INFO'),
  114. another: false,
  115. listHeight: 0,
  116. prices: {
  117. index: 0,
  118. data: []
  119. },
  120. stationInfo: {},
  121. deviceList: [],//该站点桩列表
  122. nowPriceTime: {},//当前费用时段信息
  123. }
  124. },
  125. methods: {
  126. getStationsInfo(stationId) {
  127. if (!stationId) {
  128. return;
  129. }
  130. // 终端列表
  131. this.$api.base("get", "/applet/v1/station/connectors", { "stationId": stationId }, {}).then(res => {
  132. this.stationInfo = res.data;
  133. })
  134. },
  135. // 价格列表
  136. getStationPriceList(stationId) {
  137. this.$api.base("get", "/applet/v1/station/prices", { "stationId": stationId }, {}).then(res => {
  138. this.prices.data = res.data;
  139. })
  140. },
  141. formatStatusName(statusName) {
  142. // 去掉括号及括号内的内容
  143. return statusName.replace(/\([^)]*\)/g, '');
  144. },
  145. getSatesObj(item) {
  146. // 状态:0-离网 1-空闲 2-占用(未充电) 3-占用(充电中) 4-占用(预约锁定) 255-故障
  147. var obj = {};
  148. if (item.status == 2 || item.status == 4 || item.status == 3) {
  149. obj = { color: 'blue' };
  150. } else if (item.status == 3) {
  151. obj = { color: 'orange' };
  152. } else if (item.status == 0) {
  153. obj = { color: 'grey' };
  154. } else if (item.status == 1) {
  155. obj = { color: 'green' };
  156. } else if (item.status == 255) {
  157. obj = { color: 'err' };
  158. }
  159. return obj;
  160. },
  161. //映射 峰 平 谷
  162. getPriceLable(type) {
  163. //时间类型 1 谷 2 平 3 峰
  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. }
  176. return str;
  177. },
  178. settitle(title) {
  179. uni.setNavigationBarTitle({ title });
  180. },
  181. // 跳转充电终端
  182. goTerminal(item) {
  183. //设备状态 0:离网1:空闲2:占用(未充电)3:占用(充电中)4:占用(预约锁定)255:故障
  184. if (item.status == 0 || item.status == 255) {
  185. return;
  186. }
  187. this.$app.url.goto('/subPackages/charging/terminal/terminal?deviceId=' + item.connectorCode + "&deviceStatus=" + item.status);
  188. },
  189. //扫一扫
  190. sacn() {
  191. this.$app.act.scan().then(res => {
  192. var paramObj = this.getUrlParams(res.result);
  193. if (!paramObj || !paramObj.connectorCode) {
  194. this.$app.popup.alert("二维码不正确。", "温馨提示!");
  195. return;
  196. }
  197. this.getDeviceInfo(paramObj.connectorCode);
  198. })
  199. },
  200. getUrlParams(url) {
  201. const paramsRegex = /[?&]+([^=&]+)=([^&]*)/gi;
  202. const params = {};
  203. let match;
  204. while (match = paramsRegex.exec(url)) {
  205. params[match[1]] = match[2];
  206. }
  207. return params;
  208. },
  209. //通过充电桩编码(sn)获取设备详情
  210. getDeviceInfo(sn) {
  211. this.$api.base("get", "/applet/v1/station/connector/detail", { "snconnectorCode": sn }, {}).then(res => {
  212. console.log("设备信息:", res)
  213. this.goTerminal(res.data);
  214. })
  215. }
  216. }
  217. }
  218. </script>
  219. <style scoped>
  220. @import url("site-more.css");
  221. </style>