Commit d27d9e52 authored by JingChao's avatar JingChao

option-item

parent f42f3afc
<template> <template>
<div :class="type" class="function">{{ text }}</div> <div :class="type" class="function" @touchstart.capture="touchStart">{{ text }}</div>
</template> </template>
<script> <script>
...@@ -22,8 +22,8 @@ export default { ...@@ -22,8 +22,8 @@ export default {
this.$parent && this.$parent.optionItem.splice(this.$parent.optionItem.indexOf(this), 1) this.$parent && this.$parent.optionItem.splice(this.$parent.optionItem.indexOf(this), 1)
}, },
methods: { methods: {
buttonClick (e) { touchStart (ev) {
this.$emit('press', this.type) this.$parent.reset()
}, },
}, },
} }
......
<template> <template>
<div :class="cusClass" class="swipeout-list"> <div :class="cusClass" class="swipeout-list">
<div ref="item" :class="bottomBorder" class="item" data-type="0"> <div ref="item" :class="bottomBorder" class="option-item" data-type="0">
<div <div
class="list-box" class="list-box"
@touchstart.capture="touchStart" @touchstart.capture="touchStart"
...@@ -57,9 +57,9 @@ export default { ...@@ -57,9 +57,9 @@ export default {
mounted () { mounted () {
this.init() this.init()
}, },
updated () { /* updated () {
this.init() this.init()
}, }, */
methods: { methods: {
touchStart (ev) { touchStart (ev) {
this.$refs.item.style.transform = 'translate3d(0px,0px,0px)' this.$refs.item.style.transform = 'translate3d(0px,0px,0px)'
...@@ -86,16 +86,6 @@ export default { ...@@ -86,16 +86,6 @@ export default {
this.startX = 0 this.startX = 0
this.endX = 0 this.endX = 0
}, },
// 判断当前是否有滑块处于滑动状态
checkSlide () {
let listItems = this.$refs.item
for (let i = 0; i < listItems.length; i++) {
if (listItems[i].dataset.type === '1') {
return true
}
}
return false
},
// 初始化 // 初始化
init () { init () {
let vm = this let vm = this
...@@ -106,10 +96,10 @@ export default { ...@@ -106,10 +96,10 @@ export default {
}) })
}, },
reset () { reset () {
let l = document.getElementsByClassName('item').length let l = document.getElementsByClassName('option-item').length
for (let i = 0; i < l; i++) { for (let i = 0; i < l; i++) {
document.getElementsByClassName('item')[i].style.transform = 'translate3d(0px,0px,0px)' document.getElementsByClassName('option-item')[i].style.transform = 'translate3d(0px,0px,0px)'
document.getElementsByClassName('item')[i].dataset.type = '0' document.getElementsByClassName('option-item')[i].dataset.type = '0'
} }
}, },
}, },
...@@ -124,14 +114,14 @@ export default { ...@@ -124,14 +114,14 @@ export default {
overflow: visible; overflow: visible;
padding: 0 0 0 15px; padding: 0 0 0 15px;
width: 100%; width: 100%;
.item[data-type="0"] { .option-item[data-type="0"] {
transform: translate3d(0px, 0px, 0px); transform: translate3d(0px, 0px, 0px);
transition: all 0.4s; transition: all 0.4s;
} }
.item[data-type="1"] { .option-item[data-type="1"] {
transition: all 1s; transition: all 1s;
} }
.item { .option-item {
overflow: visible; overflow: visible;
position: relative; position: relative;
height: 100%; height: 100%;
......
...@@ -171,14 +171,15 @@ ...@@ -171,14 +171,15 @@
<div class="list"> <div class="list">
<item-option <item-option
v-for="(color,index) in colors" :key="index" v-for="(color,index) in colors"
ref="itemOption" :key="index"
class="mySlider"> class="mySlider">
<div>{{ color.name }}</div> <div>{{ color.name }}</div>
<div>{{ color.hex }}</div> <div>{{ color.hex }}</div>
<div slot="buttons"> <div slot="buttons">
<option-button type="default" text="默认" @click.native="deleteFun"/> <option-button type="default" text="默认" @click.native="deleteFun(index)"/>
<option-button type="primary" text="编辑" @click.native="deleteFun"/> <option-button type="primary" text="编辑" @click.native="deleteFun(index)"/>
<option-button type="warn" text="删除" @click.native="deleteFun"/> <option-button type="warn" text="删除" @click.native="deleteFun(index)"/>
</div> </div>
</item-option> </item-option>
</div> </div>
...@@ -418,9 +419,10 @@ export default { ...@@ -418,9 +419,10 @@ export default {
}, },
}) })
}, },
showTime (format) { showTime (format) {
this.hlsPopup.showTime({ this.hlsPopup.showTime({
nowDate: '2017-08-12', nowDate: (new Date()).format('yyyy-MM-dd'),
format: format, format: format,
callback: (date) => { callback: (date) => {
alert(date) alert(date)
...@@ -429,7 +431,7 @@ export default { ...@@ -429,7 +431,7 @@ export default {
}, },
showBigPicture () { showBigPicture () {
this.hlsPopup.showBigPicture({ this.hlsPopup.showBigPicture({
imgUrl: 'http://hlsapp.hand-china.com/file/20190411/1554983248278.png', imgUrl: 'http://hlsapp.hand-china.com/hls_file/2018/05/F1B6D85E409A4714A8540504B2D133AD',
}) })
}, },
...@@ -591,7 +593,11 @@ export default { ...@@ -591,7 +593,11 @@ export default {
}, },
// e为该元素在数组的下标 // e为该元素在数组的下标
deleteFun (e) { deleteFun (e) {
console.log(e) let vm = this
vm.colors.remove(e)
vm.colors.sort()
debugger
vm.$refs.itemOption[0].reset()
}, },
// e为该元素在数组的下标 // e为该元素在数组的下标
editFun (e) { editFun (e) {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment