123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374 |
- <template>
- <view class="jpmain body">
- <componentLogin ref="refLogin" :check="0"
- @findByOpenId="findByOpenId"></componentLogin>
- <view class="Area Area1" v-if="pointAuthorize">
- <view class="top">
- <view class="name">附近停车场</view>
- <view class="value" @click="getUserLocation()">
- <img class="img" src="@/assets/img/homepage/riLine-restart-line.svg" alt="">
- 重新定位
- </view>
- </view>
- <view class="list">
- <view class="line" v-for="(item,i) in nearList"
- @click="gotoInfo(item)">
-
- <view class="itembody">
- <view class="itemhead">
- <img class="img" src="@/assets/img/index.png" alt="">
- </view>
- <view class="item" >
- <view class="name">
-
- {{item.name}}
- <span class="tag" v-if="item.userPreferred"> <u-icon name="star-fill" color="#FFAE00" size="24"></u-icon> 常用 </span>
-
- </view>
- <view class="item2" >
- 车位共<span style="color:#333">{{item.totalNum}}</span>个 | 空闲<span style="color:#8BC34A">{{item.idleNum}}</span>个
- </view>
- </view>
-
- </view>
-
- <view class="value">小于50米
- <u-icon name="arrow-right" color="#CCCCCC"></u-icon>
- </view>
- </view>
- </view>
-
- <u-empty text="50米内没有停车场" 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.svg" 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="line" v-for="(item,i) in otherList" :key="i"
- @click="gotoInfo(item)">
-
-
- <view class="itembody">
- <view class="itemhead">
- <img class="img" src="@/assets/img/index.png" alt="">
- </view>
- <view class="item" >
- <view class="name">
-
- {{item.name}}
- <span class="tag" v-if="item.userPreferred" > <u-icon name="star-fill" color="#FFAE00" size="24"></u-icon> 常用 </span>
- </view>
- <view class="item2" >
- 车位共<span style="color:#333">{{item.totalNum}}</span>个 | 空闲<span style="color:#8BC34A">{{item.idleNum}}</span>个
- </view>
- </view>
-
- </view>
- <view class="value" v-if="item.distance" >{{distanceN(item.distance)}}<u-icon name="arrow-right" color="#CCCCCC"></u-icon></view>
-
-
- </view>
- </view>
- </view>
- <tabbar ></tabbar>
- </view>
- </template>
- <script>
- import * as API from '@/apis/pagejs/index.js'
- import componentLogin from '@/components/componentLogin.vue';
- import tabbar from '@/components/Tabbar.vue';
-
- export default {
- components: {
- componentLogin,tabbar,
- },
- data() {
- return {
- pointAuthorize:true,
- latitude: 30.337053,
- longitude: 112.240222,
-
- allList: [],
- isReady:true,
- point: false, //是否获取了定位
- }
- },
- onLoad() {
- this.userInfo = this.jphelp.getPersonInfo()
-
- },
- onReady() {
- this.$refs.refLogin.findByOpenId()
- //this.getParkingList()
-
- },
- onShow() {
- if(this.isReady){
- if(this.point){
- // #ifdef MP-WEIXIN
- this.getUserLocation()
- // #endif
- }else{
- this.getParkingList()
- }
-
- }
- },
- onShareTimeline(){
- return {
- title: '智泊e家',
- path: '/pages/index/index' ,
- }
- },
- onShareAppMessage(res) {
- if (res.from === 'button') { // 来自页面内分享按钮
- //.log(res.target)
- }
- return {
- title: '智泊e家',
- path: '/pages/index/index'
- }
- },
- 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: {
- gotoInfo(item){
- var url='pages/index/main/parkingDetails?id='+item.id;
- if (this.point) {
- url+=`&point=1&longitude=${this.longitude}&latitude=${this.latitude}`
- }
- this.gotoUrl(url)
- },
- 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) {
- this.isReady=true
- // #ifdef MP-WEIXIN
- this.getUserLocation()
- // #endif
-
- this.getParkingList()
-
- },
- getUserLocation() {
- var _this=this
- uni.authorize({
- scope: 'scope.userLocation',
- success() {
- uni.getLocation({
- type: 'gcj02',
- altitude:true,
- isHighAccuracy:true,
- success: function(res) {
-
- console.log('当前位置的经度:' + res.longitude);
- console.log('当前位置的纬度:' + res.latitude);
- _this.point=true
- _this.longitude=res.longitude
- _this.latitude=res.latitude
- _this.getParkingList()
- }
- });
- }
- })
- }
- }
- }
- </script>
- <style scoped lang="scss">
- .body {
- padding: 32rpx;
- padding-top:40rpx;
- }
-
- .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 {
- .line{
- display: flex;
- align-items: center;
- justify-content: space-between;
- .itemhead{
- display: flex;
- .img {
- width: 48rpx;
- height: 48rpx;
- }
- }
- .itembody{
- padding: 16rpx 0;
-
- display: flex;
- align-items: center;
- }
- .item {
- display: flex;
- flex-direction: column;
- padding-left: 16rpx;
- .name {
- color: rgba(51, 51, 51, 1);
- font-size: 32rpx;
- display: flex;
- align-items: center;
- padding-bottom: 8rpx;
-
- .tag{
- font-size: 24rpx;
- color: rgba(255,174,0,1);
- border: 1px solid rgba(255,174,0,1);
- padding: 1px 8rpx;
- border-radius: 4px;
- margin-left: 8rpx;
- }
-
- }
-
- .value {
- color: rgba(119, 119, 119, 1);
-
- font-size: 28rpx;
- }
- }
- .item2{
-
- color: rgba(119, 119, 119, 1);
-
- font-size: 24rpx;
-
- }
- }
-
- }
- }
- .Area2 {
- margin-top: 40rpx;
- .list {
- .line {
- border-bottom: 1px solid rgba(232, 232, 232, 1);
- ;
- }
- }
- }
- </style>
|