ComponentDetail.vue 21 KB

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