Showing
2 changed files
with
118 additions
and
47 deletions
| 1 | /* | 1 | /* |
| 2 | * @Date: 2022-10-14 17:26:56 | 2 | * @Date: 2022-10-14 17:26:56 |
| 3 | * @LastEditors: hookehuyr hookehuyr@gmail.com | 3 | * @LastEditors: hookehuyr hookehuyr@gmail.com |
| 4 | - * @LastEditTime: 2022-10-19 16:44:53 | 4 | + * @LastEditTime: 2022-10-21 22:59:04 |
| 5 | * @FilePath: /swx/src/api/Host/index.js | 5 | * @FilePath: /swx/src/api/Host/index.js |
| 6 | * @Description: 活动相关接口 | 6 | * @Description: 活动相关接口 |
| 7 | */ | 7 | */ |
| ... | @@ -9,6 +9,9 @@ import { fn, fetch } from '../fn'; | ... | @@ -9,6 +9,9 @@ import { fn, fetch } from '../fn'; |
| 9 | 9 | ||
| 10 | const Api = { | 10 | const Api = { |
| 11 | HOST_LIST: '/srv/?a=host_list', | 11 | HOST_LIST: '/srv/?a=host_list', |
| 12 | + HOST_INFO: '/srv/?a=host_info', | ||
| 13 | + HOST_EDIT: '/srv/?a=host_edit', | ||
| 14 | + HOST_DELETE: '/srv/?a=host_del', | ||
| 12 | ACTIVITY_ADD: '/srv/?a=activity_add', | 15 | ACTIVITY_ADD: '/srv/?a=activity_add', |
| 13 | ACTIVITY_EDIT: '/srv/?a=activity_edit', | 16 | ACTIVITY_EDIT: '/srv/?a=activity_edit', |
| 14 | ACTIVITY_HOMEPAGE: '/srv/?a=activity_app_homepage', | 17 | ACTIVITY_HOMEPAGE: '/srv/?a=activity_app_homepage', |
| ... | @@ -19,7 +22,25 @@ const Api = { | ... | @@ -19,7 +22,25 @@ const Api = { |
| 19 | * @description: 主办方列表 | 22 | * @description: 主办方列表 |
| 20 | * @returns | 23 | * @returns |
| 21 | */ | 24 | */ |
| 22 | -export const hostListAPI = (params) => fn(fetch.post(Api.HOST_LIST, params)); | 25 | +export const hostListAPI = (params) => fn(fetch.get(Api.HOST_LIST, params)); |
| 26 | + | ||
| 27 | +/** | ||
| 28 | + * @description: 主办方详情 | ||
| 29 | + * @returns | ||
| 30 | + */ | ||
| 31 | +export const hostInfoAPI = (params) => fn(fetch.get(Api.HOST_INFO, params)); | ||
| 32 | + | ||
| 33 | +/** | ||
| 34 | + * @description: 修改主办方 | ||
| 35 | + * @returns | ||
| 36 | + */ | ||
| 37 | +export const editHostAPI = (params) => fn(fetch.post(Api.HOST_EDIT, params)); | ||
| 38 | + | ||
| 39 | +/** | ||
| 40 | + * @description: 删除主办方 | ||
| 41 | + * @returns | ||
| 42 | + */ | ||
| 43 | +export const deleteHostAPI = (params) => fn(fetch.post(Api.HOST_DELETE, params)); | ||
| 23 | 44 | ||
| 24 | /** | 45 | /** |
| 25 | * @description: 新增活动 | 46 | * @description: 新增活动 | ... | ... |
| 1 | <!-- | 1 | <!-- |
| 2 | * @Date: 2022-09-19 14:11:06 | 2 | * @Date: 2022-09-19 14:11:06 |
| 3 | * @LastEditors: hookehuyr hookehuyr@gmail.com | 3 | * @LastEditors: hookehuyr hookehuyr@gmail.com |
| 4 | - * @LastEditTime: 2022-10-10 10:55:06 | 4 | + * @LastEditTime: 2022-10-21 23:42:11 |
| 5 | - * @FilePath: /swx/src/pages/createProject/index.vue | 5 | + * @FilePath: /swx/src/pages/editProject/index.vue |
| 6 | * @Description: 新建主办方页面 | 6 | * @Description: 新建主办方页面 |
| 7 | --> | 7 | --> |
| 8 | <template> | 8 | <template> |
| ... | @@ -47,7 +47,7 @@ | ... | @@ -47,7 +47,7 @@ |
| 47 | <text class="bg-gradient">用户类型</text> | 47 | <text class="bg-gradient">用户类型</text> |
| 48 | </view> | 48 | </view> |
| 49 | <view style="width: 22rem;"> | 49 | <view style="width: 22rem;"> |
| 50 | - <van-field :value="add_user_type" label-class="label-class" input-class="input-class" rows="1" autosize label="用户类型" | 50 | + <van-field :value="add_user_type.name" label-class="label-class" input-class="input-class" rows="1" autosize label="用户类型" |
| 51 | type="textarea" placeholder="请输入用户类型(6个字以内)" placeholder-style="color: #999;" customStyle="" inputAlign="" | 51 | type="textarea" placeholder="请输入用户类型(6个字以内)" placeholder-style="color: #999;" customStyle="" inputAlign="" |
| 52 | rightIcon="" :required="true" :border="true" @change="onChangeType" /> | 52 | rightIcon="" :required="true" :border="true" @change="onChangeType" /> |
| 53 | <van-row> | 53 | <van-row> |
| ... | @@ -75,7 +75,7 @@ | ... | @@ -75,7 +75,7 @@ |
| 75 | <text class="bg-gradient">用户状态</text> | 75 | <text class="bg-gradient">用户状态</text> |
| 76 | </view> | 76 | </view> |
| 77 | <view style="width: 22rem;"> | 77 | <view style="width: 22rem;"> |
| 78 | - <van-field :value="add_user_status" label-class="label-class" input-class="input-class" rows="1" autosize label="用户状态" | 78 | + <van-field :value="add_user_status.name" label-class="label-class" input-class="input-class" rows="1" autosize label="用户状态" |
| 79 | type="textarea" placeholder="请输入用户状态(6个字以内)" placeholder-style="color: #999;" customStyle="" inputAlign="" | 79 | type="textarea" placeholder="请输入用户状态(6个字以内)" placeholder-style="color: #999;" customStyle="" inputAlign="" |
| 80 | rightIcon="" :required="true" :border="true" @change="onChangeStatus" /> | 80 | rightIcon="" :required="true" :border="true" @change="onChangeStatus" /> |
| 81 | <van-row> | 81 | <van-row> |
| ... | @@ -99,90 +99,97 @@ | ... | @@ -99,90 +99,97 @@ |
| 99 | 99 | ||
| 100 | <script setup> | 100 | <script setup> |
| 101 | import Taro from '@tarojs/taro' | 101 | import Taro from '@tarojs/taro' |
| 102 | -import { ref } from "vue"; | 102 | +import { ref, onMounted } from "vue"; |
| 103 | import { AtInput } from 'taro-ui-vue3' | 103 | import { AtInput } from 'taro-ui-vue3' |
| 104 | import "taro-ui-vue3/dist/style/components/input.scss"; | 104 | import "taro-ui-vue3/dist/style/components/input.scss"; |
| 105 | import bottomButton from "@/components/bottom-button"; | 105 | import bottomButton from "@/components/bottom-button"; |
| 106 | import request from '../../utils/request'; | 106 | import request from '../../utils/request'; |
| 107 | import Toast from '@/components/vant-weapp/toast/toast'; | 107 | import Toast from '@/components/vant-weapp/toast/toast'; |
| 108 | +import { hostInfoAPI, editHostAPI } from '@/api/Host/index'; | ||
| 109 | +import { getCurrentPageParam } from "@/utils/weapp"; | ||
| 110 | +import { randomId } from '@/utils/tools' | ||
| 111 | +import { json } from 'stream/consumers'; | ||
| 112 | + | ||
| 113 | + | ||
| 114 | +onMounted(async () => { | ||
| 115 | + const { code, data } = await hostInfoAPI({ i: getCurrentPageParam().id }); | ||
| 116 | + if (code) { | ||
| 117 | + console.warn(data); | ||
| 118 | + name.value = data.name | ||
| 119 | + } | ||
| 120 | +}) | ||
| 108 | 121 | ||
| 109 | const name = ref(''); | 122 | const name = ref(''); |
| 110 | const user_type = ref([]); | 123 | const user_type = ref([]); |
| 111 | const user_status = ref([]); | 124 | const user_status = ref([]); |
| 112 | -const add_user_type= ref(''); | 125 | +const add_user_type= ref({}); |
| 113 | -const add_user_status = ref(''); | 126 | +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 | 127 | ||
| 145 | const userType = ref([{ | 128 | const userType = ref([{ |
| 129 | + key: 'first', | ||
| 146 | label: '首次参与', | 130 | label: '首次参与', |
| 147 | checked: 1, | 131 | checked: 1, |
| 132 | + nop: true | ||
| 148 | }, { | 133 | }, { |
| 134 | + key: 'old', | ||
| 149 | label: '老用户', | 135 | label: '老用户', |
| 150 | checked: 1, | 136 | checked: 1, |
| 137 | + nop: true | ||
| 151 | }]); | 138 | }]); |
| 152 | const userStatus = ref([{ | 139 | const userStatus = ref([{ |
| 140 | + key: 'follow', | ||
| 153 | label: '跟踪', | 141 | label: '跟踪', |
| 154 | checked: 1, | 142 | checked: 1, |
| 143 | + nop: true | ||
| 155 | }, { | 144 | }, { |
| 145 | + key: 'guide', | ||
| 156 | label: '引导', | 146 | label: '引导', |
| 157 | checked: 1, | 147 | checked: 1, |
| 148 | + nop: true | ||
| 158 | }]); | 149 | }]); |
| 159 | 150 | ||
| 160 | - | ||
| 161 | - | ||
| 162 | // 用户类型弹框操作 | 151 | // 用户类型弹框操作 |
| 163 | const onTapType = (item) => { | 152 | const onTapType = (item) => { |
| 164 | - item.checked = !item.checked | 153 | + if (item.nop) return false; // 如果是固定字段不能操作 |
| 154 | + item.checked = !item.checked; | ||
| 165 | } | 155 | } |
| 156 | + | ||
| 157 | +const is_long_press = ref(false); // 是否是长按激活 | ||
| 166 | const onLongPressType = (item) => { | 158 | const onLongPressType = (item) => { |
| 159 | + if (item.nop) return false; // 如果是固定字段不能操作 | ||
| 167 | show_edit_type.value = true; | 160 | show_edit_type.value = true; |
| 161 | + is_long_press.value = true; | ||
| 162 | + add_user_type.value.key = item.key; | ||
| 163 | + add_user_type.value.name = item.label; | ||
| 168 | } | 164 | } |
| 169 | const show_edit_type = ref(false) | 165 | const show_edit_type = ref(false) |
| 170 | const onChangeType = ({ detail }) => { | 166 | const onChangeType = ({ detail }) => { |
| 171 | - add_user_type.value = detail; | 167 | + add_user_type.value.name = detail; |
| 172 | } | 168 | } |
| 173 | const closeEditType = () => { | 169 | const closeEditType = () => { |
| 174 | show_edit_type.value = false; | 170 | show_edit_type.value = false; |
| 171 | + is_long_press.value = false; | ||
| 175 | } | 172 | } |
| 176 | const confirmEditType = () => { | 173 | const confirmEditType = () => { |
| 177 | if (!add_user_type.value) { | 174 | if (!add_user_type.value) { |
| 178 | Toast.fail('名称不能为空'); | 175 | Toast.fail('名称不能为空'); |
| 179 | } else { | 176 | } else { |
| 180 | show_edit_type.value = false; | 177 | show_edit_type.value = false; |
| 178 | + if (is_long_press.value) { | ||
| 179 | + userType.value.forEach(item => { | ||
| 180 | + if (item.key === add_user_type.value.key) { // key值相同 | ||
| 181 | + item.label = add_user_type.value.name; | ||
| 182 | + } | ||
| 183 | + }); | ||
| 184 | + } else { | ||
| 181 | userType.value.push({ | 185 | userType.value.push({ |
| 182 | - label: add_user_type.value, | 186 | + key: randomId(5), |
| 187 | + label: add_user_type.value.name, | ||
| 183 | checked: 1, | 188 | checked: 1, |
| 184 | }); | 189 | }); |
| 185 | - add_user_type.value = ''; | 190 | + } |
| 191 | + add_user_type.value = {}; | ||
| 192 | + is_long_press.value = false; | ||
| 186 | } | 193 | } |
| 187 | } | 194 | } |
| 188 | const addSign = () => { | 195 | const addSign = () => { |
| ... | @@ -191,10 +198,17 @@ const addSign = () => { | ... | @@ -191,10 +198,17 @@ const addSign = () => { |
| 191 | 198 | ||
| 192 | // 用户状态 | 199 | // 用户状态 |
| 193 | const onTapStatus = (item) => { | 200 | const onTapStatus = (item) => { |
| 194 | - item.checked = !item.checked | 201 | + if (item.nop) return false; // 如果是固定字段不能操作 |
| 202 | + item.checked = !item.checked; | ||
| 195 | } | 203 | } |
| 204 | + | ||
| 205 | +const is_long_press_status = ref(false); // 是否是长按激活 | ||
| 196 | const onLongPressStatus = (item) => { | 206 | const onLongPressStatus = (item) => { |
| 207 | + if (item.nop) return false; //如果是固定字段不能操作 | ||
| 197 | show_edit_status.value = true; | 208 | show_edit_status.value = true; |
| 209 | + is_long_press_status.value = true; | ||
| 210 | + add_user_status.value.key = item.key; | ||
| 211 | + add_user_status.value.name = item.label; | ||
| 198 | } | 212 | } |
| 199 | const show_edit_status= ref(false) | 213 | const show_edit_status= ref(false) |
| 200 | const onChangeStatus = ({ detail }) => { | 214 | const onChangeStatus = ({ detail }) => { |
| ... | @@ -202,23 +216,56 @@ const onChangeStatus = ({ detail }) => { | ... | @@ -202,23 +216,56 @@ const onChangeStatus = ({ detail }) => { |
| 202 | } | 216 | } |
| 203 | const closeEditStatus = () => { | 217 | const closeEditStatus = () => { |
| 204 | show_edit_status.value = false; | 218 | show_edit_status.value = false; |
| 219 | + is_long_press_status.value = false; | ||
| 205 | } | 220 | } |
| 206 | const confirmEditStatus = () => { | 221 | const confirmEditStatus = () => { |
| 207 | if (!add_user_status.value) { | 222 | if (!add_user_status.value) { |
| 208 | Toast.fail('名称不能为空'); | 223 | Toast.fail('名称不能为空'); |
| 209 | } else { | 224 | } else { |
| 210 | show_edit_status.value = false; | 225 | show_edit_status.value = false; |
| 226 | + if (is_long_press.value) { | ||
| 227 | + userStatus.value.forEach(item => { | ||
| 228 | + if (item.key === add_user_status.value.key) { // key值相同 | ||
| 229 | + item.label = add_user_status.value.name; | ||
| 230 | + } | ||
| 231 | + }); | ||
| 232 | + } else { | ||
| 211 | userStatus.value.push({ | 233 | userStatus.value.push({ |
| 234 | + key: randomId(5), | ||
| 212 | label: add_user_status.value, | 235 | label: add_user_status.value, |
| 213 | checked: 1, | 236 | checked: 1, |
| 214 | }) | 237 | }) |
| 215 | - add_user_status.value = ''; | 238 | + } |
| 239 | + add_user_status.value = {}; | ||
| 240 | + is_long_press_status.value = false; | ||
| 216 | } | 241 | } |
| 217 | } | 242 | } |
| 218 | const addStatus = () => { | 243 | const addStatus = () => { |
| 219 | show_edit_status.value = true; | 244 | show_edit_status.value = true; |
| 220 | } | 245 | } |
| 221 | 246 | ||
| 247 | +const onSave = async () => { | ||
| 248 | + if (!name.value) { | ||
| 249 | + Toast.fail('名称不能为空'); | ||
| 250 | + return false; | ||
| 251 | + } | ||
| 252 | + let temp_user_type = userType.value.filter(element => element.checked && !element.nop); | ||
| 253 | + user_type.value = temp_user_type.map(element => element.label); | ||
| 254 | + let temp_user_status = userStatus.value.filter(element => element.checked && !element.nop); | ||
| 255 | + user_status.value = temp_user_status.map(element => element.label); | ||
| 256 | + // 修改主办方信息 | ||
| 257 | + const params = { | ||
| 258 | + i: getCurrentPageParam().id, | ||
| 259 | + name: name.value, | ||
| 260 | + user_type: JSON.stringify(user_type.value), | ||
| 261 | + user_status: JSON.stringify(user_status.value), | ||
| 262 | + } | ||
| 263 | + const { code, data } = await editHostAPI(params); | ||
| 264 | + if (code) { | ||
| 265 | + Toast.success('修改成功'); | ||
| 266 | + Taro.navigateBack(); | ||
| 267 | + } | ||
| 268 | +} | ||
| 222 | </script> | 269 | </script> |
| 223 | 270 | ||
| 224 | <script> | 271 | <script> |
| ... | @@ -226,5 +273,8 @@ import "./index.less"; | ... | @@ -226,5 +273,8 @@ import "./index.less"; |
| 226 | 273 | ||
| 227 | export default { | 274 | export default { |
| 228 | name: "createProjectPage", | 275 | name: "createProjectPage", |
| 276 | + async onShow () { | ||
| 277 | + | ||
| 278 | + } | ||
| 229 | }; | 279 | }; |
| 230 | </script> | 280 | </script> | ... | ... |
-
Please register or login to post a comment