Browse Source

价值优惠券采美豆抵扣

zhengjinyi 3 years ago
parent
commit
c8a618859c

+ 23 - 4
components/cm-module/cart-components/index.vue

@@ -387,15 +387,15 @@
 										<view class="list-cell-btn">
 											<view class="icon-used">
 												<template v-if="coupon.couponBtnType == 0">
-													<template v-if="coupon.moneyCouponFlag == 1">
-														<view class="icon-used-text">1000采美豆</view>
+													<template v-if="coupon.couponPayWay == 2">
+														<view class="icon-used-text">{{ coupon.moneyCouponPrice }}采美豆</view>
 														<view
 															class="icon-used-btn receive"
 															@click="toDeductCoupon(coupon)"
 															>抵扣</view
 														>
 													</template>								
-													<template v-else-if="coupon.moneyCouponFlag == 0">
+													<template v-else-if="coupon.couponPayWay == 1">
 														<view class="icon-used-text">购买</view>
 														<view
 															class="icon-used-btn receive"
@@ -1513,11 +1513,30 @@ export default {
 					this.$util.msg('您的身份暂不支持领取优惠券', 2000)
 					return
 				}
-				this.createCouponRecord(coupon)
+				this.WeChatPayCouponBeans(coupon)
 			} else {
 				this.$api.navigateTo('/pages/login/login')
 			}
 		},
+		WeChatPayCouponBeans(coupon){
+			// 采美豆抵扣优惠券
+			this.PayService.WeChatPayCouponBeans({
+				source: 1, //领取渠道 1 小程序  2 网站
+				userId: this.couponParam.userId,
+				couponId: coupon.couponId
+			})
+			.then(response => {
+				this.$util.msg('抵扣成功', 1500)
+				setTimeout(() => {
+					this.currentTab = 1
+					this.couponParam.status = 2
+					this.queryPopupCoupons()
+				}, 1500)
+			})
+			.catch(error => {
+				this.$util.msg(error.msg, 2000)
+			})
+		},
 		toPayCoupon(coupon){
 			// 点击购买优惠券,友盟埋点收集购买优惠券
 			if (process.env.NODE_ENV != 'development') {

+ 23 - 4
pages/goods/product.vue

@@ -422,15 +422,15 @@
 												<view class="list-cell-btn">
 													<view class="icon-used">
 														<template v-if="coupon.couponBtnType == 0">
-															<template v-if="coupon.moneyCouponFlag == 1">
-																<view class="icon-used-text">1000采美豆</view>
+															<template v-if="coupon.couponPayWay == 2">
+																<view class="icon-used-text">{{ coupon.moneyCouponPrice }}采美豆</view>
 																<view
 																	class="icon-used-btn receive"
 																	@click="toDeductCoupon(coupon)"
 																	>抵扣</view
 																>
 															</template>								
-															<template v-else-if="coupon.moneyCouponFlag == 0">
+															<template v-else-if="coupon.couponPayWay == 1">
 																<view class="icon-used-text">购买</view>
 																<view
 																	class="icon-used-btn receive"
@@ -1158,11 +1158,30 @@ export default {
 					this.$util.msg('您的身份暂不支持领取优惠券', 2000)
 					return
 				}
-				this.createCouponRecord(coupon)
+				this.WeChatPayCouponBeans(coupon)
 			} else {
 				this.$api.navigateTo('/pages/login/login')
 			}
 		},
+		WeChatPayCouponBeans(coupon){
+			// 采美豆抵扣优惠券
+			this.PayService.WeChatPayCouponBeans({
+				source: 1, //领取渠道 1 小程序  2 网站
+				userId: this.couponParam.userId,
+				couponId: coupon.couponId
+			})
+			.then(response => {
+				this.$util.msg('抵扣成功', 1500)
+				setTimeout(() => {
+					this.currentTab = 1
+					this.couponParam.status = 2
+					this.queryPopupCoupons()
+				}, 1500)
+			})
+			.catch(error => {
+				this.$util.msg(error.msg, 2000)
+			})
+		},
 		toPayCoupon(coupon) {
 			// 点击购买优惠券,友盟埋点收集购买优惠券
 			if (process.env.NODE_ENV != 'development') {

+ 23 - 5
pages/seller/cart/coupon-share.vue

@@ -30,19 +30,20 @@
 						<view class="list-cell-time">{{ coupon.startDate }} - {{ coupon.endDate }}</view>
 					</view>
 					<view class="list-cell-ri">
-						<template  v-if="coupon.couponBtnType == 1">
+						<template  v-if="coupon.couponPayWay == 1">
 							<view class="coupon-minMoney">售价</view>
 							<view class="coupon-maxMoney"> <text class="small">¥</text> {{ coupon.moneyCouponPrice }} </view>
 						</template>
-						<template v-else>
+						<template v-if="coupon.couponPayWay == 2">
 							<view class="coupon-minMoney">售价</view>
-							<view class="coupon-maxMoney">1000采美豆 </view>
+							<view class="coupon-maxMoney">{{ coupon.moneyCouponPrice }}采美豆</view>
 						</template>
 					</view>
 				</view>
 			</view>
 			<view class="container-button">
-				<view class="button" @click="createCouponRecord">¥{{ coupon.moneyCouponPrice }}购买</view>
+				<view class="button" v-if="coupon.couponPayWay == 1" @click="createCouponRecord">¥{{ coupon.moneyCouponPrice }}购买</view>
+				<view class="button" v-if="coupon.couponPayWay == 2" @click="WeChatPayCouponBeans">{{ coupon.moneyCouponPrice }}采美豆抵扣</view>
 			</view>
 		</view>
 		<!-- 弹窗提示 -->
@@ -141,6 +142,23 @@ export default {
 					console.log('初始化优惠券信息异常~')
 				})
 		},
+		WeChatPayCouponBeans(coupon){
+			// 采美豆抵扣优惠券
+			this.PayService.WeChatPayCouponBeans({
+				source: 1, //领取渠道 1 小程序  2 网站
+				userId: this.userId,
+				couponId: this.couponId
+			})
+			.then(response => {
+				this.$util.msg('抵扣成功', 1500)
+				setTimeout(() => {
+					this.$api.switchTabTo('/pages/tabBar/home/index')
+				}, 1500)
+			})
+			.catch(error => {
+				this.$util.msg(error.msg, 2000)
+			})
+		},
 		createCouponRecord(){
 			// 生成购买优惠券记录Id
 			this.PayService.WeChatCouponRecord({
@@ -282,7 +300,7 @@ page {
 				width: 100%;
 				height: 78rpx;
 				line-height: 78rpx;
-				font-size: 40rpx;
+				font-size: 28rpx;
 				color: #f94b4b;
 				text-align: center;
 				.small {

+ 1 - 1
pages/seller/cart/coupon.vue

@@ -8,7 +8,7 @@
 			<template v-else>
 				<view v-for="(coupon, index) in coupinList" :key="index" :id="coupon.id" class="coupon-list">
 					<view class="list-cell-tag" v-if="coupon.couponBtnType == 1">售价¥{{ coupon.moneyCouponPrice }}</view>
-					<view class="list-cell-tag" v-else>售价1000采美豆</view>
+					<view class="list-cell-tag" v-else>售价{{ coupon.moneyCouponPrice }}采美豆</view>
 					<view class="list-cell-le">
 						<view class="coupon-maxMoney"> <text class="small">¥</text> {{ coupon.couponAmount }} </view>
 						<view class="coupon-minMoney"> 满{{ coupon.touchPrice }}可用 </view>

+ 34 - 7
pages/user/coupon/coupon-activity.vue

@@ -54,13 +54,23 @@
 								</view>
 								<view class="list-cell-btn">
 									<view class="icon-used">
-										<template v-if="coupon.moneyCouponFlag == 0">
-											<view class="icon-used-text">1000采美豆</view>
-											<view class="icon-used-btn buy" @click="toDeductCoupon(coupon)"
-												>抵扣</view
-											>
+										<template v-if="coupon.couponPayWay == 2">
+											<template v-if="coupon.couponBtnType == 0">
+												<view class="icon-used-text">{{ coupon.moneyCouponPrice }}采美豆</view>
+												<view class="icon-used-btn buy" @click="toDeductCoupon(coupon)"
+													>抵扣</view
+												>
+											</template>
+											<template v-else>
+												<view
+													class="icon-used-btn make"
+													v-if="coupon.couponBtnType == 1"
+													@click="toUseCoupon(coupon)"
+													>去使用</view
+												>
+											</template>
 										</template>								
-										<template v-else-if="coupon.moneyCouponFlag == 1">
+										<template v-else-if="coupon.couponPayWay == 1">
 											<view class="icon-used-text">购买</view>
 											<view class="icon-used-btn buy" @click="toPayCoupon(coupon)"
 												>¥{{ coupon.moneyCouponPrice }}</view
@@ -344,11 +354,28 @@ export default {
 					this.$util.msg('您的身份暂不支持领取优惠券', 2000)
 					return
 				}
-				this.createCouponRecord(coupon)
+				this.WeChatPayCouponBeans(coupon)
 			} else {
 				this.$api.navigateTo('/pages/login/login')
 			}
 		},
+		WeChatPayCouponBeans(coupon){
+			// 采美豆抵扣优惠券
+			this.PayService.WeChatPayCouponBeans({
+				source: 1, //领取渠道 1 小程序  2 网站
+				userId: this.listQuery.userId,
+				couponId: coupon.couponId
+			})
+			.then(response => {
+				this.$util.msg('抵扣成功', 1500)
+				setTimeout(() => {
+					coupon.couponBtnType = 1
+				}, 1500)
+			})
+			.catch(error => {
+				this.$util.msg(error.msg, 2000)
+			})
+		},
 		toPayCoupon(coupon) {
 			// 点击购买优惠券,友盟埋点收集购买优惠券
 			if (process.env.NODE_ENV != 'development') {

+ 34 - 7
pages/user/coupon/coupon-collection.vue

@@ -44,13 +44,23 @@
 							</view>
 							<view class="list-cell-btn">
 								<view class="icon-used">
-									<template v-if="coupon.moneyCouponFlag == 1">
-										<view class="icon-used-text">1000采美豆</view>
-										<view class="icon-used-btn buy" @click="toDeductCoupon(coupon)"
-											>抵扣</view
-										>
+									<template v-if="coupon.couponPayWay == 2">
+										<template v-if="coupon.couponBtnType == 0">
+											<view class="icon-used-text">{{ coupon.moneyCouponPrice }}采美豆</view>
+											<view class="icon-used-btn buy" @click="toDeductCoupon(coupon)"
+												>抵扣</view
+											>
+										</template>
+										<template v-else>
+											<view
+												class="icon-used-btn make"
+												v-if="coupon.couponBtnType == 1"
+												@click="toUseCoupon(coupon)"
+												>去使用</view
+											>
+										</template>
 									</template>								
-									<template v-else-if="coupon.moneyCouponFlag == 0">
+									<template v-else-if="coupon.couponPayWay == 1">
 										<view class="icon-used-text">购买</view>
 										<view class="icon-used-btn buy" @click="toPayCoupon(coupon)"
 											>¥{{ coupon.moneyCouponPrice }}</view
@@ -322,11 +332,28 @@ export default {
 					this.$util.msg('您的身份暂不支持领取优惠券', 2000)
 					return
 				}
-				this.createCouponRecord(coupon)
+				this.WeChatPayCouponBeans(coupon)
 			} else {
 				this.$api.navigateTo('/pages/login/login')
 			}
 		},
+		WeChatPayCouponBeans(coupon){
+			// 采美豆抵扣优惠券
+			this.PayService.WeChatPayCouponBeans({
+				source: 1, //领取渠道 1 小程序  2 网站
+				userId: this.listQuery.userId,
+				couponId: coupon.couponId
+			})
+			.then(response => {
+				this.$util.msg('抵扣成功', 1500)
+				setTimeout(() => {
+					coupon.couponBtnType = 1
+				}, 1500)
+			})
+			.catch(error => {
+				this.$util.msg(error.msg, 2000)
+			})
+		},
 		toPayCoupon(coupon) {
 			// 点击购买优惠券,友盟埋点收集购买优惠券
 			if (process.env.NODE_ENV != 'development') {

+ 2 - 2
services/config.env.js

@@ -4,8 +4,8 @@ if(process.env.NODE_ENV === 'development'){
     // URL_CONFIG = 'http://192.168.2.67:18002'	 //智捷联调地址
     // URL_CONFIG = 'http://192.168.2.68:18002'	 //涛涛联调地址
     // URL_CONFIG = 'http://192.168.2.75:18002'	 //超超联调地址
-    // URL_CONFIG = 'https://core-b.caimei365.com'
-    URL_CONFIG = 'https://core.caimei365.com'
+    URL_CONFIG = 'https://core-b.caimei365.com'
+    // URL_CONFIG = 'https://core.caimei365.com'
 }else{
     // 生产环境
     // URL_CONFIG = 'https://core-b.caimei365.com'

+ 14 - 0
services/pay.service.js

@@ -103,6 +103,20 @@ export default class PayService {
             isLoading: false ,
         })
     }
+    /**
+	 *采美豆抵扣优惠券
+	 *@param  source  领取渠道 1 小程序  2 网站
+	 *@param  userId  用户Id
+	 *@param  couponId  优惠券Id
+	 */
+    WeChatPayCouponBeans (data = {}) {
+        return this.AjaxService.post({ 
+            url:'/order/pay/coupon/beans', 
+            data, 
+            isLoading: true ,
+            loadText:'请求抵扣中...'  
+        })
+    }
     /**
 	 *生成支付链接
 	 *@param  unpaidAmount 本次待付款金额