detail.vue 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129
  1. <template>
  2. <div class="detail" :style="{ paddingBottom: isLock ? '23vw' : '' }">
  3. <nav-bar title="商品详情" @click-left="$router.back()" />
  4. <goods-image :imageList="imageList"/>
  5. <goods-share :productInfo="productInfo" :userInfo="userInfo" :dataInfo="dataInfo"/>
  6. <goods-sku :productInfo="productInfo" @handlerSku="handlerSku"/>
  7. <goods-classification :productInfo="productInfo"/>
  8. <goods-detail :productInfo="productInfo"/>
  9. <div class="buy-now" v-if="isLock">
  10. <div class="foot" @click="$router.push('/shopping-mall')">
  11. <van-image class="index" width="80%" height="80%" src="https://static.caimei365.com/app/mini-distribution/index.png"></van-image>
  12. <div>首页</div>
  13. </div>
  14. <van-button color="#FF5B00" @click="showSku">立即购买</van-button>
  15. </div>
  16. <share-modal :suid="suid" :userInfo="userInfo"/>
  17. </div>
  18. </template>
  19. <script>
  20. import GoodsClassification from './components/goods-classification'
  21. import GoodsImage from './components/goods-image'
  22. import GoodsShare from './components/goods-share'
  23. import GoodsSku from './components/goods-sku'
  24. import GoodsDetail from './components/goods-detail'
  25. import { productDetail } from '@/api/institutionApi/product'
  26. import { getUserInfo } from '@/api/userApi/login'
  27. export default {
  28. components: { GoodsClassification, GoodsImage, GoodsShare, GoodsSku, GoodsDetail },
  29. data () {
  30. return {
  31. formData: {
  32. userId: this.$store.getters.userId,
  33. productId: 0,
  34. typeId: 0
  35. },
  36. productInfo: {},
  37. skus: {},
  38. imageList: [],
  39. userInfo: {},
  40. dataInfo: {}
  41. }
  42. },
  43. computed: {
  44. productId () {
  45. return this.$route.query.productId
  46. },
  47. typeId () {
  48. return this.$route.query.typeId
  49. },
  50. isLock () {
  51. return this.$route.query.isLock
  52. },
  53. suid () {
  54. return this.$route.query.suid
  55. },
  56. cId () {
  57. return this.$route.query.cId
  58. }
  59. },
  60. async mounted () {
  61. await this.productDetail()
  62. await this.getUserInfo()
  63. },
  64. methods: {
  65. async productDetail () {
  66. const data = await productDetail(Object.assign(this.formData, { productId: this.productId, typeId: this.typeId }))
  67. this.productInfo = data
  68. this.imageList = data.imageList.map(i => i.image)
  69. this.skus = data.skus
  70. this.dataInfo.productImage = this.imageList[0]
  71. this.dataInfo.name = this.productInfo.name
  72. },
  73. handlerSku ({ selectedNum, selectedSku }) {
  74. this.$router.push(`/order-create?selectedNum=${selectedNum}&selectedSku=${selectedSku.s1}&typeId=${this.typeId}&productId=${this.productId}&cId=${this.cId}`)
  75. },
  76. showSku () {
  77. this.$children[3].show = true
  78. },
  79. async getUserInfo () {
  80. const data = await getUserInfo({ userId: this.suid ? this.suid : this.$store.getters.userId })
  81. this.userInfo = data
  82. // this.dataInfo.productImage = await getImage2Blob(this.dataInfo.productImage)
  83. }
  84. }
  85. }
  86. </script>
  87. <style lang="scss" scoped>
  88. .detail {
  89. box-sizing: border-box;
  90. }
  91. .sku-cell {
  92. margin: 2.7vw 0;
  93. }
  94. .classification {
  95. margin-bottom: 2.7vw;
  96. }
  97. .buy-now {
  98. width: 100%;
  99. padding: 1vw 3.2vw 1vw 8.4vw;
  100. box-sizing: border-box;
  101. background: #fff;
  102. position: fixed;
  103. bottom: 0;
  104. left: 0;
  105. @include display-flex-between;
  106. height: 23vw;
  107. .foot {
  108. display: flex;
  109. flex-direction: column;
  110. align-items: center;
  111. justify-content: space-between;
  112. font-size: 2.9vw;
  113. color: #333;
  114. height: 11.2vw;
  115. }
  116. .index {
  117. width: 4vw;
  118. height: 4vw;
  119. }
  120. .van-button {
  121. width: 70vw;
  122. height: 11.2vw;
  123. border-radius: 1vw;
  124. }
  125. }
  126. </style>