Forráskód Böngészése

Merge branch 'online' of http://git.dayaedu.com/lex/h5-colexiu into online

skyblued 3 éve
szülő
commit
aec1ef26c9

+ 1 - 1
src/components/col-share/code-down-load.tsx

@@ -13,7 +13,7 @@ export default defineComponent({
     }
   },
   mounted() {
-    console.log(this.shareUrl, 'this.shareUrl')
+    // console.log(this.shareUrl, 'this.shareUrl')
     // const canvas = document.getElementById('canvas')
     const canvas = this.$refs.canvas
     QRCode.toCanvas(

+ 31 - 2
src/components/col-share/index.tsx

@@ -26,7 +26,9 @@ export default defineComponent({
     return {
       swiperIndex: 0,
       image: null as any,
-      codeUrl: ''
+      codeUrl: '',
+      shareLoading: false,
+      saveLoading: false
     }
   },
   async mounted() {
@@ -45,6 +47,11 @@ export default defineComponent({
   },
   methods: {
     async onSaveImg() {
+      // 判断是否在保存中...
+      if (this.saveLoading) {
+        return
+      }
+      this.saveLoading = true
       const container: any = document.getElementById(
         `share-preview-container${this.swiperIndex}`
       )
@@ -60,6 +67,9 @@ export default defineComponent({
             message: '图片生成中...',
             forbidClick: true
           })
+          setTimeout(() => {
+            this.saveLoading = false
+          }, 100)
           const res = await promisefiyPostMessage({
             api: 'savePicture',
             content: {
@@ -74,9 +84,15 @@ export default defineComponent({
         })
         .catch(() => {
           Toast.clear()
+          this.saveLoading = false
         })
     },
     async shareShow() {
+      // 判断是否在分享中...
+      if (this.shareLoading) {
+        return
+      }
+      this.shareLoading = true
       const container: any = document.getElementById(
         `share-preview-container${this.swiperIndex}`
       )
@@ -90,6 +106,9 @@ export default defineComponent({
           this.image = url
 
           const image = this.image
+          setTimeout(() => {
+            this.shareLoading = false
+          }, 100)
           if (image) {
             postMessage(
               {
@@ -115,6 +134,7 @@ export default defineComponent({
         })
         .catch(() => {
           Toast.clear()
+          this.shareLoading = false
         })
     }
   },
@@ -188,12 +208,21 @@ export default defineComponent({
             </div>
 
             <div class={['btnGroup', styles.shareGroupBtn]}>
-              <Button type="primary" plain round onClick={this.onSaveImg}>
+              <Button
+                type="primary"
+                plain
+                round
+                loading={this.saveLoading}
+                loadingText="保存中"
+                onClick={this.onSaveImg}
+              >
                 保存图片
               </Button>
               <Button
                 type="primary"
                 round
+                loading={this.shareLoading}
+                loadingText="分享中"
                 onClick={() => {
                   this.shareShow()
                 }}

+ 1 - 1
src/components/col-share/share-item.tsx

@@ -66,7 +66,7 @@ export default defineComponent({
     // '@base@tag=imgscale&m=0&w=80&et=1&eth=100&etw=100&etc=cccccc'
     // ?time= +
     // new Date().valueOf()
-    console.log(this.heardUrl, 'heardUrl')
+    // console.log(this.heardUrl, 'heardUrl')
   },
   render() {
     return (

+ 8 - 4
src/student/trade/tradeOrder.ts

@@ -11,7 +11,7 @@ const apiSuffix =
 // VIDEO: '视频课',
 // VIP: '开通会员',
 // MUSIC: '单曲点播'
-export const formatOrderDetail = async (item: any) => {
+export const formatOrderDetail = async (item: any, couponAmount?: number) => {
   const type = item.goodType
   let tempList: any = {}
 
@@ -88,7 +88,10 @@ export const formatOrderDetail = async (item: any) => {
             goodName: item.goodName,
             id: item.id,
             title: memberType[res.period] || '',
-            price: res.salePrice || item.actualPrice,
+            // 判断是否有优惠金额
+            price: couponAmount
+              ? Number((res.salePrice - couponAmount).toFixed(2))
+              : res.salePrice || item.actualPrice,
             startTime: dayjs(res.startTime).format('YYYY-MM-DD'),
             endTime: dayjs(res.endTime).format('YYYY-MM-DD')
           }
@@ -204,7 +207,8 @@ export const tradeOrder = (result: any, callBack?: any) => {
     orderDesc,
     orderName,
     orderType,
-    orderDetailList
+    orderDetailList,
+    couponAmount // 优惠金额
   } = result
   orderStatus.orderObject.orderType = orderType
   orderStatus.orderObject.orderName = orderName
@@ -215,7 +219,7 @@ export const tradeOrder = (result: any, callBack?: any) => {
   orderStatus.orderObject.orderList = []
   try {
     orderDetailList.forEach(async (item: any) => {
-      await formatOrderDetail(item)
+      await formatOrderDetail(item, couponAmount)
     })
     callBack && callBack()
   } catch {

BIN
src/teacher/share-page/images/icon_discount.png


+ 1 - 0
src/teacher/share-page/share-mall/index.tsx

@@ -23,6 +23,7 @@ import { shareCall } from '../share'
 import { state } from '@/state'
 import qs from 'query-string'
 import { getAssetsHomeFile } from '../share-video'
+import { postMessage } from '@/helpers/native-message'
 
 export default defineComponent({
   name: 'goods-detail',

+ 5 - 0
src/teacher/share-page/share-music-sheet/index.module.less

@@ -60,6 +60,11 @@
       color: #6a6a6a;
       line-height: 17px;
     }
+    .discount {
+      height: 18px;
+      width: auto;
+      margin-top: 8px;
+    }
   }
 }
 

+ 20 - 0
src/teacher/share-page/share-music-sheet/index.tsx

@@ -7,6 +7,7 @@ import { postMessage } from '@/helpers/native-message'
 
 import iconMusic from '../images/icon_music.png'
 import iconCert from '../images/icon-cert.png'
+import iconDiscount from '../images/icon_discount.png'
 import iconTeacher from '@/common/images/icon_teacher.png'
 import request from '@/helpers/request'
 
@@ -17,6 +18,8 @@ export default defineComponent({
     return {
       id: query.id,
       recomUserId: query.recomUserId, // 分享人编号
+      activityId: query.activityId || 0, // 专属优惠Id
+      discounts: 0,
       musicSheet: {} as any,
       teacherName: ''
     }
@@ -31,6 +34,18 @@ export default defineComponent({
       })
       this.musicSheet = res.data.musicSheet || {}
       this.teacherName = res.data.name || ''
+
+      // 判断是否有活动编号
+      if (this.activityId) {
+        const discountObj = await request.post(
+          `/api-student/open/activity/state/${this.activityId}`,
+          {
+            data: {}
+          }
+        )
+
+        this.discounts = discountObj.data.check || 0
+      }
     } catch {
       //
     }
@@ -45,6 +60,8 @@ export default defineComponent({
         query: {
           id: this.id,
           recomUserId: this.recomUserId,
+          activityId: this.activityId,
+          discounts: this.discounts,
           client: browserInfo.isTeacher ? 'teacher' : 'student',
           behaviorId
         }
@@ -81,6 +98,9 @@ export default defineComponent({
             <div>
               <h2>{this.musicSheet.musicSheetName}</h2>
               <p>作曲人: {this.musicSheet.composer}</p>
+              {this.discounts == 1 && (
+                <img src={iconDiscount} class={styles.discount} />
+              )}
             </div>
           </div>
           <Cell

+ 3 - 3
src/views/live-class/index.tsx

@@ -107,9 +107,9 @@ export default defineComponent({
             ? '/api-student/courseGroup/queryPageCourseGroup'
             : '/api-teacher/courseGroup/queryPageCourseGroup'
         // 处理搜索,老师端分享用
-        if (state.platformType === 'TEACHER') {
-          params.myself = false
-        }
+        // if (state.platformType === 'TEACHER') {
+        params.myself = false
+        // }
         const res = await request.post(url, {
           data: {
             ...params

BIN
src/views/member-center/images/discount_bg.png


BIN
src/views/member-center/images/icon_discount.png


BIN
src/views/member-center/images/icon_gift.png


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

@@ -154,7 +154,7 @@
     position: relative;
     user-select: none;
     box-sizing: content-box;
-    padding-top: 10px;
+    padding-top: 16px;
     padding-bottom: 10px;
     margin-bottom: 10px;
   }
@@ -259,3 +259,55 @@
     }
   }
 }
+
+.memberDiscount {
+  margin-top: 16px;
+  position: relative;
+  background: url('./images/discount_bg.png') no-repeat center;
+  background-size: contain;
+  display: flex;
+  align-items: center;
+  height: 44px;
+  font-size: 16px;
+  color: #ff7100;
+  line-height: 18px;
+
+  .discountAvatar {
+    margin-left: 15px;
+    width: 36px;
+    height: 36px;
+    border-radius: 50%;
+    overflow: hidden;
+    border: 1px solid #ffaf59;
+  }
+
+  .discountName {
+    padding-left: 30px;
+    max-width: 200px;
+    white-space: nowrap;
+    overflow: hidden;
+    text-overflow: ellipsis;
+  }
+
+  .discountGift {
+    position: absolute;
+    right: 26px;
+    top: 7px;
+    width: 29px;
+    height: 29px;
+  }
+}
+
+.discountItem {
+  height: 14px;
+  padding-bottom: 2px;
+  img {
+    height: 100%;
+  }
+}
+
+.discountBuy {
+  height: 18px;
+  padding-bottom: 0;
+  margin-left: 8px;
+}

+ 65 - 40
src/views/member-center/index.tsx

@@ -5,6 +5,9 @@ import styles from './index.module.less'
 import request from '@/helpers/request'
 import { state } from '@/state'
 import iconStudent from '@common/images/icon_student.png'
+import iconTeacher from '@common/images/icon_teacher.png'
+import iconGift from './images/icon_gift.png'
+import iconDiscount from './images/icon_discount.png'
 import { orderStatus } from '@/views/order-detail/orderStatus'
 import dayjs from 'dayjs'
 import { memberType } from '@/constant'
@@ -19,7 +22,10 @@ export const getAssetsHomeFile = (fileName: string) => {
 export default defineComponent({
   name: 'MemberCenter',
   data() {
+    const query = this.$route.query
     return {
+      activityId: query.activityId,
+      recomUserId: query.recomUserId,
       apiSuffix:
         state.platformType === 'STUDENT' ? '/api-student' : '/api-teacher',
       agreeStatus: false,
@@ -29,6 +35,11 @@ export default defineComponent({
       params: {
         page: 1,
         rows: 20
+      },
+      discountTeacher: {
+        avatar: '',
+        discount: 0,
+        username: ''
       }
     }
   },
@@ -61,10 +72,17 @@ export default defineComponent({
       const setting = await request.post(
         `${this.apiSuffix}/memberPriceSettings/list`,
         {
-          data: {}
+          data: {
+            activityId: Number(this.activityId),
+            userId: this.recomUserId
+          }
         }
       )
-      const settingResult = setting.data || []
+      const { list, ...more } = setting.data
+      this.discountTeacher = {
+        ...more
+      }
+      const settingResult = list || []
       const settingList: any = []
       settingResult.forEach((item: any) => {
         const tempItem = {
@@ -73,6 +91,8 @@ export default defineComponent({
           originalPrice: item.originalPrice,
           period: item.period,
           id: item.id,
+          discount: item.discount,
+          discountPrice: item.discountPrice,
           status: false
         }
 
@@ -85,10 +105,22 @@ export default defineComponent({
         settingList[0].status = true
         this.selectMember = settingList[0]
       }
+      console.log(settingList)
       this.memberList = settingList
     } catch {}
   },
   methods: {
+    calcSalePrice(item: any) {
+      // discount
+
+      if (item.discount === 1) {
+        const tempPrice = Number(
+          (item.salePrice - item.discountPrice).toFixed(2)
+        )
+        return tempPrice >= 0 ? tempPrice : 0
+      }
+      return item.salePrice
+    },
     onSubmit() {
       const member: any = this.selectMember
       // 判断是否有会员
@@ -106,12 +138,12 @@ export default defineComponent({
         endTime = dayjs(startTime).add(1, 'year').toDate()
       }
 
-      const query = this.$route.query
       orderStatus.orderObject.orderType = 'VIP'
       orderStatus.orderObject.orderName = '小酷Ai' + member.title
       orderStatus.orderObject.orderDesc = '小酷Ai' + member.title
-      orderStatus.orderObject.actualPrice = member.salePrice
-      orderStatus.orderObject.recomUserId = query.recomUserId
+      orderStatus.orderObject.actualPrice = this.calcSalePrice(member)
+      orderStatus.orderObject.recomUserId = this.recomUserId
+      orderStatus.orderObject.activityId = this.activityId
       orderStatus.orderObject.orderNo = ''
       orderStatus.orderObject.orderList = [
         {
@@ -119,10 +151,10 @@ export default defineComponent({
           goodsName: '小酷Ai' + member.title,
           id: member.id,
           title: member.title,
-          price: member.salePrice,
+          price: this.calcSalePrice(member),
           startTime: dayjs(startTime).format('YYYY-MM-DD'),
           endTime: dayjs(endTime).format('YYYY-MM-DD'),
-          recomUserId: query.recomUserId
+          recomUserId: this.recomUserId
         }
       ]
       this.$router.push({
@@ -192,6 +224,22 @@ export default defineComponent({
               会员<span>VIP</span>
             </div>
 
+            {/* 判断是否有推荐老师 */}
+            {this.discountTeacher.discount == 1 && (
+              <div class={styles.memberDiscount}>
+                <Image
+                  src={this.discountTeacher.avatar || iconTeacher}
+                  class={styles.discountAvatar}
+                />
+
+                <span class={styles.discountName}>
+                  {this.discountTeacher.username}老师的专属优惠~
+                </span>
+
+                <Image src={iconGift} class={styles.discountGift} />
+              </div>
+            )}
+
             <div class={styles['system-list']}>
               {this.memberList.map((item: any) => (
                 <div
@@ -204,47 +252,19 @@ export default defineComponent({
                     this.selectMember = item
                   }}
                 >
+                  <div class={styles.discountItem}>
+                    {item.discount == 1 && <img src={iconDiscount} />}
+                  </div>
                   <p class={styles.title}>{item.title}</p>
                   <p class={styles.price}>
                     <span>¥</span>
-                    {moneyFormat(item.salePrice, '0,0[.]00')}
+                    {moneyFormat(this.calcSalePrice(item), '0,0[.]00')}
                   </p>
                   <del class={styles.originalPrice}>
                     ¥{moneyFormat(item.originalPrice, '0,0[.]00')}
                   </del>
                 </div>
               ))}
-              {/* <div class={[styles['system-item'], styles.active]}>
-                <p class={styles.title}>月度会员</p>
-                <p class={styles.price}>
-                  <span>¥</span>199
-                </p>
-                <del class={styles.originalPrice}>¥199</del>
-              </div>
-
-              <div class={styles['system-item']}>
-                <p class={styles.title}>月度会员</p>
-                <p class={styles.price}>
-                  <span>¥</span>199
-                </p>
-                <del class={styles.originalPrice}>¥199</del>
-              </div>
-
-              <div class={styles['system-item']}>
-                <p class={styles.title}>月度会员</p>
-                <p class={styles.price}>
-                  <span>¥</span>199
-                </p>
-                <del class={styles.originalPrice}>¥199</del>
-              </div>
-
-              <div class={styles['system-item']}>
-                <p class={styles.title}>月度会员</p>
-                <p class={styles.price}>
-                  <span>¥</span>199
-                </p>
-                <del class={styles.originalPrice}>¥199</del>
-              </div> */}
             </div>
           </div>
 
@@ -284,10 +304,15 @@ export default defineComponent({
               <span class={styles.priceUnit}>¥</span>
               <span class={styles.priceNum}>
                 {(this as any).$filters.moneyFormat(
-                  this.selectMember?.salePrice || 0
+                  this.calcSalePrice(this.selectMember) || 0
                 )}
               </span>
             </div>
+            {this.selectMember?.discount == 1 && (
+              <div class={[styles.discountItem, styles.discountBuy]}>
+                <img src={iconDiscount} />
+              </div>
+            )}
           </div>
           <Button
             color="linear-gradient(220deg, #DFA164 0%, #FAC87E 100%)"

+ 3 - 3
src/views/music/album/index.tsx

@@ -30,9 +30,9 @@ export default defineComponent({
       tempParams.platform =
         state.platformType === 'STUDENT' ? 'ios-student' : 'ios-teacher'
     }
-    if (state.platformType === 'TEACHER') {
-      tempParams.myself = false
-    }
+    // if (state.platformType === 'TEACHER') {
+    tempParams.myself = false
+    // }
     console.log({ ...defauleParams })
     const params = reactive({
       search: (route.query.search as string) || '',

+ 3 - 3
src/views/music/list/index.tsx

@@ -77,9 +77,9 @@ export default defineComponent({
         idAndName: params.search,
         createBy: teacherId
       }
-      if (state.platformType === 'TEACHER') {
-        tempParams.myself = false
-      }
+      // if (state.platformType === 'TEACHER') {
+      tempParams.myself = false
+      // }
 
       try {
         const res = await request.post(`${apiSuffix.value}/music/sheet/list`, {

+ 16 - 1
src/views/music/list/item.module.less

@@ -95,6 +95,7 @@
 }
 
 .shareMate {
+  position: relative;
   margin-top: 50px;
   display: flex;
   flex: 1;
@@ -102,7 +103,7 @@
   padding: 11px 12px;
   background: #ffffff;
   border-radius: 10px;
-  border: 1px solid #2dc7aa;
+  // border: 1px solid #2dc7aa;
   .icon {
     width: 36px;
     height: 36px;
@@ -123,4 +124,18 @@
       line-height: 17px;
     }
   }
+
+  .tagDiscount {
+    position: absolute;
+    top: -26px;
+    left: 15px;
+    padding: 2px 10px 1px;
+    height: 23px;
+    background: linear-gradient(180deg, #ffb635 0%, #ff4e18 100%);
+    border-radius: 8px 8px 0px 0px;
+    font-size: 14px;
+    font-weight: 600;
+    color: #ffffff;
+    line-height: 20px;
+  }
 }

+ 27 - 14
src/views/music/list/item.tsx

@@ -54,18 +54,36 @@ export default defineComponent({
 
     const shareStatus = ref(false)
     const shareUrl = ref('')
+    const shareDiscount = ref(0)
     // console.log(data)
-    const onShare = (evt: MouseEvent) => {
+    const onShare = async (evt: MouseEvent) => {
       evt.stopPropagation()
+
+      try {
+        const res = await request.post('/api-teacher/open/musicShareProfit', {
+          data: {
+            bizId: data.id,
+            userId: state.user.data?.userId
+          }
+        })
+        let url =
+          location.origin +
+          `/accompany/colexiu-share.html?id=${data.id}&recomUserId=${state.user.data?.userId}`
+        // 判断是否有活动
+        if (res.data.discount === 1) {
+          url += `&activityId=${res.data.activityId}`
+        }
+        shareDiscount.value = res.data.discount || 0
+        shareUrl.value = url
+        shareStatus.value = true
+        return
+      } catch {}
+
       // if (!shareStatus.value) {
       //   Toast('暂无分享地址')
       //   return
       // }
       // https://dev.colexiu.com/accompany/colexiu-share.html?id=2500&recomUserId=1
-      shareUrl.value =
-        location.origin +
-        `/accompany/colexiu-share.html?id=${data.id}&recomUserId=${state.user.data?.userId}`
-      shareStatus.value = true
     }
     return () => (
       <div>
@@ -148,15 +166,10 @@ export default defineComponent({
             shareType="music"
           >
             <div class={styles.shareMate}>
-              {/* <Image
-                src={
-                  data.titleImg +
-                    `@base@tag=imgScale&h=80&w=80&m=1?t=${+new Date()}` ||
-                  MusicIcon
-                }
-                round
-                class={styles.icon}
-              /> */}
+              {shareDiscount.value === 1 && (
+                <div class={styles.tagDiscount}>专属优惠</div>
+              )}
+
               <img
                 class={styles.icon}
                 crossorigin="anonymous"

+ 3 - 3
src/views/music/songbook/album.tsx

@@ -20,9 +20,9 @@ export default defineComponent({
     }
     const apiSuffix =
       tempState.platformType === 'STUDENT' ? '/api-student' : '/api-teacher'
-    if (tempState.platformType === 'TEACHER') {
-      params.myself = false
-    }
+    // if (tempState.platformType === 'TEACHER') {
+    params.myself = false
+    // }
     const { isLoading, state } = useAsyncState(
       request.post(`${apiSuffix}/music/album/list`, {
         data: {

+ 3 - 3
src/views/music/songbook/list.tsx

@@ -23,9 +23,9 @@ export default defineComponent({
     }
     const apiSuffix =
       tempState.platformType === 'STUDENT' ? '/api-student' : '/api-teacher'
-    if (tempState.platformType === 'TEACHER') {
-      params.myself = false
-    }
+    // if (tempState.platformType === 'TEACHER') {
+    params.myself = false
+    // }
     const { isLoading, state } = useAsyncState(
       request.post(`${apiSuffix}/music/sheet/list`, {
         data: {

+ 4 - 0
src/views/order-detail/index.tsx

@@ -36,6 +36,7 @@ export default defineComponent({
       loading: false, // 是否加载中,为了处理0元订单()
       orderType: query.orderType,
       recomUserId: query.recomUserId, // 推荐人id
+      activityId: query.activityId, // 活动编号
       id: query.id,
       agreeStatus: false,
       popupShow: false,
@@ -125,6 +126,7 @@ export default defineComponent({
         orderStatus.orderObject.orderDesc = item.musicSheetName
         orderStatus.orderObject.actualPrice = item.musicPrice
         orderStatus.orderObject.recomUserId = this.recomUserId
+        orderStatus.orderObject.activityId = this.activityId
         // 判断当前订单是否在支付中
         if (['WAIT_PAY', 'PAYING'].includes(item.orderStatus)) {
           orderStatus.orderObject.orderNo = item.orderNo
@@ -194,6 +196,7 @@ export default defineComponent({
             orderType: orderObject.orderType,
             actualPrice: orderObject.actualPrice || 0,
             recomUserId: orderObject.recomUserId,
+            activityId: orderObject.activityId,
             orderInfos: [...orderInfos()]
           }
         })
@@ -234,6 +237,7 @@ export default defineComponent({
         orderDesc: '',
         orderType: '',
         recomUserId: null as any,
+        activityId: '',
         orderList: []
       }
     }

+ 3 - 1
src/views/order-detail/orderStatus.ts

@@ -35,7 +35,8 @@ export const orderStatus = reactive({
     orderDesc: '',
     orderType: '' as orderType,
     recomUserId: null as any,
-    orderList: [] as Array<any>
+    orderList: [] as Array<any>,
+    activityId: '' as any
   }
 })
 
@@ -117,6 +118,7 @@ export const onSubmitZero = async (callBack?: Function): Promise<void> => {
         orderType: orderObject.orderType,
         actualPrice: orderObject.actualPrice || 0,
         recomUserId: orderObject.recomUserId,
+        activityId: orderObject.activityId,
         orderInfos: [...orderInfos()]
       }
     })

+ 3 - 3
src/views/video-class/index.tsx

@@ -89,9 +89,9 @@ export default defineComponent({
             ? '/api-student/videoLesson/selectGroup'
             : '/api-teacher/videoLessonGroup/page'
         // 处理搜索,老师端分享用
-        if (state.platformType === 'TEACHER') {
-          params.myself = false
-        }
+        // if (state.platformType === 'TEACHER') {
+        params.myself = false
+        // }
         const res = await request.post(url, {
           data: {
             ...params