component.vue 6.0 KB

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