lex-xin 3 tháng trước cách đây
mục cha
commit
5770ec598f

+ 17 - 16
src/student/trade/tradeOrder.ts

@@ -207,7 +207,6 @@ export const formatOrderDetail = async (item: any, amount?: IAmount) => {
           goodName: item.goodName,
           num: item.goodNum,
           id: item.id,
-          discountPrice: item.discountPrice || 0,
           title: item.goodName || '',
           // 判断是否有优惠金额
           price: item.expectPrice,
@@ -341,20 +340,20 @@ export const getAlbumDetail = async (id: any) => {
 }
 
 /** 处理选择了畅学卡之后的显示 */
-const formatOrder = (orderDetailList: any, orderType: string) => {
-  let discountJson: any = {}
-  orderDetailList.forEach((item: any) => {
-    if(item.goodType === orderType) {
-      discountJson = item.discountJson ? JSON.parse(item.discountJson) : {}
-    }
-  })
-  orderDetailList.forEach((item: any) => {
-    if(item.goodType === "DISCOUNT") {
-      item.discountPrice = discountJson.DISCOUNT || 0
-    }
-  })
-  return orderDetailList
-}
+// const formatOrder = (orderDetailList: any, orderType: string) => {
+//   let discountJson: any = {}
+//   orderDetailList.forEach((item: any) => {
+//     if(item.goodType === orderType) {
+//       discountJson = item.discountJson ? JSON.parse(item.discountJson) : {}
+//     }
+//   })
+//   orderDetailList.forEach((item: any) => {
+//     if(item.goodType === "DISCOUNT") {
+//       item.discountPrice = discountJson.DISCOUNT || 0
+//     }
+//   })
+//   return orderDetailList
+// }
 
 const moveToEnd = () => {
   const orderList = orderStatus.orderObject.orderList || []
@@ -378,6 +377,7 @@ export const tradeOrder = async (result: any, callBack?: any) => {
     orderType,
     orderDetailList,
     couponAmount, // 优惠金额
+    cardDiscountPrice,
     discountPrice,
     paymentConfig,
     paymentVendor,
@@ -389,6 +389,7 @@ export const tradeOrder = async (result: any, callBack?: any) => {
   orderStatus.orderObject.orderDesc = orderDesc
   orderStatus.orderObject.actualPrice = actualPrice
   orderStatus.orderObject.orderNo = orderNo
+  orderStatus.orderObject.discountCardPrice = cardDiscountPrice
   orderStatus.orderObject.discountPrice = discountPrice
   orderStatus.orderObject.couponAmount = couponAmount
   orderStatus.orderObject.paymentConfig = {
@@ -410,7 +411,7 @@ export const tradeOrder = async (result: any, callBack?: any) => {
     })
     orderDetails[0] && (orderDetails[0].activityList = orderDetailsActivity)
 
-    formatOrder(orderDetails, orderType).forEach(async (item: any) => {
+    orderDetails.forEach(async (item: any) => {
       const child = await formatOrderDetail(item, {
         couponAmount,
         discountPrice,

+ 19 - 21
src/teacher/practice-class/timer/timer.tsx

@@ -19,8 +19,8 @@ export default defineComponent({
     return {
       startSetting: '08:00',  // 开始设置时间
       endSetting: '18:00', // 结束设置时间
-      freeMinutes: 5, // 空余时长
-      courseMinutes: 25, // // 课程时长
+      // freeMinutes: 5, // 空余时长
+      courseMinutes: 30, // // 课程时长
       timerObject: {},
       chargeTypeArr: {
         0: '否',
@@ -46,31 +46,29 @@ export default defineComponent({
     this.list = this.timerInit(
       this.startSetting,
       this.endSetting,
-      this.courseMinutes + this.freeMinutes || 30
+      this.courseMinutes || 30
     )
   },
   methods: {
     async _initFetch() {
       try {
         // 获取手续费和分钟数
-        const config = await request.get(
-          '/api-teacher/sysConfig/queryByParamNameList',
-          {
-            params: {
-              paramNames:
-                'practice_service_fee,course_start_setting,course_end_setting'
-            }
-          }
+        const { data } = await request.get(
+          '/api-teacher/teacher/queryTeacherTime'
         )
-        const configData = config.data || []
-        configData.forEach((item: any) => {
-          if (item.paramName === 'course_start_setting') {
-            this.startSetting = item.paramValue
-          }
-          if (item.paramName === 'course_end_setting') {
-            this.endSetting = item.paramValue
-          }
-        })
+        this.startSetting = data.startTime ? data.startTime: this.startSetting
+        this.endSetting = data.endTime ? data.endTime: this.endSetting
+        this.courseMinutes = data.intervalTime  ? data.intervalTime: this.courseMinutes
+        
+        // const configData = config.data || []
+        // configData.forEach((item: any) => {
+        //   if (item.paramName === 'course_start_setting') {
+        //     this.startSetting = item.paramValue
+        //   }
+        //   if (item.paramName === 'course_end_setting') {
+        //     this.endSetting = item.paramValue
+        //   }
+        // })
   
         // 获取课程设置
         const setting = await request.get('/api-teacher/teacherFreeTime/get')
@@ -183,7 +181,7 @@ export default defineComponent({
             status = true
             weekList[weekType[j]].push({
               startTime: dayjs(times.startTime, 'HH:mm').format('HH:mm:ss'),
-              endTime: dayjs(times.endTime, 'HH:mm').subtract(this.freeMinutes, 'minute').format('HH:mm:ss')
+              endTime: dayjs(times.endTime, 'HH:mm').format('HH:mm:ss')
             })
           }
         })

+ 55 - 18
src/views/order-detail/add-discount/index.tsx

@@ -1,4 +1,4 @@
-import { defineComponent, onMounted, reactive, ref } from 'vue'
+import { defineComponent, onMounted, reactive, ref, watch } from 'vue'
 import styles from './index.module.less'
 import { Cell, CellGroup, Checkbox, Icon, Image } from 'vant'
 import activeButtonIcon from '@common/images/icon_checkbox.png'
@@ -30,16 +30,23 @@ export default defineComponent({
       type: String,
       default: ''
     },
+    orderGoodsType: {
+      type: Array,
+      default: () => []
+    },
     /** 实际需要支付金额 */
     actualPrice: {
       type: Number,
       default: 0
     }
   },
-  emits: ['confirm'],
+  /** confirm 选择畅学卡, confirmOnlyDiscount 在有效期内,直接抵扣  */
+  emits: ['confirm', 'confirmOnlyDiscount'],
   setup(props, { emit }) {
-    //
+    // 是否显示畅学卡
     const isDisplay = ref(false)
+    const isDiscountApply = ref(false) // 畅学卡是否在有效期内
+    const productType = ref<any[]>([])
     const checked = ref(false)
     const params = reactive({
       discountPrice: 0 as any, // 优惠的金额,
@@ -54,15 +61,18 @@ export default defineComponent({
       vipType: 'DISCOUNT'
     })
 
+    // watch(() => props.orderGoodsType, () => {
+    //   console.log('watch ---- ')
+    //   productChange()
+    // })
+
     // 格式化显示
     const formatShowTime = () => {
-      console.log(props.actualPrice, 'actualPrice')
       if(checked.value) {
         params.discountPrice = (
           props.actualPrice -
           (props.actualPrice * discountDetail.value.discountRate / 100)
         ).toFixed(2)
-        // discountEndTime
         const users = state.user.data
         const startTime = users.discountEndTime || new Date()
         let endTime = dayjs(new Date()).format('YYYY-MM-DD')
@@ -96,6 +106,29 @@ export default defineComponent({
       })
     }
 
+    const onDiscountChange2 = () => {
+      checked.value = true
+      formatShowTime()
+
+      emit("confirmOnlyDiscount", {
+        checked: checked.value,
+        discountPrice: params.discountPrice,
+        ...discountDetail.value
+      })
+    }
+
+    const productChange = (productType) => {
+      // 判断是否需要购买畅学卡
+      let status = false
+      props.orderGoodsType.forEach((item: any) => {
+        
+        if (productType.includes(item)) {
+          status = true
+        }
+      })
+      isDisplay.value = status
+    }
+
     const __init = async () => {
       const { data } = await request.get(
         `${state.platformApi}/memberPriceSettings/getDiscount`
@@ -108,11 +141,16 @@ export default defineComponent({
         vipType: data.vipType
       }
       const productType = data.productType ? data.productType.split(',') : []
-      // 判断是否需要购买畅学卡
-      if (productType.includes(props.orderType)) {
-        isDisplay.value = true
-      } else {
-        isDisplay.value = false
+      productType.value = productType
+      productChange(productType)
+
+      const users = state.user.data
+      const nowTime = dayjs()
+      const endTime = users.discountEndTime || new Date()
+      console.log(endTime, 'endTime', users, nowTime)
+      if(dayjs(nowTime).isBefore(dayjs(endTime))) {
+        isDiscountApply.value = true
+        onDiscountChange2()
       }
     }
 
@@ -120,7 +158,7 @@ export default defineComponent({
     return () =>
       isDisplay.value ? (
         <div class={styles.addDiscount}>
-          <CellGroup class={['mb12', styles.cellGroup]} border={false}>
+          {!isDiscountApply.value ? <><CellGroup class={['mb12', styles.cellGroup]} border={false}>
             <Cell
               center
               class={styles.selectDiscount}
@@ -174,7 +212,6 @@ export default defineComponent({
           </CellGroup>
 
           {checked.value ? (
-            <>
               <CellGroup class={['mb12', styles.cellGroup]} border={false}>
                 <Cell
                   center
@@ -192,7 +229,11 @@ export default defineComponent({
                   }}
                 />
               </CellGroup>
-              <CellGroup class={['mb12', styles.cellGroup]} border={false}>
+          ) : (
+            ''
+          )}</> : ''}
+
+          {checked.value || isDiscountApply.value ? <CellGroup class={['mb12', styles.cellGroup]} border={false}>
                 <Cell
                   center
                   v-slots={{
@@ -206,11 +247,7 @@ export default defineComponent({
                     )
                   }}
                 />
-              </CellGroup>
-            </>
-          ) : (
-            ''
-          )}
+              </CellGroup> : ''}
         </div>
       ) : (
         ''

+ 37 - 0
src/views/order-detail/index.module.less

@@ -158,3 +158,40 @@
     line-height: 22px;
   }
 }
+
+.cellGroup {
+  border-radius: 10px;
+  overflow: hidden;
+.timerTitle {
+  display: flex;
+  align-items: center;
+  // font-size: 14px;
+  // font-weight: 500;
+  // color: #333333;
+
+  color: var(--van-cell-text-color) !important;
+  font-size: var(--van-cell-font-size) !important;
+  line-height: var(--van-cell-line-height) !important;
+  line-height: 20px;
+  padding-right: 12px;
+}
+
+.timer {
+  font-size: 14px;
+  font-weight: 500;
+  color: #FE2451;
+  line-height: 20px;
+}
+
+.timerCell {
+  display: flex;
+  align-items: center;
+  justify-content: space-between;
+
+  // span {
+  //   font-size: 16px;
+  //   font-weight: 600;
+  //   color: #131415;
+  // }
+}
+}

+ 51 - 2
src/views/order-detail/index.tsx

@@ -1,5 +1,5 @@
 import ColProtocol from '@/components/col-protocol'
-import { Button, Dialog, Popup, Toast } from 'vant'
+import { Button, Cell, CellGroup, Dialog, Popup, Toast } from 'vant'
 import ColPopup from '@/components/col-popup'
 import { defineComponent } from 'vue'
 import { postMessage } from '@/helpers/native-message'
@@ -56,6 +56,7 @@ export default defineComponent({
       dialogBtnText: '确定',
       dialogType: 'back' as 'back' | 'refresh',
       orderType: query.orderType as string,
+      orderGoodsType: [],
       recomUserId: query.recomUserId, // 推荐人id
       activityId: query.activityId, // 活动编号
       id: query.id,
@@ -109,7 +110,7 @@ export default defineComponent({
     },
     countDiscountPrice() {
       const orderObject = orderStatus.orderObject
-      return orderObject.couponAmount || orderObject.couponDiscountPrice + orderObject.discountCardPrice
+      return orderObject.couponAmount || (orderObject.couponDiscountPrice + orderObject.discountCardPrice + orderObject.discountCardPrice).toFixed(2)
     }
   },
   async mounted() {
@@ -146,6 +147,17 @@ export default defineComponent({
       }
     }
 
+    // 初始化所有商品的类型
+    const orderList = orderStatus.orderObject.orderList || []
+    const tempGoodsType: any = []
+    orderList.forEach((order: any) => {
+      tempGoodsType.push(order.orderType)
+    })
+    this.orderGoodsType = tempGoodsType
+
+    console.log(this.orderGoodsType, 'orderGoodsType')
+
+
     await this.getOrderPayType()
 
     this.orderAmount = orderStatus.orderObject.actualPrice || 0
@@ -594,6 +606,23 @@ export default defineComponent({
               <AddDiscount
                 actualPrice={this.orderAmount}
                 orderType={this.orderType}
+                orderGoodsType={this.orderGoodsType}
+                onConfirmOnlyDiscount={(item: {
+                  checked: boolean
+                  id: number | null
+                  salePrice: number
+                  discountRate: number
+                  discountPrice: number | string
+                  vipType: string
+                }) => {
+                  this.orderPrice = Number(
+                    (
+                      Number(this.orderAmount) -
+                      Number(item.discountPrice) -
+                      Number(orderStatus.orderObject.couponDiscountPrice)
+                    ).toFixed(2)
+                  )
+                }}
                 onConfirm={(item: {
                   checked: boolean
                   id: number | null
@@ -643,6 +672,26 @@ export default defineComponent({
               ''
             )}
 
+            {/* 只做显示用 - 不参与逻辑 */}
+            {state.platformType === 'STUDENT' &&
+              !this.dataLoading &&
+              this.disabledCoupon && orderStatus.orderObject.discountCardPrice > 0 ? <CellGroup class={['mb12', styles.cellGroup]} border={false}>
+              <Cell
+                center
+                v-slots={{
+                  title: () => (
+                    <div class={styles.timerCell}>
+                      <div class={styles.timerTitle}>
+                        <span>畅学卡优惠</span>
+                      </div>
+                      <div class={styles.timer}>-¥{(this as any).$filters.moneyFormat(orderStatus.orderObject.discountCardPrice)}</div>
+                    </div>
+                  )
+                }}
+              />
+            </CellGroup> : '' }
+        
+
             {/* 优惠券使用 */}
             {!this.dataLoading && (
               <UseCoupon

+ 2 - 2
src/views/order-detail/order-discount/index.tsx

@@ -111,7 +111,7 @@ export default defineComponent({
           />
         </CellGroup>
 
-        {item.discountPrice && item.discountPrice > 0 ? <CellGroup class={['mb12', styles.cellGroup]} border={false}>
+        {/* {item.discountPrice && item.discountPrice > 0 ? <CellGroup class={['mb12', styles.cellGroup]} border={false}>
           <Cell
             center
             v-slots={{
@@ -125,7 +125,7 @@ export default defineComponent({
               )
             }}
           />
-        </CellGroup> : ''}
+        </CellGroup> : ''} */}
         
       </div>
       // 视频课

+ 1 - 1
src/views/trade/trade-detail.tsx

@@ -208,7 +208,7 @@ export default defineComponent({
                           {(this as any).$filters.moneyFormat(item.expectPrice)}
                         </span>
-                        <span class={styles.num}>x{1}</span>
+                        <span class={styles.num}>x{item.goodNum}</span>
                       </div>
                     )
                   }}