message-select.wxml 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  1. <wxs module="_">
  2. module.exports.getClassName = function (option) {
  3. if (!option) return '';
  4. if (option.disabled) return 'card--disabled';
  5. if (option.checked) return 'card--active';
  6. }
  7. module.exports.maxHeight = function (options, height, maxHeight) {
  8. var rows = Math.ceil(options.filter(function (option) { return !option.hide }).length / 3);
  9. return Math.min(rows * (height + 8), maxHeight || 350);
  10. }
  11. module.exports.subName = function (option) {
  12. if (!option.options) return '';
  13. var options = option.options
  14. .filter(function (option) { return option.checked; })
  15. .map(function (option) { return option.name; })
  16. if (options.length) return ':' + options.join(' ');
  17. return ''
  18. }
  19. module.exports.options = function (options) {
  20. return options.filter(function (option) { return !option.hide })
  21. }
  22. </wxs>
  23. <!--module/chats/components/message-select/message-select.wxml-->
  24. <view class="chat-card left">
  25. <view class="chat-card__avatar ">
  26. <image src="../../assets/robot.png" mode="aspectFill" />
  27. </view>
  28. <view class="chat-card__content">
  29. <t-cell t-class="cell-border-gradient" title="{{payload.title}}"></t-cell>
  30. <scroll-view class="options-wrapper" type="custom" scroll-y style="height: {{_.maxHeight(options, itemHeight)}}px;" mark:type="options" bind:tap="handleTop">
  31. <grid-builder list="{{_.options(options)}}" cross-axis-count="3" cross-axis-gap="8" main-axis-gap="8" padding="{{[4,4,4,4]}}">
  32. <view slot:item slot:index class="card {{_.getClassName(item)}}" style="height: {{itemHeight}}px;" mark:item="{{item}}">
  33. <t-icon wx:if="{{item.checked}}" name="check" t-class="card__icon" ariaHidden="{{true}}" />
  34. <text overflow="ellipsis" max-lines="2">{{item.name}}{{_.subName(item)}}</text>
  35. </view>
  36. </grid-builder>
  37. </scroll-view>
  38. <view wx:if="{{payload.multiple || !payload.required}}" class="chat-card__handle {{active ? '' : 'disabled'}}">
  39. <view wx:if="{{!payload.required}}" class="item {{hasSelected ? 'disabled': ''}}" bind:tap="onSkip">
  40. <image src="../../assets/button-1.bg.png" mode="aspectFit" />
  41. <view style="color: #d4d4d4;">都没有</view>
  42. </view>
  43. <view wx:if="{{payload.multiple}}" class="item" bind:tap="onSubmit">
  44. <image src="../../assets/button-1.bg.png" mode="aspectFit" />
  45. <view>提交</view>
  46. </view>
  47. </view>
  48. </view>
  49. </view>
  50. <view class="chat-card right" wx:if="{{result}}">
  51. <view class="chat-card__avatar ">
  52. <user-avatar></user-avatar>
  53. </view>
  54. <view class="chat-card__content">
  55. <t-cell title="{{result}}" bordered="{{false}}"></t-cell>
  56. </view>
  57. <t-loading wx:if="{{active}}" t-class="loading" theme="spinner" size="40rpx" class="wrapper" />
  58. </view>
  59. <t-popup wx:if="{{subOptions.length}}" t-class="form-picker__inner" visible="{{true}}" bind:visible-change="onCancel" placement="bottom" close-on-overlay-click="{{false}}">
  60. <view class="form-picker__header">
  61. <view class="btn btn--cancel" aria-role="button" bind:tap="onCancel">取消</view>
  62. <view class="title">{{subTitle}}</view>
  63. <view wx:if="{{subMultiple}}" class="btn btn--confirm" aria-role="button" bind:tap="onConfirm">确定</view>
  64. </view>
  65. <view class="form-picker__content">
  66. <scroll-view class="options-wrapper" type="custom" scroll-y style="height: {{_.maxHeight(subOptions, itemHeight)}}px;" mark:type="sub" bind:tap="handleSub">
  67. <grid-builder list="{{_.options(subOptions)}}" cross-axis-count="3" cross-axis-gap="8" main-axis-gap="8" padding="{{[4,4,4,4]}}">
  68. <view slot:item slot:index class="card {{_.getClassName(item)}}" style="height: {{itemHeight}}px;" mark:item="{{item}}">
  69. <t-icon wx:if="{{item.checked}}" name="check" t-class="card__icon" ariaHidden="{{true}}" />
  70. <text overflow="ellipsis" max-lines="2">{{item.name}}{{_.subName(item)}}</text>
  71. </view>
  72. </grid-builder>
  73. </scroll-view>
  74. </view>
  75. </t-popup>