attentionBus.vue 9.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300
  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-if="!isSearchSearchingMore && attentionList.length === 0">
  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.keyword = ''
  93. this.getAttentionListArray(this.page)
  94. },
  95. searchSeek() {
  96. this.page = 0
  97. this.attentionList = []
  98. this.getMoreSearch()
  99. },
  100. attentionFn(kindConcern, index) {
  101. let param = {
  102. date: kindConcern.date,
  103. enUU: kindConcern.enUU,
  104. nameCn: kindConcern.nameCn,
  105. nameEn: kindConcern.nameEn,
  106. status: kindConcern.status
  107. }
  108. if (kindConcern.status === 1) {
  109. param.id = kindConcern.id
  110. this.$http.post('/produce/kindConcern/modify', param).then(res => {
  111. this.collectResult = '取消成功'
  112. this.timeoutCount++
  113. this.attentionList.splice(index, 1)
  114. if (this.attentionList.length <= 15 && this.page < this.allPage) {
  115. this.page++
  116. this.getAttentionListArray(this.page)
  117. }
  118. })
  119. } else {
  120. this.$http.post('/produce/kindConcern/modify', param).then(res => {
  121. this.collectResult = '关注成功'
  122. this.timeoutCount++
  123. this.attentionList.splice(index, 1)
  124. if (this.attentionList.length <= 15 && this.page < this.allPage) {
  125. this.page++
  126. this.getAttentionListArray(this.page)
  127. }
  128. })
  129. }
  130. },
  131. getAttentionListArray(page) {
  132. this.isSearchSearchingMore = true
  133. if (this.activeType === 'attention') {
  134. this.$store.dispatch('product/getUserCollectCode', {keyword: this.keyword, count: 20, page: page, type: 'yes', enUU: this.$store.state.option.user.data.enterprise.uu})
  135. } else {
  136. this.$store.dispatch('product/getUserCollectCode', {keyword: this.keyword, count: 20, page: page, type: 'no', enUU: this.$store.state.option.user.data.enterprise.uu})
  137. }
  138. },
  139. getMoreSearch() {
  140. this.page++
  141. this.getAttentionListArray(this.page)
  142. }
  143. },
  144. components: {
  145. RemindBox,
  146. PullUp
  147. },
  148. filters: {
  149. filterStr(val) {
  150. if (val.length > 30) {
  151. return val.substr(0, 30) + '...'
  152. }
  153. return val
  154. }
  155. }
  156. }
  157. </script>
  158. <style scoped lang='scss'>
  159. .attention-bus-wrap {
  160. background: #f1f3f6;
  161. margin: 1.26rem 0 0.98rem 0;
  162. height: calc(100vh - 1.26rem - 0.98rem);
  163. overflow-y: auto;
  164. padding-bottom: 0.2rem;
  165. .product-switch-item {
  166. text-align: center;
  167. background: #fff;
  168. border-bottom: 1px solid #d8d8d8;
  169. box-shadow: 0 1px 3px #ddd;
  170. .mobile-switch-btn {
  171. color: #333;
  172. display: inline-block;
  173. height: .72rem;
  174. line-height: .72rem;
  175. font-size: .28rem;
  176. width: 1.4rem;
  177. &:first-child {
  178. margin-right: 1.78rem;
  179. }
  180. &.active {
  181. color: #3f84f6;
  182. border-bottom: .04rem solid #3f84f6;
  183. }
  184. }
  185. }
  186. .search-content {
  187. text-align: center;
  188. padding: .25rem 0 0 0;
  189. input {
  190. width: 7.1rem;
  191. border: 1px solid #376ff3;
  192. }
  193. span {
  194. height: .46rem;
  195. line-height: .46rem;
  196. }
  197. }
  198. .attention-bus-list {
  199. border: 0.01rem solid #e3e5e8;
  200. border-radius: 4px;
  201. background: #fff;
  202. width: 7.1rem;
  203. margin: 0 auto;
  204. ul {
  205. li {
  206. display: table;
  207. border-bottom: 1px solid #d3d3d3;
  208. margin: 0 0.24rem;
  209. height: 1.1rem;
  210. &:nth-last-of-type(1) {
  211. border-bottom: 0;
  212. }
  213. div {
  214. display: table-cell;
  215. vertical-align: middle;
  216. position: relative;
  217. word-wrap: break-word;
  218. &.name {
  219. font-size: 0.28rem;
  220. color: #666;
  221. width: 5.48rem;
  222. overflow : hidden;
  223. }
  224. &.attention-button {
  225. width: 1.2rem;
  226. font-size: 0.24rem;
  227. color: #666;
  228. text-align: center;
  229. .icon-shoucang {
  230. &.active {
  231. color: #ff7800
  232. }
  233. color: #dadada;
  234. font-size: 0.5rem;
  235. }
  236. }
  237. }
  238. }
  239. }
  240. }
  241. .fixedAlert {
  242. position: fixed;
  243. z-index: 11;
  244. width: 4.91rem;
  245. height: 0.7rem;
  246. line-height:0.7rem;
  247. left: 50%;
  248. margin-left: -2.455rem;
  249. background: rgba(82, 147, 255, 0.9);
  250. border-radius: 0.7rem;
  251. font-size: 0.32rem;
  252. color: #fff;
  253. text-align: center;
  254. top: 2.6rem;
  255. i {
  256. font-size: 0.4rem;
  257. position: absolute;
  258. right: -0.15rem;
  259. top: -0.28rem;
  260. color: rgba(61, 61, 61, 0.76);
  261. &:after {
  262. position: absolute;
  263. top: -0.1rem;
  264. right: -0.1rem;
  265. left: -0.1rem;
  266. bottom: -0.1rem;
  267. content: ' ';
  268. }
  269. }
  270. }
  271. .none-state{
  272. text-align: center;
  273. padding:1.5rem 0;
  274. background: #fff;
  275. margin-top:.1rem;
  276. width:100%;
  277. img{
  278. margin:0 auto;
  279. width: 4.08rem;
  280. height: 2.62rem;
  281. }
  282. p {
  283. font-size: .32rem;
  284. color: #999;
  285. margin: 1.19rem 0 0 0;
  286. }
  287. a {
  288. display: block;
  289. font-size: .28rem;
  290. color: #fff;
  291. width: 1.88rem;
  292. height: .54rem;
  293. line-height: .54rem;
  294. background: #418bf6;
  295. margin: .7rem auto 0;
  296. border-radius: .05rem;
  297. }
  298. }
  299. }
  300. </style>