123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124 |
- <template>
- <view>
- <view class="search">
- <u-search placeholder="搜索商品名称" v-model="param.customerName" 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="show = true">
- <text>分类</text>
- <text class="icon"></text>
- </view>
- <view class="clear"></view>
- </view>
- <view class="item" v-for="(item, index) in list" :key="index" @click="detail(item.id)">
- <view class="title">{{item.merchantName}}</view>
- <image src="../../../static/news.jpg" mode="aspectFill" class="pic"></image>
- <view class="con">
- <view class="productName omit">{{ item.goodsName }}</view>
- <view class="desc omit">
- <text>{{item.grossWeight}} {{item.goodsUnits}}</text>
- <text>{{ item.tradeAreaName }}</text>
- </view>
- <view class="price">¥ {{ item.price }}</view>
- <view class="icon buy" @click.stop="addCar(item)" v-if="user.userType == 2"></view>
- </view>
- <view class="clear"></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 {
- show: false,
- user: this.getUser(),
- sort: [{ name: '综合' }, { name: '日期' }, { name: '价格' }],
- list: [],
- param: { pageNo: 1, pageSize: 10 },
- loadMore: true
- };
- },
- onLoad() {
- this.getData();
- },
- methods: {
- getData() {
- this.http.request({
- url: '/level-one-server/app/TbGoodsTransit/getList',
- data: this.param,
- loading: 'false',
- success: res => {
- this.loadMore = parseInt(res.data.pageCount) > this.param.pageNo;
- this.list.push(...res.data.data);
- }
- });
- },
- // 添加购物车
- addCar(goods) {
- let params = {
- buyUserId: this.user.id,
- enterpriseId: goods.merchantId,
- shopId: goods.shopId,
- tradeAreaId: goods.tradeAreaId,
- saleGoodsInfoId: goods.id,
- goodsImg: goods.goodsImg,
- goodsName: goods.goodsName,
- publishGoodsId: goods.id
- };
- this.http.request({
- url: '/level-one-server/app/TbGoodsCart/addGoodsInShopCart',
- data: params,
- contentType: 'application/json; charset=utf-8',
- method: 'POST',
- success: res => {
- uni.showToast({ title: '添加成功' });
- }
- });
- },
- detail(id) {
- uni.navigateTo({ url: '/pages/market/one/detail?id=' + id });
- },
- //刷新数据
- 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();
- }
- }
- };
- </script>
- <style lang="scss">
- page {
- background-color: $pg;
- }
- .search {
- padding: 12px 12px 0px 12px;
- }
- </style>
|