图书馆小程序
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.

86 lines
1.8 KiB

2 weeks ago
1 week ago
2 weeks ago
  1. <template>
  2. <!-- :style="{ bottom: bottom + 'px' }" -->
  3. <view class="comment-container" >
  4. <uni-easyinput
  5. v-model="value"
  6. type="textarea"
  7. placeholder="HI,请留下您的留言吧!"
  8. :inputBorder="false"
  9. ></uni-easyinput>
  10. <button class="commit" type="primary" :disabled="!value" @click="onBtnClick">
  11. 提交
  12. </button>
  13. </view>
  14. </template>
  15. <script>
  16. import { userArticleComment } from 'api/user';
  17. export default {
  18. name: 'article-comment-commit',
  19. props: {
  20. },
  21. data() {
  22. return {
  23. value: '',
  24. bottom: 0
  25. };
  26. },
  27. created() {
  28. // 检测软键盘的变化
  29. uni.onKeyboardHeightChange(({ height }) => {
  30. this.bottom = height;
  31. });
  32. },
  33. methods: {
  34. /**
  35. * 发送按钮点击事件
  36. */
  37. async onBtnClick() {
  38. // 展示加载框
  39. uni.showLoading({
  40. title: '加载中'
  41. });
  42. // 异步处理即可
  43. // const { data: res } = await userArticleComment({
  44. // articleId: this.articleId,
  45. // content: this.value
  46. // });
  47. console.log('this.value',this.value)
  48. uni.showToast({
  49. title: '发表成功',
  50. icon: 'success',
  51. mask: true
  52. });
  53. // 发表成功之后的回调
  54. this.$emit('success', res);
  55. }
  56. }
  57. };
  58. </script>
  59. <style lang="scss" scoped>
  60. .comment-container {
  61. position: relative;
  62. padding: 10px;
  63. ::v-deep .uni-easyinput{
  64. width: calc(100% - 20px) !important;
  65. background-color: #fff;
  66. padding: 12px;
  67. box-shadow: 0px 3px 60px 1px rgba(0,0,0,0.08);
  68. border-radius: 6px;
  69. }
  70. ::v-deep .uni-easyinput__content{
  71. padding: 5px 10px !important;
  72. background: #F1F1F9 !important;
  73. }
  74. ::v-deep .uni-easyinput__content-textarea{
  75. height: 140px !important;
  76. }
  77. .commit{
  78. margin: 40px 20px 0 20px;
  79. background-color: #01a4fe;
  80. border-radius: 23px;
  81. }
  82. }
  83. </style>