site.vue 11 KB

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