selects.vue 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117
  1. <template>
  2. <view>
  3. <view class="search">
  4. <u-search :placeholder="'搜索'+param.tradeAreaName+'商品'" v-model="param.name" bgColor="white" @search="refresh()" :animation="true" actionText="取消" @clear="refresh()"></u-search>
  5. </view>
  6. <view class="list">
  7. <view class="item" v-for="(item, index) in list" :key="index" @click="detail(item)">
  8. <view class="title omit">{{ item.name }}</view>
  9. <view class="desc">
  10. <text>{{ item.typeNames }}</text>
  11. <text>{{ item.unit }}</text>
  12. <text>{{ item.source }}</text>
  13. </view>
  14. </view>
  15. <view class="loading" v-if="loadMore"><u-loadmore :status="loadMore ? 'loading' : 'nomore'" /></view>
  16. <u-empty v-if="!loadMore && list.length == 0"></u-empty>
  17. </view>
  18. </view>
  19. </template>
  20. <script>
  21. export default {
  22. data() {
  23. return {
  24. param: { pageNo: 1, pageSize: 20 },
  25. list: [],
  26. loadMore: true
  27. };
  28. },
  29. onLoad(e) {
  30. //商品要和互市区对应
  31. if (e.tradeAreaId) {
  32. this.param.tradeAreaId = e.tradeAreaId;
  33. this.param.tradeAreaName = e.tradeAreaName;
  34. }
  35. this.getData();
  36. //选择商品分类
  37. uni.$on('productType', res => {
  38. this.param.typeNames = res.name;
  39. this.param.current = res.current;
  40. this.param.now = res.now;
  41. this.refresh();
  42. });
  43. },
  44. methods: {
  45. getData() {
  46. this.http.request({
  47. url: '/level-one-server/app/TbGoods/getByTradeArea',
  48. loading: 'false',
  49. data: this.param,
  50. success: res => {
  51. this.loadMore = parseInt(res.data.pageCount) > this.param.pageNo;
  52. this.list.push(...res.data.data);
  53. uni.setNavigationBarTitle({ title: '商品选择(' + res.data.dataCount + ')' });
  54. }
  55. });
  56. },
  57. detail(item) {
  58. uni.$emit('selects', item);
  59. uni.navigateBack();
  60. },
  61. //刷新数据
  62. refresh() {
  63. this.loadMore = true;
  64. this.param.pageNo = 1;
  65. this.list = [];
  66. this.getData();
  67. }
  68. },
  69. //下拉刷新
  70. onPullDownRefresh() {
  71. setTimeout(() => {
  72. this.refresh();
  73. uni.stopPullDownRefresh();
  74. }, 1000);
  75. },
  76. //上拉加载
  77. onReachBottom() {
  78. if (this.loadMore) {
  79. this.param.pageNo++;
  80. this.getData();
  81. }
  82. },
  83. onNavigationBarButtonTap() {
  84. uni.navigateTo({ url: '/pages/market/productType?current=' + this.param.current + '&now=' + this.param.now });
  85. }
  86. };
  87. </script>
  88. <style lang="scss">
  89. page {
  90. background-color: $pg;
  91. }
  92. .list {
  93. padding: 12px;
  94. .search {
  95. padding-top: 0px;
  96. }
  97. .item {
  98. padding: 13px;
  99. background-color: white;
  100. margin-bottom: 10px;
  101. border-radius: 5px;
  102. .title {
  103. font-weight: bold;
  104. }
  105. .desc {
  106. padding-top: 5px;
  107. font-size: 14px;
  108. color: #7a7a7a;
  109. text {
  110. padding-right: 15px;
  111. }
  112. }
  113. }
  114. }
  115. </style>