rate.wxml 3.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  1. <wxs src="../common/utils.wxs" module="_" />
  2. <wxs src="./rate.wxs" module="utils" />
  3. <view class="{{classPrefix}}" style="{{_._style([style, customStyle])}}">
  4. <view
  5. class="{{classPrefix}}__wrapper {{prefix}}-class"
  6. style="font-size:{{ utils.regSize(size) }}"
  7. catch:touchmove="{{ !disabled ? 'onTouchMove' : '' }}"
  8. catch:tap="{{ !disabled ? 'onTap' : '' }}"
  9. catch:touchend="{{ !disabled ? 'onTouchEnd' : ''}}"
  10. catch:touchcancel="{{ !disabled ? 'onTouchEnd' : ''}}"
  11. >
  12. <t-icon
  13. wx:for="{{ count }}"
  14. wx:key="*this"
  15. class="{{classPrefix }}__icon {{utils.getIconClass(classPrefix + '__icon', defaultValue, value, index, allowHalf, disabled, scaleIndex)}}"
  16. t-class="{{prefix}}-class-icon"
  17. name="{{utils.getIconName(defaultValue, value, index, variant, icon)}}"
  18. size="{{ size }}"
  19. style="margin-right:{{ count - index > 1 ? gap : 0 }}px; {{utils.getColor(color)}}"
  20. />
  21. </view>
  22. <text wx:if="{{showText}}" class="{{_.cls(classPrefix + '__text', [['active', value > 0]])}} {{prefix}}-class-text"
  23. >{{utils.getText(texts,value,defaultTexts)}}</text
  24. >
  25. <view wx:if="{{tipsVisible}}" class="{{classPrefix}}__tips" style="left: {{tipsLeft}}px">
  26. <block wx:if="{{actionType == 'tap'}}">
  27. <view
  28. wx:if="{{allowHalf}}"
  29. class="{{_.cls(classPrefix + '__tips-item', [['active', utils.ceil(value) - 0.5 == value]])}}"
  30. bind:tap="onSelect"
  31. data-value="{{utils.ceil(value) - 0.5}}"
  32. >
  33. <t-icon
  34. class="{{classPrefix }}__icon {{classPrefix }}__icon--selected-half"
  35. name="{{utils.getIconName(defaultValue, value, index, variant, icon)}}"
  36. size="{{ size }}"
  37. style="{{utils.getColor(color)}}"
  38. />
  39. <view class="{{classPrefix}}__tips-text">{{utils.ceil(value) - 0.5}}</view>
  40. </view>
  41. <view
  42. class="{{_.cls(classPrefix + '__tips-item', [['active', utils.ceil(value) == value]])}}"
  43. bind:tap="onSelect"
  44. data-value="{{utils.ceil(value)}}"
  45. >
  46. <t-icon
  47. class="{{_.cls(classPrefix + '__icon', ['selected'])}}"
  48. name="{{utils.getIconName(defaultValue, value, index, 'filled', icon)}}"
  49. size="{{ size }}"
  50. style="{{utils.getColor(color)}}"
  51. />
  52. <view class="{{classPrefix}}__tips-text">{{utils.ceil(value)}}</view>
  53. </view>
  54. </block>
  55. <view
  56. wx:else
  57. class="{{_.cls(classPrefix + '__tips-item', [['active', utils.ceil(value) == value && actionType == 'tap']])}}"
  58. bind:tap="onSelect"
  59. data-value="{{utils.ceil(value)}}"
  60. >
  61. <t-icon
  62. class="{{_.cls(classPrefix + '__icon', [['selected', utils.ceil(value) == value], ['selected-half', utils.ceil(value) != value]]) }}"
  63. name="{{utils.getIconName(defaultValue, value, index, 'filled', icon)}}"
  64. size="{{ size }}"
  65. style="{{utils.getColor(color)}}; font-size: {{size}};"
  66. />
  67. <view class="{{classPrefix}}__tips-text">{{value}}</view>
  68. </view>
  69. </view>
  70. </view>