123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290 |
- <template>
- <view>
- <view class="product-window" :class="(attr.cartAttr === true ? 'on' : '') + ' ' + (iSbnt?'join':'')">
- <view class="textpic acea-row row-between-wrapper">
- <view class="pictrue">
- <image :src="attr.productSelect.image"></image>
- </view>
- <view class="text">
- <view class="line1">
- {{ attr.productSelect.store_name }}
- </view>
- <view class="money font-color">
- ¥<text class="num">{{ attr.productSelect.price }}</text>
- <text class="stock" v-if='isShow'>库存: {{ attr.productSelect.stock }}</text>
- <text class='stock' v-if="limitNum">限量: {{attr.productSelect.quota_show}}</text>
- </view>
- </view>
- <view class="iconfont icon-guanbi" @click="closeAttr"></view>
- </view>
- <view class="productWinList">
- <view class="item" v-for="(item, indexw) in attr.productAttr" :key="indexw">
- <view class="title">{{ item.attr_name }}</view>
- <view class="listn acea-row row-middle">
- <view class="itemn" :class="item.index === itemn.attr ? 'on' : ''" v-for="(itemn, indexn) in item.attr_value"
- @click="tapAttr(indexw, indexn)" :key="indexn">
- {{ itemn.attr }}
- </view>
- </view>
- </view>
- </view>
- <view class="cart">
- <view class="title">数量</view>
- <view class="carnum acea-row row-left">
- <view class="item reduce" :class="attr.productSelect.cart_num <= 1 ? 'on' : ''" @click="CartNumDes">
- -
- </view>
- <view class='item num'>
- <input type="number" v-model="attr.productSelect.cart_num" data-name="productSelect.cart_num" @input="bindCode(attr.productSelect.cart_num)"></input>
- </view>
- <view v-if="iSplus" class="item plus" :class="
- attr.productSelect.cart_num >= attr.productSelect.stock
- ? 'on'
- : ''
- "
- @click="CartNumAdd">
- +
- </view>
- <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>
- </view>
- </view>
- <view class="joinBnt bg-color" v-if="iSbnt && attr.productSelect.product_stock>0 &&attr.productSelect.quota>0" @click="goCat">我要参团</view>
- <view class="joinBnt on" v-else-if="(iSbnt && attr.productSelect.quota<=0)||(iSbnt &&attr.productSelect.product_stock<=0)">已售罄</view>
- </view>
- <view class="mask" @touchmove.prevent :hidden="attr.cartAttr === false" @click="closeAttr"></view>
- </view>
- </template>
- <script>
- export default {
- props: {
- attr: {
- type: Object,
- default: () => {}
- },
- limitNum:{
- type: Number,
- value: 0
- },
- isShow:{
- type: Number,
- value: 0
- },
- iSbnt:{
- type:Number,
- value:0
- },
- iSplus:{
- type:Number,
- value:0
- }
- },
- data() {
- return {};
- },
- methods: {
- goCat:function(){
- this.$emit('goCat');
- },
- /**
- * 购物车手动输入数量
- *
- */
- bindCode: function (e) {
- this.$emit('iptCartNum', this.attr.productSelect.cart_num);
- },
- closeAttr: function() {
- this.$emit('myevent');
- },
- CartNumDes: function() {
- this.$emit('ChangeCartNum', false);
- },
- CartNumAdd: function() {
- this.$emit('ChangeCartNum', true);
- },
- tapAttr: function(indexw, indexn) {
- let that = this;
- that.$emit("attrVal", {
- indexw: indexw,
- indexn: indexn
- });
- this.$set(this.attr.productAttr[indexw], 'index', this.attr.productAttr[indexw].attr_values[indexn]);
- let value = that
- .getCheckedValue()
- .sort()
- .join(",");
- that.$emit("ChangeAttr", value);
- },
- //获取被选中属性;
- getCheckedValue: function() {
- let productAttr = this.attr.productAttr;
- let value = [];
- for (let i = 0; i < productAttr.length; i++) {
- for (let j = 0; j < productAttr[i].attr_values.length; j++) {
- if (productAttr[i].index === productAttr[i].attr_values[j]) {
- value.push(productAttr[i].attr_values[j]);
- }
- }
- }
- return value;
- }
- }
- }
- </script>
- <style scoped lang="scss">
- .product-window {
- position: fixed;
- bottom: 0;
- width: 100%;
- left: 0;
- background-color: #fff;
- z-index: 77;
- border-radius: 16rpx 16rpx 0 0;
- padding-bottom: 140rpx;
- transform: translate3d(0, 100%, 0);
- transition: all .3s cubic-bezier(.25, .5, .5, .9);
- }
- .product-window.on {
- transform: translate3d(0, 0, 0);
- }
-
- .product-window.join{padding-bottom: 30rpx;}
- .product-window .textpic {
- padding: 0 130rpx 0 30rpx;
- margin-top: 29rpx;
- position: relative;
- }
- .product-window .textpic .pictrue {
- width: 150rpx;
- height: 150rpx;
- }
- .product-window .textpic .pictrue image {
- width: 100%;
- height: 100%;
- border-radius: 10rpx;
- }
- .product-window .textpic .text {
- width: 410rpx;
- font-size: 32rpx;
- color: #202020;
- }
- .product-window .textpic .text .money {
- font-size: 24rpx;
- margin-top: 40rpx;
- }
- .product-window .textpic .text .money .num {
- font-size: 36rpx;
- }
- .product-window .textpic .text .money .stock {
- color: #999;
- margin-left: 18rpx;
- }
- .product-window .textpic .iconfont {
- position: absolute;
- right: 30rpx;
- top: -5rpx;
- font-size: 35rpx;
- color: #8a8a8a;
- }
- .product-window .productWinList {
- max-height: 395rpx;
- overflow: auto;
- margin-top: 36rpx;
- }
- .product-window .productWinList .item~.item {
- margin-top: 36rpx;
- }
- .product-window .productWinList .item .title {
- font-size: 30rpx;
- color: #999;
- padding: 0 30rpx;
- }
- .product-window .productWinList .item .listn {
- padding: 0 30rpx 0 16rpx;
- }
- .product-window .productWinList .item .listn .itemn {
- border: 1px solid #bbb;
- font-size: 26rpx;
- color: #282828;
- padding: 7rpx 33rpx;
- border-radius: 6rpx;
- margin: 14rpx 0 0 14rpx;
- }
- .product-window .productWinList .item .listn .itemn.on {
- color: #fff;
- background-color: #ff3700;
- border-color: #ff3700;
- }
- .product-window .cart {
- margin-top: 36rpx;
- padding: 0 30rpx;
- }
- .product-window .cart .title {
- font-size: 30rpx;
- color: #999;
- }
- .product-window .cart .carnum {
- height: 54rpx;
- margin-top: 24rpx;
- }
- .product-window .cart .carnum view {
- border: 1px solid #a4a4a4;
- width: 84rpx;
- text-align: center;
- height: 100%;
- line-height: 54rpx;
- color: #a4a4a4;
- font-size: 45rpx;
- }
- .product-window .cart .carnum .reduce {
- border-right: 0;
- border-radius: 6rpx 0 0 6rpx;
- line-height: 48rpx;
- }
- .product-window .cart .carnum .reduce.on {
- border-color: #e3e3e3;
- color: #dedede;
- }
- .product-window .cart .carnum .plus {
- border-left: 0;
- border-radius: 0 6rpx 6rpx 0;
- line-height: 46rpx;
- }
- .product-window .cart .carnum .plus.on {
- border-color: #e3e3e3;
- color: #dedede;
- }
- .product-window .cart .carnum .num {
- color: #282828;
- font-size: 28rpx;
- }
- .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;}
- .product-window .joinBnt.on{background-color:#bbb;color:#fff;}
- </style>
|