Toggle navigation
Toggle navigation
This project
Loading...
Sign in
Hooke
/
swx_weapp
Go to a project
Toggle navigation
Toggle navigation pinning
Projects
Groups
Snippets
Help
Project
Activity
Repository
Graphs
Network
Create a new issue
Commits
Issue Boards
Authored by
hookehuyr
2022-10-26 10:35:00 +0800
Browse Files
Options
Browse Files
Download
Email Patches
Plain Diff
Commit
72a03e66a351944c4b603632933177f11fc02307
72a03e66
1 parent
9e77905a
✨ feat(创建的活动页面): 新增活动复制功能
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
57 additions
and
10 deletions
src/api/Activity/index.js
src/components/activity-card.vue
src/pages/myCreateActivity/index.vue
src/api/Activity/index.js
View file @
72a03e6
/*
* @Date: 2022-10-20 13:15:00
* @LastEditors: hookehuyr hookehuyr@gmail.com
* @LastEditTime: 2022-10-2
5 17:27:05
* @LastEditTime: 2022-10-2
6 10:09:46
* @FilePath: /swx/src/api/Activity/index.js
* @Description: 活动信息
*/
...
...
@@ -10,6 +10,7 @@ import { fn, fetch } from '../fn';
const
Api
=
{
ACTIVITY_JOIN_LIST
:
'/srv/?a=activity_join_list'
,
ACTIVITY_ADD_LIST
:
'/srv/?a=activity_add_list'
,
ACTIVITY_COPY
:
'/srv/?a=activity_copy'
,
}
/**
...
...
@@ -23,3 +24,9 @@ export const joinListAPI = (params) => fn(fetch.get(Api.ACTIVITY_JOIN_LIST, para
* @returns
*/
export
const
addListAPI
=
(
params
)
=>
fn
(
fetch
.
get
(
Api
.
ACTIVITY_ADD_LIST
,
params
));
/**
* @description: 复制活动
* @returns
*/
export
const
copyListAPI
=
(
params
)
=>
fn
(
fetch
.
get
(
Api
.
ACTIVITY_COPY
,
params
));
...
...
src/components/activity-card.vue
View file @
72a03e6
<!--
* @Date: 2022-09-20 15:39:37
* @LastEditors: hookehuyr hookehuyr@gmail.com
* @LastEditTime: 2022-10-2
5 16:59:43
* @LastEditTime: 2022-10-2
6 10:23:46
* @FilePath: /swx/src/components/activity-card.vue
* @Description: 活动卡片组件
-->
<template>
<view
@tap="goTo(data.id, formatStatus(data))"
class="activity-card-page">
<view class="activity-card-page">
<view class="card-main">
<van-row>
<van-col :span="10">
<van-image width="100%" height="5rem" fit="cover" :src="data.cover" />
<van-image
@tap="goTo(data.id, formatStatus(data))"
width="100%" height="5rem" fit="cover" :src="data.cover" />
</van-col>
<van-col :span="14">
<view class="card-main-text">
<view
@tap="goTo(data.id, formatStatus(data))"
class="card-main-text">
<view style="font-size: 1.1rem;">{{ data.name }}</view>
<view class="status-text">
<van-tag v-if="data.mode === 'offline'" :round="true" color="#E9FAF4" text-color="#199A74" size="large">现场活动</van-tag>
...
...
@@ -52,9 +52,11 @@
</view>
</van-col>
</van-row>
<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>
<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>
</view>
</view>
<van-toast id="van-toast" />
<van-dialog id="van-dialog" />
</template>
<script setup>
...
...
@@ -62,6 +64,9 @@ import { ref, defineProps, computed } from 'vue'
import icon_address from '@/images/icon/address@2x.png'
import Taro from '@tarojs/taro'
import * as dayjs from 'dayjs'
import { copyListAPI } from '@/api/Activity/index'
import Toast from '@/components/vant-weapp/toast/toast';
import Dialog from '@vant/weapp/dist/dialog/dialog';
const props = defineProps({
data: Object,
...
...
@@ -97,6 +102,32 @@ const goTo = (id, status) => {
url: '../activityDetail/index?id=' + id + '&status=' + decodeURIComponent(status)
})
}
const emit = defineEmits(['on-copy']);
const copyActivity = async (id) => {
Dialog.confirm({
title: '温馨提示',
message: '是否确认复制活动?',
confirmButtonColor: '#199A74'
})
.then(async () => {
// 复制活动
const { code, data } = await copyListAPI({ i: id });
if (code) {
Toast({
duration: 1000,
type: 'success',
message: '复制成功',
onClose: () => {
emit('on-copy', id);
},
});
}
})
.catch(() => {
// on cancel
});
}
</script>
<style lang="less">
...
...
src/pages/myCreateActivity/index.vue
View file @
72a03e6
<!--
* @Date: 2022-09-19 14:11:06
* @LastEditors: hookehuyr hookehuyr@gmail.com
* @LastEditTime: 2022-10-26
09:42:30
* @LastEditTime: 2022-10-26
10:29:22
* @FilePath: /swx/src/pages/myCreateActivity/index.vue
* @Description: 文件描述
-->
...
...
@@ -66,9 +66,11 @@
<van-switch :checked="check_status" @change="onChange" size="22px" active-color="#199A74" />
</view>
</view>
<view style="">
<activity-card v-for="(item, index) in activity_list" :key="index" :data="item" status="edit" style="margin-bottom: 1rem;"></activity-card>
</view>
<scroll-view :scroll-y="true" :style="scrollStyle" @scrolltolower="onScrollToLower">
<view style="">
<activity-card @on-copy="onCopy" v-for="(item, index) in activity_list" :key="index" :data="item" status="copy" style="margin-bottom: 1rem;"></activity-card>
</view>
</scroll-view>
<view style="height: 3rem;"></view>
</view>
</div>
...
...
@@ -287,6 +289,13 @@ export default {
this.flag = true;
this.page = 0;
this.getList();
},
onCopy () { // 活动复制时间回调
// 查询数据
this.activity_list = [];
this.flag = true;
this.page = 0;
this.getList();
}
},
};
...
...
Please
register
or
login
to post a comment