good-detail1.vue 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131
  1. <template>
  2. <view class="good-detail1">
  3. <AddCart ref="addCart" />
  4. <swiper :indicator-dots="true" :circular="true" :autoplay="false" :interval="3456" :duration="234" indicator-color="#FFFFFF" indicator-active-color="#F76454">
  5. <swiper-item v-if="data.banner_img" v-for="(item, index) in data.banner_img" :key="index">
  6. <image :src="item"></image>
  7. </swiper-item>
  8. </swiper>
  9. <view class="info">
  10. <text>{{ data.name }}</text>
  11. <text>¥{{ data.money }}/{{ data.unit }}</text>
  12. </view>
  13. <view class="size app-item" @tap="tapAdd">
  14. <text>规格</text>
  15. <text class="cuIcon-right"></text>
  16. </view>
  17. <view class="intr">
  18. </view>
  19. <view class="bottom-bar">
  20. <navigator open-type="navigate" url="../shop-car1/shop-car1" class="left">
  21. <text class="cuIcon-cart"></text>
  22. <text>购物车</text>
  23. <view v-if="shopcarNum" class="num">{{ shopcarNum }}</view>
  24. </navigator>
  25. <view class="right" @tap="tapAdd">加入购物车</view>
  26. </view>
  27. </view>
  28. </template>
  29. <script>
  30. import { deepClone } from '@/common/util/index.js'
  31. import AddCart from '@/components/public/add-cart.vue'
  32. export default {
  33. components: { AddCart },
  34. data() {
  35. return {
  36. data: {}
  37. }
  38. },
  39. computed: {
  40. item() {
  41. const temp = deepClone(this.data)
  42. temp.cart = Array(temp.size.length).fill(0)
  43. const index = this.$store.state.cart.list.findIndex(e => e.attr_id === temp.attr_id)
  44. return index === -1 ? temp : Object.assign(temp, this.$store.state.cart.list[index])
  45. },
  46. shopcarNum() { return this.$store.getters['cart/shopcarNum'] },
  47. },
  48. onLoad({ data }) {
  49. this.data = JSON.parse(uni.getStorageSync('ggg'))
  50. if (!this.data.banner_img.length) {
  51. this.data.banner_img = [this.data.main_img]
  52. }
  53. },
  54. methods: {
  55. tapAdd() {
  56. this.$refs.addCart.show(deepClone(this.item))
  57. }
  58. }
  59. }
  60. </script>
  61. <style lang="scss" scoped>
  62. .good-detail1 {
  63. height: 100vh;
  64. background: $app-base-bg;
  65. border-bottom: 99rpx solid #000000;
  66. swiper {
  67. height: 600rpx;
  68. image {
  69. width: 100%;
  70. height: 100%;
  71. }
  72. }
  73. .info {
  74. @include flex(column);
  75. height: 140rpx;
  76. background: #FFFFFF;
  77. padding: 24rpx 31rpx;
  78. box-sizing: border-box;
  79. align-items: flex-start;
  80. justify-content: space-between;
  81. }
  82. .size {
  83. height: 90rpx;
  84. margin: 10rpx 0;
  85. background: #FFFFFF;
  86. }
  87. .bottom-bar {
  88. height: 99rpx;
  89. position: fixed;
  90. width: 100vw;
  91. bottom: 0;
  92. background: #FFFFFF;
  93. @include flex();
  94. > view, > navigator {
  95. flex: 1;
  96. height: 100%;
  97. @include flex();
  98. position: relative;
  99. .num {
  100. position: absolute;
  101. right: 30%;
  102. top: 10%;
  103. background: red;
  104. font-size: 24rpx;
  105. height: 42rpx;
  106. min-width: 42rpx;
  107. line-height: 42rpx;
  108. text-align: center;
  109. border-radius: 42rpx;
  110. padding: 2rpx 8rpx;
  111. color: #FFFFFF;
  112. }
  113. &.left {
  114. flex-direction: column;
  115. font-size: 24rpx;
  116. .cuIcon-cart {
  117. font-size: 49rpx;
  118. }
  119. }
  120. &.right {
  121. font-size: 36rpx;
  122. color: #FFFFFF;
  123. background: $app-base-color;
  124. }
  125. }
  126. }
  127. }
  128. </style>