query-home.vue 10.1 KB
Newer Older
786817560's avatar
786817560 committed
1 2 3 4
<!--
   * @Descrip: 查询首页
 * @Author: your name
 * @Date: 2019-10-15 14:30:00
5
 * @LastEditTime: 2019-12-17 11:27:19
786817560's avatar
786817560 committed
6 7 8
 * @LastEditors: Please set LastEditors
   -->
<template>
Hello's avatar
Hello committed
9
  <h-view id="query-home" class="public-style" title="产品查询">
邹骏's avatar
邹骏 committed
10
    <h-header v-if="$route.path=='/query-home'" :proportion="[5,1,1]" class="bar-custom">
786817560's avatar
786817560 committed
11
      <div slot="left" class="h-header-btn">
786817560's avatar
786817560 committed
12
        <img src="@/assets/userBind/arrow.png" @click="$routeGo()">
邹骏's avatar
邹骏 committed
13
        <span>产品查询</span>
786817560's avatar
786817560 committed
14 15
      </div>
    </h-header>
邹骏's avatar
邹骏 committed
16 17 18
    <h-header v-if="$route.path=='/tab/query-home'" class="bar-custom">
      <div slot="center" class="top-word">产品中心</div>
    </h-header>
786817560's avatar
786817560 committed
19 20
    <!-- 搜索 -->
    <div class="search has-header">
jiacheng.mao's avatar
jiacheng.mao committed
21
      <input v-model="searchInput" type="text" placeholder="请输入产品名称">
786817560's avatar
786817560 committed
22 23 24 25 26 27 28 29 30
    </div>
    <scroll
      ref="scrollLists"
      :updateData="[prolists]"
      :pullUp="true"
      @pullingUp="loadMore"
    >
      <div class="scroll-box">
        <div v-for="(item,index) in prolists" :key="index" class="wrap">
邹骏's avatar
邹骏 committed
31
          <div class="box" @click="goLists(item.factory_bp_id)">
786817560's avatar
786817560 committed
32
            <div class="leftPic">
邹骏's avatar
邹骏 committed
33
              <img :src="item.url" alt="" class="leftPic">
786817560's avatar
786817560 committed
34 35 36 37
            </div>
            <div class="first">
              <p class="product">{{ item.factory_bp_name }}</p>
            </div>
Hello's avatar
Hello committed
38
            <img class="arrow" src="@/assets/productQuery/getIn.png" alt="">
786817560's avatar
786817560 committed
39
          </div>
786817560's avatar
786817560 committed
40
        </div>
786817560's avatar
786817560 committed
41 42
      </div>
    </scroll>
786817560's avatar
786817560 committed
43 44 45 46
  </h-view>
</template>

<script>
邹骏's avatar
邹骏 committed
47
import noImg from '../../assets/productQuery/none.png'
Hello's avatar
Hello committed
48

786817560's avatar
786817560 committed
49 50 51 52
export default {
  name: 'QueryHome',
  data () {
    return {
786817560's avatar
786817560 committed
53
      prolists: [],
786817560's avatar
786817560 committed
54 55 56
      divisionList: [],
      list_flag: false,
      factory_bp_id: '',
786817560's avatar
786817560 committed
57 58
      searchInput: '', // 搜索内容
      pagenum: 1,
786817560's avatar
786817560 committed
59 60 61
    }
  },
  computed: {},
786817560's avatar
786817560 committed
62 63 64 65 66 67 68 69 70 71 72
  watch: {
    searchInput () {
      let vm = this
      if (vm.timeout) {
        clearTimeout(vm.timeout)
      }
      vm.timeout = setTimeout(() => {
        vm.search()
      }, 1000)
    },
  },
786817560's avatar
786817560 committed
73
  beforeRouteEnter (to, from, next) {
Hello's avatar
Hello committed
74 75 76 77 78
    next(vm => {
      vm.searchInput = ''
      vm.pagenum = 1
      vm.proQuery()
    })
786817560's avatar
786817560 committed
79
  },
Hello's avatar
Hello committed
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
  methods: {
    // 初始产品查询
    proQuery () {
      let vm = this
      let url = $config.basePath + 'prd_product_type_list'
      let param = {
        searchInput: vm.searchInput,
        pagenum: vm.pagenum,
        pagesize: 10,
      }
      vm.hlsPopup.showLoading('数据加载中')
      vm.$post(url, param).then(function (res) {
        vm.hlsPopup.hideLoading()
        if (res.result === 'S') {
          vm.prolists = res.lists
          if (vm.prolists.length === 0) {
            vm.$refs.scrollLists.update(true)
          } else if (vm.prolists.length > 0 && vm.prolists.length < 10) {
            vm.prolists.forEach(item => {
              item['url'] = item.factory_attachment_id ? process.env.filePath + 'attachment_id=' + item.factory_attachment_id + '&access_token=' + window.localStorage.access_token : noImg
            })
            vm.$refs.scrollLists.update(true)
          } else if (vm.prolists.length === 10) {
            vm.prolists.forEach(item => {
              item['url'] = item.factory_attachment_id ? process.env.filePath + 'attachment_id=' + item.factory_attachment_id + '&access_token=' + window.localStorage.access_token : noImg
            })
            vm.$refs.scrollLists.update(false)
          }
          console.log(vm.prolists)
        } else {
          hlsPopup.showLongCenter(res.message)
        }
      })
    },
    // 跳列表 val = 产品线
    goLists (val) {
      this.$router.push({
        name: 'ProductList',
        params: {
          factory_bp_id: val,
        },
      })
    },
786817560's avatar
786817560 committed
123

Hello's avatar
Hello committed
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
    loadMore () {
      let vm = this
      vm.pagenum = vm.pagenum + 1
      let url = $config.basePath + 'prd_product_type_list'
      let param = {
        searchInput: vm.searchInput,
        pagenum: vm.pagenum,
        pagesize: 10,
      }
      vm.hlsPopup.showLoading('数据加载中')
      vm.$post(url, param).then(function (res) {
        vm.hlsPopup.hideLoading()
        let returnData = []
        if (res.result === 'S') {
          returnData = res.lists
          if (returnData.length === 0) {
            vm.$refs.scrollLists.update(true)
          } else if (returnData.length > 0 && returnData.length < 10) {
            returnData.forEach((data, index, array) => {
              vm.prolists.push(array[index])
            })
            vm.prolists.forEach(item => {
              item['url'] = item.factory_attachment_id ? process.env.filePath + 'attachment_id=' + item.factory_attachment_id + '&access_token=' + window.localStorage.access_token : noImg
            })
            vm.$refs.scrollLists.update(true)
          } else if (returnData.length === 10) {
            returnData.forEach((data, index, array) => {
              vm.prolists.push(array[index])
            })
            vm.prolists.forEach(item => {
              item['url'] = item.factory_attachment_id ? process.env.filePath + 'attachment_id=' + item.factory_attachment_id + '&access_token=' + window.localStorage.access_token : noImg
            })
            vm.$refs.scrollLists.update(false)
          }
        } else {
          hlsPopup.showLongCenter(res.message)
        }
      })
    },
    // 搜索
    search () {
      let vm = this
      vm.pagenum = 1
      let url = $config.basePath + 'prd_product_type_list'
      let param = {
        pagesize: 10,
        pagenum: vm.pagenum,
        searchInput: vm.searchInput,
      }
      vm.hlsPopup.showLoading('数据加载中')
      vm.hlsHttp.post(url, param).then(function (res) {
        vm.hlsPopup.hideLoading()
        vm.prolists = res.lists
        if (vm.prolists.length >= 0 && vm.prolists.length < 10) {
          vm.prolists.forEach(item => {
邹骏's avatar
邹骏 committed
179
            item['url'] = item.factory_attachment_id ? process.env.filePath + 'attachment_id=' + item.factory_attachment_id + '&access_token=' + window.localStorage.access_token : noImg
Hello's avatar
Hello committed
180 181 182 183
          })
          vm.$refs.scrollLists.update(true)
        } else if (vm.lists.length === 10) {
          vm.prolists.forEach(item => {
邹骏's avatar
邹骏 committed
184
            item['url'] = item.factory_attachment_id ? process.env.filePath + 'attachment_id=' + item.factory_attachment_id + '&access_token=' + window.localStorage.access_token : noImg
Hello's avatar
Hello committed
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
          })
          vm.$refs.scrollLists.update(false)
        }
      })
    },
    // 产品线查询val=主机厂id,ind=产品列表索引
    queryDivision (val, ind) {
      let vm = this
      let url = $config.basePath + 'prd_product_division_list'
      let param = {
        factory_bp_id: val,
      }
      vm.$post(url, param).then(function (res) {
        console.log(res)
        if (res.result === 'S') {
          vm.divisionList = res.lists.map(item => {
            return {
              code: item.division,
              code_name: item.product_line,
            }
          })
          //  vm.divisionList = res.lists
          vm.hlsPopup.selectList({
            list: vm.divisionList, // 下拉列表
            code: 'bp_type',
            object: {},
            returnItem: function (index, obj) {
              // 更改产品线(division)和 产品线描述(division_n)
              vm.prolists[ind].division_n = obj.bp_type_n
              vm.prolists[ind].division = obj.bp_type
            },
          })
        } else {
          hlsPopup.showLongCenter(res.message)
        }
      })
    },
  },
786817560's avatar
786817560 committed
223 224
}
</script>
786817560's avatar
786817560 committed
225
<style lang='less'>
Hello's avatar
Hello committed
226
  #query-home {
786817560's avatar
786817560 committed
227 228 229 230
    .search {
      background-color: #fff;
      padding: 8px 12px;
      position: absolute;
786817560's avatar
786817560 committed
231
      width: 100%;
786817560's avatar
786817560 committed
232 233
      z-index: 100;
      margin-bottom: 8px;
Hello's avatar
Hello committed
234

786817560's avatar
786817560 committed
235 236
      input {
        padding-left: 12px;
786817560's avatar
786817560 committed
237
        height: 36px;
786817560's avatar
786817560 committed
238
        width: 100%;
786817560's avatar
786817560 committed
239
        font-family: PingFangSC-Regular;
786817560's avatar
786817560 committed
240 241
        font-size: 14px;
        color: #21254c;
242
        line-height: 36px;
786817560's avatar
786817560 committed
243
        border-radius: 4px;
786817560's avatar
786817560 committed
244 245 246 247
        background: url("../../assets/contractStart/search1.png") 320px no-repeat;
        background-size: 16px 16px;
        background-color: rgba(239, 239, 239, 0.55);
      }
Hello's avatar
Hello committed
248

786817560's avatar
786817560 committed
249 250 251 252 253
      input::placeholder {
        font-family: PingFangSC-Regular;
        font-size: 14px;
        color: #888C8F;
        letter-spacing: 0;
786817560's avatar
786817560 committed
254
      }
Hello's avatar
Hello committed
255

786817560's avatar
786817560 committed
256
      input:focus {
邹骏's avatar
邹骏 committed
257 258 259 260 261
        background: url("../../assets/contractStart/search2.png") 320px no-repeat;
        background-size: 16px 16px;
        background-color: rgba(239, 239, 239, 0.55);
        border: 2px solid #bcc6ff;
      }
786817560's avatar
786817560 committed
262
    }
Hello's avatar
Hello committed
263

linxin's avatar
linxin committed
264 265 266
    .scroll-box {
      padding: 8px;
    }
Hello's avatar
Hello committed
267

786817560's avatar
786817560 committed
268
    .box {
邹骏's avatar
邹骏 committed
269 270 271 272 273 274 275 276 277
      width: 100%;
      height: 80px;
      background: #fff;
      margin-bottom: 8px;
      border-radius: 4px;
      display: flex;
      justify-content: center;
      align-items: center;
      padding: 20px;
Hello's avatar
Hello committed
278

邹骏's avatar
邹骏 committed
279 280 281 282
      .leftPic {
        height: 40px;
        width: 40px;
        border-radius: 8px;
Hello's avatar
Hello committed
283

邹骏's avatar
邹骏 committed
284 285 286
        img {
          height: 40px;
          width: 40px;
786817560's avatar
786817560 committed
287
        }
邹骏's avatar
邹骏 committed
288
      }
Hello's avatar
Hello committed
289

邹骏's avatar
邹骏 committed
290 291
      .first {
        flex-grow: 1;
jiacheng.mao's avatar
jiacheng.mao committed
292
        margin-left: 20px;
邹骏's avatar
邹骏 committed
293 294 295 296 297
        .product {
          font-family: PingFangSC-Regular;
          font-size: 14px;
          color: #383F45;
          text-align: left;
786817560's avatar
786817560 committed
298
        }
邹骏's avatar
邹骏 committed
299
      }
Hello's avatar
Hello committed
300

邹骏's avatar
邹骏 committed
301 302 303 304
      .arrow {
        height: 16px;
        width: 16px;
      }
786817560's avatar
786817560 committed
305
    }
Hello's avatar
Hello committed
306

邹骏's avatar
邹骏 committed
307
    .content {
786817560's avatar
786817560 committed
308
      position: absolute;
Hello's avatar
Hello committed
309
      top: 0;
786817560's avatar
786817560 committed
310
    }
Hello's avatar
Hello committed
311

邹骏's avatar
邹骏 committed
312
    .scrollContent {
Hello's avatar
Hello committed
313
      //padding-top: 1.92rem;
786817560's avatar
786817560 committed
314 315
      padding-bottom: 20px;
    }
Hello's avatar
Hello committed
316 317 318
  }

  .platform-ios {
786817560's avatar
786817560 committed
319 320 321 322 323 324
    #query {
      .scrollContent {
        padding-top: 2.32rem;
      }
    }
  }
Hello's avatar
Hello committed
325

786817560's avatar
786817560 committed
326 327 328 329 330 331 332 333 334 335
  // iPhoneX适配
  @media (device-width: 375px) and (device-height: 812px) and (-webkit-min-device-pixel-ratio: 3) {
    .platform-ios {
      #query {
        .scrollContent {
          padding-top: 2.72rem;
        }
      }
    }
  }
Hello's avatar
Hello committed
336

786817560's avatar
786817560 committed
337 338 339 340 341 342 343
  // iPhoneXR适配
  @media (device-width: 414px) and (device-height: 896px) {
    .platform-ios {
      #query {
        .scrollContent {
          padding-top: 2.72rem;
        }
Hello's avatar
Hello committed
344

345
        .search {
Hello's avatar
Hello committed
346 347 348 349 350 351 352 353 354 355 356
          input {
            background: url("../../assets/contractStart/search1.png") 320px no-repeat;
            background-size: 16px 16px;
            background-color: rgba(239, 239, 239, 0.55);
            padding: 8px 12px;
            border-radius: 4px;
            width: 100%;
            font-family: PingFangSC-Regular;
            font-size: 14px;
            color: #888c8f;
          }
357 358
        }
      }
786817560's avatar
786817560 committed
359 360
    }
  }
786817560's avatar
786817560 committed
361
</style>