123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411 |
- <template>
- <view class="active-list">
- <!-- 活动查询 -->
- <view class="active-list-search">
- <!-- 搜索框 -->
- <view class="search">
- <u-input placeholderStyle='color:#999' placeholder="输入活动名称或参赛项目" border='none' v-model="search"
- @input="searchText(isActive,items[isActive].id)">
- <template slot="suffix" style='margin-right:40rpx;'>
- <u-image :showLoading="true" :showError='true' src="/static/icon/search.png" width="40rpx"
- height="32rpx"></u-image>
- </template>
- </u-input>
- </view>
- <view class="tab_nav">
- <view class="navTitle" v-for="(item,index) in items" :key="index">
- <view :class="{'active':isActive === index}" @click="checked(index,item.id)">
- {{item.name}}
- </view>
- </view>
- </view>
- </view>
- <view class="msg-null" v-if="List.length == 0">
- <image src="https://t9.9026.com/imgs/dataNull.png" style="width: 394rpx;height: 396rpx;" mode=""></image>
- <view class="msg-null-text">
- <text>暂无数据</text>
- </view>
- </view>
- <view class="List" v-if="List.length > 0">
- <template v-for="(item,index) in List">
- <view class="ListItem" v-if="item.show_status" :key="index" @click="activeDetail(item.id)">
- <image :src="item.banners?item.cover_img:'http://t9.9026.com/imgs/Kudosbg.png'"
- style="width: 640rpx;height:420rpx;border-radius: 12rpx;"></image>
- <view class="kudosicon" @click.stop="kudosActive(item.id,index)">
- <image src="/static/icon/Kudos.png" v-if="item.is_like==0"></image>
- <image src="/static/icon/Kudos(1).png" v-if="item.is_like==1"></image>
- </view>
- <view class="nav">
- <view class="events">
- <text>{{item.title}}</text>
- </view>
- <view class="voteStatus" style="width: 100rpx;">
- <text style="font-size: 30rpx;color: #999;" v-if="item.activity_status==1">未开始</text>
- <text style="font-size: 30rpx;color: #FF6503;" v-if="item.activity_status==2">进行中</text>
- <text style="font-size: 30rpx;color: #999;" v-if="item.activity_status==3">已结束</text>
- </view>
- </view>
- <view class="foot">
- <image src="/static/icon/data.png"></image>
- <text>{{item.end_time}} 结束</text>
- </view>
- </view>
- </template>
- </view>
- <!-- 触底 -->
- <view class="home-bottom" v-if="List.length > 0">
- <uni-load-more :status="status" color="#CCCCCC" :content-text="contentText" />
- </view>
- </view>
- </template>
- <script>
- import util from '@/utils/util.js'
- export default {
- data() {
- return {
- //活动分类categoryId
- categoryId: '',
- // 搜索
- search: '',
- //分段器
- items: [{
- name: '热门活动'
- },
- {
- name: '西区活动'
- }, {
- name: '酒店评选'
- },
- {
- name: '旅游推选'
- }
- ],
- //激活指定table菜单
- isActive: 0,
- contentText: {
- contentdown: '查看更多',
- contentrefresh: '加载中',
- contentnomore: '—— 已经到底啦 ——'
- },
- // 活动列表
- List: [],
- // 分页
- page: 1,
- pagesize: 15,
- totalElements: '',
- allListItem: '',
- // 组件uni-load-more
- status: 'noMore',
- }
- },
- onLoad() {
- // this.getList()
- this.getCategoryList()
- console.log(util, "until")
- },
- // 触底加载
- onReachBottom() {
- // 触底的时候请求数据,即为上拉加载更多
- var allTotal = this.page * this.pagesize
- console.log(allTotal, '----allTotal');
- //this.page为加载次数,this.pagesize为每一次加载的数据条数
- if (allTotal < this.totalElements) {
- //this.totalElements为请求数据的总条数。只要现有条数小于总条数就就执行一下代码
- this.allListItem = false;
- this.page++;
- //加载次数递加
- this.status = "loading"
- this.$api.active.getActiveList({ //请求更多数据列表
- page: this.page,
- category_id: this.categoryId,
- keyword: this.search
- }).then(res => {
- let ret = [...this.List, ...res.data.data]
- this.List = ret
- console.log(ret)
- })
- } else {
- this.allListItem = true;
- console.log('已加载全部数据')
- this.status = "noMore"
- }
- },
- methods: {
- // 获取活动列表
- getList(category_id) {
- this.$api.active.getActiveList({
- page: 0,
- keyword: '',
- category_id: `${category_id}`
- }).then(res => {
- console.log(res, '活动列表')
- if (res.code == 0) {
- this.List = res.data.data
- this.totalElements = res.data.total
- this.pagesize = res.data.per_page
- console.log(this.List, '--->this.List');
- }
- })
- },
- // 获取分类列表
- getCategoryList() {
- this.$api.category.getCategoryList({
- page: 1,
- type: 1
- }).then(res => {
- console.log(res, "活动分类列表")
- if (res.code == 0) {
- this.items = res.data.data
- this.categoryId = this.items[0].id
- console.log(this.categoryId, '--->this.categoryId');
- this.getList(this.categoryId)
- }
- })
- },
- // 点赞活动
- kudosActive(id, index) {
- let beforeLike = this.List[index].is_like
- this.$api.active.kudos({
- activity_id: id
- }).then(res => {
- console.log(res, '点赞')
- if (res.code == 0) {
- if (beforeLike == 1) {
- this.List[index].is_like = 0
- } else {
- this.List[index].is_like = 1
- }
- }
- })
- },
- //菜单index切换
- checked(index, id) {
- this.page = 1
- this.isActive = index
- this.categoryId = id
- this.getList(id)
- console.log(this.isActive, '---->this.isActive');
- },
- // 活动详情页
- activeDetail(id) {
- uni.navigateTo({
- url: '/pages/index/active-detail/index?id=' + id
- })
- },
- // 搜索防抖
- searchText: util.debounce(function(index, id) {
- this.goSearch(index, id)
- console.log(id, '---->id');
- }, 1000),
- //搜索
- goSearch(index, id) {
- uni.showLoading({
- title: '加载中'
- })
- this.$api.active.getActiveList({
- page: 1,
- keyword: this.search,
- category_id: id
- }).then(res => {
- if (res.code == 0) {
- uni.hideLoading()
- this.isActive = index
- this.List = res.data.data
- this.totalElements = res.data.total
- this.pagesize = res.data.per_page
- console.log(this.List, '--->this.list');
- }
- })
- },
- }
- }
- </script>
- <style lang="scss" scoped>
- $pageColor:#F9F9F9;
- $bgColor:#FFFFFF;
- @mixin flexlayout {
- display: flex;
- align-items: center;
- justify-content: center;
- }
- .active-list {
- height: 100%;
- background: #F9F9F9;
- }
- .msg-null {
- margin-top: 224rpx;
- display: flex;
- flex-direction: column;
- align-items: center;
- justify-content: center;
- padding-top: 60rpx;
- .msg-null-text {
- margin-top: 40rpx;
- font-size: 28rpx;
- color: #333;
- }
- }
- .home-bottom {
- background-color: #f9f9f9;
- padding-bottom: 84rpx;
- }
- .active-list-search {
- padding: 24rpx 30rpx 32rpx;
- height: 222rpx;
- background-color: #FFFFFF;
- width: 100%;
- position: fixed;
- top: 0;
- z-index: 99;
- // 搜索
- .search {
- ::v-deep .u-input {
- width: 690rpx !important;
- height: 68rpx !important;
- background: #F1F1F1;
- border-radius: 74rpx;
- }
- ::v-deep .u-input__content__field-wrapper {
- padding-left: 36rpx;
- }
- ::v-deep .u-input__content__field-wrapper__field {
- color: #999999 !important;
- font-size: 28rpx !important;
- }
- }
- //菜单切换
- .tab_nav {
- width: 100%;
- margin-top: 32rpx;
- display: flex;
- justify-content: space-between;
- align-items: center;
- font-family: PingFang-SC-Heavy, PingFang-SC;
- }
- .tab_nav .navTitle {
- width: 150rpx;
- flex: none;
- height: 28rpx;
- font-size: 32rpx;
- color: #666;
- position: relative;
- }
- .active {
- color: #D9A94D;
- font-weight: bold;
- &::after {
- display: inline-block;
- content: '';
- width: 48rpx;
- height: 12rpx;
- background: linear-gradient(90deg, #F3D69F 0%, #D9A94D 100%);
- border-radius: 6px;
- position: absolute;
- bottom: -36rpx;
- left: 40rpx;
- }
- }
- }
- .List {
- padding: 0 30rpx;
- box-sizing: border-box;
- padding-top: 20rpx;
- padding-bottom: 88rpx;
- background-color: #F9F9F9;
- margin-top: 222rpx;
- .ListItem {
- position: relative;
- margin-bottom: 24rpx;
- width: 100%;
- height: 562rpx;
- background: #F9F9F9;
- box-shadow: 0rpx 12rpx 40rpx 0rpx rgba(220, 222, 229, 0.4);
- border-radius: 24rpx;
- padding: 20rpx 26rpx 26rpx 24rpx;
- .kudosicon {
- width: 48rpx;
- height: 48rpx;
- position: absolute;
- top: 52rpx;
- right: 58rpx;
- border-radius: 50%;
- background: #FFFFFF;
- opacity: 0.84;
- @include flexlayout() image {
- width: 32rpx;
- height: 28rpx;
- }
- }
- .nav {
- display: flex;
- align-items: flex-start;
- justify-content: space-between;
- .events {
- text {
- font-size: 30rpx;
- font-family: PingFang-SC-Bold, PingFang-SC;
- font-weight: bold;
- color: #333333;
- }
- }
- .voteStatus {
- font-size: 30rpx;
- font-family: PingFang-SC-Medium, PingFang-SC;
- font-weight: 500;
- color: #999999;
- }
- }
- .foot {
- margin-top: 10rpx;
- display: flex;
- align-items: center;
- image {
- width: 28rpx;
- height: 28rpx;
- margin-right: 8rpx;
- }
- text {
- font-size: 24rpx;
- font-family: PingFang-SC-Medium, PingFang-SC;
- font-weight: 500;
- color: #999999;
- display: block;
- }
- }
- }
- }
- </style>
|