index.vue 7.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290
  1. <template>
  2. <view>
  3. <view class="product-window" :class="(attr.cartAttr === true ? 'on' : '') + ' ' + (iSbnt?'join':'')">
  4. <view class="textpic acea-row row-between-wrapper">
  5. <view class="pictrue">
  6. <image :src="attr.productSelect.image"></image>
  7. </view>
  8. <view class="text">
  9. <view class="line1">
  10. {{ attr.productSelect.store_name }}
  11. </view>
  12. <view class="money font-color">
  13. ¥<text class="num">{{ attr.productSelect.price }}</text>
  14. <text class="stock" v-if='isShow'>库存: {{ attr.productSelect.stock }}</text>
  15. <text class='stock' v-if="limitNum">限量: {{attr.productSelect.quota_show}}</text>
  16. </view>
  17. </view>
  18. <view class="iconfont icon-guanbi" @click="closeAttr"></view>
  19. </view>
  20. <view class="productWinList">
  21. <view class="item" v-for="(item, indexw) in attr.productAttr" :key="indexw">
  22. <view class="title">{{ item.attr_name }}</view>
  23. <view class="listn acea-row row-middle">
  24. <view class="itemn" :class="item.index === itemn.attr ? 'on' : ''" v-for="(itemn, indexn) in item.attr_value"
  25. @click="tapAttr(indexw, indexn)" :key="indexn">
  26. {{ itemn.attr }}
  27. </view>
  28. </view>
  29. </view>
  30. </view>
  31. <view class="cart">
  32. <view class="title">数量</view>
  33. <view class="carnum acea-row row-left">
  34. <view class="item reduce" :class="attr.productSelect.cart_num <= 1 ? 'on' : ''" @click="CartNumDes">
  35. -
  36. </view>
  37. <view class='item num'>
  38. <input type="number" v-model="attr.productSelect.cart_num" data-name="productSelect.cart_num" @input="bindCode(attr.productSelect.cart_num)"></input>
  39. </view>
  40. <view v-if="iSplus" class="item plus" :class="
  41. attr.productSelect.cart_num >= attr.productSelect.stock
  42. ? 'on'
  43. : ''
  44. "
  45. @click="CartNumAdd">
  46. +
  47. </view>
  48. <view v-else class='item plus' :class='(attr.productSelect.cart_num >= attr.productSelect.quota_show) || (attr.productSelect.cart_num >= attr.productSelect.product_stock)? "on":""' @click='CartNumAdd'>+</view>
  49. </view>
  50. </view>
  51. <view class="joinBnt bg-color" v-if="iSbnt && attr.productSelect.product_stock>0 &&attr.productSelect.quota>0" @click="goCat">我要参团</view>
  52. <view class="joinBnt on" v-else-if="(iSbnt && attr.productSelect.quota<=0)||(iSbnt &&attr.productSelect.product_stock<=0)">已售罄</view>
  53. </view>
  54. <view class="mask" @touchmove.prevent :hidden="attr.cartAttr === false" @click="closeAttr"></view>
  55. </view>
  56. </template>
  57. <script>
  58. export default {
  59. props: {
  60. attr: {
  61. type: Object,
  62. default: () => {}
  63. },
  64. limitNum:{
  65. type: Number,
  66. value: 0
  67. },
  68. isShow:{
  69. type: Number,
  70. value: 0
  71. },
  72. iSbnt:{
  73. type:Number,
  74. value:0
  75. },
  76. iSplus:{
  77. type:Number,
  78. value:0
  79. }
  80. },
  81. data() {
  82. return {};
  83. },
  84. methods: {
  85. goCat:function(){
  86. this.$emit('goCat');
  87. },
  88. /**
  89. * 购物车手动输入数量
  90. *
  91. */
  92. bindCode: function (e) {
  93. this.$emit('iptCartNum', this.attr.productSelect.cart_num);
  94. },
  95. closeAttr: function() {
  96. this.$emit('myevent');
  97. },
  98. CartNumDes: function() {
  99. this.$emit('ChangeCartNum', false);
  100. },
  101. CartNumAdd: function() {
  102. this.$emit('ChangeCartNum', true);
  103. },
  104. tapAttr: function(indexw, indexn) {
  105. let that = this;
  106. that.$emit("attrVal", {
  107. indexw: indexw,
  108. indexn: indexn
  109. });
  110. this.$set(this.attr.productAttr[indexw], 'index', this.attr.productAttr[indexw].attr_values[indexn]);
  111. let value = that
  112. .getCheckedValue()
  113. .sort()
  114. .join(",");
  115. that.$emit("ChangeAttr", value);
  116. },
  117. //获取被选中属性;
  118. getCheckedValue: function() {
  119. let productAttr = this.attr.productAttr;
  120. let value = [];
  121. for (let i = 0; i < productAttr.length; i++) {
  122. for (let j = 0; j < productAttr[i].attr_values.length; j++) {
  123. if (productAttr[i].index === productAttr[i].attr_values[j]) {
  124. value.push(productAttr[i].attr_values[j]);
  125. }
  126. }
  127. }
  128. return value;
  129. }
  130. }
  131. }
  132. </script>
  133. <style scoped lang="scss">
  134. .product-window {
  135. position: fixed;
  136. bottom: 0;
  137. width: 100%;
  138. left: 0;
  139. background-color: #fff;
  140. z-index: 77;
  141. border-radius: 16rpx 16rpx 0 0;
  142. padding-bottom: 140rpx;
  143. transform: translate3d(0, 100%, 0);
  144. transition: all .3s cubic-bezier(.25, .5, .5, .9);
  145. }
  146. .product-window.on {
  147. transform: translate3d(0, 0, 0);
  148. }
  149. .product-window.join{padding-bottom: 30rpx;}
  150. .product-window .textpic {
  151. padding: 0 130rpx 0 30rpx;
  152. margin-top: 29rpx;
  153. position: relative;
  154. }
  155. .product-window .textpic .pictrue {
  156. width: 150rpx;
  157. height: 150rpx;
  158. }
  159. .product-window .textpic .pictrue image {
  160. width: 100%;
  161. height: 100%;
  162. border-radius: 10rpx;
  163. }
  164. .product-window .textpic .text {
  165. width: 410rpx;
  166. font-size: 32rpx;
  167. color: #202020;
  168. }
  169. .product-window .textpic .text .money {
  170. font-size: 24rpx;
  171. margin-top: 40rpx;
  172. }
  173. .product-window .textpic .text .money .num {
  174. font-size: 36rpx;
  175. }
  176. .product-window .textpic .text .money .stock {
  177. color: #999;
  178. margin-left: 18rpx;
  179. }
  180. .product-window .textpic .iconfont {
  181. position: absolute;
  182. right: 30rpx;
  183. top: -5rpx;
  184. font-size: 35rpx;
  185. color: #8a8a8a;
  186. }
  187. .product-window .productWinList {
  188. max-height: 395rpx;
  189. overflow: auto;
  190. margin-top: 36rpx;
  191. }
  192. .product-window .productWinList .item~.item {
  193. margin-top: 36rpx;
  194. }
  195. .product-window .productWinList .item .title {
  196. font-size: 30rpx;
  197. color: #999;
  198. padding: 0 30rpx;
  199. }
  200. .product-window .productWinList .item .listn {
  201. padding: 0 30rpx 0 16rpx;
  202. }
  203. .product-window .productWinList .item .listn .itemn {
  204. border: 1px solid #bbb;
  205. font-size: 26rpx;
  206. color: #282828;
  207. padding: 7rpx 33rpx;
  208. border-radius: 6rpx;
  209. margin: 14rpx 0 0 14rpx;
  210. }
  211. .product-window .productWinList .item .listn .itemn.on {
  212. color: #fff;
  213. background-color: #ff3700;
  214. border-color: #ff3700;
  215. }
  216. .product-window .cart {
  217. margin-top: 36rpx;
  218. padding: 0 30rpx;
  219. }
  220. .product-window .cart .title {
  221. font-size: 30rpx;
  222. color: #999;
  223. }
  224. .product-window .cart .carnum {
  225. height: 54rpx;
  226. margin-top: 24rpx;
  227. }
  228. .product-window .cart .carnum view {
  229. border: 1px solid #a4a4a4;
  230. width: 84rpx;
  231. text-align: center;
  232. height: 100%;
  233. line-height: 54rpx;
  234. color: #a4a4a4;
  235. font-size: 45rpx;
  236. }
  237. .product-window .cart .carnum .reduce {
  238. border-right: 0;
  239. border-radius: 6rpx 0 0 6rpx;
  240. line-height: 48rpx;
  241. }
  242. .product-window .cart .carnum .reduce.on {
  243. border-color: #e3e3e3;
  244. color: #dedede;
  245. }
  246. .product-window .cart .carnum .plus {
  247. border-left: 0;
  248. border-radius: 0 6rpx 6rpx 0;
  249. line-height: 46rpx;
  250. }
  251. .product-window .cart .carnum .plus.on {
  252. border-color: #e3e3e3;
  253. color: #dedede;
  254. }
  255. .product-window .cart .carnum .num {
  256. color: #282828;
  257. font-size: 28rpx;
  258. }
  259. .product-window .joinBnt{font-size: 30rpx;width: 620rpx;height: 86rpx;border-radius: 50rpx;text-align: center;line-height: 86rpx;color: #fff;margin: 21rpx auto 0 auto;}
  260. .product-window .joinBnt.on{background-color:#bbb;color:#fff;}
  261. </style>