dealer.vue 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137
  1. <template>
  2. <view class="dealer">
  3. <view class="top">
  4. <input class="uni-input" v-model="keyword" placeholder="请输入" @input="input"/>
  5. <view class="btn" @click="searchHistory(keyword)">搜索</view>
  6. </view>
  7. <view class="bom">
  8. <view class="grouping" v-for="(v,i) in aList" :key="i">
  9. <view class="th">
  10. {{v._id}}
  11. </view>
  12. <view class="td" v-for="(v1,i1) in v.data" :key="i1" @click="$goBack(2,'/pages/dealer/dealerDetails?id=' + v1.id + '&name=' +v1.name)">
  13. {{v1.name}}
  14. </view>
  15. </view>
  16. </view>
  17. </view>
  18. </template>
  19. <script>
  20. import {search} from '../../api/dealer.js'
  21. export default {
  22. data() {
  23. return {
  24. keyword: '',
  25. aList: [], //展示的数据
  26. //所有的数据
  27. bList: []
  28. };
  29. },
  30. onLoad() {
  31. },
  32. created() {
  33. this.getData()
  34. },
  35. methods: {
  36. input(){
  37. if(this.keyword.length <= 0){
  38. this.getList()
  39. }
  40. },
  41. async getData(){
  42. uni.showLoading({
  43. title: '加载中'
  44. });
  45. const res = await search({
  46. agencyList: [],
  47. name: '',
  48. accessToken: uni.getStorageSync('tokenInfo'),
  49. account: uni.getStorageSync('account')
  50. })
  51. uni.hideLoading();
  52. this.bList = res.data.list
  53. this.getList()
  54. },
  55. getList(){
  56. this.aList = this.bList
  57. },
  58. // 搜索
  59. searchHistory(value) {
  60. // value自动接收输入框中的内容
  61. if (value == '') {
  62. //如果输入的值为空则加载所有的列表
  63. this.getList();
  64. } else {
  65. //先清空展示的数据
  66. this.aList = []
  67. //然后开始循环全部数据
  68. this.bList.forEach(v => {
  69. v.data.forEach(v1 => {
  70. if(v1.name.indexOf(value) >= 0){
  71. let list = {
  72. _id: v._id,
  73. data: [{
  74. name: v1.name,
  75. id: v1.id
  76. }]
  77. }
  78. this.aList.push(list)
  79. }
  80. })
  81. })
  82. }
  83. },
  84. }
  85. }
  86. </script>
  87. <style lang="scss">
  88. .dealer {
  89. height: 100%;
  90. .top {
  91. height: 100rpx;
  92. display: flex;
  93. padding: 10rpx;
  94. border-bottom: 1rpx solid #dfdfdf;
  95. .uni-input{
  96. flex: 1;
  97. height: 100%;
  98. padding-left: 20rpx;
  99. }
  100. .btn{
  101. width: 20%;
  102. height: 100%;
  103. line-height: 100rpx;
  104. text-align: center;
  105. font-size: 30rpx;
  106. background-color: #f4f4f4;
  107. }
  108. }
  109. .bom {
  110. height: calc(100% - 130rpx);
  111. padding-top: 10rpx;
  112. overflow-y: scroll;
  113. .grouping {
  114. .th {
  115. height: 60rpx;
  116. line-height: 60rpx;
  117. text-align: center;
  118. background-color: #f1f1f1;
  119. color: #834e9a;
  120. }
  121. .td {
  122. padding: 30rpx;
  123. border-bottom: 1rpx solid #b0b0b0;
  124. &:last-child{
  125. border-bottom: 0;
  126. }
  127. }
  128. }
  129. }
  130. }
  131. </style>