Commit 091a27acfe02b50a1570f40f0fade4135596ceb6
Merge branch 'version_2.0.0_optimization_mall_update' of http://bj.gitlab.cnlive…
….com/w-front-end/select_good into version_2.0.0_optimization_mall_update
Showing
4 changed files
with
71 additions
and
31 deletions
src/components/searchBar/searchBar.less
src/pages/labourUnion/labourUnion.vue
| @@ -49,7 +49,7 @@ | @@ -49,7 +49,7 @@ | ||
| 49 | <div class="buttons-box"> | 49 | <div class="buttons-box"> |
| 50 | <div class="btn btn-active" @click="toOrderList"> | 50 | <div class="btn btn-active" @click="toOrderList"> |
| 51 | <div class="text">购买记录</div> | 51 | <div class="text">购买记录</div> |
| 52 | - <img src="static/img/icon_arrow_right_color.png" class="icon" mode="aspectFill" /> | 52 | + <img src="/static/img/icon_arrow_right_color.png" class="icon" mode="aspectFill" /> |
| 53 | </div> | 53 | </div> |
| 54 | </div> | 54 | </div> |
| 55 | </div> | 55 | </div> |
src/pages/labourUnionSearch/labourUnionSearch.vue
| @@ -51,7 +51,7 @@ | @@ -51,7 +51,7 @@ | ||
| 51 | </template> | 51 | </template> |
| 52 | 52 | ||
| 53 | <!-- 没有搜索数据 --> | 53 | <!-- 没有搜索数据 --> |
| 54 | - <template v-else-if="tabs && tabs.keyword"> | 54 | + <template v-else-if="tabs && tabs.keyword && initialized"> |
| 55 | 55 | ||
| 56 | <!-- 未找到您搜索的内容 --> | 56 | <!-- 未找到您搜索的内容 --> |
| 57 | <div class="no-data"> | 57 | <div class="no-data"> |
| @@ -131,6 +131,7 @@ | @@ -131,6 +131,7 @@ | ||
| 131 | navsSearch: null, // 导航栏对象 | 131 | navsSearch: null, // 导航栏对象 |
| 132 | searchHistoryArr: [], // 搜索历史记录数组 | 132 | searchHistoryArr: [], // 搜索历史记录数组 |
| 133 | tabs: {}, // tabsBar数据对象 | 133 | tabs: {}, // tabsBar数据对象 |
| 134 | + initialized: false, // 已初始化过标识,默认false | ||
| 134 | interface: 'goodsSearch', // 列表页接口名称 | 135 | interface: 'goodsSearch', // 列表页接口名称 |
| 135 | lists: [] // 列表数据 | 136 | lists: [] // 列表数据 |
| 136 | } | 137 | } |
| @@ -304,6 +305,9 @@ | @@ -304,6 +305,9 @@ | ||
| 304 | // 获取数据列表失败 | 305 | // 获取数据列表失败 |
| 305 | Toast('获取数据列表失败'); | 306 | Toast('获取数据列表失败'); |
| 306 | } | 307 | } |
| 308 | + | ||
| 309 | + // 设置已初始化过 | ||
| 310 | + this.$set(this, 'initialized', true); | ||
| 307 | }, | 311 | }, |
| 308 | 312 | ||
| 309 | /** | 313 | /** |
| @@ -340,51 +344,58 @@ | @@ -340,51 +344,58 @@ | ||
| 340 | * @param {String} keyword [搜索关键字] | 344 | * @param {String} keyword [搜索关键字] |
| 341 | */ | 345 | */ |
| 342 | doSearch(keyword) { | 346 | doSearch(keyword) { |
| 343 | - console.log(keyword); | 347 | + |
| 344 | if (this.debug) { | 348 | if (this.debug) { |
| 345 | console.log('doSearch', keyword); | 349 | console.log('doSearch', keyword); |
| 346 | } | 350 | } |
| 347 | 351 | ||
| 348 | // 判断必要参数 | 352 | // 判断必要参数 |
| 349 | - if (keyword && typeof keyword === 'string' && keyword.trim()) { | 353 | + if (keyword && typeof keyword === 'string' && keyword.trim()) { |
| 350 | 354 | ||
| 351 | - // 清空列表 | ||
| 352 | - this.$set(this, 'lists', []); | 355 | + // 清空列表 |
| 356 | + this.$set(this, 'lists', []); | ||
| 353 | 357 | ||
| 354 | - // 初始化tabs对象 | ||
| 355 | - this.setTabs(keyword); | 358 | + // 初始化tabs对象 |
| 359 | + this.setTabs(keyword); | ||
| 356 | 360 | ||
| 357 | - /* 记录搜搜历史 开始 */ | 361 | + /* 记录搜搜历史 开始 */ |
| 358 | 362 | ||
| 359 | - // 最多8个历史搜索结果 | ||
| 360 | - if (this.searchHistoryArr.length >= 8) { | 363 | + // 最多8个历史搜索结果 |
| 364 | + if (this.searchHistoryArr.length >= 8) { | ||
| 361 | 365 | ||
| 362 | - // 弹出一个数据 | ||
| 363 | - this.searchHistoryArr.pop(); | ||
| 364 | - } | 366 | + // 弹出一个数据 |
| 367 | + this.searchHistoryArr.pop(); | ||
| 368 | + } | ||
| 365 | 369 | ||
| 366 | - // 向前插入搜索历史 | ||
| 367 | - this.searchHistoryArr.unshift(keyword); | 370 | + // 向前插入搜索历史 |
| 371 | + this.searchHistoryArr.unshift(keyword); | ||
| 368 | 372 | ||
| 369 | - // 搜索历史放入Storage中 | ||
| 370 | - this.setSearchHistoryArr(keyword); | 373 | + // 搜索历史放入Storage中 |
| 374 | + this.setSearchHistoryArr(keyword); | ||
| 371 | 375 | ||
| 372 | - /* 记录搜搜历史 结束 */ | 376 | + /* 记录搜搜历史 结束 */ |
| 373 | 377 | ||
| 374 | - // 下一周期执行 | ||
| 375 | - this.$nextTick(() => { | 378 | + // 下一周期执行 |
| 379 | + this.$nextTick(() => { | ||
| 376 | 380 | ||
| 377 | - // 请求搜索接口 | ||
| 378 | - this.getLists(this.tabs, this.CALL_STATUS.INIT); | ||
| 379 | - }); | ||
| 380 | - } | 381 | + // 请求搜索接口 |
| 382 | + this.getLists(this.tabs, this.CALL_STATUS.INIT); | ||
| 383 | + }); | ||
| 384 | + } | ||
| 381 | }, | 385 | }, |
| 382 | - /** | 386 | + |
| 387 | + /** | ||
| 383 | * 搜索异常 | 388 | * 搜索异常 |
| 384 | */ | 389 | */ |
| 385 | - exceptions(){ | ||
| 386 | - Toast("请输入要搜索的商品"); | ||
| 387 | - }, | 390 | + exceptions() { |
| 391 | + | ||
| 392 | + // 提示 | ||
| 393 | + Toast("请输入要搜索的商品"); | ||
| 394 | + | ||
| 395 | + // 设置未初始化过 | ||
| 396 | + this.$set(this, 'initialized', false); | ||
| 397 | + }, | ||
| 398 | + | ||
| 388 | /** | 399 | /** |
| 389 | * 清除输入框事件监听 | 400 | * 清除输入框事件监听 |
| 390 | */ | 401 | */ |
| @@ -399,6 +410,9 @@ | @@ -399,6 +410,9 @@ | ||
| 399 | 410 | ||
| 400 | // 初始化tabs对象 | 411 | // 初始化tabs对象 |
| 401 | this.setTabs(); | 412 | this.setTabs(); |
| 413 | + | ||
| 414 | + // 设置未初始化过 | ||
| 415 | + this.$set(this, 'initialized', false); | ||
| 402 | }, | 416 | }, |
| 403 | 417 | ||
| 404 | /** | 418 | /** |
src/pages/optimization2/optimization2.vue
| @@ -474,7 +474,9 @@ | @@ -474,7 +474,9 @@ | ||
| 474 | page: 1, | 474 | page: 1, |
| 475 | list: [] | 475 | list: [] |
| 476 | }, | 476 | }, |
| 477 | - hotSalesActivityCode: 'ds_ghw_ad' // 页面渠道码 | 477 | + hotSalesActivityCode: 'ds_ghw_ad', // 页面渠道码 |
| 478 | + refreshInterval: 5, // 刷新时间间隔 | ||
| 479 | + refreshPoint: 0 // 页面从隐藏到显示的刷新时间点,时间戳格式 | ||
| 478 | } | 480 | } |
| 479 | }, | 481 | }, |
| 480 | computed: { | 482 | computed: { |
| @@ -555,6 +557,13 @@ | @@ -555,6 +557,13 @@ | ||
| 555 | // 优选页面接口 | 557 | // 优选页面接口 |
| 556 | this.index(); | 558 | this.index(); |
| 557 | 559 | ||
| 560 | + // 设置刷新时间点 | ||
| 561 | + if (!this.refreshPoint && this.refreshInterval > 0) { | ||
| 562 | + | ||
| 563 | + // 设置刷新时间点 | ||
| 564 | + this.setRefreshPoint(this.refreshInterval); | ||
| 565 | + } | ||
| 566 | + | ||
| 558 | // 商品列表 | 567 | // 商品列表 |
| 559 | // this.shopGoodsList(); | 568 | // this.shopGoodsList(); |
| 560 | 569 | ||
| @@ -598,6 +607,16 @@ | @@ -598,6 +607,16 @@ | ||
| 598 | methods: { | 607 | methods: { |
| 599 | 608 | ||
| 600 | /** | 609 | /** |
| 610 | + * 设置刷新时间点 | ||
| 611 | + * @param {Number} minute [刷新间隔时间,单位分钟] | ||
| 612 | + */ | ||
| 613 | + setRefreshPoint(minute) { | ||
| 614 | + | ||
| 615 | + // 设置刷新时间点 | ||
| 616 | + this.refreshPoint = new Date().getTime() + (parseFloat(minute) * 60 * 1000); | ||
| 617 | + }, | ||
| 618 | + | ||
| 619 | + /** | ||
| 601 | * 加载更多 | 620 | * 加载更多 |
| 602 | */ | 621 | */ |
| 603 | loadMore() { | 622 | loadMore() { |
| @@ -1495,7 +1514,10 @@ | @@ -1495,7 +1514,10 @@ | ||
| 1495 | document.addEventListener('visibilitychange', () => { | 1514 | document.addEventListener('visibilitychange', () => { |
| 1496 | 1515 | ||
| 1497 | // 页面显示出来了 | 1516 | // 页面显示出来了 |
| 1498 | - if (document.hidden === false && this.$route.name == 'optimization2') { | 1517 | + if (document.hidden === false && this.$route.name == 'optimization2' && ((this.refreshPoint && new Date().getTime() > this.refreshPoint) || !this.refreshPoint)) { |
| 1518 | + | ||
| 1519 | + // 设置刷新时间点 | ||
| 1520 | + this.setRefreshPoint(this.refreshInterval); | ||
| 1499 | 1521 | ||
| 1500 | // 优选页面接口 | 1522 | // 优选页面接口 |
| 1501 | this.index(); | 1523 | this.index(); |