component.vue 6.3 KB

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