You need to sign in or sign up before continuing.
index.vue 21.1 KB
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548
<!--
 * @Date: 2022-09-21 16:04:10
 * @LastEditors: hookehuyr hookehuyr@gmail.com
 * @LastEditTime: 2022-10-13 21:51:33
 * @FilePath: /swx/src/pages/createActivity/index.vue
 * @Description: 创建活动页面
-->
<template>
  <view>
    <van-cell-group inset>
      <van-field :value="org_type" label-class="label-class" input-class="input-class" label="主办方"
        :right-icon="icon_sel" placeholder="请选择活动主办方" placeholder-style="color: #999;" customStyle="" inputAlign=""
        maxlength="" type="text" @tap="show_org_popup=true" :required="true" :disabled="true" />
      <view class="divide-line"></view>
      <van-field :value="activity_name" label-class="label-class" input-class="input-class" label="活动主题" type="textarea"
        placeholder="请输入活动主题(最多30个字)" placeholder-style="color: #999;" :autosize="{ maxHeight: 80, minHeight: 20 }" customStyle="" inputAlign=""
        rightIcon="" :required="true" :maxlength="30" :border="false" @change="onChange" />
      <view class="divide-line"></view>
      <view class="form-item">
        <view class="form-item-title required">活动封面图<text class="sub">(图片比例16:9展示最佳)</text></view>
        <van-uploader v-if="!has_image" @after-read="afterRead">
          <view class="upload-box" :style="uploaderStyle">
            <van-icon :name="icon_upload" size="5rem" color="" class="upload-icon" />
          </view>
        </van-uploader>
        <view v-else class="upload-box" :style="uploaderStyle">
          <van-image fit="contain" :width="uploader_width" height="12rem" :src="uploader_image" />
          <van-icon name="clear" size="1.5rem" color="#000" class="upload-close" @tap="removeUploadImage" />
        </view>
      </view>
      <view class="divide-line"></view>
      <view class="form-item">
        <view class="form-item-title border">活动详情</view>
        <!-- <van-field :value="message" input-class="input-class" label="" inputAlign="" maxlength="" placeholderStyle=""
          rightIcon="" type="textarea" placeholder="开始输入活动详情介绍" :autosize="{ maxHeight: 200, minHeight: 100 }"
          custom-style="padding-left: 0;" /> -->
        <activity-editor name="editor" :showTabBar="true" placeholder="开始输入活动详情介绍"></activity-editor>
      </view>
      <view class="divide-line"></view>
      <view class="form-item">
        <view class="form-item-title">报名信息<text class="sub">( <text style="color: red;">*</text>为必填项,单击启用,长按修改)</text>
        </view>
      </view>
      <view class="sign-box">
        <view @tap="onTapSign(item)" @longpress="onLongPressSign(item)" v-for="(item, index) in signInfo" :key="index"
          class="sign-item" :class="{ 'checked': item.checked }"><text class="required">{{ item.label }}</text></view>
        <!-- <view class="sign-item"><text class="">推荐人</text></view> -->
        <view class="sign-item" @tap="addSign">
          <van-icon name="plus" color="" />
        </view>
      </view>
      <view class="divide-line"></view>
      <view class="advanced-title">
        <view class="box">
          <text class="bg-gradient" style="font-size: 1.15rem;">高级设置</text>
        </view>
      </view>
      <view class="advanced-settings-modules">
        <!-- 活动时间 -->
        <timePickerData :start-time="startTime" :end-time="endTime" :default-time="defaultTime" @result="onResult">
          <van-field :value="datetime" label-class="label-class-super" input-class="input-class" label="活动时间"
            :right-icon="icon_sel" input-align="right" placeholder="请选择" placeholder-style="color: #999;" customStyle=""
            maxlength="" type="" :border="true" :required="false" :disabled="true" />
        </timePickerData>
        <!-- 报名开始时间 -->
        <timePickerData :start-time="startTime" :end-time="endTime" :default-time="defaultTime" @result="onResult">
          <van-field :value="datetime" label-class="label-class-super" input-class="input-class" label="报名开始时间"
            :right-icon="icon_sel" input-align="right" placeholder="请选择" placeholder-style="color: #999;" customStyle=""
            maxlength="" type="" :border="true" :required="false" :disabled="true" />
        </timePickerData>
        <!-- 报名截止时间 -->
        <timePickerData :start-time="startTime" :end-time="endTime" :default-time="defaultTime" @result="onResult">
          <van-field :value="datetime" label-class="label-class-super" input-class="input-class" label="报名截止时间"
            :right-icon="icon_sel" input-align="right" placeholder="请选择" placeholder-style="color: #999;" customStyle=""
            maxlength="" type="" :border="true" :required="false" :disabled="true" />
        </timePickerData>
        <!-- 人数限制 -->
        <van-field :value="person_num" label-class="label-class-super" input-class="input-class" label="人数限制"
          :right-icon="icon_sel" input-align="right" placeholder="请选择" placeholder-style="color: #999;" customStyle=""
          maxlength="" type="" :border="true" @tap="show_popup=true" :required="false" :disabled="true" />
        <!-- 是否发布 -->
        <van-field :value="publish_status" label-class="label-class-super" input-class="input-class" label="是否发布"
          :right-icon="icon_sel" input-align="right" placeholder="请选择" placeholder-style="color: #999;" customStyle=""
          maxlength="" type="" :border="true" @tap="show_publish_popup=true" :required="false" :disabled="true" />
        <!-- 活动方式 -->
        <van-field :value="activity_type" label-class="label-class-super" input-class="input-class" label="活动方式"
          :right-icon="icon_sel" input-align="right" placeholder="请选择" placeholder-style="color: #999;" customStyle=""
          maxlength="" type="" :border="true" @tap="show_activity_type_popup=true" :required="false" :disabled="true" />
        <!-- 活动地址 -->
        <van-field :value="message1" label-class="label-class-super" input-class="input-class" label="活动地址"
          type="textarea" placeholder="请输入地址或位置说明" placeholder-style="color: #999;" customStyle="" inputAlign="right"
          rightIcon="" :required="false" maxlength="" :border="false" :autosize="{ maxHeight: 80, minHeight: 20 }"
          @change="onChange1" />
      </view>
      <view class="divide-line"></view>
      <view>
        <view class="form-item public-sub">
          <view class="public-sub-border">
            <van-row>
              <van-col span="12">
                <view class="form-item-title fix">
                  是否公开显示
                  <van-icon :name="icon_vip" size="1rem" color="" class="vip-icon" />
                </view>
              </van-col>
              <van-col span="12">
                <view>
                  <van-field :value="public_type" label-class="label-class-super" input-class="input-class" label=""
                    :right-icon="icon_sel" input-align="right" placeholder="请选择" placeholder-style="color: #999;"
                    customStyle="" maxlength="" type="" :border="false" @tap="show_public_popup=true" :required="false"
                    :disabled="true" />
                </view>

              </van-col>
            </van-row>
          </view>
        </view>
        <view class="form-item inner-sub">
          <view class="inner-sub-border">
            <view class="form-item-title fix">
              允许内部人员报名活动
              <van-icon :name="icon_vip" size="1rem" color="" class="vip-icon" />
            </view>
            <van-switch style="float: right; padding-top: 0.5rem;" :checked="limit_number" @change="onChangeLimit"
              size="1.5rem" active-color="#199A74" inactive-color="#FFFFFF" />
          </view>
        </view>
        <view class="form-item blacklist-sub">
          <view class="blacklist-sub-border">
            <view class="form-item-title fix">
              屏蔽黑名单用户
              <van-icon :name="icon_vip" size="1rem" color="" class="vip-icon" />
            </view>
            <van-switch style="float: right; padding-top: 0.5rem;" :checked="limit_number" @change="onChangeLimit"
              size="1.5rem" active-color="#199A74" inactive-color="#FFFFFF" />
          </view>
        </view>
        <view class="form-item server-sub">
          <van-row>
            <van-col span="12">
              <view class="form-item-title fix">
                服务岗位报名
                <van-icon :name="icon_vip" size="1rem" color="" class="vip-icon" />
              </view>
            </van-col>
            <van-col span="12">
              <view style="">
                <van-field :value="message1" label-class="label-class-super" input-class="input-class" label=""
                  type="textarea" placeholder="岗位名以逗号分隔" placeholder-style="color: #999;" customStyle=""
                  inputAlign="right" rightIcon="" :required="false" maxlength="" :border="false"
                  :autosize="{ maxHeight: 80, minHeight: 20 }" @change="onChange1" />
              </view>

            </van-col>
          </van-row>
        </view>
      </view>
    </van-cell-group>
  </view>

  <view class="confirm-publish-wrapper">
    <view class="box">
      <view @tap="onSubmit" class="button">确定发布</view>
    </view>
  </view>

  <!-- 活动主办方弹出框 -->
  <van-popup :show="show_org_popup" position="bottom" custom-style="height: 40%;" :lock-scroll="true">
    <van-picker :show-toolbar="true" title="" confirm-button-text="确定" :columns="org_type_columns"
      toolbar-class="picker-toolbar" @confirm="onOrgTypeConfirm" @cancel="onOrgTypeCancel" @change="onOrgTypeChange" />
  </van-popup>
  <!-- 报名信息弹出框 -->
  <van-overlay :show="show_edit_sign" z-index="999">
    <view class="sign-wrapper">
      <view class="block">
        <view class="title">
          <text class="bg-gradient">报名信息</text>
        </view>
        <!-- <view>
          <AtInput
            name='value1'
            title='标准五个字'
            type='text'
            placeholder='使用 v-model:value 更新 value 值'
            v-model:value="value1"
          />
        </view> -->
        <view style="width: 22rem;">
          <van-field :value="message" label-class="label-class" input-class="input-class" rows="1" autosize label="字段名称"
            type="textarea" placeholder="请输入字段名称(6个字以内)" placeholder-style="color: #999;" customStyle="" inputAlign=""
            rightIcon="" :required="true" :maxlength="6" :border="true" @change="onChange" />
          <view class="form-item border">
            <view class="form-item-title fix">是否必填</view>
            <van-switch style="float: right; padding-top: 0.5rem;" :checked="checked" @change="onChangeEdit"
              size="1.5rem" active-color="#199A74" inactive-color="#FFFFFF" />
          </view>
          <van-row>
            <van-col span="12">
              <view class="cancel-box">
                <view class="button" @tap="closeEditSign">取消</view>
              </view>
            </van-col>
            <van-col span="12">
              <view class="confirm-box">
                <view class="button" @tap="confirmEditSign">确定</view>
              </view>
            </van-col>
          </van-row>
          <!-- <view style="padding: 1rem 0; margin: 1rem; text-align: center;">
            <view @tap="closeEditSign" style="color: #FFFFFF; background-color: #199A74; padding: 0.5rem 1rem; border-radius: 1rem;">确定</view>
          </view> -->
        </view>
      </view>
    </view>
  </van-overlay>
  <!-- 人数限制弹出框 -->
  <van-popup :show="show_popup" position="bottom" custom-style="height: 40%;" :lock-scroll="true">
    <view class="limit-wrapper">
      <view class="form-item border">
        <view class="form-item-title fix">不限制人数</view>
        <van-switch style="float: right; padding-top: 0.5rem;" :checked="limit_number" @change="onChangeLimit"
          size="1.5rem" active-color="#199A74" inactive-color="#FFFFFF" />
      </view>
      <view v-if="!limit_number" class="form-item border">
        <view class="form-item-title fix">人数最小值</view>
        <view style="float: right;">
          <van-field :value="min_number" type="number" label="" placeholder="请输入人数最小值"
            placeholder-style="color: #999; font-size: 1rem;" input-align="right" customStyle="" rightIcon=""
            maxlength="" :border="false" />
        </view>
      </view>
      <view v-if="!limit_number" class="form-item border">
        <view class="form-item-title fix">人数最大值</view>
        <view style="float: right;">
          <van-field :value="max_number" type="number" label="" placeholder="请输入人数最大值"
            placeholder-style="color: #999; font-size: 1rem;" input-align="right" customStyle="" rightIcon=""
            maxlength="" :border="false" />
        </view>
      </view>
    </view>
    <van-row>
      <van-col span="12">
        <view class="limit-button-wrapper">
          <view class="button cancel" @tap="closeEditLimit">取消</view>
        </view>
      </van-col>
      <van-col span="12">
        <view class="limit-button-wrapper">
          <view class="button confirm" @tap="confirmEditLimit">确定</view>
        </view>
      </van-col>
    </van-row>
  </van-popup>
  <!-- 是否发布弹出框 -->
  <van-popup :show="show_publish_popup" position="bottom" custom-style="height: 40%;" :lock-scroll="true">
    <van-picker :show-toolbar="true" title="" confirm-button-text="确定" :columns="columns" toolbar-class="picker-toolbar"
      @confirm="onPublishConfirm" @cancel="onPublishCancel" @change="onPublishChange" />
  </van-popup>
  <!-- 活动方式弹出框 -->
  <van-popup :show="show_activity_type_popup" position="bottom" custom-style="height: 40%;" :lock-scroll="true">
    <van-picker :show-toolbar="true" title="" confirm-button-text="确定" :columns="activity_type_columns"
      toolbar-class="picker-toolbar" @confirm="onActivityTypeConfirm" @cancel="onActivityTypeCancel"
      @change="onActivityTypeChange" />
  </van-popup>
  <!-- 是否公开显示弹出框 -->
  <van-popup :show="show_public_popup" position="bottom" custom-style="height: 40%;" :lock-scroll="true">
    <van-picker :show-toolbar="true" confirm-button-text="确定" title="" :columns="public_type_columns"
      toolbar-class="picker-toolbar" @confirm="onPublicTypeConfirm" @cancel="onPublicTypeCancel"
      @change="onPublicTypeChange" />
  </van-popup>
</template>

<script setup>
import { ref, onMounted, nextTick } from "vue";
// import icon_home1 from '@/images/icon/home01@2x.png'
import icon_upload from '@/images/icon/upload@2x.png'
import icon_vip from '@/images/icon/vip@2x.png'
import icon_sel from '@/images/icon/sel@2x.png'
import timePickerData from "@/components/time-picker-data/picker";
import activityEditor from "@/components/activity-editor";
import { getCurrentPageUrl, getCurrentPageParam } from "@/utils/weapp";
import request from '../../utils/request';
import Taro from '@tarojs/taro'

const message = ref('');
const message1 = ref('');
const checked = ref(false);

const onSubmit = () => {
  console.warn(message.value);
}

const onChange = ({ detail }) => {
  console.warn(detail);
  message.value = detail
}
const onChange1 = ({ detail }) => {
  // console.warn(detail);
  // message1.value = detail
}

/**************** 上传模块 ******************/
const uploader_width = ref('')
const uploaderStyle = ref({})
const has_image = ref(false)
const uploader_image = ref('')
const afterRead = (event) => {
  const { file } = event.detail;
  console.warn(file);
  has_image.value = true;
  uploader_image.value = file.url
}
const removeUploadImage = () => {
  has_image.value = false;
  uploader_image.value = ''
}
/**********************************/

onMounted(() => {
  // if (!wx.getStorageSync("sessionid")) {
  //   Taro.navigateTo({
  //     url: '../auth/index'
  //   })
  // }
  if (getCurrentPageParam().type === 'edit') {
    // 动态修改标题
    wx.setNavigationBarTitle({
      title: '修改活动',
    })
  }
  nextTick(() => {
    setTimeout(() => {
      // 获取元素宽度
      wx.createSelectorQuery().selectAll('.form-item-title').boundingClientRect(function (rect) {
        uploaderStyle.value = {
          width: rect[0].width - 8 + 'px'
        }
        uploader_width.value = rect[0].width - 8 + 'px';
      }).exec();
    }, 500);
  })
  //
  startTime = getTime("min", 1);
  endTime = getTime("year", 2);
  defaultTime = getTime("min", 30);

  // 获取主办方列表信息
  request.get('/srv/?a=host_list')
  .then(res => {
    if (res.data.code) {
      res.data.data.my_hosts.forEach(item => {
        item.text = item.name
      })
      org_type_columns.value = res.data.data.my_hosts;
    } else {
      console.warn(res.data.msg);
    }
  })
  .catch(err => {
    console.error(err);
  });
});

const signInfo = ref([{
  key: 'name',
  label: '姓名',
  checked: 1,
  required: 1
}, {
  key: 'phone',
  label: '手机号',
  checked: 1,
  required: 1
}, {
  key: 'sex',
  label: '性别',
  checked: 1,
  required: 1
}, {
  key: 'age',
  label: '年龄段',
  checked: 1,
  required: 1
}]);

const onTapSign = (item) => {
  item.checked = !item.checked
}

const onLongPressSign = (item) => {
  console.warn(item);
  show_edit_sign.value = true;
}

const show_edit_sign = ref(false)

const onChangeEdit = ({ detail }) => {
  console.warn(detail);
  checked.value = detail;
}

const closeEditSign = () => {
  show_edit_sign.value = false;
}
const confirmEditSign = () => {
  show_edit_sign.value = false;
  signInfo.value.push({
    key: 'person',
    label: '推荐人',
    checked: 1,
    required: 1
  })
}

const addSign = () => {
  show_edit_sign.value = true;
}

const show_popup = ref(false);
const closeEditLimit = () => {
  show_popup.value = false;
}
const confirmEditLimit = () => {
  show_popup.value = false;
}


const datetime = ref('');
let startTime = new Date()
let endTime = new Date()
let defaultTime = new Date()

const getTime = (key, number, date) => {
  let _date = date ? new Date(date) : new Date();
  if (key === "min") {
    _date.setMinutes(_date.getMinutes() + number);
  }
  if (key === "hour") {
    _date.setHours(_date.getHours() + number);
  }
  if (key === "year") {
    _date.setFullYear(_date.getFullYear() + number);
  }
  return _date;
}
const onResult = (arr) => {
  let time = arr[0] + "-" + arr[1] + "-" + arr[2] + " " + arr[3] + ":" + arr[4];
  datetime.value = time;
}

const person_num = ref('')
const limit_number = ref(false);
const min_number = ref('');
const max_number = ref('');
const onChangeLimit = ({ detail }) => {
  limit_number.value = detail
}

const show_publish_popup = ref(false);
const publish_status = ref('暂不发布');
const columns = ref(['暂不发布', '立即发布']);
const onPublishChange = (event) => {
  const { picker, value, index } = event.detail;
  console.warn(value);
  console.warn(index);
  publish_status.value = value;
}
const onPublishConfirm = (event) => {
  show_publish_popup.value = false;
}
const onPublishCancel = (event) => {
  show_publish_popup.value = false;
}

const show_activity_type_popup = ref(false);
const activity_type = ref('现场活动');
const activity_type_columns = ref(['现场活动', '线上活动']);
const onActivityTypeChange = (event) => {
  const { picker, value, index } = event.detail;
  console.warn(value);
  console.warn(index);
  activity_type.value = value;
}
const onActivityTypeConfirm = (event) => {
  show_activity_type_popup.value = false;
}
const onActivityTypeCancel = (event) => {
  show_activity_type_popup.value = false;
}

const show_public_popup = ref(false);
const public_type = ref('不公开');
const public_type_columns = ref(['不公开', '公开']);
const onPublicTypeChange = (event) => {
  const { picker, value, index } = event.detail;
  console.warn(value);
  console.warn(index);
  public_type.value = value;
}
const onPublicTypeConfirm = (event) => {
  show_public_popup.value = false;
}
const onPublicTypeCancel = (event) => {
  show_public_popup.value = false;
}

/***** 主办方选择弹框列表 *****/
const show_org_popup = ref(false);
const org_type = ref('');
const host_id = ref('');
const org_type_columns = ref([]);
const onOrgTypeChange = (event) => {
  // const { picker, value, index } = event.detail;
  // console.warn(value);
  // console.warn(index);
  // org_type.value = value.text;
  // host_id.value = value.id; // 主办方ID
}
const onOrgTypeConfirm = (event) => { // 主办方弹框确认按钮回调
  const detail = event.detail;
  org_type.value = detail.value.text; // 主办方名称
  host_id.value = detail.value.id; // 主办方ID
  show_org_popup.value = false;
}
const onOrgTypeCancel = (event) => {
  show_org_popup.value = false;
}
/******************/
</script>

<script>
import "./index.less";

export default {
  name: "createActivityPage",
  // onLoad (options) {
    //options.参数名就可以取到
    // if (options.type === 'edit') {
    //   // 动态修改标题
    //   wx.setNavigationBarTitle({
    //     title: '修改活动',
    //   })
    // }
  // },
  onShow () {
  }
};
</script>