Sfoglia il codice sorgente

Merge remote-tracking branch 'origin/hqyDev' into iteration-20241126

lex-xin 7 mesi fa
parent
commit
d31876689b

+ 10 - 6
src/shims-vue.d.ts

@@ -1,16 +1,20 @@
-import dayjs from "dayjs";
-
+import dayjs from 'dayjs'
 
 declare module 'vue-cropper'
 declare module '*.vue' {
-  import { DefineComponent } from 'vue';
-  const component: DefineComponent<{}, {}, any>;
-  export default component;
+  import { DefineComponent } from 'vue'
+  const component: DefineComponent<{}, {}, any>
+  export default component
 }
 
-
 declare module '@vue/runtime-core' {
   export interface ComponentCustomProperties {
     $dayjs: dayjs.Dayjs
   }
 }
+
+declare module 'vue' {
+  interface CSSProperties {
+    '--navBarHeight'?: string
+  }
+}

+ 4 - 2
src/student/activePage/double12Active/index.tsx

@@ -12,7 +12,7 @@ import svipCon2 from './imgs/svipCon2.png'
 import dayjs from 'dayjs'
 import { state as baseState } from '@/state'
 import { Toast, Popup, Button } from 'vant'
-import { useRouter } from 'vue-router'
+import { useRouter, useRoute } from 'vue-router'
 import { tradeOrder } from '@/student/trade/tradeOrder'
 import { orderStatus } from '@/views/order-detail/orderStatus'
 import { memberType, studyCardType } from '@/constant'
@@ -21,12 +21,13 @@ export default defineComponent({
   name: 'double12Active',
   setup(props, { emit }) {
     const router = useRouter()
+    const route = useRoute()
     const state = reactive({
       titleOpacity: 0,
       navBarHeight: 0,
       orderVisiable: false,
       orderDetail: {} as any,
-      activityId: '19'
+      activityId: route.query.activityId
     })
     const activitData = reactive({
       activityStart: '2024-12-12 00:00:00',
@@ -68,6 +69,7 @@ export default defineComponent({
     })
     initActivit()
     function initActivit() {
+      if (!state.activityId) return
       request
         .get(
           `/api-student/memberPriceSettings/getDoubleTwelve/${state.activityId}`

+ 92 - 12
src/student/trade/tradeOrder.ts

@@ -14,6 +14,7 @@ const apiSuffix =
 interface IAmount {
   couponAmount: number
   discountPrice: number
+  expectPrice: number
 }
 export const formatOrderDetail = async (item: any, amount?: IAmount) => {
   const type = item.goodType
@@ -87,27 +88,93 @@ export const formatOrderDetail = async (item: any, amount?: IAmount) => {
     case 'SVIP':
       {
         try {
-          const res = await getVipDetail(item.id)
-
           // couponAmount 总的优惠金额
           // discountPrice 优惠券金额
-          let tempPrice = res.salePrice || item.actualPrice
-          if (amount?.couponAmount) {
-            tempPrice = Number(((res.salePrice - (amount.couponAmount -
-              amount.discountPrice) / res.times)).toFixed(2))
+          let tempPrice = amount?.expectPrice || item.actualPrice
+          // 如果是赠送活动 就是一口价
+          if (item.activityType !== 'MEMBER') {
+            if (amount?.couponAmount) {
+              tempPrice = Number(
+                (
+                  amount?.expectPrice -
+                  (amount.couponAmount - amount.discountPrice) / item.goodNum
+                ).toFixed(2)
+              )
+            }
+          }
+          // 判断是否有会员
+          let startTime = new Date()
+          if (item.goodType === 'SVIP') {
+            startTime = dayjs(
+              state.user.data.userVip.svipEndDate || new Date()
+            ).toDate()
+          } else if (item.goodType === 'VIP') {
+            // 购买Vip时,先有vip的有效时间,如果没有则取SVIP有效时间,都没有默认当前
+            startTime = dayjs(
+              state.user.data.userVip.vipEndDate ||
+                state.user.data.userVip.svipEndDate ||
+                new Date()
+            ).toDate()
+          }
+          let endTime = new Date()
+          if (item.period === 'MONTH') {
+            endTime = dayjs(startTime)
+              .add(1 * item.goodNum, 'month')
+              .toDate()
+          } else if (item.period === 'QUARTERLY') {
+            endTime = dayjs(startTime)
+              .add(3 * item.goodNum, 'month')
+              .toDate()
+          } else if (item.period === 'YEAR_HALF') {
+            endTime = dayjs(startTime)
+              .add(6 * item.goodNum, 'month')
+              .toDate()
+          } else if (item.period === 'YEAR') {
+            endTime = dayjs(startTime)
+              .add(1 * item.goodNum, 'year')
+              .toDate()
           }
           tempList = {
             orderType: item.goodType,
             goodName: item.goodName,
             num: item.goodNum,
             id: item.id,
-            title: memberType[res.period] || '',
+            title: item.goodName || '',
             vipEndDays: item.vipEndDays,
             // 判断是否有优惠金额
             price: tempPrice,
-            startTime: dayjs(res.startTime).format('YYYY-MM-DD'),
-            endTime: dayjs(res.endTime).format('YYYY-MM-DD')
+            period: item.period,
+            startTime: dayjs(startTime).format('YYYY-MM-DD'),
+            endTime: dayjs(endTime).format('YYYY-MM-DD'),
+            activityList: [], // 活动赠送的东西
+            discountEndTime: state.user.data.discountEndTime, // 畅学卡结束时间
+            discountStartTime: state.user.data.discountStartTime // 畅学卡开始时间
           }
+          tempList.activityList = (item.activityList || []).map(item => {
+            const { goodType, goodName, goodNum, giftFlag, bizId, period } = item
+            if (goodType === 'DISCOUNT') {
+              return {
+                goodType,
+                goodName,
+                goodNum,
+                bizContent: bizId,
+                giftFlag,
+                vipEndDays: null,
+                goodsNum: goodNum,
+                unit:period
+              }
+            }
+            return {
+              goodType,
+              goodName,
+              goodNum,
+              bizContent: bizId,
+              giftFlag,
+              vipEndDays: null,
+              goodsNum: goodNum,
+              unit:period
+            }
+          })
         } catch (e: any) {
           throw new Error(e.message)
         }
@@ -283,7 +350,8 @@ export const tradeOrder = (result: any, callBack?: any) => {
     discountPrice,
     paymentConfig,
     paymentVendor,
-    paymentVersion
+    paymentVersion,
+    expectPrice
   } = result
   orderStatus.orderObject.orderType = orderType
   orderStatus.orderObject.orderName = orderName
@@ -298,10 +366,22 @@ export const tradeOrder = (result: any, callBack?: any) => {
   }
   orderStatus.orderObject.orderList = []
   try {
-    orderDetailList.forEach(async (item: any) => {
+    // 排除活动商品
+    const orderDetails: any[] = []
+    const orderDetailsActivity: any[] = []
+    orderDetailList.map(item => {
+      if (item.giftFlag) {
+        orderDetailsActivity.push(item)
+      } else {
+        orderDetails.push(item)
+      }
+    })
+    orderDetails[0] && (orderDetails[0].activityList = orderDetailsActivity)
+    orderDetails.forEach(async (item: any) => {
       await formatOrderDetail(item, {
         couponAmount,
-        discountPrice
+        discountPrice,
+        expectPrice
       })
     })
     callBack && callBack()

+ 19 - 1
src/views/member-center/index.module.less

@@ -195,6 +195,22 @@
   border-radius: 16px 16px 0px 0px;
   padding-bottom: 10px;
 }
+.activitTip2{
+  margin: 16px;
+  background: linear-gradient( 90deg, #FFE9EE 0%, #FFECD9 100%);
+  border-radius: 8px;
+  padding: 8px 9px;
+  .activitTipText{
+    white-space: pre-line;
+    font-weight: 500;
+    font-size: 14px;
+    color: #6B4429;
+    line-height: 22px;
+    background: linear-gradient(90deg, #F31234 0%, #FF6E00 100%);
+    -webkit-background-clip: text; /* 让背景裁剪到文字上 */
+    -webkit-text-fill-color: transparent; /* 文字填充透明色,显示背景渐变 */
+  }
+}
 
 .member_tabs {
   display: flex;
@@ -546,7 +562,9 @@
     .iconPermanent {
       left: -2px;
     }
-
+    .activitTip1 {
+      left: -2px;
+    }
     .extraTip {
       background: #0ED8B0;
       color: #FFFFFF;

+ 16 - 6
src/views/member-center/index.tsx

@@ -298,7 +298,7 @@ export default defineComponent({
         orderStatus.orderObject.orderDesc = `小酷Ai ${state.tabActive} ${member.title}`
         orderStatus.orderObject.actualPrice = calcSalePrice(member)
         orderStatus.orderObject.recomUserId = state.recomUserId
-        orderStatus.orderObject.activityId = activitData.activityId || state.activityId
+        orderStatus.orderObject.activityId = state.activityId
         orderStatus.orderObject.orderNo = ''
 
         const orderData = {
@@ -322,10 +322,12 @@ export default defineComponent({
           discountEndTime: userInfo.value.discountEndTime, // 畅学卡结束时间
           discountStartTime: userInfo.value.discountStartTime // 畅学卡开始时间
         }
+        // 当能购买并且是当前活动商品时候加上 活动信息
         const canBuyNum = activitData.buyCount - activitData.buyNum
-        if (canBuyNum > 0) {
+        if (member.id === activitData.vipCardId && canBuyNum > 0) {
           orderData.activityBuyCount = canBuyNum
           orderData.activityList = activitData.activityList
+          orderStatus.orderObject.activityId = activitData.activityId
         }
         orderStatus.orderObject.orderList = [orderData]
         router.push({
@@ -411,10 +413,10 @@ export default defineComponent({
         )
         const { list, ...more } = data
 
-        // 学生端 活动
-        if (baseState.platformType === 'STUDENT') {
+        // 学生端 活动 有分享活动的时候 就不支持折扣活动
+        if (baseState.platformType === 'STUDENT' && !state.activityId) {
           const activitRes = await request.post(
-            `api-student/memberPriceSettings/getMemberBuyGift`
+            `/api-student/memberPriceSettings/getMemberBuyGift`
           )
           if (activitRes.code === 200 && activitRes.data) {
             const {
@@ -849,7 +851,15 @@ export default defineComponent({
                   <span>原VIP会员天数升级为SVIP</span>
                 </div>
               )}
-
+            {/* 活动描述 */}
+            {state.selectMember?.id === activitData.vipCardId &&
+              activitData.extConfig?.describe && (
+                <div class={styles.activitTip2}>
+                  <div class={styles.activitTipText}>
+                    {activitData.extConfig?.describe}
+                  </div>
+                </div>
+              )}
             <MemberInteres type={state.tabActive} />
           </div>
         </div>

+ 28 - 1
src/views/order-detail/order-vip/index.tsx

@@ -94,6 +94,33 @@ export default defineComponent({
           endTime: null
         }
       }
+    },
+    // vip 结束时间
+    vipEndTime() {
+      const vipVal = (this.item.activityList || []).find(item => {
+        return this.item.orderType === item.goodType
+      })
+      let endTime = this.item.endTime
+      if(vipVal){
+        if (vipVal.unit === 'MONTH') {
+          endTime = dayjs(endTime)
+            .add(1 * vipVal.goodsNum, 'month')
+            .toDate()
+        } else if (vipVal.unit === 'QUARTERLY') {
+          endTime = dayjs(endTime)
+            .add(3 * vipVal.goodsNum, 'month')
+            .toDate()
+        } else if (vipVal.unit === 'YEAR_HALF') {
+          endTime = dayjs(endTime)
+            .add(6 * vipVal.goodsNum, 'month')
+            .toDate()
+        } else if (vipVal.unit === 'YEAR') {
+          endTime = dayjs(endTime)
+            .add(1 * vipVal.goodsNum, 'year')
+            .toDate()
+        }
+      }
+      return dayjs(endTime).format('YYYY-MM-DD')
     }
   },
   watch: {
@@ -243,7 +270,7 @@ export default defineComponent({
                       <span>{item.orderType}会员生效时间</span>
                     </div>
                     <div class={styles.timer}>
-                      {this.startTime} 至 {item.endTime}
+                      {this.startTime} 至 {this.vipEndTime}
                     </div>
                   </div>
                 )