Просмотр исходного кода

优化:用户端结算台选择优惠券样式重构

萤火科技 1 год назад
Родитель
Сommit
f0ea718afe
2 измененных файлов с 206 добавлено и 122 удалено
  1. 50 22
      pages/checkout/index.vue
  2. 156 100
      pages/checkout/style.scss

+ 50 - 22
pages/checkout/index.vue

@@ -154,37 +154,59 @@
         <view class="popup__coupon">
           <view class="coupon__title f-30">选择优惠券</view>
           <!-- 优惠券列表 -->
-          <view class="coupon-list">
-            <scroll-view :scroll-y="true" style="height: 565rpx;">
+          <scroll-view :scroll-y="true" style="height: 650rpx;">
+            <view class="coupon-list">
               <view class="coupon-item" v-for="(item, index) in order.couponList" :key="index">
-                <view class="item-wrapper" :class="[item.is_apply ? 'color-' + CouponColors[index % CouponColors.length] : 'color-gray']"
-                  @click="handleSelectCoupon(index)">
-                  <view class="coupon-type">{{ CouponTypeEnum[item.coupon_type].name }}</view>
-                  <view class="tip dis-flex flex-dir-column flex-x-center">
-                    <view v-if="item.coupon_type == CouponTypeEnum.FULL_DISCOUNT.value">
-                      <text class="f-30">¥</text>
-                      <text class="money">{{ item.reduce_price }}</text>
+                <view class="item-wrapper" :class="[ !item.state.value ? 'disable' : '' ]" @click="handleSelectCoupon(index)">
+                  <!-- 优惠券类型 (标签) -->
+                  <view class="coupon-tag">
+                    <text>{{ CouponTypeEnum[item.coupon_type].name }}</text>
+                  </view>
+                  <view class="coupon-left">
+                    <!-- 优惠额度/折扣 -->
+                    <view class="coupon-reduce">
+                      <view class="coupon-reduce-unit"><text>¥</text></view>
+                      <view class="coupon-reduce-amount">
+                        <text class="value">{{ item.reduce_price }}</text>
+                      </view>
                     </view>
-                    <text class="money" v-if="item.coupon_type == CouponTypeEnum.DISCOUNT.value">{{ item.discount }}折</text>
-                    <text class="pay-line">满{{ item.min_price }}元可用</text>
+                    <!-- 最低消费金额 -->
+                    <text class="coupon-hint">满{{ item.min_price }}元可用</text>
                   </view>
-                  <view class="split-line"></view>
-                  <view class="content dis-flex flex-dir-column flex-x-between">
-                    <view class="title">{{ item.name }}</view>
-                    <view class="bottom dis-flex flex-y-center">
-                      <view class="time flex-box">
-                        <block v-if="item.start_time === item.end_time">{{ item.start_time }} 当天有效</block>
-                        <block v-else>{{ item.start_time }}~{{ item.end_time }}</block>
+                  <view class="coupon-content">
+                    <view class="coupon-name">{{ item.name }}</view>
+                    <view class="coupon-middle">
+                      <view class="coupon-expire">
+                        <text v-if="item.expire_type == CouponTypeEnum.FULL_DISCOUNT.value">领取后{{ item.expire_day }}天内有效</text>
+                        <text v-if="item.expire_type == CouponTypeEnum.DISCOUNT.value">
+                          <block v-if="item.start_time === item.end_time">{{ item.start_time }} 当天有效</block>
+                          <block v-else>{{ item.start_time }}~{{ item.end_time }}</block>
+                        </text>
                       </view>
                     </view>
+                    <view v-if="item.describe" class="coupon-expand" @click.stop="handleDescribe(index)">
+                      <text>使用说明</text>
+                      <text class="coupon-expand-arrow iconfont icon-arrow-down" :class="[item.expand ? 'expand' : '']" />
+                    </view>
+                  </view>
+                  <view class="coupon-right">
+                    <u-radio-group v-model="selectCouponId">
+                      <u-radio :name="item.user_coupon_id" :active-color="appTheme.mainBg"></u-radio>
+                    </u-radio-group>
+                  </view>
+                </view>
+                <!-- 优惠券描述 -->
+                <view :class="[item.expand ? 'expand' : '']" class="coupon-expand-rules">
+                  <view class="coupon-expand-rules-content">
+                    <view class="pre">{{ item.describe }}</view>
                   </view>
                 </view>
               </view>
-            </scroll-view>
-          </view>
+            </view>
+          </scroll-view>
           <!-- 不使用优惠券 -->
-          <view class="coupon__do_not dis-flex flex-y-center flex-x-center">
-            <view class="control dis-flex flex-y-center flex-x-center" @click="handleNotUseCoupon()">
+          <view class="coupon__do_not">
+            <view class="control" @click="handleNotUseCoupon()">
               <text class="f-26">不使用优惠券</text>
             </view>
           </view>
@@ -365,6 +387,12 @@
         this.showPopup = true
       },
 
+      // 展开优惠券描述
+      handleDescribe(index) {
+        const { couponList } = this.order
+        couponList[index].expand = !couponList[index].expand
+      },
+
       // 选择优惠券
       handleSelectCoupon(index) {
         const app = this

+ 156 - 100
pages/checkout/style.scss

@@ -84,13 +84,23 @@
 .popup__coupon {
   background: #fff;
   box-sizing: border-box;
-  padding: 30rpx;
+  padding: 30rpx 0 30rpx 0;
   // 设置ios刘海屏底部横线安全区域
   padding-bottom: calc(constant(safe-area-inset-bottom) + 30rpx);
   padding-bottom: calc(env(safe-area-inset-bottom) + 30rpx);
 
   .coupon__do_not {
+    position: relative;
+    display: flex;
+    justify-content: center;
+    align-items: center;
+    padding-top: 30rpx;
+    box-shadow: 0 -12rpx 30rpx -6rpx rgba(151, 151, 151, 0.24);
+    
     .control {
+      display: flex;
+      justify-content: center;
+      align-items: center;
       width: 90%;
       height: 72rpx;
       color: #888;
@@ -101,7 +111,7 @@
 
   .coupon__title {
     text-align: center;
-    margin-bottom: 30rpx;
+    margin-bottom: 15rpx;
   }
 
   .coupon-list {
@@ -109,140 +119,186 @@
     max-width: 1120rpx;
     margin: 0 auto;
     /* #endif */
-    margin-bottom: 24rpx;
+    padding: 40rpx 30rpx;
   }
 
   .coupon-item {
-    position: relative;
-    overflow: hidden;
     margin-bottom: 22rpx;
+    font-size: 24rpx;
+    background: #fff;
+    border-radius: 12rpx;
+    overflow: hidden;
+    box-shadow: 0 8rpx 40rpx rgba(0, 0, 0, 0.06);
+    position: relative;
   }
 
   .item-wrapper {
-    width: 100%;
     display: flex;
-    background: #fff;
-    border-radius: 8rpx;
-    color: #fff;
-    height: 180rpx;
-
-    .coupon-type {
-      position: absolute;
-      top: 0;
-      right: 0;
-      z-index: 10;
-      width: 128rpx;
-      padding: 6rpx 0;
-      background: #a771ff;
-      font-size: 20rpx;
-      text-align: center;
-      color: #ffffff;
-      transform: rotate(45deg);
-      transform-origin: 64rpx 64rpx;
-    }
+    align-items: center;
 
-    &.color-blue {
-      background: linear-gradient(-125deg, #57bdbf, #2f9de2);
-    }
+    &.disable {
+      .coupon-tag {
+        background: linear-gradient(-113deg, #bdbdbd, #a2a1a2);
+      }
 
-    &.color-red {
-      background: linear-gradient(-128deg, #ff6d6d, #ff3636);
+      .coupon-reduce {
+        color: #757575;
+      }
+
+      .state-text {
+        color: #757575;
+      }
     }
+  }
 
-    &.color-violet {
-      background: linear-gradient(-113deg, #ef86ff, #b66ff5);
+  .coupon-tag {
+    position: absolute;
+    left: 0;
+    top: 0;
+    color: #fff;
+    width: 96rpx;
+    text-align: center;
+    font-size: 22rpx;
+    border-radius: 12rpx 0 12rpx 0;
+    font-weight: 500;
+    height: 34rpx;
+    display: flex;
+    align-items: center;
+    justify-content: center;
+    background: linear-gradient(to right, $main-bg, $main-bg2);
+    color: $main-text;
+  }
 
-      .coupon-type {
-        background: #55b5ff;
+  .coupon-left {
+    width: 242rpx;
+    text-align: center;
+    display: flex;
+    flex-flow: column;
+    justify-content: center;
+    position: relative;
+
+    .coupon-reduce {
+      color: $main-bg;
+
+      &-unit {
+        display: inline-block;
+        margin-right: -4rpx;
+        font-size: 32rpx;
+        font-weight: 600;
+      }
+
+      &-amount {
+        display: inline-block;
+
+        .value {
+          font-size: 48rpx;
+        }
       }
     }
 
-    &.color-yellow {
-      background: linear-gradient(-141deg, #f7d059, #fdb054);
+    .coupon-hint {
+      margin-top: 16rpx;
+      color: #757575;
+      font-size: 24rpx;
+      white-space: nowrap;
+      text-overflow: ellipsis;
+      overflow: hidden;
     }
+  }
 
-    &.color-gray {
-      background: linear-gradient(-113deg, #bdbdbd, #a2a1a2);
+  .coupon-content {
+    flex: 1;
+    padding: 32rpx 0;
+    position: relative;
+    display: flex;
+    flex-direction: column;
+    flex-wrap: nowrap;
+    align-items: flex-start;
+    justify-content: space-between;
 
-      .coupon-type {
-        background: #9e9e9e;
-      }
+    .coupon-name {
+      color: #212121;
+      font-size: 28rpx;
+      font-weight: 500;
     }
 
-    .content {
+    .coupon-middle {
       flex: 1;
-      padding: 30rpx 20rpx;
-      border-radius: 16rpx 0 0 16rpx;
+      padding-top: 12rpx;
+      margin-bottom: 26rpx;
 
-      .title {
-        font-size: 32rpx;
+      .coupon-expire {
+        color: #757575;
+        font-size: 24rpx;
       }
+    }
 
-      .bottom {
-        .time {
-          font-size: 24rpx;
-        }
-
-        .receive {
-          height: 46rpx;
-          width: 122rpx;
-          border: 1rpx solid #fff;
-          border-radius: 30rpx;
-          color: #fff;
-          font-size: 24rpx;
-          display: flex;
-          justify-content: center;
-          align-items: center;
-
-          &.state {
-            border: none;
-          }
+    .coupon-expand {
+      display: flex;
+      align-items: center;
+      color: #9e9e9e;
+      font-size: 24rpx;
+
+      &-arrow {
+        margin-top: 4rpx;
+        font-size: 24rpx;
+        display: inline-block;
+        vertical-align: initial;
+        transform: rotate(0);
+        margin-left: 8rpx;
+        transition: all 0.15s ease-in-out;
+
+        &.expand {
+          transform: rotate(180deg);
         }
       }
     }
+  }
 
-    .tip {
-      position: relative;
-      flex: 0 0 32%;
-      text-align: center;
-      border-radius: 0 16rpx 16rpx 0;
+  .coupon-right {
+    padding-right: 38rpx;
 
-      .money {
-        font-weight: bold;
-        font-size: 52rpx;
-      }
+    .btn-receive,
+    .state-text {
+      text-align: center;
+      width: 100rpx;
+      padding: 15rpx 0;
+    }
 
-      .pay-line {
-        font-size: 22rpx;
-      }
+    .btn-receive {
+      font-size: 23rpx;
+      line-height: 1;
+      font-weight: 500;
+      border-radius: 8rpx;
+      cursor: pointer;
+      background: linear-gradient(to right, $main-bg, $main-bg2);
+      color: $main-text;
     }
 
-    .split-line {
-      position: relative;
-      flex: 0 0 0;
-      border-left: 4rpx solid #fff;
-      margin: 0 10rpx 0 6rpx;
-      background: #fff;
+    .state-text {
+    }
+  }
 
-      &:before {
-        border-radius: 0 0 16rpx 16rpx;
-        top: 0;
-      }
+  .coupon-expand-rules {
+    display: none;
+    position: relative;
 
-      &:after {
-        border-radius: 16rpx 16rpx 0 0;
-        bottom: 0;
-      }
+    &.expand {
+      top: -30rpx;
+      display: block;
+    }
 
-      &:before,
-      &:after {
-        content: '';
-        position: absolute;
-        width: 24rpx;
-        height: 12rpx;
-        background: #f7f7f7;
-        left: -14rpx;
-        z-index: 1;
+    &-content {
+      padding: 8rpx 30rpx 8rpx 242rpx;
+      font-weight: 400;
+      color: #9e9e9e;
+      line-height: 36rpx;
+
+      .pre {
+        font-family: auto;
+        white-space: pre-wrap;
+        word-wrap: break-word;
+        word-break: break-all;
       }
     }
   }