select-reason.vue 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108
  1. <template>
  2. <u-popup v-model="show" mask mode="bottom" mask-close-able border-radius="16">
  3. <view class="header">
  4. <view class="cancel" @click="close">取消</view>
  5. <view class="title">{{ title }}</view>
  6. <view class="submit" @click="submit">确认</view>
  7. </view>
  8. <view class="list">
  9. <u-radio-group v-model="currentReasonIndex" @change="reasonChange">
  10. <view class="item" v-for="(item, index) in ops" :key="index" @click="currentReasonIndex = index">
  11. <view class="label">{{ item.label }}</view>
  12. <view class="check"><u-radio :name="index" :active-color="radioColor"></u-radio></view>
  13. </view>
  14. </u-radio-group>
  15. </view>
  16. </u-popup>
  17. </template>
  18. <script>
  19. export default {
  20. props: {
  21. // 标题
  22. title: {
  23. type: String,
  24. default: ''
  25. },
  26. // 配置项
  27. ops: {
  28. type: Array,
  29. default: () => {
  30. return [];
  31. }
  32. }
  33. },
  34. data() {
  35. return {
  36. show: false,
  37. currentReasonIndex: 5,
  38. radioColor: this.$appTheme.appThemeColor
  39. };
  40. },
  41. methods: {
  42. // 打开popup
  43. open(currentReasonIndex) {
  44. this.currentReasonIndex = currentReasonIndex;
  45. this.show = true;
  46. },
  47. // 选择原因
  48. reasonChange(e) {},
  49. // 关闭
  50. close() {
  51. this.show = false;
  52. },
  53. // 提交
  54. submit() {
  55. if (this.currentReasonIndex == null) {
  56. uni.showToast({
  57. title: '请选择' + this.title,
  58. icon: 'none'
  59. });
  60. return;
  61. }
  62. this.$emit('change', this.currentReasonIndex);
  63. this.close();
  64. }
  65. }
  66. };
  67. </script>
  68. <style lang="scss" scoped>
  69. .header {
  70. padding: 26rpx 32rpx;
  71. display: flex;
  72. justify-content: space-between;
  73. align-items: center;
  74. .cancel {
  75. font-size: 28rpx;
  76. color: $app-theme-card-gray-deep-color;
  77. }
  78. .title {
  79. font-size: 32rpx;
  80. color: $app-theme-text-black-color;
  81. }
  82. .submit {
  83. font-size: 28rpx;
  84. color: $app-theme-color;
  85. }
  86. }
  87. .list {
  88. padding: 30rpx;
  89. .item {
  90. margin-bottom: 40rpx;
  91. display: flex;
  92. justify-content: space-between;
  93. align-items: center;
  94. .label {
  95. font-size: 30rpx;
  96. color: $app-theme-text-color;
  97. }
  98. .check {
  99. width: 36rpx;
  100. }
  101. }
  102. }
  103. </style>