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.
high-mini/physical-merchants/classify/goods-search/goods-search.vue

170 lines
3.7 KiB

2 years ago
<template>
2 years ago
<!-- <view class="backcor9" style="height: 100vh;overflow: hidden;"> -->
<view class="search-container backcor9">
2 years ago
<!-- 搜索框 -->
2 years ago
<block>
<view class="nav-search jianbian">
2 years ago
<component-search @onsearch="search_button_event" :propIsRequired="false"
2 years ago
propPlaceholder="输入商品名称搜索"></component-search>
2 years ago
</view>
</block>
<!-- 搜索列表 -->
<view class="search-list">
<goodsList ref="goodsList" typeList="goodsSearch" @loadData="loadData" :propData="data_list"
:paddBottom="0">
2 years ago
</goodsList>
2 years ago
</view>
2 years ago
2 years ago
</view>
2 years ago
<!-- </view> -->
2 years ago
</template>
<script>
import componentSearch from "@/components/search/search.vue";
2 years ago
import goodsList from '@/components/goods-list/goods-list.vue';
2 years ago
import {
getListGoodsDetail
2 years ago
} from '@/Utils/physicalObject.js'
const app = getApp()
2 years ago
export default {
2 years ago
data() {
return {
data_list: [],
keywordsSearh: '',
page: {
pageStart: 1, //页码
2 years ago
pageNum: 20, //每页有多少条数据
2 years ago
navigateLastPage: 1, //总共有几页
allData: 0 //总共有多少条数据
2 years ago
},
2 years ago
companyId :app.globalData.companyId,
goodsLabel:''
2 years ago
}
},
2 years ago
onLoad(options){
2 years ago
// console.log(options,"options")
2 years ago
if(options.goodsLabel){
this.goodsLabel = options.goodsLabel
}
this.search_button_event("")
},
2 years ago
components: {
2 years ago
componentSearch,
goodsList
},
onShow() {
this.$nextTick(() => {
if (this.$refs.goodsList) {
this.$refs.goodsList.refreshCartNum()
}
})
2 years ago
},
2 years ago
methods: {
2 years ago
//搜索事件
search_button_event(keywords) {
2 years ago
if(keywords==null){keywords=''}
2 years ago
this.keywordsSearh = keywords;
this.data_list = [];
this.page = {
pageStart: 1, //页码
2 years ago
pageNum: 20, //每页有多少条数据
2 years ago
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()
}
2 years ago
},
// 加载数据
2 years ago
searchData() {
2 years ago
// if (!this.keywordsSearh) {
// uni.showToast({
// title: '请输入商品名称',
// duration: 1000,
// icon: 'none'
// });
2 years ago
2 years ago
// return
// }
2 years ago
let _this = this
let params = {
title: _this.keywordsSearh,
pageNum: _this.page.pageStart,
pageSize: _this.page.pageNum,
2 years ago
price: 0,
companyId:_this.companyId,
goodsLabel:_this.goodsLabel
2 years ago
}
// params = JSON.stringify(params)
// console.log(params)
uni.showLoading({
title: '加载中',
mask: true,
});
2 years ago
getListGoodsDetail(params).then(res => {
2 years ago
setTimeout(()=>{
uni.hideLoading();
if (res.return_code == '000000') {
2 years ago
2 years ago
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 = []
}
2 years ago
} else {
2 years ago
uni.showToast({
title: res.return_msg,
icon: 'none',
duration: 2000
})
2 years ago
}
2 years ago
},100)
2 years ago
})
2 years ago
}
}
}
</script>
<style lang="scss" scoped>
2 years ago
.search-container {
.search-list {
2 years ago
height: calc(100vh - 80px - var(--window-top));
2 years ago
// padding: 20rpx;
}
}
2 years ago
2 years ago
.nav-search {
2 years ago
padding: 20px;
background: linear-gradient(to bottom, #3da7e7, #FFFFFF) no-repeat;
2 years ago
}
2 years ago
</style>