hookehuyr

处理义工相关功能逻辑

<!--
* @Date: 2022-09-26 16:10:35
* @LastEditors: hookehuyr hookehuyr@gmail.com
* @LastEditTime: 2022-10-25 17:08:45
* @LastEditTime: 2022-10-27 18:35:16
* @FilePath: /swx/src/components/activity-bar.vue
* @Description: 活动详情页底部导航栏
-->
......@@ -50,6 +50,8 @@
</van-col>
</van-row>
</view>
<van-toast id="van-toast" />
</template>
<script setup>
......@@ -57,6 +59,7 @@ import { ref, defineProps } from 'vue'
import icon_home1 from '@/images/icon/home01@2x.png'
import Taro from '@tarojs/taro'
import { getCurrentPageParam } from "@/utils/weapp";
import Toast from '@/components/vant-weapp/toast/toast';
const props = defineProps({
// player=参与者,可报名活动。
......@@ -67,8 +70,10 @@ const props = defineProps({
userType: String,
regId: String,
memberRole : String,
regRole : String,
isEnd : String,
activityStatus : String,
volunteerStatus : String,
})
const goTo = (type) => {
......@@ -81,17 +86,21 @@ const goTo = (type) => {
url: '../joinActivity/index?id=' + getCurrentPageParam().id
})
} else if (type === 'volunteer') { // 义工报名
if (props.volunteerStatus) {
Taro.navigateTo({
url: '../joinVolunteer/index?id=' + getCurrentPageParam().id
})
} else {
Toast('未设置义工岗位,不能报名!')
}
} else if (type === 'info') { // 报名信息
if (props.memberRole === 'player') { // 普通用户报名详情页
if (props.regRole === 'player') { // 普通用户报名详情页
Taro.navigateTo({
url: '../joinInfo/index?reg_id=' + props.regId + '&id=' + getCurrentPageParam().id
})
} else { // 义工报名详情页
Taro.navigateTo({
url: '../joinVolunteerInfo/index?reg_id=' + props.regId
url: '../joinVolunteerInfo/index?reg_id=' + props.regId + '&id=' + getCurrentPageParam().id
})
}
} else if (type === 'list') { // 报名列表
......
<!--
* @Date: 2022-09-26 14:36:57
* @LastEditors: hookehuyr hookehuyr@gmail.com
* @LastEditTime: 2022-10-26 14:02:39
* @LastEditTime: 2022-10-27 14:45:09
* @FilePath: /swx/src/pages/activityDetail/index.vue
* @Description: 活动详情页
-->
......@@ -106,7 +106,7 @@
</view>
</view>
<view style="height: 6rem;"></view>
<activity-bar :user-type="userType" :reg-id="reg_id" :member-role="member_role" :is-end="is_end" :activity-status="activity_status" />
<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" />
<!-- <van-action-sheet
:z-index="10"
......@@ -477,10 +477,13 @@ export default {
this.is_end = data.activity.is_end;
this.host = data.host;
this.member_role = data.member_role;
this.reg_role = data.reg_role;
this.reg_id = data.reg_id;
// 如果有岗位说明可以报名义工
this.volunteer_status = this.activity?.extend.length ? true : false;
}
// 活动状态判断显示
this.activity_status = getCurrentPageParam().status;
this.activity_status = getCurrentPageParam().status ? getCurrentPageParam().status : '';
},
mounted() {
},
......@@ -492,6 +495,7 @@ export default {
reg_id: '',
is_end: '',
activity_status: '',
volunteer_status: false,
}
},
computed: {
......
<!--
* @Date: 2022-09-27 17:13:05
* @LastEditors: hookehuyr hookehuyr@gmail.com
* @LastEditTime: 2022-09-28 16:35:18
* @LastEditTime: 2022-10-27 18:41:46
* @FilePath: /swx/src/pages/joinVolunteer/index.vue
* @Description: 义工报名
-->
......@@ -15,8 +15,8 @@
<view class="at-input">
<view class="at-input__container">
<label class="h5-label at-input__title at-input__title">岗位</label>
<input @tap="show_post_popup=true" class="h5-input at-input__input" placeholder-class="placeholder" :value="age_range" placeholder="请选择义工岗位" :disabled="true"/>
<view style="margin-right: 1rem; margin-top: 0.5rem;"><van-icon :name="icon_sel" color="" /></view>
<input @tap="show_post_popup=true" class="h5-input at-input__input" placeholder-class="placeholder" :value="post_status" placeholder="请选择义工岗位" :disabled="true"/>
<view @tap="show_post_popup=true" style="margin-right: 1rem; margin-top: 0.5rem;"><van-icon :name="icon_sel" color="" /></view>
</view>
</view>
<AtInput :border="true" title="姓名" type='text' placeholder='请输入姓名' v-model:value="username" />
......@@ -29,8 +29,8 @@
@change="onSexChange"
direction="horizontal"
>
<van-radio name="female" checked-color="#199A74">男士</van-radio>
<van-radio name="male" checked-color="#199A74">女士</van-radio>
<van-radio name="man" checked-color="#199A74">男士</van-radio>
<van-radio name="woman" checked-color="#199A74">女士</van-radio>
</van-radio-group>
</view>
</view>
......@@ -38,10 +38,13 @@
<bottom-button @on-submit="onSubmit">确认报名</bottom-button>
<!-- 年龄段弹出框 -->
<van-popup :show="show_post_popup" position="bottom" custom-style="height: 40%;" :lock-scroll="true">
<van-popup :show="show_post_popup" position="bottom" custom-style="height: 50%;" :lock-scroll="true">
<van-picker :show-toolbar="true" title="" confirm-button-text="确定" :columns="columns" toolbar-class="picker-toolbar"
@confirm="onPostConfirm" @cancel="onPostCancel" @change="onPostChange" />
:default-index="defaultIndex"
@confirm="onPostConfirm" @cancel="onPostCancel" />
</van-popup>
<van-toast id="van-toast" />
</template>
<script setup>
......@@ -51,54 +54,131 @@ import "taro-ui-vue3/dist/style/components/input.scss";
import icon_sel from '@/images/icon/sel@2x.png'
import bottomButton from "@/components/bottom-button";
import Taro from '@tarojs/taro'
import { myInfoAPI } from '@/api/Reg/index';
const username = ref('');
const phone = ref('');
const age_range = ref('');
const user_sex = ref('');
const show_post_popup = ref(false)
const post_status = ref('')
const username = ref('')
const phone = ref('')
const user_sex = ref('man')
const defaultIndex = ref(0)
onMounted(() => {
onMounted(async () => {
// const { code, data } = await activityInfoAPI({ i: getCurrentPageParam().id });
// if (code) {
// // 额外的报名信息
// fields.value = data.activity.fields;
// fields.value.forEach(item => {
// item.value = '';
// });
// }
// 编辑模式
if (getCurrentPageParam().type === 'edit') {
// 动态修改标题
wx.setNavigationBarTitle({
title: '修改义工报名',
});
const { code, data } = await myInfoAPI({ i: getCurrentPageParam().reg_id });
if (code) {
username.value = data.name;
phone.value = data.phone;
post_status.value = data.post;
user_sex.value = data.gender;
}
const info = await activityInfoAPI({ i: getCurrentPageParam().id });
if (code) {
info.data.activity.extend.forEach((item, index) => {
if (post_status.value === item) {
defaultIndex.value = index;
}
})
}
}
})
// const handleInput = (value) => {
// console.warn(arr.value);
// }
const onSexChange = ({ detail }) => {
user_sex.value = detail;
}
const show_post_popup = ref(false);
const post_status = ref('前台');
const columns = ref(['前台', '后台']);
const onPostChange = (event) => {
const { picker, value, index } = event.detail;
console.warn(value);
console.warn(index);
post_status.value = value;
}
const onPostConfirm = (event) => {
const onPostConfirm = ({ detail }) => {
show_post_popup.value = false;
post_status.value = detail.value;
}
const onPostCancel = (event) => {
show_post_popup.value = false;
}
const onSubmit = (val) => {
console.warn(val);
const validForm = () => {
if (!post_status.value) {
Toast('岗位不能为空');
return false;
}
if (!username.value) {
Toast('姓名不能为空');
return false;
}
if (!phone.value) {
Toast('手机号不能为空');
return false;
}
const pattern = /^\d{11}$/;
if (!pattern.test(phone.value)) {
Toast('请输入正确手机号');
return false;
}
if (!user_sex.value) {
Toast('性别不能为空');
return false;
}
return true;
}
const onSubmit = async () => {
if (validForm()) {
const params = {
activity_id: getCurrentPageParam().id,
type: 'volunteer',
name: username.value,
phone: phone.value,
gender: user_sex.value,
post: post_status.value
}
const { code } = await addRegAPI(params);
if (code) {
Taro.showToast({
title: '请检查输入项',
icon: 'error',
duration: 2000
title: '报名成功',
icon: 'success',
duration: 3000,
success: function () {
Taro.navigateBack()
}
});
// Taro.redirectTo({
// url: '../joinSuccess/index'
// })
}
}
}
</script>
<script>
import "./index.less";
import { activityInfoAPI } from '@/api/Host/index';
import { getCurrentPageParam } from "@/utils/weapp";
import { addRegAPI } from '@/api/Reg/index';
import Toast from '@/components/vant-weapp/toast/toast';
export default {
name: "demoPage",
name: "joinVolunteerPage",
async onShow () {
// 获取活动详情
const { code, data } = await activityInfoAPI({ i: getCurrentPageParam().id });
if (code) {
this.columns = data.activity.extend;
}
},
data () {
return {
columns: [],
}
},
methods: {
},
};
</script>
......
<!--
* @Date: 2022-09-27 17:13:05
* @LastEditors: hookehuyr hookehuyr@gmail.com
* @LastEditTime: 2022-10-20 17:48:47
* @LastEditTime: 2022-10-27 18:37:45
* @FilePath: /swx/src/pages/joinVolunteerInfo/index.vue
* @Description: 活动报名
* @Description: 义工报名
-->
<template>
<view class="join-activity-page">
......@@ -15,7 +15,7 @@
<view class="at-input">
<view class="at-input__container">
<label class="h5-label at-input__title at-input__title">岗位</label>
<input class="h5-input at-input__input" placeholder-class="placeholder" :value="extend" placeholder="" :disabled="true"/>
<input class="h5-input at-input__input" placeholder-class="placeholder" :value="post" placeholder="" :disabled="true"/>
</view>
</view>
<view class="at-input">
......@@ -32,12 +32,6 @@
</view>
<view class="at-input">
<view class="at-input__container">
<label class="h5-label at-input__title at-input__title">年龄段</label>
<input class="h5-input at-input__input" placeholder-class="placeholder" :value="age_group" placeholder="" :disabled="true"/>
</view>
</view>
<view class="at-input">
<view class="at-input__container">
<label class="h5-label at-input__title at-input__title">性别</label>
<input class="h5-input at-input__input" placeholder-class="placeholder" :value="user_sex" placeholder="" :disabled="true"/>
</view>
......@@ -52,51 +46,44 @@
<view @tap="editJoin" class="button">确认修改报名</view>
</view>
</view>
<van-dialog id="van-dialog" />
</template>
<script setup>
import { ref, onMounted } from "vue";
import "taro-ui-vue3/dist/style/components/input.scss";
import Taro from '@tarojs/taro'
import { myInfoAPI } from '@/api/Reg/index';
import { myInfoAPI, cancelRegAPI } from '@/api/Reg/index';
import { getCurrentPageParam } from "@/utils/weapp";
const username = ref('');
const phone = ref('');
const age_group = ref('');
const user_sex = ref('');
const extend = ref([]);
onMounted(async () => {
const { code, data } = await myInfoAPI({ i: getCurrentPageParam().reg_id });
if (code) {
username.value = data.name;
phone.value = data.phone;
age_group.value = data.age_group;
user_sex.value = data.gender === 'man' ? '男士' : '女士';
// 额外信息
if (data.extend) {
for (const key in data.extend) {
extend.value.push({
title: key,
value: data.extend[key],
});
}
}
}
})
import Dialog from '@/components/vant-weapp/dialog/dialog';
const cancelJoin = (val) => {
Dialog.confirm({
title: '温馨提示',
message: '是否确认取消报名?',
confirmButtonColor: '#199a74'
})
.then(async () => {
// on confirm
const { code, data } = await cancelRegAPI({ i: getCurrentPageParam().reg_id });
if (code) {
Taro.showToast({
title: '取消成功',
icon: 'success',
duration: 2000
});
Taro.navigateBack()
}
})
.catch(() => {
// on cancel
});
}
const editJoin = (val) => {
Taro.navigateTo({
url: '../joinActivity/index'
url: '../joinVolunteer/index?type=edit&reg_id=' + getCurrentPageParam().reg_id + '&id=' + getCurrentPageParam().id
})
}
</script>
......@@ -105,5 +92,22 @@ const editJoin = (val) => {
import "./index.less";
export default {
name: "demoPage",
data () {
return {
username: '',
phone: '',
user_sex: '',
post: '',
}
},
async onShow () {
const { code, data } = await myInfoAPI({ i: getCurrentPageParam().reg_id });
if (code) {
this.username = data.name;
this.phone = data.phone;
this.post = data.post;
this.user_sex = data.gender === 'man' ? '男士' : '女士';
}
}
};
</script>
......