site.vue 11 KB

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