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
786817560's avatar
786817560 committed
5
 * @LastEditTime: 2019-11-22 09:45:40
786817560's avatar
786817560 committed
6 7 8 9 10 11
 * @LastEditors: Please set LastEditors
   -->
<template>
  <h-view id="query" class="public-style" title="产品查询">
    <h-header :proportion="[5,1,1]" class="bar-custom">
      <div slot="left" class="h-header-btn">
786817560's avatar
786817560 committed
12
        <img src="@/assets/userBind/arrow.png" @click="$routeGo()">
786817560's avatar
786817560 committed
13
        <span>产品选择</span>
786817560's avatar
786817560 committed
14 15
      </div>
    </h-header>
786817560's avatar
786817560 committed
16 17 18 19 20 21 22 23 24 25 26
    <!-- 搜索 -->
    <div class="search has-header">
      <input v-model="searchInput" type="text" placeholder="请输入产品类别/产品线">
    </div>
    <scroll
      ref="scrollLists"
      :updateData="[prolists]"
      :pullUp="true"
      @pullingUp="loadMore"
    >
      <div class="scroll-box">
786817560's avatar
786817560 committed
27

786817560's avatar
786817560 committed
28
        <div v-for="(item,index) in prolists" :key="index" class="wrap">
linxin's avatar
linxin committed
29

786817560's avatar
786817560 committed
30 31
          <div class="box" @click="goLists(item.division)">
            <div class="leftPic">
linxin's avatar
linxin committed
32

786817560's avatar
786817560 committed
33 34 35 36 37 38 39 40 41 42
              <img src="@/assets/productQuery/product-query.png" alt="" class="leftPic">
            </div>
            <div class="first">
              <p class="product-class">主机厂</p>
              <p class="product">{{ item.factory_bp_name }}</p>
            </div>
            <div class="second">
              <p class="product-class">产品名称</p>
              <div class="product">
                <p>{{ item.division_n }}</p>
linxin's avatar
linxin committed
43
              </div>
786817560's avatar
786817560 committed
44
              <img src="@/assets/productQuery/down.png" alt="" @click.stop="queryDivision(item.factory_bp_id,index)">
786817560's avatar
786817560 committed
45
            </div>
786817560's avatar
786817560 committed
46
            <!-- <img class="arrow" src="@/assets/productQuery/getIn.png" alt="" > -->
786817560's avatar
786817560 committed
47
          </div>
786817560's avatar
786817560 committed
48
        </div>
786817560's avatar
786817560 committed
49 50
      </div>
    </scroll>
786817560's avatar
786817560 committed
51 52 53 54 55 56 57 58
  </h-view>
</template>

<script>
export default {
  name: 'QueryHome',
  data () {
    return {
786817560's avatar
786817560 committed
59
      prolists: [],
786817560's avatar
786817560 committed
60 61 62
      divisionList: [],
      list_flag: false,
      factory_bp_id: '',
786817560's avatar
786817560 committed
63 64
      searchInput: '', // 搜索内容
      pagenum: 1,
786817560's avatar
786817560 committed
65 66 67
    }
  },
  computed: {},
786817560's avatar
786817560 committed
68 69 70 71 72 73 74 75 76 77 78
  watch: {
    searchInput () {
      let vm = this
      if (vm.timeout) {
        clearTimeout(vm.timeout)
      }
      vm.timeout = setTimeout(() => {
        vm.search()
      }, 1000)
    },
  },
786817560's avatar
786817560 committed
79 80 81
  beforeRouteEnter (to, from, next) {
    if (from.name === 'HomePage') {
      next(vm => {
786817560's avatar
786817560 committed
82 83
        vm.searchInput = ''
        vm.pagenum = 1
786817560's avatar
786817560 committed
84 85 86 87 88
        vm.proQuery()
      })
    }
    next()
  },
786817560's avatar
786817560 committed
89 90
  methods:
 {
786817560's avatar
786817560 committed
91
   // 初始产品查询
786817560's avatar
786817560 committed
92 93 94
   proQuery () {
     let vm = this
     let url = $config.basePath + 'prd_product_type_list'
786817560's avatar
786817560 committed
95 96 97 98 99
     let param = {
       searchInput: vm.searchInput,
       pagenum: vm.pagenum,
       pagesize: 10,
     }
786817560's avatar
786817560 committed
100
     vm.hlsPopup.showLoading('数据加载中')
786817560's avatar
786817560 committed
101
     vm.$post(url, param).then(function (res) {
786817560's avatar
786817560 committed
102
       vm.hlsPopup.hideLoading()
786817560's avatar
786817560 committed
103 104
       if (res.result === 'S') {
         vm.prolists = res.lists
786817560's avatar
786817560 committed
105 106 107 108 109 110 111
         if (vm.prolists.length === 0) {
           vm.$refs.scrollLists.update(true)
         } else if (vm.prolists.length > 0 && vm.prolists.length < 10) {
           vm.$refs.scrollLists.update(true)
         } else if (vm.prolists.length === 10) {
           vm.$refs.scrollLists.update(false)
         }
786817560's avatar
786817560 committed
112 113 114 115 116
       } else {
         hlsPopup.showLongCenter(res.message)
       }
     })
   },
786817560's avatar
786817560 committed
117
   // 跳列表 val = 产品线
786817560's avatar
786817560 committed
118
   goLists (val) {
786817560's avatar
786817560 committed
119
     this.$router.push({
786817560's avatar
786817560 committed
120
       name: 'ProductList',
786817560's avatar
786817560 committed
121 122 123
       params: {
         division: val,
       },
786817560's avatar
786817560 committed
124 125
     })
   },
786817560's avatar
786817560 committed
126

786817560's avatar
786817560 committed
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
   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.$refs.scrollLists.update(true)
         } else if (returnData.length === 10) {
           returnData.forEach((data, index, array) => {
             vm.prolists.push(array[index])
           })
           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.$refs.scrollLists.update(true)
       } else if (vm.lists.length === 10) {
         vm.$refs.scrollLists.update(false)
       }
     })
   },
786817560's avatar
786817560 committed
181
   // 产品线查询val=主机厂id,ind=产品列表索引
786817560's avatar
786817560 committed
182
   queryDivision (val, ind) {
786817560's avatar
786817560 committed
183 184 185 186 187 188 189 190
     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') {
786817560's avatar
786817560 committed
191 192 193 194 195 196 197 198 199 200 201 202
         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) {
786817560's avatar
786817560 committed
203
             // 更改产品线(division)和 产品线描述(division_n)
786817560's avatar
786817560 committed
204 205 206 207
             vm.prolists[ind].division_n = obj.bp_type_n
             vm.prolists[ind].division = obj.bp_type
           },
         })
786817560's avatar
786817560 committed
208 209 210 211 212
       } else {
         hlsPopup.showLongCenter(res.message)
       }
     })
   },
786817560's avatar
786817560 committed
213

786817560's avatar
786817560 committed
214 215 216
 },
}
</script>
786817560's avatar
786817560 committed
217
<style lang='less'>
786817560's avatar
786817560 committed
218
#query {
786817560's avatar
786817560 committed
219 220 221 222
    .search {
      background-color: #fff;
      padding: 8px 12px;
      position: absolute;
786817560's avatar
786817560 committed
223
      width: 100%;
786817560's avatar
786817560 committed
224 225 226 227 228
      z-index: 100;
      margin-bottom: 8px;

      input {
        padding-left: 12px;
786817560's avatar
786817560 committed
229
        height: 36px;
786817560's avatar
786817560 committed
230
        width: 100%;
786817560's avatar
786817560 committed
231
        font-family: PingFangSC-Regular;
786817560's avatar
786817560 committed
232 233
        font-size: 14px;
        color: #21254c;
786817560's avatar
786817560 committed
234
        // line-height: 36px;
786817560's avatar
786817560 committed
235
        border-radius: 4px;
786817560's avatar
786817560 committed
236 237 238 239
        background: url("../../assets/contractStart/search1.png") 320px no-repeat;
        background-size: 16px 16px;
        background-color: rgba(239, 239, 239, 0.55);
      }
786817560's avatar
786817560 committed
240

786817560's avatar
786817560 committed
241 242 243 244 245
      input::placeholder {
        font-family: PingFangSC-Regular;
        font-size: 14px;
        color: #888C8F;
        letter-spacing: 0;
786817560's avatar
786817560 committed
246
      }
786817560's avatar
786817560 committed
247 248 249 250 251 252 253

      input:focus {
      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
254
    }
linxin's avatar
linxin committed
255 256 257
    .scroll-box {
      padding: 8px;
    }
786817560's avatar
786817560 committed
258 259 260
    .box {
        position: relative;
        width: 100%;
linxin's avatar
linxin committed
261
        height: 85px;
786817560's avatar
786817560 committed
262 263 264
        background: #fff;
        border-top: 1px solid #cccccc70;
        margin-bottom: 8px;
786817560's avatar
786817560 committed
265
        border-radius: 4px;
linxin's avatar
linxin committed
266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285
        display: flex;
        flex-direction: column;
        justify-content: center;
        align-items: center;
        .leftPic {
          position: absolute;
          left: 12px;
          top:29px;
          height: 26px;
          width: 26px;
          background: rgba(29, 63, 255, 0.1);
          border-radius: 8px;
          img {
            height: 16px;
            width: 16px;
            position: absolute;
            left: 5px;
            top: 5px;
          }
        }
786817560's avatar
786817560 committed
286
        .first {
linxin's avatar
linxin committed
287 288 289 290 291 292 293 294 295 296
            height: 42px;
            line-height: 42px;
            width: 80%;
            position: absolute;
            left: 50px;
            top: 0;
            border-bottom: 1px solid #F3F3F7;
            // display: flex;
            // flex-direction: row;
            //margin-top: 16px;
786817560's avatar
786817560 committed
297 298 299 300
            .product-class {
                font-family: PingFangSC-Regular;
                font-size: 14px;
                color: rgba(56,63,69,0.60);
linxin's avatar
linxin committed
301
                position: absolute;
786817560's avatar
786817560 committed
302 303 304 305 306
            }
            .product {
                font-family: PingFangSC-Regular;
                font-size: 14px;
                color: #383F45;
linxin's avatar
linxin committed
307 308
                position: absolute;
                right: 0px;
786817560's avatar
786817560 committed
309 310 311
            }
        }
        .second {
linxin's avatar
linxin committed
312 313 314 315 316 317
            height: 42px;
            line-height: 42px;
            width: 80%;
            position: absolute;
            left: 50px;
            top: 43px;
786817560's avatar
786817560 committed
318 319 320 321
            .product-class {
                font-family: PingFangSC-Regular;
                font-size: 14px;
                color: rgba(56,63,69,0.60);
linxin's avatar
linxin committed
322
                position: absolute;
786817560's avatar
786817560 committed
323 324 325 326 327
            }
            .product {
                font-family: PingFangSC-Regular;
                font-size: 14px;
                color: #383F45;
linxin's avatar
linxin committed
328 329
                position: absolute;
                right: 30px;
786817560's avatar
786817560 committed
330
                }
786817560's avatar
786817560 committed
331 332 333
            img {
                width: 16px;
                height: 16px;
linxin's avatar
linxin committed
334 335 336
                position: absolute;
                right: 0;
                top: 12px;
786817560's avatar
786817560 committed
337 338 339 340 341 342 343 344 345 346 347
            }
        }
        .arrow {
            position: absolute;
            top: 50%;
            margin-top: -8px;
            right: 20px;
            height: 16px;
            width: 16px;
        }
    }
786817560's avatar
786817560 committed
348 349 350 351 352 353 354 355
    .content{
      position: absolute;
      top:0;
    }
    .scrollContent{
     padding-top: 1.92rem;
      padding-bottom: 20px;
    }
786817560's avatar
786817560 committed
356
}
786817560's avatar
786817560 committed
357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383
.platform-ios {
    #query {
      .scrollContent {
        padding-top: 2.32rem;
      }
    }
  }
  // iPhoneX适配
  @media (device-width: 375px) and (device-height: 812px) and (-webkit-min-device-pixel-ratio: 3) {
    .platform-ios {
      #query {
        .scrollContent {
          padding-top: 2.72rem;
        }
      }
    }
  }
  // iPhoneXR适配
  @media (device-width: 414px) and (device-height: 896px) {
    .platform-ios {
      #query {
        .scrollContent {
          padding-top: 2.72rem;
        }
      }
    }
  }
786817560's avatar
786817560 committed
384
</style>