hookehuyr

✨ feat(首页): 联调首页活动和轮播API

1 /* 1 /*
2 * @Date: 2022-10-14 17:26:56 2 * @Date: 2022-10-14 17:26:56
3 * @LastEditors: hookehuyr hookehuyr@gmail.com 3 * @LastEditors: hookehuyr hookehuyr@gmail.com
4 - * @LastEditTime: 2022-10-18 09:28:54 4 + * @LastEditTime: 2022-10-18 11:34:45
5 * @FilePath: /swx/src/api/Host/index.js 5 * @FilePath: /swx/src/api/Host/index.js
6 - * @Description: 文件描述 6 + * @Description: 活动相关接口
7 */ 7 */
8 import { fn, fetch } from '../fn'; 8 import { fn, fetch } from '../fn';
9 9
10 const Api = { 10 const Api = {
11 HOST_LIST: '/srv/?a=host_list', 11 HOST_LIST: '/srv/?a=host_list',
12 ACTIVITY_ADD: '/srv/?a=activity_add', 12 ACTIVITY_ADD: '/srv/?a=activity_add',
13 + ACTIVITY_HOMEPAGE: '/srv/?a=activity_app_homepage',
13 } 14 }
14 15
15 /** 16 /**
...@@ -23,3 +24,9 @@ export const hostListAPI = (params) => fn(fetch.post(Api.HOST_LIST, params)); ...@@ -23,3 +24,9 @@ export const hostListAPI = (params) => fn(fetch.post(Api.HOST_LIST, params));
23 * @returns 24 * @returns
24 */ 25 */
25 export const addActivityAPI = (params) => fn(fetch.post(Api.ACTIVITY_ADD, params)); 26 export const addActivityAPI = (params) => fn(fetch.post(Api.ACTIVITY_ADD, params));
27 +
28 +/**
29 + * @description: 首页活动和轮播
30 + * @returns
31 + */
32 +export const activityHomeAPI = (params) => fn(fetch.get(Api.ACTIVITY_HOMEPAGE, params));
......
1 <!-- 1 <!--
2 * @Date: 2022-09-20 15:39:37 2 * @Date: 2022-09-20 15:39:37
3 * @LastEditors: hookehuyr hookehuyr@gmail.com 3 * @LastEditors: hookehuyr hookehuyr@gmail.com
4 - * @LastEditTime: 2022-10-08 10:14:21 4 + * @LastEditTime: 2022-10-18 14:21:21
5 * @FilePath: /swx/src/components/activity-card.vue 5 * @FilePath: /swx/src/components/activity-card.vue
6 * @Description: 活动卡片组件 6 * @Description: 活动卡片组件
7 --> 7 -->
...@@ -10,20 +10,18 @@ ...@@ -10,20 +10,18 @@
10 <view class="card-main"> 10 <view class="card-main">
11 <van-row> 11 <van-row>
12 <van-col :span="10"> 12 <van-col :span="10">
13 - <van-image width="100%" height="5rem" fit="cover" src="https://img.yzcdn.cn/vant/cat.jpeg" /> 13 + <van-image width="100%" height="5rem" fit="cover" :src="data.cover" />
14 </van-col> 14 </van-col>
15 <van-col :span="14"> 15 <van-col :span="14">
16 <view class="card-main-text"> 16 <view class="card-main-text">
17 - <view style="font-size: 1.1rem;">{{ data.title }}</view> 17 + <view style="font-size: 1.1rem;">{{ data.name }}</view>
18 - <!-- <view class="status-text">
19 - <text>网络活动</text>
20 - </view> -->
21 <view class="status-text"> 18 <view class="status-text">
22 - <van-tag :round="true" color="#E9FAF4" text-color="#199A74" size="large">网络活动</van-tag> 19 + <van-tag v-if="data.mode === 'offline'" :round="true" color="#E9FAF4" text-color="#199A74" size="large">现场活动</van-tag>
23 - <van-tag :round="true" color="#D7FFD7" text-color="#019200" size="large">报名中</van-tag> 20 + <van-tag v-if="data.mode === 'online'" :round="true" color="#E9FAF4" text-color="#199A74" size="large">线上活动</van-tag>
21 + <van-tag v-if="register" :round="true" color="#D7FFD7" text-color="#019200" size="large">报名中</van-tag>
24 </view> 22 </view>
25 <view style="font-size: 0.95rem;"> 23 <view style="font-size: 0.95rem;">
26 - <van-icon name="clock-o" color="#BBBBBB" />&nbsp;2022-08-25 14:00 24 + <van-icon name="clock-o" color="#BBBBBB" />&nbsp;{{ formatDate(data.activity_time) }}
27 </view> 25 </view>
28 </view> 26 </view>
29 </van-col> 27 </van-col>
...@@ -41,13 +39,13 @@ ...@@ -41,13 +39,13 @@
41 <van-row> 39 <van-row>
42 <van-col :span="19"> 40 <van-col :span="19">
43 <view style="line-height: 2;"> 41 <view style="line-height: 2;">
44 - <text>浏览:2996</text>&nbsp; 42 + <text>浏览:{{ data.view_count }}</text>&nbsp;
45 - <text>报名:444/无限</text>&nbsp; 43 + <text>报名:{{ data.reg_count }}/<text v-if="data.reg_max === 0">无限</text><text v-else>{{ data.reg_max }}</text></text>&nbsp;
46 - <text>岗位:333</text> 44 + <text v-if="data.extend.length">岗位:{{ data.extend && data.extend.join(',') }}</text>
47 </view> 45 </view>
48 </van-col> 46 </van-col>
49 <van-col v-if="status === 'join'" :span="5"> 47 <van-col v-if="status === 'join'" :span="5">
50 - <view @tap="goTo()" class="status-button"> 48 + <view @tap="goTo(data.id)" class="status-button">
51 <text>我要报名</text> 49 <text>我要报名</text>
52 </view> 50 </view>
53 </van-col> 51 </van-col>
...@@ -58,20 +56,27 @@ ...@@ -58,20 +56,27 @@
58 </template> 56 </template>
59 57
60 <script setup> 58 <script setup>
61 -import { ref, defineProps } from 'vue' 59 +import { ref, defineProps, computed } from 'vue'
62 -import icon_time from '@/images/icon/time@2x.png'
63 import icon_address from '@/images/icon/address@2x.png' 60 import icon_address from '@/images/icon/address@2x.png'
64 -
65 import Taro from '@tarojs/taro' 61 import Taro from '@tarojs/taro'
62 +import * as dayjs from 'dayjs'
66 63
67 const props = defineProps({ 64 const props = defineProps({
68 data: Object, 65 data: Object,
69 status: String 66 status: String
67 +});
68 +
69 +const register = computed(() => { // 报名中状态显示
70 + return false
70 }) 71 })
71 72
72 -const goTo = () => { 73 +const formatDate = (date) => {
74 + return dayjs(date).format('YYYY-MM-DD HH:mm')
75 +}
76 +
77 +const goTo = (id) => {
73 Taro.navigateTo({ 78 Taro.navigateTo({
74 - url: '../activityDetail/index' 79 + url: '../activityDetail/index?id=' + id
75 }) 80 })
76 } 81 }
77 </script> 82 </script>
...@@ -82,6 +87,7 @@ const goTo = () => { ...@@ -82,6 +87,7 @@ const goTo = () => {
82 .activity-card-page { 87 .activity-card-page {
83 background-color: #FFFFFF; 88 background-color: #FFFFFF;
84 border-radius: 0.5rem; 89 border-radius: 0.5rem;
90 + margin-bottom: 1rem;
85 .card-main { 91 .card-main {
86 padding: 0.8rem; 92 padding: 0.8rem;
87 border-bottom: 1px solid #F2F2F2; 93 border-bottom: 1px solid #F2F2F2;
......
1 <!-- 1 <!--
2 * @Date: 2022-09-21 16:04:10 2 * @Date: 2022-09-21 16:04:10
3 * @LastEditors: hookehuyr hookehuyr@gmail.com 3 * @LastEditors: hookehuyr hookehuyr@gmail.com
4 - * @LastEditTime: 2022-10-18 11:09:05 4 + * @LastEditTime: 2022-10-18 13:15:36
5 * @FilePath: /swx/src/pages/createActivity/index.vue 5 * @FilePath: /swx/src/pages/createActivity/index.vue
6 * @Description: 创建活动页面 6 * @Description: 创建活动页面
7 --> 7 -->
...@@ -528,15 +528,9 @@ const status = ref('disable'); // disable=未发布,enable=已发布 ...@@ -528,15 +528,9 @@ const status = ref('disable'); // disable=未发布,enable=已发布
528 const publish_status = ref('暂不发布'); 528 const publish_status = ref('暂不发布');
529 const columns = ref(['暂不发布', '立即发布']); 529 const columns = ref(['暂不发布', '立即发布']);
530 const onPublishChange = (event) => { 530 const onPublishChange = (event) => {
531 - // const { picker, value, index } = event.detail;
532 - // console.warn(value);
533 - // console.warn(index);
534 - // publish_status.value = value;
535 } 531 }
536 const onPublishConfirm = (event) => { 532 const onPublishConfirm = (event) => {
537 const { picker, value, index } = event.detail; 533 const { picker, value, index } = event.detail;
538 - // console.warn(value);
539 - // console.warn(index);
540 if (index) { // 已发布 534 if (index) { // 已发布
541 status.value = 'enable'; 535 status.value = 'enable';
542 } else { // 未发布 536 } else { // 未发布
...@@ -555,10 +549,6 @@ const activity_type = ref('现场活动'); ...@@ -555,10 +549,6 @@ const activity_type = ref('现场活动');
555 const mode = ref('offline'); // offline=现场活动,online=线上活动 549 const mode = ref('offline'); // offline=现场活动,online=线上活动
556 const activity_type_columns = ref(['现场活动', '线上活动']); 550 const activity_type_columns = ref(['现场活动', '线上活动']);
557 const onActivityTypeChange = (event) => { 551 const onActivityTypeChange = (event) => {
558 - // const { picker, value, index } = event.detail;
559 - // console.warn(value);
560 - // console.warn(index);
561 - // activity_type.value = value;
562 } 552 }
563 const onActivityTypeConfirm = (event) => { 553 const onActivityTypeConfirm = (event) => {
564 const { picker, value, index } = event.detail; 554 const { picker, value, index } = event.detail;
...@@ -586,10 +576,6 @@ const public_type = ref('不公开'); ...@@ -586,10 +576,6 @@ const public_type = ref('不公开');
586 const is_public = ref(0); 576 const is_public = ref(0);
587 const public_type_columns = ref(['不公开', '公开']); 577 const public_type_columns = ref(['不公开', '公开']);
588 const onPublicTypeChange = (event) => { 578 const onPublicTypeChange = (event) => {
589 - // const { picker, value, index } = event.detail;
590 - // console.warn(value);
591 - // console.warn(index);
592 - // public_type.value = value;
593 } 579 }
594 const onPublicTypeConfirm = (event) => { 580 const onPublicTypeConfirm = (event) => {
595 const { picker, value, index } = event.detail; 581 const { picker, value, index } = event.detail;
...@@ -685,10 +671,10 @@ const onSubmit = async () => { ...@@ -685,10 +671,10 @@ const onSubmit = async () => {
685 reg_begin_time: reg_begin_time.value, // 报名开始时间 671 reg_begin_time: reg_begin_time.value, // 报名开始时间
686 reg_end_time: reg_end_time.value, // 报名截止时间 672 reg_end_time: reg_end_time.value, // 报名截止时间
687 reg_max: reg_max.value === '无限制' ? 0 : reg_max.value, // 报名限制人数 673 reg_max: reg_max.value === '无限制' ? 0 : reg_max.value, // 报名限制人数
688 - status: publish_status.value === '暂不发布' ? 0 : 1, // 状态 674 + status: status.value, // 状态
689 - mode: activity_type.value === '现场活动' ? 0 : 1, // 活动方式 675 + mode: mode.value, // 活动方式
690 address: address.value, // 活动地址 676 address: address.value, // 活动地址
691 - is_public: public_type.value === '不公开' ? 0 : 1, // 是否公开 677 + is_public: is_public.value, // 是否公开
692 is_inner: is_inner.value ? 1 : 0, // 是否允许内部人员报名 678 is_inner: is_inner.value ? 1 : 0, // 是否允许内部人员报名
693 is_black: is_black.value ? 1 : 0, // 是否屏蔽黑名单 679 is_black: is_black.value ? 1 : 0, // 是否屏蔽黑名单
694 extend: JSON.stringify(extend.value), // 义工岗位 680 extend: JSON.stringify(extend.value), // 义工岗位
......
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-13 22:30:46 4 + * @LastEditTime: 2022-10-18 14:28:15
5 * @FilePath: /swx/src/pages/index/index.vue 5 * @FilePath: /swx/src/pages/index/index.vue
6 * @Description: 首页 6 * @Description: 首页
7 --> 7 -->
...@@ -10,8 +10,8 @@ ...@@ -10,8 +10,8 @@
10 <swiper class='slide-box' indicatorColor='#94B294' indicatorActiveColor='#FFFFFF' current="current" 10 <swiper class='slide-box' indicatorColor='#94B294' indicatorActiveColor='#FFFFFF' current="current"
11 :duration="duration" :interval="interval" :circular="isCircular" :autoplay="isAutoplay" 11 :duration="duration" :interval="interval" :circular="isCircular" :autoplay="isAutoplay"
12 :indicatorDots="hasIndicatorDots"> 12 :indicatorDots="hasIndicatorDots">
13 - <swiper-item v-for="(item, idx) in imgUrls" :key="idx"> 13 + <swiper-item v-for="(item, idx) in carousel" :key="idx">
14 - <image :src="item" class="slide-image" /> 14 + <image @tap="goTo(item.id)" :src="item.cover" class="slide-image" />
15 </swiper-item> 15 </swiper-item>
16 </swiper> 16 </swiper>
17 </view> 17 </view>
...@@ -30,37 +30,16 @@ import Taro from '@tarojs/taro' ...@@ -30,37 +30,16 @@ import Taro from '@tarojs/taro'
30 import { ref, onMounted } from 'vue'; 30 import { ref, onMounted } from 'vue';
31 import activityCard from '@/components/activity-card.vue' 31 import activityCard from '@/components/activity-card.vue'
32 import navbar from '@/components/navbar.vue' 32 import navbar from '@/components/navbar.vue'
33 -import request from '../../utils/request'; 33 +import Taro from '@tarojs/taro'
34 34
35 -onMounted(() => { 35 +onMounted(async () => {
36 - request.get('/srv/?a=activity_app_homepage')
37 - .then(res => {
38 - // console.warn(res);
39 - })
40 - .catch(err => {
41 - console.error(err);
42 - })
43 }) 36 })
44 37
45 -const activity_list = ref([{ 38 +const goTo = (id) => {
46 - title: '智慧没有烦恼', 39 + Taro.navigateTo({
47 - address: '上海市杨浦区军工路100号A座05室', 40 + url: '../activityDetail/index?id=' + id
48 -}, { 41 + })
49 - title: '万人共乘浪漫热气球', 42 +}
50 - address: '',
51 -}, {
52 - title: '八段锦',
53 - address: '',
54 -}, {
55 - title: '智慧没有烦恼',
56 - address: '上海市杨浦区军工路100号A座05室',
57 -}, {
58 - title: '万人共乘浪漫热气球',
59 - address: '',
60 -}, {
61 - title: '八段锦',
62 - address: '',
63 -}]);
64 43
65 // 分享功能 44 // 分享功能
66 wx.showShareMenu({ 45 wx.showShareMenu({
...@@ -71,6 +50,7 @@ wx.showShareMenu({ ...@@ -71,6 +50,7 @@ wx.showShareMenu({
71 50
72 <script> 51 <script>
73 import "./index.less"; 52 import "./index.less";
53 +import { activityHomeAPI } from '@/api/Host/index'
74 54
75 export default { 55 export default {
76 name: "indexPage", 56 name: "indexPage",
...@@ -113,6 +93,14 @@ export default { ...@@ -113,6 +93,14 @@ export default {
113 } 93 }
114 }); 94 });
115 }, 95 },
96 + async onShow () {
97 + // 获取活动和轮播信息
98 + const { code, data } = await activityHomeAPI();
99 + if (code) {
100 + this.activity_list = data.activity_list;
101 + this.carousel = data.carousel;
102 + }
103 + },
116 data() { 104 data() {
117 return { 105 return {
118 current: 1, 106 current: 1,
...@@ -121,11 +109,8 @@ export default { ...@@ -121,11 +109,8 @@ export default {
121 isCircular: true, 109 isCircular: true,
122 isAutoplay: false, 110 isAutoplay: false,
123 hasIndicatorDots: true, 111 hasIndicatorDots: true,
124 - imgUrls: [ 112 + activity_list: [],
125 - 'http://gyzs.onwall.cn/swx_banner%402x.png', 113 + carousel: []
126 - 'http://gyzs.onwall.cn/swx_banner%402x.png',
127 - 'http://gyzs.onwall.cn/swx_banner%402x.png',
128 - ],
129 }; 114 };
130 }, 115 },
131 methods: { 116 methods: {
......