hookehuyr

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

...@@ -11,6 +11,7 @@ ...@@ -11,6 +11,7 @@
11 "dependencies": { 11 "dependencies": {
12 "@babel/runtime": "^7.7.7", 12 "@babel/runtime": "^7.7.7",
13 "@tarojs/components": "3.4.10", 13 "@tarojs/components": "3.4.10",
14 + "@tarojs/extend": "^3.5.7",
14 "@tarojs/plugin-framework-react": "^3.4.10", 15 "@tarojs/plugin-framework-react": "^3.4.10",
15 "@tarojs/plugin-framework-vue3": "3.4.10", 16 "@tarojs/plugin-framework-vue3": "3.4.10",
16 "@tarojs/plugin-html": "^3.4.10", 17 "@tarojs/plugin-html": "^3.4.10",
...@@ -2505,6 +2506,12 @@ ...@@ -2505,6 +2506,12 @@
2505 "weui": "^1.1.2" 2506 "weui": "^1.1.2"
2506 } 2507 }
2507 }, 2508 },
2509 + "node_modules/@tarojs/extend": {
2510 + "version": "3.5.7",
2511 + "resolved": "https://mirrors.cloud.tencent.com/npm/@tarojs%2fextend/-/extend-3.5.7.tgz",
2512 + "integrity": "sha512-duVxMBtmafSH751zztv3RCOH1D1LbNZhhV0Gnvtla4/6R1DUBTONBs1KWg1O5ED4FQsv7TGCvwWSetBqEYYD6g==",
2513 + "license": "MIT"
2514 + },
2508 "node_modules/@tarojs/helper": { 2515 "node_modules/@tarojs/helper": {
2509 "version": "3.4.10", 2516 "version": "3.4.10",
2510 "resolved": "https://mirrors.cloud.tencent.com/npm/@tarojs%2fhelper/-/helper-3.4.10.tgz", 2517 "resolved": "https://mirrors.cloud.tencent.com/npm/@tarojs%2fhelper/-/helper-3.4.10.tgz",
...@@ -21119,6 +21126,11 @@ ...@@ -21119,6 +21126,11 @@
21119 "weui": "^1.1.2" 21126 "weui": "^1.1.2"
21120 } 21127 }
21121 }, 21128 },
21129 + "@tarojs/extend": {
21130 + "version": "3.5.7",
21131 + "resolved": "https://mirrors.cloud.tencent.com/npm/@tarojs%2fextend/-/extend-3.5.7.tgz",
21132 + "integrity": "sha512-duVxMBtmafSH751zztv3RCOH1D1LbNZhhV0Gnvtla4/6R1DUBTONBs1KWg1O5ED4FQsv7TGCvwWSetBqEYYD6g=="
21133 + },
21122 "@tarojs/helper": { 21134 "@tarojs/helper": {
21123 "version": "3.4.10", 21135 "version": "3.4.10",
21124 "resolved": "https://mirrors.cloud.tencent.com/npm/@tarojs%2fhelper/-/helper-3.4.10.tgz", 21136 "resolved": "https://mirrors.cloud.tencent.com/npm/@tarojs%2fhelper/-/helper-3.4.10.tgz",
......
...@@ -36,6 +36,7 @@ ...@@ -36,6 +36,7 @@
36 "dependencies": { 36 "dependencies": {
37 "@babel/runtime": "^7.7.7", 37 "@babel/runtime": "^7.7.7",
38 "@tarojs/components": "3.4.10", 38 "@tarojs/components": "3.4.10",
39 + "@tarojs/extend": "^3.5.7",
39 "@tarojs/plugin-framework-react": "^3.4.10", 40 "@tarojs/plugin-framework-react": "^3.4.10",
40 "@tarojs/plugin-framework-vue3": "3.4.10", 41 "@tarojs/plugin-framework-vue3": "3.4.10",
41 "@tarojs/plugin-html": "^3.4.10", 42 "@tarojs/plugin-html": "^3.4.10",
......
...@@ -6,7 +6,7 @@ ...@@ -6,7 +6,7 @@
6 * @Description: 底部导航栏 6 * @Description: 底部导航栏
7 --> 7 -->
8 <template> 8 <template>
9 - <view class="navbar-page"> 9 + <view id="navbar-page" class="navbar-page">
10 <view @tap="goTo('home')" class="home"> 10 <view @tap="goTo('home')" class="home">
11 <view style="height: 2rem;"> 11 <view style="height: 2rem;">
12 <van-icon :name="icon_home" size="2rem" color="" /> 12 <van-icon :name="icon_home" size="2rem" color="" />
......
1 <!-- 1 <!--
2 * @Date: 2022-09-19 14:11:06 2 * @Date: 2022-09-19 14:11:06
3 * @LastEditors: hookehuyr hookehuyr@gmail.com 3 * @LastEditors: hookehuyr hookehuyr@gmail.com
4 - * @LastEditTime: 2022-10-18 14:44:50 4 + * @LastEditTime: 2022-10-20 11:51:22
5 * @FilePath: /swx/src/pages/index/index.vue 5 * @FilePath: /swx/src/pages/index/index.vue
6 * @Description: 首页 6 * @Description: 首页
7 --> 7 -->
8 <template> 8 <template>
9 + <view id="page-header">
9 <view> 10 <view>
10 <swiper class='slide-box' indicatorColor='#94B294' indicatorActiveColor='#FFFFFF' current="current" 11 <swiper class='slide-box' indicatorColor='#94B294' indicatorActiveColor='#FFFFFF' current="current"
11 :duration="duration" :interval="interval" :circular="isCircular" :autoplay="isAutoplay" 12 :duration="duration" :interval="interval" :circular="isCircular" :autoplay="isAutoplay"
...@@ -18,21 +19,24 @@ ...@@ -18,21 +19,24 @@
18 <view style="padding: 1rem 1rem 0.5rem 1rem;"> 19 <view style="padding: 1rem 1rem 0.5rem 1rem;">
19 <text class="bg-gradient" style="font-size: 1.15rem;">推荐活动</text> 20 <text class="bg-gradient" style="font-size: 1.15rem;">推荐活动</text>
20 </view> 21 </view>
22 + </view>
23 + <scroll-view :scroll-y="true" :style="scrollStyle" @scrolltolower="onScrollToLower">
21 <view style="padding: 0 1rem;"> 24 <view style="padding: 0 1rem;">
22 <activity-card v-for="(item, index) in activity_list" :key="index" :data="item" status="join"></activity-card> 25 <activity-card v-for="(item, index) in activity_list" :key="index" :data="item" status="join"></activity-card>
23 </view> 26 </view>
27 + </scroll-view>
24 <view style="height: 6rem;"></view> 28 <view style="height: 6rem;"></view>
25 <navbar activated="home" /> 29 <navbar activated="home" />
30 + <van-toast id="van-toast" />
31 +
26 </template> 32 </template>
27 33
28 <script setup> 34 <script setup>
29 import Taro from '@tarojs/taro' 35 import Taro from '@tarojs/taro'
30 -import { ref, onMounted } from 'vue'; 36 +import { ref } from 'vue';
31 import activityCard from '@/components/activity-card.vue' 37 import activityCard from '@/components/activity-card.vue'
32 import navbar from '@/components/navbar.vue' 38 import navbar from '@/components/navbar.vue'
33 - 39 +import Toast from '@/components/vant-weapp/toast/toast';
34 -onMounted(async () => {
35 -})
36 40
37 const goTo = (id) => { 41 const goTo = (id) => {
38 Taro.navigateTo({ 42 Taro.navigateTo({
...@@ -50,6 +54,7 @@ wx.showShareMenu({ ...@@ -50,6 +54,7 @@ wx.showShareMenu({
50 <script> 54 <script>
51 import "./index.less"; 55 import "./index.less";
52 import { activityHomeAPI } from '@/api/Host/index' 56 import { activityHomeAPI } from '@/api/Host/index'
57 +import { $ } from '@tarojs/extend'
53 58
54 export default { 59 export default {
55 name: "indexPage", 60 name: "indexPage",
...@@ -94,11 +99,27 @@ export default { ...@@ -94,11 +99,27 @@ export default {
94 }, 99 },
95 async onShow () { 100 async onShow () {
96 // 获取活动和轮播信息 101 // 获取活动和轮播信息
97 - const { code, data } = await activityHomeAPI(); 102 + const { code, data } = await activityHomeAPI({ page: this.page, limit: this.limit });
98 if (code) { 103 if (code) {
99 this.activity_list = data.activity_list; 104 this.activity_list = data.activity_list;
100 this.carousel = data.carousel; 105 this.carousel = data.carousel;
106 + this.page = this.page + 1;
107 + }
108 + },
109 + onHide () { // 离开当前页面
110 + this.page = 0;
111 + this.flag = true;
112 + },
113 + mounted () {
114 + // 设置滚动列表可视高度
115 + const windowHeight = wx.getSystemInfoSync().windowHeight;
116 + setTimeout(async () => {
117 + const headerHeight = await $('#page-header').height();
118 + const navHeight = await $('#navbar-page').height();
119 + this.scrollStyle = {
120 + height: windowHeight - headerHeight - navHeight + 'px'
101 } 121 }
122 + }, 500);
102 }, 123 },
103 data() { 124 data() {
104 return { 125 return {
...@@ -109,10 +130,34 @@ export default { ...@@ -109,10 +130,34 @@ export default {
109 isAutoplay: false, 130 isAutoplay: false,
110 hasIndicatorDots: true, 131 hasIndicatorDots: true,
111 activity_list: [], 132 activity_list: [],
112 - carousel: [] 133 + carousel: [],
134 + flag: true,
135 + page: 0,
136 + limit: 3,
137 + scrollStyle: { height: '1000rpx' }
113 }; 138 };
114 }, 139 },
115 methods: { 140 methods: {
141 + onScrollToLower () {
142 + if(!this.flag){
143 + return
144 + }
145 + this.flag = false;
146 + this.getList();
147 + },
148 + async getList () {
149 + // 获取推荐活动列表
150 + const { code, data } = await activityHomeAPI({ page: this.page, limit: this.limit });
151 + if (code) {
152 + if (data.activity_list.length) {
153 + this.activity_list = this.activity_list.concat(data.activity_list);
154 + this.page = this.page + 1;
155 + this.flag = true;
156 + } else {
157 + Toast('到底了')
158 + }
159 + }
160 + }
116 }, 161 },
117 // TODO:分享内容待设置 162 // TODO:分享内容待设置
118 onShareAppMessage(options) { 163 onShareAppMessage(options) {
......
...@@ -1305,6 +1305,11 @@ ...@@ -1305,6 +1305,11 @@
1305 "swiper" "6.8.0" 1305 "swiper" "6.8.0"
1306 "weui" "^1.1.2" 1306 "weui" "^1.1.2"
1307 1307
1308 +"@tarojs/extend@^3.5.7":
1309 + "integrity" "sha512-duVxMBtmafSH751zztv3RCOH1D1LbNZhhV0Gnvtla4/6R1DUBTONBs1KWg1O5ED4FQsv7TGCvwWSetBqEYYD6g=="
1310 + "resolved" "https://mirrors.cloud.tencent.com/npm/@tarojs%2fextend/-/extend-3.5.7.tgz"
1311 + "version" "3.5.7"
1312 +
1308 "@tarojs/helper@3.4.10": 1313 "@tarojs/helper@3.4.10":
1309 "integrity" "sha512-lu1KrFhusPowrljRkmoFiaOATtiPwPe+WfCbPbIa7gzM6ek+VqwNBVFeIebwyZwL8j2F1wWkk5zJAsyha/hqzw==" 1314 "integrity" "sha512-lu1KrFhusPowrljRkmoFiaOATtiPwPe+WfCbPbIa7gzM6ek+VqwNBVFeIebwyZwL8j2F1wWkk5zJAsyha/hqzw=="
1310 "resolved" "https://mirrors.cloud.tencent.com/npm/@tarojs%2fhelper/-/helper-3.4.10.tgz" 1315 "resolved" "https://mirrors.cloud.tencent.com/npm/@tarojs%2fhelper/-/helper-3.4.10.tgz"
......