You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
136 lines
3.0 KiB
136 lines
3.0 KiB
<template>
|
|
<view class="backcor9" style="height: 100vh;overflow: hidden;">
|
|
<view class="search-container">
|
|
<!-- 搜索框 -->
|
|
<block>
|
|
<view class="nav-search jianbian">
|
|
<component-search @onsearch="search_button_event" :propIsOnEvent="true" :propIsRequired="true"
|
|
propPlaceholder="输入商品名称搜索"></component-search>
|
|
</view>
|
|
</block>
|
|
<!-- 搜索列表 -->
|
|
<view class="search-list">
|
|
<goodsList v-if="hackReset" typeList="goodsSearch" @loadData="loadData" :propData="data_list" :paddBottom="0">
|
|
</goodsList>
|
|
|
|
</view>
|
|
|
|
|
|
</view>
|
|
</view>
|
|
</template>
|
|
|
|
<script>
|
|
import componentSearch from "@/components/search/search.vue";
|
|
import goodsList from '@/pages/classify/goods-list/goods-list.vue'
|
|
import {
|
|
getListGoodsDetail
|
|
} from '@/Utils/physicalObject.js'
|
|
export default {
|
|
|
|
data() {
|
|
return {
|
|
data_list: [],
|
|
keywordsSearh: '',
|
|
page: {
|
|
pageStart: 1, //页码
|
|
pageNum: 7, //每页有多少条数据
|
|
navigateLastPage: 1, //总共有几页
|
|
allData: 0 //总共有多少条数据
|
|
},
|
|
hackReset:false,
|
|
}
|
|
},
|
|
components: {
|
|
componentSearch,
|
|
goodsList
|
|
},
|
|
onShow(){
|
|
this.hackReset = false;
|
|
this.$nextTick(() => {
|
|
this.hackReset = true;
|
|
})
|
|
},
|
|
methods: {
|
|
//搜索事件
|
|
search_button_event(keywords) {
|
|
this.keywordsSearh = keywords;
|
|
this.data_list = [];
|
|
this.page = {
|
|
pageStart: 1, //页码
|
|
pageNum: 7, //每页有多少条数据
|
|
navigateLastPage: 1, //总共有几页
|
|
allData: 0 //总共有多少条数据
|
|
}
|
|
this.searchData()
|
|
// console.log(this.keywordsSearh, "子组件弹射的keywords")
|
|
},
|
|
loadData() {
|
|
let _this = this;
|
|
if (_this.page.pageStart < _this.page.navigateLastPage) {
|
|
_this.page.pageStart = _this.page.pageStart + 1;
|
|
_this.searchData()
|
|
}
|
|
},
|
|
// 加载数据
|
|
searchData() {
|
|
|
|
if (!this.keywordsSearh) {
|
|
uni.showToast({
|
|
title: '请输入商品名称',
|
|
duration: 1000,
|
|
icon: 'none'
|
|
});
|
|
|
|
return
|
|
}
|
|
let _this = this
|
|
let params = {
|
|
title: _this.keywordsSearh,
|
|
pageNum: _this.page.pageStart,
|
|
pageSize: _this.page.pageNum,
|
|
price: 0
|
|
}
|
|
// params = JSON.stringify(params)
|
|
console.log(params)
|
|
getListGoodsDetail(params).then(res => {
|
|
if (res.return_code == '000000') {
|
|
|
|
if (res.return_data.list.length > 0) {
|
|
_this.data_list = _this.data_list.concat(res.return_data.list);
|
|
this.page.pageStart = res.return_data.pageNum;
|
|
this.page.pageSize = res.return_data.pageSize;
|
|
this.page.total = res.return_data.total;
|
|
this.page.navigateLastPage = res.return_data.navigateLastPage
|
|
|
|
} else {
|
|
_this.data_list = []
|
|
}
|
|
|
|
} else {
|
|
uni.showToast({
|
|
title: res.return_msg,
|
|
icon: 'none',
|
|
duration: 2000
|
|
})
|
|
}
|
|
})
|
|
}
|
|
}
|
|
}
|
|
</script>
|
|
|
|
<style lang="scss" scoped>
|
|
.search-container {
|
|
|
|
|
|
.search-list {
|
|
height: calc(100vh - 50px);
|
|
// padding: 20rpx;
|
|
}
|
|
}
|
|
|
|
.nav-search {
|
|
padding: 10px;
|
|
}
|
|
</style>
|
|
|