CommentInput.vue 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697
  1. <template>
  2. <view class="input_bar" :style="{ bottom: kewbordHeight }">
  3. <u--input
  4. :focus="isFocus"
  5. :placeholder="placeholder || '评论'"
  6. border="none"
  7. v-model="value"
  8. @blur="isFocus = false"
  9. >
  10. </u--input>
  11. <!-- <u-button type="primary" text="发送" :loading="loading" :disabled="!value" loadingSize="12"
  12. @click="$emit('completeInput',value)" /> -->
  13. <image
  14. @click="$emit('completeInput', value)"
  15. src="https://bjyjb-1362704775.cos.ap-chongqing.myqcloud.com/shop/image/send_btn.png"
  16. alt=""
  17. srcset=""
  18. />
  19. </view>
  20. </template>
  21. <script>
  22. export default {
  23. components: {},
  24. props: {
  25. commenting: Boolean,
  26. loading: Boolean,
  27. placeholder: String,
  28. inDetails: Boolean,
  29. },
  30. data() {
  31. return {
  32. value: "",
  33. isFocus: false,
  34. kewbordHeight: 0,
  35. };
  36. },
  37. watch: {
  38. commenting(val) {
  39. if (val) {
  40. setTimeout(() => {
  41. this.isFocus = true;
  42. }, 20);
  43. } else {
  44. this.value = "";
  45. }
  46. },
  47. },
  48. methods: {
  49. // keyboard
  50. keyboardChangeHander({ height }) {
  51. this.kewbordHeight = `${height}px`;
  52. if (height > 0) {
  53. !this.inDetails && uni.hideTabBar();
  54. } else {
  55. this.$emit("hiddenInput");
  56. !this.inDetails && uni.showTabBar();
  57. }
  58. },
  59. setKeyboardListener() {
  60. uni.onKeyboardHeightChange(this.keyboardChangeHander);
  61. },
  62. disposeKeyboardListener() {
  63. uni.offKeyboardHeightChange(this.keyboardChangeHander);
  64. },
  65. },
  66. };
  67. </script>
  68. <style lang="scss" scoped>
  69. .input_bar {
  70. display: flex;
  71. justify-content: center;
  72. align-items: center;
  73. padding: 18rpx 24rpx;
  74. background-color: #f0f2f6;
  75. .u-input {
  76. flex: 1;
  77. height: 64rpx;
  78. background-color: #fff;
  79. }
  80. .u-button {
  81. height: 64rpx;
  82. width: 108rpx;
  83. margin-left: 24rpx;
  84. padding: 0;
  85. }
  86. image {
  87. margin-left: 16rpx;
  88. width: 26px;
  89. height: 26px;
  90. }
  91. }
  92. </style>