From 3bc055f2ee9e813db0f08c5aefc4799be943f77f Mon Sep 17 00:00:00 2001 From: skyouc Date: 星期一, 23 十二月 2024 19:38:57 +0800 Subject: [PATCH] 添加选择机构功能 --- uni_modules/uni-swipe-action/components/uni-swipe-action-item/mpalipay.js | 386 +++++++++++++++++++++++++++--------------------------- 1 files changed, 193 insertions(+), 193 deletions(-) diff --git a/uni_modules/uni-swipe-action/components/uni-swipe-action-item/mpalipay.js b/uni_modules/uni-swipe-action/components/uni-swipe-action-item/mpalipay.js index 1a68ef8..68369ad 100644 --- a/uni_modules/uni-swipe-action/components/uni-swipe-action-item/mpalipay.js +++ b/uni_modules/uni-swipe-action/components/uni-swipe-action-item/mpalipay.js @@ -1,193 +1,193 @@ -export default { - data() { - return { - x: 0, - transition: false, - width: 0, - viewWidth: 0, - swipeShow: 0 - } - }, - watch: { - show(newVal) { - if (this.autoClose) return - if (newVal && newVal !== 'none' ) { - this.transition = true - this.open(newVal) - } else { - this.close() - } - } - }, - created() { - this.swipeaction = this.getSwipeAction() - if (this.swipeaction.children !== undefined) { - this.swipeaction.children.push(this) - } - }, - mounted() { - this.isopen = false - setTimeout(() => { - this.getQuerySelect() - }, 50) - }, - methods: { - appTouchStart(e) { - const { - clientX - } = e.changedTouches[0] - this.clientX = clientX - this.timestamp = new Date().getTime() - }, - appTouchEnd(e, index, item, position) { - const { - clientX - } = e.changedTouches[0] - // fixed by xxxx 妯℃嫙鐐瑰嚮浜嬩欢锛岃В鍐� ios 13 鐐瑰嚮鍖哄煙閿欎綅鐨勯棶棰� - let diff = Math.abs(this.clientX - clientX) - let time = (new Date().getTime()) - this.timestamp - if (diff < 40 && time < 300) { - this.$emit('click', { - content: item, - index, - position - }) - } - }, - /** - * 绉诲姩瑙﹀彂 - * @param {Object} e - */ - onChange(e) { - this.moveX = e.detail.x - this.isclose = false - }, - touchstart(e) { - this.transition = false - this.isclose = true - this.autoClose && this.swipeaction.closeOther(this) - }, - touchmove(e) {}, - touchend(e) { - // 0鐨勪綅缃粈涔堥兘涓嶆墽琛� - if (this.isclose && this.isopen === 'none') return - if (this.isclose && this.isopen !== 'none') { - this.transition = true - this.close() - } else { - this.move(this.moveX + this.leftWidth) - } - }, - - /** - * 绉诲姩 - * @param {Object} moveX - */ - move(moveX) { - // 鎵撳紑鍏抽棴鐨勫鐞嗛�昏緫涓嶅お涓�鏍� - this.transition = true - // 鏈墦寮�鐘舵�� - if (!this.isopen || this.isopen === 'none') { - if (moveX > this.threshold) { - this.open('left') - } else if (moveX < -this.threshold) { - this.open('right') - } else { - this.close() - } - } else { - if (moveX < 0 && moveX < this.rightWidth) { - const rightX = this.rightWidth + moveX - if (rightX < this.threshold) { - this.open('right') - } else { - this.close() - } - } else if (moveX > 0 && moveX < this.leftWidth) { - const leftX = this.leftWidth - moveX - if (leftX < this.threshold) { - this.open('left') - } else { - this.close() - } - } - - } - - }, - - /** - * 鎵撳紑 - */ - open(type) { - this.x = this.moveX - this.animation(type) - }, - - /** - * 鍏抽棴 - */ - close() { - this.x = this.moveX - // TODO 瑙e喅 x 鍊间笉鏇存柊鐨勯棶棰橈紝鎵�浠ヤ細澶氳Е鍙戜竴娆� nextTick 锛屽緟浼樺寲 - this.$nextTick(() => { - this.x = -this.leftWidth - if(this.isopen!=='none'){ - this.$emit('change', 'none') - } - this.isopen = 'none' - }) - }, - - /** - * 鎵ц缁撴潫鍔ㄧ敾 - * @param {Object} type - */ - animation(type) { - this.$nextTick(() => { - if (type === 'left') { - this.x = 0 - } else { - this.x = -this.rightWidth - this.leftWidth - } - - if(this.isopen!==type){ - this.$emit('change', type) - } - this.isopen = type - }) - - }, - getSlide(x) {}, - getQuerySelect() { - const query = uni.createSelectorQuery().in(this); - query.selectAll('.movable-view--hock').boundingClientRect(data => { - this.leftWidth = data[1].width - this.rightWidth = data[2].width - this.width = data[0].width - this.viewWidth = this.width + this.rightWidth + this.leftWidth - if (this.leftWidth === 0) { - // TODO 鐤戜技bug ,鍒濆鍖栫殑鏃跺�欏鏋渪 鏄�0锛屼細瀵艰嚧绉诲姩浣嶇疆閿欒锛屾墍浠ヨ鍏冪礌瓒呭嚭涓�鐐� - this.x = -0.1 - } else { - this.x = -this.leftWidth - } - this.moveX = this.x - this.$nextTick(() => { - this.swipeShow = 1 - }) - - if (!this.buttonWidth) { - this.disabledView = true - } - - if (this.autoClose) return - if (this.show !== 'none') { - this.transition = true - this.open(this.shows) - } - }).exec(); - - } - } -} +export default { + data() { + return { + x: 0, + transition: false, + width: 0, + viewWidth: 0, + swipeShow: 0 + } + }, + watch: { + show(newVal) { + if (this.autoClose) return + if (newVal && newVal !== 'none' ) { + this.transition = true + this.open(newVal) + } else { + this.close() + } + } + }, + created() { + this.swipeaction = this.getSwipeAction() + if (this.swipeaction.children !== undefined) { + this.swipeaction.children.push(this) + } + }, + mounted() { + this.isopen = false + setTimeout(() => { + this.getQuerySelect() + }, 50) + }, + methods: { + appTouchStart(e) { + const { + clientX + } = e.changedTouches[0] + this.clientX = clientX + this.timestamp = new Date().getTime() + }, + appTouchEnd(e, index, item, position) { + const { + clientX + } = e.changedTouches[0] + // fixed by xxxx 妯℃嫙鐐瑰嚮浜嬩欢锛岃В鍐� ios 13 鐐瑰嚮鍖哄煙閿欎綅鐨勯棶棰� + let diff = Math.abs(this.clientX - clientX) + let time = (new Date().getTime()) - this.timestamp + if (diff < 40 && time < 300) { + this.$emit('click', { + content: item, + index, + position + }) + } + }, + /** + * 绉诲姩瑙﹀彂 + * @param {Object} e + */ + onChange(e) { + this.moveX = e.detail.x + this.isclose = false + }, + touchstart(e) { + this.transition = false + this.isclose = true + this.autoClose && this.swipeaction.closeOther(this) + }, + touchmove(e) {}, + touchend(e) { + // 0鐨勪綅缃粈涔堥兘涓嶆墽琛� + if (this.isclose && this.isopen === 'none') return + if (this.isclose && this.isopen !== 'none') { + this.transition = true + this.close() + } else { + this.move(this.moveX + this.leftWidth) + } + }, + + /** + * 绉诲姩 + * @param {Object} moveX + */ + move(moveX) { + // 鎵撳紑鍏抽棴鐨勫鐞嗛�昏緫涓嶅お涓�鏍� + this.transition = true + // 鏈墦寮�鐘舵�� + if (!this.isopen || this.isopen === 'none') { + if (moveX > this.threshold) { + this.open('left') + } else if (moveX < -this.threshold) { + this.open('right') + } else { + this.close() + } + } else { + if (moveX < 0 && moveX < this.rightWidth) { + const rightX = this.rightWidth + moveX + if (rightX < this.threshold) { + this.open('right') + } else { + this.close() + } + } else if (moveX > 0 && moveX < this.leftWidth) { + const leftX = this.leftWidth - moveX + if (leftX < this.threshold) { + this.open('left') + } else { + this.close() + } + } + + } + + }, + + /** + * 鎵撳紑 + */ + open(type) { + this.x = this.moveX + this.animation(type) + }, + + /** + * 鍏抽棴 + */ + close() { + this.x = this.moveX + // TODO 瑙e喅 x 鍊间笉鏇存柊鐨勯棶棰橈紝鎵�浠ヤ細澶氳Е鍙戜竴娆� nextTick 锛屽緟浼樺寲 + this.$nextTick(() => { + this.x = -this.leftWidth + if(this.isopen!=='none'){ + this.$emit('change', 'none') + } + this.isopen = 'none' + }) + }, + + /** + * 鎵ц缁撴潫鍔ㄧ敾 + * @param {Object} type + */ + animation(type) { + this.$nextTick(() => { + if (type === 'left') { + this.x = 0 + } else { + this.x = -this.rightWidth - this.leftWidth + } + + if(this.isopen!==type){ + this.$emit('change', type) + } + this.isopen = type + }) + + }, + getSlide(x) {}, + getQuerySelect() { + const query = uni.createSelectorQuery().in(this); + query.selectAll('.movable-view--hock').boundingClientRect(data => { + this.leftWidth = data[1].width + this.rightWidth = data[2].width + this.width = data[0].width + this.viewWidth = this.width + this.rightWidth + this.leftWidth + if (this.leftWidth === 0) { + // TODO 鐤戜技bug ,鍒濆鍖栫殑鏃跺�欏鏋渪 鏄�0锛屼細瀵艰嚧绉诲姩浣嶇疆閿欒锛屾墍浠ヨ鍏冪礌瓒呭嚭涓�鐐� + this.x = -0.1 + } else { + this.x = -this.leftWidth + } + this.moveX = this.x + this.$nextTick(() => { + this.swipeShow = 1 + }) + + if (!this.buttonWidth) { + this.disabledView = true + } + + if (this.autoClose) return + if (this.show !== 'none') { + this.transition = true + this.open(this.shows) + } + }).exec(); + + } + } +} -- Gitblit v1.9.1