new-site.vue 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405
  1. <template>
  2. <ax-body :blank="0">
  3. <view class="site-body">
  4. <view class="top-banner" v-if="stationDetail.pictures && stationDetail.pictures.length > 0">
  5. <swiper class="banner-swiper" circular :autoplay="true" interval="3000" duration="500"
  6. @change="swiperChange">
  7. <swiper-item class="banner-swiper-item" v-for="item in stationDetail.pictures">
  8. <image class="swiper-item-image" :src="item" mode=""></image>
  9. </swiper-item>
  10. </swiper>
  11. <view class="swiper-current">{{ bannerIndex }}/{{ stationDetail.pictures.length }}</view>
  12. </view>
  13. <view class="site-content"
  14. :style="{ top: `${stationDetail.pictures && stationDetail.pictures.length > 0 ? '320rpx' : '0'}` }">
  15. <view class="top-site-info">
  16. <view class="site-title">{{ stationDetail.stationName }}</view>
  17. <view class="site-text">
  18. <image src="@/static/img/site-icon03.png" class="icon"></image>
  19. <view class="item-text">{{ stationDetail.tips || '--' }}</view>
  20. </view>
  21. </view>
  22. <view class="site-location" @click="openLocation()">
  23. <view class="location-left">
  24. <view class="left-km">距离您{{ stationDetail.distance }}km</view>
  25. <view class="left-address">{{ stationDetail.address }}</view>
  26. </view>
  27. <view class="location-rihgt">
  28. <image src="@/static/img/locate2.svg" class="right-icon"></image>
  29. <view class="right-nav">导航</view>
  30. </view>
  31. </view>
  32. <view class="site-cost-info">
  33. <view class="cost-info-title">
  34. <view class="title-name">费用信息</view>
  35. <view class="check-info" @click="toPriceAll()">
  36. <text>查看全部</text>
  37. <text class="ax ax-iconline i-arrow-right icon"></text>
  38. </view>
  39. </view>
  40. <view class="cost-price-info" v-if="!stationDetail.enterprisePrice">
  41. <view class="cost-title">
  42. <view class="title-left">当前价</view>
  43. <view class="title-right">惊喜价</view>
  44. </view>
  45. <view class="cost-price">
  46. <text style="color: #FF6464;font-size: 48rpx;font-weight: 800;">{{
  47. stationDetail.currentPrice
  48. }}</text>
  49. <text class="cost-price-unit">元/度</text>
  50. </view>
  51. <view class="time-cost-price">当前时段:</view>
  52. <view class="time-cost-number">{{ stationDetail.currentPeriod }}</view>
  53. </view>
  54. <view class="firm-price-info-box" v-else>
  55. <view class="current-price-info">
  56. <view class="current-price-title">当前价</view>
  57. <view class="current-price">
  58. <view class="current-price-text"><text class="operation-symbol">¥</text>
  59. <text>{{ stationDetail.currentPrice }}</text>
  60. </view>
  61. <view class="current-price-unit">元/度</view>
  62. </view>
  63. <view class="time-current-price">当前时段:</view>
  64. <view class="time-current-number">{{ stationDetail.currentPeriod }}</view>
  65. </view>
  66. <view class="firm-price-info">
  67. <view class="firm-price-title">
  68. <view class="title-text">企业专享价</view>
  69. <view class="tags-price">特惠价</view>
  70. </view>
  71. <view class="firm-price-box">
  72. <view class="firm-price-text">
  73. {{ stationDetail.enterprisePrice || '--' }}
  74. </view>
  75. <view class="firm-price-unit">元/度</view>
  76. </view>
  77. <view class="current-pay-price-box">
  78. <view class="pay-price">
  79. <view class="firm-old-price">{{ stationDetail.currentPrice }}元/度
  80. </view>
  81. <!-- <view class="discount-price">本单预计省9元</view> -->
  82. </view>
  83. <image class="pay-price-icon" src="/static/img/firm-price.png" mode=""></image>
  84. </view>
  85. </view>
  86. </view>
  87. <view class="stopcar-tips">
  88. <image class="stopcar-tips-icon" src="@/static/img/site-icon03.png"></image>
  89. <view class="stopcar-tips-text">
  90. <view class="tips-text-title">停车参考</view>
  91. <view class="tips-text-mini">充电减免2小时停车费</view>
  92. </view>
  93. </view>
  94. </view>
  95. <view class="site-list-card">
  96. <view class="cost-info-title">
  97. <view class="title-name">充电终端</view>
  98. <view class="check-info" @click="toDeiceAll()">
  99. <text>查看全部</text>
  100. <text class="ax ax-iconline i-arrow-right icon"></text>
  101. </view>
  102. </view>
  103. <view class="app-flex site-select-tab">
  104. <view class="select-item" v-for="(item, index) in siteSortList" @click="selectItem(item, index)"
  105. :class="{ selectItemActive: siteSelectIndex == index }">
  106. {{ item.text }}({{ item.total }})
  107. </view>
  108. </view>
  109. <view class="site-list-box">
  110. <view v-for="(item, index) in filteredConnectorList" :key="index" @click="goTerminal(item)"
  111. class="terminal-item">
  112. <view class="state" :class="[getSatesObj(item).color]">
  113. <view class="cake">
  114. <image src="@/static/img/site-icon01.svg" class="icon"></image>
  115. <view class="name">{{ formatStatusName(item.statusName) }}</view>
  116. </view>
  117. </view>
  118. <view class="info">
  119. <view class="name">{{ item.connectorName }}</view>
  120. <view class="subinfo">电类分类:{{ item.equipmentType }}</view>
  121. <view class="subinfo">终端编号:{{ item.connectorCode }}</view>
  122. </view>
  123. </view>
  124. <view v-if="filteredConnectorList.length === 0" class="not-data">暂无设备</view>
  125. </view>
  126. </view>
  127. <!-- <view class="site-list-card" v-if="stationDetail.customerServiceHotline">
  128. <view class="cost-info-title">
  129. <view class="title-name">电站信息</view>
  130. <view class="check-info">
  131. <text>查看全部</text>
  132. <text class="ax ax-iconline i-arrow-right icon"></text>
  133. </view>
  134. </view>
  135. <view class="site-detail-line"></view>
  136. <view class="site-detail-info">
  137. <view class="detail-info-item">
  138. <view class="left-item">营业时间</view>
  139. <view class="right-item">{{ stationDetail.businessHours || '--' }}</view>
  140. </view>
  141. <view class="detail-info-item">
  142. <view class="left-item">服务提供</view>
  143. <view class="right-item">{{ stationDetail.serviceProvider }}</view>
  144. </view>
  145. <view class="detail-info-item">
  146. <view class="left-item">发票提供</view>
  147. <view class="right-item">{{ stationDetail.serviceProvider }}</view>
  148. </view>
  149. <view class="detail-info-item">
  150. <view class="left-item">客服热线</view>
  151. <view class="right-item">{{ stationDetail.customerServiceHotline }}</view>
  152. </view>
  153. </view>
  154. </view> -->
  155. <view style="height: 200rpx;"></view>
  156. </view>
  157. <!-- 扫码充电 -->
  158. <view class="footer">
  159. <view class="bg5">
  160. <view class="text">
  161. <view>中数电动</view>
  162. <view>特惠价</view>
  163. </view>
  164. <image src="@/static/img/site-bg05.svg" class="bg" mode="heightFix"></image>
  165. </view>
  166. <view class="price-wrap">
  167. <view class="price">
  168. <text class="symbol">¥</text>
  169. <!-- v-if="nowPriceTime.firmPrice===null" -->
  170. <text v-if="!stationDetail.enterprisePrice">{{ stationDetail.currentPrice }}</text>
  171. <text v-else>{{ stationDetail.enterprisePrice || '--' }}</text>
  172. </view>
  173. <view class="unit">元/度</view>
  174. </view>
  175. <view @click="sacn()" class="scan">扫码充电</view>
  176. </view>
  177. </view>
  178. </ax-body>
  179. </template>
  180. <script>
  181. export default {
  182. onLoad: function (option) {
  183. console.log(option); //打印出上个页面传递的参数。
  184. this.stationInfo = JSON.parse(option.item);
  185. this.getStationsInfo();
  186. this.getConfigStationInfo();
  187. },
  188. mounted() {
  189. this.$app.act.selectorQuery(this, '#footer').then(res => {
  190. const win = uni.getWindowInfo();
  191. const tHight = win.windowWidth * 9 / 16;
  192. this.mainHeight = win.windowHeight - tHight - res.height + 10;
  193. });
  194. },
  195. data() {
  196. return {
  197. user_info: this.$app.storage.get('USER_INFO'),
  198. mainHeight: 0,
  199. tops: ["../../static/img/$temp-site.png"],
  200. another: false,
  201. terminals: [],
  202. entInfo: {
  203. title: '服务提供',
  204. name: '华能贵州盘州市风电有限责任公司',
  205. code: '915205555155625655',
  206. tel: '0851-8815158',
  207. businessLicenceUrl: "/static/img/$temp-site01.jpg"
  208. },
  209. stationInfo: "",//站点信息
  210. deviceList: [],//该站点桩列表
  211. timePricesList: [],//费用时段列表
  212. nowPriceTime: {},//当前费用时段信息
  213. service: {
  214. tel: '400-0000-0000',
  215. work: '09:00 至 18:00'
  216. },
  217. busineHours: "",//营业时间
  218. bannerIndex: 1,//轮播下标
  219. stationDetail: {},
  220. siteSelectIndex: 0,
  221. siteSortList: [{
  222. total: 0,
  223. text: '空闲',
  224. status: 1
  225. }, {
  226. total: 0,
  227. text: '占用',
  228. status: 2
  229. }, {
  230. total: 0,
  231. text: '离线',
  232. status: 0
  233. }],
  234. filteredConnectorList: [],
  235. }
  236. },
  237. methods: {
  238. swiperChange(e) {
  239. this.bannerIndex = e.detail.current + 1
  240. },
  241. getStationsInfo() {
  242. let location = this.$app.storage.get('USER_LOCATION')
  243. this.$api.base("get", "/applet/v1/station/detail", {
  244. stationId: parseInt(this.stationInfo.stationId),
  245. longitude: location.split(",")[0] || 0,
  246. latitude: location.split(",")[1] || 0
  247. }, {}).then(res => {
  248. let pictures = res.data.pictures;
  249. if (typeof pictures === 'string') {
  250. pictures = JSON.parse(pictures) || [];
  251. } else if (!Array.isArray(pictures)) {
  252. pictures = [];
  253. }
  254. res.data.pictures = pictures;
  255. const countMapping = {
  256. '空闲': res.data.idleCount,
  257. '占用': res.data.occupiedCount,
  258. '离线': res.data.offlineCount
  259. };
  260. this.siteSortList.forEach(item => {
  261. item.total = countMapping[item.text] || 0;
  262. });
  263. this.stationDetail = res.data
  264. console.log(this.stationDetail, '数据');
  265. // 初始化默认显示空闲状态的前3个设备
  266. this.siteSelectIndex = 0;
  267. this.filteredConnectorList = this.stationDetail.connectorList
  268. .filter(connector => connector.status == 1) // 空闲状态
  269. .slice(0, 3);
  270. })
  271. },
  272. selectItem(e, i) {
  273. this.siteSelectIndex = i;
  274. // 根据选择的状态过滤 connectorList - 先过滤再取前3条
  275. if (e.status === 1) { // 空闲
  276. this.filteredConnectorList = this.stationDetail.connectorList
  277. .filter(connector => connector.status == 1)
  278. .slice(0, 3);
  279. console.log("空闲过滤后的connectorList:", this.filteredConnectorList);
  280. } else if (e.status === 2 || e.status === 3) { // 占用
  281. this.filteredConnectorList = this.stationDetail.connectorList
  282. .filter(connector => connector.status == 2 || connector.status == 3)
  283. .slice(0, 3);
  284. console.log("占用过滤后的connectorList:", this.filteredConnectorList);
  285. } else if (e.status === 0) { // 离线
  286. this.filteredConnectorList = this.stationDetail.connectorList
  287. .filter(connector => connector.status == 0)
  288. .slice(0, 3);
  289. console.log("离线过滤后的connectorList:", this.filteredConnectorList);
  290. }
  291. },
  292. getSatesObj(item) {
  293. //{name:'离线',color:'grey'},{name:'空闲',color:'green'},{name:'占用',color:'blue'}
  294. var obj = {};
  295. if (item.status == 2) {
  296. obj = { color: 'blue' };
  297. } else if (item.status == 0) {
  298. obj = { color: 'grey' };
  299. } else if (item.status == 1) {
  300. obj = { color: 'green' };
  301. }
  302. return obj;
  303. },
  304. formatStatusName(statusName) {
  305. // 去掉括号及括号内的内容
  306. return statusName.replace(/\([^)]*\)/g, '');
  307. },
  308. //获取配置文件信息
  309. getConfigStationInfo() {
  310. this.$api.static(this.$config.url.configUrl + "stationConfi.json").then(res => {
  311. console.log("获取的配置文件信息:", res.busineHours);
  312. this.entInfo = res.entInfo;
  313. this.service = res.service;
  314. this.busineHours = res;
  315. })
  316. },
  317. // 拨打电话
  318. callPhone(phone) {
  319. this.$app.act.callPhone(phone);
  320. },
  321. // 打开客服
  322. openCustomerService() {
  323. this.$refs.service.open();
  324. },
  325. // 打开服务提供
  326. openEnt_Serve() {
  327. this.entInfo.title = '服务提供';
  328. this.$refs.entInfo.open();
  329. },
  330. // 打开发票提供
  331. openEnt_Invoicing() {
  332. this.entInfo.title = '发票提供';
  333. this.$refs.entInfo.open();
  334. },
  335. // 关闭企业弹窗
  336. closeEnt() {
  337. this.$refs.entInfo.close();
  338. },
  339. // 关闭服务弹窗
  340. closeService() {
  341. this.$refs.service.close();
  342. },
  343. // 打开地图
  344. openLocation() {
  345. uni.openLocation({
  346. latitude: Number(this.stationDetail.latitude),
  347. longitude: Number(this.stationDetail.longitude),
  348. });
  349. },
  350. // 跳转充电终端
  351. goTerminal(item) {
  352. //设备状态 0:离网1:空闲2:占用(未充电)3:占用(充电中)4:占用(预约锁定)255:故障
  353. if (item.status == 0 || item.status == 255) {
  354. return;
  355. }
  356. this.$app.url.goto('/subPackages/charging/terminal/terminal?deviceId=' + item.connectorCode + "&deviceStatus=" + item.status);
  357. },
  358. //去查看全部电站
  359. toDeiceAll() {
  360. this.$app.url.goto('/subPackages/charging/site-more/site-more?stationId=' + this.stationDetail.stationId)
  361. },
  362. //去查看全部电价
  363. toPriceAll() {
  364. this.$app.url.goto('/subPackages/charging/site-more/site-more?show=1&stationId=' + this.stationDetail.stationId)
  365. },
  366. //扫一扫
  367. sacn() {
  368. this.$app.act.scan().then(res => {
  369. console.log(res);
  370. var paramObj = this.getUrlParams(res.result);
  371. if (!paramObj || !paramObj.connectorCode) {
  372. this.$app.popup.alert("二维码不正确。", "温馨提示!");
  373. return;
  374. }
  375. this.getDeviceInfo(paramObj.connectorCode);
  376. })
  377. },
  378. getUrlParams(url) {
  379. const paramsRegex = /[?&]+([^=&]+)=([^&]*)/gi;
  380. const params = {};
  381. let match;
  382. while (match = paramsRegex.exec(url)) {
  383. params[match[1]] = match[2];
  384. }
  385. return params;
  386. },
  387. //通过充电桩编码(sn)获取设备详情
  388. getDeviceInfo(sn) {
  389. this.$api.base("get", "/applet/v1/station/connector/detail", { "connectorCode": sn }, {}).then(res => {
  390. console.log("设备信息:", res)
  391. this.goTerminal(res.data);
  392. })
  393. }
  394. }
  395. }
  396. </script>
  397. <style scoped>
  398. @import url("new-site.css");
  399. </style>