gui-submit-comment.vue 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119
  1. <template>
  2. <gui-popup
  3. ref="guipopupforsubcomment"
  4. position="bottom"
  5. :canCloseByShade="true"
  6. @close="closePop"
  7. :zIndex="zIndex">
  8. <view
  9. class="gui-comments gui-bg-white gui-dark-bg-level-1"
  10. @tap.stop.prevent="stopfun">
  11. <text
  12. class="gui-comments-at gui-block gui-primary-color"
  13. v-if="comment.at != ''">@ {{comment.at}}</text>
  14. <view
  15. style="height:20rpx;"
  16. v-if="comment.at == ''"></view>
  17. <view
  18. class="gui-flex gui-row gui-nowrap gui-space-between">
  19. <view
  20. class="gui-comments-img gui-relative"
  21. v-if="comment.img != ''">
  22. <image
  23. :src="comment.img"
  24. class="gui-comments-img-in"
  25. mode="widthFix"></image>
  26. <text
  27. class="gui-comments-img-remove gui-icons"
  28. @tap="removeImg"
  29. :style="{color:removeBtnColor}">&#xe78a;</text>
  30. </view>
  31. <textarea
  32. :show-confirm-bar="false"
  33. cursor-spacing="200"
  34. v-model="comment.content"
  35. class="gui-comments-textarea gui-border-box gui-bg-gray gui-dark-bg-level-2"
  36. :placeholder="placeholder" />
  37. </view>
  38. <view class="gui-flex gui-row gui-space-between gui-align-items-center">
  39. <text
  40. class="gui-comments-btns gui-icons gui-color-gray"
  41. @tap="selectImg"
  42. v-if="isImg">&#xe63d;</text>
  43. <text class="gui-comments-btns"
  44. v-if="!isImg"></text>
  45. <view class="gui-comments-submit"
  46. hover-class="gui-tap">
  47. <text
  48. class="gui-comments-btns gui-comments-submit gui-icons gui-primary-color"
  49. @tap="submit">提交</text>
  50. </view>
  51. </view>
  52. <gui-iphone-bottom v-if="!isSwitchPage"></gui-iphone-bottom>
  53. </view>
  54. </gui-popup>
  55. </template>
  56. <script>
  57. export default{
  58. name : "gui-submit-comment",
  59. props : {
  60. placeholder : { type : String, default : "说点什么吧"},
  61. isImg : { type : Boolean, default : true},
  62. removeBtnColor : { type : String, default : '#FF0036'},
  63. zIndex : { type : Number, default : 999},
  64. isSwitchPage : { type : Boolean, default : false},
  65. },
  66. data() {
  67. return {
  68. comment : {img:'', content:'',at:''}
  69. }
  70. },
  71. methods:{
  72. open : function(){
  73. this.$refs.guipopupforsubcomment.open();
  74. },
  75. close : function(){
  76. this.$refs.guipopupforsubcomment.close();
  77. this.$emit('close');
  78. },
  79. closePop : function(){
  80. this.$emit('close');
  81. },
  82. stopfun : function(e){
  83. e.stopPropagation();
  84. return null;
  85. },
  86. submit : function () {
  87. this.$emit('submit', this.comment);
  88. this.close();
  89. this.comment = {img:'', content:'',at:''}
  90. },
  91. selectImg : function(){
  92. uni.chooseImage({
  93. count:1,
  94. success:(res)=>{this.comment.img = res.tempFilePaths[0];}
  95. });
  96. },
  97. removeImg : function () {
  98. this.comment.img = '';
  99. },
  100. setAt : function(name){
  101. this.comment.at = name;
  102. },
  103. setContent : function (content) {
  104. this.comment.content = content;
  105. }
  106. },
  107. emits : ['close', 'submit']
  108. }
  109. </script>
  110. <style scoped>
  111. .gui-comments{padding:10rpx 30rpx;}
  112. .gui-comments-at{line-height:80rpx; height:80rpx; font-size:28rpx; font-weight:bold;}
  113. .gui-comments-textarea{width:200rpx; border-radius:8rpx; padding:15rpx; font-size:26rpx; line-height:36rpx; height:160rpx; flex:1;}
  114. .gui-comments-img{width:160rpx; height:160rpx; margin-right:25rpx; font-size:0; overflow:hidden; border-radius:8rpx;}
  115. .gui-comments-img-in{width:160rpx;}
  116. .gui-comments-img-remove{width:60rpx; height:60rpx; line-height:60rpx; position:absolute; right:0; top:0; text-align:center; font-size:50rpx; color:#FF0036;}
  117. .gui-comments-btns{width:96rpx; height:80rpx; line-height:80rpx; font-size:44rpx;}
  118. .gui-comments-submit{width:180rpx; text-align:right; font-size:28rpx;}
  119. </style>