Browse Source

feat(student): 体育馆列表功能- 新增体育馆列表接口和相关页面

- 实现用户定位和计算距离功能
- 优化列表展示,增加距离显示
- 添加跳转到课程列表的功能
- 更新小程序配置,增加定位权限
master
liutong 1 year ago
parent
commit
d74f295e5b
  1. 8
      api/member.js
  2. 7
      manifest.json
  3. 6
      pages/student/timetable/index.vue
  4. 230
      pages/student/timetable/list.vue

8
api/member.js

@ -67,6 +67,14 @@ export default {
}) })
}, },
//场地列表
venuesList(data) {
let url = '/member/venues_list'
return http.get(url, data).then(res => {
return res;
})
},
} }

7
manifest.json

@ -62,7 +62,7 @@
"quickapp" : {}, "quickapp" : {},
/* */ /* */
"mp-weixin" : { "mp-weixin" : {
"appid" : "wx42762c713f7bfa2e", "appid" : "wx675f2696abf932c5",
"setting" : { "setting" : {
"urlCheck" : false, "urlCheck" : false,
"minified" : true, "minified" : true,
@ -74,7 +74,10 @@
"desc" : "你的位置信息将用于小程序位置接口的效果展示" "desc" : "你的位置信息将用于小程序位置接口的效果展示"
} }
}, },
"requiredPrivateInfos" : [ "getFuzzyLocation" ] "requiredPrivateInfos": [
"getLocation",
"chooseLocation"
]
}, },
"mp-alipay" : { "mp-alipay" : {
"usingComponents" : true "usingComponents" : true

6
pages/student/timetable/index.vue

@ -110,7 +110,7 @@ export default {
// //
today: '', today: '',
dateList: []// dateList: [],//
} }
}, },
onLoad(options) { onLoad(options) {
@ -248,8 +248,10 @@ export default {
}, },
// //
more() { more() {
let schedule_date = this.filteredData.schedule_date
let venue_id = this.venuesInfo.id//id
uni.navigateTo({ uni.navigateTo({
url: '/pages/student/timetable/list' url: `/pages/student/timetable/list?schedule_date=${schedule_date}&venue_id=${venue_id}`
}) })
} }
} }

230
pages/student/timetable/list.vue

@ -4,122 +4,18 @@
<scroll-view scroll-y="true" :lower-threshold="lowerThreshold" <scroll-view scroll-y="true" :lower-threshold="lowerThreshold"
@scrolltolower="loadMoreData" style="height: 100vh;"> @scrolltolower="loadMoreData" style="height: 100vh;">
<view class="main_section"> <view class="main_section" v-for="(v,k) in tableList" :key="k" @click="opebViewTimetable(v)">
<view class="title">XXX体育馆</view> <view class="title">{{v.name}}</view>
<view class="con">南山区科苑路15号科兴科学园</view> <view class="con">{{v.address}}</view>
<view class="con">距您1km</view> <view class="con" v-if="v.distance === null ">无法获取定位</view>
<view class="current-venue" v-if="true"> <view class="con" v-else-if="v.distance">距您{{v.distance}}km</view>
<view class="current-venue" v-if="venue_id == v.id">
当前场馆 当前场馆
</view> </view>
</view> </view>
<view class="main_section">
<view class="title">XXX体育馆</view>
<view class="con">南山区科苑路15号科兴科学园</view>
<view class="con">距您1km</view>
<view class="current-venue" v-if="true">
当前场馆
</view>
</view>
<view class="main_section">
<view class="title">XXX体育馆</view>
<view class="con">南山区科苑路15号科兴科学园</view>
<view class="con">距您1km</view>
<view class="current-venue" v-if="true">
当前场馆
</view>
</view>
<view class="main_section">
<view class="title">XXX体育馆</view>
<view class="con">南山区科苑路15号科兴科学园</view>
<view class="con">距您1km</view>
<view class="current-venue" v-if="true">
当前场馆
</view>
</view>
<view class="main_section">
<view class="title">XXX体育馆</view>
<view class="con">南山区科苑路15号科兴科学园</view>
<view class="con">距您1km</view>
<view class="current-venue" v-if="true">
当前场馆
</view>
</view>
<view class="main_section">
<view class="title">XXX体育馆</view>
<view class="con">南山区科苑路15号科兴科学园</view>
<view class="con">距您1km</view>
<view class="current-venue" v-if="true">
当前场馆
</view>
</view>
<view class="main_section">
<view class="title">XXX体育馆</view>
<view class="con">南山区科苑路15号科兴科学园</view>
<view class="con">距您1km</view>
<view class="current-venue" v-if="true">
当前场馆
</view>
</view>
<view class="main_section">
<view class="title">XXX体育馆</view>
<view class="con">南山区科苑路15号科兴科学园</view>
<view class="con">距您1km</view>
<view class="current-venue" v-if="true">
当前场馆
</view>
</view>
</scroll-view> </scroll-view>
<!-- 加载状态--> <!-- 加载状态-->
<fui-loading :isFixed="true" srcCol="/static/icon-img/loading_white.png" text="正在加载..." v-if="loading"></fui-loading> <!-- <fui-loading :isFixed="true" srcCol="/static/icon-img/loading_white.png" text="正在加载..." v-if="loading"></fui-loading>-->
<!-- <view class="main_section">-->
<!-- <view class="title">XXX体育馆</view>-->
<!-- <view class="con">南山区科苑路15号科兴科学园</view>-->
<!-- <view class="con">距您1km</view>-->
<!-- </view>-->
<!-- <view class="main_section">-->
<!-- <view class="title">XXX体育馆</view>-->
<!-- <view class="con">南山区科苑路15号科兴科学园</view>-->
<!-- <view class="con">距您1km</view>-->
<!-- </view>-->
<!-- <view class="main_section">-->
<!-- <view class="title">XXX体育馆</view>-->
<!-- <view class="con">南山区科苑路15号科兴科学园</view>-->
<!-- <view class="con">距您1km</view>-->
<!-- </view>-->
<!-- <view class="main_section">-->
<!-- <view class="title">XXX体育馆</view>-->
<!-- <view class="con">南山区科苑路15号科兴科学园</view>-->
<!-- <view class="con">距您1km</view>-->
<!-- </view>-->
<!-- <view class="main_section">-->
<!-- <view class="title">XXX体育馆</view>-->
<!-- <view class="con">南山区科苑路15号科兴科学园</view> -->
<!-- <view class="con">距您1km</view>-->
<!-- </view>-->
<!-- <view class="main_section">-->
<!-- <view class="title">XXX体育馆</view>-->
<!-- <view class="con">南山区科苑路15号科兴科学园</view>-->
<!-- <view class="con">距您1km</view>-->
<!-- </view>-->
<!-- <view class="main_section">-->
<!-- <view class="title">XXX体育馆</view>-->
<!-- <view class="con">南山区科苑路15号科兴科学园</view>-->
<!-- <view class="con">距您1km</view>-->
<!-- </view>-->
<!-- <view class="main_section">-->
<!-- <view class="title">XXX体育馆</view>-->
<!-- <view class="con">南山区科苑路15号科兴科学园</view>-->
<!-- <view class="con">距您1km</view>-->
<!-- </view>-->
<!-- <view class="main_section">-->
<!-- <view class="title">XXX体育馆</view>-->
<!-- <view class="con">南山区科苑路15号科兴科学园</view>-->
<!-- <view class="con">距您1km</view>-->
<!-- </view>-->
</view> </view>
</template> </template>
@ -140,29 +36,92 @@
// //
filteredData:{ filteredData:{
page:1,// // page:1,//
limit:10,// // limit:10,//
total:10,// // total:10,//
schedule_date:'',//
}, },
tableList:[],// tableList:[],//
longitude:'',//
latitude:'',//
venue_id:'',//id
} }
}, },
onLoad() {}, onLoad(options) {
this.filteredData.schedule_date = options.schedule_date//
//id
this.venue_id = options.venue_id || ''
},
onShow() { onShow() {
this.init()// this.init()//
}, },
methods: { methods: {
// //
async init() { async init() {
await this.getList() await this.getUserLocation();
await this.getList();
},
//
async getUserLocation() {
try {
const location = await this.getLocation();
this.longitude = location.longitude;
this.latitude = location.latitude;
} catch (error) {
console.log(error);
uni.showToast({
title: '获取位置失败',
icon: 'none'
});
// throw error; // 便 init
}
},
// uni.getLocation Promise
getLocation() {
return new Promise((resolve, reject) => {
uni.getLocation({
type: 'wgs84',
success: (res) => {
console.log('当前位置的经度:' + res.longitude);
console.log('当前位置的纬度:' + res.latitude);
resolve(res);
},
fail: (err) => {
console.log(err);
reject(err);
}
});
});
}, },
//() //
getDistance(lat1, lng1, lat2, lng2) {
const R = 6371; //
const dLat = this.deg2rad(lat2 - lat1);
const dLon = this.deg2rad(lng2 - lng1);
const a =
Math.sin(dLat / 2) * Math.sin(dLat / 2) +
Math.cos(this.deg2rad(lat1)) * Math.cos(this.deg2rad(lat2)) *
Math.sin(dLon / 2) * Math.sin(dLon / 2);
const c = 2 * Math.atan2(Math.sqrt(a), Math.sqrt(1 - a));
const distance = R * c; //
return distance.toFixed(2); //
},
//
deg2rad(deg) {
return deg * (Math.PI / 180);
},
//()
loadMoreData() { loadMoreData() {
return //
// //
if (!this.isReachedBottom) { if (!this.isReachedBottom) {
this.isReachedBottom = true;// this.isReachedBottom = true;//
@ -176,7 +135,7 @@
}, 1000); }, 1000);
}, },
// //
async getList(){ async getList(){
this.loading = true this.loading = true
@ -192,7 +151,7 @@
return return
} }
let res = await memberApi.courseList(data) let res = await memberApi.venuesList(data)
this.loading = false this.loading = false
this.isReachedBottom = false; this.isReachedBottom = false;
if (res.code != 1){ if (res.code != 1){
@ -203,11 +162,34 @@
return return
} }
this.tableList = res.data.data this.tableList = res.data
this.total = res.data.total
this.page++ this.tableList.forEach((v,k)=>{
if(this.longitude && this.latitude && v.longitude && v.latitude){
v.distance = this.getDistance(this.latitude, this.longitude, v.latitude, v.longitude)
}else{
v.distance = null
}
})
console.log('列表',this.tableList)
},
//-
opebViewTimetable(item) {
let venue_id = item.id
uni.navigateTo({
url: `/pages/student/timetable/index?venue_id=${venue_id}`
})
}, },
} }
} }
</script> </script>

Loading…
Cancel
Save