ComponentDetail.vue 19 KB

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