lilei 4 months ago
parent
commit
b8bd8458cc

+ 3 - 2
pagesB/cart/index.vue

@@ -232,7 +232,6 @@
 							  }
 						  }
 						  key.priceStr = Number(key.price).toFixed(2).toString().split('.')
-						  delete key.shopPromoProduct
 						  return {
 								id: key.id,
 								edit: false,
@@ -256,7 +255,9 @@
 								promoType: key.promoType,
 								promoProductSn: key.promoProductSn,
 								promoSn: key.promoSn,
-								giftQty: 0
+								giftQty: 0,
+								shopPromoProduct: key.shopPromoProduct,
+								shopProductSubsidy: key.shopProductSubsidy
 							}
 					  }))
 				  }

+ 1 - 1
pagesB/cart/productitem.vue

@@ -35,7 +35,7 @@
 								<view class="flex align_center tejia-tag" v-if="item.promoType=='PROMO_PROD'">
 									特价<text>¥{{item.orginPrice}}</text>
 								</view>
-								<view class="flex align_center tejia-tag" v-if="item.shopProductSubsidy&&!item.shopPromoProduct">
+								<view class="flex align_center rebate-tag" v-if="item.shopProductSubsidy&&item.shopProductSubsidy.subsidyAmount<item.price&&!item.shopPromoProduct">
 									可抵扣<text>¥{{item.shopProductSubsidy.subsidyAmount}}</text>
 								</view>
 							</view>

+ 19 - 5
pagesB/components/payOptions.vue

@@ -4,17 +4,23 @@
 			<text>{{title}}:</text>
 		</view>
 		<view class="pay-item">
-			<view class="flex align_center justify_between" @tap="changeItem(0)">
+			<view class="flex align_center justify_between" v-if="hasBalancePay" @tap="changeItem(0)">
 				<view>
 					<uni-icons size="18" :type="defaultValue=='0'?'checkbox-filled':'checkbox'" color="#2196f3"></uni-icons>
 				</view>
-				<view>充值余额(<text class="pf">¥</text>{{balance}})</view>
+				<view class="flex align_center">充值余额(<text class="pf">¥</text>{{balance}})</view>
 			</view>
-			<view class="flex align_center justify_between" @tap="changeItem(1)">
+			<view class="flex align_center justify_between" v-if="hasPay" @tap="changeItem(1)">
 				<view>
 					<uni-icons size="18" :type="defaultValue=='1'?'checkbox-filled':'checkbox'" color="#2196f3"></uni-icons>
 				</view>
-				<view>微信支付</view>
+				<view class="flex_auto u-text-right">微信支付</view>
+			</view>
+			<view class="flex align_center justify_between" @tap="changeItem(2)">
+				<view>
+					<uni-icons size="18" :type="defaultValue=='2'?'checkbox-filled':'checkbox'" color="#2196f3"></uni-icons>
+				</view>
+				<view class="flex_auto u-text-right">线下支付</view>
 			</view>
 		</view>
 	</view>
@@ -29,11 +35,19 @@
 			},
 			value: {
 				type: String,
-				default: '1'
+				default: '2'
 			},
 			balance: {
 				type: Number,
 				default: 0
+			},
+			hasBalancePay:{
+				type: Boolean,
+				default: false
+			},
+			hasPay: {
+				type: Boolean,
+				default: false
 			}
 		},
 		data() {

+ 46 - 12
pagesB/procureOrder/creatOrder.vue

@@ -38,10 +38,14 @@
 								<text>总金额</text>
 								<text class="price">¥{{Number(totalAmount).toFixed(2)}}</text>
 							</view>
-							<view class="product-price-item" v-if="hasBalancePay">
-								<view class="flex align_center"><uni-icons size="18" :type="hasBlancel?'checkbox-filled':'checkbox'" color="#2196f3"></uni-icons> 抵扣(余额:¥3.00)</view>
-								<view class="flex align_center">
-									<text>¥2.00</text>
+							<view class="product-price-item" v-if="hasBalancePay&&subsidyAmount">
+								<view class="flex align_center" v-if="storeAccount">抵扣(余额:¥{{storeAccount.giveBalance}})</view>
+								<view class="flex align_center" v-if="!disKdk" @click="hasKdk=!hasKdk">
+									<uni-icons size="18" :type="hasKdk?'checkbox-filled':'checkbox'" color="#2196f3"></uni-icons> 
+									<text>¥{{subsidyAmount}}</text>
+								</view>
+								<view class="flex align_center" v-else>
+									<text>¥{{subsidyAmount}}</text>
 								</view>
 							</view>
 							<view class="product-price-item" v-if="totalDiscount">
@@ -54,9 +58,12 @@
 							</view>
 							<view class="product-price-item" v-if="totalAmount">
 								<text>合计:</text>
-								<text class="price">¥{{Number(totalAmount).toFixed(2)}}</text>
+								<text class="price">¥{{settleAmount.join('.')}}</text>
 							</view>
 						</view>
+						<view style="margin-top: 10px;">
+							<payOptions v-model="payType" :hasBalancePay="hasBalancePay" :hasPay="shelfInfo&&shelfInfo.payOnlineFlag&&shelfInfo.payOnlineFlag=='1'" @change="v=>hasKdk=v!=2" :balance="storeAccount?storeAccount.rechargeBalance:0"></payOptions>
+						</view>
 					</view>
 				</scroll-view>
 				<!-- 底部 -->
@@ -91,12 +98,14 @@
 	import productItem from '@/pagesB/cart/productitem.vue'
 	import sklineHeader from '../../components/skline/sklineHeader.vue'
 	import payModal from '../components/payModal.vue'
+	import payOptions from '../components/payOptions.vue'
 	import { purchaseSave, purchaseCheck, purchasePay } from '@/api/purchase.js'
 	export default {
 		components:{
 			productItem,
 			sklineHeader,
-			payModal
+			payModal,
+			payOptions
 		},
 		onLoad() {
 			// 计算区域高度
@@ -126,6 +135,7 @@
 				total: 0, // 总款数
 				totalAmount: 0, // 总金额
 				totalDiscount:0, // 总优惠
+				subsidyAmount:0, // 总可抵扣金额
 				totalCoupon: 0, // 总代金券
 				totalNum: 0, // 总数量
 				screenWidth: 325, // 屏幕宽度
@@ -134,7 +144,8 @@
 				safeAreaBottom: 0, // 底部安全区域高度
 				showPopu: false, // 弹框
 				payData: null ,// 付款参数
-				hasBlancel: true
+				payType: 0, // 支付方式,0抵扣、1微信,2线下
+				hasKdk: false, // 是否使用抵扣金额
 			}
 		},
 		computed: {
@@ -152,7 +163,16 @@
 			},
 			// 抵扣余额支付是否可用,有【余额支付权限】且该产品有抵扣金额
 			hasBalancePay(){
-				return true
+				return this.$store.state.vuex_showBalanceAuth&&this.storeAccount.giveBalance
+			},
+			// 抵扣总余额
+			storeAccount(){
+				return this.$store.state.vuex_storeAccount
+			},
+			// 禁用抵扣金额
+			disKdk(){
+				const kdk = this.storeAccount&&this.subsidyAmount>0&&this.subsidyAmount<this.storeAccount.giveBalance
+				return this.payType==2 || !kdk
 			},
 			// 最小支付金额
 			minPayAmount(){
@@ -162,7 +182,7 @@
 			//是否开启线上支付
 			hasPay(){
 				const shelfInfo = this.shelfInfo
-				return shelfInfo&&shelfInfo.payOnlineFlag&&shelfInfo.payOnlineFlag=='1'
+				return shelfInfo&&shelfInfo.payOnlineFlag&&shelfInfo.payOnlineFlag=='1'&&this.payType!=2
 			},
 			// 付款信息
 			payInfo(){
@@ -297,10 +317,17 @@
 								bizSn:res.data.purchaseSn,
 								bizNo:res.data.purchaseNo,
 								bizType:'SETTLE_BILL',
-								payUserOpenId: this.$store.state.vuex_openid || uni.getStorageSync('openid')
+								payUserOpenId: this.$store.state.vuex_openid || uni.getStorageSync('openid'),
+								settleType: this.payType == 0 ? 'RECHARGE_BALANCE' : 'WXPAY_ONLINE'
 							}).then(res=>{
-								this.showPopu = true
-								this.payData = res.data?res.data.payRequestRest:null
+								// 微信支付
+								if(this.payType == 1){
+									this.showPopu = true
+									this.payData = res.data?res.data.payRequestRest:null
+								}else{
+									// 余额支付
+									this.payComplete(null,true)
+								}
 							})
 						}else{
 							this.payComplete(null,true)
@@ -324,6 +351,7 @@
 			getChooseHeji(){
 				this.totalAmount = 0
 				this.totalDiscount = 0
+				this.subsidyAmount = 0
 				this.totalCoupon = 0
 				this.total = 0
 				this.totalNum = 0
@@ -332,6 +360,10 @@
 						this.totalAmount += item.price * item.qty // 总金额
 						this.totalNum += item.qty // 总数量
 						this.total += 1 // 总款数
+						// 有抵扣金额
+						if(item.shopProductSubsidy){
+							this.subsidyAmount += item.shopProductSubsidy.subsidyAmount
+						}
 						// 如果是返券类型
 						if(item.promoType=='BUY_PROD_GIVE_VALID'){
 							this.totalCoupon += item.resultValue * item.qty
@@ -344,6 +376,8 @@
 						item.giftQty = item.promoType=='BUY_PROD_GIVE_PROD' ? Math.floor(item.qty / item.conditionValue)*item.resultValue : 0
 					})
 				})
+				// 可抵扣金额小于抵扣金额且大于0
+				this.hasKdk = this.subsidyAmount>0&&this.subsidyAmount<this.storeAccount.giveBalance
 			},
 		}
 	}

+ 4 - 0
pagesB/procureOrder/orderDetail.vue

@@ -98,6 +98,10 @@
 					<text>总金额</text>
 					<view class="price-txt">¥<text>{{Number(info.totalAmount).toFixed(2)}}</text></view>
 				</view>
+				<view class="infoList gray-text" v-if="info.totalSubsidyAmount">
+					<text>总抵扣</text>
+					<text class="cText">¥{{Number(info.totalSubsidyAmount).toFixed(2)}}</text>
+				</view>
 				<view class="infoList gray-text" v-if="info.totalSpecialGiveAmount">
 					<text>总优惠</text>
 					<text class="cText">¥{{Number(info.totalSpecialGiveAmount).toFixed(2)}}</text>

+ 30 - 20
pagesB/shopiing/productDetail.vue

@@ -138,7 +138,7 @@
 								特价<text>¥{{detail.orginPrice}}</text>
 							</view>
 							<view class="flex align_center rebate-tag" 
-							v-if="hasLogin&&detail.shopProductSubsidy&&detail.shopProductSubsidy.subsidyAmount<item.price&&!detail.shopPromoProduct">
+							v-if="hasLogin&&detail.shopProductSubsidy&&detail.shopProductSubsidy.subsidyAmount<detail.price&&!detail.shopPromoProduct">
 								可抵扣<text>¥{{detail.shopProductSubsidy.subsidyAmount}}</text>
 							</view>
 						</view>
@@ -177,7 +177,7 @@
 						<text>配送商:{{shelfInfo.dealerName}}</text>
 						<view @click="callPhone()"><uni-icons size="18" type="phone" color="dodgerblue"></uni-icons><text style="font-size:12px;">拨打</text></view>
 					</view>
-					<view v-if="hasBalancePay&&storeAccount.giveBalance&&!isAddCart">
+					<view v-if="hasBalancePay&&!isAddCart">
 						<view class="totalBar-box">
 							<view class="flex align_center justify_between">
 								<view>总金额</view>
@@ -185,17 +185,20 @@
 							</view>
 							<view class="flex align_center justify_between">
 								<view v-if="storeAccount">抵扣(余额:<text class="pf">¥</text>{{storeAccount.giveBalance}})</view>
-								<view class="flex align_center" v-if="detail.shopProductSubsidy" @click="hasKdk=!hasKdk">
+								<view class="flex align_center" v-if="!disKdk" @click="hasKdk=!hasKdk">
 									<uni-icons size="18" :type="hasKdk?'checkbox-filled':'checkbox'" color="#2196f3"></uni-icons> 
 									<text class="pf">¥</text>{{detail.shopProductSubsidy.subsidyAmount}}
 								</view>
+								<view class="flex align_center" v-else>
+									<text class="pf">¥</text>{{detail.shopProductSubsidy.subsidyAmount}}
+								</view>
 							</view>
-							<view class="flex align_center justify_between" v-if="detail.shopProductSubsidy">
-								<view>合计</view>
-								<view><text class="pf">¥</text>{{Number(totalAmount-(hasKdk?detail.shopProductSubsidy.subsidyAmount:0)).toFixed(2)}}</view>
+							<view class="flex align_center justify_end" v-if="detail.shopProductSubsidy">
+								<view>合计</view>
+								<view><text class="pf">¥</text>{{payAmount}}</view>
 							</view>
 						</view>
-						<payOptions v-model="payType" :balance="storeAccount?storeAccount.rechargeBalance:0"></payOptions>
+						<payOptions v-model="payType" :hasBalancePay="hasBalancePay" :hasPay="hasPay" @change="v=>hasKdk=v!=2" :balance="storeAccount?storeAccount.rechargeBalance:0"></payOptions>
 					</view>
 				</view>
 				<view class="popu-content-btn">
@@ -229,8 +232,11 @@
 						<view></view>
 					</view>
 					<view class="popu-content-pay flex align_center justify_between">
-						<view class="flex align_center"><uni-icons size="20" type="weixin" color="#4CAF50"></uni-icons> <text style="margin-left: 5px;">微信支付</text></view>
-						<view><uni-icons size="22" type="checkbox-filled" color="red"></uni-icons></view>
+						<view class="flex align_center">
+							<uni-icons size="20" type="weixin" color="#4CAF50"></uni-icons> 
+							<text style="margin-left: 5px;">微信支付</text>
+						</view>
+						<view><uni-icons size="22" type="checkbox-filled" color="#2196f3"></uni-icons></view>
 					</view>
 				</view>
 				<view class="popu-content-btn">
@@ -291,9 +297,8 @@
 				showPay: false, // 是否显示付款信息
 				isAddCart: false, // 是否加入购物车
 				payData: null, // 支付参数
-				payType: 0, // 支付方式,抵扣、还是微信
+				payType: 0, // 支付方式,0抵扣、1微信,2线下
 				hasKdk: false,
-				disKdk: false,
 			}
 		},
 		onLoad(option) {
@@ -324,10 +329,10 @@
 			shelfInfo(){
 				return this.$store.state.vuex_storeShelf
 			},
-			//是否开启线上支付
+			//是否开启线上支付,支付方式不是线下支付
 			hasPay(){
 				const shelfInfo = this.shelfInfo
-				return shelfInfo&&shelfInfo.payOnlineFlag&&shelfInfo.payOnlineFlag=='1'
+				return shelfInfo&&shelfInfo.payOnlineFlag&&shelfInfo.payOnlineFlag=='1'&&this.payType!=2
 			},
 			// 最小支付金额
 			minPayAmount(){
@@ -336,11 +341,16 @@
 			},
 			// 抵扣余额支付是否可用,有【余额支付权限】且该产品有抵扣金额
 			hasBalancePay(){
-				return this.$store.state.vuex_showBalanceAuth
+				return this.$store.state.vuex_showBalanceAuth&&this.storeAccount.giveBalance&&this.detail&&!this.detail.shopPromoProduct
 			},
 			storeAccount(){
 				return this.$store.state.vuex_storeAccount
 			},
+			// 禁用抵扣金额
+			disKdk(){
+				const kdk = this.detail&&this.detail.shopProductSubsidy&&this.storeAccount&&this.detail.shopProductSubsidy.subsidyAmount>0&&this.detail.shopProductSubsidy.subsidyAmount<this.storeAccount.giveBalance
+				return this.payType==2 || !kdk
+			},
 			// 经销商电话
 			dealerPhone(){
 				const shelfInfo = this.shelfInfo
@@ -353,15 +363,14 @@
 			totalAmount(){
 				return this.hasLogin&&this.detail&&this.detail.price * this.qty
 			},
+			// 支付合计,结算金额
+			payAmount(){
+				return Number(this.totalAmount-(this.hasKdk&&this.detail&&this.detail.shopProductSubsidy?this.detail.shopProductSubsidy.subsidyAmount:0)).toFixed(2)
+			},
 			// 赠品数量
 			giftNum(){
 				return this.detail && this.detail.promoType=='BUY_PROD_GIVE_PROD' ? Math.floor(this.qty / this.detail.conditionValue)*this.detail.resultValue : 0
 			},
-			// 支付总金额
-			payAmount(){
-				const price = this.detail && this.detail.priceStr ? this.detail.priceStr.join('.') : 0
-				return price ? Number(price*this.qty).toFixed(2) : 0
-			},
 			// 付款信息
 			payInfo(){
 				return this.$store.state.vuex_tempOrderData
@@ -443,7 +452,6 @@
 							// 可抵扣金额小于抵扣金额且大于0
 							const kdk = res.data.shopProductSubsidy&&res.data.shopProductSubsidy.subsidyAmount>0&&res.data.shopProductSubsidy.subsidyAmount<this.storeAccount.giveBalance
 							this.hasKdk = kdk
-							this.disKdk = !kdk
 						}
 					}
 					uni.hideLoading()
@@ -524,6 +532,8 @@
 							// 打开数量选择弹框
 							if(!this.showPopu){
 								this.showPopu = true
+								this.payType = this.hasBalancePay ? 0 : (this.hasPay ? 1 : 2)
+								this.hasKdk = this.detail.shopProductSubsidy&&this.detail.shopProductSubsidy.subsidyAmount>0&&this.detail.shopProductSubsidy.subsidyAmount<this.storeAccount.giveBalance
 							}else{
 								if(this.hasPay && this.minPayAmount>this.payAmount){
 									uni.showModal({