site.vue 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363
  1. <template>
  2. <ax-body>
  3. <view class="body app-hide-scrollbar">
  4. <!-- 顶部 -->
  5. <view class="top">
  6. <view class="site-base">
  7. <view class="site-name">{{ stationInfo.name }}</view>
  8. <view class="site-parkade">充电减免2小时停车费,超出部分按每小时3元计算</view>
  9. </view>
  10. <view class="location">
  11. <view class="info app-flex-one">
  12. <view class="name">距离您{{ stationInfo.params.rangeShow }}</view>
  13. <view class="subname">{{ stationInfo.addr }}</view>
  14. </view>
  15. <view @click="openLocation()" class="info app-flex c-center column">
  16. <image src="@/static/img/locate2.svg" class="icon"></image>
  17. <view class="txt">导航</view>
  18. </view>
  19. <image src="@/static/img/site-bg01.png" class="bg"></image>
  20. </view>
  21. <image src="@/static/img/logo.svg" class="logo" mode="widthFix"></image>
  22. </view>
  23. <!-- 费用信息 -->
  24. <view class="card">
  25. <view class="card-title">
  26. <text>费用信息</text>
  27. <view @click="toPriceAll()" class="more">
  28. <text>查看全部</text>
  29. <text class="ax ax-iconline i-arrow-right icon"></text>
  30. </view>
  31. </view>
  32. <view class="info-cell">
  33. <image src="@/static/img/site-icon02.png" class="icon"></image>
  34. <text>当前时段:</text><text>{{ stationInfo.params.priceShow }}</text>
  35. </view>
  36. <view class="info-cell">
  37. <image src="@/static/img/site-icon03.png" class="icon"></image>
  38. <text>停车参考:</text><text>充电减免2小时停车费</text>
  39. </view>
  40. <view class="current-price">
  41. <view class="bg5">
  42. <view class="text">当前价</view>
  43. <image src="@/static/img/site-bg05.svg" class="bg" mode="heightFix"></image>
  44. </view>
  45. <!-- v-if="user_info.firmId===null" -->
  46. <view class="price-wrap"
  47. v-if="user_info.firmId === null || $app.storage.get('USER_INFO').firmType === 0">
  48. <view class="price">
  49. <text class="symbol">¥</text>
  50. <text>{{ nowPriceTime.price ? parseFloat(nowPriceTime.price).toFixed(4) : "0.0000" }}</text>
  51. </view>
  52. <view class="unit">元/度</view>
  53. </view>
  54. <view class="price-wrap" v-else>
  55. <view class="operation-price">
  56. <text class="operation-symbol">¥</text>
  57. <text>{{ parseFloat(nowPriceTime.firmPrice).toFixed(4) }}</text>
  58. </view>
  59. <view class="mini-text">元/度</view>
  60. <view class="operation-price-btn">
  61. 企业专享价
  62. </view>
  63. <view class="ordinary-price">
  64. {{ nowPriceTime.price ? parseFloat(nowPriceTime.price).toFixed(4) : "0.0000" }}</view>
  65. </view>
  66. </view>
  67. </view>
  68. <!-- 充电终端 -->
  69. <view class="card">
  70. <view class="card-title">
  71. <text>充电终端</text>
  72. <view @click="toDeiceAll()" class="more">
  73. <text>查看全部</text>
  74. <text class="ax ax-iconline i-arrow-right icon"></text>
  75. </view>
  76. </view>
  77. <view class="bread">
  78. <view class="bread-item">
  79. <view class="value">{{ getStatusNum(1) }}</view>
  80. <view class="name">空闲</view>
  81. </view>
  82. <view class="bread-item">
  83. <view class="value">{{ getStatusNum(2) }}</view>
  84. <view class="name">占用</view>
  85. </view>
  86. <view class="bread-item">
  87. <view class="value">{{ getStatusNum(0) }}</view>
  88. <view class="name">离线</view>
  89. </view>
  90. </view>
  91. <view class="terminals">
  92. <view v-for="(item, index) in terminals" :key="index" @click="goTerminal(item)"
  93. class="terminal-item">
  94. <view class="state" :class="[getSatesObj(item).color]">
  95. <view class="cake">
  96. <image src="@/static/img/site-icon01.svg" class="icon"></image>
  97. <view class="name">{{ getSatesObj(item).name }}</view>
  98. </view>
  99. </view>
  100. <view class="info">
  101. <view class="name">{{ item.deviceName }}</view>
  102. <view class="subinfo">电类分类:{{ getdeviceTypeName(item.eType) }}</view>
  103. <view class="subinfo">终端编号:{{ item.deviceNo }}</view>
  104. </view>
  105. </view>
  106. </view>
  107. </view>
  108. <!-- 扫码充电 -->
  109. <view class="footer">
  110. <view class="bg5">
  111. <view class="text">
  112. <view>中数电动</view>
  113. <view>特惠价</view>
  114. </view>
  115. <image src="@/static/img/site-bg05.svg" class="bg" mode="heightFix"></image>
  116. </view>
  117. <view class="price-wrap">
  118. <view class="price">
  119. <text class="symbol">¥</text>
  120. <!-- v-if="nowPriceTime.firmPrice===null" -->
  121. <text v-if="nowPriceTime.firmPrice === null || $app.storage.get('USER_INFO').firmType === 0">{{
  122. nowPriceTime.price ? nowPriceTime.price.toFixed(4) : "0.0000" }}</text>
  123. <text v-else>{{ parseFloat(nowPriceTime.firmPrice).toFixed(4) }}</text>
  124. </view>
  125. <view class="unit">{{ nowPriceTime.unit }}</view>
  126. </view>
  127. <view @click="sacn()" class="scan">扫码充电</view>
  128. </view>
  129. </view>
  130. </ax-body>
  131. </template>
  132. <script>
  133. export default {
  134. onLoad: function (option) {
  135. console.log(option); //打印出上个页面传递的参数。
  136. this.stationInfo = JSON.parse(option.item);
  137. if (this.stationInfo.pictures) {
  138. //添加站点图片
  139. var imgArr = this.stationInfo.pictures.split(",");
  140. if (imgArr.length > 0) {
  141. this.tops = imgArr;
  142. }
  143. }
  144. this.getStationsInfo();
  145. this.getConfigStationInfo();
  146. },
  147. mounted() {
  148. this.$app.act.selectorQuery(this, '#footer').then(res => {
  149. const win = uni.getWindowInfo();
  150. const tHight = win.windowWidth * 9 / 16;
  151. this.mainHeight = win.windowHeight - tHight - res.height + 10;
  152. });
  153. },
  154. data() {
  155. return {
  156. user_info: this.$app.storage.get('USER_INFO'),
  157. mainHeight: 0,
  158. tops: ["../../static/img/$temp-site.png"],
  159. another: false,
  160. terminals: [],
  161. entInfo: {
  162. title: '服务提供',
  163. name: '华能贵州盘州市风电有限责任公司',
  164. code: '915205555155625655',
  165. tel: '0851-8815158',
  166. businessLicenceUrl: "/static/img/$temp-site01.jpg"
  167. },
  168. stationInfo: "",//站点信息
  169. deviceList: [],//该站点桩列表
  170. timePricesList: [],//费用时段列表
  171. nowPriceTime: {},//当前费用时段信息
  172. service: {
  173. tel: '400-0000-0000',
  174. work: '09:00 至 18:00'
  175. },
  176. busineHours: "",//营业时间
  177. }
  178. },
  179. methods: {
  180. getStationsInfo() {
  181. this.$api.base("post", "/chargeApi/getStationsInfoAndUpdateDecice", { "stationId": this.stationInfo.stationId }, {}).then(res => {
  182. this.deviceList = res.devices;
  183. this.timePricesList = res.prices;
  184. this.nowPriceTime = res.nowPriceTime;
  185. //只显示三个设备信息
  186. for (var i = 0; i < this.deviceList.length; i++) {
  187. this.terminals.push(this.deviceList[i]);
  188. if (i == 2) {
  189. break;
  190. }
  191. }
  192. })
  193. },
  194. //获取桩状态的数量
  195. getStatusNum(status) {
  196. var num = 0;
  197. //设备状态 0:离网1:空闲2:占用(未充电)3:占用(充电中)4:占用(预约锁定)255:故障
  198. for (var i = 0; i < this.deviceList.length; i++) {
  199. var device = this.deviceList[i];
  200. if (status == 2) {
  201. if (device.deviceStatus == 2 || device.deviceStatus == 3 || device.deviceStatus == 4) {
  202. num++;
  203. continue;
  204. }
  205. }
  206. if (device.deviceStatus == status) {
  207. num++;
  208. }
  209. }
  210. return num;
  211. },
  212. getSatesObj(item) {
  213. //{name:'离线',color:'grey'},{name:'空闲',color:'green'},{name:'占用',color:'blue'}
  214. var obj = {};
  215. if (item.deviceStatus == 2 || item.deviceStatus == 4) {
  216. obj = { name: '占用', color: 'blue' };
  217. } else if (item.deviceStatus == 3) {
  218. obj = { name: '充电中', color: 'orange' };
  219. } else if (item.deviceStatus == 0) {
  220. obj = { name: '离线', color: 'grey' };
  221. } else if (item.deviceStatus == 1) {
  222. obj = { name: '空闲', color: 'green' };
  223. } else if (item.deviceStatus == 255) {
  224. obj = { name: '故障', color: 'err' };
  225. }
  226. return obj;
  227. },
  228. //获取充电桩设备类型
  229. getdeviceTypeName(type) {
  230. //电类型 1:直流设备;2:交流设备3:交直流一体设备;4:无线设备;5:其他
  231. var str = "";
  232. switch (type) {
  233. case "1":
  234. str = "直流设备";
  235. break
  236. case "2":
  237. str = "交流设备";
  238. break
  239. case "3":
  240. str = "交直流一体设备";
  241. break
  242. case "4":
  243. str = "无线设备";
  244. break
  245. case "5":
  246. str = "其他";
  247. break
  248. }
  249. return str;
  250. },
  251. //映射 峰 平 谷
  252. getPriceLable(type) {
  253. //时间类型 1 谷 2 平 3 峰
  254. var str = "";
  255. switch (type) {
  256. case 1:
  257. str = "谷";
  258. break;
  259. case 2:
  260. str = "平";
  261. break;
  262. case 3:
  263. str = "峰";
  264. break;
  265. }
  266. return str;
  267. },
  268. //获取配置文件信息
  269. getConfigStationInfo() {
  270. this.$api.static(this.$config.url.configUrl + "stationConfi.json").then(res => {
  271. console.log("获取的配置文件信息:", res);
  272. this.entInfo = res.entInfo;
  273. this.service = res.service;
  274. this.busineHours = res.busineHours;
  275. })
  276. },
  277. // 拨打电话
  278. callPhone(phone) {
  279. this.$app.act.callPhone(phone);
  280. },
  281. // 打开客服
  282. openCustomerService() {
  283. this.$refs.service.open();
  284. },
  285. // 打开服务提供
  286. openEnt_Serve() {
  287. this.entInfo.title = '服务提供';
  288. this.$refs.entInfo.open();
  289. },
  290. // 打开发票提供
  291. openEnt_Invoicing() {
  292. this.entInfo.title = '发票提供';
  293. this.$refs.entInfo.open();
  294. },
  295. // 关闭企业弹窗
  296. closeEnt() {
  297. this.$refs.entInfo.close();
  298. },
  299. // 关闭服务弹窗
  300. closeService() {
  301. this.$refs.service.close();
  302. },
  303. // 打开地图
  304. openLocation() {
  305. uni.openLocation({
  306. latitude: Number(this.stationInfo.lat),
  307. longitude: Number(this.stationInfo.lng),
  308. });
  309. },
  310. // 跳转充电终端
  311. goTerminal(item) {
  312. //设备状态 0:离网1:空闲2:占用(未充电)3:占用(充电中)4:占用(预约锁定)255:故障
  313. if (item.deviceStatus == 0 || item.deviceStatus == 255) {
  314. return;
  315. }
  316. this.$app.url.goto('/pages/terminal/terminal?deviceId=' + item.id + "&deviceStatus=" + item.deviceStatus);
  317. },
  318. //去查看全部电站
  319. toDeiceAll() {
  320. var strList = JSON.stringify(this.timePricesList);
  321. var currPriceId = this.nowPriceTime.id
  322. this.$app.url.goto('/pages/site-more/site-more?stationId=' + this.stationInfo.id)
  323. },
  324. //去查看全部电价
  325. toPriceAll() {
  326. this.$app.url.goto('/pages/site-more/site-more?show=1&stationId=' + this.stationInfo.id)
  327. },
  328. //扫一扫
  329. sacn() {
  330. this.$app.act.scan().then(res => {
  331. console.log(res);
  332. var paramObj = this.getUrlParams(res.result);
  333. if (!paramObj || !paramObj.connectorCode) {
  334. this.$app.popup.alert("二维码不正确。", "温馨提示!");
  335. return;
  336. }
  337. this.getDeviceInfo(paramObj.connectorCode);
  338. })
  339. },
  340. getUrlParams(url) {
  341. const paramsRegex = /[?&]+([^=&]+)=([^&]*)/gi;
  342. const params = {};
  343. let match;
  344. while (match = paramsRegex.exec(url)) {
  345. params[match[1]] = match[2];
  346. }
  347. return params;
  348. },
  349. //通过充电桩编码(sn)获取设备详情
  350. getDeviceInfo(sn) {
  351. this.$api.base("post", "/chargeApi/checkDevicesBySn", { "connectorCode": sn }, {}).then(res => {
  352. console.log("设备信息:", res)
  353. this.goTerminal(res.device);
  354. })
  355. }
  356. }
  357. }
  358. </script>
  359. <style scoped>
  360. @import url("site.css");
  361. </style>