list.vue 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133
  1. <template>
  2. <view>
  3. <view class="search">
  4. <u-search placeholder="搜索商品名称" v-model="param.goodsName" bgColor="white" @search="refresh()" :animation="true" actionText="取消" @clear="refresh()"></u-search>
  5. <view class="clear"></view>
  6. </view>
  7. <view class="goodsList">
  8. <view class="sort-list">
  9. <view class="sort-item" :class="{ active: item.check }" v-for="(item, index) in sort" :key="index" @click="select(item, index)">
  10. <text>{{ item.name }}</text>
  11. <text v-if="index > 0 && item.isAsc == 'desc'" class="icon">&#xeb0a;</text>
  12. <text v-if="index > 0 && item.isAsc == 'asc'" class="icon">&#xeb0b;</text>
  13. </view>
  14. <view class="type" @click="go()">
  15. <text>{{ param.goodsType || '分类' }}</text>
  16. <text class="icon">&#xe8f2;</text>
  17. </view>
  18. </view>
  19. <view class="item" v-for="(item, index) in list" :key="index">
  20. <view class="title" @click="detail(item)">{{ item.createName }}</view>
  21. <image @click="detail(item)" src="../../../static/news.jpg" mode="aspectFill" class="pic"></image>
  22. <view class="con">
  23. <view class="productName omit" @click="detail(item)">{{ item.goodsName }}</view>
  24. <view class="desc" @click="detail(item)">数量:{{ item.goodsQuantity }}</view>
  25. <view class="btn" v-if="user.userType == 2" @click="confirm(item)">立即接单</view>
  26. </view>
  27. </view>
  28. <view class="loading" v-if="loadMore"><u-loadmore :status="loadMore ? 'loading' : 'nomore'" /></view>
  29. <u-empty v-if="!loadMore && list.length == 0"></u-empty>
  30. </view>
  31. <productType v-model="show"></productType>
  32. </view>
  33. </template>
  34. <script>
  35. export default {
  36. data() {
  37. return {
  38. user: this.getUser(),
  39. show: false,
  40. isAsc: 'desc',
  41. sort: [
  42. { name: '综合', sortName: 'id', isAsc: 'desc', check: false },
  43. { name: '日期', sortName: 'create_time', isAsc: 'desc', check: false },
  44. { name: '数量', sortName: 'goods_quantity', isAsc: 'desc', check: false }
  45. ],
  46. list: [],
  47. param: { pageNo: 1, pageSize: 10 },
  48. loadMore: true
  49. };
  50. },
  51. onLoad(e) {
  52. this.getData();
  53. //选择商品分类
  54. uni.$on('productType', res => {
  55. this.param.goodsType = res.name;
  56. this.param.current = res.current;
  57. this.param.now = res.now;
  58. this.refresh();
  59. });
  60. },
  61. methods: {
  62. select(item, index) {
  63. this.sort.forEach(it => (it.check = false));
  64. item.check = true;
  65. if (index > 0) {
  66. this.isAsc = this.isAsc == 'desc' ? 'asc' : 'desc';
  67. item.isAsc = this.isAsc;
  68. }
  69. this.param.orderBy = item.sortName + ' ' + this.isAsc;
  70. this.refresh();
  71. },
  72. getData() {
  73. this.http.request({
  74. url: '/level-two-server/app/TbGoodsDemand/getList',
  75. data: this.param,
  76. loading: 'false',
  77. success: res => {
  78. this.loadMore = parseInt(res.data.pageCount) > this.param.pageNo;
  79. this.list.push(...res.data.data);
  80. }
  81. });
  82. },
  83. //选择分类
  84. go() {
  85. uni.navigateTo({ url: '/pages/market/productType?current=' + this.param.current + '&now=' + this.param.now });
  86. },
  87. detail(item) {
  88. uni.navigateTo({ url: '/pages/market/two/detail?id=' + item.id });
  89. },
  90. confirm(item) {
  91. uni.navigateTo({ url: '/pages/market/two/leader/confirm?item=' + JSON.stringify(item) });
  92. },
  93. //刷新数据
  94. refresh() {
  95. this.loadMore = true;
  96. this.param.pageNum = 1;
  97. this.list = [];
  98. this.getData();
  99. }
  100. },
  101. //下拉刷新
  102. onPullDownRefresh() {
  103. setTimeout(() => {
  104. this.refresh();
  105. uni.stopPullDownRefresh();
  106. }, 1000);
  107. },
  108. //上拉加载
  109. onReachBottom() {
  110. if (this.loadMore) {
  111. this.param.pageNum++;
  112. this.getData();
  113. }
  114. }
  115. };
  116. </script>
  117. <style lang="scss">
  118. page {
  119. background-color: $pg;
  120. }
  121. .btn {
  122. width: 120rpx;
  123. height: 40rpx;
  124. background-color: #fff;
  125. color: #000;
  126. border: #b5b5b5 1px solid;
  127. position: relative;
  128. left: 350rpx;
  129. font-size: 14px;
  130. }
  131. </style>