黄琪勇 1 year ago
parent
commit
42bc0870b9

+ 111 - 4
src/tenant/music/courseList/index.tsx

@@ -13,6 +13,8 @@ import {
 } from 'vue'
 import styles from './index.module.less'
 import { useRoute, useRouter } from 'vue-router'
+import { state as baseState } from '@/state'
+import { orderStatus } from '@/views/order-detail/orderStatus'
 import {
   listenerMessage,
   postMessage,
@@ -43,7 +45,9 @@ export default defineComponent({
       list: [] as any,
       isDownloading: false // 是否在下载资源
     })
-
+    const apiSuffix = ref(
+      baseState.platformType === 'STUDENT' ? '/api-student' : '/api-teacher'
+    )
     /** 获取课件详情 */
     const getDetail = async () => {
       try {
@@ -130,7 +134,11 @@ export default defineComponent({
 
     const handleClick = async (item: any) => {
       if (!data.detail?.play) {
-        gotoPlay(item)
+        if (!browser().isApp) {
+          onDownloadApp()
+          return
+        }
+        onSubmit()
         return
       }
       if (!item.knowledgePointList) {
@@ -268,6 +276,101 @@ export default defineComponent({
         document.documentElement.scrollTop
       data.titleOpacity = height > 100 ? 1 : height / 100
     })
+    //  购买
+    const onSubmit = async () => {
+      const url =
+        apiSuffix.value +
+        '/tenantGroupAlbum/buyAlbumInfo?tenantGroupAlbumId=' +
+        (route.query.taId || '')
+      // if (state.albumId) {
+      //   url = url + '?albumId=' + state.albumId
+      // }
+      const { data } = await request.get(url)
+      const details = data[0]
+      orderStatus.orderObject.orderType = 'TENANT_ALBUM'
+      orderStatus.orderObject.orderName = details.name
+      orderStatus.orderObject.orderDesc = details.name
+      orderStatus.orderObject.actualPrice = details.actualPrice
+      // orderStatus.orderObject.recomUserId = route.query.recomUserId || 0
+      // orderStatus.orderObject.activityId = route.query.activityId || 0
+      orderStatus.orderObject.orderNo = ''
+      orderStatus.orderObject.orderList = [
+        {
+          orderType: 'TENANT_ALBUM',
+          goodsName: details.name,
+          actualPrice: details.actualPrice,
+          price: details.actualPrice,
+          ...details
+        }
+      ]
+
+      const res = await request.post('/api-student/userOrder/getPendingOrder', {
+        data: {
+          goodType: 'TENANT_ALBUM',
+          bizId: details.id
+        }
+      })
+
+      const result = res.data
+      if (result) {
+        Dialog.confirm({
+          title: '提示',
+          message: '您有一个未支付的订单,是否继续支付?',
+          theme: 'round-button',
+          className: 'confirm-button-group',
+          cancelButtonText: '取消订单',
+          confirmButtonText: '继续支付'
+        })
+          .then(async () => {
+            orderStatus.orderObject.orderNo = result.orderNo
+            orderStatus.orderObject.actualPrice = result.actualPrice
+            orderStatus.orderObject.discountPrice = result.discountPrice
+            orderStatus.orderObject.paymentConfig = {
+              ...result.paymentConfig,
+              paymentVendor: result.paymentVendor,
+              paymentVersion: result.paymentVersion
+            }
+
+            routerToALBUM(details.id)
+          })
+          .catch(() => {
+            Dialog.close()
+            // 只用取消订单,不用做其它处理
+            cancelPaymentALBUM(result.orderNo)
+          })
+      } else {
+        routerToALBUM(details.id)
+      }
+    }
+    const cancelPaymentALBUM = async (orderNo: string) => {
+      try {
+        await request.post('/api-student/userOrder/orderCancel/v2', {
+          data: {
+            orderNo
+          }
+        })
+      } catch {
+        //
+      }
+    }
+    const routerToALBUM = (id: string) => {
+      router.push({
+        path: '/orderDetail',
+        query: {
+          orderType: 'ALBUM',
+          album: id
+        }
+      })
+    }
+    const onDownloadApp = () => {
+      Dialog.alert({
+        title: '提示',
+        message: '请在酷乐秀APP中使用',
+        confirmButtonColor: '#2dc7aa'
+      }).then(() => {
+        window.location.href = location.origin + '/student/#/download'
+      })
+    }
     return () => (
       <div class={styles.courseList}>
         <TheSticky position="top">
@@ -396,7 +499,7 @@ export default defineComponent({
           <ColResult tips="暂无内容" classImgSize="SMALL" btnStatus={false} />
         )}
         <TheSticky position="bottom">
-          {!data.detail.play && (
+          {data.detail.id && !data.detail.play && (
             <div class={styles.footers}>
               <Button
                 round
@@ -404,7 +507,11 @@ export default defineComponent({
                 type="primary"
                 color="linear-gradient(270deg, #FF3C81 0%, #FF76A6 100%)"
                 onClick={() => {
-                  //
+                  if (!browser().isApp) {
+                    onDownloadApp()
+                    return
+                  }
+                  onSubmit()
                 }}
               >
                 开通训练教程

+ 15 - 13
src/tenant/music/lessonCourseware/index.tsx

@@ -147,18 +147,19 @@ export default defineComponent({
                 inputBackground="transparent"
                 // leftIcon={iconSearch}
                 v-slots={{
-                  left: () => (
-                    <DropdownMenu class={styles.dropdownMenuSub}>
-                      <DropdownItem
-                        titleClass={styles.titleActive}
-                        v-model={subjectOptValue.value}
-                        options={subjectOpt.value}
-                        onChange={handleOnRefresh}
-                      >
-                        <div></div>
-                      </DropdownItem>
-                    </DropdownMenu>
-                  )
+                  left: () =>
+                    subjectOpt.value.length > 1 && (
+                      <DropdownMenu class={styles.dropdownMenuSub}>
+                        <DropdownItem
+                          titleClass={styles.titleActive}
+                          v-model={subjectOptValue.value}
+                          options={subjectOpt.value}
+                          onChange={handleOnRefresh}
+                        >
+                          <div></div>
+                        </DropdownItem>
+                      </DropdownMenu>
+                    )
                 }}
               />
             </TheSticky>
@@ -189,7 +190,8 @@ export default defineComponent({
                       path: '/courseList',
                       query: {
                         id: row.id,
-                        albumId: params.albumId
+                        albumId: params.albumId,
+                        taId: route.query.taId
                       }
                     })
                   }}

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

@@ -47,6 +47,7 @@ import ColShare from '@/components/col-share'
 import iconListen from './images/icon_listen.png'
 import iconTeacher from '@common/images/icon_teacher.png'
 import emtpy from './images/emtpy.png'
+import { state as baseState } from '@/state'
 
 import activeButtonIcon from './images/icon_checkbox.png'
 import inactiveButtonIcon from './images/icon_checkbox_default.png'
@@ -112,7 +113,9 @@ export default defineComponent({
         text: '点播'
       }
     }
-
+    const apiSuffix = ref(
+      baseState.platformType === 'STUDENT' ? '/api-student' : '/api-teacher'
+    )
     // 更改预览状态
     const onChangeStaff = (type: string) => {
       staff.radio = type
@@ -756,6 +759,93 @@ export default defineComponent({
         window.location.href = location.origin + '/student/#/download'
       })
     }
+
+    //  购买
+    const onSubmit = async () => {
+      const url =
+        apiSuffix.value +
+        '/tenantGroupAlbum/buyAlbumInfo?tenantGroupAlbumId=' +
+        (route.query.taId || '')
+      // if (state.albumId) {
+      //   url = url + '?albumId=' + state.albumId
+      // }
+      const { data } = await request.get(url)
+      const details = data[0]
+      orderStatus.orderObject.orderType = 'TENANT_ALBUM'
+      orderStatus.orderObject.orderName = details.name
+      orderStatus.orderObject.orderDesc = details.name
+      orderStatus.orderObject.actualPrice = details.actualPrice
+      // orderStatus.orderObject.recomUserId = route.query.recomUserId || 0
+      // orderStatus.orderObject.activityId = route.query.activityId || 0
+      orderStatus.orderObject.orderNo = ''
+      orderStatus.orderObject.orderList = [
+        {
+          orderType: 'TENANT_ALBUM',
+          goodsName: details.name,
+          actualPrice: details.actualPrice,
+          price: details.actualPrice,
+          ...details
+        }
+      ]
+
+      const res = await request.post('/api-student/userOrder/getPendingOrder', {
+        data: {
+          goodType: 'TENANT_ALBUM',
+          bizId: details.id
+        }
+      })
+
+      const result = res.data
+      if (result) {
+        Dialog.confirm({
+          title: '提示',
+          message: '您有一个未支付的订单,是否继续支付?',
+          theme: 'round-button',
+          className: 'confirm-button-group',
+          cancelButtonText: '取消订单',
+          confirmButtonText: '继续支付'
+        })
+          .then(async () => {
+            orderStatus.orderObject.orderNo = result.orderNo
+            orderStatus.orderObject.actualPrice = result.actualPrice
+            orderStatus.orderObject.discountPrice = result.discountPrice
+            orderStatus.orderObject.paymentConfig = {
+              ...result.paymentConfig,
+              paymentVendor: result.paymentVendor,
+              paymentVersion: result.paymentVersion
+            }
+
+            routerToALBUM(details.id)
+          })
+          .catch(() => {
+            Dialog.close()
+            // 只用取消订单,不用做其它处理
+            cancelPaymentALBUM(result.orderNo)
+          })
+      } else {
+        routerToALBUM(details.id)
+      }
+    }
+    const cancelPaymentALBUM = async (orderNo: string) => {
+      try {
+        await request.post('/api-student/userOrder/orderCancel/v2', {
+          data: {
+            orderNo
+          }
+        })
+      } catch {
+        //
+      }
+    }
+    const routerToALBUM = (id: string) => {
+      router.push({
+        path: '/orderDetail',
+        query: {
+          orderType: 'ALBUM',
+          album: id
+        }
+      })
+    }
     return () => (
       <div class={styles.detail}>
         <TheSticky position="top">
@@ -1047,7 +1137,7 @@ export default defineComponent({
                       if (route.query.type === 'search') {
                         router.push('train-tool')
                       } else {
-                        router.back()
+                        onSubmit()
                       }
                     }}
                   >

+ 159 - 158
src/tenant/music/train-list/index.tsx

@@ -295,166 +295,166 @@ export default defineComponent({
                 inputBackground="transparent"
                 // leftIcon={iconSearch}
                 v-slots={{
-                  left: () => (
-                    <DropdownMenu>
-                      <DropdownItem
-                        disabled={!isSearchStatus.value}
-                        titleClass={
-                          params.subjectId || params.type || params.level
-                            ? styles.titleActive
-                            : ''
-                        }
-                        title="筛选"
-                        ref={searchRef}
-                      >
-                        <div
-                          class={styles.searchResult}
-                          style={{ maxHeight: '45vh', overflowY: 'auto' }}
+                  left: () =>
+                    isSearchStatus.value && (
+                      <DropdownMenu>
+                        <DropdownItem
+                          titleClass={
+                            params.subjectId || params.type || params.level
+                              ? styles.titleActive
+                              : ''
+                          }
+                          title="筛选"
+                          ref={searchRef}
                         >
-                          {searchObj.value.subjects &&
-                            searchObj.value.subjects.length > 0 && (
-                              <>
-                                <div class={styles.searchTitle}>声部</div>
-                                <div
-                                  class={[
-                                    styles['radio-group'],
-                                    styles.radio,
-                                    styles['organ-radio']
-                                  ]}
-                                >
-                                  {searchObj.value.subjects.map(
-                                    (subject: any) => {
-                                      const isActive =
-                                        subject.id === params.subjectId
-                                      const type = isActive
-                                        ? 'primary'
-                                        : 'default'
-                                      return (
-                                        <Tag
-                                          size="large"
-                                          plain={isActive}
-                                          type={type}
-                                          round
-                                          onClick={() => {
-                                            params.subjectId = subject.id
-                                          }}
-                                        >
-                                          {subject.name}
-                                        </Tag>
-                                      )
-                                    }
-                                  )}
-                                </div>
-                              </>
-                            )}
-                          {searchObj.value.levelList &&
-                            searchObj.value.levelList.length > 0 && (
-                              <>
-                                <div class={styles.searchTitle}>级别</div>
-                                <div
-                                  class={[
-                                    styles['radio-group'],
-                                    styles.radio,
-                                    styles['organ-radio']
-                                  ]}
-                                >
-                                  {searchObj.value.levelList.map(
-                                    (subject: any) => {
-                                      const isActive =
-                                        subject.id === params.level
-                                      const type = isActive
-                                        ? 'primary'
-                                        : 'default'
-                                      return (
-                                        <Tag
-                                          size="large"
-                                          plain={isActive}
-                                          type={type}
-                                          round
-                                          onClick={() => {
-                                            params.level = subject.id
-                                          }}
-                                        >
-                                          {subject.value}
-                                        </Tag>
-                                      )
-                                    }
-                                  )}
-                                </div>
-                              </>
-                            )}
-                          {searchObj.value.typeList &&
-                            searchObj.value.typeList.length > 0 && (
-                              <>
-                                <div class={styles.searchTitle}>类型</div>
-                                <div
-                                  class={[
-                                    styles['radio-group'],
-                                    styles.radio,
-                                    styles['organ-radio']
-                                  ]}
-                                >
-                                  {searchObj.value.typeList.map(
-                                    (subject: any) => {
-                                      const isActive =
-                                        subject.id === params.type
-                                      const type = isActive
-                                        ? 'primary'
-                                        : 'default'
-                                      return (
-                                        <Tag
-                                          size="large"
-                                          plain={isActive}
-                                          type={type}
-                                          round
-                                          onClick={() => {
-                                            params.type = subject.id
-                                          }}
-                                        >
-                                          {subject.value}
-                                        </Tag>
-                                      )
-                                    }
-                                  )}
-                                </div>
-                              </>
-                            )}
-                        </div>
-
-                        <div class={['btnGroup', 'btnMore']}>
-                          <Button
-                            class={styles.resetting}
-                            type="primary"
-                            plain
-                            round
-                            onClick={() => {
-                              params.subjectId = null
-                              params.level = ''
-                              params.type = ''
-                            }}
+                          <div
+                            class={styles.searchResult}
+                            style={{ maxHeight: '45vh', overflowY: 'auto' }}
                           >
-                            重 置
-                          </Button>
+                            {searchObj.value.subjects &&
+                              searchObj.value.subjects.length > 0 && (
+                                <>
+                                  <div class={styles.searchTitle}>声部</div>
+                                  <div
+                                    class={[
+                                      styles['radio-group'],
+                                      styles.radio,
+                                      styles['organ-radio']
+                                    ]}
+                                  >
+                                    {searchObj.value.subjects.map(
+                                      (subject: any) => {
+                                        const isActive =
+                                          subject.id === params.subjectId
+                                        const type = isActive
+                                          ? 'primary'
+                                          : 'default'
+                                        return (
+                                          <Tag
+                                            size="large"
+                                            plain={isActive}
+                                            type={type}
+                                            round
+                                            onClick={() => {
+                                              params.subjectId = subject.id
+                                            }}
+                                          >
+                                            {subject.name}
+                                          </Tag>
+                                        )
+                                      }
+                                    )}
+                                  </div>
+                                </>
+                              )}
+                            {searchObj.value.levelList &&
+                              searchObj.value.levelList.length > 0 && (
+                                <>
+                                  <div class={styles.searchTitle}>级别</div>
+                                  <div
+                                    class={[
+                                      styles['radio-group'],
+                                      styles.radio,
+                                      styles['organ-radio']
+                                    ]}
+                                  >
+                                    {searchObj.value.levelList.map(
+                                      (subject: any) => {
+                                        const isActive =
+                                          subject.id === params.level
+                                        const type = isActive
+                                          ? 'primary'
+                                          : 'default'
+                                        return (
+                                          <Tag
+                                            size="large"
+                                            plain={isActive}
+                                            type={type}
+                                            round
+                                            onClick={() => {
+                                              params.level = subject.id
+                                            }}
+                                          >
+                                            {subject.value}
+                                          </Tag>
+                                        )
+                                      }
+                                    )}
+                                  </div>
+                                </>
+                              )}
+                            {searchObj.value.typeList &&
+                              searchObj.value.typeList.length > 0 && (
+                                <>
+                                  <div class={styles.searchTitle}>类型</div>
+                                  <div
+                                    class={[
+                                      styles['radio-group'],
+                                      styles.radio,
+                                      styles['organ-radio']
+                                    ]}
+                                  >
+                                    {searchObj.value.typeList.map(
+                                      (subject: any) => {
+                                        const isActive =
+                                          subject.id === params.type
+                                        const type = isActive
+                                          ? 'primary'
+                                          : 'default'
+                                        return (
+                                          <Tag
+                                            size="large"
+                                            plain={isActive}
+                                            type={type}
+                                            round
+                                            onClick={() => {
+                                              params.type = subject.id
+                                            }}
+                                          >
+                                            {subject.value}
+                                          </Tag>
+                                        )
+                                      }
+                                    )}
+                                  </div>
+                                </>
+                              )}
+                          </div>
 
-                          <Button
-                            class={styles.confirm}
-                            type="primary"
-                            color="linear-gradient( 270deg, #FF204B 0%, #FE5B71 100%)"
-                            round
-                            block
-                            onClick={() => {
-                              params.page = 1
-                              data.value = null
-                              FetchList()
-                              searchRef.value?.toggle()
-                            }}
-                          >
-                            确 认
-                          </Button>
-                        </div>
-                      </DropdownItem>
-                    </DropdownMenu>
-                  )
+                          <div class={['btnGroup', 'btnMore']}>
+                            <Button
+                              class={styles.resetting}
+                              type="primary"
+                              plain
+                              round
+                              onClick={() => {
+                                params.subjectId = null
+                                params.level = ''
+                                params.type = ''
+                              }}
+                            >
+                              重 置
+                            </Button>
+
+                            <Button
+                              class={styles.confirm}
+                              type="primary"
+                              color="linear-gradient( 270deg, #FF204B 0%, #FE5B71 100%)"
+                              round
+                              block
+                              onClick={() => {
+                                params.page = 1
+                                data.value = null
+                                FetchList()
+                                searchRef.value?.toggle()
+                              }}
+                            >
+                              确 认
+                            </Button>
+                          </div>
+                        </DropdownItem>
+                      </DropdownMenu>
+                    )
                 }}
               />
             </TheSticky>
@@ -480,7 +480,8 @@ export default defineComponent({
                       query: {
                         subjectType,
                         id: item.id,
-                        tenantAlbumId: item.tenantAlbumId
+                        tenantAlbumId: item.tenantAlbumId,
+                        taId: route.query.taId
                       }
                     })
                   }}

+ 6 - 5
src/tenant/music/train-tool/index.tsx

@@ -89,7 +89,8 @@ export default defineComponent({
       state.loadingAlbum = true
       try {
         // tenantGroupAlbum/buyAlbumInfo
-        if (state.albumId) {
+        // 当小组专辑id和专辑id同时传入的时候以小组专辑id为准
+        if (state.albumId && !route.query.taId) {
           let url = apiSuffix.value + '/userTenantAlbumRecord/detail'
           if (state.albumId) {
             url = url + '?albumId=' + state.albumId
@@ -282,7 +283,6 @@ export default defineComponent({
       })
 
       const result = res.data
-      console.log(details, album)
       if (result) {
         state.popupStatus = false
         Dialog.confirm({
@@ -561,7 +561,8 @@ export default defineComponent({
                               path: '/courseList',
                               query: {
                                 id: row.id,
-                                albumId: state.details.id
+                                albumId: state.details.id,
+                                taId: state.details.tenantGroupAlbumId  // 当通过专辑查看时候 这个值为空
                               }
                             })
                           }}
@@ -579,8 +580,8 @@ export default defineComponent({
                               path: '/music-detail',
                               query: {
                                 id: item.id,
-                                tenantAlbumId: item.tenantAlbumId
-                                // albumId: route.params.id
+                                tenantAlbumId: item.tenantAlbumId,
+                                taId: state.details.tenantGroupAlbumId // 当通过专辑查看时候 这个值为空
                               }
                             })
                           }}