hookehuyr

✨ feat(创建活动): 新增活动API联调

......@@ -20,10 +20,10 @@
"@vant/weapp": "^1.10.3",
"axios": "^0.27.2",
"axios-miniprogram": "^2.0.0-rc-2",
"dayjs": "^1.11.5",
"pinia": "^2.0.6",
"taro-plugin-pinia": "^1.0.0",
"taro-ui-vue3": "^1.0.0-alpha.21",
"uuid": "^9.0.0",
"vant": "^4.0.0-alpha.3",
"vue": "^3.2.24"
},
......@@ -18386,15 +18386,6 @@
"node": ">= 0.4.0"
}
},
"node_modules/uuid": {
"version": "9.0.0",
"resolved": "https://mirrors.cloud.tencent.com/npm/uuid/-/uuid-9.0.0.tgz",
"integrity": "sha512-MXcSTerfPa4uqyzStbRoTgt5XIe3x5+42+q1sDuy3R5MDk66URdLMOZe5aPX/SQd+kuYAh0FdP/pO28IkQyTeg==",
"license": "MIT",
"bin": {
"uuid": "dist/bin/uuid"
}
},
"node_modules/v8-compile-cache": {
"version": "2.3.0",
"resolved": "https://mirrors.tencent.com/npm/v8-compile-cache/-/v8-compile-cache-2.3.0.tgz",
......@@ -32664,11 +32655,6 @@
"integrity": "sha1-n5VxD1CiZ5R7LMwSR0HBAoQn5xM=",
"devOptional": true
},
"uuid": {
"version": "9.0.0",
"resolved": "https://mirrors.cloud.tencent.com/npm/uuid/-/uuid-9.0.0.tgz",
"integrity": "sha512-MXcSTerfPa4uqyzStbRoTgt5XIe3x5+42+q1sDuy3R5MDk66URdLMOZe5aPX/SQd+kuYAh0FdP/pO28IkQyTeg=="
},
"v8-compile-cache": {
"version": "2.3.0",
"resolved": "https://mirrors.tencent.com/npm/v8-compile-cache/-/v8-compile-cache-2.3.0.tgz",
......
......@@ -45,10 +45,10 @@
"@vant/weapp": "^1.10.3",
"axios": "^0.27.2",
"axios-miniprogram": "^2.0.0-rc-2",
"dayjs": "^1.11.5",
"pinia": "^2.0.6",
"taro-plugin-pinia": "^1.0.0",
"taro-ui-vue3": "^1.0.0-alpha.21",
"uuid": "^9.0.0",
"vant": "^4.0.0-alpha.3",
"vue": "^3.2.24"
},
......
/*
* @Date: 2022-10-14 17:26:56
* @LastEditors: hookehuyr hookehuyr@gmail.com
* @LastEditTime: 2022-10-14 17:31:38
* @LastEditTime: 2022-10-18 09:28:54
* @FilePath: /swx/src/api/Host/index.js
* @Description: 文件描述
*/
......@@ -9,6 +9,7 @@ import { fn, fetch } from '../fn';
const Api = {
HOST_LIST: '/srv/?a=host_list',
ACTIVITY_ADD: '/srv/?a=activity_add',
}
/**
......@@ -16,3 +17,9 @@ const Api = {
* @returns
*/
export const hostListAPI = (params) => fn(fetch.post(Api.HOST_LIST, params));
/**
* @description: 新增活动
* @returns
*/
export const addActivityAPI = (params) => fn(fetch.post(Api.ACTIVITY_ADD, params));
......
<!--
* @Date: 2022-09-26 21:52:25
* @LastEditors: hookehuyr hookehuyr@gmail.com
* @LastEditTime: 2022-10-17 13:40:57
* @LastEditTime: 2022-10-18 09:52:24
* @FilePath: /swx/src/components/activity-editor.vue
* @Description: 文件描述
-->
......@@ -146,11 +146,12 @@ export default {
},
//监控输入
_onInputting: function (e) {
let html = e.detail.html;
let text = e.detail.text;
this.$emit('on-input', e.detail)
// let html = e.detail.html;
// let text = e.detail.text;
// this.triggerEvent("input", { html: html, text: text }, {});
console.warn(html);
console.warn(text);
// console.warn(html);
// console.warn(text);
}
}
}
......
<!--
* @Date: 2022-09-21 16:04:10
* @LastEditors: hookehuyr hookehuyr@gmail.com
* @LastEditTime: 2022-10-17 18:30:58
* @LastEditTime: 2022-10-18 11:09:05
* @FilePath: /swx/src/pages/createActivity/index.vue
* @Description: 创建活动页面
-->
......@@ -31,7 +31,7 @@
<view class="divide-line"></view>
<view class="form-item">
<view class="form-item-title border">活动详情</view>
<activity-editor name="editor" :showTabBar="true" placeholder="开始输入活动详情介绍"></activity-editor>
<activity-editor name="editor" :showTabBar="true" placeholder="开始输入活动详情介绍" @on-input="onEditorInput"></activity-editor>
</view>
<view class="divide-line"></view>
<view class="form-item">
......@@ -261,7 +261,7 @@
</template>
<script setup>
import { ref, onMounted, nextTick } from "vue";
import { ref, onMounted, nextTick, toRefs } 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'
......@@ -269,12 +269,12 @@ 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'
import mixin from '../../utils/mixin';
import mixin from '@/utils/mixin';
import BASE_URL from '@/utils/config';
import Toast from '@/components/vant-weapp/toast/toast';
import { randomId } from '@/utils/tools'
import * as dayjs from 'dayjs'
const activity_name = ref('');
const onChange = ({ detail }) => {
......@@ -285,13 +285,7 @@ const onChange = ({ detail }) => {
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;
......@@ -444,7 +438,9 @@ const confirmEditSign = () => { // 确认报名信息回调
label: sign_filed.value.name,
checked: 1,
required: sign_filed.value.checked ? 1 : 0,
nop: false
nop: false,
type: 'player',
field: sign_filed.value.name
});
}
}
......@@ -625,20 +621,89 @@ const onExtendChange = ({ detail }) => {
extend.value = detail.split(',');
}
const onExtendBlur = () => { // TODO:提交时可以才检查一次
console.warn(job_post.value.indexOf(','));
if (job_post.value.indexOf(',') >= 0) {
Toast('请使用中文标点逗号');
}
}
const onSubmit = () => {
console.warn(extend.value);
// 活动详情富文本
const activity_note = ref('');
const onEditorInput = ({ html, text }) => {
activity_note.value = html;
}
const validForm = () => { // 校验表单
if (!host_id.value) {
Toast('主办方不能为空');
return false;
}
if (!activity_name.value) {
Toast('活动主题不能为空');
return false;
}
if (!uploader_image.value) {
Toast('活动封面不能为空');
return false;
}
if (!activity_time.value) {
Toast('活动时间不能为空');
return false;
}
if (!reg_begin_time.value) {
Toast('报名开始时间不能为空');
return false;
}
if (!reg_end_time.value) {
Toast('报名截止时间不能为空');
return false;
}
if (!dayjs(reg_begin_time.value).isBefore(dayjs(reg_end_time.value))) {
Toast('报名开始时间不能晚于报名截止时间');
return false;
}
if (reg_max.value === '') {
Toast('报名人数不能为空');
return false;
}
if (address.value === '') {
Toast('活动地址不能为空');
return false;
}
return true;
}
const onSubmit = async () => {
const fields = signInfo.value.filter(item => !item.nop && item.checked); // 处理报名信息结构,剔除固定字段,获取选中字段
if (validForm()) {
const params = {
host_id: host_id.value, // 主办方
name: activity_name.value, // 活动主题
cover: uploader_image.value, // 活动封面
note: activity_note.value, // 活动详情
fields: JSON.stringify(fields), // 报名信息
activity_time: activity_time.value, // 活动(开始)时间
reg_begin_time: reg_begin_time.value, // 报名开始时间
reg_end_time: reg_end_time.value, // 报名截止时间
reg_max: reg_max.value === '无限制' ? 0 : reg_max.value, // 报名限制人数
status: publish_status.value === '暂不发布' ? 0 : 1, // 状态
mode: activity_type.value === '现场活动' ? 0 : 1, // 活动方式
address: address.value, // 活动地址
is_public: public_type.value === '不公开' ? 0 : 1, // 是否公开
is_inner: is_inner.value ? 1 : 0, // 是否允许内部人员报名
is_black: is_black.value ? 1 : 0, // 是否屏蔽黑名单
extend: JSON.stringify(extend.value), // 义工岗位
}
const { code } = await addActivityAPI(params);
if (code) {
Taro.navigateBack()
}
}
}
</script>
<script>
import "./index.less";
import { hostListAPI } from '../../api/Host/index'
import { hostListAPI, addActivityAPI } from '@/api/Host/index'
export default {
name: "createActivityPage",
......
......@@ -3772,7 +3772,7 @@
"whatwg-mimetype" "^2.3.0"
"whatwg-url" "^8.0.0"
"dayjs@^1.8.29":
"dayjs@^1.11.5", "dayjs@^1.8.29":
"integrity" "sha512-CAdX5Q3YW3Gclyo5Vpqkgpj8fSdLQcRuzfX6mC6Phy0nfJ0eGYOeS7m4mt2plDWLAtA4TqTakvbboHvUxfe4iA=="
"resolved" "https://mirrors.cloud.tencent.com/npm/dayjs/-/dayjs-1.11.5.tgz"
"version" "1.11.5"
......@@ -10253,11 +10253,6 @@
"resolved" "https://mirrors.cloud.tencent.com/npm/uuid/-/uuid-3.4.0.tgz"
"version" "3.4.0"
"uuid@^9.0.0":
"integrity" "sha512-MXcSTerfPa4uqyzStbRoTgt5XIe3x5+42+q1sDuy3R5MDk66URdLMOZe5aPX/SQd+kuYAh0FdP/pO28IkQyTeg=="
"resolved" "https://mirrors.cloud.tencent.com/npm/uuid/-/uuid-9.0.0.tgz"
"version" "9.0.0"
"v8-compile-cache@^2.0.3":
"integrity" "sha512-l8lCEmLcLYZh4nbunNZvQCJc5pv7+RCwa8q/LdUx8u7lsWvPDKmpodJAJNwkAhJC//dFY48KuIEmjtd4RViDrA=="
"resolved" "https://mirrors.tencent.com/npm/v8-compile-cache/-/v8-compile-cache-2.3.0.tgz"
......