site.vue 11 KB

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