index.vue 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192
  1. <template>
  2. <view v-show="display" class="tui-common-words-container">
  3. <view class="tui-common-words-box">
  4. <view class="tui-common-words-title">
  5. <view>请选择你要发送的常用语</view>
  6. <view style="color: #006EFF; font-family: PingFangSC-Regular;" class="tui-common-words-close" @tap="handleClose">关闭</view>
  7. </view>
  8. <view class="tui-search-bar">
  9. <image class="tui-searchcion" src="/static/static/assets/serach-icon.svg"></image>
  10. <input class="tui-search-bar-input" :value="words" placeholder="请输入您想要提出的问题" @input="wordsInput" />
  11. </view>
  12. <scroll-view class="tui-common-words-list" scroll-y="true" enable-flex="true">
  13. <view v-for="(item, index) in commonWordsMatch" :key="index" class="tui-common-words-item" @tap="sendMessage" :data-words="item">{{ item }}</view>
  14. </scroll-view>
  15. </view>
  16. </view>
  17. </template>
  18. <script>
  19. const commonWordsList = [
  20. '什么时候发货',
  21. '发什么物流',
  22. '为什么物流一直没更新',
  23. '最新优惠',
  24. '包邮吗',
  25. '修改地址信息',
  26. '修改收件人信息',
  27. '物流一直显示正在揽收',
  28. '问题A',
  29. '问题B'
  30. ];
  31. export default {
  32. data() {
  33. return {
  34. words: '',
  35. commonWordsMatch: commonWordsList
  36. };
  37. },
  38. components: {},
  39. props: {
  40. display: {
  41. type: Boolean,
  42. default: false
  43. }
  44. },
  45. watch: {
  46. display: {
  47. handler: function(newVal) {
  48. // this.setData({
  49. // display: newVal
  50. // });
  51. },
  52. immediate: true
  53. }
  54. },
  55. methods: {
  56. handleClose() {
  57. this.$emit('close', {
  58. detail: {
  59. key: '0'
  60. }
  61. });
  62. },
  63. wordsInput(e) {
  64. (this.commonWordsMatch = []),
  65. commonWordsList.forEach(item => {
  66. if (item.indexOf(e.detail.value) > -1) {
  67. this.commonWordsMatch.push(item);
  68. }
  69. });
  70. this.setData({
  71. words: e.detail.value,
  72. commonWordsMatch: this.commonWordsMatch
  73. });
  74. },
  75. sendMessage(e) {
  76. this.$emit('sendMessage', {
  77. detail: {
  78. message: e.currentTarget.dataset.words
  79. }
  80. });
  81. }
  82. }
  83. };
  84. </script>
  85. <style>
  86. @import './index.css';
  87. </style>