index.vue 23 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758
  1. <template>
  2. <ax-body hide-indicator-area :style="[StyleSheet]">
  3. <!-- 标题栏 -->
  4. <template #title>
  5. <view class="titlebar">
  6. <image src="@/static/img/title.png" class="page-title"></image>
  7. <!-- <text class="page-subtitle">“特惠充电享不停”</text> -->
  8. </view>
  9. </template>
  10. <view class="base">
  11. <!-- 搜索块 -->
  12. <view id="search" class="app-flex search-view">
  13. <label class="search-bar" @click="$app.url.goto('/subPackages/other/search/search')">
  14. <view class="locate-city">
  15. <image src="@/static/img/locate.svg" class="_icon"></image>
  16. <text class="__name">{{ city.data[city.index].text }}</text>
  17. </view>
  18. <input placeholder-class="app-placeholder" placeholder="| 输入目的地/电站名" />
  19. <image src="@/static/img/search.svg" class="_icon-search"></image>
  20. </label>
  21. <view style="width: 20rpx;"></view>
  22. <view class="search-map-mode" @click="$app.url.goto('/pages/map/map', false)">
  23. <image class="search-map-icon" src="@/static/img/map-icon.svg" mode=""></image>
  24. <text>地图模式</text>
  25. </view>
  26. </view>
  27. </view>
  28. <view class="arrears-tips" v-if="payment_msg != null">
  29. <view class="arrears-left">
  30. <image class="arrears-icon" src="@/static/img/arrears-icon.svg" mode=""></image>
  31. <view class="arrears-text">
  32. 您有一笔超充订单{{ (payment_msg.maspAmount + payment_msg.maspRealAmount).toFixed(2) }}元待补缴</view>
  33. </view>
  34. <view class="arrears-btn" @click="topage_coupon">去补缴</view>
  35. </view>
  36. <!-- 主滚动 -->
  37. <view class="main-scroll-wrap">
  38. <scroll-view class="root-scroll app-hide-scrollbar" @scrolltolower="scrollLock = true"
  39. @scrolltoupper="scrollLock = false" scroll-y>
  40. <view class="contet-root">
  41. <!-- 内容顶部 -->
  42. <view id="roller" class="base">
  43. <!-- 快捷栏 -->
  44. <view class="shortcut-bar">
  45. <view class="buy-charge-coupon"
  46. @click="$app.url.goto('/subPackages/coupon/coupon-buy/coupon-buy')">
  47. <view class="coupon-tag">特惠</view>
  48. <view class="charge-title">
  49. <view class="title-coupon-text">购充电券</view>
  50. <view class="title-right-text">
  51. <text class="ax ax-iconline i-arrow-right icon"></text>
  52. </view>
  53. </view>
  54. <!-- <view class="charge-text-dsc">特惠价限时购买</view> -->
  55. <image class="charge-coupon-img"
  56. src="https://national-motion.oss-cn-beijing.aliyuncs.com/20260107/c2a6329e87394f77a8ab0549b3ceb19e.png"
  57. mode=""></image>
  58. </view>
  59. <view class="">
  60. <view class="order-center" @click="$app.url.goto('/subPackages/order/order/order')">
  61. <view class="order-center-left">
  62. <view class="charge-title" style="margin-top:0;">
  63. <!-- <image class="title-coupon-text" src="@/static/img/order-center.png"
  64. mode="">
  65. </image> -->
  66. <view class="title-coupon-text">订单中心</view>
  67. <view class="title-right-text">
  68. <text class="ax ax-iconline i-arrow-right icon"></text>
  69. </view>
  70. </view>
  71. <view class="order-center-number">
  72. 查看充电订单
  73. </view>
  74. </view>
  75. <image class="order-center-icon"
  76. src="https://national-motion.oss-cn-beijing.aliyuncs.com/20260106/27d2ab4f8d544109a597f3cafa451a10.png"
  77. mode=""></image>
  78. </view>
  79. <view class="order-center" style="margin-top: 20rpx;"
  80. @click="$app.url.goto('/subPackages/other/feedback/feedback')">
  81. <view class="order-center-left">
  82. <view class="charge-title" style="margin-top:0;">
  83. <!-- <image class="title-coupon-text" src="@/static/img/yijian-fankui.png"
  84. mode="">
  85. </image> -->
  86. <view class="title-coupon-text">意见反馈</view>
  87. <view class="title-right-text">
  88. <text class="ax ax-iconline i-arrow-right icon"></text>
  89. </view>
  90. </view>
  91. <view class="order-center-number">
  92. 随时为您服务
  93. </view>
  94. </view>
  95. <image class="order-center-icon"
  96. src="https://national-motion.oss-cn-beijing.aliyuncs.com/20260106/f4ca76c0808642e49627463c8e6a2310.png"
  97. mode=""></image>
  98. </view>
  99. </view>
  100. </view>
  101. <!-- 版头广告 -->
  102. <swiper class="banner" v-if="banners.length > 0" autoplay="true" circular>
  103. <swiper-item v-for="(item, index) in banners" :key="index"
  104. @click="$app.url.goto(item.jumpPage)">
  105. <view class="swiper-item">
  106. <image @load="bannerLoadCompleted()" :src="item.picture" class="swiper-item-image"
  107. mode="widthFix"></image>
  108. </view>
  109. </swiper-item>
  110. </swiper>
  111. </view>
  112. <view id="fixed" class="base">
  113. <!-- 选项条 -->
  114. <view class="app-flex options-bar">
  115. <view class="options-tabs" v-for="(item, index) in sorts.data" :key="index"
  116. @click="changeSort(index)" :class="{ active: sorts.index == index }">
  117. <text>{{ item.name }}</text>
  118. </view>
  119. </view>
  120. </view>
  121. <!-- 电站列表 -->
  122. <view id="list-box" class="list-scroll-wrap">
  123. <!-- <scroll-view class="list-scroll" :scroll-y="scrollLock"> -->
  124. <view class="list">
  125. <view class="list-top">
  126. <view class="list-top-img">
  127. <image class="list-top-img-img"
  128. src="https://national-motion.oss-cn-beijing.aliyuncs.com/20260107/ae817f97a31d45b5a014b33be96cfb73.png"
  129. mode="" />
  130. </view>
  131. </view>
  132. <view v-for="(item, index) in list.data" :key="index" @click="gotoSiteDetail(item)"
  133. class="item">
  134. <view class="contet">
  135. <view class="name">
  136. <view class="txt">{{ item.stationName }}</view>
  137. <view class="firm-price" v-if="index!=0">
  138. 充电特惠
  139. </view>
  140. </view>
  141. <view class="parkade">
  142. <view class="txt">{{ item.tips || '' }}</view>
  143. </view>
  144. <view class="app-flex c-between info">
  145. <view class="app-flex middle">
  146. <view class="charge"><text class="icon"
  147. style="margin-right: 16rpx;">快</text>{{
  148. item.fastCharging }}
  149. </view>
  150. <view class="charge"><text class="icon blue" style="margin-right: 16rpx;">慢
  151. </text>{{
  152. item.slowCharging }}
  153. </view>
  154. </view>
  155. <view class="distance">
  156. <view class="icon">
  157. <image src="@/static/img/distance.svg" mode="widthFix"></image>
  158. </view>
  159. <text>{{ item.distance || '0' }}km</text>
  160. </view>
  161. </view>
  162. </view>
  163. <view class="price">
  164. <view class="normal-user-price" v-if="!item.enterprisePrice">
  165. <view class="normal-user-price-label">
  166. <text class="value" style="color: #FF6464;margin-left: 20rpx;">{{
  167. item.platformPrice }}</text>
  168. <text class="unit" style="color: #2B303A;font-weight: normal;">元/度</text>
  169. </view>
  170. <image class="normal-user-price-icon" src="@/static/img/normal-user.png"
  171. mode="" />
  172. <view class="normal-user-text">去充电</view>
  173. </view>
  174. <view class="app-flex middle" v-else>
  175. <text class="value" style="color: #FF6464;margin-left: 20rpx;">{{
  176. item.platformPrice }}</text>
  177. <text class="unit" style="color: #2B303A;font-weight: normal;">元/度</text>
  178. <view class="card-bottom-text">
  179. <text class="card-bottom-text-minitext">{{ item.enterprisePrice
  180. }}</text> <text style="color: #2B303A;font-size: 18rpx;">元/度</text>
  181. </view>
  182. </view>
  183. <view>{{ item.peakValue }}{{ item.peakTime || '--' }}</view>
  184. </view>
  185. </view>
  186. </view>
  187. <!-- </scroll-view> -->
  188. </view>
  189. <!-- <view style="height: 158px;"></view> -->
  190. </view>
  191. </scroll-view>
  192. <view class="concat-father" @click="customerService()">
  193. <image class="concat-icon"
  194. src="https://national-motion.oss-cn-beijing.aliyuncs.com/20251230/818d10965318468496abbbdef97e908d.png"
  195. mode=""></image>
  196. </view>
  197. </view>
  198. <ax-popup ref="filter" position="" maskType="black" maskEnable maskClose>
  199. <view class="ad-popup">
  200. <view class="close-get" @click="closeAd">X</view>
  201. <swiper class="ad-swiper" :autoplay="true" :interval="8000" :duration="1000" circular indicator-dots>
  202. <swiper-item class="ad-swiper-item" v-for="(item, index) in adBanner" :key="index">
  203. <image class="ad-image" :src="item.picture" @click="goImgLink(item)" mode="widthFix">
  204. </image>
  205. </swiper-item>
  206. </swiper>
  207. </view>
  208. </ax-popup>
  209. <view style="position: fixed;width: 100%;bottom:100rpx;z-index: 100;">
  210. <app-navigation id="app-navigation" active="home"></app-navigation>
  211. </view>
  212. </ax-body>
  213. </template>
  214. <script>
  215. var bmap = require('static/js/bmap-wx.js');
  216. export default {
  217. async onLoad(options) {
  218. const permit = await this.queryPermit();
  219. if (permit.privacy) {
  220. // 没有通过隐私协议
  221. this.privacy.visible = true;
  222. } else {
  223. // 已通过隐私协议
  224. if (permit.location === true) {
  225. // 可以调用定位能力
  226. this.updateLocation();
  227. } else if (permit.location === false) {
  228. // 通过了隐私协议,但是定位被拒绝
  229. this.location.visible = true;
  230. this.updateLocation();
  231. } else if (permit.location === undefined) {
  232. // 没有申请过定位能力
  233. this.updateLocation();
  234. }
  235. }
  236. if (options.hasOwnProperty('q') && options.q) {
  237. // 通过下面这步解码,可以拿到url的值
  238. const url = decodeURIComponent(options.q)
  239. // 对url中携带的参数提取处理
  240. console.log("url:" + url)
  241. var device_no = this.getQueryParams(url, "connectorCode")
  242. console.log("connectorCode:" + device_no)
  243. if (device_no) {
  244. this.getDeviceInfo(device_no)
  245. }
  246. }
  247. if (this.closeAdvertising) {
  248. this.getAdswiper()
  249. }
  250. // this.user_info=this.$app.storage.get('USER_INFO')
  251. },
  252. mounted() {
  253. if (this.adBanner.length > 0 && !this.$app.storage.get('AD_STATUS')) {
  254. this.$refs.filter.open();
  255. }
  256. // #ifdef MP-WEIXIN
  257. this.setListHeight();
  258. // #endif
  259. this.setAppNavigationHeight();
  260. this.get_frimid()
  261. // this.get_paymentMsg()
  262. this.getBanners()
  263. this.queryUserIsBindCard()
  264. },
  265. data() {
  266. return {
  267. payment_msg: null,
  268. user_info: {},
  269. // 导航栏高度
  270. appNavigationHeight: 0,
  271. // 页面滚动锁
  272. scrollLock: true,
  273. sorts: {
  274. index: 0,
  275. data: [{
  276. name: '离我最近',
  277. code: "range"
  278. }, {
  279. name: '空闲最多',
  280. code: "device"
  281. }, {
  282. name: '电费最低',
  283. code: "price"
  284. }]
  285. },
  286. list: {
  287. height: 0,
  288. data: []
  289. },
  290. banners: [],
  291. adBanner: [],
  292. location: {
  293. visible: false,
  294. value: '',
  295. },
  296. privacy: {
  297. visible: false,
  298. },
  299. city: {
  300. index: 0,
  301. data: [{
  302. text: '贵阳',
  303. areaCode: "5201"
  304. },
  305. {
  306. text: '六盘水',
  307. areaCode: "5202"
  308. },
  309. {
  310. text: '遵义',
  311. areaCode: "5203"
  312. },
  313. {
  314. text: '安顺',
  315. areaCode: "5204"
  316. },
  317. {
  318. text: '毕节',
  319. areaCode: "5205"
  320. },
  321. {
  322. text: '铜仁',
  323. areaCode: "5206"
  324. },
  325. {
  326. text: '黔东南',
  327. areaCode: "5226"
  328. },
  329. {
  330. text: '黔南',
  331. areaCode: "5227"
  332. },
  333. {
  334. text: '黔西南',
  335. areaCode: "5223"
  336. },
  337. ]
  338. },
  339. discountInfo: null,
  340. closeAdvertising: false,
  341. pageNum: 1
  342. }
  343. },
  344. onShow() {
  345. this.getAdswiper()
  346. },
  347. onHide() {
  348. this.$app.storage.remove('AD_STATUS')
  349. },
  350. computed: {
  351. StyleSheet() {
  352. return {
  353. '--app-navigation-heiht': `${this.appNavigationHeight}px`,
  354. '--list-heiht': `${this.list.height}px`
  355. }
  356. }
  357. },
  358. onShareAppMessage(res) {
  359. if (res.from === 'button') {
  360. // 来自页面内分享按钮
  361. console.log(res.target);
  362. }
  363. return {
  364. title: "用券充天天都享会员价", // 标题
  365. path: "/pages/index/index", // 分享路径
  366. imageUrl: 'https://national-motion.oss-cn-beijing.aliyuncs.com/20251230/7eda17a802dd49e39f8c6bb3d0f1aa4e.jpg', // 分享图
  367. desc: '用券充天天都享会员价'
  368. };
  369. },
  370. onShareTimeline() {
  371. return {
  372. title: "用券充天天都享会员价", // 标题
  373. path: "/pages/index/index", // 分享路径
  374. imageUrl: 'https://national-motion.oss-cn-beijing.aliyuncs.com/20251230/7eda17a802dd49e39f8c6bb3d0f1aa4e.jpg' // 分享图
  375. };
  376. },
  377. methods: {
  378. closeAd() {
  379. this.closeAdvertising = true
  380. this.$refs.filter.close()
  381. this.$app.storage.set('AD_STATUS', this.closeAdvertising);
  382. },
  383. // 企业用户扫码进入
  384. get_frimid() {
  385. if (this.$app.storage.get('FRIM_ID')) {
  386. if (this.$app.storage.get('USER_INFO')) {
  387. this.$api.base("post", "/userApi/add-firm-user?firmId=" + parseInt(this.$app.storage.get(
  388. 'FRIM_ID')), {}, {
  389. error: false
  390. }).then(res => {
  391. this.get_userinfo()
  392. setTimeout(() => {
  393. this.$app.storage.remove('FRIM_ID')
  394. }, 500)
  395. this.$app.popup.alert(res.msg);
  396. }).catch(err => {
  397. setTimeout(() => {
  398. this.$app.storage.remove('FRIM_ID')
  399. }, 500)
  400. // this.$app.popup.alert(err.msg)
  401. })
  402. } else {
  403. uni.showModal({
  404. title: '未登录',
  405. content: '你还未进行登录,请去登录',
  406. showCancel: false,
  407. success: function(res) {
  408. if (res.confirm) {
  409. uni.navigateTo({
  410. url: '/pages/login/login'
  411. })
  412. }
  413. }
  414. })
  415. }
  416. }
  417. },
  418. getDeviceInfo(sn) {
  419. this.$api.base("get", "/applet/v1/station/connector/detail", {
  420. "connectorCode": sn
  421. }, {}).then(res => {
  422. //设备状态 0:离网1:空闲2:占用(未充电)3:占用(充电中)4:占用(预约锁定)255:故障
  423. if (res.data.status == 0 || res.data.status == 255) {
  424. return;
  425. }
  426. this.$app.url.goto('/subPackages/charging/terminal/terminal?deviceId=' + res.data
  427. .connectorCode + "&deviceStatus=" + res.data
  428. .status);
  429. })
  430. },
  431. getQueryParams(url, key) {
  432. const queryString = url.split('?')[1] || '';
  433. const params = {};
  434. const pairs = queryString.split('&');
  435. pairs.forEach(pair => {
  436. const [key, value] = pair.split('=');
  437. params[decodeURIComponent(key)] = decodeURIComponent(value || '');
  438. });
  439. return params[key];
  440. },
  441. // 校验用户是否绑定车牌
  442. queryUserIsBindCard() {
  443. this.$api.base("get", "/applet/v1/vehicle/list", {}, {}).then(res => {
  444. if (res.data.length < 1) {
  445. this.$app.popup.confirm("绑定车牌享更多权益", "充电车主专享").then(confirm => {
  446. if (confirm) {
  447. this.$app.url.goto('/subPackages/other/addLicensePlates/addLicensePlates');
  448. }
  449. });
  450. }
  451. })
  452. },
  453. goImgLink(e) {
  454. this.$app.url.goto(e.skipUrl);
  455. },
  456. // 打开客服
  457. customerService() {
  458. const cs = this.$config.customerService;
  459. this.$app.act.customerService(cs.id, cs.url).catch(err => {
  460. console.log(err);
  461. this.$app.popup.alert('客服中心失联啦,请联系管理员!');
  462. });
  463. },
  464. // 查询许可
  465. queryPermit() {
  466. return new Promise((resolve, reject) => {
  467. const data = {};
  468. const check = () => {
  469. if (Object.keys(data).length == 2) resolve(data);
  470. }
  471. // #ifndef H5
  472. if (uni.getPrivacySetting) {
  473. uni.getPrivacySetting({
  474. success: res => {
  475. data.privacy = res.needAuthorization;
  476. },
  477. complete: () => {
  478. if (typeof data.privacy != 'boolean' && typeof data.privacy !=
  479. 'undefined') data.privacy = null;
  480. check();
  481. },
  482. });
  483. } else {
  484. data.privacy = false;
  485. }
  486. // #endif
  487. // #ifdef H5
  488. data.privacy = false;
  489. // #endif
  490. // #ifdef MP-WEIXIN
  491. uni.getSetting({
  492. success: res => {
  493. data.location = uni.getLocation ? res.authSetting['scope.userLocation'] :
  494. undefined;
  495. },
  496. complete: () => {
  497. if (typeof data.location != 'boolean' && typeof data.location !=
  498. 'undefined') data.location = null;
  499. check();
  500. },
  501. })
  502. // #endif
  503. // #ifdef H5
  504. data.location = true;
  505. check();
  506. // #endif
  507. });
  508. },
  509. // 更新位置
  510. updateLocation() {
  511. this.getLocation().then(res => {
  512. this.location.value = [res.longitude, res.latitude].join(',');
  513. this.get_userinfo()
  514. this.getStations(res.longitude, res.latitude)
  515. this.$app.storage.set('USER_LOCATION', this.location.value);
  516. return this.reverseGeocoder([res.latitude, res.longitude].join(','))
  517. });
  518. },
  519. // 获取定位
  520. getLocation() {
  521. return new Promise((resolve, reject) => {
  522. // #ifdef H5
  523. // H5环境下使用浏览器定位API
  524. if (navigator.geolocation) {
  525. navigator.geolocation.getCurrentPosition(
  526. (position) => {
  527. resolve({
  528. longitude: position.coords.longitude,
  529. latitude: position.coords.latitude
  530. });
  531. },
  532. (error) => {
  533. console.log('H5定位失败', error);
  534. this.getStations("", "");
  535. this.get_userinfo()
  536. }
  537. );
  538. } else {
  539. console.log('浏览器不支持定位');
  540. resolve({
  541. longitude: '',
  542. latitude: ''
  543. });
  544. }
  545. // #endif
  546. // #ifndef H5
  547. if (uni.getLocation) {
  548. uni.getLocation({
  549. success: res => resolve(res),
  550. fail: err => {
  551. console.log(err)
  552. console.log('定位失败');
  553. this.getStations("", "")
  554. this.get_userinfo()
  555. }
  556. })
  557. } else {
  558. console.log('微信版本太低,无定位接口可用');
  559. resolve({
  560. longitude: '',
  561. latitude: ''
  562. });
  563. }
  564. // #endif
  565. });
  566. },
  567. reverseGeocoder(latlon) {
  568. // #ifdef H5
  569. // H5环境跳过百度地图处理
  570. console.log('H5环境跳过百度地图处理');
  571. return Promise.resolve();
  572. // #endif
  573. // #ifndef H5
  574. console.log(latlon)
  575. let lat = latlon.split(",")[0]
  576. let lng = latlon.split(",")[1]
  577. let baiduLoc = this.convertGcj02ToBd09(lng, lat)
  578. latlon = baiduLoc.lat + "," + baiduLoc.lng
  579. console.log(latlon)
  580. return new Promise((resolve, reject) => {
  581. var BMap = new bmap.BMapWX({
  582. ak: 'vtQgaPzonb3H4qeUOWGr53ePcNCsmdMj'
  583. });
  584. BMap.regeocoding({
  585. location: latlon,
  586. success: res => {
  587. let code = res.originalData.result.addressComponent.adcode.substr(0, 4)
  588. for (var i = 0; i < this.city.data.length; i++) {
  589. if (this.city.data[i].areaCode == code) {
  590. this.city.index = i
  591. break;
  592. }
  593. }
  594. console.log(res)
  595. },
  596. fail: err => {
  597. console.log(err)
  598. }
  599. })
  600. });
  601. // #endif
  602. },
  603. // get_paymentMsg() {
  604. // // maspStatus(1:待补缴,2:已补缴)realPredictServiceCost平台;maspAmount第三方
  605. // this.$api.base("post", "/chargeApi/queryOrderList-arrearage", {}, {}).then(res => {
  606. // this.payment_msg = res.data
  607. // })
  608. // },
  609. getBanners() {
  610. this.$api.base("get", "/applet/v1/homePage/getBannerList/1", {}, {}).then(res => {
  611. this.banners = res.data
  612. })
  613. },
  614. getAdswiper() {
  615. this.$api.base("get", "/applet/v1/homePage/getAdvertisingList", {}, {}).then(res => {
  616. this.adBanner = res.data
  617. // this.$refs.filter.open()
  618. })
  619. },
  620. convertBdToTx(lng, lat) {
  621. // 百度坐标系(BD09)转火星坐标系(GCJ-02,即腾讯地图使用的坐标系)
  622. // 这里的转换公式是基于经验公式,可能存在一定的误差
  623. let x_pi = 3.14159265358979324 * 3000.0 / 180.0;
  624. let x = lng - 0.0065;
  625. let y = lat - 0.006;
  626. let z = Math.sqrt(x * x + y * y) - 0.00002 * Math.sin(y * x_pi);
  627. let theta = Math.atan2(y, x) - 0.000003 * Math.cos(x * x_pi);
  628. let lngs = z * Math.cos(theta);
  629. let lats = z * Math.sin(theta);
  630. return {
  631. lng: lngs,
  632. lat: lats
  633. };
  634. },
  635. getStations(lng, lat) {
  636. this.$api.base("post", "/applet/v1/homePage/getStationInfoPage", {
  637. pageNum: this.pageNum,
  638. pageSize: 10,
  639. sortType: this.sorts.index + 1,
  640. longitude: lng,
  641. latitude: lat,
  642. userId: this.$app.storage.get('USER_INFO') ? parseInt(this.$app.storage.get('USER_INFO')
  643. .appletUserId) : 0
  644. }, {}).then(res => {
  645. if (this.pageNum == 1) {
  646. this.list.data = res.data.list
  647. } else {
  648. this.list.data = this.list.data.concat(res.data.list)
  649. }
  650. })
  651. },
  652. get_userinfo() {
  653. this.$api.base("get", "/applet/v1/user/getUserInfo", {}, {
  654. error: false
  655. }).then(res => {
  656. this.user_info = res.data
  657. this.$app.storage.set('USER_INFO', res.data);
  658. })
  659. },
  660. // 设定导航栏高度
  661. setAppNavigationHeight() {
  662. this.$nextTick(() => {
  663. uni.createSelectorQuery().in(this).select("#app-navigation").boundingClientRect(data => {
  664. this.appNavigationHeight = data.height;
  665. }).exec();
  666. });
  667. },
  668. // 设置列表高度
  669. setListHeight() {
  670. this.$app.act.selectorQuery(this, "#list-box,#roller", true).then(res => {
  671. const win = uni.getWindowInfo();
  672. const roller = res.find(i => i.id == 'roller');
  673. const list = res.find(i => i.id == 'list-box');
  674. this.list.height = win.windowHeight - list.top - this.appNavigationHeight + roller.height;
  675. });
  676. },
  677. // 版头加载完成
  678. bannerLoadCompleted() {
  679. this.setListHeight();
  680. },
  681. changeSort(index) {
  682. this.sorts.index = index;
  683. this.pageNum = 1
  684. this.getStations(this.location.value.split(',')[0], this.location.value.split(',')[1])
  685. },
  686. scrolltolower() {
  687. console.log('到底')
  688. this.pageNum++
  689. this.getStations(this.location.value.split(',')[0], this.location.value.split(',')[1])
  690. },
  691. gotoSiteDetail(item) {
  692. this.$app.url.goto('/subPackages/charging/new-site/new-site?item=' + JSON.stringify(item));
  693. },
  694. topage_coupon() {
  695. let payment = this.payment_msg.realPredictServiceCost + this.payment_msg.maspAmount
  696. this.$app.url.goto('/subPackages/coupon/coupon-buy/coupon-buy?payment=' + payment)
  697. },
  698. // 确认隐私协议
  699. agreePrivacyAuthorization() {
  700. this.privacy.visible = false;
  701. this.updateLocation();
  702. },
  703. // 打开隐私协议
  704. openPrivacyContract() {
  705. uni.openPrivacyContract();
  706. },
  707. // 拒绝隐私协议
  708. refusePrivacy() {
  709. this.privacy.visible = false;
  710. },
  711. convertGcj02ToBd09(lng, lat) {
  712. const x_pi = 3.14159265358979324 * 3000.0 / 180.0;
  713. const z = Math.sqrt(lng * lng + lat * lat) + 0.00002 * Math.sin(lat * x_pi);
  714. const theta = Math.atan2(lat, lng) + 0.000003 * Math.cos(lng * x_pi);
  715. const bd_lng = z * Math.cos(theta) + 0.0065;
  716. const bd_lat = z * Math.sin(theta) + 0.006;
  717. return {
  718. lng: bd_lng,
  719. lat: bd_lat
  720. };
  721. }
  722. }
  723. }
  724. </script>
  725. <style>
  726. @import url('index.css');
  727. .discount {
  728. flex: 1;
  729. text-align: right;
  730. padding-right: 5px;
  731. }
  732. .discount view {
  733. display: inline-flex;
  734. align-items: center;
  735. height: 22px;
  736. border: 1px solid #ccc;
  737. border-radius: 5px;
  738. font-size: 12px;
  739. color: #F59C79;
  740. padding: 0 7px;
  741. overflow: hidden;
  742. }
  743. </style>