vue 下列表侧滑操作实例代码详解
作者:wzzehui 发布时间:2024-04-30 10:19:36
标签:vue,列表,侧滑
由于是上线的项目且已经按照数据逻辑去渲染了能看懂的看逻辑吧。有点多
效果如图
<template>
<div class="lottery-management-wrapper">
<ul>
<li class="lottery-management-list-wrapper">
<div class="lottery-management-list" v-for="(item , index) in activityListData">
<div class="lottery-management-list-left" @click="detailOfTheActivity(item)">
<dl>
<dd>
<h3>{{item.activityName}}</h3>
<p>活动时间:{{item.beginTime}}至{{item.endTime}}</p>
</dd>
<dt :class="item.status == 3 ? 'txt-red': item.status == 0 ? 'txt-blue' : ''">{{item.status == 3 ? '进行中': item.status == 1 ? '已结束': item.status == 0 ? '待启用' : ''}}</dt>
</dl>
</div>
<div class="lottery-management-list-right">
<a @click="startActivityAlert = true;currentItem = item;currentIndex = index" v-if="item.status == 0">启用活动</a>
<span @click="delActivityAlert = true;currentItem = item;currentIndex = index" v-if="item.status == 1">删除活动</span>
<span @click="stopActivityAlert = true;currentItem = item;currentIndex = index" v-if="item.status == 3 || item.status == 0">结束活动</span>
</div>
</div>
</li>
</ul>
<div class="add-wrapper" @click="addAwardActivity">
<span class="iconfont icon-tianjia1"></span>
<span class="text">新增活动</span>
</div>
<h4>商户员工账号只有活动查看权限,没有活动操作权限</h4>
<transition name="fade">
<div class="mask-wrapper"
v-show="delActivityAlert"
@touchmove.prevent>
<tipsBox title="操作提示"
text1="是否删除当前活动"
button1="取消"
button2="确定"
@confirm="delActivity"
@cancel="delActivityAlert = false">
</tipsBox>
</div>
</transition>
<transition name="fade2">
<div class="mask-wrapper"
v-show="stopActivityAlert"
@touchmove.prevent>
<tipsBox title="操作提示"
text1="是否停止当前活动"
button1="取消"
button2="确定"
@confirm="stopActivity"
@cancel="stopActivityAlert = false">
</tipsBox>
</div>
</transition>
<transition name="fade3">
<div class="mask-wrapper"
v-show="startActivityAlert"
@touchmove.prevent>
<tipsBox title="操作提示"
text1="是否启用当前活动"
button1="取消"
button2="确定"
@confirm="startActivity"
@cancel="startActivityAlert = false">
</tipsBox>
</div>
</transition>
</div>
</template>
<script>
import TipsBox from 'components/tipsBox/TipsBox';
import {configs} from 'common/js/config.js';
import {baseAjaxParam, baseAjaxErr} from 'common/js/publicFn.js';
const activityListApi = configs.baseApi + '/marketing/rouletter/activityList';
const overActivityApi = configs.baseApi + '/marketing/rouletter/overActivity';
const delActivityApi = configs.baseApi + '/marketing/rouletter/delActivity';
const startActivityApi = configs.baseApi + '/marketing/rouletter/startActivity';
export default {
data () {
return {
delActivityAlert: false,
stopActivityAlert: false,
startActivityAlert: false,
activityListData: [],
currentItem: null,
currentIndex: null
};
},
methods: {
getActivityList () {
let data = baseAjaxParam(this);
this.$http.jsonp(activityListApi, {params: data}).then((res) => {
if (res.body.code === 0) {
this.activityListData = res.body.data;
this.setSlide();
} else {
baseAjaxErr(this, res);
}
}).catch(function (err) {
alert('服务器错误:' + err.status);
console.log(err);
});
},
setSlide () {
this.$nextTick(() => {
let list = document.getElementsByClassName('lottery-management-list');
if (list) {
if (this.currentIndex !== null) {
list[this.currentIndex].firstElementChild.style.marginLeft = '0';
}
for (let i = 0; i < list.length; i++) {
(() => {
let start = 0;
list[i].ontouchstart = function (e) {
start = e.touches[0].pageX;
};
list[i].ontouchmove = function () {
list[i].ontouchend = function (e) {
let end = e.changedTouches[0].pageX;
let rightWidth = list[i].lastElementChild.offsetWidth;
if (end < start) {
list[i].firstElementChild.style.marginLeft = -rightWidth + 'px';
}
if (end > start) {
list[i].firstElementChild.style.marginLeft = '0';
}
};
};
})(i);
}
}
});
},
// 查看详情
detailOfTheActivity (item) {
this.$router.push('/detailOfTheActivity?activityId=' + item.activityId);
},
// 删除活动
delActivity () {
if (this.$store.state.roleId !== '0' && this.$store.state.roleId !== 'ROL197001010800007e4b5ce2fe28308' && this.$store.state.roleId !== 'ROL197001010800004ca4238a0b92382') {
if (!this.$store.state.authList['AUT20180705181442eQbFSPyr7HTOKji']) {
this.$store.commit('popSet', {tips: '无权限操作', status: 1, time: 1500});
return;
}
}
this.delActivityAlert = false;
let data = baseAjaxParam(this);
data.activityId = this.currentItem.activityId;
this.$http.jsonp(delActivityApi, {params: data}).then((res) => {
if (res.body.code === 0) {
this.$store.commit('popSet', {tips: '删除动成功', status: 0, time: 1500});
this.getActivityList();
} else {
baseAjaxErr(this, res);
}
}).catch(function (err) {
alert('服务器错误:' + err.status);
console.log(err);
});
},
// 停止活动
stopActivity () {
if (this.$store.state.roleId !== '0' && this.$store.state.roleId !== 'ROL197001010800007e4b5ce2fe28308' && this.$store.state.roleId !== 'ROL197001010800004ca4238a0b92382') {
if (!this.$store.state.authList['AUT20180705181442eQbFSPyr7HTOKji']) {
this.$store.commit('popSet', {tips: '无权限操作', status: 1, time: 1500});
return;
}
}
this.stopActivityAlert = false;
let data = baseAjaxParam(this);
data.activityId = this.currentItem.activityId;
this.$http.jsonp(overActivityApi, {params: data}).then((res) => {
if (res.body.code === 0) {
this.$store.commit('popSet', {tips: '结束活动成功', status: 0, time: 1500});
this.getActivityList();
} else {
baseAjaxErr(this, res);
}
}).catch(function (err) {
alert('服务器错误:' + err.status);
console.log(err);
});
},
// 启用活动
startActivity () {
if (this.$store.state.roleId !== '0' && this.$store.state.roleId !== 'ROL197001010800007e4b5ce2fe28308' && this.$store.state.roleId !== 'ROL197001010800004ca4238a0b92382') {
if (!this.$store.state.authList['AUT20180705181442eQbFSPyr7HTOKji']) {
this.$store.commit('popSet', {tips: '无权限操作', status: 1, time: 1500});
return;
}
}
this.startActivityAlert = false;
let data = baseAjaxParam(this);
data.activityId = this.currentItem.activityId;
this.$http.jsonp(startActivityApi, {params: data}).then((res) => {
if (res.body.code === 0) {
this.$store.commit('popSet', {tips: '启用活动成功', status: 0, time: 1500});
this.getActivityList();
} else {
baseAjaxErr(this, res);
}
}).catch(function (err) {
alert('服务器错误:' + err.status);
console.log(err);
});
},
addAwardActivity () {
if (this.$store.state.roleId !== '0' && this.$store.state.roleId !== 'ROL197001010800007e4b5ce2fe28308' && this.$store.state.roleId !== 'ROL197001010800004ca4238a0b92382') {
if (!this.$store.state.authList['AUT20180705181442eQbFSPyr7HTOKji']) {
this.$store.commit('popSet', {tips: '无权限操作', status: 1, time: 1500});
return;
}
}
this.$router.push('addAwardActivity');
}
},
created () {
this.getActivityList();
},
components: {
TipsBox
}
};
</script>
<style lang="stylus" rel="stylesheet/stylus">
@import '../../../common/stylus/mixin'
.lottery-management-wrapper {
width :100%;
position :absolute;
background-color :#ECF0F3;
min-height :100%;
.lottery-management-list-wrapper {
width :100%;
overflow hidden;
.lottery-management-list {
background-color :#fff;
margin-bottom cal(10);
overflow :hidden;
width :200%;
.lottery-management-list-left {
width :cal(750);
float :left;
transition: margin-left .4s;
dl {
overflow :hidden;
height :cal(128);
dd {
float left;
width :80%;
h3 {
font-size :cal(28);
color: #4A4A4A;
margin:cal(32) 0 0 cal(50);
}
p {
font-size : cal(18)
color:#4A4A4A;
margin:cal(16) 0 0 cal(50);
}
}
dt {
float :left;
width :20%;
color: #9B9B9B;
font-size :cal(26);
line-height :cal(128);
}
.txt-red {
color:#D0021B;
}
.txt-blue {
color:#4A90E2;
}
}
}
.lottery-management-list-right {
float :left;
overflow: hidden;
font-size :cal(24);
line-height :cal(128);
color :#ffffff;
text-align :center;
a {
float: left;
background-color :#70AEF6;
width :cal(190);
color :#ffffff;
}
span {
float: left;
width :cal(128);
background-color :#FE3A32;
}
}
}
}
.add-wrapper {
height: cal(100)
box-sizing: border-box
padding-top: cal(24)
margin-bottom: cal(72)
background: #fff
text-align: center
font-size: 0
margin-top :cal(20)
.icon-tianjia1 {
color: #fe6f3f
font-size: cal(54)
vertical-align: top
margin-right: cal(12)
}
.text {
line-height: cal(60)
vertical-align: top
color: #fe6f3f
font-size: cal(30)
}
}
h4 {
color: #D0021B;
font-size :cal(24);
text-align: center;
margin-bottom :cal(100);
}
.mask-wrapper {
position: fixed
left: 0
right: 0
bottom: 0
top: 0
background: rgba(0,0,0,.5)
&.fade-enter-active, &.fade-leave-active {
transition: all 0.2s linear
}
&.fade-enter,&.fade-leave-active{
opacity: 0
}
&.fade2-enter-active, &.fade2-leave-active {
transition: all 0.2s linear
}
&.fade2-enter,&.fade2-leave-active{
opacity: 0
}
&.fade3-enter-active, &.fade3-leave-active {
transition: all 0.2s linear
}
&.fade3-enter,&.fade3-leave-active{
opacity: 0
}
}
}
</style>
总结
以上所述是小编给大家介绍的vue 下列表侧滑操作实例代码详解网站的支持!
来源:https://blog.csdn.net/wzzehui/article/details/81171071


猜你喜欢
- python提取照片坐标信息的代码如下所示:from PIL import Imagefrom PIL.ExifTags import TA
- sqoop是一款用于hadoop和关系型数据库之间数据导入导出的工具。你可以通过sqoop把数据从数据库(比如mysql,oracle)导入
- 下表列出了所有Python语言支持的比较操作符。假设变量a持有10和变量b持有20,则: 例如:试试下面的例子就明白了所有的Pyt
- 1. 背景在使用selenium浏览器渲染技术,爬取网站信息时,一般来说,速度是很慢的。而且一般需要用到这种技术爬取的网站,反爬技术都比较厉
- 在python中可以使用json将数据格式化为JSON格式:1.将字典转换成JSON数据格式:s=['张三','年龄
- 本文实例讲述了Python实现链表反转的方法。分享给大家供大家参考,具体如下:Python实现链表反转链表反转(while迭代实现):链表的
- 需求:用的是django的框架,想显示一个基本固定的页面,用到了form_layout上图的ROW中添加的是model中的字段名,可以显示对
- 一、语言结构和注意事项package main // 声明 main 包,表明当前是一个可执行程序import "fm
- 机房一台服务器上的mysql运行一段时间了,突然出现了一个很奇怪的现象:重启后无法恢复了!准确情况是:启动mysql后随即就又关闭了。查看m
- 前言electron-vue脚手架搭建的项目,在开发阶段可能你注意不到项目启动慢的问题,但是在build 生成的exe可执行文件,启动后,要
- 这篇文章主要介绍了opencv python图像梯度实例详解,文中通过示例代码介绍的非常详细,对大家的学习或者工作具有一定的参考学习价值,需
- ECMAScript 5.1规范§15.4.4.4 中说到:concat函数是有意设计成通用的;它并不要求它的this值必须得是个Array
- MySQL中concat函数使用方法:CONCAT(str1,str2,…) 返回结果为连接参数产生的字符串。如有任何一个参数为N
- CentOS7默认数据库是mariadb, 但是 好多用的都是mysql ,但是CentOS7的yum源中默认好像是没有mysql的。上一篇
- 表数据导出到一个文本文件最简单的方法是使用SELECT... INTO OUTFILE语句的查询结果直接导出到一个文件在服务器主机上。导出数
- 从windows操作系统本地读取csv文件报错data = pd.read_csv(path)Traceback (most recent
- 一、安装mongo plugs插件File->SettingPlugins查询Mongo选择Search in repositorie
- 内容有些啰嗦,内容记载了当时遇到了bug以及解决问题的思路。业务场景简述:前端做配置化组件,通过url内的唯一标识,请求后端sql 哪取页面
- 训练好了model后,可以通过python调用caffe的模型,然后进行模型测试的输出。本次测试主要依靠的模型是在caffe模型里面自带训练
- PHP convert_cyr_string() 函数实例把字符串由一种字符集转换成另一种:<?php $str = "He