ComponentDetail.vue 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382
  1. <template>
  2. <div class="component-detail">
  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>规格书:<img src="/images/mobile/@2x/productDetail/pdf.png" alt=""><span>查看</span></span>
  14. </div>
  15. <div class="base-detail-item" v-if="component.description">
  16. <span class="description">产品描述:{{component.description}}</span>
  17. </div>
  18. <i class="iconfont icon-shoucang" :style="isCollect?'color:#ff7800':'color: #ddd'" @click="collectComponent"></i>
  19. </div>
  20. <div class="product-switch-item">
  21. <span :class="activeType=='param'?'mobile-switch-btn active':'mobile-switch-btn'" @click="activeType='param'">参数</span>
  22. <span :class="activeType=='store'?'mobile-switch-btn active':'mobile-switch-btn'" @click="activeType='store'">商家</span>
  23. </div>
  24. <div class="product-params" v-if="activeType == 'param'">
  25. <div class="param-item" v-if="prop.value && prop.value!=''" v-for="prop in component.properties">
  26. <span class="prop-name">{{prop.property.labelCn}}</span>
  27. <span class="prop-value">{{prop.value}}</span>
  28. </div>
  29. </div>
  30. <div class="product-store" v-if="activeType == 'store'">
  31. <table v-if="storeList.content&&storeList.content.length > 0">
  32. <thead>
  33. <tr>
  34. <th>商家</th>
  35. <th>包装</th>
  36. <th>数量</th>
  37. <th>单价</th>
  38. <th>交期(天)</th>
  39. </tr>
  40. </thead>
  41. <tbody>
  42. <tr v-for="store in storeList.content">
  43. <td class="store-name">{{store.storeName || '-'}}</td>
  44. <td>
  45. <div v-if="!store.packaging && !store.breakUp && !store.produceDate">-</div>
  46. <div>{{store.packaging}}</div>
  47. <div>{{store.breakUp?'可拆卖':'不可拆卖'}}</div>
  48. <div>{{store.produceDate}}</div>
  49. </td>
  50. <td>
  51. <div v-if="!store.prices || store.prices.length == 0">-</div>
  52. <div v-for="price in store.prices">{{price.start}}+</div>
  53. </td>
  54. <td>
  55. <div v-if="!store.prices || store.prices.length == 0">
  56. <span>—</span>
  57. </div>
  58. <div v-for="price in store.prices" class="price-level">
  59. <span v-if="store.currencyName.indexOf('RMB')!==-1">¥{{price.rMBPrice | currency}}</span>
  60. <span v-if="store.currencyName.indexOf('USD')!==-1">${{price.uSDPrice | currency}}</span>
  61. </div>
  62. </td>
  63. <td>
  64. <div v-if="store.b2cMinDelivery">
  65. <span>交期:</span>
  66. <span>{{store.b2cMinDelivery}}</span>
  67. <span v-if="store.b2cMaxDelivery && store.b2cMaxDelivery !== store.b2cMinDelivery">-</span>
  68. <span v-if="store.b2cMaxDelivery && store.b2cMaxDelivery !== store.b2cMinDelivery">{{store.b2cMaxDelivery}}</span>
  69. </div>
  70. <div v-if="store.minBuyQty"><span class="order-tag">订</span>{{store.minBuyQty}}起订</div>
  71. <div v-if="!store.b2cMinDelivery">
  72. <span>—</span>
  73. </div>
  74. </td>
  75. </tr>
  76. </tbody>
  77. </table>
  78. <div v-if="!storeList.content || storeList.content.length == 0" class="no-store">
  79. <img src="/images/mobile/@2x/car@2x.png" alt="">
  80. <div>抱歉,暂无商家出售此型号!</div>
  81. <div>您可前往<strong>www.usoftmall.com</strong>网页版进行<strong>“发布求购”</strong>或<strong>“产品上架”</strong>操作!</div>
  82. </div>
  83. </div>
  84. <remind-box :title="collectResult" :timeoutCount="timeoutCount"></remind-box>
  85. </div>
  86. </template>
  87. <script>
  88. import RemindBox from '~components/mobile/common/remindBox.vue'
  89. export default {
  90. data () {
  91. return {
  92. activeType: 'param',
  93. collectResult: '收藏成功',
  94. timeoutCount: 0
  95. }
  96. },
  97. components: {
  98. RemindBox
  99. },
  100. computed: {
  101. component () {
  102. return this.$store.state.componentDetail.detail.data
  103. },
  104. storeList () {
  105. let storeList = this.$store.state.componentInformation.information.data
  106. let _self = this
  107. if (storeList.content) {
  108. storeList.content.forEach(function (item) {
  109. _self.storeIds.push(item.storeid)
  110. })
  111. }
  112. if (this.storeIds.length > 0) {
  113. if (this.storeIds.indexOf(this.storeId) === -1) {
  114. this.storeExist = true
  115. } else {
  116. this.storeIds.splice(this.storeIds.indexOf(this.storeId), 1)
  117. if (this.storeIds.length > 0) {
  118. this.storeExist = true
  119. }
  120. this.UmallExist = true
  121. }
  122. }
  123. return storeList
  124. },
  125. colList () {
  126. return this.$store.state.product.common.collectList.data
  127. },
  128. isCollect () {
  129. let id = this.component.id
  130. let store = this.colList
  131. if (store) {
  132. for (let i = 0; i < store.length; i++) {
  133. if (store[i].componentid === id) {
  134. return true
  135. }
  136. }
  137. } else {
  138. return false
  139. }
  140. }
  141. },
  142. filters: {
  143. currency: function (num) {
  144. if (typeof num === 'number') {
  145. if (num <= 0.000001) {
  146. num = 0.000001
  147. } else {
  148. if (num.toString().indexOf('.') === -1) {
  149. num += '.00'
  150. } else {
  151. let inputStr = num.toString()
  152. let arr = inputStr.split('.')
  153. let floatNum = arr[1]
  154. if (floatNum.length > 6) {
  155. num = inputStr.substring(0, arr[0].length + 7)
  156. if (Number(floatNum.charAt(6)) > 4) {
  157. num = (Number(num) * 1000000 + 1) / 1000000
  158. }
  159. } else if (floatNum.length === 1) {
  160. num = num + '0'
  161. }
  162. }
  163. }
  164. }
  165. return num
  166. }
  167. },
  168. methods: {
  169. goAttach: function (url) {
  170. if (url && url !== '1') {
  171. window.location.href = url
  172. }
  173. },
  174. collectComponent: function () {
  175. if (!this.isCollect) {
  176. this.$store.dispatch('product/saveEntity', {componentid: this.component.id, kind: this.component.kindid})
  177. this.collectResult = '收藏成功'
  178. this.timeoutCount++
  179. } else {
  180. this.$http.post('/trade/collection/delete/cmpId', [this.component.id]).then(response => {
  181. this.collectResult = '取消成功'
  182. this.timeoutCount++
  183. this.$store.dispatch('product/saveStores')
  184. })
  185. }
  186. }
  187. }
  188. }
  189. </script>
  190. <style lang="scss" scoped>
  191. .component-detail {
  192. font-size: .28rem;
  193. margin-bottom: 1.2rem;
  194. background: #f7f7f7;
  195. padding-top: .4rem;
  196. .base-detail {
  197. margin: 0 .27rem .34rem .27rem;
  198. padding: .18rem .36rem;
  199. background: #fff;
  200. border-radius: .1rem;
  201. background: url('/images/mobile/@2x/productDetail/component-desc-bg.png')no-repeat;
  202. background-size: cover;
  203. height: 3.17rem;
  204. position: relative;
  205. .base-detail-item {
  206. margin-bottom: .2rem;
  207. position: relative;
  208. color: #fff;
  209. &:nth-last-child(1) {
  210. color: #999;
  211. }
  212. &.attach {
  213. display: inline-block;
  214. img {
  215. background-color: #fff;
  216. width: .36rem;
  217. height: .4rem;
  218. }
  219. >span >span {
  220. margin-left: .1rem;
  221. color: #418bf6;
  222. }
  223. }
  224. &:last-child {
  225. margin-bottom: 0;
  226. }
  227. .description {
  228. line-height: .4rem;
  229. max-height: 1.2rem;
  230. word-break: break-all;
  231. overflow : hidden;
  232. text-overflow: ellipsis;
  233. display: -webkit-box;
  234. -webkit-line-clamp: 3;
  235. -webkit-box-orient: vertical;
  236. color: #999;
  237. }
  238. }
  239. >i {
  240. position: absolute;
  241. font-size: .4rem;
  242. background: #fff;
  243. width: .6rem;
  244. height: .6rem;
  245. line-height: .6rem;
  246. border-radius: 100%;
  247. box-shadow: 0 0 5px #aaa;
  248. right: .28rem;
  249. top: .55rem;
  250. text-align: center;
  251. }
  252. }
  253. .product-switch-item {
  254. text-align: center;
  255. background: #fff;
  256. .mobile-switch-btn {
  257. background: #fff;
  258. color: #666;
  259. display: inline-block;
  260. height: .64rem;
  261. line-height: .64rem;
  262. font-size: .34rem;
  263. width: 1.4rem;
  264. &:first-child {
  265. margin-right: 1.78rem;
  266. }
  267. &.active {
  268. color: #fc5708;
  269. border-bottom: .01rem solid #fc5708;
  270. }
  271. }
  272. }
  273. .product-params {
  274. line-height: .28rem;
  275. margin-top: .2rem;
  276. .param-item {
  277. padding: .19rem .4rem;
  278. &:nth-child(even) {
  279. background: #f9f9f9;
  280. }
  281. &:nth-child(odd) {
  282. background: #fff;
  283. }
  284. .prop-name {
  285. width: 3.72rem;
  286. display: inline-block;
  287. text-overflow: ellipsis;
  288. overflow: hidden;
  289. white-space: nowrap;
  290. }
  291. .prop-value {
  292. text-overflow: ellipsis;
  293. overflow: hidden;
  294. white-space: nowrap;
  295. display: inline-block;
  296. width: 2.69rem;
  297. float: right;
  298. text-align: right;
  299. }
  300. }
  301. }
  302. .product-store {
  303. margin: .2rem 0;
  304. table {
  305. width: 100%;
  306. font-size: .28rem;
  307. thead {
  308. background: #d5e5fb;
  309. tr {
  310. th {
  311. font-weight: bold;
  312. text-align: center;
  313. height: .78rem;
  314. line-height: .78rem;
  315. }
  316. }
  317. }
  318. tbody {
  319. tr {
  320. border-top: .01rem solid rgb(174,175,176);
  321. td {
  322. padding: .2rem .1rem;
  323. &.store-name {
  324. color: #418bf6;
  325. }
  326. div {
  327. padding-left: .4rem;
  328. overflow: hidden;
  329. text-overflow: ellipsis;
  330. white-space: nowrap;
  331. margin-bottom: .2rem;
  332. &:last-child {
  333. margin-bottom: 0;
  334. }
  335. }
  336. .price-level:last-child {
  337. color: #fc5708;
  338. }
  339. .order-tag {
  340. display: inline-block;
  341. font-size: .18rem;
  342. color: #fff;
  343. font-weight: bold;
  344. background: #ee1717;
  345. height: .27rem;
  346. width: .27rem;
  347. line-height: .27rem;
  348. text-align: center;
  349. border-radius: .05rem;
  350. position: relative;
  351. top: -.03rem;
  352. }
  353. }
  354. }
  355. }
  356. }
  357. .no-store {
  358. background: #fff;
  359. padding-top: 1rem;
  360. img {
  361. display: block;
  362. text-align: center;
  363. margin: 0 auto;
  364. margin-bottom: .45rem;
  365. width: 3.31rem;
  366. height: 2.13rem;
  367. }
  368. div {
  369. width: 5.27rem;
  370. margin: 0 auto;
  371. text-align: center;
  372. line-height: .4rem;
  373. color: #999;
  374. .link-url {
  375. color: #01a44e;
  376. }
  377. }
  378. }
  379. }
  380. }
  381. </style>