|
@@ -10,14 +10,25 @@
|
|
@handleGoodList="handChangeInputGoodsList"
|
|
@handleGoodList="handChangeInputGoodsList"
|
|
></goodsList>
|
|
></goodsList>
|
|
<!-- 选择优惠券 TODO-->
|
|
<!-- 选择优惠券 TODO-->
|
|
- <view class="select-coupon" @click="couponVisible = true">
|
|
|
|
|
|
+ <view class="select-coupon" @click="couponVisible = true" v-if="receiveCouponList.length > 0">
|
|
<view class="left-title">优惠券</view>
|
|
<view class="left-title">优惠券</view>
|
|
<view class="right-content">
|
|
<view class="right-content">
|
|
- <view class="coupon-amount">-¥20.00</view> <view class="iconfont icon-chakangengduo"></view>
|
|
|
|
|
|
+ <view class="coupon-amount">-¥{{ couponAmount | NumFormat }}</view>
|
|
|
|
+ <view class="iconfont icon-chakangengduo"></view>
|
|
</view>
|
|
</view>
|
|
</view>
|
|
</view>
|
|
<!-- 优惠券列表 TODO-->
|
|
<!-- 优惠券列表 TODO-->
|
|
- <cm-coupon-list title="优惠券" listType="use" :visible="couponVisible" @close="closeCouponList"></cm-coupon-list>
|
|
|
|
|
|
+ <cm-coupon-list
|
|
|
|
+ title="优惠券"
|
|
|
|
+ listType="use"
|
|
|
|
+ :visible="couponVisible"
|
|
|
|
+ @close="closeCouponList"
|
|
|
|
+ :chooseAble="true"
|
|
|
|
+ :showStatus="false"
|
|
|
|
+ :couponList="receiveCouponList"
|
|
|
|
+ @chooseCoupon="chooseCoupon"
|
|
|
|
+ :currentId="currentCouponId"
|
|
|
|
+ ></cm-coupon-list>
|
|
<!-- 运费 -->
|
|
<!-- 运费 -->
|
|
<seller-freight ref="freight" v-if="isRequest" :freightDatas="freightData"> </seller-freight>
|
|
<seller-freight ref="freight" v-if="isRequest" :freightDatas="freightData"> </seller-freight>
|
|
<!-- 底部 -->
|
|
<!-- 底部 -->
|
|
@@ -27,9 +38,10 @@
|
|
<text>共{{ allCount }}件商品</text>
|
|
<text>共{{ allCount }}件商品</text>
|
|
</view>
|
|
</view>
|
|
<view class="footer-price">
|
|
<view class="footer-price">
|
|
- <view class="sum" :class="totalFullReduction == 0 ? 'none' : ''"
|
|
|
|
- >总价:<text class="price">¥{{ payAllPrice | NumFormat }}</text></view
|
|
|
|
- >
|
|
|
|
|
|
+ <view class="sum" :class="totalFullReduction == 0 ? 'none' : ''">
|
|
|
|
+ <view class="price">总价:¥{{ payAllPrice | NumFormat }}</view>
|
|
|
|
+ <view class="discount">共减 ¥{{ discountedPrice | NumFormat }}</view>
|
|
|
|
+ </view>
|
|
</view>
|
|
</view>
|
|
</view>
|
|
</view>
|
|
<view class="footer-submit" @click.stop="orderSubmitMit">
|
|
<view class="footer-submit" @click.stop="orderSubmitMit">
|
|
@@ -45,6 +57,7 @@ import choiceAddress from '@/components/cm-module/createOrder/address'
|
|
import goodsList from '@/components/cm-module/createOrder/goodsList'
|
|
import goodsList from '@/components/cm-module/createOrder/goodsList'
|
|
import sellerFreight from '@/components/cm-module/createOrder/sellerFreight'
|
|
import sellerFreight from '@/components/cm-module/createOrder/sellerFreight'
|
|
import CmCouponList from '@/components/cm-module/cm-coupon-list/cm-coupon-list'
|
|
import CmCouponList from '@/components/cm-module/cm-coupon-list/cm-coupon-list'
|
|
|
|
+import { mapGetters } from 'vuex'
|
|
export default {
|
|
export default {
|
|
components: {
|
|
components: {
|
|
choiceAddress,
|
|
choiceAddress,
|
|
@@ -61,7 +74,6 @@ export default {
|
|
allCount: 1, //订单提交总数量
|
|
allCount: 1, //订单提交总数量
|
|
totalOriginalPrice: 0, //订单总原价(划线部分)
|
|
totalOriginalPrice: 0, //订单总原价(划线部分)
|
|
totalFullReduction: 0, //满减金额
|
|
totalFullReduction: 0, //满减金额
|
|
- payAllPrice: 0.0, //订单提交总金额
|
|
|
|
allPrice: 0.0, //订单总金额
|
|
allPrice: 0.0, //订单总金额
|
|
townId: '', //区ID
|
|
townId: '', //区ID
|
|
isRequest: false, //是否加载完成渲染子组件
|
|
isRequest: false, //是否加载完成渲染子组件
|
|
@@ -85,27 +97,45 @@ export default {
|
|
orderShouldPayFee: 0
|
|
orderShouldPayFee: 0
|
|
}
|
|
}
|
|
},
|
|
},
|
|
- orderInfo: ''
|
|
|
|
|
|
+ orderInfo: '',
|
|
|
|
+ receiveCouponList: [],
|
|
|
|
+ currentCouponId: -1,
|
|
|
|
+ currentCoupon: null
|
|
}
|
|
}
|
|
},
|
|
},
|
|
onLoad(option) {
|
|
onLoad(option) {
|
|
//商品数据
|
|
//商品数据
|
|
let data = JSON.parse(option.data)
|
|
let data = JSON.parse(option.data)
|
|
this.allCount = data.data.allCount
|
|
this.allCount = data.data.allCount
|
|
- console.log(data)
|
|
|
|
if (option.type == 'prodcut') {
|
|
if (option.type == 'prodcut') {
|
|
this.subParams.cartType = 2
|
|
this.subParams.cartType = 2
|
|
this.params.productCount = data.data.productCount
|
|
this.params.productCount = data.data.productCount
|
|
this.params.productId = data.data.productId
|
|
this.params.productId = data.data.productId
|
|
this.params.heUserId = data.data.heUserId ? data.data.heUserId : 0
|
|
this.params.heUserId = data.data.heUserId ? data.data.heUserId : 0
|
|
|
|
+ this.productIds = data.data.productId.toString()
|
|
} else {
|
|
} else {
|
|
this.subParams.cartType = 1
|
|
this.subParams.cartType = 1
|
|
this.params.cartIds = data.data.cartIds
|
|
this.params.cartIds = data.data.cartIds
|
|
|
|
+ this.productIds = data.data.productIds
|
|
|
|
+ }
|
|
|
|
+ this.params.userId = this.userId
|
|
|
|
+ this.subParams.userId = this.userId
|
|
|
|
+ this.getInitCrearOrder(this.params)
|
|
|
|
+ },
|
|
|
|
+ computed: {
|
|
|
|
+ ...mapGetters(['userId']),
|
|
|
|
+ // 选中的优惠券的金额
|
|
|
|
+ couponAmount() {
|
|
|
|
+ return this.currentCoupon ? this.currentCoupon.couponAmount : 0
|
|
|
|
+ },
|
|
|
|
+ // 优惠价格
|
|
|
|
+ discountedPrice() {
|
|
|
|
+ return this.couponAmount
|
|
|
|
+ },
|
|
|
|
+ // 支付金额
|
|
|
|
+ payAllPrice() {
|
|
|
|
+ return this.allPrice - this.couponAmount
|
|
}
|
|
}
|
|
- this.$api.getStorage().then(resolve => {
|
|
|
|
- this.params.userId = this.subParams.userId = resolve.userId ? resolve.userId : 0
|
|
|
|
- this.getInitCrearOrder(this.params)
|
|
|
|
- })
|
|
|
|
},
|
|
},
|
|
filters: {
|
|
filters: {
|
|
NumFormat(value) {
|
|
NumFormat(value) {
|
|
@@ -114,44 +144,96 @@ export default {
|
|
}
|
|
}
|
|
},
|
|
},
|
|
methods: {
|
|
methods: {
|
|
- closeCouponList(){
|
|
|
|
|
|
+ closeCouponList() {
|
|
|
|
+ this.couponVisible = false
|
|
|
|
+ },
|
|
|
|
+ // 获取可用优惠券
|
|
|
|
+ fetchCouponList() {
|
|
|
|
+ this.CouponService.GetCouponByProductIds({ userId: this.userId, productIds: this.productIds }).then(res => {
|
|
|
|
+ this.receiveCouponList = res.data.receiveCouponList
|
|
|
|
+ this.filterCouponList()
|
|
|
|
+ })
|
|
|
|
+ },
|
|
|
|
+ // 对优惠券进行分类排序
|
|
|
|
+ filterCouponList() {
|
|
|
|
+ const productList = []
|
|
|
|
+ this.goodsData.forEach(shop => productList.push(...shop.productList.map(prod => prod)))
|
|
|
|
+ let canUseCouponList = []
|
|
|
|
+ let notUseCouponList = []
|
|
|
|
+ this.list = this.receiveCouponList.forEach(coupon => {
|
|
|
|
+ if (
|
|
|
|
+ coupon.noThresholdFlag === 1 ||
|
|
|
|
+ (coupon.productType === 1 && this.allProdoceUseCheck(productList, coupon)) ||
|
|
|
|
+ (coupon.productType === 2 && this.someProductUseCheck(productList, coupon))
|
|
|
|
+ ) {
|
|
|
|
+ coupon.canSelect = true
|
|
|
|
+ canUseCouponList.push(coupon)
|
|
|
|
+ } else {
|
|
|
|
+ coupon.canSelect = false
|
|
|
|
+ notUseCouponList.push(coupon)
|
|
|
|
+ }
|
|
|
|
+ })
|
|
|
|
+ // 金额高的拍前面
|
|
|
|
+ canUseCouponList = canUseCouponList.sort((a, b) => b.couponAmount - a.couponAmount)
|
|
|
|
+ notUseCouponList = notUseCouponList.sort((a, b) => b.couponAmount - a.couponAmount)
|
|
|
|
+ this.receiveCouponList = [...canUseCouponList, ...notUseCouponList]
|
|
|
|
+ // 当有可用优惠券时 默认选取第一个最优惠的
|
|
|
|
+ if (this.receiveCouponList.length > 0) {
|
|
|
|
+ this.currentCouponId = this.receiveCouponList[0].couponId
|
|
|
|
+ this.currentCoupon = this.receiveCouponList[0]
|
|
|
|
+ }
|
|
|
|
+ },
|
|
|
|
+ // 判断全部商品可用 是否可勾选使用
|
|
|
|
+ allProdoceUseCheck(productList, coupon) {
|
|
|
|
+ return productList.some(prod => prod.price * prod.productCount >= coupon.couponAmount)
|
|
|
|
+ },
|
|
|
|
+ // 判断指定商品可用 是否可勾选使用
|
|
|
|
+ someProductUseCheck(productList, coupon) {
|
|
|
|
+ return productList.some(
|
|
|
|
+ prod =>
|
|
|
|
+ coupon.productIds.indexOf(prod.productId.toString()) > -1 &&
|
|
|
|
+ prod.price * prod.productCount >= coupon.couponAmount
|
|
|
|
+ )
|
|
|
|
+ },
|
|
|
|
+ // 选中优惠券
|
|
|
|
+ chooseCoupon(coupon) {
|
|
|
|
+ if (coupon.couponId > -1) {
|
|
|
|
+ this.currentCoupon = coupon
|
|
|
|
+ this.currentCouponId = coupon.couponId
|
|
|
|
+ } else {
|
|
|
|
+ this.currentCoupon = null
|
|
|
|
+ this.currentCouponId = -1
|
|
|
|
+ }
|
|
this.couponVisible = false
|
|
this.couponVisible = false
|
|
|
|
+ console.log(coupon)
|
|
},
|
|
},
|
|
|
|
+ //确认订单初始化信息
|
|
getInitCrearOrder(params) {
|
|
getInitCrearOrder(params) {
|
|
- //确认订单初始化信息
|
|
|
|
this.OrderService.QueryOrderConfirm(params)
|
|
this.OrderService.QueryOrderConfirm(params)
|
|
.then(response => {
|
|
.then(response => {
|
|
let data = response.data
|
|
let data = response.data
|
|
- let productIds = []
|
|
|
|
this.isRequest = true
|
|
this.isRequest = true
|
|
this.goodsData = data.shopList
|
|
this.goodsData = data.shopList
|
|
- console.log(this.goodsData)
|
|
|
|
- // this.totalFullReduction = data.totalFullReduction
|
|
|
|
- // this.totalOriginalPrice = data.totalFullReduction + data.totalPrice
|
|
|
|
- this.allPrice = this.payAllPrice = data.totalPrice
|
|
|
|
- this.subParams.payInfo.orderShouldPayFee = this.payAllPrice.toFixed(2)
|
|
|
|
- console.log('this.subParams.payInfo.orderShouldPayFee', this.subParams.payInfo.orderShouldPayFee)
|
|
|
|
|
|
+ this.allPrice = data.totalPrice
|
|
|
|
+
|
|
|
|
+ this.fetchCouponList()
|
|
})
|
|
})
|
|
.catch(error => {
|
|
.catch(error => {
|
|
this.$util.msg(error.msg, 2000)
|
|
this.$util.msg(error.msg, 2000)
|
|
})
|
|
})
|
|
},
|
|
},
|
|
|
|
+ //获取地址信息
|
|
getAddressData() {
|
|
getAddressData() {
|
|
- //获取地址信息
|
|
|
|
- this.$api.getStorage().then(resolve => {
|
|
|
|
- this.UserService.QueryAddressList({ pageNum: 1, pageSize: 1, userId: resolve.userId }).then(
|
|
|
|
- response => {
|
|
|
|
- this.isAddress = true
|
|
|
|
- this.addressData = {}
|
|
|
|
- if (response.data.list != '') {
|
|
|
|
- this.subParams.addressId = response.data.list[0].addressId
|
|
|
|
- this.townId = response.data.list[0].townId
|
|
|
|
- this.addressData = response.data.list[0]
|
|
|
|
- } else {
|
|
|
|
- this.addressData = this.addressData
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
- )
|
|
|
|
|
|
+ this.UserService.QueryAddressList({ pageNum: 1, pageSize: 1, userId: this.userId }).then(response => {
|
|
|
|
+ this.isAddress = true
|
|
|
|
+ this.addressData = {}
|
|
|
|
+ if (response.data.list != '') {
|
|
|
|
+ this.subParams.addressId = response.data.list[0].addressId
|
|
|
|
+ this.townId = response.data.list[0].townId
|
|
|
|
+ this.addressData = response.data.list[0]
|
|
|
|
+ } else {
|
|
|
|
+ this.addressData = this.addressData
|
|
|
|
+ }
|
|
})
|
|
})
|
|
},
|
|
},
|
|
handChangeInputGoodsList(data) {
|
|
handChangeInputGoodsList(data) {
|
|
@@ -160,13 +242,11 @@ export default {
|
|
},
|
|
},
|
|
orderSubmitMit() {
|
|
orderSubmitMit() {
|
|
//提交订单
|
|
//提交订单
|
|
- if (this.isSubLoading) {
|
|
|
|
- return
|
|
|
|
- }
|
|
|
|
- if (this.subParams.addressId == '') {
|
|
|
|
- this.$util.msg('请先添加收货地址~', 2000)
|
|
|
|
- return
|
|
|
|
- }
|
|
|
|
|
|
+ if (this.isSubLoading) return
|
|
|
|
+ if (this.subParams.addressId == '') return this.$util.msg('请先添加收货地址~', 2000)
|
|
|
|
+ // 选中的优惠券id
|
|
|
|
+ this.subParams.couponId = this.currentCouponId === -1 ? '' : this.currentCouponId
|
|
|
|
+ this.subParams.payInfo.orderShouldPayFee = this.payAllPrice
|
|
// 处理商品信息及留言
|
|
// 处理商品信息及留言
|
|
this.subParams.orderInfo = this.goodsData.map(el => {
|
|
this.subParams.orderInfo = this.goodsData.map(el => {
|
|
let productInfo = []
|
|
let productInfo = []
|
|
@@ -179,7 +259,7 @@ export default {
|
|
})
|
|
})
|
|
return { shopId: el.shopId, note: el.note ? el.note : '', productInfo: productInfo }
|
|
return { shopId: el.shopId, note: el.note ? el.note : '', productInfo: productInfo }
|
|
})
|
|
})
|
|
- console.log(this.subParams)
|
|
|
|
|
|
+ debugger
|
|
this.isSubLoading = true
|
|
this.isSubLoading = true
|
|
this.OrderService.CreatedOrderSubmit(this.subParams)
|
|
this.OrderService.CreatedOrderSubmit(this.subParams)
|
|
.then(response => {
|
|
.then(response => {
|
|
@@ -231,8 +311,6 @@ export default {
|
|
wx.reLaunch({ url: '/pages/tabBar/index/index' })
|
|
wx.reLaunch({ url: '/pages/tabBar/index/index' })
|
|
},
|
|
},
|
|
fail: function(res) {
|
|
fail: function(res) {
|
|
- console.log(res)
|
|
|
|
- console.log('ORDERID', self.orderInfo)
|
|
|
|
self.$api.redirectTo(`/pages/user/order/success?data=${JSON.stringify({ data: self.orderInfo })}`)
|
|
self.$api.redirectTo(`/pages/user/order/success?data=${JSON.stringify({ data: self.orderInfo })}`)
|
|
},
|
|
},
|
|
complete: function(res) {}
|
|
complete: function(res) {}
|
|
@@ -259,6 +337,9 @@ page {
|
|
height: auto;
|
|
height: auto;
|
|
background: #f7f7f7;
|
|
background: #f7f7f7;
|
|
}
|
|
}
|
|
|
|
+.container {
|
|
|
|
+ height: initial;
|
|
|
|
+}
|
|
.btn-hover {
|
|
.btn-hover {
|
|
background: #ffffff;
|
|
background: #ffffff;
|
|
}
|
|
}
|
|
@@ -398,12 +479,12 @@ page {
|
|
align-items: center;
|
|
align-items: center;
|
|
width: 100%;
|
|
width: 100%;
|
|
height: 110rpx;
|
|
height: 110rpx;
|
|
- line-height: 110rpx;
|
|
|
|
justify-content: space-between;
|
|
justify-content: space-between;
|
|
font-size: $font-size-28;
|
|
font-size: $font-size-28;
|
|
background-color: #ffffff;
|
|
background-color: #ffffff;
|
|
z-index: 998;
|
|
z-index: 998;
|
|
color: $text-color;
|
|
color: $text-color;
|
|
|
|
+ border-top: 1px solid #f7f7f7;
|
|
.footer-le {
|
|
.footer-le {
|
|
width: 570rpx;
|
|
width: 570rpx;
|
|
height: 100%;
|
|
height: 100%;
|
|
@@ -412,6 +493,7 @@ page {
|
|
.footer-count {
|
|
.footer-count {
|
|
float: left;
|
|
float: left;
|
|
padding-left: 24rpx;
|
|
padding-left: 24rpx;
|
|
|
|
+ line-height: 110rpx;
|
|
width: 170rpx;
|
|
width: 170rpx;
|
|
box-sizing: border-box;
|
|
box-sizing: border-box;
|
|
font-size: $font-size-26;
|
|
font-size: $font-size-26;
|
|
@@ -423,15 +505,23 @@ page {
|
|
padding-right: 20rpx;
|
|
padding-right: 20rpx;
|
|
box-sizing: border-box;
|
|
box-sizing: border-box;
|
|
width: 370rpx;
|
|
width: 370rpx;
|
|
|
|
+ padding-left: 24rpx;
|
|
.sum {
|
|
.sum {
|
|
|
|
+ display: flex;
|
|
|
|
+ justify-content: center;
|
|
|
|
+ flex-direction: column;
|
|
|
|
+ align-items: flex-start;
|
|
width: 100%;
|
|
width: 100%;
|
|
height: 110rpx;
|
|
height: 110rpx;
|
|
- line-height: 110rpx;
|
|
|
|
- float: left;
|
|
|
|
.price {
|
|
.price {
|
|
font-size: $font-size-32;
|
|
font-size: $font-size-32;
|
|
color: $color-system;
|
|
color: $color-system;
|
|
}
|
|
}
|
|
|
|
+ .discount {
|
|
|
|
+ // margin-top: 32rpx;
|
|
|
|
+ font-size: $font-size-24;
|
|
|
|
+ color: #ff457b;
|
|
|
|
+ }
|
|
}
|
|
}
|
|
}
|
|
}
|
|
.footer-submit {
|
|
.footer-submit {
|