attentionBus.vue 9.2 KB

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