123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194 |
- <template>
- <view class="studentWrapper">
- <view v-for="(item,index) in stuNeeds" :key="index" >
- <view class="studentList" @click="goDetail(item)">
- <view class="studentLeft">
- <view class="studentLeftTitle">
- <text>{{item.name}}<text style="font-weight: 400; margin-left: 4px">学员</text></text>
- </view>
- <view class="studentNeedCourse">
- <text>科目:</text>
- <text class="needCourse">{{item.subjectBig}}/{{item.subjectSmall}}</text>
- </view>
- <view class="studentExpect">
- <text>期望目标:</text>
- <text class="expect">{{item.goal}}</text>
- </view>
- </view>
- <view class="studentRight">
- <view class="studentRightTitle">
- <text>{{item.salary}}/小时</text>
- </view>
- <view class="studentSex">
- <text>{{item.sex}}</text>
- </view>
- <view class="studentRightTitle">
- <text>{{item.kil}}km</text>
- </view>
- </view>
- </view>
- </view>
-
- </view>
- </template>
- <script>
- import { mapState } from 'vuex'
-
- export default {
- computed: {
- ...mapState('m_user', ['location'])
- },
- data() {
- return {
- stuNeeds: [],
- queryObj: {
- pageNum: 1,
- pageSize: 8
- },
- total: 0,
- isloading: false
- };
- },
- created() {
- this.getAllStuNeeds()
- },
- methods: {
- async getAllStuNeeds(cb) {
- // 打开节流阀
- this.isloading = true
-
- // 发起请求
- const { data: result } = await uni.$http.get('/education/student-requirements/getAllRequirements', this.queryObj)
-
- // 关闭节流阀
- this.isloading = false
- // 只要数据请求完毕,就立即按需调用 cb 回调函数
- cb && cb()
-
- for (let i = 0; i < result.data.list.length; i++) {
- let arr = result.data.list[i].locationAl.split(",")
- let kil = this.space(arr[0], arr[1], this.location.latitude, this.location.longitude)
- result.data.list[i].kil = kil
- }
-
- // 新旧拼接
- this.stuNeeds = [...this.stuNeeds, ...result.data.list]
- this.total = result.data.total
-
- // console.log(result)
- },
- // 下拉刷新
- onPullDownRefresh() {
- if (this.isloading) return
-
- this.queryObj.pageNum = 1
- this.total = 0
- this.stuNeeds = []
- this.isloading = false
-
- this.getAllStuNeeds( () => uni.stopPullDownRefresh())
- },
- // 触底事件
- onReachBottom() {
- // 判断是否有下一页
- if (this.queryObj.pageNum * this.queryObj.pageSize >= this.total)
- return uni.$showMsg('数据加载完毕!')
-
- // 判断是否正在请求数据
- if (this.isloading) return
-
- this.queryObj.pageNum += 1
- this.getAllStuNeeds()
- },
- space(lat1, lng1, lat2, lng2) {
- // console.log(lat1, lng1, lat2, lng2)
- var radLat1 = lat1 * Math.PI / 180.0;
- var radLat2 = lat2 * Math.PI / 180.0;
- var a = radLat1 - radLat2;
- var b = lng1 * Math.PI / 180.0 - lng2 * Math.PI / 180.0;
- var s = 2 * Math.asin(Math.sqrt(Math.pow(Math.sin(a / 2), 2) +
- Math.cos(radLat1) * Math.cos(radLat2) * Math.pow(Math.sin(b / 2), 2)));
- s = s * 6378.137;
- s = Math.round(s * 10000) / 10000; // 单位千米
- return s.toFixed(2) // 保留两位小数
- },
- goDetail(item) {
- uni.navigateTo({
- url: '/subpkg/all_stu_require_detail/all_stu_require_detail?item=' + encodeURIComponent(JSON.stringify(item))
- })
- }
- }
- }
- </script>
- <style lang="scss">
- .studentWrapper{
- height: 100%;
- background-color: #E2F0D9;
- padding: 20rpx;
- }
- .studentList{
- display: flex;
- position: relative;
- /* border: 1rpx solid gray; */
- border-radius: 20rpx;
- background-color: #FFF2CC;
- margin-bottom: 20rpx;
- }
- /* 左侧部分 */
- .studentLeft{
- padding: 10rpx;
- font-weight: bold;
- font-size: 30rpx;
- }
- .studentLeftTitle,
- .studentExpect,
- .studentNeedCourse{
- padding: 6rpx 0;
- }
- /* 科目 */
- .studentNeedCourse{
- display: flex;
- }
- /* 期望目标 */
- .studentExpect{
- display: flex;
- font-weight: 400;
- font-size: 26rpx;
- }
- /* 期望目标和需求科目详情 */
- .needCourse,
- .expect{
- margin-left: 10rpx;
- width: 240rpx;
- display: block;
- white-space: nowrap;
- overflow: hidden;
- text-overflow: ellipsis;
- }
- /* 右侧部分定位 */
- .studentRight{
- position: absolute;
- left: 65%;
- color: #FF0000;
- font-size: 32rpx;
- }
- .studentRight,
- .studentSex{
- padding: 10rpx 0;
- }
- /* 设置性别的字体 */
- .studentSex{
- font-weight: bold;
- color: #00B050;
- }
- </style>
|