hookehuyr

✨ feat(创建活动): 调整高级设置里时间模块,人数限制功能优化

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-17 16:15:25 4 + * @LastEditTime: 2022-10-17 17:25:54
5 * @FilePath: /swx/src/pages/createActivity/index.vue 5 * @FilePath: /swx/src/pages/createActivity/index.vue
6 * @Description: 创建活动页面 6 * @Description: 创建活动页面
7 --> 7 -->
...@@ -41,7 +41,6 @@ ...@@ -41,7 +41,6 @@
41 <view class="sign-box"> 41 <view class="sign-box">
42 <view @tap="onTapSign(item)" @longpress="onLongPressSign(item)" v-for="(item, index) in signInfo" :key="index" 42 <view @tap="onTapSign(item)" @longpress="onLongPressSign(item)" v-for="(item, index) in signInfo" :key="index"
43 class="sign-item" :class="{ 'checked': item.checked }"><text :class="{ 'required': item.required }">{{ item.label }}</text></view> 43 class="sign-item" :class="{ 'checked': item.checked }"><text :class="{ 'required': item.required }">{{ item.label }}</text></view>
44 - <!-- <view class="sign-item"><text class="">推荐人</text></view> -->
45 <view class="sign-item" @tap="addSign"> 44 <view class="sign-item" @tap="addSign">
46 <van-icon name="plus" color="" /> 45 <van-icon name="plus" color="" />
47 </view> 46 </view>
...@@ -54,25 +53,25 @@ ...@@ -54,25 +53,25 @@
54 </view> 53 </view>
55 <view class="advanced-settings-modules"> 54 <view class="advanced-settings-modules">
56 <!-- 活动时间 --> 55 <!-- 活动时间 -->
57 - <timePickerData :start-time="startTime" :end-time="endTime" :default-time="defaultTime" @result="onResult"> 56 + <timePickerData :start-time="startTime" :end-time="endTime" :default-time="defaultTime" @result="onActivityTime">
58 - <van-field :value="datetime" label-class="label-class-super" input-class="input-class" label="活动时间" 57 + <van-field :value="activity_time" label-class="label-class-super" input-class="input-class" label="活动时间"
59 :right-icon="icon_sel" input-align="right" placeholder="请选择" placeholder-style="color: #999;" customStyle="" 58 :right-icon="icon_sel" input-align="right" placeholder="请选择" placeholder-style="color: #999;" customStyle=""
60 maxlength="" type="" :border="true" :required="false" :disabled="true" /> 59 maxlength="" type="" :border="true" :required="false" :disabled="true" />
61 </timePickerData> 60 </timePickerData>
62 <!-- 报名开始时间 --> 61 <!-- 报名开始时间 -->
63 - <timePickerData :start-time="startTime" :end-time="endTime" :default-time="defaultTime" @result="onResult"> 62 + <timePickerData :start-time="startTime" :end-time="endTime" :default-time="defaultTime" @result="onBeginTime">
64 - <van-field :value="datetime" label-class="label-class-super" input-class="input-class" label="报名开始时间" 63 + <van-field :value="reg_begin_time" label-class="label-class-super" input-class="input-class" label="报名开始时间"
65 :right-icon="icon_sel" input-align="right" placeholder="请选择" placeholder-style="color: #999;" customStyle="" 64 :right-icon="icon_sel" input-align="right" placeholder="请选择" placeholder-style="color: #999;" customStyle=""
66 maxlength="" type="" :border="true" :required="false" :disabled="true" /> 65 maxlength="" type="" :border="true" :required="false" :disabled="true" />
67 </timePickerData> 66 </timePickerData>
68 <!-- 报名截止时间 --> 67 <!-- 报名截止时间 -->
69 - <timePickerData :start-time="startTime" :end-time="endTime" :default-time="defaultTime" @result="onResult"> 68 + <timePickerData :start-time="startTime" :end-time="endTime" :default-time="defaultTime" @result="onEndTime">
70 - <van-field :value="datetime" label-class="label-class-super" input-class="input-class" label="报名截止时间" 69 + <van-field :value="reg_end_time" label-class="label-class-super" input-class="input-class" label="报名截止时间"
71 :right-icon="icon_sel" input-align="right" placeholder="请选择" placeholder-style="color: #999;" customStyle="" 70 :right-icon="icon_sel" input-align="right" placeholder="请选择" placeholder-style="color: #999;" customStyle=""
72 maxlength="" type="" :border="true" :required="false" :disabled="true" /> 71 maxlength="" type="" :border="true" :required="false" :disabled="true" />
73 </timePickerData> 72 </timePickerData>
74 <!-- 人数限制 --> 73 <!-- 人数限制 -->
75 - <van-field :value="person_num" label-class="label-class-super" input-class="input-class" label="人数限制" 74 + <van-field :value="reg_max" label-class="label-class-super" input-class="input-class" label="人数限制"
76 :right-icon="icon_sel" input-align="right" placeholder="请选择" placeholder-style="color: #999;" customStyle="" 75 :right-icon="icon_sel" input-align="right" placeholder="请选择" placeholder-style="color: #999;" customStyle=""
77 maxlength="" type="" :border="true" @tap="show_popup=true" :required="false" :disabled="true" /> 76 maxlength="" type="" :border="true" @tap="show_popup=true" :required="false" :disabled="true" />
78 <!-- 是否发布 --> 77 <!-- 是否发布 -->
...@@ -211,7 +210,7 @@ ...@@ -211,7 +210,7 @@
211 </view> 210 </view>
212 </van-overlay> 211 </van-overlay>
213 <!-- 人数限制弹出框 --> 212 <!-- 人数限制弹出框 -->
214 - <van-popup :show="show_popup" position="bottom" custom-style="height: 40%;" :lock-scroll="true"> 213 + <van-popup :show="show_popup" position="bottom" custom-style="height: 30%;" :lock-scroll="true">
215 <view class="limit-wrapper"> 214 <view class="limit-wrapper">
216 <view class="form-item border"> 215 <view class="form-item border">
217 <view class="form-item-title fix">不限制人数</view> 216 <view class="form-item-title fix">不限制人数</view>
...@@ -219,19 +218,11 @@ ...@@ -219,19 +218,11 @@
219 size="1.5rem" active-color="#199A74" inactive-color="#FFFFFF" /> 218 size="1.5rem" active-color="#199A74" inactive-color="#FFFFFF" />
220 </view> 219 </view>
221 <view v-if="!limit_number" class="form-item border"> 220 <view v-if="!limit_number" class="form-item border">
222 - <view class="form-item-title fix">人数最小值</view> 221 + <view class="form-item-title fix">参加人数</view>
223 <view style="float: right;"> 222 <view style="float: right;">
224 - <van-field :value="min_number" type="number" label="" placeholder="请输入人数最小值" 223 + <van-field :value="temp_reg_max" type="number" label="" placeholder="请输入参加人数"
225 placeholder-style="color: #999; font-size: 1rem;" input-align="right" customStyle="" rightIcon="" 224 placeholder-style="color: #999; font-size: 1rem;" input-align="right" customStyle="" rightIcon=""
226 - maxlength="" :border="false" /> 225 + maxlength="" :border="false" @change="onRegMaxChange" />
227 - </view>
228 - </view>
229 - <view v-if="!limit_number" class="form-item border">
230 - <view class="form-item-title fix">人数最大值</view>
231 - <view style="float: right;">
232 - <van-field :value="max_number" type="number" label="" placeholder="请输入人数最大值"
233 - placeholder-style="color: #999; font-size: 1rem;" input-align="right" customStyle="" rightIcon=""
234 - maxlength="" :border="false" />
235 </view> 226 </view>
236 </view> 227 </view>
237 </view> 228 </view>
...@@ -285,17 +276,12 @@ import BASE_URL from '@/utils/config'; ...@@ -285,17 +276,12 @@ import BASE_URL from '@/utils/config';
285 import Toast from '@/components/vant-weapp/toast/toast'; 276 import Toast from '@/components/vant-weapp/toast/toast';
286 import { randomId } from '@/utils/tools' 277 import { randomId } from '@/utils/tools'
287 278
288 -const message = ref('');
289 -const message1 = ref('');
290 -const checked = ref(false);
291 279
292 -const onSubmit = () => { 280 +const message1 = ref('');
293 - console.warn(message.value);
294 -}
295 281
282 +const activity_name = ref('');
296 const onChange = ({ detail }) => { 283 const onChange = ({ detail }) => {
297 - console.warn(detail); 284 + activity_name.value = detail
298 - message.value = detail
299 } 285 }
300 const onChange1 = ({ detail }) => { 286 const onChange1 = ({ detail }) => {
301 // console.warn(detail); 287 // console.warn(detail);
...@@ -454,18 +440,12 @@ const addSign = () => { // 新增-报名信息弹框 ...@@ -454,18 +440,12 @@ const addSign = () => { // 新增-报名信息弹框
454 sign_filed.value.name = ''; 440 sign_filed.value.name = '';
455 sign_filed.value.checked = false; 441 sign_filed.value.checked = false;
456 } 442 }
457 -/****************************/
458 443
459 -const show_popup = ref(false); 444 +/************* 活动时间 ************/
460 -const closeEditLimit = () => {
461 - show_popup.value = false;
462 -}
463 -const confirmEditLimit = () => {
464 - show_popup.value = false;
465 -}
466 445
467 - 446 +const activity_time = ref('');
468 -const datetime = ref(''); 447 +const reg_begin_time = ref('');
448 +const reg_end_time = ref('');
469 let startTime = new Date() 449 let startTime = new Date()
470 let endTime = new Date() 450 let endTime = new Date()
471 let defaultTime = new Date() 451 let defaultTime = new Date()
...@@ -483,17 +463,52 @@ const getTime = (key, number, date) => { ...@@ -483,17 +463,52 @@ const getTime = (key, number, date) => {
483 } 463 }
484 return _date; 464 return _date;
485 } 465 }
486 -const onResult = (arr) => { 466 +const onActivityTime = (arr) => {
467 + let time = arr[0] + "-" + arr[1] + "-" + arr[2] + " " + arr[3] + ":" + arr[4];
468 + activity_time.value = time;
469 +}
470 +const onBeginTime = (arr) => {
487 let time = arr[0] + "-" + arr[1] + "-" + arr[2] + " " + arr[3] + ":" + arr[4]; 471 let time = arr[0] + "-" + arr[1] + "-" + arr[2] + " " + arr[3] + ":" + arr[4];
488 - datetime.value = time; 472 + reg_begin_time.value = time;
489 } 473 }
474 +const onEndTime = (arr) => {
475 + let time = arr[0] + "-" + arr[1] + "-" + arr[2] + " " + arr[3] + ":" + arr[4];
476 + reg_end_time.value = time;
477 +}
478 +
490 479
491 -const person_num = ref('') 480 +/********* 人数限制 *********/
481 +const reg_max = ref('')
482 +const temp_reg_max = ref('')
492 const limit_number = ref(false); 483 const limit_number = ref(false);
493 -const min_number = ref(''); 484 +const onRegMaxChange = ({ detail }) => {
494 -const max_number = ref(''); 485 + temp_reg_max.value = detail
495 -const onChangeLimit = ({ detail }) => { 486 +}
496 - limit_number.value = detail 487 +const onChangeLimit = ({ detail }) => { // 不限制开关回调
488 + if (detail) {
489 + limit_number.value = detail
490 + } else {
491 + limit_number.value = detail
492 + temp_reg_max.value = ''
493 + }
494 +}
495 +const show_popup = ref(false);
496 +const closeEditLimit = () => {
497 + show_popup.value = false;
498 +}
499 +const confirmEditLimit = () => { // 提交人数限制
500 + if (limit_number.value) {
501 + reg_max.value = '无限制'; // 无限人数默认为0
502 + show_popup.value = false;
503 + } else {
504 + const pattern = /^([1-9][0-9]*){1,3}$/; // 非零正整数
505 + if (!pattern.test(temp_reg_max.value)) {// 如果包含特殊字符返回false
506 + Toast('请输入非零正整数');
507 + } else {
508 + reg_max.value = temp_reg_max.value;
509 + show_popup.value = false;
510 + }
511 + }
497 } 512 }
498 513
499 const show_publish_popup = ref(false); 514 const show_publish_popup = ref(false);
...@@ -565,7 +580,10 @@ const onOrgTypeConfirm = (event) => { // 主办方弹框确认按钮回调 ...@@ -565,7 +580,10 @@ const onOrgTypeConfirm = (event) => { // 主办方弹框确认按钮回调
565 const onOrgTypeCancel = (event) => { 580 const onOrgTypeCancel = (event) => {
566 show_org_popup.value = false; 581 show_org_popup.value = false;
567 } 582 }
568 -/******************/ 583 +
584 +
585 +const onSubmit = () => {
586 +}
569 </script> 587 </script>
570 588
571 <script> 589 <script>
......