ComponentDetail.vue 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494
  1. <template>
  2. <div class="component-detail mobile-content">
  3. <div class="base-detail">
  4. <div class="base-detail-item" v-if="component.kind.nameCn">
  5. <span>类&nbsp;&nbsp;&nbsp;&nbsp;目:</span>
  6. <span>{{component.kind.nameCn}}</span>
  7. </div>
  8. <div class="base-detail-item" v-if="component.brand.nameCn">
  9. <span>品&nbsp;&nbsp;&nbsp;&nbsp;牌:</span>
  10. <span>{{component.brand.nameCn}}</span>
  11. </div>
  12. <div class="base-detail-item attach" @click="goAttach(component.attach)">
  13. <span v-if="component.attach">规格书:<img src="/images/mobile/@2x/productDetail/pdf.png" alt=""><span>查看</span></span>
  14. <span v-else>规格书:-</span>
  15. </div>
  16. <div class="base-detail-item product-description" v-if="component.description">
  17. <span class="description">产品描述:{{component.description}}</span>
  18. </div>
  19. <i class="iconfont icon-shoucang" :style="isCollect?'color:#ff7800':'color: #ddd'" @click="collectComponent"></i>
  20. </div>
  21. <div class="product-switch-item">
  22. <span :class="activeType=='param'?'mobile-switch-btn active':'mobile-switch-btn'" @click="activeType='param'">参数</span>
  23. <span :class="activeType=='store'?'mobile-switch-btn active':'mobile-switch-btn'" @click="activeType='store'">商家</span>
  24. </div>
  25. <div class="product-params" v-if="activeType == 'param'">
  26. <div class="param-item" v-if="prop.value && prop.value!=''" v-for="prop in component.properties">
  27. <span class="prop-name">{{prop.property.labelCn}}</span>
  28. <span class="prop-value">{{prop.value}}</span>
  29. </div>
  30. </div>
  31. <div class="product-store" v-if="activeType == 'store'">
  32. <table v-if="searchLists&&searchLists.length > 0">
  33. <thead>
  34. <tr>
  35. <th>商家</th>
  36. <th>生产日期</th>
  37. <th>数量<span>(PCS)</span></th>
  38. <th>单价</th>
  39. <th>交期(天)</th>
  40. </tr>
  41. </thead>
  42. <tbody>
  43. <tr v-for="store in searchLists">
  44. <td class="store-name">
  45. <div>
  46. <nuxt-link :to="'/mobile/shop/' + store.storeid">
  47. {{store.storeName || '-' | storeNameFilter}}
  48. </nuxt-link>
  49. </div>
  50. </td>
  51. <td>
  52. <div v-if="!store.packaging && !store.breakUp && !store.produceDate">-</div>
  53. <div>{{store.produceDate}}</div>
  54. <div>{{store.packaging}}</div>
  55. <div>{{store.breakUp?'可拆卖':'不可拆卖'}}</div>
  56. </td>
  57. <td>
  58. <div v-if="!store.prices || store.prices.length == 0">-</div>
  59. <div v-for="price in store.prices">{{price.start}}+</div>
  60. </td>
  61. <td>
  62. <div v-if="!store.prices || store.prices.length == 0">
  63. <span>—</span>
  64. </div>
  65. <div v-for="price in store.prices" class="price-level">
  66. <span v-if="store.currencyName.indexOf('RMB')!==-1">¥{{price.rMBPrice | currency}}</span>
  67. <span v-if="store.currencyName.indexOf('USD')!==-1">${{price.uSDPrice | currency}}</span>
  68. </div>
  69. </td>
  70. <td class="push-date">
  71. <div v-if="store.b2cMinDelivery">
  72. <span>{{store.b2cMinDelivery}}</span>
  73. <span v-if="store.b2cMaxDelivery && store.b2cMaxDelivery !== store.b2cMinDelivery">-</span>
  74. <span v-if="store.b2cMaxDelivery && store.b2cMaxDelivery !== store.b2cMinDelivery">{{store.b2cMaxDelivery}}</span>
  75. </div>
  76. <div v-if="store.minBuyQty"><span class="order-tag">订</span>{{store.minBuyQty}}起订</div>
  77. <div v-if="!store.b2cMinDelivery">
  78. <span>—</span>
  79. </div>
  80. </td>
  81. </tr>
  82. </tbody>
  83. </table>
  84. </div>
  85. <div v-if="(storeList.totalElements == 0 && activeType == 'store') || (component.properties && component.properties.length == 0 && activeType == 'param')" class="no-store">
  86. <img src="/images/mobile/@2x/car@2x.png" alt="">
  87. <div v-if="activeType == 'store'">抱歉,暂无商家出售此型号!</div>
  88. <div v-if="activeType == 'store'">您可前往<strong>www.usoftmall.com</strong>网页版进行<strong>“发布求购”</strong>或<strong>“产品上架”</strong>操作!</div>
  89. <div v-if="activeType == 'param'">抱歉,暂无参数信息!</div>
  90. </div>
  91. <remind-box :title="collectResult" :timeoutCount="timeoutCount"></remind-box>
  92. <loading v-show="isSearchingMore"></loading>
  93. <login-box @onLoginBoxClose="showLoginBox = false" v-if="showLoginBox"></login-box>
  94. </div>
  95. </template>
  96. <script>
  97. import {RemindBox, Loading, LoginBox} from '~components/mobile/common'
  98. export default {
  99. data () {
  100. return {
  101. activeType: 'param',
  102. collectResult: '收藏成功',
  103. timeoutCount: 0,
  104. storeIds: [],
  105. UmallExist: false,
  106. storeExist: false,
  107. params: {
  108. count: 10,
  109. page: 1,
  110. sorting: {'minPriceRMB': 'ASC'},
  111. filter: {
  112. uuid: this.$route.params.uuid,
  113. ignoreUMall: false,
  114. ignoreStore: false,
  115. storeIds: ''
  116. }
  117. },
  118. isSearchingMore: false,
  119. searchLists: [],
  120. showLoginBox: false
  121. }
  122. },
  123. components: {
  124. RemindBox,
  125. Loading,
  126. LoginBox
  127. },
  128. mounted: function () {
  129. let _this = this
  130. _this.$nextTick(function () {
  131. window.addEventListener('scroll', function () {
  132. _this.scroll()
  133. }, false)
  134. })
  135. },
  136. computed: {
  137. component () {
  138. return this.$store.state.componentDetail.detail.data
  139. },
  140. storeList () {
  141. let storeList = this.$store.state.componentInformation.information.data
  142. let _self = this
  143. if (storeList.content) {
  144. storeList.content.forEach(function (item) {
  145. _self.storeIds.push(item.storeid)
  146. })
  147. }
  148. if (this.storeIds.length > 0) {
  149. if (this.storeIds.indexOf(this.storeId) === -1) {
  150. this.storeExist = true
  151. } else {
  152. this.storeIds.splice(this.storeIds.indexOf(this.storeId), 1)
  153. if (this.storeIds.length > 0) {
  154. this.storeExist = true
  155. }
  156. this.UmallExist = true
  157. }
  158. }
  159. this.searchLists = this.searchLists.concat(storeList.content)
  160. this.isSearchingMore = false
  161. return storeList
  162. },
  163. allPage () {
  164. return this.storeList.totalPages
  165. },
  166. colList () {
  167. return this.$store.state.product.common.collectList.data
  168. },
  169. isCollect () {
  170. let id = this.component.id
  171. let store = this.colList
  172. if (store) {
  173. for (let i = 0; i < store.length; i++) {
  174. if (store[i].componentid === id) {
  175. return true
  176. }
  177. }
  178. } else {
  179. return false
  180. }
  181. },
  182. user () {
  183. return this.$store.state.option.user
  184. }
  185. },
  186. filters: {
  187. currency: function (num) {
  188. if (typeof num === 'number') {
  189. if (num <= 0.000001) {
  190. num = 0.000001
  191. } else {
  192. if (num.toString().indexOf('.') === -1) {
  193. num += '.00'
  194. } else {
  195. let inputStr = num.toString()
  196. let arr = inputStr.split('.')
  197. let floatNum = arr[1]
  198. if (floatNum.length > 6) {
  199. num = inputStr.substring(0, arr[0].length + 7)
  200. if (Number(floatNum.charAt(6)) > 4) {
  201. num = (Number(num) * 1000000 + 1) / 1000000
  202. }
  203. } else if (floatNum.length === 1) {
  204. num = num + '0'
  205. }
  206. }
  207. }
  208. }
  209. return num
  210. },
  211. storeNameFilter: function (str) {
  212. if (str === '') {
  213. return str
  214. }
  215. let len = 0
  216. let index = 0
  217. for (let i = 0; i < str.length; i++) {
  218. if (index === 0 && str.charAt(i).charCodeAt(0) > 255) {
  219. len = len + 2
  220. } else {
  221. len++
  222. }
  223. if (len > 22) {
  224. index = i
  225. break
  226. }
  227. }
  228. if (index > 0) {
  229. return str.substring(0, index) + '...'
  230. } else {
  231. return str
  232. }
  233. }
  234. },
  235. methods: {
  236. scroll: function () {
  237. let scrolled = document.documentElement.scrollTop || window.pageYOffset || document.body.scrollTop
  238. if (Math.ceil(scrolled + window.screen.availHeight) >= document.body.scrollHeight && !this.isSearchingMore && this.params.page < this.allPage) {
  239. this.getMoreStore()
  240. }
  241. },
  242. getMoreStore: function () {
  243. if (!this.isSearchingMore) {
  244. this.params.page++
  245. this.isSearchingMore = true
  246. this.$store.dispatch('loadComponentInformation', this.params)
  247. }
  248. },
  249. goAttach: function (url) {
  250. if (this.user.logged) {
  251. if (url && url !== '1') {
  252. window.location.href = url
  253. }
  254. } else {
  255. this.showLoginBox = true
  256. }
  257. },
  258. collectComponent: function () {
  259. if (this.user.logged) {
  260. if (!this.isCollect) {
  261. this.$store.dispatch('product/saveEntity', {componentid: this.component.id, kind: 2})
  262. this.collectResult = '收藏成功'
  263. this.timeoutCount++
  264. } else {
  265. this.$http.post('/trade/collection/delete/cmpId', [this.component.id]).then(response => {
  266. this.collectResult = '取消成功'
  267. this.timeoutCount++
  268. this.$store.dispatch('product/saveStores')
  269. })
  270. }
  271. } else {
  272. this.showLoginBox = true
  273. }
  274. }
  275. }
  276. }
  277. </script>
  278. <style lang="scss" scoped>
  279. .component-detail {
  280. font-size: .28rem;
  281. margin-bottom: 1.2rem;
  282. background: #f7f7f7;
  283. padding-top: .2rem;
  284. .base-detail {
  285. margin: 0 .27rem .2rem .27rem;
  286. padding: .18rem .36rem 0 .36rem;
  287. border-radius: .1rem;
  288. background: url('/images/mobile/@2x/productDetail/component-desc-bg.png')no-repeat;
  289. background-size: cover;
  290. max-height: 3.17rem;
  291. position: relative;
  292. .base-detail-item {
  293. margin-top: .2rem;
  294. position: relative;
  295. color: #fff;
  296. &:nth-child(1) {
  297. margin-top: 0;
  298. }
  299. &:nth-last-child(1) {
  300. color: #999;
  301. }
  302. &.attach {
  303. display: inline-block;
  304. img {
  305. background-color: #fff;
  306. width: .36rem;
  307. height: .4rem;
  308. position: relative;
  309. bottom: .05rem;
  310. }
  311. >span >span {
  312. margin-left: .1rem;
  313. color: #418bf6;
  314. }
  315. }
  316. &:last-child {
  317. margin-bottom: 0;
  318. }
  319. &.product-description {
  320. height: 1.58rem;
  321. }
  322. .description {
  323. line-height: .4rem;
  324. max-height: 1.2rem;
  325. word-break: break-all;
  326. overflow : hidden;
  327. text-overflow: ellipsis;
  328. display: -webkit-box;
  329. -webkit-line-clamp: 3;
  330. -webkit-box-orient: vertical;
  331. color: #999;
  332. }
  333. }
  334. >i {
  335. position: absolute;
  336. font-size: .4rem;
  337. background: #fff;
  338. width: .6rem;
  339. height: .6rem;
  340. line-height: .6rem;
  341. border-radius: 100%;
  342. box-shadow: 0 0 .05rem #aaa;
  343. right: .28rem;
  344. top: .55rem;
  345. text-align: center;
  346. }
  347. }
  348. .product-switch-item {
  349. text-align: center;
  350. background: #fff;
  351. .mobile-switch-btn {
  352. background: #fff;
  353. color: #666;
  354. display: inline-block;
  355. height: .64rem;
  356. line-height: .64rem;
  357. font-size: .34rem;
  358. width: 1.4rem;
  359. &:first-child {
  360. margin-right: 1.78rem;
  361. }
  362. &.active {
  363. color: #fc5708;
  364. border-bottom: .04rem solid #fc5708;
  365. }
  366. }
  367. }
  368. .product-params {
  369. line-height: .28rem;
  370. margin-top: .2rem;
  371. .param-item {
  372. padding: .19rem .4rem;
  373. border-bottom: 0.04rem solid #eee;
  374. &:nth-child(1) {
  375. border-top: 0.04rem solid #eee;
  376. }
  377. &:nth-child(even) {
  378. background: #f9f9f9;
  379. }
  380. &:nth-child(odd) {
  381. background: #fff;
  382. }
  383. .prop-name {
  384. width: 3.72rem;
  385. display: inline-block;
  386. text-overflow: ellipsis;
  387. overflow: hidden;
  388. white-space: nowrap;
  389. }
  390. .prop-value {
  391. text-overflow: ellipsis;
  392. overflow: hidden;
  393. white-space: nowrap;
  394. display: inline-block;
  395. width: 2.69rem;
  396. float: right;
  397. text-align: right;
  398. }
  399. }
  400. }
  401. .product-store {
  402. margin: .2rem 0;
  403. table {
  404. width: 100%;
  405. font-size: .28rem;
  406. thead {
  407. background: #d5e5fb;
  408. tr {
  409. th {
  410. font-weight: bold;
  411. text-align: center;
  412. height: .78rem;
  413. line-height: .78rem;
  414. >span {
  415. font-size: .22rem;
  416. }
  417. }
  418. }
  419. }
  420. tbody {
  421. background: #fff;
  422. tr {
  423. border-bottom: 0.2rem solid #f7f7f7;
  424. td {
  425. padding: .2rem .1rem;
  426. &.store-name {
  427. color: #418bf6;
  428. div {
  429. padding: 0;
  430. width: 1.2rem;
  431. overflow: hidden;
  432. margin-left: .16rem;
  433. }
  434. }
  435. div {
  436. margin-bottom: .2rem;
  437. text-align: left;
  438. &:last-child {
  439. margin-bottom: 0;
  440. }
  441. }
  442. &.push-date {
  443. text-align: center;
  444. div {
  445. text-align: center;
  446. }
  447. }
  448. .price-level:last-child {
  449. color: #fc5708;
  450. }
  451. .order-tag {
  452. display: inline-block;
  453. font-size: .18rem;
  454. color: #fff;
  455. font-weight: bold;
  456. background: #ee1717;
  457. height: .27rem;
  458. width: .27rem;
  459. line-height: .27rem;
  460. text-align: center;
  461. border-radius: .05rem;
  462. position: relative;
  463. top: -.03rem;
  464. }
  465. }
  466. }
  467. }
  468. }
  469. }
  470. .no-store {
  471. background: #fff;
  472. padding-top: 1rem;
  473. img {
  474. display: block;
  475. text-align: center;
  476. margin: 0 auto;
  477. margin-bottom: .45rem;
  478. width: 3.31rem;
  479. height: 2.13rem;
  480. }
  481. div {
  482. width: 5.27rem;
  483. margin: 0 auto;
  484. text-align: center;
  485. line-height: .4rem;
  486. color: #999;
  487. .link-url {
  488. color: #01a44e;
  489. }
  490. }
  491. }
  492. }
  493. </style>