Showing
3 changed files
with
351 additions
and
0 deletions
src/pages/editProject/index.config.js
0 → 100755
| 1 | +/* | ||
| 2 | + * @Date: 2022-10-08 18:29:20 | ||
| 3 | + * @LastEditors: hookehuyr hookehuyr@gmail.com | ||
| 4 | + * @LastEditTime: 2022-10-10 11:00:52 | ||
| 5 | + * @FilePath: /swx/src/pages/editProject/index.config.js | ||
| 6 | + * @Description: 文件描述 | ||
| 7 | + */ | ||
| 8 | +export default { | ||
| 9 | + navigationBarTitleText: '编辑主办方', | ||
| 10 | + usingComponents: { | ||
| 11 | + }, | ||
| 12 | +} |
src/pages/editProject/index.less
0 → 100644
| 1 | +.create-project-page { | ||
| 2 | + background-color: #FFFFFF; | ||
| 3 | + height: 100%; | ||
| 4 | + overflow: scroll; | ||
| 5 | + .activity-title { | ||
| 6 | + background-color: #FFFFFF; | ||
| 7 | + .box { | ||
| 8 | + padding: 1rem 1rem 0.5rem 1rem; | ||
| 9 | + text-align: center; | ||
| 10 | + } | ||
| 11 | + } | ||
| 12 | + .bg-gradient { | ||
| 13 | + background: linear-gradient(#B3DDC9, #B3DDC9) no-repeat; | ||
| 14 | + /*调整下划线的宽度占百分之百 高度是3px */ | ||
| 15 | + background-size: 100% 1vw; | ||
| 16 | + /* 调整下划线的起始位置 左侧是0 上边是1.15em */ | ||
| 17 | + background-position: 0 1.25rem; | ||
| 18 | + } | ||
| 19 | + .user-type-box, .user-status-box { | ||
| 20 | + padding-top: 1rem; | ||
| 21 | + .title { | ||
| 22 | + font-size: 32rpx; margin-left: 1rem; | ||
| 23 | + } | ||
| 24 | + .border { | ||
| 25 | + margin: 0 1rem; border-bottom: 1px solid #F2F2F2; | ||
| 26 | + } | ||
| 27 | + } | ||
| 28 | + .sign-box { | ||
| 29 | + width: 100%; | ||
| 30 | + display: flex; | ||
| 31 | + flex-wrap: wrap; | ||
| 32 | + background-color: #FFFFFF; | ||
| 33 | + padding-bottom: 1rem; | ||
| 34 | + .sign-item { | ||
| 35 | + flex: 1; | ||
| 36 | + width: 27%; | ||
| 37 | + min-width: 27%; | ||
| 38 | + max-width: 27%; | ||
| 39 | + border: 1px solid #999999; | ||
| 40 | + color: #999999; | ||
| 41 | + margin: 1rem; | ||
| 42 | + margin-right: 0; | ||
| 43 | + margin-bottom: 0; | ||
| 44 | + text-align: center; | ||
| 45 | + padding: 0.5rem 0; | ||
| 46 | + text { | ||
| 47 | + position: relative; | ||
| 48 | + &.required::before { | ||
| 49 | + color: red; | ||
| 50 | + content: "*"; | ||
| 51 | + font-size: 0.9rem; | ||
| 52 | + left: -0.5rem; | ||
| 53 | + position: absolute; | ||
| 54 | + } | ||
| 55 | + } | ||
| 56 | + &.checked { | ||
| 57 | + border: 1px solid #199A74; | ||
| 58 | + color: #199A74; | ||
| 59 | + } | ||
| 60 | + } | ||
| 61 | + } | ||
| 62 | +} | ||
| 63 | +.sign-wrapper { | ||
| 64 | + display: flex; | ||
| 65 | + align-items: center; | ||
| 66 | + justify-content: center; | ||
| 67 | + height: 100%; | ||
| 68 | + .block { | ||
| 69 | + background-color: #fff; | ||
| 70 | + border-radius: 0.6rem; | ||
| 71 | + .title { | ||
| 72 | + padding: 1rem 1rem 0.5rem 1rem; | ||
| 73 | + text-align: center; | ||
| 74 | + text { | ||
| 75 | + font-size: 1.15rem; | ||
| 76 | + } | ||
| 77 | + } | ||
| 78 | + .border { | ||
| 79 | + overflow: auto; | ||
| 80 | + border-bottom: 1px solid #F2F2F2; | ||
| 81 | + .fix { | ||
| 82 | + float: left; | ||
| 83 | + padding-top: 0.5rem; | ||
| 84 | + } | ||
| 85 | + } | ||
| 86 | + .cancel-box { | ||
| 87 | + padding: 1rem 0; | ||
| 88 | + margin: 1rem; | ||
| 89 | + text-align: center; | ||
| 90 | + .button { | ||
| 91 | + color: #199A74; | ||
| 92 | + border: 1px solid #199A74; | ||
| 93 | + padding: 0.5rem 1rem; | ||
| 94 | + border-radius: 1rem; | ||
| 95 | + } | ||
| 96 | + } | ||
| 97 | + .confirm-box { | ||
| 98 | + padding: 1rem 0; | ||
| 99 | + margin: 1rem; | ||
| 100 | + text-align: center; | ||
| 101 | + .button { | ||
| 102 | + color: #FFFFFF; | ||
| 103 | + background-color: #199A74; | ||
| 104 | + padding: 0.5rem 1rem; | ||
| 105 | + border-radius: 1rem; | ||
| 106 | + } | ||
| 107 | + } | ||
| 108 | + } | ||
| 109 | +} |
src/pages/editProject/index.vue
0 → 100644
| 1 | +<!-- | ||
| 2 | + * @Date: 2022-09-19 14:11:06 | ||
| 3 | + * @LastEditors: hookehuyr hookehuyr@gmail.com | ||
| 4 | + * @LastEditTime: 2022-10-10 10:55:06 | ||
| 5 | + * @FilePath: /swx/src/pages/createProject/index.vue | ||
| 6 | + * @Description: 新建主办方页面 | ||
| 7 | +--> | ||
| 8 | +<template> | ||
| 9 | + <view class="create-project-page"> | ||
| 10 | + <view class="activity-title"> | ||
| 11 | + <view class="box"> | ||
| 12 | + <text class="bg-gradient" style="font-size: 1.25rem;">主办方信息设置</text> | ||
| 13 | + </view> | ||
| 14 | + </view> | ||
| 15 | + <AtInput :border="true" title="主办方名称" type='text' placeholder='请输入主办方名称' v-model:value="name" /> | ||
| 16 | + <view class="user-type-box"> | ||
| 17 | + <text class="title">用户类型</text> | ||
| 18 | + <view class="sign-box"> | ||
| 19 | + <view @tap="onTapType(item)" @longpress="onLongPressType(item)" v-for="(item, index) in userType" :key="index" | ||
| 20 | + class="sign-item" :class="{ 'checked': item.checked }"><text>{{ item.label }}</text></view> | ||
| 21 | + <view class="sign-item" @tap="addSign"> | ||
| 22 | + <van-icon name="plus" color="" /> | ||
| 23 | + </view> | ||
| 24 | + </view> | ||
| 25 | + <view class="border"></view> | ||
| 26 | + </view> | ||
| 27 | + <view class="user-status-box"> | ||
| 28 | + <text class="title">用户状态</text> | ||
| 29 | + <view class="sign-box"> | ||
| 30 | + <view @tap="onTapStatus(item)" @longpress="onLongPressStatus(item)" v-for="(item, index) in userStatus" :key="index" | ||
| 31 | + class="sign-item" :class="{ 'checked': item.checked }"><text>{{ item.label }}</text></view> | ||
| 32 | + <view class="sign-item" @tap="addStatus"> | ||
| 33 | + <van-icon name="plus" color="" /> | ||
| 34 | + </view> | ||
| 35 | + </view> | ||
| 36 | + <view class="border"></view> | ||
| 37 | + </view> | ||
| 38 | + <view style="height: 6rem;"></view> | ||
| 39 | + <bottom-button @on-submit="onSave">保存</bottom-button> | ||
| 40 | + </view> | ||
| 41 | + | ||
| 42 | + <!-- 用户类型弹出框 --> | ||
| 43 | + <van-overlay :show="show_edit_type" z-index="999"> | ||
| 44 | + <view class="sign-wrapper"> | ||
| 45 | + <view class="block"> | ||
| 46 | + <view class="title"> | ||
| 47 | + <text class="bg-gradient">用户类型</text> | ||
| 48 | + </view> | ||
| 49 | + <view style="width: 22rem;"> | ||
| 50 | + <van-field :value="add_user_type" label-class="label-class" input-class="input-class" rows="1" autosize label="用户类型" | ||
| 51 | + type="textarea" placeholder="请输入用户类型(6个字以内)" placeholder-style="color: #999;" customStyle="" inputAlign="" | ||
| 52 | + rightIcon="" :required="true" :border="true" @change="onChangeType" /> | ||
| 53 | + <van-row> | ||
| 54 | + <van-col span="12"> | ||
| 55 | + <view class="cancel-box"> | ||
| 56 | + <view class="button" @tap="closeEditType">取消</view> | ||
| 57 | + </view> | ||
| 58 | + </van-col> | ||
| 59 | + <van-col span="12"> | ||
| 60 | + <view class="confirm-box"> | ||
| 61 | + <view class="button" @tap="confirmEditType">确定</view> | ||
| 62 | + </view> | ||
| 63 | + </van-col> | ||
| 64 | + </van-row> | ||
| 65 | + </view> | ||
| 66 | + </view> | ||
| 67 | + </view> | ||
| 68 | + </van-overlay> | ||
| 69 | + | ||
| 70 | + <!-- 用户状态弹出框 --> | ||
| 71 | + <van-overlay :show="show_edit_status" z-index="999"> | ||
| 72 | + <view class="sign-wrapper"> | ||
| 73 | + <view class="block"> | ||
| 74 | + <view class="title"> | ||
| 75 | + <text class="bg-gradient">用户状态</text> | ||
| 76 | + </view> | ||
| 77 | + <view style="width: 22rem;"> | ||
| 78 | + <van-field :value="add_user_status" label-class="label-class" input-class="input-class" rows="1" autosize label="用户状态" | ||
| 79 | + type="textarea" placeholder="请输入用户状态(6个字以内)" placeholder-style="color: #999;" customStyle="" inputAlign="" | ||
| 80 | + rightIcon="" :required="true" :border="true" @change="onChangeStatus" /> | ||
| 81 | + <van-row> | ||
| 82 | + <van-col span="12"> | ||
| 83 | + <view class="cancel-box"> | ||
| 84 | + <view class="button" @tap="closeEditStatus">取消</view> | ||
| 85 | + </view> | ||
| 86 | + </van-col> | ||
| 87 | + <van-col span="12"> | ||
| 88 | + <view class="confirm-box"> | ||
| 89 | + <view class="button" @tap="confirmEditStatus">确定</view> | ||
| 90 | + </view> | ||
| 91 | + </van-col> | ||
| 92 | + </van-row> | ||
| 93 | + </view> | ||
| 94 | + </view> | ||
| 95 | + </view> | ||
| 96 | + </van-overlay> | ||
| 97 | + <van-toast id="van-toast" /> | ||
| 98 | +</template> | ||
| 99 | + | ||
| 100 | +<script setup> | ||
| 101 | +import Taro from '@tarojs/taro' | ||
| 102 | +import { ref } from "vue"; | ||
| 103 | +import { AtInput } from 'taro-ui-vue3' | ||
| 104 | +import "taro-ui-vue3/dist/style/components/input.scss"; | ||
| 105 | +import bottomButton from "@/components/bottom-button"; | ||
| 106 | +import request from '../../utils/request'; | ||
| 107 | +import Toast from '@/components/vant-weapp/toast/toast'; | ||
| 108 | + | ||
| 109 | +const name = ref(''); | ||
| 110 | +const user_type = ref([]); | ||
| 111 | +const user_status = ref([]); | ||
| 112 | +const add_user_type= ref(''); | ||
| 113 | +const add_user_status = ref(''); | ||
| 114 | + | ||
| 115 | +const onSave = () => { | ||
| 116 | + if (!name.value) { | ||
| 117 | + Toast.fail('名称不能为空'); | ||
| 118 | + return false; | ||
| 119 | + } | ||
| 120 | + let temp_user_type = userType.value.filter(element => element.checked); | ||
| 121 | + user_type.value = temp_user_type.map(element => element.label); | ||
| 122 | + let temp_user_status = userStatus.value.filter(element => element.checked); | ||
| 123 | + user_status.value = temp_user_status.map(element => element.label); | ||
| 124 | + // 保存主办方信息 | ||
| 125 | + request.post('/srv/?a=host_add', { | ||
| 126 | + name: name.value, | ||
| 127 | + user_type: user_type.value, | ||
| 128 | + user_status: user_status.value, | ||
| 129 | + }) | ||
| 130 | + .then(res => { | ||
| 131 | + if (res.data.code) { | ||
| 132 | + Toast.success('保存成功'); | ||
| 133 | + Taro.navigateBack({ | ||
| 134 | + delta: 1 | ||
| 135 | + }); | ||
| 136 | + } else { | ||
| 137 | + console.warn(res.data.msg); | ||
| 138 | + } | ||
| 139 | + }) | ||
| 140 | + .catch(err => { | ||
| 141 | + console.error(err); | ||
| 142 | + }); | ||
| 143 | +} | ||
| 144 | + | ||
| 145 | +const userType = ref([{ | ||
| 146 | + label: '首次参与', | ||
| 147 | + checked: 1, | ||
| 148 | +}, { | ||
| 149 | + label: '老用户', | ||
| 150 | + checked: 1, | ||
| 151 | +}]); | ||
| 152 | +const userStatus = ref([{ | ||
| 153 | + label: '跟踪', | ||
| 154 | + checked: 1, | ||
| 155 | +}, { | ||
| 156 | + label: '引导', | ||
| 157 | + checked: 1, | ||
| 158 | +}]); | ||
| 159 | + | ||
| 160 | + | ||
| 161 | + | ||
| 162 | +// 用户类型弹框操作 | ||
| 163 | +const onTapType = (item) => { | ||
| 164 | + item.checked = !item.checked | ||
| 165 | +} | ||
| 166 | +const onLongPressType = (item) => { | ||
| 167 | + show_edit_type.value = true; | ||
| 168 | +} | ||
| 169 | +const show_edit_type = ref(false) | ||
| 170 | +const onChangeType = ({ detail }) => { | ||
| 171 | + add_user_type.value = detail; | ||
| 172 | +} | ||
| 173 | +const closeEditType = () => { | ||
| 174 | + show_edit_type.value = false; | ||
| 175 | +} | ||
| 176 | +const confirmEditType = () => { | ||
| 177 | + if (!add_user_type.value) { | ||
| 178 | + Toast.fail('名称不能为空'); | ||
| 179 | + } else { | ||
| 180 | + show_edit_type.value = false; | ||
| 181 | + userType.value.push({ | ||
| 182 | + label: add_user_type.value, | ||
| 183 | + checked: 1, | ||
| 184 | + }); | ||
| 185 | + add_user_type.value = ''; | ||
| 186 | + } | ||
| 187 | +} | ||
| 188 | +const addSign = () => { | ||
| 189 | + show_edit_type.value = true; | ||
| 190 | +} | ||
| 191 | + | ||
| 192 | +// 用户状态 | ||
| 193 | +const onTapStatus = (item) => { | ||
| 194 | + item.checked = !item.checked | ||
| 195 | +} | ||
| 196 | +const onLongPressStatus = (item) => { | ||
| 197 | + show_edit_status.value = true; | ||
| 198 | +} | ||
| 199 | +const show_edit_status= ref(false) | ||
| 200 | +const onChangeStatus = ({ detail }) => { | ||
| 201 | + add_user_status.value = detail; | ||
| 202 | +} | ||
| 203 | +const closeEditStatus = () => { | ||
| 204 | + show_edit_status.value = false; | ||
| 205 | +} | ||
| 206 | +const confirmEditStatus = () => { | ||
| 207 | + if (!add_user_status.value) { | ||
| 208 | + Toast.fail('名称不能为空'); | ||
| 209 | + } else { | ||
| 210 | + show_edit_status.value = false; | ||
| 211 | + userStatus.value.push({ | ||
| 212 | + label: add_user_status.value, | ||
| 213 | + checked: 1, | ||
| 214 | + }) | ||
| 215 | + add_user_status.value = ''; | ||
| 216 | + } | ||
| 217 | +} | ||
| 218 | +const addStatus = () => { | ||
| 219 | + show_edit_status.value = true; | ||
| 220 | +} | ||
| 221 | + | ||
| 222 | +</script> | ||
| 223 | + | ||
| 224 | +<script> | ||
| 225 | +import "./index.less"; | ||
| 226 | + | ||
| 227 | +export default { | ||
| 228 | + name: "createProjectPage", | ||
| 229 | +}; | ||
| 230 | +</script> |
-
Please register or login to post a comment