hookehuyr

✨ feat(创建的活动页面): 新增活动复制功能

1 /* 1 /*
2 * @Date: 2022-10-20 13:15:00 2 * @Date: 2022-10-20 13:15:00
3 * @LastEditors: hookehuyr hookehuyr@gmail.com 3 * @LastEditors: hookehuyr hookehuyr@gmail.com
4 - * @LastEditTime: 2022-10-25 17:27:05 4 + * @LastEditTime: 2022-10-26 10:09:46
5 * @FilePath: /swx/src/api/Activity/index.js 5 * @FilePath: /swx/src/api/Activity/index.js
6 * @Description: 活动信息 6 * @Description: 活动信息
7 */ 7 */
...@@ -10,6 +10,7 @@ import { fn, fetch } from '../fn'; ...@@ -10,6 +10,7 @@ import { fn, fetch } from '../fn';
10 const Api = { 10 const Api = {
11 ACTIVITY_JOIN_LIST: '/srv/?a=activity_join_list', 11 ACTIVITY_JOIN_LIST: '/srv/?a=activity_join_list',
12 ACTIVITY_ADD_LIST: '/srv/?a=activity_add_list', 12 ACTIVITY_ADD_LIST: '/srv/?a=activity_add_list',
13 + ACTIVITY_COPY: '/srv/?a=activity_copy',
13 } 14 }
14 15
15 /** 16 /**
...@@ -23,3 +24,9 @@ export const joinListAPI = (params) => fn(fetch.get(Api.ACTIVITY_JOIN_LIST, para ...@@ -23,3 +24,9 @@ export const joinListAPI = (params) => fn(fetch.get(Api.ACTIVITY_JOIN_LIST, para
23 * @returns 24 * @returns
24 */ 25 */
25 export const addListAPI = (params) => fn(fetch.get(Api.ACTIVITY_ADD_LIST, params)); 26 export const addListAPI = (params) => fn(fetch.get(Api.ACTIVITY_ADD_LIST, params));
27 +
28 +/**
29 + * @description: 复制活动
30 + * @returns
31 + */
32 +export const copyListAPI = (params) => fn(fetch.get(Api.ACTIVITY_COPY, params));
......
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-25 16:59:43 4 + * @LastEditTime: 2022-10-26 10:23:46
5 * @FilePath: /swx/src/components/activity-card.vue 5 * @FilePath: /swx/src/components/activity-card.vue
6 * @Description: 活动卡片组件 6 * @Description: 活动卡片组件
7 --> 7 -->
8 <template> 8 <template>
9 - <view @tap="goTo(data.id, formatStatus(data))" class="activity-card-page"> 9 + <view class="activity-card-page">
10 <view class="card-main"> 10 <view class="card-main">
11 <van-row> 11 <van-row>
12 <van-col :span="10"> 12 <van-col :span="10">
13 - <van-image width="100%" height="5rem" fit="cover" :src="data.cover" /> 13 + <van-image @tap="goTo(data.id, formatStatus(data))" width="100%" height="5rem" fit="cover" :src="data.cover" />
14 </van-col> 14 </van-col>
15 <van-col :span="14"> 15 <van-col :span="14">
16 - <view class="card-main-text"> 16 + <view @tap="goTo(data.id, formatStatus(data))" class="card-main-text">
17 <view style="font-size: 1.1rem;">{{ data.name }}</view> 17 <view style="font-size: 1.1rem;">{{ data.name }}</view>
18 <view class="status-text"> 18 <view class="status-text">
19 <van-tag v-if="data.mode === 'offline'" :round="true" color="#E9FAF4" text-color="#199A74" size="large">现场活动</van-tag> 19 <van-tag v-if="data.mode === 'offline'" :round="true" color="#E9FAF4" text-color="#199A74" size="large">现场活动</van-tag>
...@@ -52,9 +52,11 @@ ...@@ -52,9 +52,11 @@
52 </view> 52 </view>
53 </van-col> 53 </van-col>
54 </van-row> 54 </van-row>
55 - <view v-if="status === 'copy'" style="position: absolute; right: 0; bottom: 1rem; background-color: #199A74; color: white; padding: 0.25rem; padding-left: 1rem; padding-right: 0.5rem; border-top-left-radius: 1rem; border-bottom-left-radius: 1rem;">复制</view> 55 + <view v-if="status === 'copy' && formatStatus(data) !== '已结束'" @tap="copyActivity(data.id)" style="position: absolute; right: 0; bottom: 1rem; background-color: #199A74; color: white; padding: 0.25rem; padding-left: 1rem; padding-right: 0.5rem; border-top-left-radius: 1rem; border-bottom-left-radius: 1rem;">复制</view>
56 </view> 56 </view>
57 </view> 57 </view>
58 + <van-toast id="van-toast" />
59 + <van-dialog id="van-dialog" />
58 </template> 60 </template>
59 61
60 <script setup> 62 <script setup>
...@@ -62,6 +64,9 @@ import { ref, defineProps, computed } from 'vue' ...@@ -62,6 +64,9 @@ import { ref, defineProps, computed } from 'vue'
62 import icon_address from '@/images/icon/address@2x.png' 64 import icon_address from '@/images/icon/address@2x.png'
63 import Taro from '@tarojs/taro' 65 import Taro from '@tarojs/taro'
64 import * as dayjs from 'dayjs' 66 import * as dayjs from 'dayjs'
67 +import { copyListAPI } from '@/api/Activity/index'
68 +import Toast from '@/components/vant-weapp/toast/toast';
69 +import Dialog from '@vant/weapp/dist/dialog/dialog';
65 70
66 const props = defineProps({ 71 const props = defineProps({
67 data: Object, 72 data: Object,
...@@ -97,6 +102,32 @@ const goTo = (id, status) => { ...@@ -97,6 +102,32 @@ const goTo = (id, status) => {
97 url: '../activityDetail/index?id=' + id + '&status=' + decodeURIComponent(status) 102 url: '../activityDetail/index?id=' + id + '&status=' + decodeURIComponent(status)
98 }) 103 })
99 } 104 }
105 +
106 +const emit = defineEmits(['on-copy']);
107 +const copyActivity = async (id) => {
108 + Dialog.confirm({
109 + title: '温馨提示',
110 + message: '是否确认复制活动?',
111 + confirmButtonColor: '#199A74'
112 + })
113 + .then(async () => {
114 + // 复制活动
115 + const { code, data } = await copyListAPI({ i: id });
116 + if (code) {
117 + Toast({
118 + duration: 1000,
119 + type: 'success',
120 + message: '复制成功',
121 + onClose: () => {
122 + emit('on-copy', id);
123 + },
124 + });
125 + }
126 + })
127 + .catch(() => {
128 + // on cancel
129 + });
130 +}
100 </script> 131 </script>
101 132
102 <style lang="less"> 133 <style lang="less">
......
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 09:42:30 4 + * @LastEditTime: 2022-10-26 10:29:22
5 * @FilePath: /swx/src/pages/myCreateActivity/index.vue 5 * @FilePath: /swx/src/pages/myCreateActivity/index.vue
6 * @Description: 文件描述 6 * @Description: 文件描述
7 --> 7 -->
...@@ -66,9 +66,11 @@ ...@@ -66,9 +66,11 @@
66 <van-switch :checked="check_status" @change="onChange" size="22px" active-color="#199A74" /> 66 <van-switch :checked="check_status" @change="onChange" size="22px" active-color="#199A74" />
67 </view> 67 </view>
68 </view> 68 </view>
69 + <scroll-view :scroll-y="true" :style="scrollStyle" @scrolltolower="onScrollToLower">
69 <view style=""> 70 <view style="">
70 - <activity-card v-for="(item, index) in activity_list" :key="index" :data="item" status="edit" style="margin-bottom: 1rem;"></activity-card> 71 + <activity-card @on-copy="onCopy" v-for="(item, index) in activity_list" :key="index" :data="item" status="copy" style="margin-bottom: 1rem;"></activity-card>
71 </view> 72 </view>
73 + </scroll-view>
72 <view style="height: 3rem;"></view> 74 <view style="height: 3rem;"></view>
73 </view> 75 </view>
74 </div> 76 </div>
...@@ -287,6 +289,13 @@ export default { ...@@ -287,6 +289,13 @@ export default {
287 this.flag = true; 289 this.flag = true;
288 this.page = 0; 290 this.page = 0;
289 this.getList(); 291 this.getList();
292 + },
293 + onCopy () { // 活动复制时间回调
294 + // 查询数据
295 + this.activity_list = [];
296 + this.flag = true;
297 + this.page = 0;
298 + this.getList();
290 } 299 }
291 }, 300 },
292 }; 301 };
......