123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117 |
- <template>
- <view>
- <view class="search">
- <u-search :placeholder="'搜索'+param.tradeAreaName+'商品'" v-model="param.name" bgColor="white" @search="refresh()" :animation="true" actionText="取消" @clear="refresh()"></u-search>
- </view>
- <view class="list">
- <view class="item" v-for="(item, index) in list" :key="index" @click="detail(item)">
- <view class="title omit">{{ item.name }}</view>
- <view class="desc">
- <text>{{ item.typeNames }}</text>
- <text>{{ item.unit }}</text>
- <text>{{ item.source }}</text>
- </view>
- </view>
- <view class="loading" v-if="loadMore"><u-loadmore :status="loadMore ? 'loading' : 'nomore'" /></view>
- <u-empty v-if="!loadMore && list.length == 0"></u-empty>
- </view>
- </view>
- </template>
- <script>
- export default {
- data() {
- return {
- param: { pageNo: 1, pageSize: 20 },
- list: [],
- loadMore: true
- };
- },
- onLoad(e) {
- //商品要和互市区对应
- if (e.tradeAreaId) {
- this.param.tradeAreaId = e.tradeAreaId;
- this.param.tradeAreaName = e.tradeAreaName;
- }
- this.getData();
- //选择商品分类
- uni.$on('productType', res => {
- this.param.typeNames = res.name;
- this.param.current = res.current;
- this.param.now = res.now;
- this.refresh();
- });
- },
- methods: {
- getData() {
- this.http.request({
- url: '/level-one-server/app/TbGoods/getByTradeArea',
- loading: 'false',
- data: this.param,
- success: res => {
- this.loadMore = parseInt(res.data.pageCount) > this.param.pageNo;
- this.list.push(...res.data.data);
- uni.setNavigationBarTitle({ title: '商品选择(' + res.data.dataCount + ')' });
- }
- });
- },
- detail(item) {
- uni.$emit('selects', item);
- uni.navigateBack();
- },
- //刷新数据
- refresh() {
- this.loadMore = true;
- this.param.pageNo = 1;
- this.list = [];
- this.getData();
- }
- },
- //下拉刷新
- onPullDownRefresh() {
- setTimeout(() => {
- this.refresh();
- uni.stopPullDownRefresh();
- }, 1000);
- },
- //上拉加载
- onReachBottom() {
- if (this.loadMore) {
- this.param.pageNo++;
- this.getData();
- }
- },
- onNavigationBarButtonTap() {
- uni.navigateTo({ url: '/pages/market/productType?current=' + this.param.current + '&now=' + this.param.now });
- }
- };
- </script>
- <style lang="scss">
- page {
- background-color: $pg;
- }
- .list {
- padding: 12px;
- .search {
- padding-top: 0px;
- }
- .item {
- padding: 13px;
- background-color: white;
- margin-bottom: 10px;
- border-radius: 5px;
- .title {
- font-weight: bold;
- }
- .desc {
- padding-top: 5px;
- font-size: 14px;
- color: #7a7a7a;
- text {
- padding-right: 15px;
- }
- }
- }
- }
- </style>
|