new-site.vue 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399
  1. <template>
  2. <ax-body :blank="0">
  3. <view class="site-body">
  4. <view class="top-banner">
  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. <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">{{ 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. if (this.stationInfo.pictures) {
  185. //添加站点图片
  186. var imgArr = this.stationInfo.pictures.split(",");
  187. if (imgArr.length > 0) {
  188. this.tops = imgArr;
  189. }
  190. }
  191. this.getStationsInfo();
  192. this.getConfigStationInfo();
  193. },
  194. mounted() {
  195. this.$app.act.selectorQuery(this, '#footer').then(res => {
  196. const win = uni.getWindowInfo();
  197. const tHight = win.windowWidth * 9 / 16;
  198. this.mainHeight = win.windowHeight - tHight - res.height + 10;
  199. });
  200. },
  201. data() {
  202. return {
  203. user_info: this.$app.storage.get('USER_INFO'),
  204. mainHeight: 0,
  205. tops: ["../../static/img/$temp-site.png"],
  206. another: false,
  207. terminals: [],
  208. entInfo: {
  209. title: '服务提供',
  210. name: '华能贵州盘州市风电有限责任公司',
  211. code: '915205555155625655',
  212. tel: '0851-8815158',
  213. businessLicenceUrl: "/static/img/$temp-site01.jpg"
  214. },
  215. stationInfo: "",//站点信息
  216. deviceList: [],//该站点桩列表
  217. timePricesList: [],//费用时段列表
  218. nowPriceTime: {},//当前费用时段信息
  219. service: {
  220. tel: '400-0000-0000',
  221. work: '09:00 至 18:00'
  222. },
  223. busineHours: "",//营业时间
  224. bannerIndex: 1,//轮播下标
  225. stationDetail: {},
  226. siteSelectIndex: 0,
  227. siteSortList: [{
  228. total: 0,
  229. text: '空闲',
  230. status: 1
  231. }, {
  232. total: 0,
  233. text: '占用',
  234. status: 2
  235. }, {
  236. total: 0,
  237. text: '离线',
  238. status: 0
  239. }],
  240. filteredConnectorList: [],
  241. }
  242. },
  243. methods: {
  244. swiperChange(e) {
  245. this.bannerIndex = e.detail.current + 1
  246. },
  247. getStationsInfo() {
  248. let location = this.$app.storage.get('USER_LOCATION')
  249. this.$api.base("get", "/applet/v1/station/detail", {
  250. stationId: parseInt(this.stationInfo.stationId),
  251. longitude: location.split(",")[0],
  252. latitude: location.split(",")[1]
  253. }, {}).then(res => {
  254. res.data.pictures = JSON.parse(res.data.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. // 初始化默认显示空闲状态的前3个设备
  265. this.siteSelectIndex = 0;
  266. this.filteredConnectorList = this.stationDetail.connectorList
  267. .filter(connector => connector.status == 1) // 空闲状态
  268. .slice(0, 3);
  269. // this.deviceList = res.devices;
  270. // this.timePricesList = res.prices;
  271. // this.nowPriceTime = res.nowPriceTime;
  272. })
  273. },
  274. selectItem(e, i) {
  275. this.siteSelectIndex = i;
  276. // 根据选择的状态过滤 connectorList
  277. if (e.status === 1) { // 空闲
  278. this.filteredConnectorList = this.stationDetail.connectorList.slice(0, 3).filter(connector => connector.status == 1);
  279. } else if (e.status === 2) { // 占用
  280. this.filteredConnectorList = this.stationDetail.connectorList.slice(0, 3).filter(connector =>
  281. connector.status == 2 || connector.status == 3 || connector.status == 4
  282. );
  283. } else if (e.status === 0) { // 离线
  284. this.filteredConnectorList = this.stationDetail.connectorList.slice(0, 3).filter(connector => connector.status == 0);
  285. }
  286. },
  287. getSatesObj(item) {
  288. //{name:'离线',color:'grey'},{name:'空闲',color:'green'},{name:'占用',color:'blue'}
  289. var obj = {};
  290. if (item.status == 2) {
  291. obj = { color: 'blue' };
  292. } else if (item.status == 0) {
  293. obj = { color: 'grey' };
  294. } else if (item.status == 1) {
  295. obj = { color: 'green' };
  296. }
  297. return obj;
  298. },
  299. //获取配置文件信息
  300. getConfigStationInfo() {
  301. this.$api.static(this.$config.url.configUrl + "stationConfi.json").then(res => {
  302. console.log("获取的配置文件信息:", res.busineHours);
  303. this.entInfo = res.entInfo;
  304. this.service = res.service;
  305. this.busineHours = res;
  306. })
  307. },
  308. // 拨打电话
  309. callPhone(phone) {
  310. this.$app.act.callPhone(phone);
  311. },
  312. // 打开客服
  313. openCustomerService() {
  314. this.$refs.service.open();
  315. },
  316. // 打开服务提供
  317. openEnt_Serve() {
  318. this.entInfo.title = '服务提供';
  319. this.$refs.entInfo.open();
  320. },
  321. // 打开发票提供
  322. openEnt_Invoicing() {
  323. this.entInfo.title = '发票提供';
  324. this.$refs.entInfo.open();
  325. },
  326. // 关闭企业弹窗
  327. closeEnt() {
  328. this.$refs.entInfo.close();
  329. },
  330. // 关闭服务弹窗
  331. closeService() {
  332. this.$refs.service.close();
  333. },
  334. // 打开地图
  335. openLocation() {
  336. uni.openLocation({
  337. latitude: Number(this.stationInfo.lat),
  338. longitude: Number(this.stationInfo.lng),
  339. });
  340. },
  341. // 跳转充电终端
  342. goTerminal(item) {
  343. //设备状态 0:离网1:空闲2:占用(未充电)3:占用(充电中)4:占用(预约锁定)255:故障
  344. if (item.deviceStatus == 0 || item.deviceStatus == 255) {
  345. return;
  346. }
  347. this.$app.url.goto('/pages/terminal/terminal?deviceId=' + item.id + "&deviceStatus=" + item.deviceStatus);
  348. },
  349. //去查看全部电站
  350. toDeiceAll() {
  351. var strList = JSON.stringify(this.timePricesList);
  352. var currPriceId = this.nowPriceTime.id
  353. this.$app.url.goto('/pages/site-more/site-more?stationId=' + this.stationInfo.id)
  354. },
  355. //去查看全部电价
  356. toPriceAll() {
  357. this.$app.url.goto('/pages/site-more/site-more?show=1&stationId=' + this.stationInfo.id)
  358. },
  359. //扫一扫
  360. sacn() {
  361. this.$app.act.scan().then(res => {
  362. console.log(res);
  363. var paramObj = this.getUrlParams(res.result);
  364. if (!paramObj || !paramObj.connectorCode) {
  365. this.$app.popup.alert("二维码不正确。", "温馨提示!");
  366. return;
  367. }
  368. this.getDeviceInfo(paramObj.connectorCode);
  369. })
  370. },
  371. getUrlParams(url) {
  372. const paramsRegex = /[?&]+([^=&]+)=([^&]*)/gi;
  373. const params = {};
  374. let match;
  375. while (match = paramsRegex.exec(url)) {
  376. params[match[1]] = match[2];
  377. }
  378. return params;
  379. },
  380. //通过充电桩编码(sn)获取设备详情
  381. getDeviceInfo(sn) {
  382. this.$api.base("post", "/chargeApi/checkDevicesBySn", { "sn": sn }, {}).then(res => {
  383. console.log("设备信息:", res)
  384. this.goTerminal(res.device);
  385. })
  386. }
  387. }
  388. }
  389. </script>
  390. <style scoped>
  391. @import url("new-site.css");
  392. </style>