123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396 |
- <template name="cm-parameter">
- <!-- 相关规格 -->
- <tui-bottom-popup :radius="true" :show="popupShow" @close="hidePopup()">
- <view class="tui-popup-box clearfix">
- <view class="tui-shopping-main" :style="{ paddingBottom: isIphoneX ? '68rpx' : '34rpx' }">
- <view class="tui-sku-title">
- <view class="tui-sku-image"> <image :src="skuProduct.image" mode=""></image> </view>
- <view class="tui-sku-price">
- <view class="sku-price-viw">
- <view class="sku-price-text">
- ¥{{ skuProduct.price }}
- </view>
- </view>
- </view>
- </view>
- <view class="tui-sku-unit">
- <view class="sku-unit-h1">规格:</view>
- <view class="sku-unit-li">
- <view
- class="unit-li"
- v-for="(sku, index) in skuList"
- @click="handleChoisSku(sku, index)"
- :key="index"
- :class="skuIndex === index ? 'active' : ''"
- >
- {{ sku.unit }}
- </view>
- </view>
- </view>
- <view class="sku-unit-nunbox">
- <view class="sku-unit-nunbox-t">
- <view class="sku-unit-nunbox-text">购买数量:</view>
- <view class="sku-unit-nunbox-num">
- <view class="number-box">
- <view
- class="iconfont icon-jianhao"
- @click="skuChangNumberSub"
- ></view>
- <input
- class="btn-input"
- type="number"
- v-model="addParams.count"
- maxlength="4"
- @blur="skuChangNumberChange($event)"
- />
- <view
- class="iconfont icon-jiahao"
- @click="skuChangNumberAdd"
- ></view>
- </view>
- </view>
- </view>
- </view>
- </view>
- <view class="tui-right-flex tui-popup-btn" :style="{ paddingBottom: isIphoneX ? '68rpx' : '34rpx' }">
- <view class="tui-modal-flex">
- <view class="tui-modal-button cancel" @click="hidePopup">取消</view>
- <view class="tui-modal-button confirm" :class="isBtnDisable ? 'disabled' :''" @click="handleConfirm">确定</view>
- </view>
- </view>
- </view>
- </tui-bottom-popup>
- </template>
- <script>
- import { mapState, mapMutations } from 'vuex'
- import uniGrader from '@/components/uni-grade/uni-grade.vue'
- export default {
- name: 'cm-unit-popup',
- components: {
- uniGrader
- },
- props: {
- skuProduct: {
- type: Object
- },
- popupShow: {
- type: Boolean,
- default: false
- },
- type: {
- type: Number,
- default: 1
- }
- },
- data() {
- return {
- isBtnDisable:false,
- vipFlag: 0, // 是否是超级会员 0否 1是
- skuIndex: 0,
- number: 0,
- ladderPriceList: [],
- isQuantity: false,
- skuList: [],
- handleStock:0,// 规格库存
- handleMinNumber:1, // 规格起订量
- addParams:{
- oldSkuId:0,
- newSkuId:0,
- count:0,
- productId:0,
- userId:0,
- source:1
- },
- }
- },
- filters: {
- NumFormat(value) {
- //处理金额
- return Number(value).toFixed(2)
- }
- },
- created() {
- this.skuList = this.skuProduct.skus
- this.addParams.productId = this.skuProduct.productId
- this.addParams.oldSkuId = this.skuProduct.skuId
- this.addParams.count = this.skuList[0].minBuyNumber
- this.handleMinNumber = this.skuList[0].minBuyNumber
- this.handleStock = this.skuList[0].stock
- this.skuProduct.price = this.skuList[0].price;
- this.isBtnDisable = this.skuList[0].stock === 0;
- this.initData()
- },
- computed: {
- ...mapState(['hasLogin'])
- },
- methods: {
- async initData(data) {
- const userInfo = await this.$api.getStorage()
- this.addParams.userId = userInfo.userId ? userInfo.userId : 0
- this.userIdentity = userInfo.userIdentity ? userInfo.userIdentity : 0
- },
- PromotionsFormat(promo) {
- //促销活动类型数据处理
- if (promo != null) {
- if (promo.type == 1 && promo.mode == 1) {
- return true
- } else {
- return false
- }
- }
- return false
- },
- isShowVipFlag(pros) {
- // 未登录 || 非会员
- if (!this.hasLogin || !this.vipFlag === 1) return false
- // 商品所有机构可见
- if (pros.priceFlag === 0) return true
- // 商品价格仅资质机构可见
- if (pros.priceFlag === 2 && this.userIdentity === 2) return true
- // 商品价格仅医美机构可见
- if (pros.priceFlag === 3 && this.userIdentity === 2 && this.firstClubType == 1) return true
- // 其它
- return false
- },
- skuChangNumberSub() {// 减数
- if ( this.addParams.count <= this.handleMinNumber) {
- this.addParams.count = this.handleMinNumber
- } else {
- this.addParams.count--
- }
- },
- skuChangNumberAdd() {// 加数
- if(this.addParams.count === this.handleStock){ return }
- this.addParams.count++;
- },
- skuChangNumberChange() {// 修改
- if (this.addParams.count < this.handleMinNumber || this.addParams.count % this.handleMinNumber != 0) {
- this.addParams.count = this.handleMinNumber;
- }else if(this.addParams.count > this.handleStock) {
- this.addParams.count = this.handleStock;
- }
- },
- handleConfirm() {
- if(this.isBtnDisable){ return }
- this.$emit('skuBtnConfirm', this.addParams)
- this.$parent.popupShow2 = false
- },
- handleChoisSku(sku, index) {
- // 选择SKU
- this.skuIndex = index
- this.addParams.newSkuId = sku.skuId;
- this.addParams.count = sku.minBuyNumber;
- this.handleStock = sku.stock;
- this.handleMinNumber = sku.minBuyNumber;
- this.skuProduct.price = sku.price;
- this.skuProduct.originalPrice = sku.originalPrice;
- this.isBtnDisable = sku.stock === 0;
- },
- hidePopup() {
- this.$parent.popupShow2 = false
- }
- }
- }
- </script>
- <style lang="scss">
- .tui-popup-box {
- padding: 40rpx 24rpx 0 24rpx;
- }
- .tui-shopping-main {
- width: 100%;
- .tui-sku-title {
- width: 100%;
- height: 136rpx;
- float: left;
- margin-bottom: 30rpx;
- .tui-sku-image {
- width: 138rpx;
- height: 138rpx;
- float: left;
- border-radius: 8rpx;
- margin-right: 30rpx;
- box-sizing: border-box;
- border: 1px dashed #e1e1e1;
- image {
- width: 134rpx;
- height: 134rpx;
- border-radius: 10rpx;
- }
- }
- .tui-sku-price {
- height: 136rpx;
- float: left;
- .sku-price-viw {
- width: 100%;
- height: 40rpx;
- margin-bottom: 24rpx;
- .sku-price-text {
- font-size: 28rpx;
- line-height: 40rpx;
- color: #f94b4b;
- font-weight: bold;
- .sku-price-l{
- float: left;
- font-weight: normal;
- }
- &.none {
- text-decoration: line-through;
- color: #999999;
- font-weight: normal;
- }
- }
- }
- .sku-price-vip {
- width: 100%;
- height: 40rpx;
- }
- }
- }
- .tui-sku-unit {
- width: 100%;
- height: auto;
- float: left;
- .sku-unit-h1 {
- font-size: 28rpx;
- line-height: 40rpx;
- color: #333333;
- font-weight: bold;
- }
- .sku-unit-li {
- width: 100%;
- height: auto;
- .unit-li {
- padding: 0 24rpx;
- line-height: 48rpx;
- text-align: center;
- font-size: 24rpx;
- color: #666666;
- background: #f5f5f5;
- float: left;
- margin-right: 16rpx;
- margin-top: 12rpx;
- margin-bottom: 12rpx;
- border-radius: 24rpx;
- position: relative;
- box-sizing: border-box;
- border: 1px solid #f5f5f5;
- &.active {
- border-color: $color-system;
- background: #fff1eb;
- color: $color-system;
- .tips {
- background: #FF5B00;
- }
- }
- .tips {
- padding: 0 10rpx;
- line-height: 32rpx;
- text-align: center;
- font-size: 22rpx;
- color: #ffffff;
- background: #cccccc;
- float: left;
- border-radius: 16rpx;
- position: absolute;
- right: -12rpx;
- top: -15rpx;
- }
- }
- }
- }
- .sku-unit-nunbox {
- justify-content: space-between;
- align-items: center;
- width: 100%;
- height: auto;
- float: left;
- margin-top: 30rpx;
- .sku-unit-nunbox-t {
- width: 100%;
- height: 44rpx;
- position: relative;
- margin-bottom: 20rpx;
- .text {
- font-size: $font-size-24;
- line-height: 48rpx;
- color: #999999;
- }
- .sku-unit-nunbox-text {
- line-height: 44rpx;
- font-size: $font-size-28;
- float: left;
- font-weight: bold;
- }
- .sku-unit-nunbox-num{
- float: right;
- .number-box {
- display: flex;
- justify-content: center;
- align-items: center;
- border: 2rpx solid #ffe6dc;
- border-radius: 30rpx;
- height: 48rpx;
- margin-left: 20rpx;
- .iconfont {
- font-size: $font-size-24;
- padding: 0 18rpx;
- color: #333333;
- text-align: center;
- line-height: 48rpx;
- font-weight: bold;
- background: #fef6f3;
- &.icon-jianhao {
- border-radius: 30rpx 0 0 30rpx;
- }
- &.icon-jiahao {
- border-radius: 0 30rpx 30rpx 0;
- }
- }
- .btn-input {
- width: 62rpx;
- height: 48rpx;
- line-height: 48rpx;
- background: #ffffff;
- border-radius: 4rpx;
- text-align: center;
- font-size: $font-size-28;
- }
- }
- }
- }
- }
- }
- .tui-popup-btn{
- width: 100%;
- float: left;
- .tui-modal-flex {
- width: 100%;
- height: 84rpx;
- margin-top: 40rpx;
- display: flex;
- .tui-modal-button {
- flex: 1;
- line-height: 84rpx;
- font-size: $font-size-28;
- text-align: center;
- border-radius: 42rpx;
- padding: 0;
- margin: 0 15rpx;
- box-sizing: border-box;
- &.cancel {
- background: #ffe6dc;
- color: #FF5B00;
- }
- &.confirm {
- background: $btn-confirm;
- color: #ffffff;
- &.disabled {
- background: linear-gradient(135deg, rgba(242, 143, 49, 0.5) 0%, rgba(225, 86, 22, 0.5) 100%);
- }
- }
- }
- }
- }
- </style>
|