猫妈狗爸伴宠师小程序前端代码
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

115 lines
2.1 KiB

  1. <template>
  2. <popupSelect
  3. ref="popupRef"
  4. title="请选择增值服务"
  5. @confirm="onConfirm"
  6. >
  7. <view class="content">
  8. <view class="flex-between option"
  9. v-for="(option, index) in props.options"
  10. :key="`option-${index}`"
  11. @click="onSelectServe(option.value)"
  12. >
  13. <view class="option-info">
  14. <view class="option-title">{{ option.title }}</view>
  15. <view class="option-desc">{{ option.desc }}</view>
  16. </view>
  17. <up-icon
  18. name="checkmark-circle-fill"
  19. :color="serves.includes(option.value) ? '#FFBF60' : '#BDBDBD'"
  20. size="46rpx"
  21. ></up-icon>
  22. </view>
  23. </view>
  24. </popupSelect>
  25. </template>
  26. <script setup>
  27. import { ref } from 'vue'
  28. import popupSelect from '../components/popupSelect.vue';
  29. const props = defineProps({
  30. modelValue: {
  31. type: Array,
  32. default() {
  33. return []
  34. }
  35. },
  36. options: {
  37. type: Array,
  38. default() {
  39. return []
  40. }
  41. },
  42. })
  43. const emit = defineEmits(['update:modelValue'])
  44. const serves = ref([])
  45. const onSelectServe = (serve) => {
  46. const oldServes = serves.value
  47. let newServes = []
  48. if (oldServes.includes(serve)) {
  49. newServes = oldServes.filter(item => item !== serve)
  50. } else {
  51. newServes = oldServes.concat(serve)
  52. }
  53. serves.value = newServes
  54. }
  55. const popupRef = ref()
  56. const open = () => {
  57. serves.value = props.modelValue
  58. popupRef.value.open()
  59. }
  60. const close = () => {
  61. popupRef.value.close()
  62. }
  63. const onConfirm = () => {
  64. emit('update:modelValue', serves.value)
  65. }
  66. defineExpose({ open, close })
  67. </script>
  68. <style lang="scss" scoped>
  69. .content {
  70. padding-bottom: 25rpx;
  71. }
  72. .option {
  73. padding: 0 49rpx 0 25rpx;
  74. background-color: #FFF5E5;
  75. border-radius: 8rpx;
  76. & + & {
  77. margin-top: 12rpx;
  78. }
  79. &-info {
  80. padding: 7rpx 0 13rpx 0;
  81. }
  82. &-title {
  83. color: #000000;
  84. font-size: 28rpx;
  85. line-height: 37rpx;
  86. }
  87. &-desc {
  88. margin-top: 12rpx;
  89. color: #707070;
  90. font-size: 20rpx;
  91. line-height: 26rpx;
  92. }
  93. }
  94. </style>