Browse Source

修复价格显示

zhengjinyi 2 years ago
parent
commit
b6142f47c0

+ 52 - 35
pages/goods/components/cm-unit-popup.vue

@@ -6,7 +6,9 @@
 				<view class="tui-shopping-main" :style="{ paddingBottom: isIphoneX ? '68rpx' : '34rpx' }">
 					<view class="tui-sku-title">
 						<view class="tui-sku-image"> <image :src="skuProduct.mainImage" mode=""></image> </view>
-						<view class="tui-sku-price"> <cmUnitPrice :skuProduct="skuProduct"></cmUnitPrice> </view>
+						<view class="tui-sku-price">
+							<cmUnitPrice :skuProduct="skuProduct" :productCoupon="productCoupon"></cmUnitPrice>
+						</view>
 					</view>
 					<view class="tui-sku-unit">
 						<view class="sku-unit-h1">规格:</view>
@@ -51,7 +53,9 @@
 							</view>
 						</view>
 					</view>
-					<view class="sku-unit-ladel" v-if="isShowLadder" @click.stop="showLaddePopup"> 此规格商品存在阶梯价格,点击查看 >>> </view>
+					<view class="sku-unit-ladel" v-if="isShowLadder" @click.stop="showLaddePopup">
+						此规格商品存在阶梯价格,点击查看 >>>
+					</view>
 				</view>
 				<view
 					class="tui-right-flex tui-popup-btn"
@@ -59,13 +63,18 @@
 					:style="{ paddingBottom: isIphoneX ? '68rpx' : '34rpx' }"
 				>
 					<view class="tui-flex-1" v-if="type === 1">
-						<view class="tui-button" :class="[goodsData.disabled ? 'disabled' : '',isBtnDisable ? 'disabled' :'']" @click="handleBtnConfirm">确定</view>
+						<view
+							class="tui-button"
+							:class="[goodsData.disabled ? 'disabled' : '', isBtnDisable ? 'disabled' : '']"
+							@click="handleBtnConfirm"
+							>确定</view
+						>
 					</view>
 					<view class="tui-modal-flex" v-else>
 						<button
 							class="tui-modal-button cancel"
 							:disabled="goodsData.disabled"
-							:class="[goodsData.disabled ? 'disabled' : '',isBtnDisable ? 'disabled' :'']"
+							:class="[goodsData.disabled ? 'disabled' : '', isBtnDisable ? 'disabled' : '']"
 							@click="handleConfirm('add')"
 						>
 							加入购物车
@@ -73,7 +82,7 @@
 						<button
 							class="tui-modal-button confirm"
 							:disabled="goodsData.disabled"
-							:class="[goodsData.disabled ? 'disabled' : '',isBtnDisable ? 'disabled' :'']"
+							:class="[goodsData.disabled ? 'disabled' : '', isBtnDisable ? 'disabled' : '']"
 							@click="handleConfirm('buy')"
 						>
 							立即购买
@@ -103,11 +112,14 @@ export default {
 		skuProduct: {
 			type: Object
 		},
+		productCoupon: {
+			type: Array
+		},
 		goodsData: {
 			type: Object
 		},
 		popupShow: {
-			type: Boolean, 
+			type: Boolean,
 			default: false
 		},
 		type: {
@@ -123,15 +135,15 @@ export default {
 			skuIndex: 0,
 			productCount: 0,
 			ladderPriceList: [],
-			isStock:false,// 
+			isStock: false, //
 			isQuantity: false,
 			isShowButton: false,
 			skuList: [],
-			handleStock:0,// 规格库存
-			handleMinNumber:1, // 规格起订量
-			isShowLadder:false,
-			laddePopupShow:false,
-			isBtnDisable:false
+			handleStock: 0, // 规格库存
+			handleMinNumber: 1, // 规格起订量
+			isShowLadder: false,
+			laddePopupShow: false,
+			isBtnDisable: false
 		}
 	},
 	created() {
@@ -146,22 +158,22 @@ export default {
 			if (userInfo.userIdentity == 1 || userInfo.userIdentity == 3) {
 				this.isShowButton = false
 			} else {
-				this.isShowButton = true 
+				this.isShowButton = true
 			}
 			this.skuList = this.skuProduct.skus
 			this.productCount = this.skuList[0].minBuyNumber
 			this.handleMinNumber = this.skuList[0].minBuyNumber
 			this.handleStock = this.skuList[0].stock
-			if(this.skuList[0].ladderPriceList){ 
-				this.isShowLadder = true 
+			if (this.skuList[0].ladderPriceList) {
+				this.isShowLadder = true
 				this.ladderPriceList = this.skuList[0].ladderPriceList
 			}
 		},
 		//popup弹窗数量增加按钮
 		changeCountAdd() {
-			if(this.productCount === this.handleStock){ 
-				this.isStock = true 
-				return 
+			if (this.productCount === this.handleStock) {
+				this.isStock = true
+				return
 			}
 			if (this.skuProduct.step == 2) {
 				this.productCount += this.handleMinNumber
@@ -197,16 +209,16 @@ export default {
 			} else if (_value % this.handleMinNumber != 0) {
 				this.$util.msg('购买量必须为起订量的整数倍', 2000)
 				this.productCount = this.handleMinNumber
-			} else if(_value > this.handleStock) {
+			} else if (_value > this.handleStock) {
 				this.productCount = this.handleStock
-			}else{
+			} else {
 				this.productCount = e.detail.value
 			}
 			this.totalLadderPrice()
 		},
 		totalLadderPrice() {
 			//单独处理活动价格和阶梯价格
-			if(this.ladderPriceList.length>0){
+			if (this.ladderPriceList.length > 0) {
 				this.ladderPriceList.forEach((ladder, index) => {
 					if (this.productCount >= ladder.buyNum) {
 						this.$parent.skuProduct.price = ladder.buyPrice
@@ -216,7 +228,9 @@ export default {
 		},
 		handleConfirm(type) {
 			if (this.hasLogin) {
-				if(this.isBtnDisable || this.goodsData.disabled){ return }
+				if (this.isBtnDisable || this.goodsData.disabled) {
+					return
+				}
 				if (process.env.NODE_ENV != 'development') {
 					this.$uma.trackEvent(UmTrackEvent, {
 						Um_Key_PageName: UmKeyPageName,
@@ -224,9 +238,9 @@ export default {
 						Um_Key_ProductID: `${this.skuProduct.productId}`
 					})
 				}
-				const UmKeyPageName = type === 'add' ? '加入购物车' : '立即购买' 
-				const UmTrackEvent = type === 'add' ? 'Um_Event_ProductAddCart' : 'Um_Event_ProductBuyConfirm' 
-				this.$emit('buyConfirm', { type: type ,productCount : this.productCount } )
+				const UmKeyPageName = type === 'add' ? '加入购物车' : '立即购买'
+				const UmTrackEvent = type === 'add' ? 'Um_Event_ProductAddCart' : 'Um_Event_ProductBuyConfirm'
+				this.$emit('buyConfirm', { type: type, productCount: this.productCount })
 				this.$parent.popupShow3 = false
 			} else {
 				this.$api.navigateTo('/pages/login/login')
@@ -234,15 +248,18 @@ export default {
 		},
 		handleBtnConfirm() {
 			//确定加入购物车或立即购买
-			if(this.isBtnDisable || this.goodsData.disabled){ return }
-			if (process.env.NODE_ENV != 'development') {// 友盟埋点商品详情确认购买商品点击事件
+			if (this.isBtnDisable || this.goodsData.disabled) {
+				return
+			}
+			if (process.env.NODE_ENV != 'development') {
+				// 友盟埋点商品详情确认购买商品点击事件
 				this.$uma.trackEvent('Um_Event_ProductShoppingConfirm', {
 					Um_Key_PageName: '商品购买确认',
 					Um_Key_SourcePage: '商品详情',
 					Um_Key_ProductID: `${this.skuProduct.productId}`
 				})
 			}
-			this.$emit('buyConfirm', { type: this.btnType ,productCount : this.productCount})
+			this.$emit('buyConfirm', { type: this.btnType, productCount: this.productCount })
 			this.$parent.popupShow3 = false
 		},
 		handleChoisSku(sku, index) {
@@ -250,12 +267,12 @@ export default {
 			this.skuIndex = index
 			this.productCount = this.handleMinNumber = sku.minBuyNumber
 			this.handleStock = sku.stock
-			this.isBtnDisable = sku.stock === 0;
+			this.isBtnDisable = sku.stock === 0
 			this.ladderPriceList = sku.ladderPriceList
 			this.isShowLadder = sku.ladderPriceList ? true : false
 			this.$emit('skuClick', sku)
 		},
-		showLaddePopup(){
+		showLaddePopup() {
 			// 点击显示阶梯价
 			this.laddePopupShow = true
 		},
@@ -392,8 +409,8 @@ export default {
 						}
 						&.icon-jiahao {
 							border-radius: 0 30rpx 30rpx 0;
-							&.disabled{
-								background: #F5F5F5;
+							&.disabled {
+								background: #f5f5f5;
 							}
 						}
 					}
@@ -422,8 +439,8 @@ export default {
 		color: #e15616;
 	}
 }
-.tui-flex-1{
-	.tui-button{
+.tui-flex-1 {
+	.tui-button {
 		&.disabled {
 			background: linear-gradient(135deg, rgba(242, 143, 49, 0.5) 0%, rgba(225, 86, 22, 0.5) 100%);
 		}
@@ -446,7 +463,7 @@ export default {
 		&.cancel {
 			background: #ffe6dc;
 			color: #e15616;
-			&.disabled{
+			&.disabled {
 				background-color: #e1e1e1;
 				color: #ffffff;
 			}

+ 11 - 6
pages/goods/components/cm-unit-price.vue

@@ -87,7 +87,7 @@
 			<template v-if="!hasLogin">
 				<!-- 游客 -->
 				<view class="floor-item-act">
-					<view class="coupon-tags" v-if="this.$parent.productCoupon.length > 0">优惠券</view>
+					<view class="coupon-tags" v-if="productCoupon.length > 0">优惠券</view>
 					<template v-if="skuProduct.actStatus == 1">
 						<view v-if="skuProduct.promotions.type == 1 && skuProduct.promotions.mode == 1" class="floor-tags">
 							{{ skuProduct.promotions.name }}<text v-if="hasLogin">:¥{{ skuProduct.price | NumFormat }}</text>
@@ -102,7 +102,7 @@
 			<template v-else-if="userIdentity == 1">
 				<!-- 协销 -->
 				<view class="floor-item-act">
-					<view class="coupon-tags" v-if="this.$parent.productCoupon.length > 0">优惠券</view>
+					<view class="coupon-tags" v-if="productCoupon.length > 0">优惠券</view>
 					<template v-if="skuProduct.actStatus == 1">
 						<view v-if="skuProduct.promotions.type == 1 && skuProduct.promotions.mode == 1" class="floor-tags">
 							{{ skuProduct.promotions.name
@@ -124,7 +124,7 @@
 			<template v-else-if="userIdentity == 2 || (userIdentity == 4 && vipFlag == 1)">
 				<!-- 资质机构 -->
 				<view class="floor-item-act">
-					<view class="coupon-tags" v-if="this.$parent.productCoupon.length > 0">优惠券</view>
+					<view class="coupon-tags" v-if="productCoupon.length > 0">优惠券</view>
 					<template v-if="skuProduct.actStatus == 1">
 						<view v-if="skuProduct.promotions.type == 1 && skuProduct.promotions.mode == 1" class="floor-tags">
 							{{ skuProduct.promotions.name
@@ -147,7 +147,7 @@
 			<template v-else-if="userIdentity == 3">
 				<!-- 供应商 -->
 				<view class="floor-item-act">
-					<view class="coupon-tags" v-if="this.$parent.productCoupon.length > 0">优惠券</view>
+					<view class="coupon-tags" v-if="productCoupon.length > 0">优惠券</view>
 					<template v-if="skuProduct.actStatus == 1">
 						<view v-if="skuProduct.promotions.type == 1 && skuProduct.promotions.mode == 1" class="floor-tags">
 							{{ skuProduct.promotions.name
@@ -172,7 +172,7 @@
 			<template v-else-if="userIdentity == 4 && vipFlag != 1">
 				<!-- 普通机构 -->
 				<view class="floor-item-act">
-					<view class="coupon-tags" v-if="this.$parent.productCoupon.length > 0">优惠券</view>
+					<view class="coupon-tags" v-if="productCoupon.length > 0">优惠券</view>
 					<template v-if="skuProduct.actStatus == 1">
 						<view v-if="PromotionsFormat(skuProduct.promotions)" class="floor-tags">
 							{{ skuProduct.promotions.name
@@ -206,7 +206,12 @@ export default {
 	},
 	props: {
 		skuProduct: {
-			type: Object
+			type: Object,
+			default: {}
+		},
+		productCoupon: {
+			type: Array,
+			default: []
 		}
 	},
 	data() {

+ 1 - 0
pages/goods/product.vue

@@ -558,6 +558,7 @@
 			v-if="popupShow3"
 			:popupShow="popupShow3"
 			:skuProduct="skuProduct"
+			:productCoupon="productCoupon"
 			:type="unitPopupType"
 			:btnType="btnType"
 			:goodsData="goodsData"