ComponentDetail.vue 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528
  1. <template>
  2. <div class="component-detail mobile-content">
  3. <div class="base-detail">
  4. <div class="base-detail-item" v-if="component.kind.nameCn">
  5. <span>类&nbsp;&nbsp;&nbsp;&nbsp;目:</span>
  6. <span>{{component.kind.nameCn}}</span>
  7. </div>
  8. <div class="base-detail-item" v-if="component.brand.nameCn">
  9. <span>品&nbsp;&nbsp;&nbsp;&nbsp;牌:</span>
  10. <span>{{component.brand.nameCn}}</span>
  11. </div>
  12. <div class="base-detail-item attach" @click="goAttach(component.attach)">
  13. <span v-if="component.attach">规格书:<img src="/images/mobile/@2x/productDetail/pdf.png" alt=""><span>查看</span></span>
  14. <span v-else>规格书:-</span>
  15. </div>
  16. <div class="base-detail-item product-description" v-if="component.description">
  17. <span class="description">产品描述:{{component.description}}</span>
  18. </div>
  19. <i class="iconfont icon-shoucang" :style="isCollect?'color:#ff7800':'color: #ddd'" @click="collectComponent"></i>
  20. </div>
  21. <div class="product-switch-item">
  22. <span :class="activeType=='store'?'mobile-switch-btn active':'mobile-switch-btn'" @click="activeType='store'">商家</span>
  23. <span :class="activeType=='param'?'mobile-switch-btn active':'mobile-switch-btn'" @click="activeType='param'">参数</span>
  24. </div>
  25. <div class="product-params" v-if="activeType == 'param'">
  26. <div class="param-item" v-if="prop.value && prop.value!=''" v-for="prop in component.properties">
  27. <span class="prop-name">{{prop.property.labelCn}}</span>
  28. <span class="prop-value">{{prop.value}}</span>
  29. </div>
  30. </div>
  31. <div class="product-store" v-if="activeType == 'store'">
  32. <table v-if="searchLists&&searchLists.length > 0">
  33. <thead id="product-head">
  34. <tr>
  35. <th style="width: 1.55rem;">商家</th>
  36. <th style="width: 1.59rem;">生产日期</th>
  37. <th style="width: 2.58rem;">价格梯度</th>
  38. <th style="width: 1.77rem;">交期(天)</th>
  39. </tr>
  40. </thead>
  41. <thead class="active" v-show="isScrollOverTab">
  42. <tr>
  43. <th style="width: 1.55rem;">商家</th>
  44. <th style="width: 1.59rem;">生产日期</th>
  45. <th style="width: 2.58rem;">价格梯度</th>
  46. <th style="width: 1.77rem;">交期(天)</th>
  47. </tr>
  48. </thead>
  49. <tbody id="product-body">
  50. <tr v-for="store in searchLists">
  51. <td class="store-name">
  52. <nuxt-link :to="'/mobile/shop/' + store.storeid">
  53. {{store.storeName || '-' | storeNameFilter}}
  54. </nuxt-link>
  55. </td>
  56. <td>
  57. <div v-if="!store.packaging && !store.breakUp && !store.produceDate">-</div>
  58. <div>{{store.produceDate}}</div>
  59. <div>{{store.packaging}}</div>
  60. <div>{{store.breakUp?'可拆卖':'不可拆卖'}}</div>
  61. </td>
  62. <td class="price-level-wrap">
  63. <div v-if="!store.prices || store.prices.length == 0">-</div>
  64. <div class="price-number fl">
  65. <div v-for="price in store.prices">{{price.start}}+</div>
  66. </div>
  67. <div class="price-number fr">
  68. <div v-for="price in store.prices" class="price-level">
  69. <span v-if="store.currencyName.indexOf('RMB')!==-1">¥{{price.rMBPrice | currency}}</span>
  70. <span v-if="store.currencyName.indexOf('USD')!==-1">${{price.uSDPrice | currency}}</span>
  71. </div>
  72. </div>
  73. </td>
  74. <td class="push-date">
  75. <div v-if="store.b2cMinDelivery">
  76. <span>{{store.b2cMinDelivery}}</span>
  77. <span v-if="store.b2cMaxDelivery && store.b2cMaxDelivery !== store.b2cMinDelivery">-</span>
  78. <span v-if="store.b2cMaxDelivery && store.b2cMaxDelivery !== store.b2cMinDelivery">{{store.b2cMaxDelivery}}</span>
  79. </div>
  80. <div v-if="store.minBuyQty"><span class="order-tag">订</span>{{store.minBuyQty}}起订</div>
  81. <div v-if="store.reserve"><span class="order-tag reserve-tag">库</span>{{store.reserve}}</div>
  82. <div v-if="!store.b2cMinDelivery">
  83. <span>—</span>
  84. </div>
  85. </td>
  86. </tr>
  87. </tbody>
  88. </table>
  89. </div>
  90. <div v-if="(storeList.totalElements == 0 && activeType == 'store') || (component.properties && component.properties.length == 0 && activeType == 'param')" class="no-store">
  91. <img src="/images/mobile/@2x/car@2x.png" alt="">
  92. <div v-if="activeType == 'store'">抱歉,暂无商家出售此型号!</div>
  93. <div v-if="activeType == 'store'">您可前往<strong>www.usoftmall.com</strong>网页版进行<strong>“发布求购”</strong>或<strong>“产品上架”</strong>操作!</div>
  94. <div v-if="activeType == 'param'">抱歉,暂无参数信息!</div>
  95. </div>
  96. <remind-box :title="collectResult" :timeoutCount="timeoutCount"></remind-box>
  97. <loading v-show="isSearchingMore"></loading>
  98. <login-box @onLoginBoxClose="showLoginBox = false" v-if="showLoginBox"></login-box>
  99. </div>
  100. </template>
  101. <script>
  102. import {RemindBox, Loading, LoginBox} from '~components/mobile/common'
  103. export default {
  104. data () {
  105. return {
  106. activeType: 'store',
  107. collectResult: '收藏成功',
  108. timeoutCount: 0,
  109. storeIds: [],
  110. UmallExist: false,
  111. storeExist: false,
  112. params: {
  113. count: 10,
  114. page: 1,
  115. sorting: {'minPriceRMB': 'ASC'},
  116. filter: {
  117. uuid: this.$route.params.uuid,
  118. ignoreUMall: false,
  119. ignoreStore: false,
  120. storeIds: ''
  121. }
  122. },
  123. isSearchingMore: false,
  124. searchLists: [],
  125. showLoginBox: false,
  126. isScrollOverTab: false
  127. }
  128. },
  129. components: {
  130. RemindBox,
  131. Loading,
  132. LoginBox
  133. },
  134. mounted: function () {
  135. let _this = this
  136. _this.$nextTick(function () {
  137. window.addEventListener('scroll', function () {
  138. _this.scroll()
  139. }, false)
  140. })
  141. },
  142. computed: {
  143. component () {
  144. return this.$store.state.componentDetail.detail.data
  145. },
  146. storeList () {
  147. let storeList = this.$store.state.componentInformation.information.data
  148. let _self = this
  149. if (storeList.content) {
  150. storeList.content.forEach(function (item) {
  151. _self.storeIds.push(item.storeid)
  152. })
  153. }
  154. if (this.storeIds.length > 0) {
  155. if (this.storeIds.indexOf(this.storeId) === -1) {
  156. this.storeExist = true
  157. } else {
  158. this.storeIds.splice(this.storeIds.indexOf(this.storeId), 1)
  159. if (this.storeIds.length > 0) {
  160. this.storeExist = true
  161. }
  162. this.UmallExist = true
  163. }
  164. }
  165. this.searchLists = this.searchLists.concat(storeList.content)
  166. this.isSearchingMore = false
  167. return storeList
  168. },
  169. allPage () {
  170. return this.storeList.totalPages
  171. },
  172. colList () {
  173. return this.$store.state.product.common.collectList.data
  174. },
  175. isCollect () {
  176. let id = this.component.id
  177. let store = this.colList
  178. if (store) {
  179. for (let i = 0; i < store.length; i++) {
  180. if (store[i].componentid === id) {
  181. return true
  182. }
  183. }
  184. } else {
  185. return false
  186. }
  187. },
  188. user () {
  189. return this.$store.state.option.user
  190. }
  191. },
  192. filters: {
  193. currency: function (num) {
  194. if (typeof num === 'number') {
  195. if (num <= 0.000001) {
  196. num = 0.000001
  197. } else {
  198. if (num.toString().indexOf('.') === -1) {
  199. num += '.00'
  200. } else {
  201. let inputStr = num.toString()
  202. let arr = inputStr.split('.')
  203. let floatNum = arr[1]
  204. if (floatNum.length > 6) {
  205. num = inputStr.substring(0, arr[0].length + 7)
  206. if (Number(floatNum.charAt(6)) > 4) {
  207. num = (Number(num) * 1000000 + 1) / 1000000
  208. }
  209. } else if (floatNum.length === 1) {
  210. num = num + '0'
  211. }
  212. }
  213. }
  214. }
  215. return num
  216. },
  217. storeNameFilter: function (str) {
  218. if (str === '') {
  219. return str
  220. }
  221. let len = 0
  222. let index = 0
  223. for (let i = 0; i < str.length; i++) {
  224. if (index === 0 && str.charAt(i).charCodeAt(0) > 255) {
  225. len = len + 2
  226. } else {
  227. len++
  228. }
  229. if (len > 22) {
  230. index = i
  231. break
  232. }
  233. }
  234. if (index > 0) {
  235. return str.substring(0, index) + '...'
  236. } else {
  237. return str
  238. }
  239. }
  240. },
  241. methods: {
  242. scroll: function () {
  243. let scrolled = document.documentElement.scrollTop || window.pageYOffset || document.body.scrollTop
  244. if (Math.ceil(scrolled + window.screen.availHeight) >= document.body.scrollHeight && !this.isSearchingMore && this.params.page < this.allPage) {
  245. this.getMoreStore()
  246. }
  247. let tbodyObj = document.getElementById('product-body')
  248. let theadObj = document.getElementById('product-head')
  249. this.isScrollOverTab = tbodyObj.getBoundingClientRect().top - theadObj.getBoundingClientRect().height - 5 <= theadObj.getBoundingClientRect().height
  250. },
  251. getMoreStore: function () {
  252. if (!this.isSearchingMore) {
  253. this.params.page++
  254. this.isSearchingMore = true
  255. this.$store.dispatch('loadComponentInformation', this.params)
  256. }
  257. },
  258. goAttach: function (url) {
  259. if (this.user.logged) {
  260. if (url && url !== '1') {
  261. window.location.href = url
  262. }
  263. } else {
  264. this.showLoginBox = true
  265. }
  266. },
  267. collectComponent: function () {
  268. if (this.user.logged) {
  269. if (!this.isCollect) {
  270. this.$store.dispatch('product/saveEntity', {componentid: this.component.id, kind: 2})
  271. this.collectResult = '收藏成功'
  272. this.timeoutCount++
  273. } else {
  274. this.$http.post('/trade/collection/delete/cmpId', [this.component.id]).then(response => {
  275. this.collectResult = '取消成功'
  276. this.timeoutCount++
  277. this.$store.dispatch('product/saveStores')
  278. })
  279. }
  280. } else {
  281. this.showLoginBox = true
  282. }
  283. }
  284. }
  285. }
  286. </script>
  287. <style lang="scss" scoped>
  288. .component-detail {
  289. font-size: .28rem;
  290. margin-bottom: 1.2rem;
  291. background: #f7f7f7;
  292. padding-top: .2rem;
  293. .base-detail {
  294. margin: 0 .27rem .2rem .27rem;
  295. padding: .18rem .36rem 0 .36rem;
  296. border-radius: .1rem;
  297. background: url('/images/mobile/@2x/productDetail/component-desc-bg.png')no-repeat;
  298. background-size: cover;
  299. max-height: 3.17rem;
  300. position: relative;
  301. .base-detail-item {
  302. margin-top: .2rem;
  303. position: relative;
  304. color: #fff;
  305. &:nth-child(1) {
  306. margin-top: 0;
  307. }
  308. &:nth-last-child(1) {
  309. color: #999;
  310. }
  311. &.attach {
  312. display: inline-block;
  313. img {
  314. background-color: #fff;
  315. width: .36rem;
  316. height: .4rem;
  317. position: relative;
  318. bottom: .05rem;
  319. }
  320. >span >span {
  321. margin-left: .1rem;
  322. color: #418bf6;
  323. }
  324. }
  325. &:last-child {
  326. margin-bottom: 0;
  327. }
  328. &.product-description {
  329. height: 1.58rem;
  330. }
  331. .description {
  332. line-height: .4rem;
  333. max-height: 1.2rem;
  334. word-break: break-all;
  335. overflow : hidden;
  336. text-overflow: ellipsis;
  337. display: -webkit-box;
  338. -webkit-line-clamp: 3;
  339. -webkit-box-orient: vertical;
  340. color: #999;
  341. }
  342. }
  343. >i {
  344. position: absolute;
  345. font-size: .4rem;
  346. background: #fff;
  347. width: .6rem;
  348. height: .6rem;
  349. line-height: .6rem;
  350. border-radius: 100%;
  351. box-shadow: 0 0 .05rem #aaa;
  352. right: .28rem;
  353. top: .55rem;
  354. text-align: center;
  355. }
  356. }
  357. .product-switch-item {
  358. text-align: center;
  359. background: #fff;
  360. .mobile-switch-btn {
  361. background: #fff;
  362. color: #666;
  363. display: inline-block;
  364. height: .64rem;
  365. line-height: .64rem;
  366. font-size: .34rem;
  367. width: 1.4rem;
  368. &:first-child {
  369. margin-right: 1.78rem;
  370. }
  371. &.active {
  372. color: #fc5708;
  373. border-bottom: .04rem solid #fc5708;
  374. }
  375. }
  376. }
  377. .product-params {
  378. line-height: .28rem;
  379. margin-top: .2rem;
  380. .param-item {
  381. padding: .19rem .4rem;
  382. border-bottom: 0.04rem solid #eee;
  383. &:nth-child(1) {
  384. border-top: 0.04rem solid #eee;
  385. }
  386. &:nth-child(even) {
  387. background: #f9f9f9;
  388. }
  389. &:nth-child(odd) {
  390. background: #fff;
  391. }
  392. .prop-name {
  393. width: 3.72rem;
  394. display: inline-block;
  395. text-overflow: ellipsis;
  396. overflow: hidden;
  397. white-space: nowrap;
  398. }
  399. .prop-value {
  400. text-overflow: ellipsis;
  401. overflow: hidden;
  402. white-space: nowrap;
  403. display: inline-block;
  404. width: 2.69rem;
  405. float: right;
  406. text-align: right;
  407. }
  408. }
  409. }
  410. .product-store {
  411. margin: .2rem 0;
  412. table {
  413. width: 100%;
  414. font-size: .28rem;
  415. thead {
  416. background: #d5e5fb;
  417. &.active {
  418. position: fixed;
  419. top: .88rem;
  420. z-index: 2;
  421. }
  422. tr {
  423. th {
  424. font-weight: bold;
  425. text-align: center;
  426. height: .78rem;
  427. line-height: .78rem;
  428. >span {
  429. font-size: .22rem;
  430. }
  431. }
  432. }
  433. }
  434. tbody {
  435. background: #fff;
  436. tr {
  437. border-bottom: 0.2rem solid #f7f7f7;
  438. td {
  439. padding: .2rem .1rem;
  440. &.store-name {
  441. color: #418bf6;
  442. a {
  443. padding: 0;
  444. display: block;
  445. width: 1.2rem;
  446. overflow: hidden;
  447. margin-left: .16rem;
  448. }
  449. }
  450. &.price-level-wrap {
  451. text-align: center;
  452. }
  453. > div {
  454. overflow: hidden;
  455. text-overflow: ellipsis;
  456. white-space: nowrap;
  457. max-width: 1.58rem;
  458. }
  459. .price-number {
  460. display: inline-block;
  461. vertical-align: middle;
  462. margin-bottom: 0;
  463. width: .9rem;
  464. }
  465. div {
  466. margin-bottom: .2rem;
  467. text-align: left;
  468. &:last-child {
  469. margin-bottom: 0;
  470. }
  471. }
  472. &.push-date {
  473. text-align: left;
  474. div {
  475. text-align: left;
  476. }
  477. }
  478. .price-level:last-child {
  479. color: #fc5708;
  480. }
  481. .order-tag {
  482. display: inline-block;
  483. font-size: .18rem;
  484. color: #fff;
  485. font-weight: bold;
  486. background: #ee1717;
  487. height: .27rem;
  488. width: .27rem;
  489. line-height: .27rem;
  490. text-align: center;
  491. border-radius: .05rem;
  492. position: relative;
  493. top: -.05rem;
  494. margin-right: .05rem;
  495. &.reserve-tag {
  496. background: #07bb1c;
  497. }
  498. }
  499. }
  500. }
  501. }
  502. }
  503. }
  504. .no-store {
  505. background: #fff;
  506. padding-top: 1rem;
  507. img {
  508. display: block;
  509. text-align: center;
  510. margin: 0 auto;
  511. margin-bottom: .45rem;
  512. width: 3.31rem;
  513. height: 2.13rem;
  514. }
  515. div {
  516. width: 5.27rem;
  517. margin: 0 auto;
  518. text-align: center;
  519. line-height: .4rem;
  520. color: #999;
  521. .link-url {
  522. color: #01a44e;
  523. }
  524. }
  525. }
  526. }
  527. </style>