site-more.vue 6.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225
  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">{{ 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: prices.index == index }">
  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.elecPrice }}</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. this.$api.base("get", "/applet/v1/station/connectors", { "stationId": stationId }, {}).then(res => {
  131. this.stationInfo = res.data;
  132. //当前的价格时间断的下标
  133. for (var i = 0; i < this.prices.data.length; i++) {
  134. if (this.nowPriceTime.id == this.prices.data[i].id) {
  135. this.prices.index = i;
  136. break
  137. }
  138. }
  139. })
  140. },
  141. getStationPriceList(stationId) {
  142. this.$api.base("get", "/applet/v1/station/prices", { "stationId": stationId }, {}).then(res => {
  143. this.prices.data = res.data;
  144. // this.nowPriceTime = res.data[this.prices.index];
  145. })
  146. },
  147. getSatesObj(item) {
  148. //{name:'离线',color:'grey'},{name:'空闲',color:'green'},{name:'占用',color:'blue'}
  149. var obj = {};
  150. if (item.status == 2 || item.status == 4) {
  151. obj = { color: 'blue' };
  152. } else if (item.deviceStatus == 3) {
  153. obj = { color: 'orange' };
  154. } else if (item.deviceStatus == 0) {
  155. obj = { color: 'grey' };
  156. } else if (item.deviceStatus == 1) {
  157. obj = { color: 'green' };
  158. } else if (item.deviceStatus == 255) {
  159. obj = { color: 'err' };
  160. }
  161. return obj;
  162. },
  163. //映射 峰 平 谷
  164. getPriceLable(type) {
  165. //时间类型 1 谷 2 平 3 峰
  166. var str = "";
  167. switch (type) {
  168. case 1:
  169. str = "谷";
  170. break;
  171. case 2:
  172. str = "平";
  173. break;
  174. case 3:
  175. str = "峰";
  176. break;
  177. }
  178. return str;
  179. },
  180. settitle(title) {
  181. uni.setNavigationBarTitle({ title });
  182. },
  183. // 跳转充电终端
  184. goTerminal(item) {
  185. //设备状态 0:离网1:空闲2:占用(未充电)3:占用(充电中)4:占用(预约锁定)255:故障
  186. if (item.deviceStatus == 0 || item.deviceStatus == 255) {
  187. return;
  188. }
  189. this.$app.url.goto('/pages/terminal/terminal?deviceId=' + item.id + "&deviceStatus=" + item.deviceStatus);
  190. },
  191. //扫一扫
  192. sacn() {
  193. this.$app.act.scan().then(res => {
  194. var paramObj = this.getUrlParams(res.result);
  195. if (!paramObj || !paramObj.connectorCode) {
  196. this.$app.popup.alert("二维码不正确。", "温馨提示!");
  197. return;
  198. }
  199. this.getDeviceInfo(paramObj.connectorCode);
  200. })
  201. },
  202. getUrlParams(url) {
  203. const paramsRegex = /[?&]+([^=&]+)=([^&]*)/gi;
  204. const params = {};
  205. let match;
  206. while (match = paramsRegex.exec(url)) {
  207. params[match[1]] = match[2];
  208. }
  209. return params;
  210. },
  211. //通过充电桩编码(sn)获取设备详情
  212. getDeviceInfo(sn) {
  213. this.$api.base("post", "/chargeApi/checkDevicesBySn", { "sn": sn }, {}).then(res => {
  214. console.log("设备信息:", res)
  215. this.goTerminal(res.device);
  216. })
  217. }
  218. }
  219. }
  220. </script>
  221. <style scoped>
  222. @import url("site-more.css");
  223. </style>