hookehuyr

✨ feat(首页): 联调推荐活动分页功能

......@@ -11,6 +11,7 @@
"dependencies": {
"@babel/runtime": "^7.7.7",
"@tarojs/components": "3.4.10",
"@tarojs/extend": "^3.5.7",
"@tarojs/plugin-framework-react": "^3.4.10",
"@tarojs/plugin-framework-vue3": "3.4.10",
"@tarojs/plugin-html": "^3.4.10",
......@@ -2505,6 +2506,12 @@
"weui": "^1.1.2"
}
},
"node_modules/@tarojs/extend": {
"version": "3.5.7",
"resolved": "https://mirrors.cloud.tencent.com/npm/@tarojs%2fextend/-/extend-3.5.7.tgz",
"integrity": "sha512-duVxMBtmafSH751zztv3RCOH1D1LbNZhhV0Gnvtla4/6R1DUBTONBs1KWg1O5ED4FQsv7TGCvwWSetBqEYYD6g==",
"license": "MIT"
},
"node_modules/@tarojs/helper": {
"version": "3.4.10",
"resolved": "https://mirrors.cloud.tencent.com/npm/@tarojs%2fhelper/-/helper-3.4.10.tgz",
......@@ -21119,6 +21126,11 @@
"weui": "^1.1.2"
}
},
"@tarojs/extend": {
"version": "3.5.7",
"resolved": "https://mirrors.cloud.tencent.com/npm/@tarojs%2fextend/-/extend-3.5.7.tgz",
"integrity": "sha512-duVxMBtmafSH751zztv3RCOH1D1LbNZhhV0Gnvtla4/6R1DUBTONBs1KWg1O5ED4FQsv7TGCvwWSetBqEYYD6g=="
},
"@tarojs/helper": {
"version": "3.4.10",
"resolved": "https://mirrors.cloud.tencent.com/npm/@tarojs%2fhelper/-/helper-3.4.10.tgz",
......
......@@ -36,6 +36,7 @@
"dependencies": {
"@babel/runtime": "^7.7.7",
"@tarojs/components": "3.4.10",
"@tarojs/extend": "^3.5.7",
"@tarojs/plugin-framework-react": "^3.4.10",
"@tarojs/plugin-framework-vue3": "3.4.10",
"@tarojs/plugin-html": "^3.4.10",
......
......@@ -6,7 +6,7 @@
* @Description: 底部导航栏
-->
<template>
<view class="navbar-page">
<view id="navbar-page" class="navbar-page">
<view @tap="goTo('home')" class="home">
<view style="height: 2rem;">
<van-icon :name="icon_home" size="2rem" color="" />
......
<!--
* @Date: 2022-09-19 14:11:06
* @LastEditors: hookehuyr hookehuyr@gmail.com
* @LastEditTime: 2022-10-18 14:44:50
* @LastEditTime: 2022-10-20 11:51:22
* @FilePath: /swx/src/pages/index/index.vue
* @Description: 首页
-->
<template>
<view id="page-header">
<view>
<swiper class='slide-box' indicatorColor='#94B294' indicatorActiveColor='#FFFFFF' current="current"
:duration="duration" :interval="interval" :circular="isCircular" :autoplay="isAutoplay"
......@@ -18,21 +19,24 @@
<view style="padding: 1rem 1rem 0.5rem 1rem;">
<text class="bg-gradient" style="font-size: 1.15rem;">推荐活动</text>
</view>
</view>
<scroll-view :scroll-y="true" :style="scrollStyle" @scrolltolower="onScrollToLower">
<view style="padding: 0 1rem;">
<activity-card v-for="(item, index) in activity_list" :key="index" :data="item" status="join"></activity-card>
</view>
</scroll-view>
<view style="height: 6rem;"></view>
<navbar activated="home" />
<van-toast id="van-toast" />
</template>
<script setup>
import Taro from '@tarojs/taro'
import { ref, onMounted } from 'vue';
import { ref } from 'vue';
import activityCard from '@/components/activity-card.vue'
import navbar from '@/components/navbar.vue'
onMounted(async () => {
})
import Toast from '@/components/vant-weapp/toast/toast';
const goTo = (id) => {
Taro.navigateTo({
......@@ -50,6 +54,7 @@ wx.showShareMenu({
<script>
import "./index.less";
import { activityHomeAPI } from '@/api/Host/index'
import { $ } from '@tarojs/extend'
export default {
name: "indexPage",
......@@ -94,11 +99,27 @@ export default {
},
async onShow () {
// 获取活动和轮播信息
const { code, data } = await activityHomeAPI();
const { code, data } = await activityHomeAPI({ page: this.page, limit: this.limit });
if (code) {
this.activity_list = data.activity_list;
this.carousel = data.carousel;
this.page = this.page + 1;
}
},
onHide () { // 离开当前页面
this.page = 0;
this.flag = true;
},
mounted () {
// 设置滚动列表可视高度
const windowHeight = wx.getSystemInfoSync().windowHeight;
setTimeout(async () => {
const headerHeight = await $('#page-header').height();
const navHeight = await $('#navbar-page').height();
this.scrollStyle = {
height: windowHeight - headerHeight - navHeight + 'px'
}
}, 500);
},
data() {
return {
......@@ -109,10 +130,34 @@ export default {
isAutoplay: false,
hasIndicatorDots: true,
activity_list: [],
carousel: []
carousel: [],
flag: true,
page: 0,
limit: 3,
scrollStyle: { height: '1000rpx' }
};
},
methods: {
onScrollToLower () {
if(!this.flag){
return
}
this.flag = false;
this.getList();
},
async getList () {
// 获取推荐活动列表
const { code, data } = await activityHomeAPI({ page: this.page, limit: this.limit });
if (code) {
if (data.activity_list.length) {
this.activity_list = this.activity_list.concat(data.activity_list);
this.page = this.page + 1;
this.flag = true;
} else {
Toast('到底了')
}
}
}
},
// TODO:分享内容待设置
onShareAppMessage(options) {
......
......@@ -1305,6 +1305,11 @@
"swiper" "6.8.0"
"weui" "^1.1.2"
"@tarojs/extend@^3.5.7":
"integrity" "sha512-duVxMBtmafSH751zztv3RCOH1D1LbNZhhV0Gnvtla4/6R1DUBTONBs1KWg1O5ED4FQsv7TGCvwWSetBqEYYD6g=="
"resolved" "https://mirrors.cloud.tencent.com/npm/@tarojs%2fextend/-/extend-3.5.7.tgz"
"version" "3.5.7"
"@tarojs/helper@3.4.10":
"integrity" "sha512-lu1KrFhusPowrljRkmoFiaOATtiPwPe+WfCbPbIa7gzM6ek+VqwNBVFeIebwyZwL8j2F1wWkk5zJAsyha/hqzw=="
"resolved" "https://mirrors.cloud.tencent.com/npm/@tarojs%2fhelper/-/helper-3.4.10.tgz"
......