CfAppraiseStar.vue 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  1. <template>
  2. <view class="appraise-star">
  3. <view class="appraise-star-title">{{title}}</view>
  4. <view class="appraise-star-star" v-for="item in 5" :key="item" @click="onClickStar(item)">
  5. <text class="iconfont" :class="item<=starval?'is-active':''">&#xe652;</text>
  6. </view>
  7. <view class="appraise-star-text" v-if="starText&&starval">{{starText[starval]}}</view>
  8. </view>
  9. </template>
  10. <script lang="ts" setup>
  11. import { ref, PropType, onMounted, computed } from 'vue'
  12. const emit = defineEmits(['update:starval'])
  13. const props = defineProps({
  14. isEdit: Boolean,
  15. title: String,
  16. starval: Number,
  17. starText: {
  18. type: Array as PropType<string[]>
  19. },
  20. })
  21. const starval = computed({
  22. get() {
  23. return props.starval
  24. },
  25. set(val) {
  26. emit('update:starval', val)
  27. },
  28. })
  29. const onClickStar = (cur : number) => {
  30. if (props.isEdit) return
  31. starval.value = cur
  32. console.log("curVal.value", starval.value)
  33. }
  34. onMounted(() => {
  35. })
  36. </script>
  37. <style lang="scss" scoped>
  38. .appraise-star {
  39. @include flex;
  40. margin-top: 32rpx;
  41. .appraise-star-star {
  42. margin-left: 24rpx;
  43. .iconfont {
  44. font-size: 48rpx;
  45. background: linear-gradient(180deg, #B3B5B9 0%, #899AB9 100%);
  46. background-clip: text;
  47. text-fill-color: transparent;
  48. -webkit-background-clip: text;
  49. -webkit-text-fill-color: transparent;
  50. &.is-active {
  51. background: linear-gradient(180deg, #46ACFF 0%, $uni-color-primary 100%);
  52. background-clip: text;
  53. text-fill-color: transparent;
  54. -webkit-background-clip: text;
  55. -webkit-text-fill-color: transparent;
  56. }
  57. }
  58. }
  59. .appraise-star-text {
  60. margin-left: 24rpx;
  61. }
  62. }
  63. </style>