| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117 | 
							- import { memberType } from '@/constant'
 
- import request from '@/helpers/request'
 
- import { orderStatus } from '@/views/order-detail/orderStatus'
 
- import dayjs from 'dayjs'
 
- // LIVE: '直播课',
 
- // PRACTICE: '陪练课',
 
- // VIDEO: '视频课',
 
- // VIP: '开通会员',
 
- // MUSIC: '单曲点播'
 
- interface IAmount {
 
-   couponAmount: number
 
-   discountPrice: number
 
- }
 
- export const formatOrderDetail = async (item: any, amount?: IAmount) => {
 
-   const type = item.goodType
 
-   let tempList: any = {}
 
-   switch (type) {
 
-     case 'PINAO_ROOM':
 
-       {
 
-         try {
 
-           const res = await getPinaoDetail(item.bizId)
 
-           console.log('res', res)
 
-           tempList = {
 
-             orderType: item.goodType,
 
-             goodsName: item.goodName,
 
-             ...res
 
-           }
 
-         } catch (e: any) {
 
-           throw new Error(e.message)
 
-         }
 
-       }
 
-       break
 
-     case 'VIP':
 
-       try {
 
-         const res = await getVipDetail(item.id)
 
-         tempList = {
 
-           orderType: item.goodType,
 
-           goodName: item.goodName,
 
-           id: item.id,
 
-           title: memberType[res.period] || '',
 
-           // price: res.salePrice || item.actualPrice,
 
-           // 判断是否有优惠金额
 
-           price: amount?.couponAmount
 
-             ? Number(
 
-                 (
 
-                   res.salePrice -
 
-                   amount.couponAmount +
 
-                   amount.discountPrice
 
-                 ).toFixed(2)
 
-               )
 
-             : res.salePrice || item.actualPrice,
 
-           startTime: dayjs(res.startTime).format('YYYY-MM-DD'),
 
-           endTime: dayjs(res.endTime).format('YYYY-MM-DD')
 
-         }
 
-       } catch (e: any) {
 
-         throw new Error(e.message)
 
-       }
 
-       break
 
-   }
 
-   tempList.orderType = type
 
-   tempList.goodName = item.goodName
 
-   orderStatus.orderObject.orderList.push(tempList)
 
- }
 
- // 获取时长详情失败
 
- export const getPinaoDetail = async (id: any) => {
 
-   try {
 
-     const res = await request.get(`/api-teacher/pianoRoomSettings/detail/${id}`)
 
-     return res.data
 
-   } catch {
 
-     throw new Error('获取时长详情失败')
 
-   }
 
- }
 
- // 获取会员详情
 
- export const getVipDetail = async (id: any) => {
 
-   try {
 
-     const setting = await request.get('/api-teacher/vipCardRecord/detail/' + id)
 
-     return setting.data || []
 
-   } catch {
 
-     throw new Error('获取会员详情失败')
 
-   }
 
- }
 
- export const tradeOrder = (result: any, callBack?: any) => {
 
-   const {
 
-     orderNo,
 
-     actualPrice,
 
-     orderDesc,
 
-     orderName,
 
-     orderType,
 
-     orderDetailList,
 
-     couponAmount,
 
-     discountPrice
 
-   } = result
 
-   orderStatus.orderObject.orderType = orderType
 
-   orderStatus.orderObject.orderName = orderName
 
-   orderStatus.orderObject.orderDesc = orderDesc
 
-   orderStatus.orderObject.orderNo = orderNo
 
-   orderStatus.orderObject.actualPrice = actualPrice
 
-   orderStatus.orderObject.discountPrice = discountPrice
 
-   orderStatus.orderObject.orderList = []
 
-   console.log(result)
 
-   try {
 
-     orderDetailList.forEach(async (item: any) => {
 
-       await formatOrderDetail(item, {
 
-         couponAmount,
 
-         discountPrice
 
-       })
 
-     })
 
-     callBack && callBack()
 
-   } catch {
 
-     //
 
-   }
 
- }
 
 
  |