123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256 |
- <template>
- <view class="jpmain body">
- <componentLogin ref="refLogin" @findByOpenId="findByOpenId"></componentLogin>
- <view class="Area Area1">
- <view class="top">
- <view class="name">附近停车场</view>
- <view class="value" @click="getUserLocation()">
- <img class="img" src="@/assets/img/homepage/riLine-restart-line.png" alt="">
- 重新定位
- </view>
- </view>
- <view class="list">
- <view class="item" v-for="(item,i) in nearList"
- @click="gotoUrl('pages/index/main/parkingDetails?id='+item.id)">
- <view class="name">
- <img class="img" src="@/assets/img/homepage/stLine-location-l.svg" alt="">
- {{item.name}}
- </view>
- <view class="value">小于50米</view>
- </view>
- </view>
-
- <u-empty text="列表为空" mode="list" margin-top="80" v-if="!nearList.length">
- <view slot="bottom">
- <view class="value-slot" @click="getUserLocation()">
- <img class="img" src="@/assets/img/homepage/riLine-restart-line.png" alt="">
- 重新定位
- </view>
- </view>
- </u-empty>
- </view>
- <view class="Area Area2" v-if="otherList.length">
- <view class="top">
- <view class="name">全部停车场</view>
- </view>
- <view class="list">
- <view class="item" v-for="(item,i) in otherList" :key="i"
- @click="gotoUrl('pages/index/main/parkingDetails?id='+item.id)">
- <view class="name"> <img class="img" src="@/assets/img/homepage/stLine-location-l.svg" alt="">
- {{item.name}}
- </view>
- <view class="value">{{distanceN(item.distance)}}</view>
- </view>
- </view>
- </view>
- </view>
- </template>
- <script>
- import * as API from '@/apis/pagejs/index.js'
- import componentLogin from '@/components/componentLogin.vue';
- export default {
- components: {
- componentLogin,
- },
- data() {
- return {
- latitude: 30.337053,
- longitude: 112.240222,
-
- allList: [],
- point: false, //是否获取了定位
- }
- },
- onLoad() {
- this.userInfo = this.jphelp.getPersonInfo()
- this.getParkingList()
- },
- onReady() {
- this.$refs.refLogin.findByOpenId()
- },
- computed: {
- otherList() {
- var sz = []
- for (var i in this.allList) {
- var item = this.allList[i]
- if (this.point) {
- if (item.distance > 1) {
- sz.push(item)
- }
- } else {
- sz.push(item)
- }
- }
- return sz
- },
- nearList() {
- var sz = []
- for (var i in this.allList) {
- var item = this.allList[i]
- if (this.point) {
- if (item.distance < 1) {
- sz.push(item)
- }
- } else {
- }
- }
- return sz
- }
- },
- methods: {
- getParkingList() {
- uni.showLoading({
- title: "加载中",
- mask: true,
- })
- var obj = {
- pageIndex: 1,
- pageSize: 20,
- radius: 50,
- }
- if (this.point) {
- obj.longitude = this.longitude
- obj.latitude = this.latitude
- }
- API.parkingList(obj).then((res) => {
- this.allList = res.data.data
- console.log(this.nearList)
- uni.hideLoading();
- }).catch(error => {
- uni.hideLoading();
- uni.showToast({
- title: error,
- icon: "none"
- })
- })
- },
- findByOpenId(res) {
- },
- getUserLocation() {
- uni.authorize({
- scope: 'scope.userLocation',
- success() {
- uni.getLocation({
- type: 'wgs84',
- success: function(res) {
- console.log('当前位置的经度:' + res.longitude);
- console.log('当前位置的纬度:' + res.latitude);
- }
- });
- }
- })
- }
- }
- }
- </script>
- <style scoped lang="scss">
- .body {
- padding: 32rpx;
- }
-
- .value-slot {
- color: rgba(22, 119, 255, 1);
- font-size: 24rpx;
- display: flex;
- align-items: center;
-
- .img {
- width: 28rpx;
- height: 28rpx;
- }
- }
- .Area {
- .img {
- margin: 0 8rpx;
- }
- margin-bottom: 32rpx;
- .top {
- margin-bottom: 8rpx;
- display: flex;
- justify-content: space-between;
- .name {
- color: rgba(51, 51, 51, 1);
- font-size: 32rpx;
- font-weight: bold;
- }
- .value {
- color: rgba(22, 119, 255, 1);
- font-size: 24rpx;
- display: flex;
- align-items: center;
- .img {
- width: 28rpx;
- height: 28rpx;
- }
- }
- }
- .list {
- .item {
- display: flex;
- justify-content: space-between;
- padding: 16rpx 0;
- .name {
- color: rgba(51, 51, 51, 1);
- font-size: 32rpx;
- display: flex;
- align-items: center;
- .img {
- width: 32rpx;
- height: 32rpx;
- }
- }
- .value {
- color: rgba(119, 119, 119, 1);
- font-size: 28rpx;
- }
- }
- }
- }
- .Area2 {
- .list {
- .item {
- border-bottom: 1px solid rgba(232, 232, 232, 1);
- ;
- }
- }
- }
- </style>
|