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

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

黄琪勇 1 год назад
Родитель
Сommit
5b9f63bedd

+ 10 - 3
src/components/col-header/index.module.less

@@ -2,12 +2,19 @@
   --van-font-weight-bold: 600;
 
   :global {
-
+    .van-nav-bar__left{
+      padding: 0 13px;
+    }
     .van-nav-bar__title,
     .van-icon {
       color: inherit;
     }
-
+    .van-nav-bar__title{
+      font-size: 18px;
+    }
+    .van-icon{
+      font-size: 24px;
+    }
     .van-nav-bar__right {
       &>div {
         line-height: 0;
@@ -27,4 +34,4 @@
   // :global(.van-nav-bar--fixed) {
   //   box-shadow: 10px 10px 10px var(--box-shadow-color);
   // }
-}
+}

+ 4 - 3
src/components/col-result/index.module.less

@@ -21,6 +21,7 @@
     }
 
     .van-empty__description {
+      margin-top: 8px;
       padding: 0 30px;
     }
   }
@@ -28,8 +29,8 @@
   .SMALL {
     :global {
       .van-empty__image {
-        width: 182px;
-        height: 161px;
+        width: 162px;
+        height: 143px;
       }
     }
   }
@@ -46,4 +47,4 @@
       }
     }
   }
-}
+}

+ 2 - 2
src/tenant/music/component/song/index.module.less

@@ -115,7 +115,7 @@
     }
 
     .title {
-      max-width: 165px;
+      max-width: 220px;
       font-size: 16px;
       font-weight: bold;
       color: #1a1a1a;
@@ -271,4 +271,4 @@
   height: 15px;
   margin-right: 5px;
   flex-shrink: 0;
-}
+}

+ 13 - 9
src/tenant/music/component/song/index.tsx

@@ -60,19 +60,19 @@ export default defineComponent({
     //   }
     // }
 
-    const list = computed(() => {
-      return props.list.map(n => {
-        // if (typeof n.paymentType === 'string')
-        //   n.paymentType = n.paymentType.split(',')
-        n.subjectNames = n.musicSubjectName
-        return { ...n }
-      })
-    })
+    // const list = computed(() => {
+    //   return props.list.map(n => {
+    //     // if (typeof n.paymentType === 'string')
+    //     //   n.paymentType = n.paymentType.split(',')
+    //     n.subjectNames = n.musicSubjectName
+    //     return { ...n }
+    //   })
+    // })
 
     return () => {
       return (
         <div class={styles.theSong}>
-          {list.value.map((n: any, index: number) => (
+          {props.list.map((n: any, index: number) => (
             <div class={styles.item} onClick={() => emit('detail', n)}>
               {props.showNumber && <div class={styles.num}>{index + 1}</div>}
               {props.showTitleImg && (
@@ -112,6 +112,10 @@ export default defineComponent({
                       n.subjectNames
                         ?.split(',')
                         .map((name: any) => <span>{name}</span>)}
+                    {n.musicSubjectName &&
+                      n.musicSubjectName
+                        ?.split(',')
+                        .map((name: any) => <span>{name}</span>)}
                     {n.musicSheetType === 'CONCERT' && <span>合奏</span>}
                   </div>
 

BIN
src/tenant/music/courseList/image/bg.png


+ 2 - 2
src/tenant/music/courseList/index.module.less

@@ -182,7 +182,7 @@
 
 .courseDialog {
   width: 305px;
-
+  box-sizing: border-box;
   :global {
     .van-dialog__header {
       // padding-top: 0;
@@ -300,7 +300,7 @@
   border-color: #dbdbdb;
 }
 .btnRight {
-  background: linear-gradient(270deg, #ff204b 0%, #fe5b71 100%);
+  background: #FE2451;
 }
 .finch {
   width: 150px;

+ 1 - 1
src/tenant/music/lessonCourseware/component/CourseItem/index.module.less

@@ -41,7 +41,7 @@
 
 .item {
   margin: 20px 0 0 0;
-  padding: 0 8px;
+  padding: 0 12px;
   width: 33.333%;
 
   .cover {

+ 1 - 1
src/tenant/music/lessonCourseware/index.module.less

@@ -126,7 +126,7 @@
 .courseItem.courseItem1 {
   background: initial;
   border: initial;
-  padding: 0 10px 20px;
+  padding: 0 4px 20px;
   :global {
     .courseItem:nth-child(1) {
       margin-top: 10px;

+ 3 - 0
src/tenant/music/lessonCourseware/index.tsx

@@ -108,6 +108,9 @@ export default defineComponent({
             rows: 20
           }
         })
+        if (params.subjectList?.length > 0 && res.data.pageNo === 1) {
+          return
+        }
         const result = (params.subjectList || []).concat(res.data?.rows || [])
         params.subjectList = result
         params.page = res.data.pageNo + 1

+ 2 - 2
src/tenant/music/music-detail/download.module.less

@@ -37,8 +37,8 @@
 
 .downloadBtn {
   box-shadow: 0px 2px 7px 0px rgba(45, 199, 170, 0.25);
-  font-size: 14px;
+  font-size: 16px;
   font-weight: 600;
   color: #ffffff;
   line-height: 20px;
-}
+}

+ 1 - 0
src/tenant/music/music-detail/new-index.module.less

@@ -349,6 +349,7 @@
   }
 
   .musicTitle {
+    padding-top: 4px;
     font-weight: 600;
     text-align: center;
     font-size: 16px;

+ 2 - 1
src/tenant/music/music-detail/new-index.tsx

@@ -414,6 +414,7 @@ export default defineComponent({
       }
     }
     onMounted(async () => {
+      postMessage({ api: 'setStatusBarTextColor', content: { statusBarTextColor: true } })
       await FetchList()
       const { height } = useRect(headers as any)
       const footer = useRect(footers as any)
@@ -427,9 +428,9 @@ export default defineComponent({
       window.addEventListener('message', showLoading)
     })
     onUnmounted(() => {
+      postMessage({ api: 'setStatusBarTextColor', content: { statusBarTextColor: false } })
       window.removeEventListener('message', showLoading)
     })
-
     const toggleFavorite = async () => {
       try {
         await request.post('/music/sheet/favorite/' + musicDetail.value?.id, {

BIN
src/tenant/music/train-tool/images/icon-timer.png


+ 30 - 22
src/tenant/music/train-tool/index.module.less

@@ -14,7 +14,6 @@
   background-size: cover;
 }
 
-
 .bgImg {
   position: absolute;
   left: 0;
@@ -51,7 +50,7 @@
 
   :global {
     .swiper {
-      --swiper-theme-color: #FE2451 !important;
+      --swiper-theme-color: #fe2451 !important;
       --swiper-pagination-bottom: 0px !important;
       --swiper-pagination-bullet-size: 6px !important;
       padding-bottom: 15px;
@@ -64,7 +63,7 @@
     }
 
     .swiper-pagination-bullet-active {
-      background-color: #FE2451;
+      background-color: #fe2451;
     }
 
     .swiper-container {
@@ -93,7 +92,6 @@
       width: 53%;
     }
 
-
     .swiper-slide-active,
     .swiper-slide-duplicate-active {
       transform: scale(1) !important;
@@ -107,8 +105,8 @@
     z-index: 11;
     font-size: 12px;
     font-weight: 500;
-    color: #FFFFFF;
-    background: linear-gradient(270deg, #FF7B57 0%, #FF3460 100%);
+    color: #ffffff;
+    background: linear-gradient(270deg, #ff7b57 0%, #ff3460 100%);
     border-radius: 0px 0px 0px 6px;
     padding: 3px 6px 2px;
   }
@@ -125,8 +123,6 @@
 
     --van-image-error-icon-size: 130px;
 
-
-
     &::after {
       content: '';
       position: absolute;
@@ -151,7 +147,11 @@
           top: 0;
           bottom: 0;
           width: 9px;
-          background: linear-gradient(270deg, rgba(0, 0, 0, 0.18) 0%, rgba(255, 255, 255, 0) 100%);
+          background: linear-gradient(
+            270deg,
+            rgba(0, 0, 0, 0.18) 0%,
+            rgba(255, 255, 255, 0) 100%
+          );
         }
       }
     }
@@ -202,7 +202,7 @@
   }
 
   .alumTitle {
-    padding: 0 16px;
+    padding: 0 20px;
     padding-bottom: 8px;
     font-size: 16px;
     font-weight: 600;
@@ -217,7 +217,6 @@
     text-align: center;
     min-height: 64px;
 
-
     .des {
       padding: 0 16px;
       font-size: 12px;
@@ -238,12 +237,11 @@
   font-size: 13px;
   padding: 0 12px;
 
-
   .albumTimer {
     display: flex;
     align-items: center;
     font-weight: 500;
-    color: #5E3314;
+    color: #5e3314;
     line-height: 1;
   }
 
@@ -253,7 +251,6 @@
     margin-right: 6px;
   }
 
-
   .originPrice {
     font-weight: 500;
     color: rgba(38, 38, 38, 0.4);
@@ -261,17 +258,17 @@
   }
 
   .currentPrice {
-    padding: 4px 7px;
+    padding: 3px 7px;
     border-radius: 20px;
     background: #262626;
-
     margin-left: 6px;
+    display: inline-block;
 
     span {
       font-weight: 500;
-      color: #FFE1AE;
+      color: #ffe1ae;
       line-height: 18px;
-      background: linear-gradient(180deg, #FFFFFF 0%, #FFC76C 100%);
+      background: linear-gradient(180deg, #ffffff 0%, #ffc76c 100%);
       -webkit-background-clip: text;
       -webkit-text-fill-color: transparent;
     }
@@ -292,6 +289,10 @@
   --van-cell-icon-size: 10px;
 
   :global {
+    .van-tabs__nav {
+      padding-left: 5px;
+      padding-right: 5px;
+    }
     .van-tab {
       font-size: 16px !important;
       margin-top: 15px;
@@ -301,17 +302,22 @@
     .van-tab--active {
       font-size: 16px !important;
       color: #131415;
+      font-weight: 600;
     }
 
     .van-tabs__line {
       width: 24px;
       height: 4px;
-      background: linear-gradient(90deg, #FF3C5E 0%, rgba(255, 118, 155,0.5) 100%) !important;
+      background: linear-gradient(
+        90deg,
+        #ff3c5e 0%,
+        rgba(255, 118, 155, 0.5) 100%
+      ) !important;
       border-radius: 36px 36px 0px 0px;
     }
 
     .van-tab--shrink {
-      padding: 0 12px 0 12px;
+      padding: 0 15px 0 15px;
     }
 
     .van-button--plain.van-button--primary {
@@ -322,14 +328,16 @@
       background-color: #fff;
     }
   }
-
   .alumnList {
     padding: 0 15px;
+    &.alumnListCourseware {
+      padding: 3px;
+    }
   }
 }
 
 .btnGroup {
-  border-top: 1px solid #F2F2F2;
+  border-top: 1px solid #f2f2f2;
   background-color: #fff;
   padding-top: 12px;
   padding-left: 25px;

+ 82 - 79
src/tenant/music/train-tool/index.tsx

@@ -1,4 +1,12 @@
-import { computed, defineComponent, onMounted, reactive, ref, watch } from 'vue'
+import {
+  computed,
+  defineComponent,
+  onMounted,
+  reactive,
+  ref,
+  watch,
+  nextTick
+} from 'vue'
 import {
   Image,
   Tabs,
@@ -40,8 +48,12 @@ import CourseItem from '../lessonCourseware/component/CourseItem'
 export default defineComponent({
   name: 'train-tool',
   setup() {
-    const subjectType = sessionStorage.getItem('tool-subject-type')
+    const sessionStorageToolSubject =
+      sessionStorage.getItem('tool-subject-type')
+    const toolSubject =
+      sessionStorageToolSubject && JSON.parse(sessionStorageToolSubject)
     sessionStorage.removeItem('tool-subject-type')
+
     const route = useRoute()
     const router = useRouter()
     const background = ref<string>('rgba(55, 205, 177, 0)')
@@ -50,7 +62,8 @@ export default defineComponent({
       details: {} as any,
       buy: route.query.buy as any,
       albumId: route.query.albumId || null,
-      activeTab: route.query.subjectType || 'SUBJECT',
+      activeTab:
+        toolSubject?.activeTab || route.query.subjectType || 'COURSEWARE', // 有缓存 默认用缓存,之后用请求头,最后默认
       loadingAlbum: false,
       loading: false,
       finished: false,
@@ -66,7 +79,8 @@ export default defineComponent({
       ablumStatus: false,
       heightV: 0,
       hasBuyStatus: true, // 是否能继续购买
-      albumList: [] as any // 专辑列表
+      albumList: [] as any, // 专辑列表
+      initialSlide: 0
     })
     const params = reactive({
       page: 1,
@@ -103,20 +117,32 @@ export default defineComponent({
             apiSuffix.value +
             `/tenantGroupAlbum/buyAlbumInfo?tenantGroupAlbumId=${
               route.query.taId || ''
-            }&tenantAlbumId=${state.albumId || ''}`
+            }`
+          //&tenantAlbumId=${state.albumId || ''}
           // if (state.albumId) {
           //   url = url + '?albumId=' + state.albumId
           // }
           const { data } = await request.get(url)
           state.albumList = data || []
           if (state.albumList.length > 0) {
-            state.details = state.albumList[0]
+            let index = 0
+            // 以缓存为优先 其次 请求头 state.albumId
+            if (toolSubject?.tenantGroupAlbumId || state.albumId) {
+              index = state.albumList.findIndex(item => {
+                return toolSubject?.tenantGroupAlbumId
+                  ? item.tenantGroupAlbumId === toolSubject?.tenantGroupAlbumId
+                  : item.id == state.albumId // 这里不全等 因为state.albumId为字符串 id为number
+              })
+              index < 0 && (index = 0)
+            }
+            state.initialSlide = index //默认展示第几个
+            state.details = state.albumList[index] // 有缓存  就用缓存里面的数据
           } else {
             // state.albumList
             if (!browser().isApp) {
               Dialog.alert({
                 title: '提示',
-                message: '该专辑不可购买',
+                message: '该教程不可购买',
                 confirmButtonText: '确定',
                 confirmButtonColor: '#2dc7aa'
               }).then(() => {
@@ -150,41 +176,6 @@ export default defineComponent({
         state.musicCounts = state.details?.musicCounts <= 0 ? false : true
         state.coursewareCounts =
           state.details?.coursewareCounts <= 0 ? false : true
-        if (state.subjectCounts) {
-          state.activeTab = 'SUBJECT'
-        } else if (state.musicCounts) {
-          state.activeTab = 'MUSIC'
-        } else if (state.ensembleCounts) {
-          state.activeTab = 'ENSEMBLE'
-        } else if (state.coursewareCounts) {
-          state.activeTab = 'COURSEWARE'
-        }
-        // 带的参数
-        if (route.query.subjectType == 'SUBJECT' && state.subjectCounts) {
-          state.activeTab = 'SUBJECT'
-        } else if (route.query.subjectType == 'MUSIC' && state.musicCounts) {
-          state.activeTab = 'MUSIC'
-        } else if (
-          route.query.subjectType == 'ENSEMBLE' &&
-          state.ensembleCounts
-        ) {
-          state.activeTab = 'ENSEMBLE'
-        } else if (
-          route.query.subjectType == 'COURSEWARE' &&
-          state.coursewareCounts
-        ) {
-          state.activeTab = 'COURSEWARE'
-        }
-        // subjectType 缓存
-        if (subjectType == 'SUBJECT' && state.subjectCounts) {
-          state.activeTab = 'SUBJECT'
-        } else if (subjectType == 'MUSIC' && state.musicCounts) {
-          state.activeTab = 'MUSIC'
-        } else if (subjectType == 'ENSEMBLE' && state.ensembleCounts) {
-          state.activeTab = 'ENSEMBLE'
-        } else if (subjectType == 'COURSEWARE' && state.coursewareCounts) {
-          state.activeTab = 'COURSEWARE'
-        }
         if (state.details.buyTimesFlag) {
           if (state.details.buyedTimes >= state.details.buyTimes) {
             state.hasBuyStatus = false
@@ -196,11 +187,7 @@ export default defineComponent({
         }
       }
     )
-
     const FetchList = async (hideLoading = false) => {
-      if (state.loading) {
-        return
-      }
       state.loading = true
       state.isError = false
       const tempParams = {
@@ -253,7 +240,15 @@ export default defineComponent({
       document.body.scrollIntoView()
       window.scrollTo(1, 0)
     })
-
+    function handleChangeActiveTab() {
+      state.activeTab = state.details?.coursewareCounts
+        ? 'COURSEWARE'
+        : state.details?.subjectCounts
+        ? 'SUBJECT'
+        : state.details?.musicCounts
+        ? 'MUSIC'
+        : 'ENSEMBLE'
+    }
     const onSubmit = async () => {
       const album = state.details
       const details = state.details
@@ -358,7 +353,7 @@ export default defineComponent({
                 }}
               >
                 <ColResult
-                  tips="暂无专辑"
+                  tips="暂无教程"
                   classImgSize="SMALL"
                   btnStatus={false}
                 />
@@ -412,34 +407,27 @@ export default defineComponent({
                     state.albumList &&
                     state.albumList.length > 0 && (
                       <Swiper
+                        initialSlide={state.initialSlide}
                         watchSlidesProgress={true}
                         slidesPerView={'auto'}
                         centeredSlides={true}
                         modules={[Pagination]}
                         pagination={{ clickable: true }}
-                        // onSlideChange={(swiper: any) => {}}
-                        onTransitionEnd={(swiper: any) => {
+                        // onTransitionEnd={(swiper: any) => {}} onSlideChange
+                        onSlideChange={(swiper: any) => {
                           state.details = state.albumList[swiper.activeIndex]
-                          state.ensembleCounts =
-                            state.details?.ensembleCounts <= 0 ? false : true
-                          state.subjectCounts =
-                            state.details?.subjectCounts <= 0 ? false : true
-                          state.musicCounts =
-                            state.details?.musicCounts <= 0 ? false : true
-                          state.coursewareCounts =
-                            state.details?.coursewareCounts <= 0 ? false : true
-                          if (state.subjectCounts) {
-                            state.activeTab = 'SUBJECT'
-                          } else if (state.musicCounts) {
-                            state.activeTab = 'MUSIC'
-                          } else if (state.ensembleCounts) {
-                            state.activeTab = 'ENSEMBLE'
-                          } else if (state.coursewareCounts) {
-                            state.activeTab = 'COURSEWARE'
-                          }
-                          params.page = 1
-                          state.list = []
-                          FetchList(true)
+                          // 等tab渲染完了之后再切换 不然tab会自动重新赋值
+                          nextTick(() => {
+                            // 当有初始值的时候不刷新
+                            if (state.initialSlide) {
+                              state.initialSlide = 0
+                              return
+                            }
+                            handleChangeActiveTab()
+                            params.page = 1
+                            state.list = []
+                            FetchList(true)
+                          })
                         }}
                       >
                         {state.albumList.map((album: any) => (
@@ -515,13 +503,16 @@ export default defineComponent({
                     lineWidth={20}
                     shrink
                     v-model:active={state.activeTab}
-                    onChange={val => {
-                      state.activeTab = val
+                    onClick-tab={val => {
+                      state.activeTab = val.name
                       params.page = 1
                       state.list = []
                       FetchList()
                     }}
                   >
+                    {state.coursewareCounts && (
+                      <Tab title="云教程" name="COURSEWARE"></Tab>
+                    )}
                     {state.subjectCounts && (
                       <Tab title="声部练习" name="SUBJECT"></Tab>
                     )}
@@ -531,13 +522,17 @@ export default defineComponent({
                     {state.ensembleCounts && (
                       <Tab title="合奏练习" name="ENSEMBLE"></Tab>
                     )}
-                    {state.coursewareCounts && (
-                      <Tab title="云教程" name="COURSEWARE"></Tab>
-                    )}
                   </Tabs>
                 </Sticky>
 
-                <div class={styles.alumnList}>
+                <div
+                  class={[
+                    styles.alumnList,
+                    state.activeTab === 'COURSEWARE'
+                      ? styles.alumnListCourseware
+                      : ''
+                  ]}
+                >
                   <List
                     loading={state.loading}
                     finished={state.finished}
@@ -559,7 +554,11 @@ export default defineComponent({
                           onItemClick={row => {
                             sessionStorage.setItem(
                               'tool-subject-type',
-                              state.activeTab as any
+                              JSON.stringify({
+                                activeTab: state.activeTab,
+                                tenantGroupAlbumId:
+                                  state.details.tenantGroupAlbumId
+                              })
                             )
                             router.push({
                               path: '/courseList',
@@ -578,7 +577,11 @@ export default defineComponent({
                           onDetail={(item: any) => {
                             sessionStorage.setItem(
                               'tool-subject-type',
-                              state.activeTab as any
+                              JSON.stringify({
+                                activeTab: state.activeTab,
+                                tenantGroupAlbumId:
+                                  state.details.tenantGroupAlbumId
+                              })
                             )
                             router.push({
                               path: '/music-detail',
@@ -594,7 +597,7 @@ export default defineComponent({
                     ) : (
                       !state.loading && (
                         <ColResult
-                          tips="暂无曲目" //暂无教程
+                          tips="暂无教程"
                           classImgSize="SMALL"
                           btnStatus={false}
                         />