index.vue 22 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745
  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.connectorCode + "&deviceStatus=" + res.data
  427. .status);
  428. })
  429. },
  430. getQueryParams(url, key) {
  431. const queryString = url.split('?')[1] || '';
  432. const params = {};
  433. const pairs = queryString.split('&');
  434. pairs.forEach(pair => {
  435. const [key, value] = pair.split('=');
  436. params[decodeURIComponent(key)] = decodeURIComponent(value || '');
  437. });
  438. return params[key];
  439. },
  440. // 校验用户是否绑定车牌
  441. queryUserIsBindCard(){
  442. this.$api.base("get", "/applet/v1/vehicle/list", {}, {}).then(res => {
  443. if(res.data.length <1){
  444. this.$app.popup.confirm("绑定车牌享更多权益","充电车主专享").then(confirm => {
  445. if (confirm) {
  446. this.$app.url.goto('/subPackages/other/addLicensePlates/addLicensePlates');
  447. }
  448. });
  449. }
  450. })
  451. },
  452. goImgLink(e) {
  453. this.$app.url.goto(e.skipUrl);
  454. },
  455. // 打开客服
  456. customerService() {
  457. const cs = this.$config.customerService;
  458. this.$app.act.customerService(cs.id, cs.url).catch(err => {
  459. console.log(err);
  460. this.$app.popup.alert('客服中心失联啦,请联系管理员!');
  461. });
  462. },
  463. // 查询许可
  464. queryPermit() {
  465. return new Promise((resolve, reject) => {
  466. const data = {};
  467. const check = () => {
  468. if (Object.keys(data).length == 2) resolve(data);
  469. }
  470. // #ifndef H5
  471. if (uni.getPrivacySetting) {
  472. uni.getPrivacySetting({
  473. success: res => {
  474. data.privacy = res.needAuthorization;
  475. },
  476. complete: () => {
  477. if (typeof data.privacy != 'boolean' && typeof data.privacy !=
  478. 'undefined') data.privacy = null;
  479. check();
  480. },
  481. });
  482. } else {
  483. data.privacy = false;
  484. }
  485. // #endif
  486. // #ifdef H5
  487. data.privacy = false;
  488. // #endif
  489. // #ifdef MP-WEIXIN
  490. uni.getSetting({
  491. success: res => {
  492. data.location = uni.getLocation ? res.authSetting['scope.userLocation'] :
  493. undefined;
  494. },
  495. complete: () => {
  496. if (typeof data.location != 'boolean' && typeof data.location !=
  497. 'undefined') data.location = null;
  498. check();
  499. },
  500. })
  501. // #endif
  502. // #ifdef H5
  503. data.location = true;
  504. check();
  505. // #endif
  506. });
  507. },
  508. // 更新位置
  509. updateLocation() {
  510. this.getLocation().then(res => {
  511. this.location.value = [res.longitude, res.latitude].join(',');
  512. this.get_userinfo()
  513. this.getStations(res.longitude, res.latitude)
  514. this.$app.storage.set('USER_LOCATION', this.location.value);
  515. return this.reverseGeocoder([res.latitude, res.longitude].join(','))
  516. });
  517. },
  518. // 获取定位
  519. getLocation() {
  520. return new Promise((resolve, reject) => {
  521. // #ifdef H5
  522. // H5环境下使用浏览器定位API
  523. if (navigator.geolocation) {
  524. navigator.geolocation.getCurrentPosition(
  525. (position) => {
  526. resolve({
  527. longitude: position.coords.longitude,
  528. latitude: position.coords.latitude
  529. });
  530. },
  531. (error) => {
  532. console.log('H5定位失败', error);
  533. this.getStations("", "");
  534. this.get_userinfo()
  535. }
  536. );
  537. } else {
  538. console.log('浏览器不支持定位');
  539. resolve({ longitude: '', latitude: '' });
  540. }
  541. // #endif
  542. // #ifndef H5
  543. if (uni.getLocation) {
  544. uni.getLocation({
  545. success: res => resolve(res),
  546. fail: err => {
  547. console.log(err)
  548. console.log('定位失败');
  549. this.getStations("", "")
  550. this.get_userinfo()
  551. }
  552. })
  553. } else {
  554. console.log('微信版本太低,无定位接口可用');
  555. resolve({ longitude: '', latitude: '' });
  556. }
  557. // #endif
  558. });
  559. },
  560. reverseGeocoder(latlon) {
  561. // #ifdef H5
  562. // H5环境跳过百度地图处理
  563. console.log('H5环境跳过百度地图处理');
  564. return Promise.resolve();
  565. // #endif
  566. // #ifndef H5
  567. console.log(latlon)
  568. let lat = latlon.split(",")[0]
  569. let lng = latlon.split(",")[1]
  570. let baiduLoc = this.convertGcj02ToBd09(lng, lat)
  571. latlon = baiduLoc.lat + "," + baiduLoc.lng
  572. console.log(latlon)
  573. return new Promise((resolve, reject) => {
  574. var BMap = new bmap.BMapWX({
  575. ak: 'vtQgaPzonb3H4qeUOWGr53ePcNCsmdMj'
  576. });
  577. BMap.regeocoding({
  578. location: latlon,
  579. success: res => {
  580. let code = res.originalData.result.addressComponent.adcode.substr(0, 4)
  581. for (var i = 0; i < this.city.data.length; i++) {
  582. if (this.city.data[i].areaCode == code) {
  583. this.city.index = i
  584. break;
  585. }
  586. }
  587. console.log(res)
  588. },
  589. fail: err => {
  590. console.log(err)
  591. }
  592. })
  593. });
  594. // #endif
  595. },
  596. // get_paymentMsg() {
  597. // // maspStatus(1:待补缴,2:已补缴)realPredictServiceCost平台;maspAmount第三方
  598. // this.$api.base("post", "/chargeApi/queryOrderList-arrearage", {}, {}).then(res => {
  599. // this.payment_msg = res.data
  600. // })
  601. // },
  602. getBanners() {
  603. this.$api.base("get", "/applet/v1/homePage/getBannerList/1", {}, {}).then(res => {
  604. this.banners = res.data
  605. })
  606. },
  607. getAdswiper() {
  608. this.$api.base("get", "/applet/v1/homePage/getAdvertisingList", {}, {}).then(res => {
  609. this.adBanner = res.data
  610. // this.$refs.filter.open()
  611. })
  612. },
  613. convertBdToTx(lng, lat) {
  614. // 百度坐标系(BD09)转火星坐标系(GCJ-02,即腾讯地图使用的坐标系)
  615. // 这里的转换公式是基于经验公式,可能存在一定的误差
  616. let x_pi = 3.14159265358979324 * 3000.0 / 180.0;
  617. let x = lng - 0.0065;
  618. let y = lat - 0.006;
  619. let z = Math.sqrt(x * x + y * y) - 0.00002 * Math.sin(y * x_pi);
  620. let theta = Math.atan2(y, x) - 0.000003 * Math.cos(x * x_pi);
  621. let lngs = z * Math.cos(theta);
  622. let lats = z * Math.sin(theta);
  623. return {
  624. lng: lngs,
  625. lat: lats
  626. };
  627. },
  628. getStations(lng, lat) {
  629. this.$api.base("post", "/applet/v1/homePage/getStationInfoPage", {
  630. pageNum: this.pageNum, pageSize: 10, sortType: this.sorts.index + 1, longitude: lng, latitude: lat, userId: this.$app.storage.get('USER_INFO') ? parseInt(this.$app.storage.get('USER_INFO').appletUserId) : 0
  631. }, {}).then(res => {
  632. if (this.pageNum == 1) {
  633. this.list.data = res.data.list
  634. } else {
  635. this.list.data = this.list.data.concat(res.data.list)
  636. }
  637. })
  638. },
  639. get_userinfo() {
  640. this.$api.base("get", "/applet/v1/user/getUserInfo", {}, {
  641. error: false
  642. }).then(res => {
  643. this.user_info = res.data
  644. this.$app.storage.set('USER_INFO', res.data);
  645. })
  646. },
  647. // 设定导航栏高度
  648. setAppNavigationHeight() {
  649. this.$nextTick(() => {
  650. uni.createSelectorQuery().in(this).select("#app-navigation").boundingClientRect(data => {
  651. this.appNavigationHeight = data.height;
  652. }).exec();
  653. });
  654. },
  655. // 设置列表高度
  656. setListHeight() {
  657. this.$app.act.selectorQuery(this, "#list-box,#roller", true).then(res => {
  658. const win = uni.getWindowInfo();
  659. const roller = res.find(i => i.id == 'roller');
  660. const list = res.find(i => i.id == 'list-box');
  661. this.list.height = win.windowHeight - list.top - this.appNavigationHeight + roller.height;
  662. });
  663. },
  664. // 版头加载完成
  665. bannerLoadCompleted() {
  666. this.setListHeight();
  667. },
  668. changeSort(index) {
  669. this.sorts.index = index;
  670. this.pageNum = 1
  671. this.getStations(this.location.value.split(',')[0], this.location.value.split(',')[1])
  672. },
  673. scrolltolower() {
  674. console.log('到底')
  675. this.pageNum++
  676. this.getStations(this.location.value.split(',')[0], this.location.value.split(',')[1])
  677. },
  678. gotoSiteDetail(item) {
  679. this.$app.url.goto('/subPackages/charging/new-site/new-site?item=' + JSON.stringify(item));
  680. },
  681. topage_coupon() {
  682. let payment = this.payment_msg.realPredictServiceCost + this.payment_msg.maspAmount
  683. this.$app.url.goto('/subPackages/coupon/coupon-buy/coupon-buy?payment=' + payment)
  684. },
  685. // 确认隐私协议
  686. agreePrivacyAuthorization() {
  687. this.privacy.visible = false;
  688. this.updateLocation();
  689. },
  690. // 打开隐私协议
  691. openPrivacyContract() {
  692. uni.openPrivacyContract();
  693. },
  694. // 拒绝隐私协议
  695. refusePrivacy() {
  696. this.privacy.visible = false;
  697. },
  698. convertGcj02ToBd09(lng, lat) {
  699. const x_pi = 3.14159265358979324 * 3000.0 / 180.0;
  700. const z = Math.sqrt(lng * lng + lat * lat) + 0.00002 * Math.sin(lat * x_pi);
  701. const theta = Math.atan2(lat, lng) + 0.000003 * Math.cos(lng * x_pi);
  702. const bd_lng = z * Math.cos(theta) + 0.0065;
  703. const bd_lat = z * Math.sin(theta) + 0.006;
  704. return {
  705. lng: bd_lng,
  706. lat: bd_lat
  707. };
  708. }
  709. }
  710. }
  711. </script>
  712. <style>
  713. @import url('index.css');
  714. .discount {
  715. flex: 1;
  716. text-align: right;
  717. padding-right: 5px;
  718. }
  719. .discount view {
  720. display: inline-flex;
  721. align-items: center;
  722. height: 22px;
  723. border: 1px solid #ccc;
  724. border-radius: 5px;
  725. font-size: 12px;
  726. color: #F59C79;
  727. padding: 0 7px;
  728. overflow: hidden;
  729. }
  730. </style>