|
@@ -24,6 +24,7 @@
|
|
:showStatus="false"
|
|
:showStatus="false"
|
|
:couponList="receiveCouponList"
|
|
:couponList="receiveCouponList"
|
|
@chooseCoupon="chooseCoupon"
|
|
@chooseCoupon="chooseCoupon"
|
|
|
|
+ @confirm="closeCouponList"
|
|
:currentId="currentCouponId"
|
|
:currentId="currentCouponId"
|
|
></cm-coupon-list>
|
|
></cm-coupon-list>
|
|
<!-- 运费 -->
|
|
<!-- 运费 -->
|
|
@@ -37,7 +38,9 @@
|
|
<view class="footer-price">
|
|
<view class="footer-price">
|
|
<view class="sum" :class="totalFullReduction == 0 ? 'none' : ''">
|
|
<view class="sum" :class="totalFullReduction == 0 ? 'none' : ''">
|
|
<view class="price">总价:¥{{ payAllPrice | NumFormat }}</view>
|
|
<view class="price">总价:¥{{ payAllPrice | NumFormat }}</view>
|
|
- <view class="discount" v-if="discountedPrice > 0">共减 ¥{{ discountedPrice | NumFormat }}</view>
|
|
|
|
|
|
+ <view class="discount" v-if="discountedPrice > 0"
|
|
|
|
+ >共减 ¥{{ discountedPrice | NumFormat }}</view
|
|
|
|
+ >
|
|
</view>
|
|
</view>
|
|
</view>
|
|
</view>
|
|
</view>
|
|
</view>
|
|
@@ -84,7 +87,7 @@ export default {
|
|
addressData: {}, //初始化地址信息
|
|
addressData: {}, //初始化地址信息
|
|
goodsData: [], //初始化商品信息
|
|
goodsData: [], //初始化商品信息
|
|
freightData: {}, //邮费数据
|
|
freightData: {}, //邮费数据
|
|
- productsList: [],
|
|
|
|
|
|
+ productList: [],
|
|
params: {
|
|
params: {
|
|
userId: 0
|
|
userId: 0
|
|
},
|
|
},
|
|
@@ -101,7 +104,9 @@ export default {
|
|
receiveCouponList: [],
|
|
receiveCouponList: [],
|
|
currentCouponId: -1,
|
|
currentCouponId: -1,
|
|
currentCoupon: null,
|
|
currentCoupon: null,
|
|
- loadingText: '正在创建订单'
|
|
|
|
|
|
+ loadingText: '正在创建订单',
|
|
|
|
+ canUseCouponList:[],
|
|
|
|
+ notUseCouponList:[],
|
|
}
|
|
}
|
|
},
|
|
},
|
|
onLoad(option) {
|
|
onLoad(option) {
|
|
@@ -136,13 +141,13 @@ export default {
|
|
// 支付金额
|
|
// 支付金额
|
|
payAllPrice() {
|
|
payAllPrice() {
|
|
const payAllPrice = this.allPrice - this.couponAmount
|
|
const payAllPrice = this.allPrice - this.couponAmount
|
|
- return payAllPrice < 0 ? 0 : payAllPrice
|
|
|
|
|
|
+ return payAllPrice < 0 ? 0 : payAllPrice
|
|
},
|
|
},
|
|
hanldOrder() {
|
|
hanldOrder() {
|
|
return {
|
|
return {
|
|
order: this.orderInfo
|
|
order: this.orderInfo
|
|
}
|
|
}
|
|
- }
|
|
|
|
|
|
+ },
|
|
},
|
|
},
|
|
filters: {
|
|
filters: {
|
|
NumFormat(value) {
|
|
NumFormat(value) {
|
|
@@ -151,9 +156,6 @@ export default {
|
|
}
|
|
}
|
|
},
|
|
},
|
|
methods: {
|
|
methods: {
|
|
- closeCouponList() {
|
|
|
|
- this.couponVisible = false
|
|
|
|
- },
|
|
|
|
// 获取可用优惠券
|
|
// 获取可用优惠券
|
|
fetchCouponList() {
|
|
fetchCouponList() {
|
|
this.CouponService.GetCouponByProductIds({ userId: this.userId, productIds: this.productIds }).then(res => {
|
|
this.CouponService.GetCouponByProductIds({ userId: this.userId, productIds: this.productIds }).then(res => {
|
|
@@ -163,33 +165,51 @@ export default {
|
|
},
|
|
},
|
|
// 对优惠券进行分类排序
|
|
// 对优惠券进行分类排序
|
|
filterCouponList() {
|
|
filterCouponList() {
|
|
- const productList = []
|
|
|
|
- this.goodsData.forEach(shop => productList.push(...shop.productList.map(prod => prod)))
|
|
|
|
- let canUseCouponList = [] // 可以使用的优惠券
|
|
|
|
- let notUseCouponList = [] // 需要凑单使用的优惠券
|
|
|
|
|
|
+ this.goodsData.forEach(shop => this.productList.push(...shop.productList.map(prod => prod)))
|
|
|
|
+ this.canUseCouponList = [] // 可以使用的优惠券
|
|
|
|
+ this.notUseCouponList = [] // 需要凑单使用的优惠券
|
|
this.receiveCouponList.forEach(coupon => {
|
|
this.receiveCouponList.forEach(coupon => {
|
|
if (
|
|
if (
|
|
coupon.noThresholdFlag === 1 ||
|
|
coupon.noThresholdFlag === 1 ||
|
|
- (coupon.productType === 1 && allProdoceUseCheck(productList, coupon)) ||
|
|
|
|
- (coupon.productType === 2 && someProductUseCheck(productList, coupon))
|
|
|
|
|
|
+ (coupon.productType === 1 && allProdoceUseCheck(this.productList, coupon)) ||
|
|
|
|
+ (coupon.productType === 2 && someProductUseCheck(this.productList, coupon))
|
|
) {
|
|
) {
|
|
coupon.canSelect = true
|
|
coupon.canSelect = true
|
|
- canUseCouponList.push(coupon)
|
|
|
|
|
|
+ this.canUseCouponList.push(coupon)
|
|
} else {
|
|
} else {
|
|
coupon.canSelect = false
|
|
coupon.canSelect = false
|
|
- notUseCouponList.push(coupon)
|
|
|
|
|
|
+ this.notUseCouponList.push(coupon)
|
|
}
|
|
}
|
|
})
|
|
})
|
|
// 金额高的排前面
|
|
// 金额高的排前面
|
|
- this.receiveCouponList = [...couponSort(canUseCouponList), ...couponSort(notUseCouponList)]
|
|
|
|
|
|
+ this.receiveCouponList = [...couponSort(this.canUseCouponList), ...couponSort(this.notUseCouponList)]
|
|
// 当有可用优惠券时 默认选取第一个最优惠的
|
|
// 当有可用优惠券时 默认选取第一个最优惠的
|
|
- if (this.receiveCouponList.length > 0) {
|
|
|
|
|
|
+ if (this.canUseCouponList.length > 0) {
|
|
this.currentCouponId = this.receiveCouponList[0].couponId
|
|
this.currentCouponId = this.receiveCouponList[0].couponId
|
|
this.currentCoupon = this.receiveCouponList[0]
|
|
this.currentCoupon = this.receiveCouponList[0]
|
|
}
|
|
}
|
|
// 显示界面
|
|
// 显示界面
|
|
this.isRequest = false
|
|
this.isRequest = false
|
|
},
|
|
},
|
|
|
|
+ // 处理优惠券列表
|
|
|
|
+ resetCouponList(){
|
|
|
|
+ // 2将当前选中的优惠券从列表中删除
|
|
|
|
+ // 3将当前选中的优惠券放入最前面
|
|
|
|
+ // 4返回最新的优惠券列表
|
|
|
|
+ // 查找选中优惠券的索引
|
|
|
|
+ const index = this.canUseCouponList.findIndex(coupon=>coupon.couponId === this.currentCouponId)
|
|
|
|
+ // 从列表中删除
|
|
|
|
+ const currentCoupon = this.canUseCouponList.splice(index, 1)
|
|
|
|
+ // 重新排序 将选中的优惠券放到最前面
|
|
|
|
+ this.canUseCouponList = [...currentCoupon, ...couponSort(this.canUseCouponList)]
|
|
|
|
+ // 重新生成receiveCouponList
|
|
|
|
+ this.receiveCouponList = [...this.canUseCouponList, ...this.notUseCouponList]
|
|
|
|
+ },
|
|
|
|
+ // 确认选中
|
|
|
|
+ closeCouponList(){
|
|
|
|
+ this.couponVisible = false
|
|
|
|
+ this.resetCouponList()
|
|
|
|
+ },
|
|
// 选中优惠券
|
|
// 选中优惠券
|
|
chooseCoupon(coupon) {
|
|
chooseCoupon(coupon) {
|
|
if (coupon.couponId > -1) {
|
|
if (coupon.couponId > -1) {
|
|
@@ -199,7 +219,7 @@ export default {
|
|
this.currentCoupon = null
|
|
this.currentCoupon = null
|
|
this.currentCouponId = -1
|
|
this.currentCouponId = -1
|
|
}
|
|
}
|
|
- this.couponVisible = false
|
|
|
|
|
|
+ // this.couponVisible = false
|
|
},
|
|
},
|
|
//确认订单初始化信息
|
|
//确认订单初始化信息
|
|
getInitCrearOrder(params) {
|
|
getInitCrearOrder(params) {
|
|
@@ -208,6 +228,7 @@ export default {
|
|
let data = response.data
|
|
let data = response.data
|
|
this.goodsData = data.shopList
|
|
this.goodsData = data.shopList
|
|
this.allPrice = data.totalPrice
|
|
this.allPrice = data.totalPrice
|
|
|
|
+
|
|
this.fetchCouponList()
|
|
this.fetchCouponList()
|
|
})
|
|
})
|
|
.catch(error => {
|
|
.catch(error => {
|
|
@@ -235,8 +256,6 @@ export default {
|
|
orderSubmitMit() {
|
|
orderSubmitMit() {
|
|
//提交订单
|
|
//提交订单
|
|
if (this.isSubLoading) return
|
|
if (this.isSubLoading) return
|
|
- this.isSubLoading = true
|
|
|
|
- this.loadingText = '正在创建订单...'
|
|
|
|
if (this.subParams.addressId == '') return this.$util.msg('请先添加收货地址~', 2000)
|
|
if (this.subParams.addressId == '') return this.$util.msg('请先添加收货地址~', 2000)
|
|
// 选中的优惠券id
|
|
// 选中的优惠券id
|
|
this.subParams.couponId = this.currentCouponId === -1 ? '' : this.currentCouponId
|
|
this.subParams.couponId = this.currentCouponId === -1 ? '' : this.currentCouponId
|
|
@@ -253,6 +272,8 @@ export default {
|
|
})
|
|
})
|
|
return { shopId: el.shopId, note: el.note ? el.note : '', productInfo: productInfo }
|
|
return { shopId: el.shopId, note: el.note ? el.note : '', productInfo: productInfo }
|
|
})
|
|
})
|
|
|
|
+ this.isSubLoading = true
|
|
|
|
+ this.loadingText = '正在创建订单...'
|
|
this.OrderService.CreatedOrderSubmit(this.subParams)
|
|
this.OrderService.CreatedOrderSubmit(this.subParams)
|
|
.then(response => {
|
|
.then(response => {
|
|
const data = response.data
|
|
const data = response.data
|
|
@@ -260,6 +281,7 @@ export default {
|
|
this.miniWxPayFor(data)
|
|
this.miniWxPayFor(data)
|
|
})
|
|
})
|
|
.catch(error => {
|
|
.catch(error => {
|
|
|
|
+ this.isSubLoading = false
|
|
this.$util.msg(error.msg, 2000)
|
|
this.$util.msg(error.msg, 2000)
|
|
this.isSubLoading = false
|
|
this.isSubLoading = false
|
|
})
|
|
})
|
|
@@ -407,7 +429,7 @@ page {
|
|
width: 100%;
|
|
width: 100%;
|
|
line-height: 58rpx;
|
|
line-height: 58rpx;
|
|
font-size: $font-size-24;
|
|
font-size: $font-size-24;
|
|
- color: #ff2a2a;
|
|
|
|
|
|
+ color: #ff457b;
|
|
text-align: right;
|
|
text-align: right;
|
|
float: right;
|
|
float: right;
|
|
}
|
|
}
|