ComponentDetail.vue 20 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653
  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. console.log(store, '1')
  203. if (store) {
  204. for (let i = 0; i < store.length; i++) {
  205. if (store[i].componentid === id) {
  206. return true
  207. }
  208. }
  209. } else {
  210. return false
  211. }
  212. },
  213. user () {
  214. return this.$store.state.option.user
  215. }
  216. },
  217. filters: {
  218. currency: function (num) {
  219. if (typeof num === 'number') {
  220. if (num <= 0.000001) {
  221. num = 0.000001
  222. } else {
  223. if (num.toString().indexOf('.') === -1) {
  224. num += '.00'
  225. } else {
  226. let inputStr = num.toString()
  227. let arr = inputStr.split('.')
  228. let floatNum = arr[1]
  229. if (floatNum.length > 6) {
  230. num = inputStr.substring(0, arr[0].length + 7)
  231. if (Number(floatNum.charAt(6)) > 4) {
  232. num = (Number(num) * 1000000 + 1) / 1000000
  233. }
  234. } else if (floatNum.length === 1) {
  235. num = num + '0'
  236. }
  237. }
  238. }
  239. }
  240. return num
  241. },
  242. storeNameFilter: function (str) {
  243. if (str === '') {
  244. return str
  245. }
  246. let len = 0
  247. let index = 0
  248. for (let i = 0; i < str.length; i++) {
  249. if (index === 0 && str.charAt(i).charCodeAt(0) > 255) {
  250. len = len + 2
  251. } else {
  252. len++
  253. }
  254. if (len > 22) {
  255. index = i
  256. break
  257. }
  258. }
  259. if (index > 0) {
  260. return str.substring(0, index) + '...'
  261. } else {
  262. return str
  263. }
  264. }
  265. },
  266. methods: {
  267. goProductDetail: function (com) {
  268. this.$router.push('/mobile/shop/' + com.storeid)
  269. },
  270. scroll: function () {
  271. let scrolled = document.documentElement.scrollTop || window.pageYOffset || document.body.scrollTop
  272. if (Math.ceil(scrolled + window.screen.availHeight) >= document.body.scrollHeight && !this.isSearchingMore && this.params.page < this.allPage) {
  273. this.getMoreStore()
  274. }
  275. // let tbodyObj = document.getElementById('product-body')
  276. // let theadObj = document.getElementById('product-head')
  277. // if (theadObj) {
  278. // this.isScrollOverTab = tbodyObj.getBoundingClientRect().top - theadObj.getBoundingClientRect().height - 5 <= theadObj.getBoundingClientRect().height
  279. // }
  280. },
  281. getMoreStore: function () {
  282. if (!this.isSearchingMore) {
  283. this.params.page++
  284. this.isSearchingMore = true
  285. this.$store.dispatch('loadComponentInformation', this.params)
  286. }
  287. },
  288. goAttach: function (url) {
  289. if (this.user.logged) {
  290. if (url && url !== '1') {
  291. window.open(url)
  292. // window.location.href = url
  293. } else {
  294. this.collectResult = '规格书地址错误'
  295. this.timeoutCount++
  296. }
  297. } else {
  298. this.url = this.$route.fullPath
  299. this.showLoginBox = true
  300. }
  301. },
  302. collectComponent: function () {
  303. if (this.user.logged) {
  304. if (!this.isCollect) {
  305. this.$store.dispatch('product/saveEntity', {componentid: this.component.id, kind: 2})
  306. this.collectResult = '收藏成功'
  307. this.timeoutCount++
  308. } else {
  309. this.$http.post('/trade/collection/delete/cmpId', [this.component.id]).then(response => {
  310. this.collectResult = '取消成功'
  311. this.timeoutCount++
  312. this.$store.dispatch('product/saveStores')
  313. })
  314. }
  315. } else {
  316. this.url = this.$route.fullPath
  317. this.showLoginBox = true
  318. }
  319. }
  320. }
  321. }
  322. </script>
  323. <style lang="scss" scoped>
  324. .component-detail {
  325. font-size: .28rem;
  326. margin-bottom: 0.98rem;
  327. background: #f7f7f7;
  328. padding-top: .2rem;
  329. padding-bottom: 0.2rem;
  330. .base-detail {
  331. /*margin: 0 .27rem .2rem .27rem;*/
  332. padding: .18rem .36rem 0 .36rem;
  333. /*border-radius: .1rem;*/
  334. background: url('/images/mobile/@2x/productDetail/desc-bg2.jpg')no-repeat;
  335. background-size: cover;
  336. height: 4.11rem;
  337. position: relative;
  338. box-shadow: 0 0 5px #8a8a8a;
  339. .base-detail-item {
  340. margin-top: 0.3rem;
  341. position: relative;
  342. color: #fff;
  343. &:nth-child(1) {
  344. margin-top: 0;
  345. }
  346. &:nth-last-child(1) {
  347. color: #999;
  348. }
  349. &.attach {
  350. display: inline-block;
  351. img {
  352. background-color: #fff;
  353. width: .36rem;
  354. height: .4rem;
  355. position: relative;
  356. bottom: .05rem;
  357. }
  358. >span >span {
  359. margin-left: .1rem;
  360. color: #fff;
  361. }
  362. }
  363. &:last-child {
  364. margin-bottom: 0;
  365. }
  366. &.product-description {
  367. height: 1.58rem;
  368. margin-top: .6rem;
  369. img {
  370. width: 0.91rem;
  371. height: 0.91rem;
  372. margin-right: 0.1rem;
  373. }
  374. &.center {
  375. text-align: center;
  376. padding-top: 0.1rem;
  377. line-height: 0.91rem;
  378. }
  379. font-size: 0.28rem;
  380. color: #666;
  381. }
  382. .description {
  383. line-height: .4rem;
  384. max-height: 1.2rem;
  385. word-break: break-all;
  386. overflow : hidden;
  387. text-overflow: ellipsis;
  388. display: -webkit-box;
  389. -webkit-line-clamp: 3;
  390. -webkit-box-orient: vertical;
  391. color: #999;
  392. }
  393. }
  394. >i {
  395. position: absolute;
  396. font-size: .4rem;
  397. background: #fff;
  398. width: .6rem;
  399. height: .6rem;
  400. line-height: .6rem;
  401. border-radius: 100%;
  402. box-shadow: 0 0 .05rem #aaa;
  403. right: .28rem;
  404. top: .55rem;
  405. text-align: center;
  406. }
  407. }
  408. .product-switch-item {
  409. margin-top: 0.15rem;
  410. text-align: center;
  411. background: #fff;
  412. border-bottom: 1px solid #d8d8d8;
  413. .mobile-switch-btn {
  414. color: #333;
  415. display: inline-block;
  416. height: .64rem;
  417. line-height: .64rem;
  418. font-size: .34rem;
  419. width: 1.4rem;
  420. &:first-child {
  421. margin-right: 1.78rem;
  422. }
  423. &.active {
  424. color: #fc5708;
  425. border-bottom: .04rem solid #fc5708;
  426. }
  427. }
  428. }
  429. .product-params {
  430. line-height: .28rem;
  431. margin-top: .2rem;
  432. .param-item {
  433. padding: .19rem .4rem;
  434. border-bottom: 0.04rem solid #eee;
  435. &:nth-child(1) {
  436. border-top: 0.04rem solid #eee;
  437. }
  438. &:nth-child(even) {
  439. background: #f9f9f9;
  440. }
  441. &:nth-child(odd) {
  442. background: #fff;
  443. }
  444. .prop-name {
  445. width: 3.72rem;
  446. display: inline-block;
  447. text-overflow: ellipsis;
  448. overflow: hidden;
  449. white-space: nowrap;
  450. }
  451. .prop-value {
  452. text-overflow: ellipsis;
  453. overflow: hidden;
  454. white-space: nowrap;
  455. display: inline-block;
  456. width: 2.69rem;
  457. float: right;
  458. text-align: right;
  459. }
  460. }
  461. }
  462. .middle {
  463. .order-tag {
  464. display: inline-block;
  465. font-size: .18rem;
  466. color: #fff;
  467. font-weight: bold;
  468. background: #ee1717;
  469. height: .27rem;
  470. width: .27rem;
  471. line-height: .27rem;
  472. text-align: center;
  473. border-radius: .05rem;
  474. position: relative;
  475. top: -.05rem;
  476. margin-right: .05rem;
  477. &.reserve-tag {
  478. background: #07bb1c;
  479. }
  480. }
  481. text-align: left;
  482. padding: 0 0 0.24rem;
  483. background: #fff;
  484. margin: 0.24rem 0.24rem 0;
  485. border-radius: 5px;
  486. border: 1px solid #e3e5e8;
  487. .storeName{
  488. color: #3f84f6;
  489. font-size: 0.28rem;
  490. line-height: 0.6rem;
  491. border-bottom: 1px solid #d3d3d3;
  492. margin-bottom: 0.18rem;
  493. padding-left: 0.24rem;
  494. white-space: nowrap;
  495. overflow: hidden;
  496. text-overflow: ellipsis;
  497. font-weight: bold;
  498. }
  499. .pms {
  500. color: #f57710;
  501. border: 1px solid #f57710;
  502. border-radius: 0.4rem;
  503. background: #fff;
  504. font-size: 0.24rem;
  505. height: 0.4rem;
  506. line-height: 0.4rem;
  507. width: 0.8rem;
  508. text-align: center;
  509. }
  510. .list {
  511. padding: 0 0.24rem;
  512. .left {
  513. float: left;
  514. overflow: hidden;
  515. text-overflow: ellipsis;
  516. white-space: nowrap;
  517. }
  518. .textinfo {
  519. font-size: 0.18rem;
  520. margin-left: 0.1rem;
  521. display: inline-block;
  522. background: #3f84f6;
  523. color: #fff;
  524. font-weight: bold;
  525. border-radius: 3px;
  526. width: 0.8rem;
  527. height: 0.32rem;
  528. line-height: 0.32rem;
  529. text-align: center
  530. }
  531. .button {
  532. font-size: 0.3rem;
  533. color: #1a58dd;
  534. width: 0.92rem;
  535. height: 0.43rem;
  536. line-height: 0.43rem;
  537. text-align: center;
  538. border-radius: 5px;
  539. border:1px solid #1a58dd;
  540. display: inline-block;
  541. margin-right: 0.2rem;
  542. }
  543. margin-bottom: 0.18rem;
  544. &::after{
  545. clear: both;
  546. display: block;
  547. content: ' ';
  548. visibility: hidden;
  549. zoom: 1;
  550. }
  551. .fl {
  552. width: 4.4rem;
  553. float: left;
  554. overflow: hidden;
  555. text-overflow: ellipsis;
  556. white-space: nowrap;
  557. }
  558. .fr {
  559. text-align: left;
  560. width: 2.6rem;
  561. overflow: hidden;
  562. text-overflow: ellipsis;
  563. white-space: nowrap;
  564. }
  565. &.list-long {
  566. .fl {
  567. width: 100% !important;
  568. }
  569. }
  570. .name {
  571. color: #333;
  572. font-size: 0.28rem;
  573. display: inline-block;
  574. }
  575. .text {
  576. display: inline-block;
  577. color: #333;
  578. font-size: 0.28rem
  579. }
  580. .table {
  581. width: 5rem;
  582. margin-bottom: 0;
  583. margin-top: 0;
  584. margin-left: 0.1rem;
  585. li {
  586. height: 0.43rem;
  587. line-height: 0.43rem;
  588. border-left: .01rem solid #c5c5c5;
  589. font-size: .28rem;
  590. &::after {
  591. clear: both;
  592. display: block;
  593. content: ' ';
  594. visibility: hidden;
  595. zoom: 1;
  596. }
  597. div {
  598. text-align: center;
  599. width: 50%;
  600. float: left;
  601. border-right: .01rem solid #c5c5c5;
  602. border-bottom: .01rem solid #c5c5c5;
  603. }
  604. &:nth-child(odd) {
  605. background: #ddd;
  606. color: #333;
  607. font-size: 0.28rem;
  608. }
  609. &:nth-child(even) {
  610. background: #fcfcfc;
  611. color: #333;
  612. font-size: 0.28rem;
  613. }
  614. &:nth-last-of-type(1){
  615. color: #f31919;
  616. }
  617. &.title {
  618. font-size: 0.28rem;
  619. color: #333;
  620. }
  621. }
  622. }
  623. }
  624. }
  625. .no-store {
  626. background: #fff;
  627. padding-top: 1rem;
  628. img {
  629. display: block;
  630. text-align: center;
  631. margin: 0 auto;
  632. margin-bottom: .45rem;
  633. width: 3.31rem;
  634. height: 2.13rem;
  635. }
  636. div {
  637. width: 5.27rem;
  638. margin: 0 auto;
  639. text-align: center;
  640. line-height: .4rem;
  641. color: #999;
  642. .link-url {
  643. color: #01a44e;
  644. }
  645. }
  646. }
  647. }
  648. </style>