attentionBus.vue 7.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249
  1. <template>
  2. <div class="attention-bus-wrap" id="attention-bus-wrap">
  3. <div class="product-switch-item">
  4. <span :class="activeType==='attention'?'mobile-switch-btn active':'mobile-switch-btn'" @click="ChangeTab('attention')">已关注</span>
  5. <span :class="activeType==='isattention'?'mobile-switch-btn active':'mobile-switch-btn'" @click="ChangeTab('isattention')">未关注</span>
  6. </div>
  7. <div class="search-content" style="padding-bottom: 0.25rem">
  8. <input type="text" placeholder="请输入您要查找的品牌或型号" v-model="keyword" @keyup.13="searchSeek">
  9. <span @click="searchSeek" >
  10. <i class="iconfont icon-sousuo"></i>
  11. </span>
  12. </div>
  13. <div class="attention-bus-list">
  14. <ul>
  15. <li v-for="item in attentionList">
  16. <div class="item">
  17. <div class="name">
  18. {{ item.nameCn | filterStr}}
  19. </div>
  20. <div class="attention-button" @click="attentionFn(item)">
  21. <i class="iconfont icon-shoucang" :class="{'active': item.status}"></i>
  22. <p v-if="item.status === 1">取消关注</p>
  23. <p v-else>关注</p>
  24. </div>
  25. </div>
  26. </li>
  27. </ul>
  28. </div>
  29. <div class="fixedAlert" v-show="isShowAlert">
  30. 关注类目,商机无限!
  31. <i class="iconfont icon-guanbi" @click="isShowAlert = false"></i>
  32. </div>
  33. <remind-box :title="collectResult" :timeoutCount="timeoutCount"></remind-box>
  34. <pull-up :fixId="'attention-bus-wrap'" :searchMore="isSearchSearchingMore" :allPage="allPage" :page="page" @pullUpAction="getMoreSearch"></pull-up>
  35. </div>
  36. </template>
  37. <script>
  38. import { RemindBox, PullUp } from '~components/mobile/common'
  39. export default {
  40. name: 'attention-Bus',
  41. layout: 'mobile',
  42. middleware: 'authenticated',
  43. fetch({store}) {
  44. return Promise.all([
  45. store.dispatch('product/getUserCollectCode', {keyword: '', count: 10, page: 1, type: 'yes', enUU: store.state.option.user.data.enterprise.uu})
  46. ])
  47. },
  48. data() {
  49. return {
  50. activeType: 'attention',
  51. keyword: '',
  52. collectResult: '',
  53. timeoutCount: 0,
  54. page: 1,
  55. attentionList: [],
  56. isShowAlert: true,
  57. isSearchSearchingMore: false
  58. }
  59. },
  60. watch: {
  61. 'getkindConcernList.data': {
  62. handler: function (val) {
  63. if (this.isChange) {
  64. this.attentionList = val.content
  65. this.isChange = false
  66. } else {
  67. this.attentionList = [...this.attentionList, ...val.content]
  68. }
  69. this.isSearchSearchingMore = false
  70. },
  71. immediate: true
  72. }
  73. },
  74. computed: {
  75. allPage() {
  76. return Math.ceil(this.$store.state.product.component.collectCode.data.totalElements / 10)
  77. },
  78. getkindConcernList() {
  79. return this.$store.state.product.component.collectCode
  80. }
  81. },
  82. methods: {
  83. ChangeTab(a) {
  84. this.activeType = a
  85. this.attentionList = []
  86. this.page = 1
  87. this.getAttentionListArray(this.page)
  88. },
  89. searchSeek() {
  90. this.page = 0
  91. this.attentionList = []
  92. this.getMoreSearch()
  93. },
  94. attentionFn(item) {
  95. if (item.status === 1) {
  96. this.$http.post('/kind/concern', {kindConcern: item, type: 'del'}).then(res => {
  97. this.collectResult = '取消成功'
  98. this.timeoutCount++
  99. })
  100. } else {
  101. this.$http.post('/kind/concern', {indConcern: item, type: 'add'}).then(res => {
  102. this.collectResult = '关注成功'
  103. this.timeoutCount++
  104. })
  105. }
  106. },
  107. getAttentionListArray(page) {
  108. this.isSearchSearchingMore = true
  109. if (this.activeType === 'attention') {
  110. this.$store.dispatch('product/getUserCollectCode', {keyword: this.keyword, count: 10, page: page, type: 'yes', enUU: this.$store.state.option.user.data.enterprise.uu})
  111. } else {
  112. this.$store.dispatch('product/getUserCollectCode', {keyword: this.keyword, count: 10, page: page, type: 'no', enUU: this.$store.state.option.user.data.enterprise.uu})
  113. }
  114. },
  115. getMoreSearch() {
  116. this.page++
  117. this.getAttentionListArray(this.page)
  118. }
  119. },
  120. components: {
  121. RemindBox,
  122. PullUp
  123. },
  124. filters: {
  125. filterStr(val) {
  126. if (val.length > 30) {
  127. return val.substr(0, 30) + '...'
  128. }
  129. return val
  130. }
  131. }
  132. }
  133. </script>
  134. <style scoped lang='scss'>
  135. .attention-bus-wrap {
  136. background: #f1f3f6;
  137. margin: 1.26rem 0 0.98rem 0;
  138. height: calc(100vh - 1.26rem - 0.98rem);
  139. overflow-y: auto;
  140. padding-bottom: 0.2rem;
  141. .product-switch-item {
  142. text-align: center;
  143. background: #fff;
  144. border-bottom: 1px solid #d8d8d8;
  145. box-shadow: 0 1px 3px #ddd;
  146. .mobile-switch-btn {
  147. background: #fff;
  148. color: #333;
  149. display: inline-block;
  150. height: .72rem;
  151. line-height: .72rem;
  152. font-size: .28rem;
  153. width: 1.4rem;
  154. &:first-child {
  155. margin-right: 1.78rem;
  156. }
  157. &.active {
  158. color: #3f84f6;
  159. border-bottom: .04rem solid #3f84f6;
  160. }
  161. }
  162. }
  163. .search-content {
  164. text-align: center;
  165. padding: .25rem 0 0 0;
  166. input {
  167. width: 7.1rem;
  168. border: 1px solid #376ff3;
  169. }
  170. span {
  171. height: .46rem;
  172. line-height: .46rem;
  173. }
  174. }
  175. .attention-bus-list {
  176. border: 0.01rem solid #e3e5e8;
  177. border-radius: 4px;
  178. background: #fff;
  179. width: 7.1rem;
  180. margin: 0 auto;
  181. ul {
  182. li {
  183. display: table;
  184. border-bottom: 1px solid #d3d3d3;
  185. margin: 0 0.24rem;
  186. height: 1.1rem;
  187. &:nth-last-of-type(1) {
  188. border-bottom: 0;
  189. }
  190. div {
  191. display: table-cell;
  192. vertical-align: middle;
  193. position: relative;
  194. word-wrap: break-word;
  195. &.name {
  196. font-size: 0.28rem;
  197. color: #666;
  198. width: 5.48rem;
  199. overflow : hidden;
  200. }
  201. &.attention-button {
  202. width: 1.2rem;
  203. font-size: 0.24rem;
  204. color: #666;
  205. text-align: center;
  206. .icon-shoucang {
  207. &.active {
  208. color: #ff7800
  209. }
  210. color: #dadada;
  211. font-size: 0.5rem;
  212. }
  213. }
  214. }
  215. }
  216. }
  217. }
  218. .fixedAlert {
  219. position: fixed;
  220. z-index: 11;
  221. width: 4.91rem;
  222. height: 0.7rem;
  223. line-height:0.7rem;
  224. left: 50%;
  225. margin-left: -2.455rem;
  226. background: rgba(82, 147, 255, 0.9);
  227. border-radius: 0.7rem;
  228. font-size: 0.32rem;
  229. color: #fff;
  230. text-align: center;
  231. top: 2.6rem;
  232. i {
  233. font-size: 0.4rem;
  234. position: absolute;
  235. right: -0.15rem;
  236. top: -0.28rem;
  237. color: rgba(61, 61, 61, 0.76);
  238. &:after {
  239. position: absolute;
  240. top: -0.1rem;
  241. right: -0.1rem;
  242. left: -0.1rem;
  243. bottom: -0.1rem;
  244. content: ' ';
  245. }
  246. }
  247. }
  248. }
  249. </style>