forked from nsjcy/frontEnd/nsjcy

LAPTOP-RI7D261L\Mr Ke
2020-02-13 a2789abb73725738127b03d95c95081b66954916
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
<view class="wux-class {{ classes.wrap }}" style="{{ extWrapStyle }}">
    <view class="{{ classes.min }}" wx:if="{{ common.getValue(showValue, 'min') }}">{{ min }}</view>
    <slot name="min" wx:else></slot>
    <view class="{{ classes.rail }}" style="{{ extRailStyle }}">
        <block wx:for="{{ marks }}" wx:key="" wx:if="{{ showMark && marks.length > 0 }}">
            <view class="{{ classes.mark }}" style="left: {{ item + '%' }}; {{ common.getStyle(extMarkStyle, index) }}" />
        </block>
        <block wx:for="{{ inputValue }}" wx:key="">
            <view
                class="{{ classes.track }}"
                style="{{ common.getTrackStyle(offsets, index, inputValue.length > 1) }}; {{ common.getStyle(extTrackStyle, index) }}"
                wx:if="{{ inputValue.length === 1 || index !== inputValue.length - 1 }}"
            />
            <view
                class="{{ classes.handle }} {{ last === index ? prefixCls + '__handle--last' : '' }} {{ last === index && isTouched ? prefixCls + '__handle--is-touched' : '' }}"
                data-index="{{ index }}"
                data-meta="{{ common.format(tipFormatter, item) }}"
                bindtouchstart="onTouchStart"
                catchtouchmove="{{ isMoved ? 'noop' : '' }}"
                capture-bind:touchmove="onTouchMove"
                bindtouchend="onTouchEnd"
                style="left: {{ offsets[index] + '%' }}; {{ common.getStyle(extHandleStyle, index) }}"
            />
        </block>
    </view>
    <view class="{{ classes.max }}" wx:if="{{ common.getValue(showValue, 'max') }}">{{ max }}</view>
    <slot name="max" wx:else></slot>
</view>
 
<wxs module="common">
    module.exports.format = function(source, value) { return source.replace(getRegExp('\{d\}', 'g'), value) }
    module.exports.getTrackStyle = function(offsets, index, multiple) { if (!multiple) { return 'width: ' + offsets[index] + '%' } return 'left: ' + offsets[index] + '%; width: ' + (offsets[index + 1] - offsets[index]) + '%' }
    module.exports.getStyle = function(style, index) { if (style.constructor !== 'String') { return style[index] } return style }
    module.exports.getValue = function(obj, name) { if (obj.constructor === 'Object') { return obj[name] } return obj }
</wxs>