index.wxml 1.7 KB

123456789101112131415161718192021222324252627282930
  1. <view class="wux-class {{ classes.wrap }}" style="{{ extWrapStyle }}">
  2. <view class="{{ classes.min }}" wx:if="{{ common.getValue(showValue, 'min') }}">{{ min }}</view>
  3. <view class="{{ classes.rail }}" style="{{ extRailStyle }}">
  4. <block wx:for="{{ marks }}" wx:key="" wx:if="{{ showMark && marks.length > 0 }}">
  5. <view class="{{ classes.mark }}" style="left: {{ item + '%' }}; {{ common.getStyle(extMarkStyle, index) }}" />
  6. </block>
  7. <block wx:for="{{ sliderValue }}" wx:key="">
  8. <view
  9. class="{{ classes.track }}"
  10. style="{{ common.getTrackStyle(offsets, index, sliderValue.length > 1) }}; {{ common.getStyle(extTrackStyle, index) }}"
  11. wx:if="{{ sliderValue.length === 1 || index !== sliderValue.length - 1 }}"
  12. />
  13. <view
  14. class="{{ classes.handle }} {{ last === index ? prefixCls + '__handle--last' : '' }}"
  15. data-index="{{ index }}"
  16. bindtouchstart="onTouchStart"
  17. bindtouchmove="onTouchMove"
  18. bindtouchend="onTouchEnd"
  19. style="left: {{ offsets[index] + '%' }}; {{ common.getStyle(extHandleStyle, index) }}"
  20. />
  21. </block>
  22. </view>
  23. <view class="{{ classes.max }}" wx:if="{{ common.getValue(showValue, 'max') }}">{{ max }}</view>
  24. </view>
  25. <wxs module="common">
  26. module.exports.getTrackStyle = function(offsets, index, multiple) { if (!multiple) { return 'width: ' + offsets[index] + '%' } return 'left: ' + offsets[index] + '%; width: ' + (offsets[index + 1] - offsets[index]) + '%' }
  27. module.exports.getStyle = function(style, index) { if (style.constructor !== 'String') { return style[index] } return style }
  28. module.exports.getValue = function(obj, name) { if (obj.constructor === 'Object') { return obj[name] } return obj }
  29. </wxs>