index.vue 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113
  1. <template>
  2. <u-popup :show="isShow" @close="close" @open="open">
  3. <view class="rate-con">
  4. <view class="title">{{ title }}</view>
  5. <view class="rate-item">
  6. <view>评分:</view>
  7. <u-rate :activeColor="activeColor" :count="count" v-model="rateNum"></u-rate>
  8. </view>
  9. <view class="textarea-box">
  10. <u--textarea v-model="textarea" :placeholder="placeholder"></u--textarea>
  11. </view>
  12. <view class="operate-box">
  13. <u-button text="取消" @click="close"></u-button>
  14. <u-button type="primary" @click="confirm" text="确定"></u-button>
  15. </view>
  16. </view>
  17. </u-popup>
  18. </template>
  19. <script>
  20. export default {
  21. props: {
  22. title: { //标题
  23. type: String,
  24. default: '评语'
  25. },
  26. activeColor: { //星星颜色
  27. type: String,
  28. default: '#FA3534'
  29. },
  30. count: { //最多星星数
  31. type: String | Number,
  32. default: 5
  33. },
  34. rateNumProp: { //默认分数
  35. type: String | Number,
  36. default: 0
  37. },
  38. placeholder: {
  39. type: String,
  40. default: '请输入您的评价!'
  41. },
  42. columns: {
  43. type: Array,
  44. default: () => []
  45. },
  46. },
  47. data() {
  48. return {
  49. isShow: false,
  50. rateNum: 0,
  51. textarea: '',
  52. item: {}
  53. }
  54. },
  55. methods: {
  56. open() {
  57. console.log('open');
  58. },
  59. show(item) {
  60. this.rateNum = this.rateNumProp
  61. this.textarea = ''
  62. this.item = item
  63. this.isShow = true;
  64. },
  65. close() {
  66. this.isShow = false
  67. },
  68. confirm() {
  69. let { rateNum, textarea } = this
  70. this.$emit('confirm', {
  71. rateNum, textarea, item: this.item
  72. })
  73. this.close()
  74. }
  75. }
  76. }
  77. </script>
  78. <style lang="scss" scoped>
  79. .rate-con {
  80. display: flex;
  81. flex-direction: column;
  82. align-items: center;
  83. padding: 10rpx 20rpx 20rpx 20rpx;
  84. .title {
  85. padding: 10rpx 0;
  86. }
  87. .rate-item {
  88. margin-top: 20rpx;
  89. width: 100%;
  90. padding-left: 20rpx;
  91. display: flex;
  92. }
  93. .textarea-box {
  94. width: 100%;
  95. margin-top: 10rpx;
  96. padding: 10rpx;
  97. box-sizing: border-box;
  98. }
  99. .operate-box {
  100. width: 100%;
  101. display: flex;
  102. }
  103. }
  104. </style>