Showing
2 changed files
with
79 additions
and
32 deletions
| 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 13:56:03 | 4 | + * @LastEditTime: 2022-10-17 16:15:25 |
| 5 | * @FilePath: /swx/src/pages/createActivity/index.vue | 5 | * @FilePath: /swx/src/pages/createActivity/index.vue |
| 6 | * @Description: 创建活动页面 | 6 | * @Description: 创建活动页面 |
| 7 | --> | 7 | --> |
| ... | @@ -31,9 +31,6 @@ | ... | @@ -31,9 +31,6 @@ |
| 31 | <view class="divide-line"></view> | 31 | <view class="divide-line"></view> |
| 32 | <view class="form-item"> | 32 | <view class="form-item"> |
| 33 | <view class="form-item-title border">活动详情</view> | 33 | <view class="form-item-title border">活动详情</view> |
| 34 | - <!-- <van-field :value="message" input-class="input-class" label="" inputAlign="" maxlength="" placeholderStyle="" | ||
| 35 | - rightIcon="" type="textarea" placeholder="开始输入活动详情介绍" :autosize="{ maxHeight: 200, minHeight: 100 }" | ||
| 36 | - custom-style="padding-left: 0;" /> --> | ||
| 37 | <activity-editor name="editor" :showTabBar="true" placeholder="开始输入活动详情介绍"></activity-editor> | 34 | <activity-editor name="editor" :showTabBar="true" placeholder="开始输入活动详情介绍"></activity-editor> |
| 38 | </view> | 35 | </view> |
| 39 | <view class="divide-line"></view> | 36 | <view class="divide-line"></view> |
| ... | @@ -43,7 +40,7 @@ | ... | @@ -43,7 +40,7 @@ |
| 43 | </view> | 40 | </view> |
| 44 | <view class="sign-box"> | 41 | <view class="sign-box"> |
| 45 | <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" |
| 46 | - class="sign-item" :class="{ 'checked': item.checked }"><text class="required">{{ item.label }}</text></view> | 43 | + class="sign-item" :class="{ 'checked': item.checked }"><text :class="{ 'required': item.required }">{{ item.label }}</text></view> |
| 47 | <!-- <view class="sign-item"><text class="">推荐人</text></view> --> | 44 | <!-- <view class="sign-item"><text class="">推荐人</text></view> --> |
| 48 | <view class="sign-item" @tap="addSign"> | 45 | <view class="sign-item" @tap="addSign"> |
| 49 | <van-icon name="plus" color="" /> | 46 | <van-icon name="plus" color="" /> |
| ... | @@ -186,12 +183,12 @@ | ... | @@ -186,12 +183,12 @@ |
| 186 | /> | 183 | /> |
| 187 | </view> --> | 184 | </view> --> |
| 188 | <view style="width: 22rem;"> | 185 | <view style="width: 22rem;"> |
| 189 | - <van-field :value="message" label-class="label-class" input-class="input-class" rows="1" autosize label="字段名称" | 186 | + <van-field :value="sign_filed.name" label-class="label-class" input-class="input-class" rows="1" autosize label="字段名称" |
| 190 | type="textarea" placeholder="请输入字段名称(6个字以内)" placeholder-style="color: #999;" customStyle="" inputAlign="" | 187 | type="textarea" placeholder="请输入字段名称(6个字以内)" placeholder-style="color: #999;" customStyle="" inputAlign="" |
| 191 | - rightIcon="" :required="true" :maxlength="6" :border="true" @change="onChange" /> | 188 | + rightIcon="" :required="true" :maxlength="6" :border="true" @change="onFiledChange" /> |
| 192 | <view class="form-item border"> | 189 | <view class="form-item border"> |
| 193 | <view class="form-item-title fix">是否必填</view> | 190 | <view class="form-item-title fix">是否必填</view> |
| 194 | - <van-switch style="float: right; padding-top: 0.5rem;" :checked="checked" @change="onChangeEdit" | 191 | + <van-switch style="float: right; padding-top: 0.5rem;" :checked="sign_filed.checked" @change="onChangeEdit" |
| 195 | size="1.5rem" active-color="#199A74" inactive-color="#FFFFFF" /> | 192 | size="1.5rem" active-color="#199A74" inactive-color="#FFFFFF" /> |
| 196 | </view> | 193 | </view> |
| 197 | <van-row> | 194 | <van-row> |
| ... | @@ -268,6 +265,8 @@ | ... | @@ -268,6 +265,8 @@ |
| 268 | toolbar-class="picker-toolbar" @confirm="onPublicTypeConfirm" @cancel="onPublicTypeCancel" | 265 | toolbar-class="picker-toolbar" @confirm="onPublicTypeConfirm" @cancel="onPublicTypeCancel" |
| 269 | @change="onPublicTypeChange" /> | 266 | @change="onPublicTypeChange" /> |
| 270 | </van-popup> | 267 | </van-popup> |
| 268 | + | ||
| 269 | + <van-toast id="van-toast" /> | ||
| 271 | </template> | 270 | </template> |
| 272 | 271 | ||
| 273 | <script setup> | 272 | <script setup> |
| ... | @@ -283,6 +282,8 @@ import request from '../../utils/request'; | ... | @@ -283,6 +282,8 @@ import request from '../../utils/request'; |
| 283 | import Taro from '@tarojs/taro' | 282 | import Taro from '@tarojs/taro' |
| 284 | import mixin from '../../utils/mixin'; | 283 | import mixin from '../../utils/mixin'; |
| 285 | import BASE_URL from '@/utils/config'; | 284 | import BASE_URL from '@/utils/config'; |
| 285 | +import Toast from '@/components/vant-weapp/toast/toast'; | ||
| 286 | +import { randomId } from '@/utils/tools' | ||
| 286 | 287 | ||
| 287 | const message = ref(''); | 288 | const message = ref(''); |
| 288 | const message1 = ref(''); | 289 | const message1 = ref(''); |
| ... | @@ -307,6 +308,10 @@ const uploaderStyle = ref({}) | ... | @@ -307,6 +308,10 @@ const uploaderStyle = ref({}) |
| 307 | const has_image = ref(false) | 308 | const has_image = ref(false) |
| 308 | const uploader_image = ref('') | 309 | const uploader_image = ref('') |
| 309 | const afterRead = (event) => { | 310 | const afterRead = (event) => { |
| 311 | + wx.showLoading({ | ||
| 312 | + title: '上传中', | ||
| 313 | + mask: true | ||
| 314 | + }); | ||
| 310 | const { file } = event.detail; | 315 | const { file } = event.detail; |
| 311 | // 获取上传URL | 316 | // 获取上传URL |
| 312 | wx.uploadFile({ | 317 | wx.uploadFile({ |
| ... | @@ -365,60 +370,91 @@ onMounted(() => { | ... | @@ -365,60 +370,91 @@ onMounted(() => { |
| 365 | defaultTime = getTime("min", 30); | 370 | defaultTime = getTime("min", 30); |
| 366 | }); | 371 | }); |
| 367 | 372 | ||
| 373 | +/******** 报名信息 ********/ | ||
| 368 | const signInfo = ref([{ | 374 | const signInfo = ref([{ |
| 369 | key: 'name', | 375 | key: 'name', |
| 370 | label: '姓名', | 376 | label: '姓名', |
| 371 | checked: 1, | 377 | checked: 1, |
| 372 | - required: 1 | 378 | + required: 1, |
| 379 | + nop: true | ||
| 373 | }, { | 380 | }, { |
| 374 | key: 'phone', | 381 | key: 'phone', |
| 375 | label: '手机号', | 382 | label: '手机号', |
| 376 | checked: 1, | 383 | checked: 1, |
| 377 | - required: 1 | 384 | + required: 1, |
| 385 | + nop: true | ||
| 378 | }, { | 386 | }, { |
| 379 | - key: 'sex', | 387 | + key: 'gender', |
| 380 | label: '性别', | 388 | label: '性别', |
| 381 | checked: 1, | 389 | checked: 1, |
| 382 | - required: 1 | 390 | + required: 1, |
| 391 | + nop: true | ||
| 383 | }, { | 392 | }, { |
| 384 | - key: 'age', | 393 | + key: 'age_group', |
| 385 | label: '年龄段', | 394 | label: '年龄段', |
| 386 | checked: 1, | 395 | checked: 1, |
| 387 | - required: 1 | 396 | + required: 1, |
| 397 | + nop: true | ||
| 388 | }]); | 398 | }]); |
| 389 | 399 | ||
| 390 | -const onTapSign = (item) => { | 400 | +const onTapSign = (item) => { // 点击取消 |
| 391 | - item.checked = !item.checked | 401 | + if (item.nop) return false; // 如果是固定字段不能操作 |
| 402 | + item.checked = !item.checked; | ||
| 392 | } | 403 | } |
| 393 | 404 | ||
| 394 | -const onLongPressSign = (item) => { | 405 | +const onLongPressSign = (item) => { // 长按编辑 |
| 395 | - console.warn(item); | 406 | + if (item.nop) return false; // 如果是固定字段不能操作 |
| 407 | + // console.warn(item); | ||
| 408 | + sign_filed.value.key = item.key; | ||
| 409 | + sign_filed.value.name = item.label; | ||
| 410 | + sign_filed.value.required = item.required; | ||
| 396 | show_edit_sign.value = true; | 411 | show_edit_sign.value = true; |
| 397 | } | 412 | } |
| 398 | 413 | ||
| 399 | -const show_edit_sign = ref(false) | 414 | +// 报名信息弹框 |
| 400 | - | 415 | +const show_edit_sign = ref(false); |
| 416 | +const sign_filed = ref({}); // 临时报名 | ||
| 417 | +const onFiledChange = ({ detail }) => { | ||
| 418 | + sign_filed.value.name = detail; | ||
| 419 | +} | ||
| 401 | const onChangeEdit = ({ detail }) => { | 420 | const onChangeEdit = ({ detail }) => { |
| 402 | - console.warn(detail); | 421 | + sign_filed.value.checked = detail; |
| 403 | - checked.value = detail; | ||
| 404 | } | 422 | } |
| 405 | - | ||
| 406 | const closeEditSign = () => { | 423 | const closeEditSign = () => { |
| 407 | show_edit_sign.value = false; | 424 | show_edit_sign.value = false; |
| 408 | } | 425 | } |
| 409 | -const confirmEditSign = () => { | 426 | +const confirmEditSign = () => { // 确认报名信息回调 |
| 427 | + if (!sign_filed.value.name) { | ||
| 428 | + Toast.fail('字段不能为空'); | ||
| 429 | + } else { | ||
| 410 | show_edit_sign.value = false; | 430 | show_edit_sign.value = false; |
| 431 | + // 如果key值存在修改,key值不存在新增 | ||
| 432 | + const result = signInfo.value.filter(item => item.key === sign_filed.value.key); | ||
| 433 | + if (result.length) { | ||
| 434 | + signInfo.value.forEach(item => { | ||
| 435 | + if (item.key === sign_filed.value.key) { // key值相同 | ||
| 436 | + item.label = sign_filed.value.name; | ||
| 437 | + item.required = sign_filed.value.checked; | ||
| 438 | + } | ||
| 439 | + }) | ||
| 440 | + } else { | ||
| 411 | signInfo.value.push({ | 441 | signInfo.value.push({ |
| 412 | - key: 'person', | 442 | + key: randomId(5), |
| 413 | - label: '推荐人', | 443 | + label: sign_filed.value.name, |
| 414 | checked: 1, | 444 | checked: 1, |
| 415 | - required: 1 | 445 | + required: sign_filed.value.checked ? 1 : 0, |
| 416 | - }) | 446 | + nop: false |
| 447 | + }); | ||
| 448 | + } | ||
| 449 | + } | ||
| 417 | } | 450 | } |
| 418 | 451 | ||
| 419 | -const addSign = () => { | 452 | +const addSign = () => { // 新增-报名信息弹框 |
| 420 | show_edit_sign.value = true; | 453 | show_edit_sign.value = true; |
| 454 | + sign_filed.value.name = ''; | ||
| 455 | + sign_filed.value.checked = false; | ||
| 421 | } | 456 | } |
| 457 | +/****************************/ | ||
| 422 | 458 | ||
| 423 | const show_popup = ref(false); | 459 | const show_popup = ref(false); |
| 424 | const closeEditLimit = () => { | 460 | const closeEditLimit = () => { | ... | ... |
| 1 | /* | 1 | /* |
| 2 | * @Date: 2022-04-18 15:59:42 | 2 | * @Date: 2022-04-18 15:59:42 |
| 3 | * @LastEditors: hookehuyr hookehuyr@gmail.com | 3 | * @LastEditors: hookehuyr hookehuyr@gmail.com |
| 4 | - * @LastEditTime: 2022-06-30 13:54:32 | 4 | + * @LastEditTime: 2022-10-17 15:27:10 |
| 5 | - * @FilePath: /tswj/src/utils/tools.js | 5 | + * @FilePath: /swx/src/utils/tools.js |
| 6 | * @Description: 文件描述 | 6 | * @Description: 文件描述 |
| 7 | */ | 7 | */ |
| 8 | import dayjs from 'dayjs'; | 8 | import dayjs from 'dayjs'; |
| ... | @@ -71,4 +71,15 @@ const strExist = (array, str) => { | ... | @@ -71,4 +71,15 @@ const strExist = (array, str) => { |
| 71 | return exist.length > 0 | 71 | return exist.length > 0 |
| 72 | } | 72 | } |
| 73 | 73 | ||
| 74 | -export { formatDate, wxInfo, hasEllipsis, parseQueryString, strExist }; | 74 | +const randomId = (n) => { |
| 75 | + const charts = ['0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z']; | ||
| 76 | + var res = ''; | ||
| 77 | + for (var i = 0; i < n; i++) { | ||
| 78 | + undefined | ||
| 79 | + var id = Math.ceil(Math.random() * 35); | ||
| 80 | + res += charts[id]; | ||
| 81 | + } | ||
| 82 | + return res; | ||
| 83 | +} | ||
| 84 | + | ||
| 85 | +export { formatDate, wxInfo, hasEllipsis, parseQueryString, strExist, randomId }; | ... | ... |
-
Please register or login to post a comment