component.vue 5.9 KB

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