new-site.vue 13 KB

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