selBrand.vue 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128
  1. <template>
  2. <view class="selSupplier">
  3. <view class="search-view">
  4. <view class="input-view">
  5. <input type="text" confirm-type="search" placeholder-class="input-pl" placeholder="请输入品牌名称" v-model="keyword" />
  6. <u-icon class="add-icon" name="search" size="40" color="#666666" @click="search"></u-icon>
  7. </view>
  8. </view>
  9. <view class="supplier-ul">
  10. <view class="supplier-li" v-for="(item, index) in brand_list" :key="index" @click="changeBrand(item)">
  11. <view class="supplier-name">{{ item.title }}</view>
  12. <view class="other">
  13. {{item.code}}
  14. </view>
  15. </view>
  16. </view>
  17. <u-loadmore :status="load_status" />
  18. </view>
  19. </template>
  20. <script>
  21. export default {
  22. data() {
  23. return {
  24. keyword: '',
  25. load_status: 'nomore',
  26. page: 1,
  27. pageSize: 10,
  28. total: 0,
  29. brand_list: []
  30. };
  31. },
  32. onLoad() {
  33. this.getAllBrand();
  34. },
  35. onPullDownRefresh() {
  36. this.getAllBrand();
  37. },
  38. // 上拉加载
  39. onReachBottom() {
  40. if (this.total / this.pageSize > this.page) {
  41. this.page += 1;
  42. this.getAllBrand();
  43. }
  44. },
  45. methods: {
  46. changeBrand(item) {
  47. // 选择供应商返回上一页
  48. this._prePage().brandData = item;
  49. uni.navigateBack();
  50. },
  51. search() {
  52. this.page = 1;
  53. this.getAllBrand();
  54. },
  55. getAllBrand() {
  56. this.loading_status = 'loading';
  57. this.$u.api
  58. .getAllBrand({
  59. page: this.page,
  60. pageSize: this.pageSize,
  61. keyword: this.keyword
  62. })
  63. .then(res => {
  64. uni.stopPullDownRefresh();
  65. this.total = res.pageTotal;
  66. if (this.page === 1) {
  67. this.brand_list = res.data;
  68. } else {
  69. this.brand_list = this.brand_list.concat(res.data);
  70. }
  71. this.load_status = this.$utils.loadStatus(this.page,this.pageSize,this.total);
  72. })
  73. .catch(err => {
  74. uni.stopPullDownRefresh();
  75. });
  76. }
  77. }
  78. };
  79. </script>
  80. <style lang="scss" scoped>
  81. .search-view {
  82. position: fixed;
  83. z-index: 99;
  84. top: 0;
  85. left: 0;
  86. width: 100%;
  87. background-color: #ffffff;
  88. border-bottom: 1px solid #f5f5f5;
  89. padding: 20rpx 0;
  90. .input-view {
  91. padding: 0 24rpx;
  92. input {
  93. height: 60rpx;
  94. line-height: 60rpx;
  95. padding: 0 24rpx;
  96. display: inline-block;
  97. width: 580rpx;
  98. border: 1px solid #f5f5f5;
  99. vertical-align: middle;
  100. border-radius: 8rpx;
  101. background-color: #f7f8fa;
  102. }
  103. .add-icon {
  104. margin-left: 14rpx;
  105. display: inline-block;
  106. vertical-align: middle;
  107. }
  108. }
  109. }
  110. .supplier-ul {
  111. padding-top: 90rpx;
  112. padding-bottom: 20rpx;
  113. .supplier-li {
  114. width: 702rpx;
  115. margin: 0 auto;
  116. background-color: #ffffff;
  117. border-radius: 10rpx;
  118. margin-top: 20rpx;
  119. line-height: 50rpx;
  120. padding: 20rpx;
  121. .other {
  122. font-size: 24rpx;
  123. }
  124. }
  125. }
  126. </style>