liuxiaolong
2019-05-06 3e0536f508aad49f743e7bfabca34e3980a1b6e2
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="swiper pr" style="float:left;width:45%;margin: 0px 0px">
    <swiper :options="swiperOption" ref="mySwiper">
      <!-- slides -->
      <swiper-slide
        class="row bg-white"
        v-for="(slide, index) in data"
        :style="slideWidth?`width:${slideWidth};`:''"
        :key="index"
      >
        <div
          style="margin:0px 2px;text-align:center;width:60px;height:60px"
          class="row bg-white"
          @click="updateFatherImg(index)"
        >
          <httpImg
            :class="select===index?'gaoliang':''"
            :src="slide.path"
            style="height:60px;max-width: 100%;max-height: 100%;"
          ></httpImg>
          <b-img
            v-if="select===index"
            style="margin:40px 0px 0px -18px;"
            src="/static/img/search/check.png"
            width="16px"
            height="16px"
          ></b-img>
        </div>
      </swiper-slide>
      <!-- Optional controls -->
      <div class="swiper-pagination" v-if="isShowPagination" slot="pagination"></div>
 
      <!-- <div class="swiper-scrollbar"   slot="scrollbar"></div> -->
    </swiper>
    <div
      class="swiper-button-prev"
      slot="button-prev"
      v-if="isShowButton"
      @click="swiper.slidePrev()"
    >
      <i style="margin:0px 0px 0px 5px;" class="fa fa-chevron-left"></i>
    </div>
    <div
      class="swiper-button-next"
      slot="button-next"
      v-if="isShowButton"
      @click="swiper.slideNext()"
    >
      <i style="margin:0px 0px 0px 20px;" class="fa fa-chevron-right"></i>
    </div>
 
    <!-- <b-img v-if="1===1" style="float:left;margin:-40px 325px;" src="/static/img/search/check.png" width="30px" height="30px" ></b-img> -->
  </div>
</template>
<script>
import 'swiper/dist/css/swiper.css'
import { swiper, swiperSlide } from 'vue-awesome-swiper'
import { addFromRetrieve } from '../../../../server/searchList/commomList.js'
export default {
  components: {
    swiper,
    swiperSlide,
    addFromRetrieve
  },
  props: {
    slideWidth: {
      default: '90px',
      type: String
    },
    isShowPagination: {
      default: false,
      type: Boolean
    },
    isShowButton: {
      default: true,
      type: Boolean
    },
    dataarray: {
      default: () => [],
      type: Array
    }
  },
  data() {
    return {
      data: [],
      url: '',
      swiperOption: {
        pagination: {
          el: '.swiper-pagination',
          clickable: true
        },
        slidesPerView: 'auto',
        spaceBetween: 0
      },
      select: 0
    }
  },
  methods: {
    async detail(obj) {},
    async searchPerson(obj) {},
    orbit(obj) {
      localStorage.removeItem('esList') // 清除esList
      localStorage.setItem('personId', obj.personId)
      let jsonstr = localStorage.getItem('sear')
      let json = JSON.parse(jsonstr)
      json.path = obj.picSmUrl
      localStorage.setItem('searParams', JSON.stringify(json))
      this.openNewWindowtab({
        urlStr: window.document.location.href.substring(
          0,
          window.document.location.href.indexOf('#') + 2
        ),
        query: 'tabType=map'
      })
    },
    async control(obj) {
      let json = {
        dbInfos: [
          {
            cluId: obj.cluster_id,
            devId: obj.indeviceid
          }
        ],
        imgUrl: obj.picSmUrl,
        featureBase64: obj.FaceFeature,
        idCard: obj.cardId ? obj.cardId : ''
      }
      let res = addFromRetrieve(json)
      if (res && res.success) {
        this.$toast({
          type: 'primary',
          message: '已加入待布控表',
          toastHorizontalPosition: 'right'
        })
      } else {
        this.$toast({
          type: 'error',
          message: '加入待布控表失败',
          toastHorizontalPosition: 'right'
        })
      }
    },
    setData(data) {},
    createList(datalist, index) {
      this.select = index
      this.data = datalist
      this.url = this.data[index].path
      this.swiper.slideTo(index, 1000, true)
      // this.$emit('changeimg', this.url)
    },
    // 修改 父级的图片显示
    updateFatherImg(index) {
      this.select = index
      this.url = this.data[index].path
      this.$emit('changeimg', this.url, index)
    }
  },
  computed: {
    swiper() {
      return this.$refs.mySwiper.swiper
    }
  },
  mounted() {
    // this.select = 0
    // // current swiper instance
    // // 然后你就可以使用当前上下文内的swiper对象去做你想做的事了
    // this.data = new Array(10)
    // for (let i = 0; i < this.data.length; i++) {
    //   if ((i & 1) === 1) {
    //     this.data[i] = '/static/img/1.jpg'
    //   } else {
    //     this.data[i] = '/static/img/timg.jpg'
    //   }
    // }
    // this.url = this.data[0]
    // this.$emit('changeimg', this.url)
    // this.swiper.slideTo(0, 1000, false)
    // console.log('this is current swiper instance object', this.swiper)
  }
}
</script>
<style lang="scss" scoped>
.swiper {
  .swiper-container {
    padding: 0 20px;
  }
  .swiper-button-prev,
  .swiper-button-next {
    background-image: none;
    display: block;
    i {
      font-size: 25px;
      color: #76bef7;
    }
  }
  .swiper-button-prev {
    left: -15px;
    top: 40px;
  }
  .swiper-button-next {
    right: -15px;
    top: 40px;
  }
  &:hover .swiper-button-prev,
  &:hover .swiper-button-next {
    display: block;
  }
  .msg {
    position: absolute;
    left: 0px;
    bottom: 2px;
    width: 50%;
  }
}
.gaoliang {
  border: 1px solid red;
}
.img43 {
  max-width: 100%;
  max-height: 100%;
}
.myion {
  width: 20px;
  height: 20px;
}
</style>