hookehuyr

创建活动页面API逻辑联调

1 /* 1 /*
2 * @Date: 2022-10-20 13:15:00 2 * @Date: 2022-10-20 13:15:00
3 * @LastEditors: hookehuyr hookehuyr@gmail.com 3 * @LastEditors: hookehuyr hookehuyr@gmail.com
4 - * @LastEditTime: 2022-10-25 15:37:28 4 + * @LastEditTime: 2022-10-25 17:27:05
5 * @FilePath: /swx/src/api/Activity/index.js 5 * @FilePath: /swx/src/api/Activity/index.js
6 * @Description: 活动信息 6 * @Description: 活动信息
7 */ 7 */
...@@ -9,6 +9,7 @@ import { fn, fetch } from '../fn'; ...@@ -9,6 +9,7 @@ import { fn, fetch } from '../fn';
9 9
10 const Api = { 10 const Api = {
11 ACTIVITY_JOIN_LIST: '/srv/?a=activity_join_list', 11 ACTIVITY_JOIN_LIST: '/srv/?a=activity_join_list',
12 + ACTIVITY_ADD_LIST: '/srv/?a=activity_add_list',
12 } 13 }
13 14
14 /** 15 /**
...@@ -16,3 +17,9 @@ const Api = { ...@@ -16,3 +17,9 @@ const Api = {
16 * @returns 17 * @returns
17 */ 18 */
18 export const joinListAPI = (params) => fn(fetch.get(Api.ACTIVITY_JOIN_LIST, params)); 19 export const joinListAPI = (params) => fn(fetch.get(Api.ACTIVITY_JOIN_LIST, params));
20 +
21 +/**
22 + * @description: 我创建的活动列表
23 + * @returns
24 + */
25 +export const addListAPI = (params) => fn(fetch.get(Api.ACTIVITY_ADD_LIST, params));
......
1 <!-- 1 <!--
2 * @Date: 2022-09-26 14:36:57 2 * @Date: 2022-09-26 14:36:57
3 * @LastEditors: hookehuyr hookehuyr@gmail.com 3 * @LastEditors: hookehuyr hookehuyr@gmail.com
4 - * @LastEditTime: 2022-10-25 16:26:07 4 + * @LastEditTime: 2022-10-26 09:14:00
5 * @FilePath: /swx/src/pages/activityDetail/index.vue 5 * @FilePath: /swx/src/pages/activityDetail/index.vue
6 * @Description: 活动详情页 6 * @Description: 活动详情页
7 --> 7 -->
...@@ -106,7 +106,7 @@ ...@@ -106,7 +106,7 @@
106 </view> 106 </view>
107 </view> 107 </view>
108 <view style="height: 6rem;"></view> 108 <view style="height: 6rem;"></view>
109 - <activity-bar :user-type="userType" :reg-id="reg_id" :member-role="member_role" :is-end="is_end" /> 109 + <activity-bar :user-type="userType" :reg-id="reg_id" :member-role="member_role" :is-end="is_end" :activity-status="activity_status" />
110 110
111 <!-- <van-action-sheet 111 <!-- <van-action-sheet
112 :z-index="10" 112 :z-index="10"
...@@ -462,6 +462,7 @@ import "./index.less"; ...@@ -462,6 +462,7 @@ import "./index.less";
462 import { activityInfoAPI } from '@/api/Host/index'; 462 import { activityInfoAPI } from '@/api/Host/index';
463 import { pageQuery } from '@/utils/tools.js' 463 import { pageQuery } from '@/utils/tools.js'
464 import mixin from '@/utils/mixin'; 464 import mixin from '@/utils/mixin';
465 +import { getCurrentPageParam } from "@/utils/weapp";
465 require('@tarojs/taro/html.css') 466 require('@tarojs/taro/html.css')
466 467
467 export default { 468 export default {
...@@ -478,6 +479,8 @@ export default { ...@@ -478,6 +479,8 @@ export default {
478 this.member_role = data.member_role; 479 this.member_role = data.member_role;
479 this.reg_id = data.reg_id; 480 this.reg_id = data.reg_id;
480 } 481 }
482 + // 活动状态判断显示
483 + this.activity_status = getCurrentPageParam().status;
481 }, 484 },
482 mounted() { 485 mounted() {
483 }, 486 },
...@@ -488,6 +491,7 @@ export default { ...@@ -488,6 +491,7 @@ export default {
488 member_role: '', 491 member_role: '',
489 reg_id: '', 492 reg_id: '',
490 is_end: '', 493 is_end: '',
494 + activity_status: '',
491 } 495 }
492 }, 496 },
493 computed: { 497 computed: {
......
1 <!-- 1 <!--
2 * @Date: 2022-09-21 14:51:44 2 * @Date: 2022-09-21 14:51:44
3 * @LastEditors: hookehuyr hookehuyr@gmail.com 3 * @LastEditors: hookehuyr hookehuyr@gmail.com
4 - * @LastEditTime: 2022-10-25 15:12:40 4 + * @LastEditTime: 2022-10-25 18:29:15
5 * @FilePath: /swx/src/pages/my/index.vue 5 * @FilePath: /swx/src/pages/my/index.vue
6 * @Description: 我的页面 6 * @Description: 我的页面
7 --> 7 -->
...@@ -64,10 +64,12 @@ ...@@ -64,10 +64,12 @@
64 </view> 64 </view>
65 <view style="height: 6rem;"></view> 65 <view style="height: 6rem;"></view>
66 <navbar activated="my" /> 66 <navbar activated="my" />
67 + <van-toast id="van-toast" />
68 +
67 </template> 69 </template>
68 70
69 <script setup> 71 <script setup>
70 -import { ref } from "vue"; 72 +import { ref, onMounted } from "vue";
71 // import icon_vip from '@/images/icon/vip@2x.png' 73 // import icon_vip from '@/images/icon/vip@2x.png'
72 import Taro from '@tarojs/taro' 74 import Taro from '@tarojs/taro'
73 // import { AtAvatar } from 'taro-ui-vue3' 75 // import { AtAvatar } from 'taro-ui-vue3'
...@@ -78,7 +80,19 @@ import icon_user from '@/images/icon/peiban@2x.png' ...@@ -78,7 +80,19 @@ import icon_user from '@/images/icon/peiban@2x.png'
78 import icon_company from '@/images/icon/zhubanfang@2x.png' 80 import icon_company from '@/images/icon/zhubanfang@2x.png'
79 import navbar from '@/components/navbar.vue' 81 import navbar from '@/components/navbar.vue'
80 import activityCard from '@/components/activity-card.vue' 82 import activityCard from '@/components/activity-card.vue'
81 -import { text } from "stream/consumers"; 83 +import { hostListAPI } from '@/api/Host/index'
84 +import Toast from '@/components/vant-weapp/toast/toast';
85 +
86 +const host_id = ref('');
87 +onMounted(async () => {
88 + // 获取主办方列表信息
89 + const { code, data } = await hostListAPI();
90 + if (code) {
91 + if (data.my_hosts.length) {
92 + host_id.value = data.my_hosts[0]?.id
93 + }
94 + }
95 +})
82 96
83 // 参加的活动 97 // 参加的活动
84 const joinActivity = () => { 98 const joinActivity = () => {
...@@ -88,8 +102,12 @@ const joinActivity = () => { ...@@ -88,8 +102,12 @@ const joinActivity = () => {
88 } 102 }
89 // 创建的活动 103 // 创建的活动
90 const createActivity = () => { 104 const createActivity = () => {
105 + if (!host_id.value) {
106 + Toast('您还未创建过主办方');
107 + return false;
108 + }
91 Taro.navigateTo({ 109 Taro.navigateTo({
92 - url: '../myCreateActivity/index' 110 + url: '../myCreateActivity/index?host_id=' + host_id.value
93 }) 111 })
94 } 112 }
95 // 陪伴的用户 113 // 陪伴的用户
......
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-08 13:47:07 4 + * @LastEditTime: 2022-10-26 09:42:30
5 * @FilePath: /swx/src/pages/myCreateActivity/index.vue 5 * @FilePath: /swx/src/pages/myCreateActivity/index.vue
6 * @Description: 文件描述 6 * @Description: 文件描述
7 --> 7 -->
8 <template> 8 <template>
9 <div class="my-create-activity-page"> 9 <div class="my-create-activity-page">
10 - <view style="width: 100%; background-image: url(http://gyzs.onwall.cn/userinfo_bg-top%402x.png); background-size: contain; background-repeat: no-repeat;"> 10 + <view id="page-header" style="width: 100%; background-image: url(http://gyzs.onwall.cn/userinfo_bg-top%402x.png); background-size: contain; background-repeat: no-repeat;">
11 <view style="height: 4rem; padding: 1rem;"> 11 <view style="height: 4rem; padding: 1rem;">
12 <van-row> 12 <van-row>
13 <van-col span="18"> 13 <van-col span="18">
14 <view style="position: relative;"> 14 <view style="position: relative;">
15 - <AtAvatar circle size="large" image='https://jdc.jd.com/img/200' style="display: inline-block;"></AtAvatar> 15 + <AtAvatar circle size="large" :image='icon_company' style="display: inline-block;"></AtAvatar>
16 <view style="display: inline-block; position: absolute; top: 30%; left: 28%;"> 16 <view style="display: inline-block; position: absolute; top: 30%; left: 28%;">
17 - <text style="font-size: 1.05rem;">周三读书会(主办方)</text> 17 + <text style="font-size: 1.05rem;">{{ host_name }}</text>
18 - <van-icon :name="icon_vip" size="1rem" color="" class="vip-icon" /> 18 + <!-- <van-icon :name="icon_vip" size="1rem" color="" class="vip-icon" /> -->
19 </view> 19 </view>
20 </view> 20 </view>
21 </van-col> 21 </van-col>
22 <van-col span="6"> 22 <van-col span="6">
23 - <view @tap="editInfo()" style="background-color: #DABE73; color: white; padding: 0.5rem 0; border-radius: 1rem; text-align: center; font-size: 0.85rem;margin-top: 1rem;">切换主办方</view> 23 + <view @tap="show_host_popup=true" style="background-color: #DABE73; color: white; padding: 0.5rem 0; border-radius: 1rem; text-align: center; font-size: 0.85rem;margin-top: 1rem;">切换主办方</view>
24 </van-col> 24 </van-col>
25 </van-row> 25 </van-row>
26 </view> 26 </view>
...@@ -32,21 +32,21 @@ ...@@ -32,21 +32,21 @@
32 </view> 32 </view>
33 <view class="header-info"> 33 <view class="header-info">
34 <view class="activity"> 34 <view class="activity">
35 - <view><text style="font-size: 1.25rem;">5</text>场</view> 35 + <view><text style="font-size: 1.25rem;">{{ activity_count }}</text>场</view>
36 <view> 36 <view>
37 <van-icon :name="icon_join" size="1.5rem" color="" style="vertical-align: sub;" /> 37 <van-icon :name="icon_join" size="1.5rem" color="" style="vertical-align: sub;" />
38 <text style="font-size: 0.9rem; color: #999999;">活动总数</text> 38 <text style="font-size: 0.9rem; color: #999999;">活动总数</text>
39 </view> 39 </view>
40 </view> 40 </view>
41 <view class="job"> 41 <view class="job">
42 - <text style="font-size: 1.25rem;">24</text>人 42 + <text style="font-size: 1.25rem;">{{ volunteer_count }}</text>人
43 <view> 43 <view>
44 <van-icon :name="icon_job" size="1.25rem" color="" style="vertical-align: sub;" /> 44 <van-icon :name="icon_job" size="1.25rem" color="" style="vertical-align: sub;" />
45 <text style="font-size: 0.9rem; color: #999999;">岗位人数</text> 45 <text style="font-size: 0.9rem; color: #999999;">岗位人数</text>
46 </view> 46 </view>
47 </view> 47 </view>
48 <view class="sign"> 48 <view class="sign">
49 - <view><text style="font-size: 1.25rem;">233</text>人</view> 49 + <view><text style="font-size: 1.25rem;">{{ member_count }}</text>人</view>
50 <view> 50 <view>
51 <van-icon :name="icon_sign" size="1.25rem" color="" style="vertical-align: sub;" /> 51 <van-icon :name="icon_sign" size="1.25rem" color="" style="vertical-align: sub;" />
52 <text style="font-size: 0.9rem; color: #999999;">用户总数</text> 52 <text style="font-size: 0.9rem; color: #999999;">用户总数</text>
...@@ -56,11 +56,15 @@ ...@@ -56,11 +56,15 @@
56 </view> 56 </view>
57 </view> 57 </view>
58 <view style="padding: 0 1rem;"> 58 <view style="padding: 0 1rem;">
59 - <view style="background-color: white; border-radius: 0.65rem; padding: 1rem;overflow: auto; margin-bottom: 1px;"> 59 + <view id="navbar-page" style="background-color: white; border-radius: 0.65rem; padding: 1rem;overflow: auto; margin-bottom: 1px;">
60 <view @tap="show_status_popup=true" style="float: left; color: #666666; font-size: 0.9rem; border: 1px solid #DBDBDB; border-radius: 1rem; padding: 0.3rem 1rem 0.3rem 1rem;"> 60 <view @tap="show_status_popup=true" style="float: left; color: #666666; font-size: 0.9rem; border: 1px solid #DBDBDB; border-radius: 1rem; padding: 0.3rem 1rem 0.3rem 1rem;">
61 &nbsp;{{ status_type === '' ? '全部' : status_type }}&nbsp;&nbsp; 61 &nbsp;{{ status_type === '' ? '全部' : status_type }}&nbsp;&nbsp;
62 <van-icon :name="icon_sel2" size="0.8rem" color="" style="vertical-align: middle;" /> 62 <van-icon :name="icon_sel2" size="0.8rem" color="" style="vertical-align: middle;" />
63 </view> 63 </view>
64 + <view style="float: right; margin-top: 0.25rem;">
65 + <text style="font-size: 1rem; color: #999999; vertical-align: super;">仅看进行中</text>&nbsp;
66 + <van-switch :checked="check_status" @change="onChange" size="22px" active-color="#199A74" />
67 + </view>
64 </view> 68 </view>
65 <view style=""> 69 <view style="">
66 <activity-card v-for="(item, index) in activity_list" :key="index" :data="item" status="edit" style="margin-bottom: 1rem;"></activity-card> 70 <activity-card v-for="(item, index) in activity_list" :key="index" :data="item" status="edit" style="margin-bottom: 1rem;"></activity-card>
...@@ -69,11 +73,19 @@ ...@@ -69,11 +73,19 @@
69 </view> 73 </view>
70 </div> 74 </div>
71 75
72 - <!-- 切换状态弹出框 --> 76 + <!-- 切换主办方弹出框 -->
73 - <van-popup :show="show_status_popup" position="bottom" custom-style="height: 45%;" :lock-scroll="true"> 77 + <van-popup :show="show_host_popup" position="bottom" custom-style="height: 50%;" :lock-scroll="true">
78 + <van-picker :show-toolbar="true" title="" confirm-button-text="确定" :columns="host_columns"
79 + toolbar-class="picker-toolbar" @confirm="onHostConfirm" @cancel="onHostCancel" />
80 + </van-popup>
81 + <!-- 切换时间弹出框 -->
82 + <van-popup :show="show_status_popup" position="bottom" custom-style="height: 50%;" :lock-scroll="true">
74 <van-picker :show-toolbar="true" title="" confirm-button-text="确定" :columns="status_type_columns" 83 <van-picker :show-toolbar="true" title="" confirm-button-text="确定" :columns="status_type_columns"
75 - toolbar-class="picker-toolbar" @confirm="onStatusTypeConfirm" @cancel="onStatusTypeCancel" @change="onStatusTypeChange" /> 84 + :default-index="defaultIndex"
85 + toolbar-class="picker-toolbar" @confirm="onStatusTypeConfirm" @cancel="onStatusTypeCancel"/>
76 </van-popup> 86 </van-popup>
87 + <van-toast id="van-toast" />
88 +
77 </template> 89 </template>
78 90
79 <script setup> 91 <script setup>
...@@ -87,47 +99,195 @@ import icon_job from '@/images/icon/yigong@2x.png' ...@@ -87,47 +99,195 @@ import icon_job from '@/images/icon/yigong@2x.png'
87 import icon_sign from '@/images/icon/qiandao@2x.png' 99 import icon_sign from '@/images/icon/qiandao@2x.png'
88 import icon_sel2 from '@/images/icon/sel02@2x.png' 100 import icon_sel2 from '@/images/icon/sel02@2x.png'
89 import activityCard from '@/components/activity-card.vue' 101 import activityCard from '@/components/activity-card.vue'
102 +import icon_company from '@/images/icon/zhubanfang@2x.png'
103 +import Toast from '@/components/vant-weapp/toast/toast';
90 104
91 -const show_status_popup = ref(false);
92 -const status_type = ref('');
93 -const status_type_columns = ref(['一个月之内', '三个月之内', '一年之内']);
94 -const onStatusTypeChange = (event) => {
95 - const { picker, value, index } = event.detail;
96 -}
97 -const onStatusTypeConfirm = (event) => {
98 - const { picker, value, index } = event.detail;
99 - show_status_popup.value = false;
100 - status_type.value = value;
101 - console.warn('查询新数据');
102 -}
103 -const onStatusTypeCancel = (event) => {
104 - show_status_popup.value = false;
105 -}
106 -
107 -const activity_list = ref([{
108 - title: '智慧没有烦恼',
109 - address: '上海市杨浦区军工路100号A座05室',
110 -}, {
111 - title: '万人共乘浪漫热气球',
112 - address: '',
113 -}, {
114 - title: '八段锦',
115 - address: '',
116 -}, {
117 - title: '智慧没有烦恼',
118 - address: '上海市杨浦区军工路100号A座05室',
119 -}, {
120 - title: '万人共乘浪漫热气球',
121 - address: '',
122 -}, {
123 - title: '八段锦',
124 - address: '',
125 -}]);
126 </script> 105 </script>
127 106
128 <script> 107 <script>
129 import "./index.less"; 108 import "./index.less";
109 +import { addListAPI } from '@/api/Activity/index';
110 +import { $ } from '@tarojs/extend'
111 +import mixin from '@/utils/mixin';
112 +import { getCurrentPageParam } from "@/utils/weapp";
113 +import { hostListAPI } from '@/api/Host/index'
114 +import * as dayjs from 'dayjs'
115 +
130 export default { 116 export default {
131 - name: "demoPage", 117 + name: "myCreateActivityPage",
118 + mixins: [mixin.init],
119 + async onShow () {
120 + // 获取主办方列表信息
121 + const host = await hostListAPI();
122 + if (host.code) {
123 + host.data.my_hosts.forEach(item => {
124 + if (item.id == getCurrentPageParam().host_id) {
125 + this.host_id = item.id;
126 + this.host_name = item.name;
127 + }
128 + item.text = item.name;
129 + item.key = item.id;
130 + });
131 + this.host_columns = host.data.my_hosts;
132 + }
133 + const params = {
134 + host_id: getCurrentPageParam().host_id,
135 + time_begin: this.time_begin,
136 + time_end: this.time_end,
137 + status: this.status,
138 + only_start: this.only_start,
139 + page: this.page,
140 + limit: this.limit
141 + }
142 + const { code, data } = await addListAPI(params);
143 + if (code) {
144 + this.activity_list = data.activity_list;
145 + this.activity_count = data.activity_count;
146 + this.volunteer_count = data.volunteer_count;
147 + this.member_count = data.member_count;
148 + this.server_time = this.formatDate(data.server_time);
149 + this.page = this.page + 1;
150 + }
151 + },
152 + onHide () { // 离开当前页面
153 + this.page = 0;
154 + this.flag = true;
155 + },
156 + mounted () {
157 + // 设置滚动列表可视高度
158 + const windowHeight = wx.getSystemInfoSync().windowHeight;
159 + setTimeout(async () => {
160 + const headerHeight = await $('#page-header').height();
161 + const navHeight = await $('#navbar-page').height();
162 + this.scrollStyle = {
163 + height: windowHeight - headerHeight - navHeight - 50 + 'px'
164 + }
165 + }, 500);
166 + },
167 + data() {
168 + return {
169 + activity_list: [],
170 + flag: true,
171 + page: 0,
172 + limit: 10,
173 + scrollStyle: { height: '1000rpx' },
174 + status: '',
175 + activity_count: '',
176 + member_count: '',
177 + volunteer_count: '',
178 + show_status_popup: false,
179 + status_type: '',
180 + status_type_columns: ['全部', '一个月之内', '三个月之内', '一年之内'],
181 + show_host_popup: false,
182 + host_columns: [],
183 + time_begin: '',
184 + time_end: '',
185 + only_start: 0,
186 + host_id: '',
187 + host_name: '',
188 + check_status: false,
189 + filter_time: '',
190 + server_time: '',
191 + defaultIndex: 0
192 + };
193 + },
194 + methods: {
195 + formatDate (date) {
196 + return dayjs(date).format('YYYY-MM-DD HH:mm')
197 + },
198 + onScrollToLower () {
199 + if(!this.flag){
200 + return
201 + }
202 + this.flag = false;
203 + this.getList();
204 + },
205 + async getList () {
206 + // 获取推荐活动列表
207 + const params = {
208 + host_id: this.host_id,
209 + time_begin: this.time_begin,
210 + time_end: this.time_end,
211 + status: this.status,
212 + only_start: this.only_start,
213 + page: this.page,
214 + limit: this.limit
215 + }
216 + const { code, data } = await addListAPI(params);
217 + if (code) {
218 + if (data.activity_list.length) {
219 + this.activity_list = this.activity_list.concat(data.activity_list);
220 + this.activity_count = data.activity_count;
221 + this.volunteer_count = data.volunteer_count;
222 + this.member_count = data.member_count;
223 + this.page = this.page + 1;
224 + this.flag = true;
225 + } else {
226 + Toast('没有数据')
227 + }
228 + }
229 + },
230 + onStatusTypeConfirm (event) { // 时间过滤
231 + const { picker, value, index } = event.detail;
232 + this.show_status_popup = false;
233 + this.filter_time = value;
234 + // '一个月之内', '三个月之内', '一年之内'
235 + let yearMonthDay = '';
236 + if (this.filter_time === '一个月之内') {
237 + yearMonthDay = dayjs(this.server_time).subtract(1, 'month');
238 + this.defaultIndex = 1;
239 + this.status_type = '一个月之内';
240 + }
241 + if (this.filter_time === '三个月之内') {
242 + yearMonthDay = dayjs(this.server_time).subtract(3, 'month');
243 + this.defaultIndex = 2;
244 + this.status_type = '三个月之内';
245 + }
246 + if (this.filter_time === '一年之内') {
247 + yearMonthDay = dayjs(this.server_time).subtract(1, 'year');
248 + this.defaultIndex = 3;
249 + this.status_type = '一年之内';
250 + }
251 + this.time_begin = `${dayjs(yearMonthDay).format('YYYY-MM-DD')} ${dayjs(this.server_time).format('HH:mm')}`;
252 + this.time_end = this.server_time;
253 + if (this.filter_time === '全部') {
254 + this.time_begin = '';
255 + this.time_end = '';
256 + this.defaultIndex = 0;
257 + this.status_type = '全部';
258 + }
259 + // 查询数据
260 + this.activity_list = [];
261 + this.flag = true;
262 + this.page = 0;
263 + this.getList();
264 + },
265 + onStatusTypeCancel (event) {
266 + this.show_status_popup = false;
267 + },
268 + onHostConfirm (event) {
269 + const { picker, value, index } = event.detail;
270 + this.show_host_popup = false;
271 + this.host_id = value.key;
272 + this.host_name = value.text;
273 + // 查询数据
274 + this.activity_list = [];
275 + this.flag = true;
276 + this.page = 0;
277 + this.getList();
278 + },
279 + onHostCancel (event) {
280 + this.show_host_popup = false;
281 + },
282 + onChange({ detail }) {
283 + this.check_status = detail;
284 + this.only_start = detail ? 1 : 0;
285 + // 查询数据
286 + this.activity_list = [];
287 + this.flag = true;
288 + this.page = 0;
289 + this.getList();
290 + }
291 + },
132 }; 292 };
133 </script> 293 </script>
......