Showing
2 changed files
with
107 additions
and
91 deletions
| 1 | <!-- | 1 | <!-- |
| 2 | * @Date: 2022-09-20 15:39:37 | 2 | * @Date: 2022-09-20 15:39:37 |
| 3 | * @LastEditors: hookehuyr hookehuyr@gmail.com | 3 | * @LastEditors: hookehuyr hookehuyr@gmail.com |
| 4 | - * @LastEditTime: 2022-10-26 14:20:33 | 4 | + * @LastEditTime: 2022-10-26 17:20:34 |
| 5 | * @FilePath: /swx/src/components/activity-card.vue | 5 | * @FilePath: /swx/src/components/activity-card.vue |
| 6 | * @Description: 活动卡片组件 | 6 | * @Description: 活动卡片组件 |
| 7 | --> | 7 | --> |
| ... | @@ -60,7 +60,6 @@ | ... | @@ -60,7 +60,6 @@ |
| 60 | </view> | 60 | </view> |
| 61 | </view> | 61 | </view> |
| 62 | <van-toast id="van-toast" /> | 62 | <van-toast id="van-toast" /> |
| 63 | - <van-dialog id="van-dialog" /> | ||
| 64 | </template> | 63 | </template> |
| 65 | 64 | ||
| 66 | <script setup> | 65 | <script setup> |
| ... | @@ -68,10 +67,8 @@ import { ref, defineProps, computed } from 'vue' | ... | @@ -68,10 +67,8 @@ import { ref, defineProps, computed } from 'vue' |
| 68 | import icon_address from '@/images/icon/address@2x.png' | 67 | import icon_address from '@/images/icon/address@2x.png' |
| 69 | import Taro from '@tarojs/taro' | 68 | import Taro from '@tarojs/taro' |
| 70 | import * as dayjs from 'dayjs' | 69 | import * as dayjs from 'dayjs' |
| 71 | -import { copyActivityAPI } from '@/api/Activity/index' | ||
| 72 | import Toast from '@/components/vant-weapp/toast/toast'; | 70 | import Toast from '@/components/vant-weapp/toast/toast'; |
| 73 | -import Dialog from '@vant/weapp/dist/dialog/dialog'; | 71 | +import Dialog from '@/components/vant-weapp/dialog/dialog'; |
| 74 | -import { endActivityAPI, delActivityAPI } from '@/api/Activity/index'; | ||
| 75 | 72 | ||
| 76 | const props = defineProps({ | 73 | const props = defineProps({ |
| 77 | data: Object, | 74 | data: Object, |
| ... | @@ -109,98 +106,25 @@ const goTo = (id, status) => { | ... | @@ -109,98 +106,25 @@ const goTo = (id, status) => { |
| 109 | } | 106 | } |
| 110 | 107 | ||
| 111 | const emit = defineEmits(['on-handle']); | 108 | const emit = defineEmits(['on-handle']); |
| 112 | -const copyActivity = async (id) => { | 109 | + |
| 113 | - Dialog.confirm({ | 110 | +// 复制活动 |
| 114 | - title: '温馨提示', | 111 | +const copyActivity = (id) => { |
| 115 | - message: '是否确认复制活动?', | 112 | + emit('on-handle', { id, type: 'copy' }); |
| 116 | - confirmButtonColor: '#199A74' | ||
| 117 | - }) | ||
| 118 | - .then(async () => { | ||
| 119 | - // 复制活动 | ||
| 120 | - const { code, data } = await copyActivityAPI({ i: id }); | ||
| 121 | - if (code) { | ||
| 122 | - Toast({ | ||
| 123 | - duration: 1000, | ||
| 124 | - type: 'success', | ||
| 125 | - message: '复制成功', | ||
| 126 | - onClose: () => { | ||
| 127 | - emit('on-handle', id); | ||
| 128 | - }, | ||
| 129 | - }); | ||
| 130 | - } | ||
| 131 | - }) | ||
| 132 | - .catch(() => { | ||
| 133 | - // on cancel | ||
| 134 | - }); | ||
| 135 | } | 113 | } |
| 136 | 114 | ||
| 137 | // 编辑活动 | 115 | // 编辑活动 |
| 138 | const editActivity = ({ id }) => { | 116 | const editActivity = ({ id }) => { |
| 139 | - Dialog.confirm({ | 117 | + emit('on-handle', { id, type: 'edit' }); |
| 140 | - title: '温馨提示', | ||
| 141 | - message: '是否确认编辑活动?', | ||
| 142 | - confirmButtonColor: '#199A74' | ||
| 143 | - }) | ||
| 144 | - .then(async () => { | ||
| 145 | - Taro.navigateTo({ | ||
| 146 | - url: '../createActivity/index?id=' + id + '&type=edit' | ||
| 147 | - }) | ||
| 148 | - }) | ||
| 149 | - .catch(() => { | ||
| 150 | - // on cancel | ||
| 151 | - }); | ||
| 152 | } | 118 | } |
| 153 | 119 | ||
| 154 | // 结束活动 | 120 | // 结束活动 |
| 155 | const finishActivity = ({ id }) => { | 121 | const finishActivity = ({ id }) => { |
| 156 | - Dialog.confirm({ | 122 | + emit('on-handle', { id, type: 'finish' }); |
| 157 | - title: '温馨提示', | ||
| 158 | - message: '是否确认结束活动?', | ||
| 159 | - confirmButtonColor: '#199A74' | ||
| 160 | - }) | ||
| 161 | - .then(async () => { | ||
| 162 | - // 结束活动 | ||
| 163 | - const { code, data } = await endActivityAPI({ i: id }); | ||
| 164 | - if (code) { | ||
| 165 | - Toast({ | ||
| 166 | - duration: 1000, | ||
| 167 | - type: 'success', | ||
| 168 | - message: '结束成功', | ||
| 169 | - onClose: () => { | ||
| 170 | - emit('on-handle', id); | ||
| 171 | - }, | ||
| 172 | - }); | ||
| 173 | - } | ||
| 174 | - }) | ||
| 175 | - .catch(() => { | ||
| 176 | - // on cancel | ||
| 177 | - }); | ||
| 178 | } | 123 | } |
| 179 | 124 | ||
| 180 | // 删除活动 | 125 | // 删除活动 |
| 181 | const delActivity = ({ id }) => { | 126 | const delActivity = ({ id }) => { |
| 182 | - Dialog.confirm({ | 127 | + emit('on-handle', { id, type: 'delete' }); |
| 183 | - title: '温馨提示', | ||
| 184 | - message: '是否确认删除活动?', | ||
| 185 | - confirmButtonColor: '#199A74' | ||
| 186 | - }) | ||
| 187 | - .then(async () => { | ||
| 188 | - // 复制活动 | ||
| 189 | - const { code, data } = await delActivityAPI({ i: id }); | ||
| 190 | - if (code) { | ||
| 191 | - Toast({ | ||
| 192 | - duration: 1000, | ||
| 193 | - type: 'success', | ||
| 194 | - message: '删除成功', | ||
| 195 | - onClose: () => { | ||
| 196 | - emit('on-handle', id); | ||
| 197 | - }, | ||
| 198 | - }); | ||
| 199 | - } | ||
| 200 | - }) | ||
| 201 | - .catch(() => { | ||
| 202 | - // on cancel | ||
| 203 | - }); | ||
| 204 | } | 128 | } |
| 205 | </script> | 129 | </script> |
| 206 | 130 | ... | ... |
| 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-26 15:21:16 | 4 | + * @LastEditTime: 2022-10-26 17:29:34 |
| 5 | * @FilePath: /swx/src/pages/myCreateActivity/index.vue | 5 | * @FilePath: /swx/src/pages/myCreateActivity/index.vue |
| 6 | * @Description: 创建的活动页面 | 6 | * @Description: 创建的活动页面 |
| 7 | --> | 7 | --> |
| ... | @@ -68,9 +68,9 @@ | ... | @@ -68,9 +68,9 @@ |
| 68 | </view> | 68 | </view> |
| 69 | </view> | 69 | </view> |
| 70 | <scroll-view :scroll-y="true" :style="scrollStyle" @scrolltolower="onScrollToLower"> | 70 | <scroll-view :scroll-y="true" :style="scrollStyle" @scrolltolower="onScrollToLower"> |
| 71 | - <view style=""> | 71 | + <!-- <view style=""> --> |
| 72 | <activity-card @on-handle="onHandle" v-for="(item, index) in activity_list" :key="index" :data="item" status="creator" style="margin-bottom: 1rem;"></activity-card> | 72 | <activity-card @on-handle="onHandle" v-for="(item, index) in activity_list" :key="index" :data="item" status="creator" style="margin-bottom: 1rem;"></activity-card> |
| 73 | - </view> | 73 | + <!-- </view> --> |
| 74 | </scroll-view> | 74 | </scroll-view> |
| 75 | <view style="height: 3rem;"></view> | 75 | <view style="height: 3rem;"></view> |
| 76 | </view> | 76 | </view> |
| ... | @@ -89,6 +89,10 @@ | ... | @@ -89,6 +89,10 @@ |
| 89 | </van-popup> | 89 | </van-popup> |
| 90 | <van-toast id="van-toast" /> | 90 | <van-toast id="van-toast" /> |
| 91 | 91 | ||
| 92 | + <van-dialog title="温馨提示" :show="copy_show" :show-cancel-button="true" message="是否确认复制活动?" confirm-button-color="#199A74" @confirm="onCopyConfirm" @cancel="onCopyCancel"></van-dialog> | ||
| 93 | + <van-dialog title="温馨提示" :show="edit_show" :show-cancel-button="true" message="是否确认编辑活动?" confirm-button-color="#199A74" @confirm="onEditConfirm" @cancel="onEditCancel"></van-dialog> | ||
| 94 | + <van-dialog title="温馨提示" :show="finish_show" :show-cancel-button="true" message="是否确认结束活动?" confirm-button-color="#199A74" @confirm="onFinishConfirm" @cancel="onFinishCancel"></van-dialog> | ||
| 95 | + <van-dialog title="温馨提示" :show="delete_show" :show-cancel-button="true" message="是否确认删除活动?" confirm-button-color="#199A74" @confirm="onDeleteConfirm" @cancel="onDeleteCancel"></van-dialog> | ||
| 92 | </template> | 96 | </template> |
| 93 | 97 | ||
| 94 | <script setup> | 98 | <script setup> |
| ... | @@ -109,12 +113,12 @@ import Toast from '@/components/vant-weapp/toast/toast'; | ... | @@ -109,12 +113,12 @@ import Toast from '@/components/vant-weapp/toast/toast'; |
| 109 | 113 | ||
| 110 | <script> | 114 | <script> |
| 111 | import "./index.less"; | 115 | import "./index.less"; |
| 112 | -import { addListAPI } from '@/api/Activity/index'; | ||
| 113 | import { $ } from '@tarojs/extend' | 116 | import { $ } from '@tarojs/extend' |
| 114 | import mixin from '@/utils/mixin'; | 117 | import mixin from '@/utils/mixin'; |
| 115 | import { getCurrentPageParam } from "@/utils/weapp"; | 118 | import { getCurrentPageParam } from "@/utils/weapp"; |
| 116 | import { hostListAPI } from '@/api/Host/index' | 119 | import { hostListAPI } from '@/api/Host/index' |
| 117 | import * as dayjs from 'dayjs' | 120 | import * as dayjs from 'dayjs' |
| 121 | +import { addListAPI, endActivityAPI, delActivityAPI, copyActivityAPI } from '@/api/Activity/index'; | ||
| 118 | 122 | ||
| 119 | export default { | 123 | export default { |
| 120 | name: "myCreateActivityPage", | 124 | name: "myCreateActivityPage", |
| ... | @@ -191,7 +195,12 @@ export default { | ... | @@ -191,7 +195,12 @@ export default { |
| 191 | check_status: false, | 195 | check_status: false, |
| 192 | filter_time: '', | 196 | filter_time: '', |
| 193 | server_time: '', | 197 | server_time: '', |
| 194 | - defaultIndex: 0 | 198 | + defaultIndex: 0, |
| 199 | + activity_id: '', | ||
| 200 | + edit_show: false, | ||
| 201 | + copy_show: false, | ||
| 202 | + finish_show: false, | ||
| 203 | + delete_show: false, | ||
| 195 | }; | 204 | }; |
| 196 | }, | 205 | }, |
| 197 | methods: { | 206 | methods: { |
| ... | @@ -293,12 +302,95 @@ export default { | ... | @@ -293,12 +302,95 @@ export default { |
| 293 | this.page = 0; | 302 | this.page = 0; |
| 294 | this.getList(); | 303 | this.getList(); |
| 295 | }, | 304 | }, |
| 296 | - onHandle () { // 活动操作后回调 | 305 | + onHandle ({ id, type }) { // 活动操作后回调 |
| 306 | + this.activity_id = id; | ||
| 307 | + if (type === 'edit') { | ||
| 308 | + this.edit_show = true; | ||
| 309 | + } | ||
| 310 | + if (type === 'copy') { | ||
| 311 | + this.copy_show = true; | ||
| 312 | + } | ||
| 313 | + if (type === 'finish') { | ||
| 314 | + this.finish_show = true; | ||
| 315 | + } | ||
| 316 | + if (type === 'delete') { | ||
| 317 | + this.delete_show = true; | ||
| 318 | + } | ||
| 319 | + }, | ||
| 320 | + onEditConfirm () { | ||
| 321 | + this.edit_show = false; | ||
| 322 | + Taro.navigateTo({ | ||
| 323 | + url: '../createActivity/index?id=' + this.activity_id + '&type=edit' | ||
| 324 | + }) | ||
| 325 | + }, | ||
| 326 | + onEditCancel () { | ||
| 327 | + this.edit_show = false; | ||
| 328 | + }, | ||
| 329 | + async onFinishConfirm () { | ||
| 330 | + const { code, data } = await endActivityAPI({ i: this.activity_id }); | ||
| 331 | + if (code) { | ||
| 332 | + Toast({ | ||
| 333 | + duration: 1000, | ||
| 334 | + type: 'success', | ||
| 335 | + message: '结束成功', | ||
| 336 | + onClose: () => { | ||
| 337 | + this.finish_show = false; | ||
| 297 | // 查询数据 | 338 | // 查询数据 |
| 298 | this.activity_list = []; | 339 | this.activity_list = []; |
| 299 | this.flag = true; | 340 | this.flag = true; |
| 300 | this.page = 0; | 341 | this.page = 0; |
| 301 | this.getList(); | 342 | this.getList(); |
| 343 | + }, | ||
| 344 | + }); | ||
| 345 | + } | ||
| 346 | + }, | ||
| 347 | + onFinishCancel () { | ||
| 348 | + this.activity_id = ''; | ||
| 349 | + this.finish_show = false; | ||
| 350 | + }, | ||
| 351 | + async onDeleteConfirm () { | ||
| 352 | + const { code, data } = await delActivityAPI({ i: this.activity_id }); | ||
| 353 | + if (code) { | ||
| 354 | + Toast({ | ||
| 355 | + duration: 1000, | ||
| 356 | + type: 'success', | ||
| 357 | + message: '删除成功', | ||
| 358 | + onClose: () => { | ||
| 359 | + this.delete_show = false; | ||
| 360 | + // 查询数据 | ||
| 361 | + this.activity_list = []; | ||
| 362 | + this.flag = true; | ||
| 363 | + this.page = 0; | ||
| 364 | + this.getList(); | ||
| 365 | + }, | ||
| 366 | + }); | ||
| 367 | + } | ||
| 368 | + }, | ||
| 369 | + onDeleteCancel () { | ||
| 370 | + this.activity_id = ''; | ||
| 371 | + this.delete_show = false; | ||
| 372 | + }, | ||
| 373 | + async onCopyConfirm () { | ||
| 374 | + const { code, data } = await copyActivityAPI({ i: this.activity_id }); | ||
| 375 | + if (code) { | ||
| 376 | + Toast({ | ||
| 377 | + duration: 1000, | ||
| 378 | + type: 'success', | ||
| 379 | + message: '复制成功', | ||
| 380 | + onClose: () => { | ||
| 381 | + this.copy_show = false; | ||
| 382 | + // 查询数据 | ||
| 383 | + this.activity_list = []; | ||
| 384 | + this.flag = true; | ||
| 385 | + this.page = 0; | ||
| 386 | + this.getList(); | ||
| 387 | + }, | ||
| 388 | + }); | ||
| 389 | + } | ||
| 390 | + }, | ||
| 391 | + onCopyCancel () { | ||
| 392 | + this.activity_id = ''; | ||
| 393 | + this.copy_show = false; | ||
| 302 | } | 394 | } |
| 303 | }, | 395 | }, |
| 304 | }; | 396 | }; | ... | ... |
-
Please register or login to post a comment