| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606 |
- <style>
- .table-body {
- padding: 20px;
- background-color: #fff;
- }
- .input-item {
- display: inline-block;
- width: 250px;
- margin: 0 0 20px;
- }
- .input-item .el-input__inner {
- border-right: 0;
- }
- .input-item .el-input__inner:hover {
- border: 1px solid #dcdfe6;
- border-right: 0;
- outline: 0;
- }
- .input-item .el-input__inner:focus {
- border: 1px solid #dcdfe6;
- border-right: 0;
- outline: 0;
- }
- .input-item .el-input-group__append {
- background-color: #fff;
- border-left: 0;
- width: 10%;
- padding: 0;
- }
- .input-item .el-input-group__append .el-button {
- padding: 0;
- }
- .input-item .el-input-group__append .el-button {
- margin: 0;
- }
- .table-body .el-button {
- padding: 0 !important;
- border: 0;
- margin: 0 5px;
- }
- .el-table th > .cell {
- color: #333;
- font-weight: bold;
- font-size: 14px;
- }
- .el-table__footer-wrapper, .el-table__header-wrapper {
- border-bottom: 1.4px solid #D6D6D6;
- }
- .label {
- margin-right: 10px;
- }
- .default-goods{
- max-width: 50px;
- max-height: 50px;
- }
- .flex-x-between {
- display: -webkit-box;
- display: -webkit-flex;
- display: flex;
- -webkit-box-pack: space-between;
- -webkit-justify-content: space-between;
- -ms-flex-pack: space-between;
- justify-content: space-between;
- }
- .cont-title {
- font-size: 15px;
- padding-top: 20px;
- padding-bottom: 10px;
- font-weight: 700;
- }
- .cont-num {
- font-size: 14px;
- font-weight: 700;
- padding-bottom: 10px;
- }
- .center {
- text-align: center;
- }
- .el-dialog__header .el-dialog__title{
- font-size: 18px;
- }
- .el-dialog__wrapper .el-dialog__body{
- padding: 3px 20px;
- }
- /*头像样式 start*/
- .default-avatar{
- width: 50px;
- height: 50px;
- border-radius: 50%;
- }
- .user_img{
- position: relative;
- margin-right: 8px;
- height: 50px;
- width: 50px;
- }
- .el-table_2_column_8 .cell { /*-2 表示在第二行*/
- display: flex;
- }
- /*头像样式 end*/
- #qrcode-info{
- margin: 20px 31%;
- }
- </style>
- <div id="app" v-cloak>
- <el-card shadow="never" body-style="background-color: #f3f3f3;padding: 10px 0 0;">
- <div slot="header">
- <div>
- <span>活动列表</span>
- <div style="float: right; margin: -5px 0">
- <el-button type="primary" @click="add()" size="small">创建活动</el-button>
- </div>
- </div>
- </template>
- </div>
- <div class="table-body el-input--small">
- <el-form size="small" :inline="true" flex="dir:left cross:center" style="margin-bottom: 12px;">
- <div class="item-box" flex="dir:left cross:center">
- <div class="label">创建时间</div>
- <el-date-picker
- v-model="time"
- type="datetimerange"
- value-format="yyyy-MM-dd HH:mm:ss"
- range-separator="至"
- start-placeholder="开始日期"
- end-placeholder="结束日期">
- </el-date-picker>
- </div>
- <div class="item-box" flex="dir:left cross:center" style="margin-right: 20px; margin-left: 20px;">
- <div class="label">活动ID</div>
- <el-input style="width: 80px" v-model="search.id" placeholder="活动ID"></el-input>
- </div>
- <div class="item-box" flex="dir:left cross:center" style="margin-right: 20px">
- <div class="label">活动昵称</div>
- <el-input style="width: 150px" v-model="search.title" placeholder="活动昵称"></el-input>
- </div>
- <div class="item-box" flex="dir:left cross:center">
- <el-button type="primary" style="padding: 10px 20px !important;" @click="searchs">搜索
- </el-button>
- <el-button type="danger" size="small" style="padding: 10px 20px !important;" @click="resetSearch" v-if="show_clear_search_btn">清除条件</el-button>
- </div>
- </el-form>
- <el-table v-loading="listLoading" :data="list" stripe style="width: 100%">
- <el-table-column label="ID" min-width="80" align="center">
- <template slot-scope="scope">
- <p>{{scope.row.id}}</p>
- </template>
- </el-table-column>
- <el-table-column label="活动名称" min-width="80" align="center">
- <template slot-scope="scope">
- <p>{{scope.row.title}}</p>
- </template>
- </el-table-column>
- <el-table-column label="积分类型" min-width="80" align="center">
- <template slot-scope="scope">
- <p>{{integral_type[scope.row.integral_type]}}</p>
- </template>
- </el-table-column>
- <el-table-column label="状态" min-width="80" align="center">
- <template slot-scope="scope">
- <div v-if="scope.row.status == 0">失效</div>
- <div v-else>
- <p v-if="scope.row.start_time < new_time && scope.row.end_time > new_time">进行中</p>
- <p v-if="scope.row.end_time < new_time">已经结束</p>
- <p v-if="scope.row.start_time > new_time">未开始</p>
- </div>
- </template>
- </el-table-column>
- <el-table-column prop="scope" width="160" label="创建时间">
- <template slot-scope="scope">
- {{scope.row.created_at|dateTimeFormat('Y-m-d H:i:s')}}
- </template>
- </el-table-column>
- <el-table-column
- label="操作"
- min-width="180"
- align="center">
- <template slot-scope="scope">
- <el-button circle size="mini" type="text" @click="statistics(scope.row)">
- 数据
- </el-button>
- <el-button circle size="mini" type="text" @click="handle('edit',scope.row)">
- 编辑
- </el-button>
- <el-button circle size="mini" type="text" @click="handle('qrode',scope.row)">
- 推广
- </el-button>
- <el-button circle size="mini" type="text" @click="handle('copy',scope.row)">
- 复制
- </el-button>
- <el-button v-if="scope.row.status == 1" circle size="mini" type="text" @click="handle('unenable',scope.row)">
- 失效
- </el-button>
- <el-button v-if="scope.row.status == 0" circle size="mini" type="text" @click="handle('enable',scope.row)">
- 启用
- </el-button>
- <el-button circle size="mini" type="text" @click="handle('delete',scope.row)">
- 删除
- </el-button>
- </template>
- </el-table-column>
- </el-table>
- <div style="text-align: right;margin: 20px 0;">
- <el-pagination v-if="pagination" :page-size="pagination.pageSize"
- style="display: inline-block;float: right;" background @current-change="pageChange"
- layout="prev, pager, next" :total="pagination.total_count">
- </el-pagination>
- </div>
- </div>
- </el-card>
- <!-- “数据”弹窗 -->
- <!-- <el-dialog title="数据(数据更新于2021-02-12 12:11)" :visible.sync="dialogFormVisible"> -->
- <el-dialog title="数据统计" :visible.sync="dialogFormVisible">
- <div class="dialog-cont" :data="data_list">
- <el-row :gutter="20" style="padding: 10px 0">
- <el-col :span="6">
- <div class="cont-num center">{{data_list.grab_user_num}}</div>
- <div class="center">已抢积分人数</div>
- </el-col>
- <el-col :span="6">
- <div class="cont-num center">{{data_list.grab_integral}}</div>
- <div class="center">已抢积分</div>
- </el-col>
- <el-col :span="6">
- <div class="cont-num center">{{data_list.award}}</div>
- <div class="center">剩余未抢积分</div>
- </el-col>
- </el-row>
- </div>
- <div class="table-body el-input--small">
- <el-table v-loading="listLoading" :data="user_grab_list" stripe style="width: 100%">
- <el-table-column label="ID" min-width="80" align="center">
- <template slot-scope="scope">
- <p>{{scope.row.id}}</p>
- </template>
- </el-table-column>
- <el-table-column label="会员" width="180" class="user_data" >
- <template slot-scope="scope">
- <div class="user_img">
- <el-image class="default-avatar" :src="scope.row.user.avatar_url">
- <div slot="error" class="image-slot">
- <com-image src="/resources/img/common/default-avatar.png"></com-image>
- </div>
- </el-image>
- </div>
- <div>
- <div style="color:#000;">{{scope.row.user.nickname}}</div>
- <div style="font-size: 13px;">{{scope.row.user.mobile}}</div>
- </div>
- </template>
- </el-table-column>
- <el-table-column label="已抢红包" min-width="80" align="center">
- <template slot-scope="scope">
- <p>{{scope.row.grab_integral}}</p>
- </template>
- </el-table-column>
- <el-table-column label="已抢次数" min-width="80" align="center">
- <template slot-scope="scope">
- <p>{{scope.row.grab_num}}</p>
- </template>
- </el-table-column>
- <el-table-column prop="scope" width="160" label="最后抢红包时间">
- <template slot-scope="scope">
- {{scope.row.grab_time|dateTimeFormat('Y-m-d H:i:s')}}
- </template>
- </el-table-column>
- </el-table>
- <div style="text-align: right;margin: 20px 20px;">
- <el-pagination v-if="grab_pagination" :page-size="grab_pagination.pageSize"
- style="display: inline-block;float: right;" background @current-change="grabPageChange"
- layout="prev, pager, next" :total="grab_pagination.total_count">
- </el-pagination>
- </div>
- </div>
- <div style="width: 100%; height: 20px; clear: both;"></div>
- </el-dialog>
- <el-dialog title="推广链接" :visible.sync="qrodestatus" >
- <div class="dialog-cont">
- <div style="margin-left: 67px;">
- <div class="pay-msg">
- <el-input v-model.number="redpack_url" style="width: 50%" disabled type="text" placeholder="红包链接"></el-input>
- <el-button class="button-item" v-on:click="copyText">复制链接</el-button>
- </div>
- <div id="qrcode-info">
- <div id="qrcode">
- </div>
- </div>
- </div>
- </div>
- </el-dialog>
- </div>
- <script>
- const app = new Vue({
- el: '#app',
- data() {
- return {
- qrodestatus:false,
- listLoading: false,
- page: 1,
- pageCount: 0,
- //基础数据
- editBasisData: {
- materialTypeList: [],
- },
- //本地存时间,请求时不发送
- time: [],
- search: {
- id: '',
- title: '',
- date_start: null,
- date_end: null,
- },
- list: [],
- user_grab_list:[],
- integral_type:[],
- new_time:[],
- //弹框配置
- addForm: {
- id: '',
- name: '',
- },
- title: "",
- dialogFormVisible: false, //数据弹窗
- data_list: {},//数据
- goods_data:[],//详细数据
- dialogAddgsVisible: false,
- redpack_links:'',//前端红包链接
- redpack_url:'',//前端红包链接
- // 对话框显示与否
- dialogVisible: false,
- dataloading: false,
- pagination:null,
- grab_list:'', //红包记录
- grab_pagination:null,
- grab_page: 1,
- grab_pageCount: 0,
- };
- },
- computed: {
- show_clear_search_btn: function() {
- return !isEmpty(this.search.id)
- || !isEmpty(this.search.title)
- || !isEmpty(this.time)
- }
- },
- methods: {
- resetSearch(){
- this.search = {
- id: '',
- title: '',
- mobile: '',
- }
- this.time = '';
- },
- searchs() {
- this.page = 1;
- this.getList();
- },
- copyText(){
- if (!this.redpack_url) {
- alert('请输入要复制的内容')
- } else {
- var url = this.redpack_url;
- // createElement() 方法通过指定名称创建一个元素
- var copyInput = document.createElement('input')
- copyInput.setAttribute('value', url)
- document.body.appendChild(copyInput)
- copyInput.select()
- try {
- var copyed = document.execCommand('copy')
- if (copyed) {
- document.body.removeChild(copyInput)
- this.$message.success('复制成功')
- }
- } catch {
- this.$message.success('复制失败,请检查浏览器兼容')
- }
- }
- },
- statistics(data){
- this.dialogFormVisible = true;
- this.data_list = data;
- let self = this;
- self.listLoading = true;
- request({
- params: {
- r: 'score-expansion/user-grab/index',
- },
- method: 'post',
- data: {id:data.id,page:this.grab_page},
- }).then(e => {
- self.listLoading = false;
- this.user_grab_list = e.data.data.list;
- this.grab_pagination = e.data.data.pagination;
- this.grab_pagination.pageSize = e.data.data.page_size;
- this.grab_pagination.total_count = e.data.data.count;
- }).catch(e => {
- console.log(e);
- });
- console.log(this.data_list,5555);
- },
- grabPageChange(currentPage) {
- let self = this;
- self.grab_page = currentPage;
- self.statistics();
- },
- createQrcode(url){
- // 获取二维码生成的图片信息
- return new Promise((req, rej) => {
- setTimeout(() => {
- let qrcodeInfo = document.getElementById("qrcode-info");
- document.getElementById("qrcode").remove(); //删除生成的二维码
- let addCodeDom = document.createElement("div");
- addCodeDom.setAttribute("id", "qrcode");
- addCodeDom.setAttribute("style", "width:200px; height:200px;");
- qrcodeInfo.appendChild(addCodeDom) //添加标签
- let qrCodeDom = document.getElementById("qrcode");
- var qrcode = new QRCode(qrCodeDom, {
- width: 200,
- height: 200,
- });
- qrcode.makeCode(url);
- src = qrCodeDom.getElementsByTagName("img")[0].src;
- req(src);
- }, 200);
- })
- },
- pageChange(currentPage) {
- let self = this;
- self.page = currentPage;
- self.getList();
- },
- getList() {
- let self = this;
- self.listLoading = true;
- // 检查是否选择了搜索时间
- if (!self.time) {
- self.search.date_start = '';
- self.search.date_end = '';
- } else {
- self.search.date_start = self.time[0];
- self.search.date_end = self.time[1];
- }
- request({
- method: 'post',
- params: {
- r: 'score-expansion/default/index',
- },
- data: {
- page: self.page,
- id: self.search.id,
- date_start: self.search.date_start,
- date_end: self.search.date_end,
- title: self.search.title,
- },
- }).then(e => {
- self.listLoading = false;
- self.list = e.data.data.list;
- this.pagination = e.data.data.pagination;
- this.pagination.pageSize = e.data.data.page_size;
- this.pagination.total_count = e.data.data.count;
- this.integral_type = e.data.data.integral_type;
- this.new_time = e.data.data.new_time;
- this.redpack_links = e.data.data.redpacklinks;
- console.log(this.pagination);
- }).catch(e => {
- console.log(e);
- });
- },
- detail(data) {
- console.log(data);
- this.data_list = [];
- this.goods_data = [];
- this.dialogFormVisible = true;
- this.data_list = data;
- this.goods_data.push(data);
- },
- handle(type,data = null){
- switch (type) {
- case 'edit':// 编辑
- navigateTo({
- r: 'score-expansion/default/edit',
- id:data.id,
- });
- break;
- case 'copy':// 复制
- navigateTo({
- r: 'score-expansion/default/edit',
- id:data.id,
- type:1,
- });
- break;
- case 'qrode'://推广二维码
- this.qrodestatus = true;
- this.redpack_url = this.redpack_links + '&id=' + data.id;
- this.createQrcode(this.redpack_url);
- break;
- case 'delete':// 删除
- data.type = -1;
- this.$confirm('\n' +
- '删除该条数据后不可以恢复, 是否继续?', '警告', {type: 'warning'}).then(() => {this.delect(data);})
- break;
- case 'unenable':// 删除
- data.type = 0;
- this.$confirm('该活动将会失效, 是否继续?', '警告', {type: 'warning'}).then(() => {this.delect(data);})
- break;
- case 'enable':
- data.type = 1;
- this.delect(data);
- break;
- }
- },
- add(){
- navigateTo({
- r: 'score-expansion/default/edit',
- });
- },
- delect(data){
- let self = this;
- self.listLoading = true;
- request({
- params: {
- r: 'score-expansion/default/del-or-enable',
- },
- method: 'post',
- data: {id:data.id,type:data.type},
- }).then(e => {
- self.listLoading = false;
- if (e.data.code === 0) {
- self.$message.success(e.data.msg);
- } else {
- self.$message.error(e.data.msg);
- }
- self.getList();
- }).catch(e => {
- console.log(e);
- });
- },
- send(data){
- let self = this;
- self.listLoading = true;
- request({
- params: {
- r: 'score-expansion/default/edit',
- },
- method: 'post',
- data:data,
- }).then(e => {
- self.listLoading = false;
- if (e.data.code === 0) {
- self.$message.success(e.data.msg);
- } else {
- self.$message.error(e.data.msg);
- }
- self.getList();
- }).catch(e => {
- console.log(e);
- });
- },
- /**
- *关闭或取消模态框,清空值
- * @param
- */
- closeDialogAddgsVisible() {
- this.$refs.addForm.resetFields();//element封装的方法,清空模态框的值
- this.title = "" //初始化title的值
- this.addForm = {//初始化addForm中的值
- title: "",
- }
- },
- },
- mounted: function () {
- this.getList();
- }
- });
- </script>
|