|
@@ -254,7 +254,7 @@
|
|
|
</div>
|
|
|
</div>
|
|
|
<!-- vue组件 -->
|
|
|
- <div class="fixed-bottom-box p15" id="coupon-vue">
|
|
|
+ <div class="fixed-bottom-box p15" id="goods-order-vue">
|
|
|
<pay-order-template ref="couponRef" :config="$data" @update="updateS"></pay-order-template>
|
|
|
</div>
|
|
|
<div class="fixed-bottom-box p15" style="display: none;">
|
|
@@ -651,7 +651,8 @@
|
|
|
props: {
|
|
|
defaultSize: {},
|
|
|
areaCount: 1,
|
|
|
- priceInfo: {}
|
|
|
+ priceInfo: {},
|
|
|
+ giftCycle: null
|
|
|
}
|
|
|
}
|
|
|
},
|
|
@@ -682,10 +683,9 @@
|
|
|
var size = JSON.parse(sessionStorage.getItem('vip-cur-select-size'))
|
|
|
if (size) {
|
|
|
this.$refs.goodsSize.goodsActive = size.index
|
|
|
- this.defaultSize = size
|
|
|
+ this.props.defaultSize = size
|
|
|
this.$nextTick(function(){
|
|
|
- console.log(size.price, 'size.price')
|
|
|
- coupon.updatePrice(size.price/100)
|
|
|
+ goodsOrder.updatePrice(size.price/100)
|
|
|
goodsCoupon.updatePrice(size.price/100)
|
|
|
})
|
|
|
} else {
|
|
@@ -695,41 +695,46 @@
|
|
|
},
|
|
|
getGoodSize: function(data) {
|
|
|
console.log(data, '父组件接收子组件传来的商品规格')
|
|
|
- this.defaultSize = data
|
|
|
- coupon.updatePrice(data.price/100)
|
|
|
- goodsCoupon.updatePrice(data.price/100)
|
|
|
+ this.props.defaultSize = data
|
|
|
+ goodsOrder.updatePrice(data.price/100)
|
|
|
+ // 查询有无满赠,无满赠执行回调查优惠券
|
|
|
+ purchase.getGiftList(function(){
|
|
|
+ goodsCoupon.updatePrice(data.price/100)
|
|
|
+ })
|
|
|
}
|
|
|
}
|
|
|
})
|
|
|
- // vip优惠券
|
|
|
+ // 商品优惠券组件
|
|
|
var goodsCoupon = new Vue({
|
|
|
el:'#goods-coupon-vue',
|
|
|
data: function() {
|
|
|
return {
|
|
|
- curSelectCoupon: {}
|
|
|
+ curSelectCoupon: {} // 当前选择的商品优惠券
|
|
|
}
|
|
|
},
|
|
|
mounted () {},
|
|
|
methods: {
|
|
|
+ // 传入价格查询优惠券
|
|
|
updatePrice: function(data){
|
|
|
this.$refs.goodsCoupon.getCoupon(data)
|
|
|
},
|
|
|
+ // 切换优惠券 更新价格
|
|
|
updateCoupon: function(data) {
|
|
|
console.log(data, '更新优惠券选择')
|
|
|
this.curSelectCoupon = data
|
|
|
var curSize = JSON.parse(sessionStorage.getItem('vip-cur-select-size'))
|
|
|
// 更新优惠券选择同时更新订单组件的价格及优惠金额
|
|
|
if (curSize) {
|
|
|
- coupon.updatePrice(curSize.price/100)
|
|
|
+ goodsOrder.updatePrice(curSize.price/100)
|
|
|
} else {
|
|
|
- coupon.updatePrice(coupon.initPrice)
|
|
|
+ goodsOrder.updatePrice(goodsOrder.initPrice)
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
})
|
|
|
- // 订单提交组件
|
|
|
- var coupon = new Vue({
|
|
|
- el: '#coupon-vue',
|
|
|
+ // 商品订单提交组件
|
|
|
+ var goodsOrder = new Vue({
|
|
|
+ el: '#goods-order-vue',
|
|
|
data: function () {
|
|
|
return {
|
|
|
type: 'vip',
|
|
@@ -748,20 +753,27 @@
|
|
|
buttons: {
|
|
|
submit: this.submitOrder
|
|
|
},
|
|
|
- hideCoupon: true //超级订阅购买隐藏订单提交组件的优惠券部分
|
|
|
+ hideCoupon: true, //超级订阅购买隐藏订单提交组件的优惠券部分
|
|
|
+ giftName: '', // 赠品名称
|
|
|
+ giftId: '' // 赠品id
|
|
|
}
|
|
|
},
|
|
|
mounted () {
|
|
|
- this.init()
|
|
|
+ this.init(this.$data)
|
|
|
},
|
|
|
methods: {
|
|
|
// 更新价格相关
|
|
|
updatePrice: function (before) {
|
|
|
console.log( '原价:' + before)
|
|
|
var curCoupon = JSON.parse(sessionStorage.getItem('vip-cur-select-coupon'))
|
|
|
- console.log(curCoupon, '当前选择的优惠券')
|
|
|
+ // 处理优惠金额 主要作用为展示优惠明细弹框立得优惠金额
|
|
|
if (curCoupon) {
|
|
|
- this.$refs.couponRef.coupon.value = curCoupon.reduce
|
|
|
+ if(curCoupon.lotteryAttribute == '折扣券') {
|
|
|
+ // disCount为折扣率 优惠金额 = 原价*优惠了多少比例(100 - disCount)
|
|
|
+ this.$refs.couponRef.coupon.value = Number(before*((100 - curCoupon.disCount)/100)).toFixed(2)
|
|
|
+ } else if (curCoupon.lotteryAttribute == '满减券') {
|
|
|
+ this.$refs.couponRef.coupon.value = curCoupon.reduce
|
|
|
+ }
|
|
|
} else {
|
|
|
this.$refs.couponRef.coupon.value = 0
|
|
|
}
|
|
@@ -772,11 +784,9 @@
|
|
|
}
|
|
|
},
|
|
|
// 初始化及回显相关
|
|
|
- init: function () {
|
|
|
+ init: function (data) {
|
|
|
var areaStorage = sessionStorage.getItem('vipSubSelectArea');
|
|
|
- // var industryStorage = sessionStorage.getItem('vipSubSelectIndustry');
|
|
|
var readStorage = sessionStorage.getItem('vipSub_read') == 'true' ? true : false;
|
|
|
- // console.log(areaStorage, industryStorage, readStorage)
|
|
|
if(readStorage) {
|
|
|
this.checkboxStatus = true
|
|
|
}
|
|
@@ -794,7 +804,6 @@
|
|
|
checkSubmitStatus: function (checkStatus) {
|
|
|
$('#buy').prop('checked', checkStatus)
|
|
|
var areaStorage = sessionStorage.getItem('vipSubSelectArea');
|
|
|
- // var industryStorage = sessionStorage.getItem('vipSubSelectIndustry');
|
|
|
var readStorage = sessionStorage.getItem('vipSub_read');
|
|
|
return areaStorage && readStorage && OrderPhoneCheck.status
|
|
|
},
|
|
@@ -889,7 +898,7 @@
|
|
|
if (sessionStorage.getItem("vipSub_read") === "true") $("#buy").prop("checked", true);
|
|
|
//是否试用界面
|
|
|
if (sessionStorage.getItem("vipSubisTrial")) this.vipSubisTrial = true;
|
|
|
-
|
|
|
+ var _this = this
|
|
|
//加载价格
|
|
|
$DoPost("/subscribepay/vipsubscribe/getPrice", {}, function (r) {
|
|
|
if (r) {
|
|
@@ -900,7 +909,7 @@
|
|
|
// showGiveStatus(false)
|
|
|
// }
|
|
|
Calculation.Init(false, undefined, [], 0)
|
|
|
- // 将价格列表传至商品规格组件
|
|
|
+ // 将价格信息传递给商品规格组件 用户渲染商品规格
|
|
|
goodsSize.props.priceInfo = r.new
|
|
|
}
|
|
|
}, false)
|
|
@@ -1035,11 +1044,73 @@
|
|
|
var size = JSON.parse(sessionStorage.getItem('vip-cur-select-size'))
|
|
|
// 首次进入没有选择商品规格 默认
|
|
|
if (!size) {
|
|
|
- coupon.updatePrice(price)
|
|
|
- goodsCoupon.updatePrice(price)
|
|
|
+ goodsOrder.updatePrice(price) // 更新提交订单组件价格
|
|
|
+ purchase.getGiftList(function(){
|
|
|
+ goodsCoupon.updatePrice(price) // 更新商品优惠券价格(查询优惠券)
|
|
|
+ })
|
|
|
+ } else {
|
|
|
+ purchase.getGiftList(function(){
|
|
|
+ goodsCoupon.updatePrice(size.price) // 更新商品优惠券价格(查询优惠券)
|
|
|
+ })
|
|
|
}
|
|
|
}
|
|
|
- }
|
|
|
+ },
|
|
|
+ // 获取当前选择的商品有无满赠活动
|
|
|
+ getGiftList: function(callback) {
|
|
|
+ var size = JSON.parse(sessionStorage.getItem('vip-cur-select-size')) || {}
|
|
|
+ console.log(size)
|
|
|
+ if (!size || Object.keys(size).length == 0) {
|
|
|
+ size.period = '1年'
|
|
|
+ }
|
|
|
+ var pId;
|
|
|
+ var _this = this
|
|
|
+ switch (size.period) {
|
|
|
+ case '1月':
|
|
|
+ pId = 1012
|
|
|
+ break;
|
|
|
+ case '1季':
|
|
|
+ pId = 1013
|
|
|
+ break;
|
|
|
+ case '1年':
|
|
|
+ pId = 1014
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ goodsSize.props.giftCycle = null // 下次请求前将满赠周期清掉 请求成功后再赋值
|
|
|
+ // 先查有没有满赠
|
|
|
+ $.ajax({
|
|
|
+ type:'POST',
|
|
|
+ url:'/jyCoupon/giveInfo',
|
|
|
+ data:{
|
|
|
+ useProduct: pId,
|
|
|
+ useProductType: 0 // 商品类型 0普通的 1线上课程(除线上课程以外的都是0)
|
|
|
+ },
|
|
|
+ success:function(res) {
|
|
|
+ if(res.data && res.data.length > 0) {
|
|
|
+ res.data.forEach(function(item) {
|
|
|
+ // 处理展示文字(天、月、年)
|
|
|
+ if(item.timeType == 1) {
|
|
|
+ item.time = item.time + '天'
|
|
|
+ } else if (item.timeType == 2 && item.time < 12) {
|
|
|
+ item.time = item.time + '个月'
|
|
|
+ } else if (item.timeType == 2 && item.time == 12) {
|
|
|
+ item.time = '1年'
|
|
|
+ }
|
|
|
+ // 将赠品信息传递给商品订单提交子组件
|
|
|
+ goodsOrder.giftName = item.name // 满赠商品名称
|
|
|
+ goodsOrder.giftId = item.discountId // 满赠id
|
|
|
+ goodsSize.props.defaultSize.time = item.time
|
|
|
+ goodsSize.props.giftCycle = item.time
|
|
|
+ })
|
|
|
+ } else {
|
|
|
+ // 没有满赠活动再执行其他回调(优惠券)
|
|
|
+ callback && callback()
|
|
|
+ }
|
|
|
+ },
|
|
|
+ error:function(err) {
|
|
|
+ console.log(err)
|
|
|
+ }
|
|
|
+ })
|
|
|
+ },
|
|
|
};
|
|
|
|
|
|
|
|
@@ -1258,7 +1329,19 @@
|
|
|
activeCodes = couponInfo.code;
|
|
|
}
|
|
|
var size = goodsSize.defaultSize
|
|
|
+ var pId;
|
|
|
if (size && size.period) {
|
|
|
+ switch (size.period) {
|
|
|
+ case '1月':
|
|
|
+ pId = 1012
|
|
|
+ break;
|
|
|
+ case '1季':
|
|
|
+ pId = 1013
|
|
|
+ break;
|
|
|
+ case '1年':
|
|
|
+ pId = 1014
|
|
|
+ break;
|
|
|
+ }
|
|
|
if(size.period.indexOf('月') > -1) {
|
|
|
size.period = size.period.replace('月', '个月')
|
|
|
}
|
|
@@ -1266,14 +1349,15 @@
|
|
|
} else {
|
|
|
sizeTime = '1年'
|
|
|
}
|
|
|
- console.log(sizeTime, '选择的周期')
|
|
|
var param = {
|
|
|
"userLotteryId":goodsCoupon.curSelectCoupon.userLotteryId,
|
|
|
"lotteryId": goodsCoupon.curSelectCoupon.lotteryId,
|
|
|
"area": JSON.stringify(area),
|
|
|
// "industry": industry.join(","),
|
|
|
"time": sizeTime,
|
|
|
- "price": Number((coupon.initPrice*100).toFixed(2)),
|
|
|
+ "discountId": goodsOrder.giftId, // 满赠id
|
|
|
+ "useProduct": pId, // 商品类型
|
|
|
+ "price": parseInt(goodsOrder.initPrice*10000/100),
|
|
|
"orderType":{{.T.orderType}},
|
|
|
"activeCode": activeCodes,
|
|
|
"disWord": getParam("disWord")//分销系统
|