tanghaolin
2022-08-31 244c4241427b9f3316f06f1e0ae2ee571edc1a23
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
<template>
  <div class="findData_box">
    <!-- 头部导航栏 -->
    <van-nav-bar style="background-color:#528abe;">
      <template #left>
        <div @click="pageBack" style="display: flex; align-items: center">
          <van-icon  name="arrow-left" size="18" />
          <span>{{$t('selectPage.index.TR')}}</span>
        </div>
      </template>
      <template #title>
        <label>{{$t('ebookPage.search.TR')}}</label>
      </template>
      <template #right>
        <div></div>
      </template>
    </van-nav-bar>
    <div class="findData_main">
      <van-search v-model="m_keyWord" show-action :placeholder="$t('ebookPage.keyWordRule.TR')" @search="onSearch">
        <template #action>
          <div @click="onSearch">
            <span style="color:#36489e">{{$t('ebookPage.search.TR')}}</span>
          </div>
        </template>
      </van-search>
      <!-- 历史记录列表 -->
      <div class="history_record" v-if="m_historyKeyWords.length>0">
        <div class="recode_btn">
          <span>搜索历史</span>
          <van-icon name="delete-o" @click="deletedHistoryTag" />
        </div>
        <div class="tag_list">
          <van-tag
            v-for="(tagItem,index) in m_historyKeyWords"
            @click="changeTagSearch(tagItem)"
            :key="index"
            round
            type="primary"
            style="margin-right:5px;"
          >{{tagItem}}</van-tag>
        </div>
      </div>
      <div class="data_list">
        <van-cell
          @click="goPumpDetail(item)"
          clickable
          center
          is-link
          title-style="color:#528abe"
          :title="item.Name"
          :label="item.CatalogName"
          v-for="(item, index) in m_dataList"
          :key="index"
        >
          <template #icon>
            <van-image
          width="80"
          height="50"
          :src="item.ThumbnailImage"
          >
            </van-image>
          </template>
        </van-cell>
      </div>
    </div>
  </div>
</template>
 
<script>
import languageMixin from "@/mixin/language.js";
 
export default {
  mixins: [languageMixin],
  data() {
    return {
      m_Title:"",
      m_keyWord: "", //关键词
      m_historyKeyWords: [], //历史关键词记录
      m_dataList: [] //查询出来的列表
    };
  },
  mounted() {
    this.m_Title =  this.getSoftName();
    document.title = this.m_Title
    if (this.$cookies.isKey("historyRecord")) {
      //console.log(this.$cookies.get("historyRecord"),74)
      this.m_historyKeyWords = this.$cookies.get("historyRecord").split(",");
    }
  },
  methods: {
    onSearch() {
      let _this = this;
      let Toast = _this.$toast;
      Toast.loading({
        duration: 0, //为0时 不关闭toast框
        message: "Loading...",
        forbidClick: true
      });
      _this
        .$axios({
          methods: "get",
          url:
            _this.$globalConfig.WebApiUrl.MainUrl + "v1/Mobile/FilterByKeyWrd/GetList",
          params: {
            KeyWord: _this.m_keyWord,
            Lang: _this.getCurrentLanguageUrl()
          }
        })
        .then(function(res) {
          Toast.clear();
          //console.log(res);
          let result = res.data;
          if (result.Code != 0) {
            Toast.fail(result.Message);
            return;
          }
          if (result.Data) {
            if (_this.m_historyKeyWords.indexOf(_this.m_keyWord) == -1) {
              _this.m_historyKeyWords.push(_this.m_keyWord);
            }
 
            _this.$cookies.set("historyRecord", _this.m_historyKeyWords);
            let seriesList = [];
            result.Data.forEach(item => {
              let productItem = {
                ObjectType: item.ObjectType,
                PumpID: item.PumpID,
                SeriesID: item.SeriesID,
                CatalogName: item.CatalogName,
                Name: item.Name,
                ThumbnailImage: _this.$globalConfig.WebApiUrl.FileUrl + item.ThumbnailImage,
                Description: item.Description
              };
              seriesList.push(productItem);
            });
            _this.m_dataList = seriesList;
 
            //console.log(Object.entries(_this.m_ShowSeriesList), 80);
          }
        })
        .catch(function(err) {
          Toast.clear();
          console.log(err);
        });
    },
    //点击历史记录标签搜索
    changeTagSearch(name) {
      this.m_keyWord = name;
      this.onSearch();
    },
    //删除历史记录标签
    deletedHistoryTag() {
      this.m_historyKeyWords = [];
      this.$cookies.remove("historyRecord");
    },
    //跳转到详情
    goPumpDetail(item) {
      // console.log(item, 204);
      if (item.ObjectType != 0) {
        let query = { SID: item.SeriesID, PID: item.PumpID }
        this.gotoPage("/byParas/Index", query, null);
      } else if (item.ObjectType == 0) {
        let query = { ID: item.SeriesID }
        this.gotoPage("/EBook/SeriesDetailPump", query, null);
      }
    },
    //返回上一页
    pageBack() {
      this.$router.go(-1);
    }
  }
};
</script>
 
<style lang="scss">
.findData_box {
  width: 100%;
  height: 100vh;
  background-color: #fafafa;
  .findData_main {
    width: 100%;
    height: calc(100% - 46px);
    background-color: #fafafa;
    .history_record {
      width: 100%;
      height: 45px;
      .recode_btn {
        width: 96%;
        height: 30%;
        display: flex;
        justify-content: space-between;
        align-items: center;
        padding-top: 5px;
        padding-left: 10px;
        span {
          font-size: 12px;
          color: #aaaaaa;
        }
      }
      .tag_list {
        width: 96%;
        display: flex;
        height: 70%;
        align-items: center;
        padding-left: 10px;
      }
    }
    .data_list {
      width: 100%;
      height: calc(100% - 100px);
      overflow: auto;
      margin-top: 1px;
      .van-cell__title,
      .van-cell__value {
        display: flex;
        align-items: flex-start;
        flex-direction: column;
      }
      .van-index-anchor {
        text-align: left;
        font-weight: 600;
      }
    }
  }
}
</style>