component.vue 5.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187
  1. <template>
  2. <div class="mobile-center">
  3. <div class="com-mobile-header">
  4. <a @click="goLastPage"><i class="iconfont icon-fanhui"></i></a>
  5. <p>器件收藏</p>
  6. </div>
  7. <div class="mobile-content">
  8. <ul v-if="compList && compList.length">
  9. <li v-for="comp in compList">
  10. <div class="fl">
  11. <p>型号:<span v-text="comp.componentinfo.code"></span></p>
  12. <p>品牌:<span v-text="comp.componentinfo.brand.nameCn"></span></p>
  13. <p>产品描述:<span v-text="comp.componentinfo.kind.nameCn"></span></p>
  14. </div>
  15. <div class="vir"></div>
  16. <div class="fr">
  17. <i class="iconfont icon-shoucang" @click="cancelFocus(comp, $event)"></i>
  18. <a class="sa-pub" @click="compInquiry(comp, $event)">立即询价</a>
  19. </div>
  20. </li>
  21. </ul>
  22. </div>
  23. <remind-box :title="remindText" :timeoutCount="timeoutCount"></remind-box>
  24. <pull-up :searchMore="fetching" :allPage="allPage" :page="page" @pullUpAction="onPullUpAction"></pull-up>
  25. <publish-supplier-seek :product="componentSeekObj" :showPublishBox="showPublishBox" @cancelAction="showPublishBox = false" @remindAction="onRemind"></publish-supplier-seek>
  26. </div>
  27. </template>
  28. <script>
  29. import { RemindBox, PullUp } from '~components/mobile/common'
  30. import { PublishSupplierSeek } from '~components/mobile/applyPurchase'
  31. export default {
  32. middleware: 'authenticated',
  33. layout: 'mobileNoHeader',
  34. data () {
  35. return {
  36. remindText: '',
  37. timeoutCount: 0,
  38. page: 1,
  39. count: 10,
  40. isChange: false,
  41. compList: [],
  42. componentSeekObj: {
  43. standard: 1,
  44. cmpCode: '',
  45. pbranden: '',
  46. spec: null,
  47. kind: ''
  48. },
  49. showPublishBox: false
  50. }
  51. },
  52. watch: {
  53. 'compCollectList.data': {
  54. handler: function (val) {
  55. if (this.isChange) {
  56. this.compList = val.content
  57. this.isChange = false
  58. } else {
  59. this.compList = [...this.compList, ...val.content]
  60. }
  61. },
  62. immediate: true
  63. }
  64. },
  65. computed: {
  66. compCollectList () {
  67. return this.$store.state.product.common.collectList
  68. },
  69. fetching () {
  70. return this.compCollectList.fetching
  71. },
  72. allPage () {
  73. return Math.floor(this.compCollectList.data.totalElements / this.compCollectList.data.size) + Math.floor(this.compCollectList.data.totalElements % this.compCollectList.data.size > 0 ? 1 : 0)
  74. }
  75. },
  76. fetch ({ store }) {
  77. return Promise.all([
  78. // 获取器件收藏列表
  79. store.dispatch('product/saveStores', { count: 10, page: 1, type: 'component' })
  80. ])
  81. },
  82. components: {
  83. RemindBox,
  84. PullUp,
  85. PublishSupplierSeek
  86. },
  87. methods: {
  88. onRemind: function (str) {
  89. this.remindText = str
  90. this.timeoutCount++
  91. },
  92. cancelFocus: function (item, event) {
  93. event.stopPropagation()
  94. this.$http.delete('/trade/collection/' + item.id)
  95. .then(response => {
  96. this.onRemind('取消收藏成功')
  97. this.isChange = true
  98. this.page = 1
  99. this.reloadList()
  100. }, err => {
  101. this.onRemind(err.response.data || '取消收藏失败')
  102. })
  103. },
  104. reloadList: function () {
  105. this.$store.dispatch('product/saveStores', { page: this.page, count: this.count, type: 'component' })
  106. },
  107. onPullUpAction: function () {
  108. this.page++
  109. this.reloadList()
  110. },
  111. compInquiry: function (item, e) {
  112. if (e) {
  113. e.stopPropagation()
  114. }
  115. this.componentSeekObj.cmpCode = item.componentinfo.code
  116. this.componentSeekObj.pbranden = item.componentinfo.brand.nameCn
  117. this.componentSeekObj.spec = null
  118. this.componentSeekObj.kind = item.componentinfo.kind.nameCn
  119. this.componentSeekObj = JSON.parse(JSON.stringify(this.componentSeekObj))
  120. this.showPublishBox = true
  121. }
  122. }
  123. }
  124. </script>
  125. <style lang="scss" scoped>
  126. .mobile-content {
  127. ul {
  128. width: 7.1rem;
  129. margin: 0 auto;
  130. li {
  131. height: 1.8rem;
  132. border-radius: .05rem;
  133. border: 1px solid #ccc;
  134. margin: .25rem 0 0 0;
  135. position: relative;
  136. .fl {
  137. width: 4.71rem;
  138. color: #666;
  139. padding: .25rem .1rem .25rem .23rem;
  140. p {
  141. font-size: .3rem;
  142. line-height: .42rem;
  143. overflow: hidden;
  144. text-overflow: ellipsis;
  145. white-space: nowrap;
  146. span {
  147. color: #333;
  148. }
  149. }
  150. }
  151. .vir {
  152. position: absolute;
  153. top: .28rem;
  154. bottom: .28rem;
  155. right: 2.36rem;
  156. border-right: .01rem dashed #9f9f9f;
  157. }
  158. .fr {
  159. width: 2.34rem;
  160. text-align: center;
  161. i {
  162. display: block;
  163. color: #ff7800;
  164. font-size: .5rem;
  165. width: .6rem;
  166. height: .6rem;
  167. line-height: .6rem;
  168. text-align: center;
  169. margin: .29rem auto .1rem;
  170. }
  171. .sa-pub {
  172. display: block;
  173. width: 1.7rem;
  174. height: .47rem;
  175. line-height: .47rem;
  176. text-align: center;
  177. font-size: .26rem;
  178. color: #fff;
  179. background: #008bf7;
  180. margin: 0 auto;
  181. border-radius: .05rem;
  182. }
  183. }
  184. }
  185. }
  186. }
  187. </style>