猫妈狗爸伴宠师小程序前端代码
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.

118 lines
2.3 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 increaseServiceOptions"
  10. :key="`option-${index}`"
  11. @click="onSelectServe(option.id)"
  12. >
  13. <view class="option-info">
  14. <view class="option-title">{{ option.title }}</view>
  15. <view class="option-desc">{{ option.detail }}</view>
  16. </view>
  17. <up-icon
  18. name="checkmark-circle-fill"
  19. :color="serves.includes(option.id) ? '#FFBF60' : '#BDBDBD'"
  20. size="46rpx"
  21. ></up-icon>
  22. </view>
  23. </view>
  24. </popupSelect>
  25. </template>
  26. <script setup>
  27. import { ref, computed } from 'vue'
  28. import { useStore } from 'vuex'
  29. import popupSelect from '../components/popupSelect.vue';
  30. const store = useStore()
  31. const props = defineProps({
  32. modelValue: {
  33. type: Array,
  34. default() {
  35. return []
  36. }
  37. },
  38. })
  39. const emit = defineEmits(['update:modelValue', 'confirm'])
  40. const serves = ref([])
  41. const increaseServiceOptions = computed(() => {
  42. return store.getters.increaseServiceOptions
  43. })
  44. const onSelectServe = (serve) => {
  45. const oldServes = serves.value
  46. let newServes = []
  47. if (oldServes.includes(serve)) {
  48. newServes = oldServes.filter(item => item !== serve)
  49. } else {
  50. newServes = oldServes.concat(serve)
  51. }
  52. serves.value = newServes
  53. }
  54. const popupRef = ref()
  55. const open = () => {
  56. store.dispatch('fetchIncreaseServiceOptions')
  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. emit('confirm')
  66. }
  67. defineExpose({ open, close })
  68. </script>
  69. <style lang="scss" scoped>
  70. .content {
  71. padding-bottom: 25rpx;
  72. }
  73. .option {
  74. padding: 0 49rpx 0 25rpx;
  75. background-color: #FFF5E5;
  76. border-radius: 8rpx;
  77. & + & {
  78. margin-top: 12rpx;
  79. }
  80. &-info {
  81. padding: 7rpx 0 13rpx 0;
  82. }
  83. &-title {
  84. color: #000000;
  85. font-size: 28rpx;
  86. line-height: 37rpx;
  87. }
  88. &-desc {
  89. margin-top: 12rpx;
  90. color: #707070;
  91. font-size: 20rpx;
  92. line-height: 26rpx;
  93. }
  94. }
  95. </style>