hookehuyr

处理义工相关功能逻辑

1 <!-- 1 <!--
2 * @Date: 2022-09-26 16:10:35 2 * @Date: 2022-09-26 16:10:35
3 * @LastEditors: hookehuyr hookehuyr@gmail.com 3 * @LastEditors: hookehuyr hookehuyr@gmail.com
4 - * @LastEditTime: 2022-10-25 17:08:45 4 + * @LastEditTime: 2022-10-27 18:35:16
5 * @FilePath: /swx/src/components/activity-bar.vue 5 * @FilePath: /swx/src/components/activity-bar.vue
6 * @Description: 活动详情页底部导航栏 6 * @Description: 活动详情页底部导航栏
7 --> 7 -->
...@@ -50,6 +50,8 @@ ...@@ -50,6 +50,8 @@
50 </van-col> 50 </van-col>
51 </van-row> 51 </van-row>
52 </view> 52 </view>
53 + <van-toast id="van-toast" />
54 +
53 </template> 55 </template>
54 56
55 <script setup> 57 <script setup>
...@@ -57,6 +59,7 @@ import { ref, defineProps } from 'vue' ...@@ -57,6 +59,7 @@ import { ref, defineProps } from 'vue'
57 import icon_home1 from '@/images/icon/home01@2x.png' 59 import icon_home1 from '@/images/icon/home01@2x.png'
58 import Taro from '@tarojs/taro' 60 import Taro from '@tarojs/taro'
59 import { getCurrentPageParam } from "@/utils/weapp"; 61 import { getCurrentPageParam } from "@/utils/weapp";
62 +import Toast from '@/components/vant-weapp/toast/toast';
60 63
61 const props = defineProps({ 64 const props = defineProps({
62 // player=参与者,可报名活动。 65 // player=参与者,可报名活动。
...@@ -67,8 +70,10 @@ const props = defineProps({ ...@@ -67,8 +70,10 @@ const props = defineProps({
67 userType: String, 70 userType: String,
68 regId: String, 71 regId: String,
69 memberRole : String, 72 memberRole : String,
73 + regRole : String,
70 isEnd : String, 74 isEnd : String,
71 activityStatus : String, 75 activityStatus : String,
76 + volunteerStatus : String,
72 }) 77 })
73 78
74 const goTo = (type) => { 79 const goTo = (type) => {
...@@ -81,17 +86,21 @@ const goTo = (type) => { ...@@ -81,17 +86,21 @@ const goTo = (type) => {
81 url: '../joinActivity/index?id=' + getCurrentPageParam().id 86 url: '../joinActivity/index?id=' + getCurrentPageParam().id
82 }) 87 })
83 } else if (type === 'volunteer') { // 义工报名 88 } else if (type === 'volunteer') { // 义工报名
84 - Taro.navigateTo({ 89 + if (props.volunteerStatus) {
85 - url: '../joinVolunteer/index?id=' + getCurrentPageParam().id 90 + Taro.navigateTo({
86 - }) 91 + url: '../joinVolunteer/index?id=' + getCurrentPageParam().id
92 + })
93 + } else {
94 + Toast('未设置义工岗位,不能报名!')
95 + }
87 } else if (type === 'info') { // 报名信息 96 } else if (type === 'info') { // 报名信息
88 - if (props.memberRole === 'player') { // 普通用户报名详情页 97 + if (props.regRole === 'player') { // 普通用户报名详情页
89 Taro.navigateTo({ 98 Taro.navigateTo({
90 url: '../joinInfo/index?reg_id=' + props.regId + '&id=' + getCurrentPageParam().id 99 url: '../joinInfo/index?reg_id=' + props.regId + '&id=' + getCurrentPageParam().id
91 }) 100 })
92 } else { // 义工报名详情页 101 } else { // 义工报名详情页
93 Taro.navigateTo({ 102 Taro.navigateTo({
94 - url: '../joinVolunteerInfo/index?reg_id=' + props.regId 103 + url: '../joinVolunteerInfo/index?reg_id=' + props.regId + '&id=' + getCurrentPageParam().id
95 }) 104 })
96 } 105 }
97 } else if (type === 'list') { // 报名列表 106 } else if (type === 'list') { // 报名列表
......
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-26 14:02:39 4 + * @LastEditTime: 2022-10-27 14:45:09
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" :activity-status="activity_status" /> 109 + <activity-bar :user-type="userType" :reg-id="reg_id" :member-role="member_role" :reg-role="reg_role" :is-end="is_end" :activity-status="activity_status" :volunteer-status="volunteer_status" />
110 110
111 <!-- <van-action-sheet 111 <!-- <van-action-sheet
112 :z-index="10" 112 :z-index="10"
...@@ -477,10 +477,13 @@ export default { ...@@ -477,10 +477,13 @@ export default {
477 this.is_end = data.activity.is_end; 477 this.is_end = data.activity.is_end;
478 this.host = data.host; 478 this.host = data.host;
479 this.member_role = data.member_role; 479 this.member_role = data.member_role;
480 + this.reg_role = data.reg_role;
480 this.reg_id = data.reg_id; 481 this.reg_id = data.reg_id;
482 + // 如果有岗位说明可以报名义工
483 + this.volunteer_status = this.activity?.extend.length ? true : false;
481 } 484 }
482 // 活动状态判断显示 485 // 活动状态判断显示
483 - this.activity_status = getCurrentPageParam().status; 486 + this.activity_status = getCurrentPageParam().status ? getCurrentPageParam().status : '';
484 }, 487 },
485 mounted() { 488 mounted() {
486 }, 489 },
...@@ -492,6 +495,7 @@ export default { ...@@ -492,6 +495,7 @@ export default {
492 reg_id: '', 495 reg_id: '',
493 is_end: '', 496 is_end: '',
494 activity_status: '', 497 activity_status: '',
498 + volunteer_status: false,
495 } 499 }
496 }, 500 },
497 computed: { 501 computed: {
......
1 <!-- 1 <!--
2 * @Date: 2022-09-27 17:13:05 2 * @Date: 2022-09-27 17:13:05
3 * @LastEditors: hookehuyr hookehuyr@gmail.com 3 * @LastEditors: hookehuyr hookehuyr@gmail.com
4 - * @LastEditTime: 2022-09-28 16:35:18 4 + * @LastEditTime: 2022-10-27 18:41:46
5 * @FilePath: /swx/src/pages/joinVolunteer/index.vue 5 * @FilePath: /swx/src/pages/joinVolunteer/index.vue
6 * @Description: 义工报名 6 * @Description: 义工报名
7 --> 7 -->
...@@ -15,8 +15,8 @@ ...@@ -15,8 +15,8 @@
15 <view class="at-input"> 15 <view class="at-input">
16 <view class="at-input__container"> 16 <view class="at-input__container">
17 <label class="h5-label at-input__title at-input__title">岗位</label> 17 <label class="h5-label at-input__title at-input__title">岗位</label>
18 - <input @tap="show_post_popup=true" class="h5-input at-input__input" placeholder-class="placeholder" :value="age_range" placeholder="请选择义工岗位" :disabled="true"/> 18 + <input @tap="show_post_popup=true" class="h5-input at-input__input" placeholder-class="placeholder" :value="post_status" placeholder="请选择义工岗位" :disabled="true"/>
19 - <view style="margin-right: 1rem; margin-top: 0.5rem;"><van-icon :name="icon_sel" color="" /></view> 19 + <view @tap="show_post_popup=true" style="margin-right: 1rem; margin-top: 0.5rem;"><van-icon :name="icon_sel" color="" /></view>
20 </view> 20 </view>
21 </view> 21 </view>
22 <AtInput :border="true" title="姓名" type='text' placeholder='请输入姓名' v-model:value="username" /> 22 <AtInput :border="true" title="姓名" type='text' placeholder='请输入姓名' v-model:value="username" />
...@@ -29,8 +29,8 @@ ...@@ -29,8 +29,8 @@
29 @change="onSexChange" 29 @change="onSexChange"
30 direction="horizontal" 30 direction="horizontal"
31 > 31 >
32 - <van-radio name="female" checked-color="#199A74">男士</van-radio> 32 + <van-radio name="man" checked-color="#199A74">男士</van-radio>
33 - <van-radio name="male" checked-color="#199A74">女士</van-radio> 33 + <van-radio name="woman" checked-color="#199A74">女士</van-radio>
34 </van-radio-group> 34 </van-radio-group>
35 </view> 35 </view>
36 </view> 36 </view>
...@@ -38,10 +38,13 @@ ...@@ -38,10 +38,13 @@
38 <bottom-button @on-submit="onSubmit">确认报名</bottom-button> 38 <bottom-button @on-submit="onSubmit">确认报名</bottom-button>
39 39
40 <!-- 年龄段弹出框 --> 40 <!-- 年龄段弹出框 -->
41 - <van-popup :show="show_post_popup" position="bottom" custom-style="height: 40%;" :lock-scroll="true"> 41 + <van-popup :show="show_post_popup" position="bottom" custom-style="height: 50%;" :lock-scroll="true">
42 <van-picker :show-toolbar="true" title="" confirm-button-text="确定" :columns="columns" toolbar-class="picker-toolbar" 42 <van-picker :show-toolbar="true" title="" confirm-button-text="确定" :columns="columns" toolbar-class="picker-toolbar"
43 - @confirm="onPostConfirm" @cancel="onPostCancel" @change="onPostChange" /> 43 + :default-index="defaultIndex"
44 + @confirm="onPostConfirm" @cancel="onPostCancel" />
44 </van-popup> 45 </van-popup>
46 + <van-toast id="van-toast" />
47 +
45 </template> 48 </template>
46 49
47 <script setup> 50 <script setup>
...@@ -51,54 +54,131 @@ import "taro-ui-vue3/dist/style/components/input.scss"; ...@@ -51,54 +54,131 @@ import "taro-ui-vue3/dist/style/components/input.scss";
51 import icon_sel from '@/images/icon/sel@2x.png' 54 import icon_sel from '@/images/icon/sel@2x.png'
52 import bottomButton from "@/components/bottom-button"; 55 import bottomButton from "@/components/bottom-button";
53 import Taro from '@tarojs/taro' 56 import Taro from '@tarojs/taro'
57 +import { myInfoAPI } from '@/api/Reg/index';
54 58
55 -const username = ref(''); 59 +const show_post_popup = ref(false)
56 -const phone = ref(''); 60 +const post_status = ref('')
57 -const age_range = ref(''); 61 +const username = ref('')
58 -const user_sex = ref(''); 62 +const phone = ref('')
63 +const user_sex = ref('man')
64 +const defaultIndex = ref(0)
59 65
60 -onMounted(() => { 66 +onMounted(async () => {
67 + // const { code, data } = await activityInfoAPI({ i: getCurrentPageParam().id });
68 + // if (code) {
69 + // // 额外的报名信息
70 + // fields.value = data.activity.fields;
71 + // fields.value.forEach(item => {
72 + // item.value = '';
73 + // });
74 + // }
75 + // 编辑模式
76 + if (getCurrentPageParam().type === 'edit') {
77 + // 动态修改标题
78 + wx.setNavigationBarTitle({
79 + title: '修改义工报名',
80 + });
81 + const { code, data } = await myInfoAPI({ i: getCurrentPageParam().reg_id });
82 + if (code) {
83 + username.value = data.name;
84 + phone.value = data.phone;
85 + post_status.value = data.post;
86 + user_sex.value = data.gender;
87 + }
88 + const info = await activityInfoAPI({ i: getCurrentPageParam().id });
89 + if (code) {
90 + info.data.activity.extend.forEach((item, index) => {
91 + if (post_status.value === item) {
92 + defaultIndex.value = index;
93 + }
94 + })
95 + }
96 + }
61 }) 97 })
62 98
63 -// const handleInput = (value) => {
64 -// console.warn(arr.value);
65 -// }
66 const onSexChange = ({ detail }) => { 99 const onSexChange = ({ detail }) => {
67 user_sex.value = detail; 100 user_sex.value = detail;
68 } 101 }
69 102
70 -const show_post_popup = ref(false); 103 +const onPostConfirm = ({ detail }) => {
71 -const post_status = ref('前台');
72 -const columns = ref(['前台', '后台']);
73 -const onPostChange = (event) => {
74 - const { picker, value, index } = event.detail;
75 - console.warn(value);
76 - console.warn(index);
77 - post_status.value = value;
78 -}
79 -const onPostConfirm = (event) => {
80 show_post_popup.value = false; 104 show_post_popup.value = false;
105 + post_status.value = detail.value;
81 } 106 }
82 const onPostCancel = (event) => { 107 const onPostCancel = (event) => {
83 show_post_popup.value = false; 108 show_post_popup.value = false;
84 } 109 }
85 - 110 +const validForm = () => {
86 -const onSubmit = (val) => { 111 + if (!post_status.value) {
87 - console.warn(val); 112 + Toast('岗位不能为空');
88 - Taro.showToast({ 113 + return false;
89 - title: '请检查输入项', 114 + }
90 - icon: 'error', 115 + if (!username.value) {
91 - duration: 2000 116 + Toast('姓名不能为空');
92 - }); 117 + return false;
93 - // Taro.redirectTo({ 118 + }
94 - // url: '../joinSuccess/index' 119 + if (!phone.value) {
95 - // }) 120 + Toast('手机号不能为空');
121 + return false;
122 + }
123 + const pattern = /^\d{11}$/;
124 + if (!pattern.test(phone.value)) {
125 + Toast('请输入正确手机号');
126 + return false;
127 + }
128 + if (!user_sex.value) {
129 + Toast('性别不能为空');
130 + return false;
131 + }
132 + return true;
96 } 133 }
134 +const onSubmit = async () => {
135 + if (validForm()) {
136 + const params = {
137 + activity_id: getCurrentPageParam().id,
138 + type: 'volunteer',
139 + name: username.value,
140 + phone: phone.value,
141 + gender: user_sex.value,
142 + post: post_status.value
143 + }
144 + const { code } = await addRegAPI(params);
145 + if (code) {
146 + Taro.showToast({
147 + title: '报名成功',
148 + icon: 'success',
149 + duration: 3000,
150 + success: function () {
151 + Taro.navigateBack()
152 + }
153 + });
154 + }
155 + }
156 +}
157 +
97 </script> 158 </script>
98 159
99 <script> 160 <script>
100 import "./index.less"; 161 import "./index.less";
162 +import { activityInfoAPI } from '@/api/Host/index';
163 +import { getCurrentPageParam } from "@/utils/weapp";
164 +import { addRegAPI } from '@/api/Reg/index';
165 +import Toast from '@/components/vant-weapp/toast/toast';
166 +
101 export default { 167 export default {
102 - name: "demoPage", 168 + name: "joinVolunteerPage",
169 + async onShow () {
170 + // 获取活动详情
171 + const { code, data } = await activityInfoAPI({ i: getCurrentPageParam().id });
172 + if (code) {
173 + this.columns = data.activity.extend;
174 + }
175 + },
176 + data () {
177 + return {
178 + columns: [],
179 + }
180 + },
181 + methods: {
182 + },
103 }; 183 };
104 </script> 184 </script>
......
1 <!-- 1 <!--
2 * @Date: 2022-09-27 17:13:05 2 * @Date: 2022-09-27 17:13:05
3 * @LastEditors: hookehuyr hookehuyr@gmail.com 3 * @LastEditors: hookehuyr hookehuyr@gmail.com
4 - * @LastEditTime: 2022-10-20 17:48:47 4 + * @LastEditTime: 2022-10-27 18:37:45
5 * @FilePath: /swx/src/pages/joinVolunteerInfo/index.vue 5 * @FilePath: /swx/src/pages/joinVolunteerInfo/index.vue
6 - * @Description: 活动报名 6 + * @Description: 义工报名
7 --> 7 -->
8 <template> 8 <template>
9 <view class="join-activity-page"> 9 <view class="join-activity-page">
...@@ -15,7 +15,7 @@ ...@@ -15,7 +15,7 @@
15 <view class="at-input"> 15 <view class="at-input">
16 <view class="at-input__container"> 16 <view class="at-input__container">
17 <label class="h5-label at-input__title at-input__title">岗位</label> 17 <label class="h5-label at-input__title at-input__title">岗位</label>
18 - <input class="h5-input at-input__input" placeholder-class="placeholder" :value="extend" placeholder="" :disabled="true"/> 18 + <input class="h5-input at-input__input" placeholder-class="placeholder" :value="post" placeholder="" :disabled="true"/>
19 </view> 19 </view>
20 </view> 20 </view>
21 <view class="at-input"> 21 <view class="at-input">
...@@ -32,12 +32,6 @@ ...@@ -32,12 +32,6 @@
32 </view> 32 </view>
33 <view class="at-input"> 33 <view class="at-input">
34 <view class="at-input__container"> 34 <view class="at-input__container">
35 - <label class="h5-label at-input__title at-input__title">年龄段</label>
36 - <input class="h5-input at-input__input" placeholder-class="placeholder" :value="age_group" placeholder="" :disabled="true"/>
37 - </view>
38 - </view>
39 - <view class="at-input">
40 - <view class="at-input__container">
41 <label class="h5-label at-input__title at-input__title">性别</label> 35 <label class="h5-label at-input__title at-input__title">性别</label>
42 <input class="h5-input at-input__input" placeholder-class="placeholder" :value="user_sex" placeholder="" :disabled="true"/> 36 <input class="h5-input at-input__input" placeholder-class="placeholder" :value="user_sex" placeholder="" :disabled="true"/>
43 </view> 37 </view>
...@@ -52,51 +46,44 @@ ...@@ -52,51 +46,44 @@
52 <view @tap="editJoin" class="button">确认修改报名</view> 46 <view @tap="editJoin" class="button">确认修改报名</view>
53 </view> 47 </view>
54 </view> 48 </view>
49 + <van-dialog id="van-dialog" />
50 +
55 </template> 51 </template>
56 52
57 <script setup> 53 <script setup>
58 import { ref, onMounted } from "vue"; 54 import { ref, onMounted } from "vue";
59 import "taro-ui-vue3/dist/style/components/input.scss"; 55 import "taro-ui-vue3/dist/style/components/input.scss";
60 import Taro from '@tarojs/taro' 56 import Taro from '@tarojs/taro'
61 -import { myInfoAPI } from '@/api/Reg/index'; 57 +import { myInfoAPI, cancelRegAPI } from '@/api/Reg/index';
62 import { getCurrentPageParam } from "@/utils/weapp"; 58 import { getCurrentPageParam } from "@/utils/weapp";
59 +import Dialog from '@/components/vant-weapp/dialog/dialog';
63 60
64 -const username = ref(''); 61 +const cancelJoin = (val) => {
65 -const phone = ref(''); 62 + Dialog.confirm({
66 -const age_group = ref(''); 63 + title: '温馨提示',
67 -const user_sex = ref(''); 64 + message: '是否确认取消报名?',
68 -const extend = ref([]); 65 + confirmButtonColor: '#199a74'
69 - 66 + })
70 -onMounted(async () => { 67 + .then(async () => {
71 - const { code, data } = await myInfoAPI({ i: getCurrentPageParam().reg_id }); 68 + // on confirm
72 - if (code) { 69 + const { code, data } = await cancelRegAPI({ i: getCurrentPageParam().reg_id });
73 - username.value = data.name; 70 + if (code) {
74 - phone.value = data.phone; 71 + Taro.showToast({
75 - age_group.value = data.age_group; 72 + title: '取消成功',
76 - user_sex.value = data.gender === 'man' ? '男士' : '女士'; 73 + icon: 'success',
77 - // 额外信息 74 + duration: 2000
78 - if (data.extend) {
79 - for (const key in data.extend) {
80 - extend.value.push({
81 - title: key,
82 - value: data.extend[key],
83 }); 75 });
76 + Taro.navigateBack()
84 } 77 }
85 - } 78 + })
86 - } 79 + .catch(() => {
87 -}) 80 + // on cancel
88 - 81 + });
89 -const cancelJoin = (val) => {
90 - Taro.showToast({
91 - title: '取消成功',
92 - icon: 'success',
93 - duration: 2000
94 - });
95 } 82 }
96 83
97 const editJoin = (val) => { 84 const editJoin = (val) => {
98 Taro.navigateTo({ 85 Taro.navigateTo({
99 - url: '../joinActivity/index' 86 + url: '../joinVolunteer/index?type=edit&reg_id=' + getCurrentPageParam().reg_id + '&id=' + getCurrentPageParam().id
100 }) 87 })
101 } 88 }
102 </script> 89 </script>
...@@ -105,5 +92,22 @@ const editJoin = (val) => { ...@@ -105,5 +92,22 @@ const editJoin = (val) => {
105 import "./index.less"; 92 import "./index.less";
106 export default { 93 export default {
107 name: "demoPage", 94 name: "demoPage",
95 + data () {
96 + return {
97 + username: '',
98 + phone: '',
99 + user_sex: '',
100 + post: '',
101 + }
102 + },
103 + async onShow () {
104 + const { code, data } = await myInfoAPI({ i: getCurrentPageParam().reg_id });
105 + if (code) {
106 + this.username = data.name;
107 + this.phone = data.phone;
108 + this.post = data.post;
109 + this.user_sex = data.gender === 'man' ? '男士' : '女士';
110 + }
111 + }
108 }; 112 };
109 </script> 113 </script>
......