ComponentDetail.vue 20 KB

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