site.vue 10 KB

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