提交 9813a822 编写于 作者: guangjun.yang's avatar guangjun.yang

代码整理

上级 d80f67c2
此差异已折叠。
此差异已折叠。
此差异已折叠。
......@@ -179,14 +179,6 @@ export default {
},
deep: true
},
// // 监听当前商品信息
// goodsInfo4Coupon: {
// handler(goodsInfo) {
// this.setSelectCouponList(this.selectCouponList);
// },
// deep: true
// }
},
created() {
......@@ -197,7 +189,6 @@ export default {
this.projectId = this.$route.query.projectId;
this.goodsId = this.$route.query.goodsId || 74;
this.courseUrl = this.$route.query.courseUrl || ""; //
// this.couponIdFromGoodsList = this.$route.query.couponId || ""; //
this.shareUrl = getWebPageUrl(
`profexam/#/goods-detail?goodsId=${this.goodsId}`
);
......@@ -234,7 +225,6 @@ export default {
mounted() {
this.getTabW();
console.log("this.isWeb ... isWechat - 1", this.isWeb, isWechat);
// 数量加减
this.curtGoodsNum = this.goodsNum;
this.countTotalPrice = debounce(this.getTotalPrice, 300);
......@@ -314,21 +304,15 @@ export default {
firstCanCouponIndex = 0,
item = {},
count = 0;
// couponList.sort( (a, b) => {
// return b.discountAmount - a.discountAmount;
// });
for(let i = 0; i < couponList.length; i ++) {
item = couponList[i];
// couponList.forEach(item => {
// 要根据商品价格及券适用类型来计算
// item.disabled = !this.isCanSelect(item, goodsPrice);
item.disabled = !item.enableFlag;
if(!item.disabled) {
count ++;
}
// 是否已经选择
item.isChecked = !!item.checkFlag;
// console.log('firstCanCoupon, item.disabled', firstCanCoupon, item.disabled);
if (!firstCanCoupon && item.isChecked) {
firstCanCoupon = item;
firstCanCouponIndex = i;
......@@ -337,92 +321,11 @@ export default {
}
this.setCurrentCoupon( JSON.parse(JSON.stringify(firstCanCoupon)) || {});
// this.setSelectCouponList(newList.concat(sortArray));
this.setSelectCouponList(newList);
this.goodsInfo4Coupon.count = count;
this.setGoodsInfo4Coupon(this.goodsInfo4Coupon);
},
// 处理数据,并且先排序,再将不可用的放在最后
handlerCouponListOld(couponList, goodsPrice) {
if (!couponList.length) return [];
let newList = [],
obj = {},
firstCanCoupon = null,
firstCanCouponIndex = 0,
item = {},
count = 0;
// couponList.sort( (a, b) => {
// return b.discountAmount - a.discountAmount;
// });
for(let i = 0; i < couponList.length; i ++) {
item = couponList[i];
// couponList.forEach(item => {
// 要根据商品价格及券适用类型来计算
item.disabled = !this.isCanSelect(item, goodsPrice);
if(!item.disabled) {
count ++;
}
// 是否已经选择
item.isChecked = false;
// console.log('firstCanCoupon, item.disabled', firstCanCoupon, item.disabled);
if (!firstCanCoupon && !item.disabled) {
console.log('!firstCanCoupon');
item.isChecked = true;
firstCanCoupon = item;
firstCanCouponIndex = i;
}
newList.push(item);
}
// 如果是从商品列表选择过来的,则要选中这个优惠券
// 如果优惠券不可用
// if(isFromGoodsList) {
// let cCoupon = couponList.find( item => {
// return item.couponId == this.couponId;
// });
// if(cCoupon.isChecked) {
// firstCanCoupon = cCoupon;
// } else {
// firstCanCoupon = {};
// couponList[firstCanCouponIndex].isChecked = false;
// }
// }
// 商品详情接口已经选择了一张, 则使用默认的
if(this.defaultCouponId) {
console.log('in this.defaultCouponId', this.defaultCouponId);
let cCoupon = couponList.find( item => {
return item.couponId == this.defaultCouponId;
});
if(cCoupon && cCoupon.isChecked) {
firstCanCoupon = cCoupon;
} else {
firstCanCoupon = {};
couponList[firstCanCouponIndex].isChecked = false;
}
}
// 将不可用的放在最后
let sortArray = [], c = {};
for(let i = 0; i < newList.length; i ++) {
c = newList[i];
if(c.disabled) {
sortArray.push(c);
newList.splice(i, 1);
i --;
}
}
this.setCurrentCoupon( JSON.parse(JSON.stringify(firstCanCoupon)) || {});
this.setSelectCouponList(newList.concat(sortArray));
this.goodsInfo4Coupon.count = count;
this.setGoodsInfo4Coupon(this.goodsInfo4Coupon);
return newList;
},
// 判断是否可用
isCanSelect(coupon, goodsPrice) {
console.log(
......@@ -546,9 +449,6 @@ export default {
);
}
}
// if (goods.couponDTO) {
// goods.couponAmountText = (goods.couponDTO.discountAmount / 100).toFixed(2);
// }
if (goods.goodsDescWhere) {
tabs.push({ name: "使用范围", detail: goods.goodsDescWhere });
}
......
Markdown 格式
0% or
您添加了 0 到此讨论。请谨慎行事。
先完成此消息的编辑!
想要评论请 注册