selects.vue 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110
  1. <template>
  2. <view>
  3. <view class="list">
  4. <view class="search">
  5. <u-search :placeholder="'搜索'+param.tradeAreaName+'商品'" v-model="param.name" bgColor="white" @search="refresh()" :animation="true" actionText="取消" @clear="refresh()"></u-search>
  6. </view>
  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. methods: {
  38. getData() {
  39. this.http.request({
  40. url: '/level-one-server/app/TbGoods/getList',
  41. loading: 'false',
  42. data: this.param,
  43. success: res => {
  44. this.loadMore = parseInt(res.data.pageCount) > this.param.pageNo;
  45. this.list.push(...res.data.data);
  46. uni.setNavigationBarTitle({ title: '商品选择(' + res.data.dataCount + ')' });
  47. }
  48. });
  49. },
  50. detail(item) {
  51. uni.$emit('selects', item);
  52. uni.navigateBack();
  53. },
  54. //刷新数据
  55. refresh() {
  56. this.loadMore = true;
  57. this.param.pageNo = 1;
  58. this.list = [];
  59. this.getData();
  60. }
  61. },
  62. //下拉刷新
  63. onPullDownRefresh() {
  64. setTimeout(() => {
  65. this.refresh();
  66. uni.stopPullDownRefresh();
  67. }, 1000);
  68. },
  69. //上拉加载
  70. onReachBottom() {
  71. if (this.loadMore) {
  72. this.param.pageNo++;
  73. this.getData();
  74. }
  75. },
  76. onNavigationBarButtonTap() {
  77. uni.navigateTo({ url: '/pages/market/one/merchant/goods/add' });
  78. }
  79. };
  80. </script>
  81. <style lang="scss">
  82. page {
  83. background-color: $pg;
  84. }
  85. .list {
  86. padding: 12px;
  87. .search {
  88. padding-top: 0px;
  89. }
  90. .item {
  91. padding: 13px;
  92. background-color: white;
  93. margin-bottom: 10px;
  94. border-radius: 5px;
  95. .title {
  96. font-weight: bold;
  97. }
  98. .desc {
  99. padding-top: 5px;
  100. font-size: 14px;
  101. color: #7a7a7a;
  102. text {
  103. padding-right: 15px;
  104. }
  105. }
  106. }
  107. }
  108. </style>