skyblued 2 سال پیش
والد
کامیت
c0ffffc24e
3فایلهای تغییر یافته به همراه128 افزوده شده و 73 حذف شده
  1. 0 3
      src/student/my-orchestra/index.tsx
  2. 76 9
      src/views/mine-orchestra/index.tsx
  3. 52 61
      src/views/mine-orchestra/my-class/index.tsx

+ 0 - 3
src/student/my-orchestra/index.tsx

@@ -136,9 +136,6 @@ export default defineComponent({
                 {state.selectOrchestra.status === 'AUTH' && (
                   <span style={{ color: 'red' }}>申请退团中</span>
                 )}
-                {/* {state.selectOrchestra.status === 'OUTOF_ORCHESTRA' && (
-                  <span style={{ color: '#666' }}>已退团</span>
-                )} */}
               </>
             )
           }}

+ 76 - 9
src/views/mine-orchestra/index.tsx

@@ -3,7 +3,7 @@ import OSticky from '@/components/o-sticky'
 import request from '@/helpers/request'
 import { state } from '@/state'
 import { Cell, CellGroup, Picker, Popup, Tab, Tabs } from 'vant'
-import { defineComponent, onMounted, reactive, ref } from 'vue'
+import { defineComponent, nextTick, onMounted, reactive, ref } from 'vue'
 import styles from './index.module.less'
 import iconOrchestra from './images/icon-or.png'
 import MyClass from './my-class'
@@ -11,11 +11,13 @@ import OEmpty from '@/components/o-empty'
 import OFullRefresh from '@/components/o-full-refresh'
 import OrchestraDeeds from './orchestra-deeds'
 import MyPhoto from './my-photo'
+import { useRouter } from 'vue-router'
 
 export default defineComponent({
   name: 'my-orchestra',
   setup(props, ctx) {
-    const tabActive = ref('乐团相册')
+    const router = useRouter()
+    const tabActive = ref('我的班级')
     const data = reactive({
       orchestraList: [] as any[],
       loading: true
@@ -24,6 +26,22 @@ export default defineComponent({
       orchestra: {} as any,
       orchestraStatus: false
     })
+    /** 学生获取我的乐团 */
+    const getStudentOrchestras = () => {
+      data.loading = true
+      request.post(`${state.platformApi}/orchestra/studentOrchestra`).then((res: any) => {
+        if (Array.isArray(res?.data)) {
+          data.orchestraList = res.data.map((n: any) => {
+            return {
+              ...n,
+              name: n.name || n.orchestraName || '',
+              id: n.id || n.orchestraId || ''
+            }
+          })
+          modelData.orchestra = data.orchestraList[0] || {}
+        }
+      })
+    }
     const getOrchestras = async () => {
       data.loading = true
       try {
@@ -37,8 +55,15 @@ export default defineComponent({
       } catch {}
       data.loading = false
     }
+    const getData = () => {
+      getStudentOrchestras()
+      // if (state.platformType === 'STUDENT') {
+      // } else {
+      //   getOrchestras()
+      // }
+    }
     onMounted(() => {
-      getOrchestras()
+      getData()
     })
 
     return () => (
@@ -48,13 +73,45 @@ export default defineComponent({
             document.documentElement.style.setProperty('--header-height', height + 'px')
           }}
         >
-          <OHeader title="我的乐团" />
+          <OHeader
+            title="我的乐团"
+            v-slots={{
+              right: () => (
+                <>
+                  {state.platformType == 'STUDENT' && (
+                    <>
+                      {(modelData.orchestra?.status === 'REGISTER' ||
+                        modelData.orchestra?.status === 'LEARNING') && (
+                        <span
+                          onClick={() => {
+                            router.push({
+                              path: '/apply-withdrawal',
+                              query: {
+                                id: modelData.orchestra?.orchestraId
+                              }
+                            })
+                          }}
+                        >
+                          申请退团
+                        </span>
+                      )}
+                      {modelData.orchestra?.status === 'AUTH' && (
+                        <span style={{ color: 'red' }}>申请退团中</span>
+                      )}
+                    </>
+                  )}
+                </>
+              )
+            }}
+          />
         </OSticky>
         <OFullRefresh
           v-model:modelValue={data.loading}
           onRefresh={() => {
             data.orchestraList = []
-            getOrchestras()
+            nextTick(() => {
+              getData()
+            })
           }}
           style="min-height: calc(100vh - var(--van-nav-bar-height) - var(--header-height))"
         >
@@ -72,20 +129,30 @@ export default defineComponent({
             </Cell>
           </CellGroup>
           {!!data.orchestraList.length && (
-            <Tabs v-model:active={tabActive.value} class={styles.tabs} lazyRender={true} background="transparent" animated swipeable>
+            <Tabs
+              v-model:active={tabActive.value}
+              class={styles.tabs}
+              lazyRender={true}
+              background="transparent"
+              animated
+              swipeable
+            >
               <Tab name="我的班级" title="我的班级">
                 <div class={styles.content}>
-                  <MyClass orchestraId={modelData.orchestra?.id || ''} />
+                  <MyClass
+                    list={modelData.orchestra?.classGroupIdList || []}
+                    orchestraId={modelData.orchestra?.id || ''}
+                  />
                 </div>
               </Tab>
               <Tab name="乐团相册" title="乐团相册">
                 <div class={styles.content}>
-                    <MyPhoto orchestraId={modelData.orchestra?.id || ''} />
+                  <MyPhoto orchestraId={modelData.orchestra?.id || ''} />
                 </div>
               </Tab>
               <Tab name="乐团事迹" title="乐团事迹">
                 <div class={styles.content}>
-                    <OrchestraDeeds orchestraId={modelData.orchestra?.id || ''} />
+                  <OrchestraDeeds orchestraId={modelData.orchestra?.id || ''} />
                 </div>
               </Tab>
             </Tabs>

+ 52 - 61
src/views/mine-orchestra/my-class/index.tsx

@@ -11,13 +11,17 @@ import { openDefaultWebView } from '../../../state'
 export default defineComponent({
   name: 'my-orchestra',
   props: {
+    list: {
+      type: Array<any>,
+      default: () => []
+    },
     orchestraId: {
       type: String,
       default: ''
     }
   },
   setup(props) {
-    console.log('🚀 ~ props', props)
+    console.log("🚀 ~ props", props.list)
     const onMessage = async (item: any) => {
       console.log(item)
       postMessage({
@@ -36,7 +40,7 @@ export default defineComponent({
         page: 1,
         rows: 20
       },
-      classList: [] as any[],
+      classList: props.list as any[],
       loading: false,
       finished: false
     })
@@ -68,67 +72,54 @@ export default defineComponent({
       } catch {}
       data.loading = false
     }
-    onMounted(() => {
-      getClassList()
-    })
     return () => (
       <div class={styles.myClass}>
-        <List
-          v-model:loading={data.loading}
-          finishedText="没有更多数据"
-          finished={data.finished}
-          onLoad={getClassList}
-          immediateCheck={false}
-        >
-          {Array.isArray(data.classList) &&
-            data.classList.map((item: any) => (
-              <div class={styles.itemDiv} onClick={() => openClassDetail(item)}>
-                <Cell center label={item.orchestraName}>
-                  {{
-                    icon: () => (
-                      <Image
-                        src={item.teacherAvatar || iconTeacher}
-                        class={styles.iconImg}
-                        fit="cover"
-                      />
-                    ),
-                    title: () => (
-                      <div class={styles.content}>
-                        <div class={['van-ellipsis', styles.teacherName]}>{item.teacherName}</div>
-                        <div class={styles.tag}>
-                          {item.name}
-                        </div>
-                      </div>
-                    ),
-                    value: () => (
-                      <Image
-                        class={styles.messageImg}
-                        src={iconMessage}
-                        onClick={(e: Event) => {
-                          e.stopPropagation()
-                          onMessage(item)
-                        }}
-                      />
-                    )
-                  }}
-                </Cell>
-                <Grid border={false} columnNum={3} class={styles.grid}>
-                  <GridItem>
-                    <p class={styles.title}>{item.preStudentNum || 0}</p>
-                    <p class={styles.name}>学生人数</p>
-                  </GridItem>
-                  <GridItem>
-                    <p class={[styles.title]}>{item.courseNum || 0}</p>
-                    <p class={styles.name}>剩余课时</p>
-                  </GridItem>
-                  <GridItem>
-                    <p class={styles.title}>{item.courseScheduleNum || 0}</p>
-                    <p class={styles.name}>总课时</p>
-                  </GridItem>
-                </Grid>
-              </div>
-            ))}
-        </List>
+        {Array.isArray(data.classList) &&
+          data.classList.map((item: any) => (
+            <div class={styles.itemDiv} onClick={() => openClassDetail(item)}>
+              <Cell center label={item.orchestraName}>
+                {{
+                  icon: () => (
+                    <Image
+                      src={item.teacherAvatar || iconTeacher}
+                      class={styles.iconImg}
+                      fit="cover"
+                    />
+                  ),
+                  title: () => (
+                    <div class={styles.content}>
+                      <div class={['van-ellipsis', styles.teacherName]}>{item.teacherName}</div>
+                      <div class={styles.tag}>{item.classGroupName}</div>
+                    </div>
+                  ),
+                  value: () => (
+                    <Image
+                      class={styles.messageImg}
+                      src={iconMessage}
+                      onClick={(e: Event) => {
+                        e.stopPropagation()
+                        onMessage(item)
+                      }}
+                    />
+                  )
+                }}
+              </Cell>
+              <Grid border={false} columnNum={3} class={styles.grid}>
+                <GridItem>
+                  <p class={styles.title}>{item.preStudentNum || 0}</p>
+                  <p class={styles.name}>学生人数</p>
+                </GridItem>
+                <GridItem>
+                  <p class={[styles.title]}>{item.courseNum || 0}</p>
+                  <p class={styles.name}>剩余课时</p>
+                </GridItem>
+                <GridItem>
+                  <p class={styles.title}>{item.courseScheduleNum || 0}</p>
+                  <p class={styles.name}>总课时</p>
+                </GridItem>
+              </Grid>
+            </div>
+          ))}
       </div>
     )
   }