index.vue 9.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291
  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. <div class="search-content search-content2" style="position: relative">
  10. <input type="text" placeholder="请输入您要查找的型号" @input="onBrandChange" v-model="keyword" @keyup.13="searchComplist">
  11. <span @click.stop="searchComplist" >
  12. <i class="iconfont icon-sousuo"></i>
  13. </span>
  14. <ul class="similar brand-similar-list" v-show="showSimilarCodeList && keyword">
  15. <li v-for="sBrand in similarBrand" :key="sBrand.code" @click.stop="setBrand(sBrand.code)">{{sBrand.code}}</li>
  16. </ul>
  17. </div>
  18. <ul v-if="compList && compList.length">
  19. <li class="clearfix" :key="comp.componentid" v-for="comp in compList" @click="goUrl('/mobile/brand/componentDetail/' + comp.componentinfo.uuid)">
  20. <div class="fl">
  21. <p>品牌:<span v-text="comp.componentinfo.brand.nameCn || '-'"></span></p>
  22. <p>物料名称:<span v-text="comp.componentinfo.kind.nameCn || '-'"></span></p>
  23. <p>型号:<span v-text="comp.componentinfo.code || '-'"></span></p>
  24. <p>规格:<span v-text="comp.componentinfo.spec || '-'"></span></p>
  25. <p>产品描述:<span v-text="comp.componentinfo.description || '-'"></span></p>
  26. </div>
  27. <div class="vir"></div>
  28. <div class="fr">
  29. <i class="iconfont icon-shoucang" @click="cancelFocus(comp, $event)"></i>
  30. <a class="sa-pub" @click="compInquiry(comp, $event)">立即询价</a>
  31. </div>
  32. </li>
  33. </ul>
  34. <empty-status :type="'collect'" :showLink="true" :text="'抱歉,暂无器件收藏'" v-else></empty-status>
  35. </div>
  36. <remind-box :title="remindText" :timeoutCount="timeoutCount"></remind-box>
  37. <pull-up :fixId="'mobileFixContent'" :searchMore="fetching" :allPage="allPage" :page="page" @pullUpAction="onPullUpAction"></pull-up>
  38. <publish-supplier-seek :product="componentSeekObj" :showPublishBox="showPublishBox" @cancelAction="showPublishBox = false" @remindAction="onRemind"></publish-supplier-seek>
  39. </div>
  40. </template>
  41. <script>
  42. import { RemindBox, PullUp, EmptyStatus } from '~components/mobile/common'
  43. import { PublishSupplierSeek } from '~components/mobile/applyPurchase'
  44. export default {
  45. middleware: 'authenticated',
  46. layout: 'mobileNoHeader',
  47. data () {
  48. return {
  49. keyword: '',
  50. showSimilarCodeList: false,
  51. similarBrand: '',
  52. remindText: '',
  53. timeoutCount: 0,
  54. page: 1,
  55. count: 10,
  56. isChange: false,
  57. compList: [],
  58. componentSeekObj: {
  59. standard: 1,
  60. cmpCode: '',
  61. pbranden: '',
  62. spec: null,
  63. kind: ''
  64. },
  65. showPublishBox: false
  66. }
  67. },
  68. watch: {
  69. 'compCollectList.data': {
  70. handler: function (val) {
  71. if (this.isChange) {
  72. this.compList = val.content
  73. this.isChange = false
  74. } else {
  75. this.compList = [...this.compList, ...val.content]
  76. }
  77. },
  78. immediate: true
  79. }
  80. },
  81. computed: {
  82. compCollectList () {
  83. return this.$store.state.product.common.collectListMobile
  84. },
  85. fetching () {
  86. return this.compCollectList.fetching
  87. },
  88. allPage () {
  89. return Math.floor(this.compCollectList.data.totalElements / this.compCollectList.data.size) + Math.floor(this.compCollectList.data.totalElements % this.compCollectList.data.size > 0 ? 1 : 0)
  90. }
  91. },
  92. fetch ({ store }) {
  93. return Promise.all([
  94. // 获取器件收藏列表
  95. store.dispatch('product/getCollectList', { count: 10, page: 1, type: 'component' })
  96. ])
  97. },
  98. components: {
  99. RemindBox,
  100. PullUp,
  101. PublishSupplierSeek,
  102. EmptyStatus
  103. },
  104. methods: {
  105. onBrandChange: function () {
  106. this.keyword = this.keyword.trim()
  107. if ((/[^\x00-\xff]/g).test(this.keyword)) {
  108. let chineseIndex = -1
  109. for (let i = 0; i < this.keyword.length; i++) {
  110. if ((/[^\x00-\xff]/g).test(this.keyword.charAt(i)) && !(/[\u4e00-\u9fa5]/).test(this.keyword.charAt(i))) {
  111. chineseIndex = i
  112. break
  113. }
  114. }
  115. if (chineseIndex > -1) {
  116. this.keyword = this.keyword.substring(0, chineseIndex)
  117. }
  118. } else if (this.keyword && this.baseUtils.getRealLen(this.keyword) > 50) {
  119. this.keyword = this.baseUtils.cutOutString(this.keyword, 50)
  120. } else {
  121. this.getSimilarBrand()
  122. }
  123. },
  124. getSimilarBrand: function () {
  125. if (this.keyword) {
  126. this.$http.get('/search/similarKeywords', {params: {keyword: this.keyword, type: 'component'}})
  127. .then(response => {
  128. this.similarBrand = response.data.result
  129. this.showSimilarCodeList = response.data.result.length > 0
  130. })
  131. } else {
  132. this.showSimilarCodeList = false
  133. }
  134. },
  135. setBrand: function (brand) {
  136. this.keyword = brand
  137. this.showSimilarCodeList = false
  138. this.searchComplist()
  139. },
  140. searchComplist () {
  141. if (this.keyword !== '') {
  142. this.showSimilarCodeList = false
  143. this.$router.push(`/mobile/center/user/collect/component/${this.keyword}`)
  144. } else {
  145. this.remindText = '请输入您要查找的型号'
  146. this.timeoutCount++
  147. }
  148. },
  149. onRemind: function (str) {
  150. this.remindText = str
  151. this.timeoutCount++
  152. },
  153. cancelFocus: function (item, event) {
  154. event.stopPropagation()
  155. this.$http.delete('/trade/collection/' + item.id)
  156. .then(response => {
  157. this.onRemind('取消成功')
  158. this.isChange = true
  159. this.page = 1
  160. this.reloadList()
  161. }, err => {
  162. this.onRemind(err.response.data || '取消失败')
  163. })
  164. },
  165. reloadList: function () {
  166. this.$store.dispatch('product/getCollectList', { page: this.page, count: this.count, type: 'component' })
  167. },
  168. onPullUpAction: function () {
  169. this.page++
  170. this.reloadList()
  171. },
  172. compInquiry: function (item, e) {
  173. if (e) {
  174. e.stopPropagation()
  175. }
  176. this.componentSeekObj.cmpCode = item.componentinfo.code
  177. this.componentSeekObj.pbranden = item.componentinfo.brand.nameCn
  178. this.componentSeekObj.spec = null
  179. this.componentSeekObj.kind = item.componentinfo.kind.nameCn
  180. this.componentSeekObj = JSON.parse(JSON.stringify(this.componentSeekObj))
  181. this.showPublishBox = true
  182. },
  183. goUrl: function (url) {
  184. // console.log(url)
  185. this.$router.push(url)
  186. }
  187. }
  188. }
  189. </script>
  190. <style lang="scss" scoped>
  191. .mobile-fix-content {
  192. .similar {
  193. position: absolute;
  194. width: 6.5rem;
  195. max-height: 2.5rem;
  196. overflow-y: auto;
  197. z-index: 12;
  198. border: 1px solid #7e7e7e;
  199. border-radius: .05rem;
  200. top: .7rem;
  201. background: #fff;
  202. left: 0.1rem;
  203. right: 0;
  204. margin: 0 auto;
  205. li {
  206. height: .5rem;
  207. line-height: .5rem;
  208. font-size: .26rem;
  209. color: #999;
  210. padding-left: .19rem;
  211. text-align: left;
  212. overflow: hidden;
  213. text-overflow: ellipsis;
  214. white-space: nowrap;
  215. &:focus, &:active, &:hover {
  216. background: #999;
  217. color: #fff;
  218. }
  219. }
  220. }
  221. .search-content {
  222. text-align: center;
  223. input {
  224. border: 1px solid #376ff3;
  225. }
  226. span{
  227. top:0;
  228. }
  229. }
  230. > ul {
  231. width: 7.1rem;
  232. margin: 0 auto;
  233. li {
  234. border-radius: .05rem;
  235. border: 1px solid #ccc;
  236. margin: .25rem 0 0 0;
  237. position: relative;
  238. background: #fff;
  239. .fl {
  240. width: 4.71rem;
  241. color: #666;
  242. padding: .25rem .1rem .25rem .23rem;
  243. p {
  244. font-size: .3rem;
  245. line-height: .42rem;
  246. overflow: hidden;
  247. text-overflow: ellipsis;
  248. white-space: nowrap;
  249. span {
  250. color: #333;
  251. }
  252. }
  253. }
  254. .vir {
  255. position: absolute;
  256. top: .28rem;
  257. bottom: .28rem;
  258. right: 2.36rem;
  259. border-right: .01rem dashed #9f9f9f;
  260. }
  261. .fr {
  262. width: 2.34rem;
  263. text-align: center;
  264. margin-top: .3rem;
  265. i {
  266. display: block;
  267. color: #ff7800;
  268. font-size: .5rem;
  269. width: .6rem;
  270. height: .6rem;
  271. line-height: .6rem;
  272. text-align: center;
  273. margin: .29rem auto .1rem;
  274. }
  275. .sa-pub {
  276. display: block;
  277. width: 1.7rem;
  278. height: .47rem;
  279. line-height: .47rem;
  280. text-align: center;
  281. font-size: .26rem;
  282. color: #fff;
  283. background: #008bf7;
  284. margin: 0 auto;
  285. border-radius: .05rem;
  286. }
  287. }
  288. }
  289. }
  290. }
  291. </style>