vue 下列表側(cè)滑操作實(shí)例代碼詳解
由于是上線的項(xiàng)目且已經(jīng)按照數(shù)據(jù)邏輯去渲染了能看懂的看邏輯吧。有點(diǎn)多
效果如圖
<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>活動(dòng)時(shí)間:{{item.beginTime}}至{{item.endTime}}</p> </dd> <dt :class="item.status == 3 ? 'txt-red': item.status == 0 ? 'txt-blue' : ''">{{item.status == 3 ? '進(jìn)行中': item.status == 1 ? '已結(jié)束': 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">啟用活動(dòng)</a> <span @click="delActivityAlert = true;currentItem = item;currentIndex = index" v-if="item.status == 1">刪除活動(dòng)</span> <span @click="stopActivityAlert = true;currentItem = item;currentIndex = index" v-if="item.status == 3 || item.status == 0">結(jié)束活動(dòng)</span> </div> </div> </li> </ul> <div class="add-wrapper" @click="addAwardActivity"> <span class="iconfont icon-tianjia1"></span> <span class="text">新增活動(dòng)</span> </div> <h4>商戶員工賬號(hào)只有活動(dòng)查看權(quán)限,沒(méi)有活動(dòng)操作權(quán)限</h4> <transition name="fade"> <div class="mask-wrapper" v-show="delActivityAlert" @touchmove.prevent> <tipsBox title="操作提示" text1="是否刪除當(dāng)前活動(dòng)" 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="是否停止當(dāng)前活動(dòng)" 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="是否啟用當(dāng)前活動(dòng)" 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('服務(wù)器錯(cuò)誤:' + 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); }, // 刪除活動(dòng) 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: '無(wú)權(quán)限操作', 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: '刪除動(dòng)成功', status: 0, time: 1500}); this.getActivityList(); } else { baseAjaxErr(this, res); } }).catch(function (err) { alert('服務(wù)器錯(cuò)誤:' + err.status); console.log(err); }); }, // 停止活動(dòng) 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: '無(wú)權(quán)限操作', 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: '結(jié)束活動(dòng)成功', status: 0, time: 1500}); this.getActivityList(); } else { baseAjaxErr(this, res); } }).catch(function (err) { alert('服務(wù)器錯(cuò)誤:' + err.status); console.log(err); }); }, // 啟用活動(dòng) 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: '無(wú)權(quán)限操作', 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: '啟用活動(dòng)成功', status: 0, time: 1500}); this.getActivityList(); } else { baseAjaxErr(this, res); } }).catch(function (err) { alert('服務(wù)器錯(cuò)誤:' + 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: '無(wú)權(quán)限操作', 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>
總結(jié)
以上所述是小編給大家介紹的vue 下列表側(cè)滑操作實(shí)例代碼詳解,希望對(duì)大家有所幫助,如果大家有任何疑問(wèn)請(qǐng)給我留言,小編會(huì)及時(shí)回復(fù)大家的。在此也非常感謝大家對(duì)腳本之家網(wǎng)站的支持!
- vue2中引用及使用 better-scroll的方法詳解
- 詳解 vue better-scroll滾動(dòng)插件排坑
- vue2.0 better-scroll 實(shí)現(xiàn)移動(dòng)端滑動(dòng)的示例代碼
- vue使用 better-scroll的參數(shù)和方法詳解
- vue利用better-scroll實(shí)現(xiàn)輪播圖與頁(yè)面滾動(dòng)詳解
- vue滾動(dòng)軸插件better-scroll使用詳解
- vue+swiper實(shí)現(xiàn)側(cè)滑菜單效果
- Vue側(cè)滑菜單組件——DrawerLayout
- vue中使用better-scroll實(shí)現(xiàn)滑動(dòng)效果及注意事項(xiàng)
相關(guān)文章
vue3頁(yè)面query參數(shù)變化并重新加載頁(yè)面數(shù)據(jù)方式
在Web開(kāi)發(fā)中,頁(yè)面間的跳轉(zhuǎn)及數(shù)據(jù)刷新是常見(jiàn)問(wèn)題,通過(guò)使用$router.push和$router.replace方法,可以控制頁(yè)面跳轉(zhuǎn)的行為,具體操作時(shí),若發(fā)現(xiàn)頁(yè)面ID變更后數(shù)據(jù)未刷新,可通過(guò)給router-view標(biāo)簽添加key值解決,若使用keep-alive2024-10-10vue中Echarts圖表寬度沒(méi)占滿的問(wèn)題
這篇文章主要介紹了vue中Echarts圖表寬度沒(méi)占滿的問(wèn)題,具有很好的參考價(jià)值,希望對(duì)大家有所幫助。如有錯(cuò)誤或未考慮完全的地方,望不吝賜教2022-10-10vue.js通過(guò)路由實(shí)現(xiàn)經(jīng)典的三欄布局實(shí)例代碼
本文通過(guò)實(shí)例代碼給大家介紹了vue.js通過(guò)路由實(shí)現(xiàn)經(jīng)典的三欄布局,代碼簡(jiǎn)單易懂,非常不錯(cuò),具有一定的參考借鑒價(jià)值,需要的朋友參考下吧2018-07-07案例實(shí)操vue事件修飾符帶你快速了解與應(yīng)用
這篇文章主要介紹了vue常見(jiàn)的事件修飾符,在平時(shí)無(wú)論是面試還是學(xué)習(xí)工作中都會(huì)經(jīng)常遇到的,本文就帶你快速上手,需要的朋友可以參考下2023-03-03Vue3子組件實(shí)現(xiàn)v-model用法的示例代碼
在Vue 3中,實(shí)現(xiàn)自定義的input組件并支持v-model綁定,涉及到對(duì)modelValue這個(gè)默認(rèn)prop的處理和對(duì)應(yīng)的update:modelValue事件的觸發(fā),本文給大家介紹了Vue3子組件實(shí)現(xiàn)v-model用法的示例,需要的朋友可以參考下2024-04-04詳解搭建一個(gè)vue-cli的移動(dòng)端H5開(kāi)發(fā)模板
這篇文章主要介紹了詳解搭建一個(gè)vue-cli的移動(dòng)端H5開(kāi)發(fā)模板,文中通過(guò)示例代碼介紹的非常詳細(xì),對(duì)大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價(jià)值,需要的朋友們下面隨著小編來(lái)一起學(xué)習(xí)學(xué)習(xí)吧2020-01-01vue實(shí)現(xiàn)中部導(dǎo)航欄布局功能
這篇文章主要介紹了vue實(shí)現(xiàn)中部導(dǎo)航欄布局功能,本文圖文并茂,代碼實(shí)例相結(jié)合介紹的非常詳細(xì),需要的朋友參考下吧2019-07-07