123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133 |
- <template>
- <view>
- <view class="search">
- <u-search placeholder="搜索商品名称" v-model="param.goodsName" bgColor="white" @search="refresh()" :animation="true" actionText="取消" @clear="refresh()"></u-search>
- <view class="clear"></view>
- </view>
- <view class="goodsList">
- <view class="sort-list">
- <view class="sort-item" :class="{ active: item.check }" v-for="(item, index) in sort" :key="index" @click="select(item, index)">
- <text>{{ item.name }}</text>
- <text v-if="index > 0 && item.isAsc == 'desc'" class="icon"></text>
- <text v-if="index > 0 && item.isAsc == 'asc'" class="icon"></text>
- </view>
- <view class="type" @click="go()">
- <text>{{ param.goodsType || '分类' }}</text>
- <text class="icon"></text>
- </view>
- </view>
- <view class="item" v-for="(item, index) in list" :key="index">
- <view class="title" @click="detail(item)">{{ item.createName }}</view>
- <image @click="detail(item)" src="../../../static/news.jpg" mode="aspectFill" class="pic"></image>
- <view class="con">
- <view class="productName omit" @click="detail(item)">{{ item.goodsName }}</view>
- <view class="desc" @click="detail(item)">数量:{{ item.goodsQuantity }}</view>
- <view class="btn" v-if="user.userType == 2" @click="confirm(item)">立即接单</view>
- </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>
- <productType v-model="show"></productType>
- </view>
- </template>
- <script>
- export default {
- data() {
- return {
- user: this.getUser(),
- show: false,
- isAsc: 'desc',
- sort: [
- { name: '综合', sortName: 'id', isAsc: 'desc', check: false },
- { name: '日期', sortName: 'create_time', isAsc: 'desc', check: false },
- { name: '数量', sortName: 'goods_quantity', isAsc: 'desc', check: false }
- ],
- list: [],
- param: { pageNo: 1, pageSize: 10 },
- loadMore: true
- };
- },
- onLoad(e) {
- this.getData();
- //选择商品分类
- uni.$on('productType', res => {
- this.param.goodsType = res.name;
- this.param.current = res.current;
- this.param.now = res.now;
- this.refresh();
- });
- },
- methods: {
- select(item, index) {
- this.sort.forEach(it => (it.check = false));
- item.check = true;
- if (index > 0) {
- this.isAsc = this.isAsc == 'desc' ? 'asc' : 'desc';
- item.isAsc = this.isAsc;
- }
- this.param.orderBy = item.sortName + ' ' + this.isAsc;
- this.refresh();
- },
- getData() {
- this.http.request({
- url: '/level-two-server/app/TbGoodsDemand/getList',
- data: this.param,
- loading: 'false',
- success: res => {
- this.loadMore = parseInt(res.data.pageCount) > this.param.pageNo;
- this.list.push(...res.data.data);
- }
- });
- },
- //选择分类
- go() {
- uni.navigateTo({ url: '/pages/market/productType?current=' + this.param.current + '&now=' + this.param.now });
- },
- detail(item) {
- uni.navigateTo({ url: '/pages/market/two/detail?id=' + item.id });
- },
- confirm(item) {
- uni.navigateTo({ url: '/pages/market/two/leader/confirm?item=' + JSON.stringify(item) });
- },
- //刷新数据
- refresh() {
- this.loadMore = true;
- this.param.pageNum = 1;
- this.list = [];
- this.getData();
- }
- },
- //下拉刷新
- onPullDownRefresh() {
- setTimeout(() => {
- this.refresh();
- uni.stopPullDownRefresh();
- }, 1000);
- },
- //上拉加载
- onReachBottom() {
- if (this.loadMore) {
- this.param.pageNum++;
- this.getData();
- }
- }
- };
- </script>
- <style lang="scss">
- page {
- background-color: $pg;
- }
- .btn {
- width: 120rpx;
- height: 40rpx;
- background-color: #fff;
- color: #000;
- border: #b5b5b5 1px solid;
- position: relative;
- left: 350rpx;
- font-size: 14px;
- }
- </style>
|