index.vue 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119
  1. <template>
  2. <view class="attr-content">
  3. <view class="a-t">
  4. <image class="image" mode="widthFix" :src="picture || product.picture"></image>
  5. <view class="right">
  6. <text class="title in2line">{{ product.name }}</text>
  7. <view class="sku-info-wrapper">
  8. <view class="price-wrapper">
  9. <image mode="aspectFit" class="image" v-if="product.memberDiscount && product.memberDiscount.length !== 0 && product.memberDiscount.discount > 0 && price > 0" :src="vipPrice"></image>
  10. <text :class="'text-' + themeColor.name" v-if="price">{{ moneySymbol }}{{ currentProductPrice }}</text>
  11. </view>
  12. <text class="stock" v-if="stock">库存:{{ stock }}{{ product.unit || '件' }}</text>
  13. <view class="selected in2line" v-if="specSelected.length > 0">
  14. 已选:
  15. <text
  16. class="selected-text"
  17. v-for="(sItem, sIndex) in specSelected"
  18. :key="sIndex"
  19. >
  20. {{ sItem.title }}
  21. </text>
  22. <text v-if="specSelected.length > 0"> * {{ cartCount }} </text>
  23. </view>
  24. </view>
  25. </view>
  26. </view>
  27. <scroll-view class="attr-content-scroll-view" scroll-y>
  28. <view v-for="(item, index) in specList" :key="index" class="attr-list">
  29. <text>{{ item.title }}</text>
  30. <view class="item-list">
  31. <view
  32. v-for="(childItem, childIndex) in specChildList"
  33. :key="childIndex"
  34. @tap="
  35. selectSpec(childIndex, childItem.base_spec_id, item.show_type)
  36. "
  37. >
  38. <view
  39. v-if="childItem.base_spec_id === item.base_spec_id"
  40. :class="[childItem.selected ? 'bg-' + themeColor.name : 'tit-normal', childItem.disabled ? 'disabled' : '']"
  41. :style="
  42. childItem.selected && parseInt(item.show_type) === 2
  43. ? styleObject
  44. : ''
  45. "
  46. class="tit"
  47. >
  48. <text v-if="parseInt(item.show_type) === 1">
  49. {{ childItem.title }}
  50. </text>
  51. <text v-if="parseInt(item.show_type) === 2">
  52. {{ childItem.title }}
  53. </text>
  54. <view v-if="parseInt(item.show_type) === 3">
  55. <image
  56. class="img"
  57. :src="childItem.data || product.picture"
  58. mode="aspectFill"
  59. ></image>
  60. {{ childItem.title }}
  61. </view>
  62. </view>
  63. </view>
  64. </view>
  65. </view>
  66. <view class="select-count" v-if="isSelectedNum">
  67. <text>购买数量</text>
  68. <!-- <oa-number-box-->
  69. <!-- v-if="parseInt(stock || product.stock, 10) === 0"-->
  70. <!-- class="step"-->
  71. <!-- :disabled="true"-->
  72. <!-- :min="0"-->
  73. <!-- :max="0"-->
  74. <!-- @eventChange="numberChange"-->
  75. <!-- ></oa-number-box>-->
  76. <oa-number-box
  77. class="step"
  78. :min="parseInt(product.min_buy, 10) || minNum"
  79. :max="parseInt(product.max_buy, 10) || (maxNum === 0 ? parseInt(stock || product.stock, 10) : maxNum)"
  80. :value="cartCount"
  81. @eventChange="numberChange"
  82. ></oa-number-box>
  83. <!-- :max="parseInt(stock || product.stock, 10)"-->
  84. </view>
  85. </scroll-view>
  86. <button v-if="!showBuyBtn" class="btn" :class="'bg-' + themeColor.name" @tap="toggleSpec">完成</button>
  87. <view class="btn-group" v-else>
  88. <button class="btn" :class="'bg-' + themeColor.name" @tap="toggleSpec(1)">加入购物车</button>
  89. <button class="btn" :class="'bg-' + themeColor.name" @tap="toggleSpec(2)">立即购买</button>
  90. </view>
  91. </view>
  92. </template>
  93. <style scoped lang="scss">
  94. .sku-info-wrapper {
  95. width: 100%;
  96. padding-bottom: $spacing-sm;
  97. }
  98. .price-wrapper {
  99. height: 38upx;
  100. display: flex;
  101. align-items: center;
  102. margin: $spacing-sm 0;
  103. .image {
  104. width: 120upx;
  105. height: 38upx;
  106. }
  107. .base-color {
  108. margin-top: 2upx;
  109. }
  110. }
  111. .btn-group {
  112. display: flex;
  113. justify-content: space-between;
  114. .btn {
  115. width: 40vw;
  116. }
  117. }
  118. </style>