ComponentDetail.vue 20 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663
  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.$http.post('/trade/collection/save', {componentid: this.component.id, kind: 2})
  305. .then(res => {
  306. if (res.data.code === 1) {
  307. this.collectResult = '收藏成功'
  308. this.$store.dispatch('product/saveStores')
  309. } else {
  310. this.collectResult = res.data.message || '收藏失败'
  311. }
  312. this.timeoutCount++
  313. }, err => {
  314. this.collectResult = err.response.data || '收藏失败'
  315. this.timeoutCount++
  316. console.log(err)
  317. })
  318. } else {
  319. this.$http.post('/trade/collection/delete/cmpId', [this.component.id]).then(response => {
  320. this.collectResult = '取消成功'
  321. this.timeoutCount++
  322. this.$store.dispatch('product/saveStores')
  323. })
  324. }
  325. } else {
  326. this.url = this.$route.fullPath
  327. this.showLoginBox = true
  328. }
  329. }
  330. }
  331. }
  332. </script>
  333. <style lang="scss" scoped>
  334. .component-detail {
  335. font-size: .28rem;
  336. margin-bottom: 0.98rem;
  337. background: #f7f7f7;
  338. padding-top: .2rem;
  339. padding-bottom: 0.2rem;
  340. .base-detail {
  341. /*margin: 0 .27rem .2rem .27rem;*/
  342. padding: .18rem .36rem 0 .36rem;
  343. /*border-radius: .1rem;*/
  344. background: url('/images/mobile/@2x/productDetail/desc-bg2.jpg')no-repeat;
  345. background-size: cover;
  346. height: 4.11rem;
  347. position: relative;
  348. box-shadow: 0 0 5px #8a8a8a;
  349. .base-detail-item {
  350. margin-top: 0.3rem;
  351. position: relative;
  352. color: #fff;
  353. &:nth-child(1) {
  354. margin-top: 0;
  355. }
  356. &:nth-last-child(1) {
  357. color: #999;
  358. }
  359. &.attach {
  360. display: inline-block;
  361. img {
  362. background-color: #fff;
  363. width: .36rem;
  364. height: .4rem;
  365. position: relative;
  366. bottom: .05rem;
  367. }
  368. >span >span {
  369. margin-left: .1rem;
  370. color: #fff;
  371. }
  372. }
  373. &:last-child {
  374. margin-bottom: 0;
  375. }
  376. &.product-description {
  377. height: 1.58rem;
  378. margin-top: .6rem;
  379. img {
  380. width: 0.91rem;
  381. height: 0.91rem;
  382. margin-right: 0.1rem;
  383. }
  384. &.center {
  385. text-align: center;
  386. padding-top: 0.1rem;
  387. line-height: 0.91rem;
  388. }
  389. font-size: 0.28rem;
  390. color: #666;
  391. }
  392. .description {
  393. line-height: .4rem;
  394. max-height: 1.2rem;
  395. word-break: break-all;
  396. overflow : hidden;
  397. text-overflow: ellipsis;
  398. display: -webkit-box;
  399. -webkit-line-clamp: 3;
  400. -webkit-box-orient: vertical;
  401. color: #999;
  402. }
  403. }
  404. >i {
  405. position: absolute;
  406. font-size: .4rem;
  407. background: #fff;
  408. width: .6rem;
  409. height: .6rem;
  410. line-height: .6rem;
  411. border-radius: 100%;
  412. box-shadow: 0 0 .05rem #aaa;
  413. right: .28rem;
  414. top: .55rem;
  415. text-align: center;
  416. }
  417. }
  418. .product-switch-item {
  419. margin-top: 0.15rem;
  420. text-align: center;
  421. background: #fff;
  422. border-bottom: 1px solid #d8d8d8;
  423. .mobile-switch-btn {
  424. color: #333;
  425. display: inline-block;
  426. height: .64rem;
  427. line-height: .64rem;
  428. font-size: .34rem;
  429. width: 1.4rem;
  430. &:first-child {
  431. margin-right: 1.78rem;
  432. }
  433. &.active {
  434. color: #fc5708;
  435. border-bottom: .04rem solid #fc5708;
  436. }
  437. }
  438. }
  439. .product-params {
  440. line-height: .28rem;
  441. margin-top: .2rem;
  442. .param-item {
  443. padding: .19rem .4rem;
  444. border-bottom: 0.04rem solid #eee;
  445. &:nth-child(1) {
  446. border-top: 0.04rem solid #eee;
  447. }
  448. &:nth-child(even) {
  449. background: #f9f9f9;
  450. }
  451. &:nth-child(odd) {
  452. background: #fff;
  453. }
  454. .prop-name {
  455. width: 3.72rem;
  456. display: inline-block;
  457. text-overflow: ellipsis;
  458. overflow: hidden;
  459. white-space: nowrap;
  460. }
  461. .prop-value {
  462. text-overflow: ellipsis;
  463. overflow: hidden;
  464. white-space: nowrap;
  465. display: inline-block;
  466. width: 2.69rem;
  467. float: right;
  468. text-align: right;
  469. }
  470. }
  471. }
  472. .middle {
  473. .order-tag {
  474. display: inline-block;
  475. font-size: .18rem;
  476. color: #fff;
  477. font-weight: bold;
  478. background: #ee1717;
  479. height: .27rem;
  480. width: .27rem;
  481. line-height: .27rem;
  482. text-align: center;
  483. border-radius: .05rem;
  484. position: relative;
  485. top: -.05rem;
  486. margin-right: .05rem;
  487. &.reserve-tag {
  488. background: #07bb1c;
  489. }
  490. }
  491. text-align: left;
  492. padding: 0 0 0.24rem;
  493. background: #fff;
  494. margin: 0.24rem 0.24rem 0;
  495. border-radius: 5px;
  496. border: 1px solid #e3e5e8;
  497. .storeName{
  498. color: #3f84f6;
  499. font-size: 0.28rem;
  500. line-height: 0.6rem;
  501. border-bottom: 1px solid #d3d3d3;
  502. margin-bottom: 0.18rem;
  503. padding-left: 0.24rem;
  504. white-space: nowrap;
  505. overflow: hidden;
  506. text-overflow: ellipsis;
  507. font-weight: bold;
  508. }
  509. .pms {
  510. color: #f57710;
  511. border: 1px solid #f57710;
  512. border-radius: 0.4rem;
  513. background: #fff;
  514. font-size: 0.24rem;
  515. height: 0.4rem;
  516. line-height: 0.4rem;
  517. width: 0.8rem;
  518. text-align: center;
  519. }
  520. .list {
  521. padding: 0 0.24rem;
  522. .left {
  523. float: left;
  524. overflow: hidden;
  525. text-overflow: ellipsis;
  526. white-space: nowrap;
  527. }
  528. .textinfo {
  529. font-size: 0.18rem;
  530. margin-left: 0.1rem;
  531. display: inline-block;
  532. background: #3f84f6;
  533. color: #fff;
  534. font-weight: bold;
  535. border-radius: 3px;
  536. width: 0.8rem;
  537. height: 0.32rem;
  538. line-height: 0.32rem;
  539. text-align: center
  540. }
  541. .button {
  542. font-size: 0.3rem;
  543. color: #1a58dd;
  544. width: 0.92rem;
  545. height: 0.43rem;
  546. line-height: 0.43rem;
  547. text-align: center;
  548. border-radius: 5px;
  549. border:1px solid #1a58dd;
  550. display: inline-block;
  551. margin-right: 0.2rem;
  552. }
  553. margin-bottom: 0.18rem;
  554. &::after{
  555. clear: both;
  556. display: block;
  557. content: ' ';
  558. visibility: hidden;
  559. zoom: 1;
  560. }
  561. .fl {
  562. width: 4.4rem;
  563. float: left;
  564. overflow: hidden;
  565. text-overflow: ellipsis;
  566. white-space: nowrap;
  567. }
  568. .fr {
  569. text-align: left;
  570. width: 2.6rem;
  571. overflow: hidden;
  572. text-overflow: ellipsis;
  573. white-space: nowrap;
  574. }
  575. &.list-long {
  576. .fl {
  577. width: 100% !important;
  578. }
  579. }
  580. .name {
  581. color: #333;
  582. font-size: 0.28rem;
  583. display: inline-block;
  584. }
  585. .text {
  586. display: inline-block;
  587. color: #333;
  588. font-size: 0.28rem
  589. }
  590. .table {
  591. width: 5rem;
  592. margin-bottom: 0;
  593. margin-top: 0;
  594. margin-left: 0.1rem;
  595. li {
  596. height: 0.43rem;
  597. line-height: 0.43rem;
  598. border-left: .01rem solid #c5c5c5;
  599. font-size: .28rem;
  600. &::after {
  601. clear: both;
  602. display: block;
  603. content: ' ';
  604. visibility: hidden;
  605. zoom: 1;
  606. }
  607. div {
  608. text-align: center;
  609. width: 50%;
  610. float: left;
  611. border-right: .01rem solid #c5c5c5;
  612. border-bottom: .01rem solid #c5c5c5;
  613. }
  614. &:nth-child(odd) {
  615. background: #ddd;
  616. color: #333;
  617. font-size: 0.28rem;
  618. }
  619. &:nth-child(even) {
  620. background: #fcfcfc;
  621. color: #333;
  622. font-size: 0.28rem;
  623. }
  624. &:nth-last-of-type(1){
  625. color: #f31919;
  626. }
  627. &.title {
  628. font-size: 0.28rem;
  629. color: #333;
  630. }
  631. }
  632. }
  633. }
  634. }
  635. .no-store {
  636. background: #fff;
  637. padding-top: 1rem;
  638. img {
  639. display: block;
  640. text-align: center;
  641. margin: 0 auto;
  642. margin-bottom: .45rem;
  643. width: 3.31rem;
  644. height: 2.13rem;
  645. }
  646. div {
  647. width: 5.27rem;
  648. margin: 0 auto;
  649. text-align: center;
  650. line-height: .4rem;
  651. color: #999;
  652. .link-url {
  653. color: #01a44e;
  654. }
  655. }
  656. }
  657. }
  658. </style>