lex-wxl 3 days ago
parent
commit
13cdaa743c

+ 7 - 2
src/store/modules/user.ts

@@ -18,6 +18,7 @@ interface userType {
       realName?: string
       phone?: string
       subjectId?: string
+      isVip?: boolean
    }
    roles?: rolesType
 }
@@ -108,25 +109,29 @@ export default () => {
 }
 
 function handleUserInfo(userType: rolesType, userInfo: Record<string, any>) {
-   let avatar, username, realName, phone, subjectId
+   let avatar, username, realName, phone, subjectId, isVip
    if (["GYM", "KLX"].includes(userType)) {
       avatar = userInfo.avatar
       username = userInfo.username
       realName = userInfo.realName
       phone = userInfo.phone
       subjectId = userInfo.subjectId
+      // userInfo.userVip?.vipType === 'NOT_VIP' || !userInfo.userVip?.vipType ||
+      isVip = userInfo.userVip ? false : userInfo.userVip?.vipType === "NOT_VIP" || !userInfo.userVip?.vipType ? true : false
    } else {
       avatar = userInfo.avatar
       username = userInfo.nickname
       realName = userInfo.realName
       phone = userInfo.phone
       subjectId = userInfo.subjectId
+      isVip = false
    }
    return {
       avatar,
       username,
       realName,
       phone,
-      subjectId
+      subjectId,
+      isVip
    }
 }

+ 24 - 6
src/views/cloudPractice/cloudPractice.tsx

@@ -88,6 +88,15 @@ export default defineComponent({
          playState: "pause" as "play" | "pause", // 播放状态
          showPlayer: false // 是否显示播放器
       })
+
+      // 是否可以进行下载
+      const downloadMusicImg = computed(() => {
+         if (userStoreHook.roles !== "KLX") {
+            return true
+         }
+         return userStoreHook.userInfo.isVip ? true : false
+      })
+
       const partColumns = ref<any>([])
 
       const musicRenderType = computed(() => {
@@ -432,7 +441,7 @@ export default defineComponent({
             loading.value = false
             if (res.code === 200) {
                const result = res.data?.rows || []
-               state.subjectList = result.map((item: any) => {
+               const subjectList = result.map((item: any) => {
                   return {
                      label: item.name,
                      value: item.id,
@@ -440,26 +449,34 @@ export default defineComponent({
                   }
                })
 
-               state.subjectList.unshift({
+               subjectList.unshift({
                   label: "全部声部",
                   value: -1
                })
 
                const userSubjectId = userStoreHook.userInfo.subjectId
+               const tempSubjectList = []
+               // 格式化选择声部
                if (userSubjectId) {
                   const userSubjectIds = userSubjectId.split(",").map(item => Number(item))
                   const tempSubjectId = userSubjectIds[0]
-                  state.subjectList.forEach((item: any) => {
+
+                  subjectList.forEach((item: any) => {
                      // 判断是否存在声部编号
                      if (item.value === Number(tempSubjectId)) {
                         state.subjectId = Number(tempSubjectId)
                      }
 
-                     if (!userSubjectIds.includes(item.value)) {
-                        item.disabled = true
+                     if (userSubjectIds.includes(item.value)) {
+                        // item.disabled = true
+                        tempSubjectList.push(item)
                      }
                   })
+               } else {
+                  tempSubjectList.push(...subjectList)
                }
+
+               state.subjectList = tempSubjectList
             }
          })
       }
@@ -1300,6 +1317,7 @@ export default defineComponent({
                                     v-model={state.subjectId}
                                     height={42}
                                     // disabled={loading.value}
+                                    disabled={userStoreHook.roles === "KLX" && state.subjectList.length <= 1}
                                     options={state.subjectList}
                                     placeholder="全部声部"
                                     onChange={async () => {
@@ -1516,7 +1534,7 @@ export default defineComponent({
                   />
 
                   <div class={styles.rightBtns} style={{ display: activeItem.value.id ? "" : "none" }}>
-                     <div style={{ display: state.musicPdfUrl || state.imgs.length > 0 ? "" : "none" }}>
+                     <div style={{ display: (state.musicPdfUrl || state.imgs.length > 0) && downloadMusicImg.value ? "" : "none" }}>
                         <NTooltip showArrow={false}>
                            {{
                               trigger: () => (

+ 26 - 1
src/views/cloudTextbooks/cloudTextbooks.vue

@@ -148,7 +148,7 @@ function handleGetClassTypeOpt() {
    } else if (userStoreHook.roles === "KLX") {
       httpAjax(queryPageSubject_klx).then(res => {
          if (res.code === 200) {
-            classTypeOpt.value = [
+            const classList = [
                {
                   value: "",
                   label: "全部"
@@ -160,6 +160,31 @@ function handleGetClassTypeOpt() {
                   }
                })
             ]
+
+            const userSubjectId = userStoreHook.userInfo.subjectId
+            const tempSubjectList = []
+            // 格式化选择声部
+            if (userSubjectId) {
+               const userSubjectIds = userSubjectId.split(",").map(item => Number(item))
+               const tempSubjectId = userSubjectIds[0]
+
+               classList.forEach((item: any) => {
+                  // 判断是否存在声部编号
+                  if (item.value === Number(tempSubjectId)) {
+                     // console.log(tempSubjectId, "tempSubjectId")
+                     classType.value = tempSubjectId as any
+                  }
+
+                  if (userSubjectIds.includes(item.value)) {
+                     // item.disabled = true
+                     tempSubjectList.push(item)
+                  }
+               })
+            } else {
+               tempSubjectList.push(...classList)
+            }
+
+            classTypeOpt.value = [...tempSubjectList]
          }
       })
    }