_key.vue 11 KB

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