12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485 |
- <template>
- <view v-show="display" class="tui-common-words-container">
- <view class="tui-common-words-box">
- <view class="tui-common-words-title">
- <view>请选择常用语</view>
- <view style="color: #006EFF; font-family: PingFangSC-Regular;" class="tui-common-words-close" @tap="handleClose">关闭</view>
- </view>
- <view class="tui-search-bar">
- <image class="tui-searchcion" src="/static/assets/serach-icon.svg"></image>
- <input class="tui-search-bar-input" :value="words" placeholder="请输入关键字搜索" @input="wordsInput" />
- </view>
- <scroll-view class="tui-common-words-list" scroll-y="true" enable-flex="true">
- <view v-for="(item, index) in commonWordsMatch" :key="index" class="tui-common-words-item" @tap="sendMessage" :data-words="item">{{ item }}</view>
- </scroll-view>
- </view>
- </view>
- </template>
- <script>
- const commonWordsList = [
- '你好在吗',
- '问题A',
- '问题B'
- ];
- export default {
- data() {
- return {
- words: '',
- commonWordsMatch: commonWordsList
- };
- },
- components: {},
- props: {
- display: {
- type: Boolean,
- default: false
- }
- },
- watch: {
- display: {
- handler: function(newVal) {
- // this.setData({
- // display: newVal
- // });
- },
- immediate: true
- }
- },
- methods: {
- handleClose() {
- this.$emit('close', {
- detail: {
- key: '0'
- }
- });
- },
- wordsInput(e) {
- (this.commonWordsMatch = []),
- commonWordsList.forEach(item => {
- if (item.indexOf(e.detail.value) > -1) {
- this.commonWordsMatch.push(item);
- }
- });
- this.setData({
- words: e.detail.value,
- commonWordsMatch: this.commonWordsMatch
- });
- },
- sendMessage(e) {
- this.$emit('sendMessage', {
- detail: {
- message: e.currentTarget.dataset.words
- }
- });
- }
- }
- };
- </script>
- <style>
- @import './index.css';
- </style>
|