Seek.vue 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136
  1. <template>
  2. <div class="seek">
  3. <div class="com-mobile-header">
  4. <a @click="goLastPage"><i class="iconfont icon-fanhui"></i></a>
  5. <p>{{seekTitle}}</p>
  6. </div>
  7. <div class="mobile-fix-content" id="mobileFixContent">
  8. <div class="seek-title com-switch-item" v-if="userType == 'saler'">
  9. <span class="mobile-switch-btn" :class="{'active': activeType=='all'}" @click="switchActiveType('all')">公司商机</span>
  10. <span class="mobile-switch-btn" :class="{'active': activeType=='self'}" @click="switchActiveType('self')">我的商机</span>
  11. </div>
  12. <div class="search-content">
  13. <input type="text" v-model="seekKeyword" :placeholder="userType == 'buyer' ? '品牌/型号' : '品牌/类目/型号/规格/公司'" @keyup.13="onSearch">
  14. <span @click="onSearch"><i class="iconfont icon-sousuo"></i></span>
  15. </div>
  16. <seek-list :keyword="remindKeyword" :isSearch="isSearch" :userType="userType" :seekType="seekType" :purchaseManList="purchaseManListData"></seek-list>
  17. <pull-up :fixId="'mobileFixContent'" :searchMore="fetching" :allPage="allPage" :page="page" @pullUpAction="onPullUpAction"></pull-up>
  18. </div>
  19. </div>
  20. </template>
  21. <script>
  22. import SeekList from '~components/mobile/applyPurchase/SeekList.vue'
  23. import { PullUp, EmptyStatus } from '~components/mobile/common'
  24. export default {
  25. layout: 'mobileNoHeader',
  26. middleware: 'authenticated',
  27. data () {
  28. return {
  29. seekKeyword: '',
  30. purchaseManListData: [],
  31. page: 1,
  32. count: 10,
  33. isChange: false,
  34. isSearch: false,
  35. remindKeyword: '',
  36. activeType: 'all'
  37. }
  38. },
  39. props: ['userType'],
  40. components: {
  41. SeekList,
  42. PullUp,
  43. EmptyStatus
  44. },
  45. watch: {
  46. 'purchase.data': {
  47. handler: function (val) {
  48. let list = val.content ? val.content.slice() : []
  49. if (this.isChange) {
  50. this.purchaseManListData = list
  51. this.isChange = false
  52. } else {
  53. this.purchaseManListData = this.purchaseManListData.concat(list)
  54. }
  55. },
  56. immediate: true
  57. }
  58. },
  59. computed: {
  60. seekType () {
  61. return this.$route.query.seekType
  62. },
  63. purchase () {
  64. return this.$store.state.applyPurchase.purchaseManList.purchaseManList
  65. },
  66. fetching () {
  67. return this.purchase.fetching
  68. },
  69. allPage () {
  70. return Math.floor(this.purchase.data.totalElements / this.purchase.data.size) + Math.floor(this.purchase.data.totalElements % this.purchase.data.size > 0 ? 1 : 0)
  71. },
  72. seekTitle () {
  73. if (this.seekType === 'wait') {
  74. if (this.userType === 'saler') {
  75. return '商机管理'
  76. } else {
  77. return '待报价'
  78. }
  79. } else if (this.seekType === 'done') {
  80. return '已报价'
  81. }
  82. return '已报价'
  83. }
  84. },
  85. methods: {
  86. onSearch: function () {
  87. this.isSearch = true
  88. this.remindKeyword = this.seekKeyword
  89. this.page = 1
  90. this.isChange = true
  91. this.reloadData()
  92. },
  93. reloadData: function () {
  94. this.$emit('reloadAction', this.page, this.count, this.seekKeyword, this.seekType, this.activeType)
  95. },
  96. onPullUpAction: function () {
  97. this.page++
  98. this.reloadData()
  99. },
  100. switchActiveType: function (type) {
  101. this.activeType = type
  102. this.isSearch = false
  103. this.remindKeyword = this.seekKeyword = ''
  104. this.page = 1
  105. this.isChange = true
  106. this.reloadData()
  107. }
  108. }
  109. }
  110. </script>
  111. <style lang="scss" scoped>
  112. .search-content {
  113. text-align: center;
  114. padding: .25rem 0 0 0;
  115. input {
  116. border: 1px solid #376ff3;
  117. }
  118. span {
  119. height: .46rem;
  120. line-height: .46rem;
  121. }
  122. }
  123. $seekTitleLine: .72rem;
  124. .seek-title {
  125. height: $seekTitleLine;
  126. line-height: $seekTitleLine;
  127. .mobile-switch-btn {
  128. height: $seekTitleLine;
  129. line-height: $seekTitleLine;
  130. font-size: .28rem;
  131. /*&.active {
  132. border-bottom-width: .07rem;
  133. }*/
  134. }
  135. }
  136. </style>