ProductWindow.vue 4.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176
  1. <template>
  2. <div>
  3. <div
  4. class="product-window group-con"
  5. :class="attr.cartAttr === true ? 'on' : ''"
  6. :style="'padding-bottom:' + (isShowBtn ? '0' : '')"
  7. >
  8. <div class="textpic acea-row row-between-wrapper">
  9. <div class="pictrue">
  10. <img :src="attr.productSelect.image" class="image" />
  11. </div>
  12. <div class="text">
  13. <div class="line1">
  14. {{ attr.productSelect.store_name }}
  15. </div>
  16. <div class="money font-color-red">
  17. ¥<span class="num">{{ attr.productSelect.price }}</span>
  18. <span class="stock" v-if="isShow">
  19. 库存: {{ attr.productSelect.stock }}
  20. </span>
  21. <span class="stock" v-else>
  22. 限量:
  23. {{
  24. attr.productSelect.quota_show
  25. ? attr.productSelect.quota_show
  26. : 0
  27. }}
  28. </span>
  29. </div>
  30. </div>
  31. <div class="iconfont icon-guanbi" @click="closeAttr"></div>
  32. </div>
  33. <div class="productWinList">
  34. <div
  35. class="item"
  36. v-for="(item, indexw) in attr.productAttr"
  37. :key="indexw"
  38. >
  39. <div class="title">{{ item.attr_name }}</div>
  40. <div class="listn acea-row row-middle">
  41. <div
  42. class="itemn"
  43. :class="item.index === itemn.attr ? 'on' : ''"
  44. v-for="(itemn, indexn) in item.attr_value"
  45. @click="tapAttr(indexw, itemn.attr)"
  46. :key="indexn"
  47. >
  48. {{ itemn.attr }}
  49. </div>
  50. </div>
  51. </div>
  52. </div>
  53. <div class="cart">
  54. <div class="title">数量</div>
  55. <div class="carnum acea-row row-left">
  56. <div
  57. class="item reduce"
  58. :class="attr.productSelect.cart_num <= 1 ? 'on' : ''"
  59. @click="CartNumDes"
  60. >
  61. -
  62. </div>
  63. <div class="item num">
  64. <input
  65. type="number"
  66. v-model="attr.productSelect.cart_num"
  67. class="ipt_num"
  68. />
  69. </div>
  70. <div
  71. class="item plus"
  72. :class="
  73. attr.productSelect.cart_num >= attr.productSelect.stock
  74. ? 'on'
  75. : ''
  76. "
  77. @click="CartNumAdd"
  78. >
  79. +
  80. </div>
  81. </div>
  82. </div>
  83. <div class="wrapper" v-if="isShowBtn">
  84. <div
  85. class="teamBnt bg-color-red"
  86. @click="openAlone"
  87. v-if="
  88. attr.productSelect.quota > 0 && attr.productSelect.product_stock > 0
  89. "
  90. >
  91. 立即参团
  92. </div>
  93. <div class="teamBnt bg-color-hui" v-else>已售罄</div>
  94. </div>
  95. </div>
  96. <div
  97. class="mask"
  98. @touchmove.prevent
  99. :hidden="attr.cartAttr === false"
  100. @click="closeAttr"
  101. ></div>
  102. </div>
  103. </template>
  104. <script>
  105. export default {
  106. name: "ProductWindow",
  107. props: {
  108. attr: {
  109. type: Object,
  110. default: () => {}
  111. }
  112. },
  113. data: function() {
  114. return {};
  115. },
  116. computed: {
  117. isShow() {
  118. return this.$route.path.indexOf("detail") === 1;
  119. },
  120. isShowBtn() {
  121. return this.$route.path.indexOf("group_rule") != -1;
  122. }
  123. },
  124. mounted: function() {},
  125. methods: {
  126. openAlone() {
  127. this.$emit("changeFun", { action: "goPay", value: false });
  128. },
  129. closeAttr: function() {
  130. this.$emit("changeFun", { action: "changeattr", value: false });
  131. },
  132. CartNumDes: function() {
  133. this.$emit("changeFun", { action: "ChangeCartNum", value: false });
  134. },
  135. CartNumAdd: function() {
  136. this.$emit("changeFun", { action: "ChangeCartNum", value: 1 });
  137. },
  138. tapAttr: function(indexw, indexn) {
  139. let that = this;
  140. that.attr.productAttr[indexw].index = indexn;
  141. let value = that
  142. .getCheckedValue()
  143. .sort()
  144. .join(",");
  145. that.$emit("changeFun", { action: "ChangeAttr", value: value });
  146. },
  147. //获取被选中属性;
  148. getCheckedValue: function() {
  149. let productAttr = this.attr.productAttr;
  150. let value = [];
  151. for (let i = 0; i < productAttr.length; i++) {
  152. for (let j = 0; j < productAttr[i].attr_value.length; j++) {
  153. if (productAttr[i].index === productAttr[i].attr_value[j].attr) {
  154. value.push(productAttr[i].attr_value[j].attr);
  155. }
  156. }
  157. }
  158. return value;
  159. }
  160. }
  161. };
  162. </script>
  163. <style scoped>
  164. .joinCart {
  165. width: 80%;
  166. height: 0.76rem;
  167. line-height: 0.76rem;
  168. text-align: center;
  169. }
  170. .ipt_num {
  171. width: 100%;
  172. display: block;
  173. line-height: 0.54rem;
  174. text-align: center;
  175. }
  176. </style>