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-shoucang1" :class="item.status ? 'icon-shoucang1' : 'icon-shoucang2'"></i>
  22. <p v-text="item.status === 1 ? '已关注' : '关注'">已关注</p>
  23. </div>
  24. </div>
  25. </li>
  26. </ul>
  27. </div>
  28. <div class="none-state" v-if="!isSearchSearchingMore && attentionList.length === 0">
  29. <img src="/images/mobile/@2x/search-empty.png">
  30. <p>暂无数据</p>
  31. <nuxt-link to="/">返回首页</nuxt-link>
  32. </div>
  33. <div class="fixedAlert" v-show="isShowAlert">
  34. 关注物料名称,商机无限!
  35. <i class="iconfont icon-guanbi" @click="isShowAlert = false"></i>
  36. </div>
  37. <remind-box :title="collectResult" :timeoutCount="timeoutCount"></remind-box>
  38. <pull-up :fixId="'attention-bus-wrap'" :searchMore="isSearchSearchingMore" :allPage="allPage" :page="page" @pullUpAction="getMoreSearch"></pull-up>
  39. </div>
  40. </template>
  41. <script>
  42. import { RemindBox, PullUp } from '~components/mobile/common'
  43. export default {
  44. name: 'attention-Bus',
  45. layout: 'mobile',
  46. middleware: 'authenticated',
  47. fetch({store}) {
  48. return Promise.all([
  49. store.dispatch('product/getUserCollectCode', {keyword: '', count: 10, page: 1, type: 'yes', enUU: store.state.option.user.data.enterprise.uu})
  50. ])
  51. },
  52. data() {
  53. return {
  54. activeType: 'attention',
  55. keyword: '',
  56. collectResult: '',
  57. timeoutCount: 0,
  58. page: 1,
  59. attentionList: [],
  60. isShowAlert: true,
  61. isSearchSearchingMore: false
  62. }
  63. },
  64. watch: {
  65. 'getkindConcernList.data': {
  66. handler: function (val) {
  67. if (this.isChange) {
  68. this.attentionList = val.content
  69. this.isChange = false
  70. } else {
  71. this.attentionList = [...this.attentionList, ...val.content]
  72. }
  73. this.isSearchSearchingMore = false
  74. },
  75. immediate: true
  76. }
  77. },
  78. computed: {
  79. allPage() {
  80. return Math.ceil(this.$store.state.product.component.collectCode.data.totalElements / 10)
  81. },
  82. getkindConcernList() {
  83. return this.$store.state.product.component.collectCode
  84. }
  85. },
  86. methods: {
  87. ChangeTab(a) {
  88. this.activeType = a
  89. this.attentionList = []
  90. this.page = 1
  91. this.keyword = ''
  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. i{
  229. color: #008bf7;
  230. font-size: 0.5rem;
  231. }
  232. p{
  233. font-size: .26rem;
  234. color: #008bf7;
  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>