attentionBus.vue 8.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299
  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" v-if="attentionList.length > 0">
  14. <ul>
  15. <li v-for="(item, index) in attentionList" v-bind:key="index">
  16. <div class="item">
  17. <div class="name">
  18. {{ item.nameCn | filterStr}}
  19. </div>
  20. <div class="attention-button" @click="attentionFn(item, index)">
  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="none-state" v-else>
  30. <img src="/images/mobile/@2x/search-empty.png">
  31. <p>暂无数据</p>
  32. <nuxt-link to="/">返回首页</nuxt-link>
  33. </div>
  34. <div class="fixedAlert" v-show="isShowAlert">
  35. 关注类目,商机无限!
  36. <i class="iconfont icon-guanbi" @click="isShowAlert = false"></i>
  37. </div>
  38. <remind-box :title="collectResult" :timeoutCount="timeoutCount"></remind-box>
  39. <pull-up :fixId="'attention-bus-wrap'" :searchMore="isSearchSearchingMore" :allPage="allPage" :page="page" @pullUpAction="getMoreSearch"></pull-up>
  40. </div>
  41. </template>
  42. <script>
  43. import { RemindBox, PullUp } from '~components/mobile/common'
  44. export default {
  45. name: 'attention-Bus',
  46. layout: 'mobile',
  47. middleware: 'authenticated',
  48. fetch({store}) {
  49. return Promise.all([
  50. store.dispatch('product/getUserCollectCode', {keyword: '', count: 10, page: 1, type: 'yes', enUU: store.state.option.user.data.enterprise.uu})
  51. ])
  52. },
  53. data() {
  54. return {
  55. activeType: 'attention',
  56. keyword: '',
  57. collectResult: '',
  58. timeoutCount: 0,
  59. page: 1,
  60. attentionList: [],
  61. isShowAlert: true,
  62. isSearchSearchingMore: false
  63. }
  64. },
  65. watch: {
  66. 'getkindConcernList.data': {
  67. handler: function (val) {
  68. if (this.isChange) {
  69. this.attentionList = val.content
  70. this.isChange = false
  71. } else {
  72. this.attentionList = [...this.attentionList, ...val.content]
  73. }
  74. this.isSearchSearchingMore = false
  75. },
  76. immediate: true
  77. }
  78. },
  79. computed: {
  80. allPage() {
  81. return Math.ceil(this.$store.state.product.component.collectCode.data.totalElements / 10)
  82. },
  83. getkindConcernList() {
  84. return this.$store.state.product.component.collectCode
  85. }
  86. },
  87. methods: {
  88. ChangeTab(a) {
  89. this.activeType = a
  90. this.attentionList = []
  91. this.page = 1
  92. this.getAttentionListArray(this.page)
  93. },
  94. searchSeek() {
  95. this.page = 0
  96. this.attentionList = []
  97. this.getMoreSearch()
  98. },
  99. attentionFn(kindConcern, index) {
  100. let param = {
  101. date: kindConcern.date,
  102. enUU: kindConcern.enUU,
  103. nameCn: kindConcern.nameCn,
  104. nameEn: kindConcern.nameEn,
  105. status: kindConcern.status
  106. }
  107. if (kindConcern.status === 1) {
  108. param.id = kindConcern.id
  109. this.$http.post('/produce/kindConcern/modify', param).then(res => {
  110. this.collectResult = '取消成功'
  111. this.timeoutCount++
  112. this.attentionList.splice(index, 1)
  113. if (this.attentionList.length <= 15 && this.page < this.allPage) {
  114. this.page++
  115. this.getAttentionListArray(this.page)
  116. }
  117. })
  118. } else {
  119. this.$http.post('/produce/kindConcern/modify', param).then(res => {
  120. this.collectResult = '关注成功'
  121. this.timeoutCount++
  122. this.attentionList.splice(index, 1)
  123. if (this.attentionList.length <= 15 && this.page < this.allPage) {
  124. this.page++
  125. this.getAttentionListArray(this.page)
  126. }
  127. })
  128. }
  129. },
  130. getAttentionListArray(page) {
  131. this.isSearchSearchingMore = true
  132. if (this.activeType === 'attention') {
  133. this.$store.dispatch('product/getUserCollectCode', {keyword: this.keyword, count: 20, page: page, type: 'yes', enUU: this.$store.state.option.user.data.enterprise.uu})
  134. } else {
  135. this.$store.dispatch('product/getUserCollectCode', {keyword: this.keyword, count: 20, page: page, type: 'no', enUU: this.$store.state.option.user.data.enterprise.uu})
  136. }
  137. },
  138. getMoreSearch() {
  139. this.page++
  140. this.getAttentionListArray(this.page)
  141. }
  142. },
  143. components: {
  144. RemindBox,
  145. PullUp
  146. },
  147. filters: {
  148. filterStr(val) {
  149. if (val.length > 30) {
  150. return val.substr(0, 30) + '...'
  151. }
  152. return val
  153. }
  154. }
  155. }
  156. </script>
  157. <style scoped lang='scss'>
  158. .attention-bus-wrap {
  159. background: #f1f3f6;
  160. margin: 1.26rem 0 0.98rem 0;
  161. height: calc(100vh - 1.26rem - 0.98rem);
  162. overflow-y: auto;
  163. padding-bottom: 0.2rem;
  164. .product-switch-item {
  165. text-align: center;
  166. background: #fff;
  167. border-bottom: 1px solid #d8d8d8;
  168. box-shadow: 0 1px 3px #ddd;
  169. .mobile-switch-btn {
  170. color: #333;
  171. display: inline-block;
  172. height: .72rem;
  173. line-height: .72rem;
  174. font-size: .28rem;
  175. width: 1.4rem;
  176. &:first-child {
  177. margin-right: 1.78rem;
  178. }
  179. &.active {
  180. color: #3f84f6;
  181. border-bottom: .04rem solid #3f84f6;
  182. }
  183. }
  184. }
  185. .search-content {
  186. text-align: center;
  187. padding: .25rem 0 0 0;
  188. input {
  189. width: 7.1rem;
  190. border: 1px solid #376ff3;
  191. }
  192. span {
  193. height: .46rem;
  194. line-height: .46rem;
  195. }
  196. }
  197. .attention-bus-list {
  198. border: 0.01rem solid #e3e5e8;
  199. border-radius: 4px;
  200. background: #fff;
  201. width: 7.1rem;
  202. margin: 0 auto;
  203. ul {
  204. li {
  205. display: table;
  206. border-bottom: 1px solid #d3d3d3;
  207. margin: 0 0.24rem;
  208. height: 1.1rem;
  209. &:nth-last-of-type(1) {
  210. border-bottom: 0;
  211. }
  212. div {
  213. display: table-cell;
  214. vertical-align: middle;
  215. position: relative;
  216. word-wrap: break-word;
  217. &.name {
  218. font-size: 0.28rem;
  219. color: #666;
  220. width: 5.48rem;
  221. overflow : hidden;
  222. }
  223. &.attention-button {
  224. width: 1.2rem;
  225. font-size: 0.24rem;
  226. color: #666;
  227. text-align: center;
  228. .icon-shoucang {
  229. &.active {
  230. color: #ff7800
  231. }
  232. color: #dadada;
  233. font-size: 0.5rem;
  234. }
  235. }
  236. }
  237. }
  238. }
  239. }
  240. .fixedAlert {
  241. position: fixed;
  242. z-index: 11;
  243. width: 4.91rem;
  244. height: 0.7rem;
  245. line-height:0.7rem;
  246. left: 50%;
  247. margin-left: -2.455rem;
  248. background: rgba(82, 147, 255, 0.9);
  249. border-radius: 0.7rem;
  250. font-size: 0.32rem;
  251. color: #fff;
  252. text-align: center;
  253. top: 2.6rem;
  254. i {
  255. font-size: 0.4rem;
  256. position: absolute;
  257. right: -0.15rem;
  258. top: -0.28rem;
  259. color: rgba(61, 61, 61, 0.76);
  260. &:after {
  261. position: absolute;
  262. top: -0.1rem;
  263. right: -0.1rem;
  264. left: -0.1rem;
  265. bottom: -0.1rem;
  266. content: ' ';
  267. }
  268. }
  269. }
  270. .none-state{
  271. text-align: center;
  272. padding:1.5rem 0;
  273. background: #fff;
  274. margin-top:.1rem;
  275. width:100%;
  276. img{
  277. margin:0 auto;
  278. width: 4.08rem;
  279. height: 2.62rem;
  280. }
  281. p {
  282. font-size: .32rem;
  283. color: #999;
  284. margin: 1.19rem 0 0 0;
  285. }
  286. a {
  287. display: block;
  288. font-size: .28rem;
  289. color: #fff;
  290. width: 1.88rem;
  291. height: .54rem;
  292. line-height: .54rem;
  293. background: #418bf6;
  294. margin: .7rem auto 0;
  295. border-radius: .05rem;
  296. }
  297. }
  298. }
  299. </style>