From 2cc85c64f1c64a2dbaeae276a3e2ca8420de76b7 Mon Sep 17 00:00:00 2001
From: WXL <wl_5969728@163.com>
Date: 星期三, 22 四月 2026 18:09:58 +0800
Subject: [PATCH] 上报转运调试
---
node_modules/uview-plus/components/u-slider/u-slider.vue | 147 +++++++++++++++++++++++++++++++++++++-----------
1 files changed, 112 insertions(+), 35 deletions(-)
diff --git a/node_modules/uview-plus/components/u-slider/u-slider.vue b/node_modules/uview-plus/components/u-slider/u-slider.vue
index 96e4df4..6d87fc6 100644
--- a/node_modules/uview-plus/components/u-slider/u-slider.vue
+++ b/node_modules/uview-plus/components/u-slider/u-slider.vue
@@ -1,7 +1,7 @@
<template>
<view
class="u-slider"
- :style="[addStyle(customStyle)]"
+ :style="[addStyle(customStyle), {width: vertical ? addUnit(this.blockSize): ''}]"
>
<template v-if="!useNative || isRange">
<view ref="u-slider-inner" class="u-slider-inner" @click="onClick"
@@ -13,7 +13,8 @@
class="u-slider__base"
:style="[
{
- height: height,
+ width: vertical ? addUnit(sizeLocal) : addUnit(length),
+ height: vertical ? addUnit(length) : addUnit(sizeLocal),
backgroundColor: inactiveColor
}
]"
@@ -25,8 +26,6 @@
:style="[
barStyle,
{
- height: height,
- marginTop: '-' + height,
backgroundColor: activeColor
}
]"
@@ -37,8 +36,6 @@
:style="[
barStyle0,
{
- height: height,
- marginTop: '-' + height,
backgroundColor: inactiveColor
}
]"
@@ -55,7 +52,7 @@
<template v-if="isRange">
<view class="u-slider__button-wrap u-slider__button-wrap-0" @touchstart="onTouchStart($event, 0)"
@touchmove="onTouchMove($event, 0)" @touchend="onTouchEnd($event, 0)"
- @touchcancel="onTouchEnd($event, 0)" :style="{left: (getPx(barStyle0.width) + getPx(blockSize)/2) + 'px'}">
+ @touchcancel="onTouchEnd($event, 0)" :style="touchButtonStyle(barStyle0)">
<slot name="min" v-if="$slots.min || $slots.$min"/>
<view v-else class="u-slider__button" :style="[blockStyle, {
height: getPx(blockSize, true),
@@ -66,7 +63,7 @@
</template>
<view class="u-slider__button-wrap" @touchstart="onTouchStart"
@touchmove="onTouchMove" @touchend="onTouchEnd"
- @touchcancel="onTouchEnd" :style="{left: (getPx(barStyle.width) + getPx(blockSize)/2) + 'px'}">
+ @touchcancel="onTouchEnd" :style="touchButtonStyle(barStyle)">
<slot name="max" v-if="isRange && ($slots.max || $slots.$max)"/>
<slot v-else-if="$slots.default || $slots.$default"/>
<view v-else class="u-slider__button" :style="[blockStyle, {
@@ -76,7 +73,9 @@
}]"></view>
</view>
</view>
- <view class="u-slider__show-value" v-if="showValue && !isRange">{{ modelValue }}</view>
+ <view class="u-slider__show-value" v-if="showValue && !isRange">
+ {{ modelValue }}
+ </view>
</template>
<slider
class="u-slider__native"
@@ -98,10 +97,10 @@
</template>
<script>
- import { props } from './props';
- import { mpMixin } from '../../libs/mixin/mpMixin';
- import { mixin } from '../../libs/mixin/mixin';
- import { addStyle, getPx, sleep } from '../../libs/function/index.js';
+ import { props } from './props'
+ import { mpMixin } from '../../libs/mixin/mpMixin'
+ import { mixin } from '../../libs/mixin/mixin'
+ import { addUnit, addStyle, getPx, sleep } from '../../libs/function/index.js'
// #ifdef APP-NVUE
const dom = uni.requireNativePlugin('dom')
// #endif
@@ -130,17 +129,22 @@
data() {
return {
startX: 0,
+ startY: 0,
status: 'end',
newValue: 0,
distanceX: 0,
+ distanceY: 0,
startValue0: 0,
startValue: 0,
barStyle0: {},
barStyle: {},
sliderRect: {
left: 0,
- width: 0
- }
+ top: 0,
+ width: 0,
+ height: 0
+ },
+ sizeLocal: '2px'
};
},
watch: {
@@ -173,12 +177,41 @@
deep:true
}
},
- created() {
+ mounted() {
+ if (this.height != '') {
+ this.sizeLocal = val
+ } else {
+ this.sizeLocal = this.size
+ }
},
computed: {
+ touchButtonStyle() {
+ return (barStyle) => {
+ let style = {}
+ if (this.blockSize) {
+ if (this.vertical) {
+ style.top = (getPx(barStyle.height) ) + 'px'
+ } else {
+ if (barStyle.width) {
+ style.left = (getPx(barStyle.width) + getPx(this.blockSize)/2) + 'px'
+ // console.log(style)
+ }
+ }
+ }
+ return style
+ }
+ },
innerStyleCpu() {
- let style = this.innerStyle;
- style.height = (this.isRange && this.showValue) ? (getPx(this.blockSize) + 24) + 'px' : (getPx(this.blockSize)) + 'px';
+ let style = {...this.innerStyle};
+ if (this.vertical) {
+ style.flexDirection = 'row'
+ style.height = this.length
+ style.padding = '0'
+ style.width = (this.isRange && this.showValue) ? (getPx(this.blockSize) + 24) + 'px' : (getPx(this.blockSize)) + 'px';
+ } else {
+ style.flexDirection = 'column'
+ style.height = (this.isRange && this.showValue) ? (getPx(this.blockSize) + 24) + 'px' : (getPx(this.blockSize)) + 'px';
+ }
return style;
}
},
@@ -202,8 +235,10 @@
dom.getComponentRect(ref, (res) => {
// console.log(res)
this.sliderRect = {
+ top: res.size.top,
left: res.size.left,
- width: res.size.width
+ width: res.size.width,
+ height: res.size.height
};
this.init()
})
@@ -211,6 +246,7 @@
}
},
methods: {
+ addUnit,
addStyle,
getPx,
init() {
@@ -259,10 +295,12 @@
onTouchStart(event, index = 1) {
if (this.disabled) return;
this.startX = 0;
+ this.startY = 0;
// 瑙︽懜鐐归泦
let touches = event.touches[0];
// 瑙︽懜鐐瑰埌灞忓箷宸﹁竟鐨勮窛绂�
this.startX = touches.clientX;
+ this.startY = touches.clientY;
// 姝ゅ鐨則his.modelValue铏戒负props鍊硷紝浣嗘槸閫氳繃$emit('update:modelValue')杩涜浜嗕慨鏀�
if (this.isRange) {
this.startValue0 = this.format(this.rangeValue[0], 0);
@@ -277,18 +315,30 @@
}
// 鏍囩ず褰撳墠鐨勭姸鎬佷负寮�濮嬭Е鎽告粦鍔�
this.status = 'start';
+ // console.log('start', this.startValue)
let clientX = 0;
+ let clientY = 0;
// #ifndef APP-NVUE
clientX = touches.clientX;
+ clientY = touches.clientY;
// #endif
// #ifdef APP-NVUE
clientX = touches.screenX;
+ clientY = touches.screenY;
// #endif
- this.distanceX = clientX - this.sliderRect.left;
- // 鑾峰緱绉诲姩璺濈瀵规暣涓粦鍧楃殑鍊硷紝姝や负甯︽湁澶氫綅灏忔暟鐨勫�硷紝涓嶈兘鐢ㄦ鏇存柊瑙嗗浘
- // 鍚﹀垯閫犳垚閫氫俊闃诲锛岄渶瑕佹瘡鏀瑰彉涓�涓猻tep鍊兼椂淇敼涓�娆¤鍥�
- this.newValue = ((this.distanceX / this.sliderRect.width) * (this.max - this.min)) + parseFloat(this.min);
+ if (this.vertical) {
+ this.distanceY = clientY - this.sliderRect.top;
+ // 鑾峰緱绉诲姩璺濈瀵规暣涓粦鍧楃殑鍊硷紝姝や负甯︽湁澶氫綅灏忔暟鐨勫�硷紝涓嶈兘鐢ㄦ鏇存柊瑙嗗浘
+ // 鍚﹀垯閫犳垚閫氫俊闃诲锛岄渶瑕佹瘡鏀瑰彉涓�涓猻tep鍊兼椂淇敼涓�娆¤鍥�
+ this.newValue = ((this.distanceY / this.sliderRect.height) * (this.max - this.min)) + parseFloat(this.min);
+ } else {
+ this.distanceX = clientX - this.sliderRect.left;
+ // 鑾峰緱绉诲姩璺濈瀵规暣涓粦鍧楃殑鍊硷紝姝や负甯︽湁澶氫綅灏忔暟鐨勫�硷紝涓嶈兘鐢ㄦ鏇存柊瑙嗗浘
+ // 鍚﹀垯閫犳垚閫氫俊闃诲锛岄渶瑕佹瘡鏀瑰彉涓�涓猻tep鍊兼椂淇敼涓�娆¤鍥�
+ this.newValue = ((this.distanceX / this.sliderRect.width) * (this.max - this.min)) + parseFloat(this.min);
+ }
+
this.status = 'moving';
// 鍙戝嚭moving浜嬩欢
let $crtFmtValue = this.updateValue(this.newValue, true, index);
@@ -303,16 +353,26 @@
// console.log('touchs', touches)
// 婊戝潡鐨勫乏杈逛笉涓�瀹氳窡灞忓箷宸﹁竟鎺ュ¥锛屾墍浠ラ渶瑕佸噺鍘绘渶澶栧眰鐖跺厓绱犵殑宸﹁竟鍊�
let clientX = 0;
+ let clientY = 0;
// #ifndef APP-NVUE
clientX = touches.clientX;
+ clientY = touches.clientY;
// #endif
// #ifdef APP-NVUE
clientX = touches.screenX;
+ clientY = touches.screenY;
// #endif
- this.distanceX = clientX - this.sliderRect.left;
- // 鑾峰緱绉诲姩璺濈瀵规暣涓粦鍧楃殑鍊硷紝姝や负甯︽湁澶氫綅灏忔暟鐨勫�硷紝涓嶈兘鐢ㄦ鏇存柊瑙嗗浘
- // 鍚﹀垯閫犳垚閫氫俊闃诲锛岄渶瑕佹瘡鏀瑰彉涓�涓猻tep鍊兼椂淇敼涓�娆¤鍥�
- this.newValue = ((this.distanceX / this.sliderRect.width) * (this.max - this.min)) + parseFloat(this.min);
+ if (this.vertical) {
+ this.distanceY = clientY - this.sliderRect.top;
+ // 鑾峰緱绉诲姩璺濈瀵规暣涓粦鍧楃殑鍊硷紝姝や负甯︽湁澶氫綅灏忔暟鐨勫�硷紝涓嶈兘鐢ㄦ鏇存柊瑙嗗浘
+ // 鍚﹀垯閫犳垚閫氫俊闃诲锛岄渶瑕佹瘡鏀瑰彉涓�涓猻tep鍊兼椂淇敼涓�娆¤鍥�
+ this.newValue = ((this.distanceY / this.sliderRect.height) * (this.max - this.min)) + parseFloat(this.min);
+ } else {
+ this.distanceX = clientX - this.sliderRect.left;
+ // 鑾峰緱绉诲姩璺濈瀵规暣涓粦鍧楃殑鍊硷紝姝や负甯︽湁澶氫綅灏忔暟鐨勫�硷紝涓嶈兘鐢ㄦ鏇存柊瑙嗗浘
+ // 鍚﹀垯閫犳垚閫氫俊闃诲锛岄渶瑕佹瘡鏀瑰彉涓�涓猻tep鍊兼椂淇敼涓�娆¤鍥�
+ this.newValue = ((this.distanceX / this.sliderRect.width) * (this.max - this.min)) + parseFloat(this.min);
+ }
this.status = 'moving';
// 鍙戝嚭moving浜嬩欢
let $crtFmtValue = this.updateValue(this.newValue, true, index);
@@ -348,23 +408,40 @@
// console.log('click', event)
// #ifndef APP-NVUE
// nvue涓嬫殏鏃舵棤娉曡幏鍙栧潗鏍�
- let clientX = event.detail.x - this.sliderRect.left
- this.newValue = ((clientX / this.sliderRect.width) * (this.max - this.min)) + parseFloat(this.min);
- this.updateValue(this.newValue, false, 1);
+ if (this.vertical) {
+ let clientY = event.detail.y - this.sliderRect.top
+ // console.log(this.sliderRect.top, event.detail.y)
+ this.newValue = ((clientY / this.sliderRect.height) * (this.max - this.min)) + parseFloat(this.min)
+ this.updateValue(this.newValue, false, 1)
+ } else {
+ let clientX = event.detail.x - this.sliderRect.left
+ this.newValue = ((clientX / this.sliderRect.width) * (this.max - this.min)) + parseFloat(this.min)
+ this.updateValue(this.newValue, false, 1)
+ }
// #endif
},
updateValue(value, drag, index = 1) {
// 鍘绘帀灏忔暟閮ㄥ垎锛屽悓鏃朵篃鏄step姝ヨ繘鐨勫鐞�
- let valueFormat = this.format(value, index);
+ let valueFormat = this.format(value, index)
// 涓嶅厑璁告粦鍔ㄧ殑鍊艰秴杩噈ax鏈�澶у��
if(valueFormat > this.max ) {
valueFormat = this.max
}
// 璁剧疆绉诲姩鐨勮窛绂伙紝涓嶈兘鐢ㄧ櫨鍒嗘瘮锛屽洜涓篘VUE涓嶆敮鎸併��
- let width = Math.min((valueFormat - this.min) / (this.max - this.min) * this.sliderRect.width, this.sliderRect.width)
- let barStyle = {
- width: width + 'px'
- };
+ let sliderLength = 0
+ let barStyle = {}
+ if (this.vertical) {
+ sliderLength = Math.min((valueFormat - this.min) / (this.max - this.min) * this.sliderRect.height, this.sliderRect.height)
+ barStyle['height'] = addUnit(sliderLength)
+ barStyle['width'] = addUnit(this.sizeLocal)
+ barStyle['marginLeft'] = '-' + getPx(this.sizeLocal, true)
+ } else {
+ sliderLength = Math.min((valueFormat - this.min) / (this.max - this.min) * this.sliderRect.width, this.sliderRect.width)
+ barStyle['width'] = addUnit(sliderLength)
+ barStyle['height'] = addUnit(this.sizeLocal)
+ barStyle['marginTop'] = '-' + getPx(this.sizeLocal, true)
+ }
+
// 绉诲姩鏈熼棿鏃犻渶杩囨浮鍔ㄧ敾
if (drag == true) {
barStyle.transition = 'none';
--
Gitblit v1.9.3