| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302 |
- <template>
- <FootDialog :isTitle="false" :isRadius="true" :visible.sync="dialogShow" :zIndex="300">
- <view slot="main" class="book-wrap">
- <view class="goods-img-price-wrap">
- <view class="goods-img"><image :src="selectSkuItemObj.thumbnail || base.thumbnail"></image></view>
- <view class="goods-price-box">
- <view class="price">
- <text>¥ {{ selectSkuItemObj.price ? selectSkuItemObj.price : base.price }}</text>
- </view>
- <view class="sku-params" v-if="selectSkuItemObj.specificationValues && selectSkuItemObj.specificationValues.length > 0">
- <text>选择:</text>
- <text class="sku_str">
- <block v-for="(item, index) in selectSkuItemObj.specificationValues" :key="index">{{ space + item.value }}</block>
- </text>
- </view>
- <view class="count-num" v-if="selectSkuItemObj.availableStock">
- <text>库存:</text>
- <text>{{ space }}{{ selectSkuItemObj.availableStock }}</text>
- </view>
- </view>
- </view>
- <view class="goods-sku-list-wrap">
- <view class="sku-item" v-for="(item, index) in specifications" :key="index">
- <view class="sku-name">{{ item.name }}</view>
- <view class="sku-value-box">
- <block v-for="(skuItem, idx) in item.entries" :key="idx">
- <text
- v-if="JSON.stringify(selectSpecificationValueMaps)!=='{}'"
- @tap="onSelectSku(index, skuItem)"
- :class="[!skuItem.isSelected ? disabled : selectSpecificationValueMaps[index + ''].id == skuItem.id ? 'active' : '']"
- :style="skuItem.isSelected && selectSpecificationValueMaps[index + ''].id == skuItem.id ? 'color: #FFFFFF;' : 'color: #666666;'"
- >
- {{ skuItem.value }}
- </text>
- <text
- v-else
- @tap="onSelectSku(index, skuItem)"
- style="color: #666666;"
- >
- {{ skuItem.value }}
- </text>
- </block>
- </view>
- </view>
- </view>
- <view class="goods-num-select-wrap">
- <text class="num-text">数量</text>
- <view class="number-select">
- <view class="number-change-less" @tap.stop="onGoodsNum(-1)">-</view>
- <input class="goods-number" type="number" :value="number" @input="onInput" @blur="onGoodsNumBlur" />
- <view class="number_change_add" @tap.stop="onGoodsNum(1)">+</view>
- </view>
- </view>
- <view class="comfirm-btn-box"><button @tap="onConfirm">确定</button></view>
- <image @tap.stop="hide" class="book-close" src="http://139.9.103.171:1888/img/image/close.png"></image>
- </view>
- </FootDialog>
- </template>
- <script>
- import FootDialog from './foot_dialog.vue';
- export default {
- components: {
- FootDialog
- },
- props: {
- number: {
- type: [Number, String],
- default: 0
- },
- specifications: {
- type: Array,
- default: () => {
- return [];
- }
- },
- selectSpecificationValueMaps: {
- type: Object,
- default: () => {
- return {};
- }
- },
- base: {
- type: Object,
- default: () => {
- return {};
- }
- },
- selectSkuItemObj: {
- type: Object,
- default: () => {
- return {};
- }
- },
- dataList: {
- type: Array,
- default: () => {
- return []; // [{label:'选项',value:1}]
- }
- },
- type: {
- type: Number,
- default: -1
- }
- },
- data() {
- return {
- isSelected: false,
- space: '\xa0\xa0',
- dialogShow: false
- };
- },
- methods: {
- show() {
- if (!this.isSelected && this.specifications != null && this.specifications.length > 0) {
- for (var i = 0; i < this.specifications.length; i++) {
- if (this.specifications[i].entries != null && this.specifications[i].entries.length > 0) this.$emit('selectSku', i, this.specifications[i].entries[0]);
- }
- this.isSelected = true;
- }
- this.dialogShow = true;
- },
- hide() {
- this.dialogShow = false;
- },
- onSelectSku(index, skuItem) {
- this.$emit('selectsku', index, skuItem);
- },
- onInput(e) {
- this.$emit('update:number', e.detail.value);
- },
- onGoodsNumBlur(e) {
- this.$emit('goodsnumblur', e);
- },
- // 数量变化
- onGoodsNum(delta) {
- this.$emit('goodsnum', delta);
- },
- // 确认
- onConfirm(item) {
- this.$emit('confirm', item);
- }
- }
- };
- </script>
- <style lang="scss">
- .book-wrap {
- background: white;
- border-top-left-radius: 20upx;
- border-top-right-radius: 20upx;
- width: 100%;
- .goods-img-price-wrap {
- display: flex;
- flex-direction: row;
- align-items: center;
- padding: 30upx 0;
- border-bottom: 1 solid #e5e5e5;
- .goods-img {
- height: 120upx;
- width: 120upx;
- padding-left: 30upx;
- image {
- width: 120upx;
- height: 120upx;
- }
- }
- .goods-price-box {
- display: flex;
- flex-direction: column;
- justify-content: space-around;
- height: 120upx;
- padding-left: 28upx;
- .price {
- display: flex;
- flex-direction: row;
- align-items: center;
- text {
- padding-left: 10upx;
- padding-top: 7upx;
- font-size: 48upx;
- color: #2f7ff5;;
- }
- }
- .sku-params {
- font-size: 24upx;
- color: #999;
- }
- .count-num {
- font-size: 24upx;
- color: #999;
- }
- }
- }
- .goods-sku-list-wrap {
- display: flex;
- flex-direction: column;
- .sku-item {
- padding: 0 30upx;
- .sku-name {
- font-size: 24upx;
- color: #333;
- padding: 20upx 0upx;
- }
- .sku-value-box {
- display: flex;
- flex-wrap: wrap;
- flex-direction: row;
- text {
- font-size: 26upx;
- color: #333;
- padding: 10upx 20upx;
- margin-right: 15upx;
- border: 2upx solid #ebebeb;
- opacity: 0.6;
- border-radius: 5px;
- margin-bottom: 10upx;
- }
- .active {
- background-color:$base;
- border: 2upx solid $base;
- color: #fff;
- opacity: 1;
- }
- .disabled {
- background-color: #e5e5e5;
- color: #ccc;
- opacity: 1;
- }
- }
- }
- }
- .goods-num-select-wrap {
- display: flex;
- flex-direction: row;
- justify-content: space-between;
- align-items: center;
- padding: 20upx 30upx 30upx 30upx;
- .num-text {
- font-size: 24upx;
- color: rgb(51, 51, 51);
- }
- .number-select {
- height: 50upx;
- border-radius: 6upx;
- border: 2upx solid #e5e5e5;
- display: flex;
- flex-direction: row;
- align-items: center;
- justify-content: space-around;
- width: 200upx;
- .number-change-less {
- width: 60upx;
- text-align: center;
- border-right: 2upx solid #e5e5e5;
- height: 100%;
- line-height: 50upx;
- font-size: 36upx;
- }
- .number_change_add {
- width: 60upx;
- text-align: center;
- border-left: 2upx solid #e5e5e5;
- height: 100%;
- line-height: 50upx;
- font-size: 36upx;
- }
- .goods-number {
- margin-bottom: 0;
- width: 60upx;
- padding: 0 10upx;
- text-align: center;
- font-size: 36upx;
- color: #353535;
- }
- }
- }
- .comfirm-btn-box {
- margin: 40upx;
- button {
- color: #fff;
- border-radius: 6upx;
- text-align: center;
- background: $base;
- }
- }
- .book-close {
- position: absolute;
- width: 30upx;
- height: 30upx;
- right: 10upx;
- top: 0upx;
- padding: 20upx;
- }
- }
- </style>
|