<template>
|
<view class="activity-container" :data-theme='theme()' :class="theme() || ''">
|
<view class="top-box">
|
<view class="index-search-box index-search-box_re d-b-c" id="searchBox">
|
<view class="index-search index-search_re t-c flex-1">
|
<text class="icon iconfont icon-sousuo"></text>
|
<input type="text" v-model="keyword" class="flex-1 ml10 f26 gray3" value="" placeholder-class="f26 gray9"
|
placeholder="搜索活动" confirm-type="search" @confirm="searchFunc()" />
|
</view>
|
<view class="top-add d-s-c f28" @click="gotoPage('pages/branch/admin/activity/add')">
|
<text class="iconfont icon-ziyuan2 f28 mr10"></text>
|
<text>添加</text>
|
</view>
|
</view>
|
<view class="inner-tab">
|
<view :class="type_active==-1?'item active':'item'" @click="tabTypeFunc(-1)">
|
<view class="box">全部</view>
|
</view>
|
<view :class="type_active==1?'item active':'item'" @click="tabTypeFunc(1)">
|
<view class="box">进行中</view>
|
</view>
|
<view :class="type_active==0?'item active':'item'" @click="tabTypeFunc(0)">
|
<view class="box">未开始</view>
|
</view>
|
<view :class="type_active==2?'item active':'item'" @click="tabTypeFunc(2)">
|
<view class="box">已结束</view>
|
</view>
|
</view>
|
</view>
|
<!--内容-->
|
<view class="activity-box" v-if="!loading">
|
<scroll-view scroll-y="true" class="scroll-Y" :style="'height:' + scrollviewHigh + 'px;'" lower-threshold="50" @scrolltolower="scrolltolowerFunc">
|
<view :class="topRefresh ? 'top-refresh open' : 'top-refresh'">
|
<view class="circle" v-for="(circle, n) in 3" :key="n"></view>
|
</view>
|
<view class="list-box p-0-20">
|
<view class="item bg-white radius24 mt20" v-for="(item,index) in listData" :key="index">
|
<view class="d-b-c">
|
<view class="f26">活动编号:{{item.activity_id}}</view>
|
<view class="f24">
|
<text class="theme-price" v-if="item.status_text.status==1">活动进行中</text>
|
<text v-else-if="item.status_text.reg_status==1">报名进行中</text>
|
<text class="gray9" v-else-if="item.status_text.status==2">已结束</text>
|
</view>
|
</view>
|
<view class="item-info-box pt20">
|
<view class="pr20">
|
<image :src="item.image ? item.image.file_path : remoteImg('activity_bg')" mode="aspectFill"></image>
|
</view>
|
<view class="item-info d-c">
|
<view class="gray3 f28 text-ellipsis-2">{{item.name}}</view>
|
<view class="d-b-c">
|
<view class="gray6">活动开始时间:{{item.status_text.act_start_time}}</view>
|
</view>
|
</view>
|
</view>
|
<view>
|
<view class="d-b-c p-20-0">
|
<view class="gray6">活动费用:</view>
|
<view>¥{{item.fee}}</view>
|
</view>
|
<view class="d-b-c p-20-0">
|
<view class="gray6">报名人数/签到人数/名额:</view>
|
<view>{{item.total}}/{{item.verify_num}}/{{item.limit_num > 0 ? item.limit_num : '不限'}}</view>
|
</view>
|
</view>
|
<view class="item-operation d-e-c pt30">
|
<view class="item-btn" @click="onQRCode(item.activity_id)" v-if="item.status_text.status<2">核销码</view>
|
<view class="item-btn" @click="gotoPage('pages/branch/admin/activity/user?activity_id='+item.activity_id)">报名名单</view>
|
<view class="item-btn" @click="gotoPage('pages/branch/admin/activity/album?activity_id='+item.activity_id)">活动相册</view>
|
<view class="item-btn" @click="onEdit(item.activity_id)" v-if="item.status_text.status<2">编辑</view>
|
<view class="item-btn" @click="onDelete(item.activity_id)">删除</view>
|
</view>
|
</view>
|
</view>
|
<!--列表-->
|
<!-- 没有记录 -->
|
<view class="none-data-box" v-if="listData.length==0 && !loading">
|
<image :src="remoteImg('no_thing')" mode="widthFix"></image>
|
<text>暂无数据</text>
|
</view>
|
<uni-load-more v-else :loadingType="loadingType"></uni-load-more>
|
</scroll-view>
|
</view>
|
<!--核销二维码-->
|
<Popup :show="isCodeImg" type="middle" @hidePopup="hideCodePopupFunc">
|
<view class="ww100 p20 box-s-b">
|
<image class="ww100" :src="codeImg" mode="widthFix"></image>
|
</view>
|
<view class="ww100">
|
<button class="btn-red mt20" type="default" @click="saveCodeImg">保存图片</button>
|
</view>
|
</Popup>
|
</view>
|
</template>
|
|
<script>
|
import Popup from '@/components/uni-popup.vue';
|
import uniLoadMore from '@/components/uni-load-more.vue';
|
export default {
|
components: {
|
Popup,
|
uniLoadMore
|
},
|
data() {
|
return {
|
/*手机高度*/
|
phoneHeight: 0,
|
/*可滚动视图区域高度*/
|
scrollviewHigh: 0,
|
/*商品列表*/
|
listData: [],
|
/*最后一页码数*/
|
last_page: 0,
|
/*当前页面*/
|
page: 1,
|
/*每页条数*/
|
list_rows: 10,
|
/*有没有更多*/
|
no_more: false,
|
/*是否正在加载*/
|
loading: true,
|
/*顶部刷新*/
|
topRefresh: false,
|
type_active: -1,
|
keyword: '', // 搜索关键词
|
/*是否显示核销二维码*/
|
isCodeImg: false,
|
codeImg: '',
|
};
|
},
|
computed: {
|
/*加载中状态*/
|
loadingType() {
|
if (this.loading) {
|
return 1;
|
} else {
|
if (this.listData.length != 0 && this.no_more) {
|
return 2;
|
} else {
|
return 0;
|
}
|
}
|
}
|
},
|
onLoad(e) {},
|
onShow() {
|
/*获取列表*/
|
this.getlist();
|
},
|
mounted() {
|
this.init();
|
|
},
|
onReachBottom() {},
|
methods: {
|
searchFunc() {
|
this.listData = [];
|
this.page = 1;
|
/*获取列表*/
|
this.getlist();
|
},
|
/*初始化*/
|
init() {
|
let _this = this;
|
uni.getSystemInfo({
|
success(res) {
|
_this.phoneHeight = res.windowHeight;
|
// 计算组件的高度
|
let view = uni.createSelectorQuery().select('.top-box');
|
view.boundingClientRect(data => {
|
let h = _this.phoneHeight - data.height;
|
_this.scrollviewHigh = h;
|
}).exec();
|
}
|
});
|
},
|
|
/*获取活动列表*/
|
getlist() {
|
let self = this;
|
uni.showLoading({
|
title: '加载中'
|
});
|
let params = {
|
status: self.type_active,
|
keyword: self.keyword,
|
list_rows: self.list_rows,
|
page: self.page
|
};
|
self.loading = true;
|
self._get(
|
'branch.admin.activity/index', params, function(res) {
|
self.listData = res.data.list.data;
|
self.last_page = res.data.list.last_page;
|
if (res.data.list.last_page <= 1) {
|
self.no_more = true;
|
} else {
|
self.no_more = false;
|
}
|
uni.hideLoading();
|
self.loading = false;
|
}
|
);
|
},
|
|
onEdit(e) {
|
this.gotoPage('pages/branch/admin/activity/edit?activity_id=' + e);
|
},
|
|
/*还原初始化*/
|
restoreData() {
|
this.listData = [];
|
this.keyword = '';
|
},
|
|
/*类别切换*/
|
tabTypeFunc(e) {
|
let self = this;
|
self.listData = [];
|
self.page = 1;
|
self.no_more = false;
|
self.loading = true;
|
self.type_active = e;
|
self.getlist();
|
},
|
|
/*可滚动视图区域到底触发*/
|
scrolltolowerFunc() {
|
let self = this;
|
if (self.no_more) {
|
return;
|
}
|
self.page++;
|
if (self.page <= self.last_page) {
|
self.getlist();
|
} else {
|
self.no_more = true;
|
}
|
},
|
|
/*预览*/
|
gotoPreview(e) {
|
let url = 'pages/branch/activity/detail/detail?is_preview=1&activity_id=' + e.activity_id
|
this.gotoPage(url);
|
},
|
|
/*删除活动*/
|
onDelete(e) {
|
let self = this;
|
wx.showModal({
|
title: "提示",
|
content: "您确定要删除此活动吗?",
|
success: function(o) {
|
o.confirm && self._get('branch.admin.activity/delete', {
|
activity_id: e
|
}, function(result) {
|
if (result.code == 1) {
|
uni.showToast({
|
title: '删除成功',
|
duration: 2000
|
});
|
self.getlist();
|
}
|
|
});
|
}
|
});
|
|
},
|
|
/*核销码*/
|
onQRCode(e) {
|
let self = this;
|
uni.showLoading({
|
title: '加载中'
|
});
|
let activity_id = e;
|
let source = self.getPlatform();
|
self._get(
|
'branch.admin.activity/qrcode', {
|
activity_id: activity_id,
|
source: source
|
},
|
function(res) {
|
uni.hideLoading();
|
self.isCodeImg = true;
|
self.codeImg = res.data.qrcode;
|
}
|
);
|
},
|
|
/*关闭核销二维码*/
|
hideCodePopupFunc() {
|
this.isCodeImg = false;
|
},
|
|
//保存核销码
|
saveCodeImg() {
|
let self = this;
|
uni.showLoading({
|
title: '加载中'
|
});
|
// 下载海报图片
|
uni.downloadFile({
|
url: self.codeImg,
|
success(res) {
|
uni.hideLoading();
|
// 图片保存到本地
|
uni.saveImageToPhotosAlbum({
|
filePath: res.tempFilePath,
|
success(data) {
|
uni.showToast({
|
title: '保存成功',
|
icon: 'success',
|
duration: 2000
|
});
|
// 关闭核销码窗口
|
self.isCodeImg = false;
|
},
|
fail(err) {
|
if (err.errMsg === 'saveImageToPhotosAlbum:fail auth deny') {
|
uni.showToast({
|
title: '请允许访问相册后重试',
|
icon: 'none',
|
duration: 1000
|
});
|
setTimeout(() => {
|
uni.openSetting();
|
}, 1000);
|
}
|
},
|
complete(res) {
|
console.log('complete');
|
}
|
});
|
}
|
});
|
},
|
|
}
|
};
|
</script>
|
|
<style lang="scss" scoped>
|
page {
|
background: #f5f5f5;
|
}
|
.top-box {
|
.inner-tab {
|
position: relative;
|
height: 70rpx;
|
display: flex;
|
justify-content: space-around;
|
align-items: center;
|
background: #ffffff;
|
z-index: 9;
|
.item {
|
flex: 1;
|
height: 100%;
|
line-height: 70rpx;
|
position: relative;
|
color: #999;
|
font-size: 28rpx;
|
&.active {
|
color: #333333;
|
font-weight: bold;
|
&::after {
|
content: '';
|
width: 72rpx;
|
height: 4rpx;
|
background: #EE1414;
|
border-radius: 2rpx;
|
position: absolute;
|
bottom: 14rpx;
|
left: 0;
|
right: 0;
|
margin: auto;
|
}
|
}
|
.box {
|
display: flex;
|
justify-content: center;
|
align-items: center;
|
flex-direction: row;
|
}
|
}
|
}
|
.top-add {
|
@include background_color('background_color');
|
height: 60rpx;
|
border-radius: 80rpx;
|
color: #ffffff;
|
padding: 0 20rpx;
|
margin-left: 30rpx;
|
|
.iconfont {
|
color: #ffffff;
|
}
|
}
|
}
|
.activity-box {
|
|
.list-box {
|
|
.item{
|
padding: 20rpx;
|
|
.item-info-box {
|
display: flex;
|
|
image {
|
width: 230rpx;
|
height: 120rpx;
|
border-radius: 12rpx;
|
background-color: rgba(0, 0, 0, 0.1);
|
}
|
|
.item-info {
|
display: flex;
|
justify-content: space-between;
|
}
|
}
|
|
.item-operation {
|
|
.item-btn {
|
font-size: 24rpx;
|
color: #333333;
|
border: 1rpx solid #cccccc;
|
border-radius: 60rpx;
|
padding: 14rpx 20rpx;
|
margin-left: 12rpx;
|
}
|
}
|
}
|
}
|
}
|
|
|
|
</style>
|