|
|
@@ -70,8 +70,8 @@
|
|
|
placeholder="请输入您的联系电话"></view>
|
|
|
</view>
|
|
|
<view class="distribution-list distribution-list-bottom"
|
|
|
- :class="{ 'disabled': !hasAvailableCoupons }"
|
|
|
- @click="hasAvailableCoupons ? toggleMask('show') : null"
|
|
|
+ :class="{ 'disabled': !hasCoupons }"
|
|
|
+ @click="hasCoupons ? toggleMask('show') : null"
|
|
|
v-if="!orderReqeust.isIntegral">
|
|
|
<view class="distribution-text">优惠券
|
|
|
<!-- 新增最佳优惠标识 -->
|
|
|
@@ -79,9 +79,9 @@
|
|
|
最佳优惠
|
|
|
</view>
|
|
|
</view>
|
|
|
- <view class="distribution-price" :style="{ color: hasAvailableCoupons ? 'red' : '#999' }">
|
|
|
+ <view class="distribution-price" :style="{ color: hasCoupons ? 'red' : '#999' }">
|
|
|
{{
|
|
|
- orderReqeust.coupon ? "-¥" + orderReqeust.coupon.couponPrice : (hasAvailableCoupons ? '选择优惠券' : '暂无优惠券')
|
|
|
+ orderReqeust.coupon ? "-¥" + orderReqeust.coupon.couponPrice : (hasCoupons ? '选择优惠券' : '暂无优惠券')
|
|
|
}}
|
|
|
</view>
|
|
|
</view>
|
|
|
@@ -93,12 +93,12 @@
|
|
|
</view>
|
|
|
|
|
|
<view class="distribution-list distribution-list-bottom" v-if="shippingType === 1">
|
|
|
- <view class="distribution-text">加急费用(可选)</view>
|
|
|
- <view class="distribution-price">
|
|
|
+ <view class="distribution-text" style="width: 250rpx">加急费用(可选)</view>
|
|
|
+ <view class="distribution-price" style="display: flex; align-items: center; justify-content: flex-end;flex:1; width: 430upx">
|
|
|
<input type="number" v-model.number="orderReqeust.urgentFee"
|
|
|
placeholder="请输入加急费用"
|
|
|
- style="text-align: right;">
|
|
|
- <text style="margin-left: 10rpx;">元</text>
|
|
|
+ style="text-align: right; flex: 1; border: none; outline: none;">
|
|
|
+ <text style="margin-left: 5rpx;">元</text>
|
|
|
</view>
|
|
|
</view>
|
|
|
|
|
|
@@ -121,7 +121,7 @@
|
|
|
|
|
|
<!-- 添加照片按钮 -->
|
|
|
<view
|
|
|
- v-if="orderReqeust.photos.length < 5"
|
|
|
+ v-if="orderReqeust.photos.length < 6"
|
|
|
class="photo-add-btn"
|
|
|
@click="choosePhoto"
|
|
|
>
|
|
|
@@ -129,7 +129,7 @@
|
|
|
<text class="photo-add-text">添加照片</text>
|
|
|
</view>
|
|
|
</view>
|
|
|
- <view class="photo-tips">最多可上传5张照片</view>
|
|
|
+ <view class="photo-tips">最多可上传6张照片</view>
|
|
|
</view>
|
|
|
</view>
|
|
|
</view>
|
|
|
@@ -167,13 +167,14 @@
|
|
|
<view v-if="getAvailableCoupons().length === 0" class="no-coupon-tip">
|
|
|
<text>暂无可用优惠券</text>
|
|
|
</view>
|
|
|
- <view @click="selectCoupon(item)"
|
|
|
- v-if="(!item.categoryId && orderReqeust.totalPrice >= item.useMinPrice) || (item.categoryId && skuCategoryPriceMap[item.categoryId] && skuCategoryPriceMap[item.categoryId] > item.useMinPrice)"
|
|
|
- class="coupon-item" v-for="(item,index) in couponList" :key="index">
|
|
|
+ <view @click="isCouponAvailable(item) ? selectCoupon(item) : null"
|
|
|
+ class="coupon-item"
|
|
|
+ :class="{ 'coupon-disabled': !isCouponAvailable(item) }"
|
|
|
+ v-for="(item,index) in couponList" :key="index">
|
|
|
<view class="con">
|
|
|
<view class="left">
|
|
|
<text class="title">{{ item.couponTitle }}</text>
|
|
|
- <text class="time">有效期至{{ item.endTime | dateFormat }}</text>
|
|
|
+ <text class="time">有效期至{{ item.endTime || '-' }}</text>
|
|
|
</view>
|
|
|
<view class="right">
|
|
|
<text class="price">{{ item.couponPrice }}</text>
|
|
|
@@ -184,6 +185,7 @@
|
|
|
<view class="circle r"></view>
|
|
|
</view>
|
|
|
<text class="tips">{{ item.categoryTitle ? '限' + item.categoryTitle + '可用' : '全品类可用' }}</text>
|
|
|
+ <text class="info" v-if="item.id === bestCouponId && hasAvailableCoupons">最佳优惠</text>
|
|
|
</view>
|
|
|
</view>
|
|
|
</view>
|
|
|
@@ -193,7 +195,7 @@
|
|
|
<view class="price-content">
|
|
|
<text>总计</text>
|
|
|
<text class="price-content-money">
|
|
|
- ¥{{ orderPriceData.actualPrice || 0 }}
|
|
|
+ ¥{{ orderPriceData.actualPrice || '-' }}
|
|
|
</text>
|
|
|
<text class="price-content-money" style="color: red" v-if="orderReqeust.isIntegral === 1"> +
|
|
|
积分{{ orderReqeust.integral }}
|
|
|
@@ -201,7 +203,7 @@
|
|
|
</view>
|
|
|
<view class="price-preferential">
|
|
|
<text>已优惠:</text>
|
|
|
- <text>{{ jian(orderPriceData.productOriginalTotalPrice || 0, orderPriceData.actualPrice || 0) }}元</text>
|
|
|
+ <text>{{ orderPriceData.couponPrice || '0' }}元</text>
|
|
|
</view>
|
|
|
</view>
|
|
|
<view class="submit" @click="submit">
|
|
|
@@ -242,6 +244,7 @@
|
|
|
|
|
|
<script>
|
|
|
import uniPopup from "@/components/uni-popup/uni-popup.vue"
|
|
|
+import {dateFormat} from "../../filters";
|
|
|
|
|
|
export default {
|
|
|
data() {
|
|
|
@@ -272,6 +275,7 @@ export default {
|
|
|
maskState: 0, //优惠券面板显示状态
|
|
|
couponList: [],
|
|
|
hasAvailableCoupons: false, // 是否有可用优惠券
|
|
|
+ hasCoupons: false,
|
|
|
urgentFeeTimer: null, // 加急费用防抖定时器
|
|
|
orderPriceData: { // 订单价格数据
|
|
|
productTotalPrice: 0,
|
|
|
@@ -352,8 +356,16 @@ export default {
|
|
|
that.orderReqeust.totalPrice = totalPrice
|
|
|
that.$api.request('get', 'coupon/app/getUserCoupons').then(res => {
|
|
|
that.couponList = res.data
|
|
|
- that.hasAvailableCoupons = that.getAvailableCoupons().length > 0
|
|
|
this.findBestCoupon(); // 找出最佳优惠券
|
|
|
+
|
|
|
+ if (that.bestCouponId) {
|
|
|
+ const baseIndex = that.couponList.findIndex(coupon => that.bestCouponId === coupon.id)
|
|
|
+ that.couponList.unshift(...that.couponList.splice(that.couponList.indexOf(baseIndex), 1));
|
|
|
+ }
|
|
|
+
|
|
|
+ that.hasCoupons = res.data.length > 0
|
|
|
+ that.hasAvailableCoupons = that.getAvailableCoupons().length > 0
|
|
|
+
|
|
|
// 初始化价格计算
|
|
|
that.calculateOrderPrice();
|
|
|
})
|
|
|
@@ -371,7 +383,6 @@ export default {
|
|
|
if (res.data) {
|
|
|
that.addressData = res.data
|
|
|
}
|
|
|
- that.calcFreightPrice()
|
|
|
})
|
|
|
|
|
|
if (that.orderReqeust.productList.length === 1 && that.orderReqeust.productList[0].groupShopId) {
|
|
|
@@ -398,6 +409,7 @@ export default {
|
|
|
this.calcTime()
|
|
|
},
|
|
|
methods: {
|
|
|
+ dateFormat,
|
|
|
findBestCoupon() {
|
|
|
if (this.couponList.length > 0) {
|
|
|
// 找出优惠力度最大的优惠券
|
|
|
@@ -411,9 +423,15 @@ export default {
|
|
|
getAvailableCoupons() {
|
|
|
return this.couponList.filter(item => {
|
|
|
return (!item.categoryId && this.orderReqeust.totalPrice >= item.useMinPrice) ||
|
|
|
+ // 有categoryId 且 category 价格大于实际价格
|
|
|
(item.categoryId && this.skuCategoryPriceMap[item.categoryId] && this.skuCategoryPriceMap[item.categoryId] > item.useMinPrice);
|
|
|
});
|
|
|
},
|
|
|
+ // 判断单个优惠券是否可用
|
|
|
+ isCouponAvailable(item) {
|
|
|
+ return (!item.categoryId && this.orderReqeust.totalPrice >= item.useMinPrice) ||
|
|
|
+ (item.categoryId && this.skuCategoryPriceMap[item.categoryId] && this.skuCategoryPriceMap[item.categoryId] > item.useMinPrice);
|
|
|
+ },
|
|
|
// 计算订单价格
|
|
|
calculateOrderPrice() {
|
|
|
const that = this;
|
|
|
@@ -430,15 +448,7 @@ export default {
|
|
|
})
|
|
|
.catch(err => {
|
|
|
console.error('计算订单价格失败:', err);
|
|
|
- // 出错时使用默认值
|
|
|
- that.orderPriceData = {
|
|
|
- productTotalPrice: that.orderReqeust.totalPrice || 0,
|
|
|
- productOriginalTotalPrice: that.orderReqeust.totalotPrice || 0,
|
|
|
- freightPrice: that.orderReqeust.freightPrice || 0,
|
|
|
- urgentFee: that.orderReqeust.urgentFee || 0,
|
|
|
- couponPrice: that.orderReqeust.coupon ? that.orderReqeust.coupon.couponPrice : 0,
|
|
|
- actualPrice: (that.orderReqeust.totalPrice || 0) - (that.orderReqeust.coupon ? that.orderReqeust.coupon.couponPrice : 0) + (that.orderReqeust.freightPrice || 0) + (that.orderReqeust.urgentFee || 0)
|
|
|
- };
|
|
|
+ throw err
|
|
|
});
|
|
|
},
|
|
|
showFreightMsg() {
|
|
|
@@ -510,7 +520,6 @@ export default {
|
|
|
},
|
|
|
addressType: function (index) {
|
|
|
this.shippingType = index
|
|
|
- this.calcFreightPrice()
|
|
|
},
|
|
|
//显示优惠券面板
|
|
|
toggleMask(type) {
|
|
|
@@ -1026,7 +1035,7 @@ page {
|
|
|
flex-direction: column;
|
|
|
margin: 20upx 24upx;
|
|
|
background: #fff;
|
|
|
-
|
|
|
+ position: relative;
|
|
|
.con {
|
|
|
display: flex;
|
|
|
align-items: center;
|
|
|
@@ -1045,7 +1054,12 @@ page {
|
|
|
transform: scaleY(50%);
|
|
|
}
|
|
|
}
|
|
|
-
|
|
|
+ .info {
|
|
|
+ position: absolute;
|
|
|
+ right: 20rpx;
|
|
|
+ bottom: 20rpx;
|
|
|
+ color: red;
|
|
|
+ }
|
|
|
.left {
|
|
|
display: flex;
|
|
|
flex-direction: column;
|
|
|
@@ -1110,6 +1124,28 @@ page {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+/* 不可用优惠券置灰样式 */
|
|
|
+.coupon-disabled {
|
|
|
+ opacity: 0.5;
|
|
|
+ pointer-events: none;
|
|
|
+
|
|
|
+ .title {
|
|
|
+ color: #999 !important;
|
|
|
+ }
|
|
|
+
|
|
|
+ .time {
|
|
|
+ color: #ccc !important;
|
|
|
+ }
|
|
|
+
|
|
|
+ .price {
|
|
|
+ color: #999 !important;
|
|
|
+ }
|
|
|
+
|
|
|
+ .tips {
|
|
|
+ color: #ccc !important;
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
.address {
|
|
|
padding: 36upx 30upx;
|
|
|
background-color: #FFFFFF;
|
|
|
@@ -1449,8 +1485,8 @@ page {
|
|
|
|
|
|
.photo-item {
|
|
|
position: relative;
|
|
|
- width: 120rpx; /* 固定正方形宽度 */
|
|
|
- height: 120rpx; /* 固定正方形高度 */
|
|
|
+ width: 200rpx; /* 固定正方形宽度 */
|
|
|
+ height: 200rpx; /* 固定正方形高度 */
|
|
|
margin-bottom: 20rpx; /* 行间距 */
|
|
|
}
|
|
|
|
|
|
@@ -1481,8 +1517,8 @@ page {
|
|
|
}
|
|
|
|
|
|
.photo-add-btn {
|
|
|
- width: 120rpx; /* 与photo-item保持一致 */
|
|
|
- height: 120rpx; /* 与photo-item保持一致 */
|
|
|
+ width: 200rpx; /* 与photo-item保持一致 */
|
|
|
+ height: 200rpx; /* 与photo-item保持一致 */
|
|
|
margin-bottom: 20rpx; /* 与photo-item保持一致的行间距 */
|
|
|
border: 2rpx dashed #ccc;
|
|
|
border-radius: 8rpx;
|