|
|
<template>
|
|
|
<view>
|
|
|
<view class="listActivity">
|
|
|
<u-empty mode="list" text="暂无活动" marginTop="50" v-if="list.length==0&&!isloading"></u-empty>
|
|
|
<view class="activityBox" v-for="(item,index) in list" :key="index" @click="openInfo(item)">
|
|
|
<view class="activityBox-top">
|
|
|
<image :src='item.cover_upload.url' style="width: 100%;height: 333rpx;"></image>
|
|
|
<view class="book-status">
|
|
|
{{item.rate_name}}
|
|
|
</view>
|
|
|
<!-- <view class="book-num" v-if="item.orders_count>0">
|
|
|
<text class="book-num-y"> {{isUnde(item.orders_count)}} </text>
|
|
|
<text>人已报名</text>
|
|
|
</view> -->
|
|
|
</view>
|
|
|
<view class="activityBox-content flex-col">
|
|
|
<view class="activityBox-row">
|
|
|
<text class="activityBox-title">{{isUnde(item.name)}}</text>
|
|
|
</view>
|
|
|
<view class="activityBox-row flex-row justify-between">
|
|
|
<view :class="item.type_name?'tag tag_green activityBox_btn':''">
|
|
|
<text>{{isUnde(item.type_name)}}</text>
|
|
|
</view>
|
|
|
<block v-if="item.orders_count==item.total&&item.orders_count!=0">
|
|
|
<view class="tag" v-if="item.isCanBook">
|
|
|
<text>已约满</text>
|
|
|
</view>
|
|
|
<view class="tag" v-else>
|
|
|
<text>{{item.rate_name}}</text>
|
|
|
</view>
|
|
|
</block>
|
|
|
<block v-else>
|
|
|
<view class="tag" :class="{activityBox_btn:item.isCanBook}">
|
|
|
<text>{{item.isCanBook?"立即报名":"已结束"}}</text>
|
|
|
</view>
|
|
|
</block>
|
|
|
</view>
|
|
|
|
|
|
<view class="activityBox-row" style="display: flex;">
|
|
|
<view style="display: inline-block;">
|
|
|
<text class="icon-shijian iconfont"></text>活动场次:
|
|
|
</view>
|
|
|
<view style="display: flex;flex-direction: column;">
|
|
|
<block v-for="(k,index) in item.numbers">
|
|
|
<view v-if="index<2" class="tag tag_green activityBox_btn activityBox_time" style="margin-top: -5px;margin-bottom: 10px;">
|
|
|
<text style="margin-right:12rpx">
|
|
|
{{timeFormat(k.start_time,"MM月DD日")}}
|
|
|
</text>
|
|
|
<text>
|
|
|
{{getHm(k.start_time)}}-{{getHm(k.end_time)}}
|
|
|
</text>
|
|
|
</view>
|
|
|
</block>
|
|
|
|
|
|
</view>
|
|
|
|
|
|
<view v-if="item.numbers.length>2"
|
|
|
class="activityMore">
|
|
|
更多>>
|
|
|
</view>
|
|
|
</view>
|
|
|
<!-- <view class="activityBox-row">
|
|
|
<text class="icon-huodongfangshi iconfont"></text>
|
|
|
<text>活动方式:{{isUnde(item.area_name)}}</text>
|
|
|
|
|
|
</view> -->
|
|
|
<view class="activityBox-row">
|
|
|
<text class="icon-huodong iconfont"></text>
|
|
|
<text>活动地址:{{isUnde(item.address)}}</text>
|
|
|
</view>
|
|
|
|
|
|
<!-- <view class="activityBox-row">
|
|
|
<text class="icon-renshu iconfont"></text>
|
|
|
<text>人数限制:{{isUnde(item.total)==0?'不限':isUnde(item.total)}}</text>
|
|
|
</view> -->
|
|
|
<view class="activityBox-row flex-row align-center" style="margin-bottom: 0rpx;"
|
|
|
@click.stop="tothere(item)">
|
|
|
<text class="icon-ditu-dibiao iconfont"></text>
|
|
|
<text>距离:{{isUnde(item.distance)}}km</text>
|
|
|
<view class="tomap">
|
|
|
<text class="icon-daohang1 iconfont" style="margin-right: 0;"></text>
|
|
|
</view>
|
|
|
</view>
|
|
|
|
|
|
</view>
|
|
|
</view>
|
|
|
</view>
|
|
|
</view>
|
|
|
</template>
|
|
|
|
|
|
<script>
|
|
|
export default {
|
|
|
data() {
|
|
|
return {
|
|
|
showInfo: true,
|
|
|
list: [],
|
|
|
latitude: "",
|
|
|
longitude: "",
|
|
|
isloading: true,
|
|
|
locationError: false // 定位是否失败
|
|
|
}
|
|
|
},
|
|
|
onLoad() {
|
|
|
var that = this;
|
|
|
|
|
|
// 检测运行环境
|
|
|
const isH5 = typeof window !== 'undefined' && window.location
|
|
|
|
|
|
if (isH5) {
|
|
|
// H5环境:使用浏览器定位API
|
|
|
if (navigator.geolocation) {
|
|
|
navigator.geolocation.getCurrentPosition(
|
|
|
function(position) {
|
|
|
that.latitude = position.coords.latitude;
|
|
|
that.longitude = position.coords.longitude;
|
|
|
console.log('定位成功:', that.latitude, that.longitude);
|
|
|
that.loadActivity()
|
|
|
},
|
|
|
function(error) {
|
|
|
console.log('定位失败:', error);
|
|
|
that.locationError = true;
|
|
|
// 定位失败时仍然加载活动列表
|
|
|
that.loadActivity()
|
|
|
},
|
|
|
{
|
|
|
enableHighAccuracy: true,
|
|
|
timeout: 15000, // 增加超时时间到15秒
|
|
|
maximumAge: 300000 // 缓存5分钟
|
|
|
}
|
|
|
);
|
|
|
} else {
|
|
|
console.log('浏览器不支持定位');
|
|
|
that.loadActivity()
|
|
|
}
|
|
|
} else {
|
|
|
// 小程序环境:使用wx.getLocation
|
|
|
wx.getLocation({
|
|
|
success(res) {
|
|
|
console.log(res)
|
|
|
that.latitude = res.latitude;
|
|
|
that.longitude = res.longitude;
|
|
|
that.loadActivity()
|
|
|
},
|
|
|
fail(err) {
|
|
|
console.log('定位失败:', err);
|
|
|
that.loadActivity()
|
|
|
}
|
|
|
})
|
|
|
}
|
|
|
},
|
|
|
onShareAppMessage() {
|
|
|
return this.util.shareInfo
|
|
|
},
|
|
|
methods: {
|
|
|
tothere(item) {
|
|
|
uni.openLocation({
|
|
|
latitude: parseFloat(item.latitude),
|
|
|
longitude: parseFloat(item.longitude),
|
|
|
name: item.name,
|
|
|
address: item.address
|
|
|
})
|
|
|
},
|
|
|
openInfo(obj) {
|
|
|
|
|
|
uni.navigateTo({
|
|
|
url: "info?id=" + obj.id
|
|
|
})
|
|
|
},
|
|
|
loadActivity() {
|
|
|
console.log("加载活动列表")
|
|
|
var that = this;
|
|
|
var nt = new Date();
|
|
|
that.isloading = true;
|
|
|
|
|
|
// 构建请求参数
|
|
|
var requestData = {
|
|
|
page_size: 100
|
|
|
};
|
|
|
|
|
|
// 如果有定位信息,添加到请求参数中
|
|
|
if (that.latitude && that.longitude) {
|
|
|
requestData.latitude = that.latitude;
|
|
|
requestData.longitude = that.longitude;
|
|
|
}
|
|
|
|
|
|
this.util.request({
|
|
|
api: '/api/mobile/activity/index',
|
|
|
data: requestData,
|
|
|
utilSuccess: function(res) {
|
|
|
for (var mod of res.data) {
|
|
|
mod.isCanBook = that.$moment(nt).isBefore(mod.end_plan);
|
|
|
}
|
|
|
that.list = res.data;
|
|
|
that.isloading = false;
|
|
|
},
|
|
|
utilFail: function(res) {
|
|
|
that.isloading = false;
|
|
|
}
|
|
|
})
|
|
|
},
|
|
|
isUnde(val) {
|
|
|
if (val) {
|
|
|
return val
|
|
|
} else {
|
|
|
return ""
|
|
|
}
|
|
|
},
|
|
|
getHm(val) {
|
|
|
if (val) {
|
|
|
return this.$moment(val).format("HH:mm")
|
|
|
} else return "";
|
|
|
},
|
|
|
timeFormat(val, format) {
|
|
|
return this.$moment(val).format(format)
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
</script>
|
|
|
|
|
|
<style>
|
|
|
@import url("@/static/css/activitybox.css");
|
|
|
|
|
|
page {
|
|
|
background-color: #f7f6f4;
|
|
|
}
|
|
|
|
|
|
.activityBox_time {
|
|
|
/* height: 70rpx; */
|
|
|
vertical-align: middle;
|
|
|
display: inline-block;
|
|
|
margin: 4rpx;
|
|
|
background: #FCF6E3;
|
|
|
border: 2rpx solid #EF9525;
|
|
|
border-radius: 20rpx;
|
|
|
color: #4E4E4E;
|
|
|
margin-right: 10rpx;
|
|
|
}
|
|
|
.activityMore{
|
|
|
font-size: 26rpx;
|
|
|
font-family: PingFang SC;
|
|
|
font-weight: 400;
|
|
|
display: flex;
|
|
|
color: #EF9525;
|
|
|
flex-direction: column-reverse;
|
|
|
margin-left:10rpx
|
|
|
}
|
|
|
</style>
|