浏览代码

添加会员

lex 9 月之前
父节点
当前提交
f64d0fa09c

+ 17 - 7
src/business-components/user-detail/index.tsx

@@ -13,6 +13,7 @@ import IconJiaozi from '@common/images/icon-jiaozi.png'
  * @param {type} username 姓名
  * @param {type} startTime 开始时间
  * @param {type} buyNum 购买用户数
+ * @param {type} payType 收费方式
  * @param {type} lessonPrice 价格
  * @param {type} lessonCoverUrl 视频封面
  * @param {type} lessonDesc 课程描述
@@ -26,6 +27,7 @@ interface UserType {
   startTime?: string
   id?: number
   buyNum?: number
+  payType?: string
   lessonPrice: number
   lessonNum?: number
   lessonDesc?: string
@@ -129,19 +131,27 @@ export default defineComponent({
               value: () => (
                 <div class={styles.info}>
                   {/* 0元不显示,为了处理ios审核问题 */}
-                  {this.userInfo.lessonPrice > 0 && (
-                    <>¥{this.userInfo.lessonPrice}</>
+                  {this.userInfo.payType === 'VIP' ? (
+                    <span style={{ color: '#C76E21' }}>会员</span>
+                  ) : (
+                    <>
+                      {this.userInfo.lessonPrice > 0 && (
+                        <>¥{this.userInfo.lessonPrice}</>
+                      )}
+                      {this.userInfo.lessonPrice <= 0 &&
+                        this.userInfo.auditVersion !== 0 && <>¥{0}</>}
+                      {this.userInfo.lessonPrice <= 0 &&
+                        this.userInfo.auditVersion === 0 && (
+                          <span style={{ color: '#20BEA0' }}>免费</span>
+                        )}
+                    </>
                   )}
-                  {this.userInfo.lessonPrice <= 0 &&
-                    this.userInfo.auditVersion !== 0 && <>¥{0}</>}
-                  {this.userInfo.lessonPrice <= 0 &&
-                    this.userInfo.auditVersion === 0 && <>免费</>}
                   <span
                     style={{ color: '#999', fontSize: '14px', fontWeight: 400 }}
                   >
                     /{this.userInfo.lessonNum}课时
                   </span>
-                  {this.showBuy && (
+                  {this.showBuy && this.userInfo.payType === 'PAY' && (
                     <div class={styles.buyNum}>
                       {this.userInfo.buyNum}人已
                       {this.userInfo.lessonPrice <= 0 &&

+ 1 - 1
src/components/col-field/index.module.less

@@ -1,7 +1,7 @@
 .formTitle {
   font-size: 16px;
   color: #000;
-  display: flex;
+  display: flex !important;
   align-items: center;
   justify-content: space-between;
 

+ 10 - 1
src/components/col-video/index.tsx

@@ -20,6 +20,11 @@ export default defineComponent({
       type: Boolean,
       default: false
     },
+    // 收费方式
+    payType: {
+      type: String,
+      default: ''
+    },
     freeTitleStatus: {
       type: Boolean,
       default: true
@@ -382,7 +387,7 @@ export default defineComponent({
         <video
           ref="video"
           class={styles['video']}
-          src={this.src}
+          // src={this.src}
           id={this.videoID}
           playsinline={this.playsinline}
           poster={this.poster}
@@ -435,6 +440,8 @@ export default defineComponent({
                   <p class={styles.tips}>
                     {this.freeTitleStatus
                       ? '免费试看结束,购买完整课程后继续学习'
+                      : this.payType === 'VIP'
+                      ? '免费试看结束,开通会员后继续学习'
                       : '试看结束,领取课程后继续学习'}
                   </p>
                 ) : (
@@ -453,6 +460,8 @@ export default defineComponent({
                     {state.platformType === 'STUDENT'
                       ? this.freeTitleStatus
                         ? '立即购买'
+                        : this.payType === 'VIP'
+                        ? '开通会员'
                         : '免费领取'
                       : '返回免费'}
                   </Button>

+ 1 - 1
src/helpers/native-message.ts

@@ -77,7 +77,7 @@ if (browserInfo.isApp) {
 }
 
 // 判断是否是管乐团学生端的app
-console.log(browserInfo.isOrchestraStudent)
+// console.log(browserInfo.isOrchestraStudent)
 let instance: any
 if (browserInfo.isOrchestraStudent) {
   instance = (window as any).ORCHESTRA || (window as any).webkit?.messageHandlers?.ORCHESTRA

+ 53 - 3
src/student/video-class/video-class-detail.tsx

@@ -17,25 +17,30 @@ import {
   Toast,
   Dialog
 } from 'vant'
+import { postMessage } from '@/helpers/native-message'
 import { defineComponent } from 'vue'
 import styles from './video-class-detail.module.less'
-import { state } from '@/state'
+import { setLogin, state } from '@/state'
 
 import iconTeacher from '@common/images/icon_teacher.png'
 import ColResult from '@/components/col-result'
 import dayjs from 'dayjs'
 import { onSubmitZero, orderStatus } from '@/views/order-detail/orderStatus'
+import { browser } from '@/helpers/utils'
+import { usePageVisibility } from '@vant/use'
 
 export default defineComponent({
   name: 'VideoClassDetail',
   data() {
     const query = this.$route.query
     return {
+      pageVisibility: 'visible' as any,
       groupId: query.groupId,
       classId: query.classId,
       tabIndex: 1,
       title: '',
       lessonPrice: 0,
+      payType: '',
       useRelationType: '',
       alreadyBuy: false,
       videoDetail: {} as any,
@@ -71,6 +76,7 @@ export default defineComponent({
     }
   },
   async mounted() {
+    this.pageVisibility = usePageVisibility()
     // 处理视频显示
     const width = document.body.clientWidth || document.body.offsetWidth
     this.videoHeight = (width / 16) * 9 + 'px'
@@ -105,13 +111,22 @@ export default defineComponent({
           }
         )
         const result = res.data || {}
+        const userInfo = state.user.data as any
+        const alreadyBuy =
+          result.lessonGroup.payType === 'VIP'
+            ? userInfo.isVip
+              ? true
+              : false
+            : result.alreadyBuy
         this.videoDetail = result.lessonGroup
         this.title = result.lessonGroup.lessonName
+        this.payType = result.lessonGroup.payType
         this.lessonPrice = result.lessonGroup.lessonPrice
         this.useRelationType = result.lessonGroup.relationType
-        this.alreadyBuy = result.alreadyBuy
+        this.alreadyBuy = alreadyBuy
         this.detailList = result.detailList || []
-        this.trySee = !result.alreadyBuy
+        this.trySee = !alreadyBuy
+
         this.detailList.forEach((item: any, index: number) => {
           if (item.id === Number(this.classId)) {
             this.posterUrl = item.coverUrl
@@ -193,6 +208,22 @@ export default defineComponent({
       } catch {}
     }
   },
+  watch: {
+    pageVisibility() {
+      // 如果不是会员则不用刷新
+      if (this.payType !== 'VIP') {
+        return
+      }
+      request
+        .get('/api-student/student/queryUserInfo', {
+          initRequest: true // 初始化接口
+        })
+        .then((res: any) => {
+          setLogin(res.data)
+          this.__init()
+        })
+    }
+  },
   render() {
     return (
       <div class={styles['video-class-detail']}>
@@ -206,10 +237,29 @@ export default defineComponent({
                   freeTitleStatus={this.lessonPrice > 0 ? true : false}
                   trySee={this.trySee}
                   src={this.srcUrl}
+                  payType={this.payType}
                   poster={this.posterUrl}
                   height={this.videoHeight}
                   isBuy
                   onBuyEmit={async () => {
+                    if (this.payType === 'VIP') {
+                      if (browser().isApp) {
+                        postMessage({
+                          api: 'openWebView',
+                          content: {
+                            url: `${location.origin}${location.pathname}#/memberCenter`,
+                            orientation: 1,
+                            isHideTitle: false
+                          }
+                        })
+                      } else {
+                        this.$router.push({
+                          path: '/memberCenter'
+                        })
+                      }
+                      return
+                    }
+
                     if (this.lessonPrice > 0) {
                       this.$router.back()
                       return

+ 57 - 4
src/student/video-class/video-detail.tsx

@@ -2,6 +2,7 @@ import CourseVideoItem from '@/business-components/course-video-item'
 import SectionDetail from '@/business-components/section-detail'
 import UserDetail from '@/business-components/user-detail'
 import { Sticky, Button, Dialog, Popup, Toast } from 'vant'
+import { postMessage } from '@/helpers/native-message'
 import { defineComponent } from 'vue'
 import styles from './video-detail.module.less'
 import request from '@/helpers/request'
@@ -12,13 +13,15 @@ import ColSticky from '@/components/col-sticky'
 import iconShare from '@/views/shop-mall/images/icon-share.svg'
 import ColShare from '@/components/col-share'
 import LiveItem from '@/views/live-class/live-item'
-import { state } from '@/state'
+import { setLogin, state } from '@/state'
 import { browser } from '@/helpers/utils'
+import { usePageVisibility } from '@vant/use'
 export default defineComponent({
   name: 'VideoDetail',
   data() {
     const query = this.$route.query
     return {
+      pageVisibility: 'visible' as any,
       userInfo: {} as any,
       detailList: [],
       recomUserId: query.recomUserId, // 推荐人id
@@ -40,6 +43,7 @@ export default defineComponent({
     }
   },
   async mounted() {
+    this.pageVisibility = usePageVisibility()
     await this._init()
     if (/(localhost|192)/g.test(location.origin)) {
       this.shareUrl = `https://dev.colexiu.com/teacher#/shareVideo?recomUserId=${state.user.data?.userId}&groupId=${this.params.groupId}&userType=${state.platformType}&p=tenant`
@@ -61,8 +65,16 @@ export default defineComponent({
         const result = res.data || {}
         const lessonGroup = result.lessonGroup || {}
         const teachertTag = result.teachertTag || ''
+        const userInfo = state.user.data as any
+        const alreadyBuy =
+          lessonGroup.payType === 'VIP'
+            ? userInfo.isVip
+              ? true
+              : false
+            : result.alreadyBuy
+
         this.userInfo = {
-          alreadyBuy: result.alreadyBuy,
+          alreadyBuy: alreadyBuy,
           username:
             lessonGroup.username || `游客${lessonGroup.teacherId || ''}`,
           headUrl: lessonGroup.avatar,
@@ -70,6 +82,7 @@ export default defineComponent({
           id: lessonGroup.id,
           lessonNum: lessonGroup.lessonCount,
           lessonName: lessonGroup.lessonName,
+          payType: lessonGroup.payType,
           lessonDesc: lessonGroup.lessonDesc,
           lessonPrice: lessonGroup.lessonPrice,
           relationType: lessonGroup.relationType,
@@ -80,6 +93,9 @@ export default defineComponent({
           isTeacher: result.teacherFlag ? true : false
         }
         this.detailList = result.detailList || []
+
+        console.log(lessonGroup.payType, userInfo.isVip)
+        console.log(this.userInfo, 'this.userInfo')
       } catch {
         //
       }
@@ -95,6 +111,24 @@ export default defineComponent({
     },
     async onBuy() {
       try {
+        if (this.userInfo.payType === 'VIP') {
+          if (browser().isApp) {
+            postMessage({
+              api: 'openWebView',
+              content: {
+                url: `${location.origin}${location.pathname}#/memberCenter`,
+                orientation: 1,
+                isHideTitle: false
+              }
+            })
+          } else {
+            this.$router.push({
+              path: '/memberCenter'
+            })
+          }
+          return
+        }
+
         const userInfo = this.userInfo
         orderStatus.orderObject.orderType = 'VIDEO'
         orderStatus.orderObject.orderName = '视频课购买'
@@ -182,6 +216,22 @@ export default defineComponent({
       } catch {}
     }
   },
+  watch: {
+    pageVisibility() {
+      // 如果不是会员则不用刷新
+      if (this.userInfo.payType !== 'VIP') {
+        return
+      }
+      request
+        .get('/api-student/student/queryUserInfo', {
+          initRequest: true // 初始化接口
+        })
+        .then((res: any) => {
+          setLogin(res.data)
+          this.userInfo.alreadyBuy = res.data?.isVip ? true : false
+        })
+    }
+  },
   render() {
     return (
       <div class={[styles['video-detail']]}>
@@ -195,7 +245,6 @@ export default defineComponent({
         <UserDetail
           userInfo={this.userInfo}
           onUserDetail={(item: any) => {
-            console.log(item)
             if (browser().isApp && state.platformType === 'STUDENT') {
               this.$router.push({
                 path: '/teacherHome',
@@ -279,7 +328,11 @@ export default defineComponent({
                 onClick={this.onBuy}
                 disabled={this.platformStatus}
               >
-                {this.userInfo.lessonPrice <= 0 ? '免费领取' : `立即购买`}
+                {this.userInfo.payType === 'VIP'
+                  ? '开通会员'
+                  : this.userInfo.lessonPrice <= 0
+                  ? '免费领取'
+                  : `立即购买`}
               </Button>
             </div>
           </ColSticky>

+ 25 - 15
src/student/video-class/video-item.tsx

@@ -60,28 +60,38 @@ export default defineComponent({
           </div> */}
           <div class={styles.viPrice}>
             <span class={styles.priceNum}>
-              {item?.lessonPrice > 0 && (
+              {item.payType === 'VIP' ? (
+                <span style={{ color: '#C76E21' }}>会员</span>
+              ) : (
                 <>
-                  <i>¥</i>
-                  {item?.lessonPrice}
+                  {item?.lessonPrice > 0 && (
+                    <>
+                      <i>¥</i>
+                      {item?.lessonPrice}
+                    </>
+                  )}
+                  {item?.lessonPrice <= 0 && item.auditVersion !== 0 && (
+                    <>
+                      <i>¥</i>0
+                    </>
+                  )}
+                  {item?.lessonPrice <= 0 && item.auditVersion === 0 && (
+                    <span style={{ color: '#20BEA0' }}>免费</span>
+                  )}
                 </>
               )}
-              {item?.lessonPrice <= 0 && item.auditVersion !== 0 && (
-                <>
-                  <i>¥</i>0
-                </>
-              )}
-              {item?.lessonPrice <= 0 && item.auditVersion === 0 && <>免费</>}
             </span>
             <span class={styles.label}>/{item?.lessonCount}课时</span>
           </div>
 
-          <div class={styles.viUserNum}>
-            {item?.countStudent}人已
-            {item?.lessonPrice <= 0 && item.auditVersion === 0
-              ? '领取'
-              : '购买'}
-          </div>
+          {item?.payType !== 'VIP' && (
+            <div class={styles.viUserNum}>
+              {item?.countStudent}人已
+              {item?.lessonPrice <= 0 && item.auditVersion === 0
+                ? '领取'
+                : '购买'}
+            </div>
+          )}
         </div>
       </div>
     )

+ 118 - 85
src/teacher/video-class/class-info.module.less

@@ -1,85 +1,118 @@
-.classInfo {
-  .infoField {
-    width: 50vw;
-    font-size: 16px;
-
-    :global {
-      .van-tab {
-        font-size: 16px;
-      }
-      .van-tabs__nav--line {
-        padding-left: 0;
-      }
-      .van-tab--active {
-        color: #000;
-      }
-      // .van-tab--shrink {
-      //   padding-left: 0;
-      // }
-    }
-  }
-
-  .boxStyle {
-    background: transparent !important;
-    width: 18px;
-    height: 18px;
-    border: transparent !important;
-  }
-  :global {
-    .van-radio {
-      display: inline-block;
-      align-items: inherit;
-      overflow: inherit;
-    }
-    .van-radio__icon {
-      height: 18px;
-      line-height: 18px;
-      display: inline-block;
-      vertical-align: sub;
-    }
-    .van-radio__label {
-      line-height: 18px;
-    }
-  }
-
-  .imgContainer {
-    width: 150px;
-    height: 85px;
-    border-radius: 10px;
-    overflow: hidden;
-    margin: 0 0 12px;
-    position: relative;
-
-    :global {
-      .van-radio {
-        position: absolute;
-        bottom: 10px;
-        right: 20px;
-        z-index: 9;
-      }
-    }
-  }
-
-  .btnGroup {
-    padding: 0 14px;
-    padding-bottom: 15px;
-  }
-}
-
-.class-info-tip {
-  font-size: 14px;
-  color: #999999;
-  line-height: 27px;
-  padding: 0 12px 12px;
-
-  span {
-    color: #ff4e19;
-  }
-}
-
-.photoTip {
-  font-size: 14px;
-  color: #999999;
-  line-height: 27px;
-  padding: 5px 0;
-}
+.classInfo {
+  .infoField {
+    width: 50vw;
+    font-size: 16px;
+
+    :global {
+      .van-tab {
+        font-size: 16px;
+      }
+
+      .van-tabs__nav--line {
+        padding-left: 0;
+      }
+
+      .van-tab--active {
+        color: #000;
+      }
+
+      // .van-tab--shrink {
+      //   padding-left: 0;
+      // }
+    }
+  }
+
+  .boxStyle {
+    background: transparent !important;
+    width: 18px;
+    height: 18px;
+    border: transparent !important;
+  }
+
+  :global {
+    .van-radio {
+      display: inline-block;
+      align-items: inherit;
+      overflow: inherit;
+    }
+
+    .van-radio__icon {
+      height: 18px;
+      line-height: 18px;
+      display: inline-block;
+      vertical-align: sub;
+    }
+
+    .van-radio__label {
+      line-height: 18px;
+    }
+  }
+
+  .radioGroup {
+    padding-top: 14px;
+    display: flex;
+  }
+
+  .radio {
+    width: 80px;
+    height: 28px;
+    line-height: 28px;
+    background: #F8F8F8;
+    border: 1px solid #F8F8F8;
+    border-radius: 5px;
+    font-size: 16px;
+    color: #C0C0C0;
+    text-align: center;
+
+    &+.radio {
+      margin-left: 12px;
+    }
+
+    &.active {
+      background: #E9FFF8;
+      border: 1px solid var(--van-primary);
+      color: var(--van-primary);
+    }
+  }
+
+  .imgContainer {
+    width: 150px;
+    height: 85px;
+    border-radius: 10px;
+    overflow: hidden;
+    margin: 0 0 12px;
+    position: relative;
+
+    :global {
+      .van-radio {
+        position: absolute;
+        bottom: 10px;
+        right: 20px;
+        z-index: 9;
+      }
+    }
+  }
+
+  .btnGroup {
+    padding: 0 14px;
+    padding-bottom: 15px;
+  }
+}
+
+.class-info-tip {
+  font-size: 14px;
+  color: #999999;
+  line-height: 27px;
+  padding: 0 12px 12px;
+
+  span {
+    color: #ff4e19;
+  }
+}
+
+.photoTip {
+  font-size: 14px;
+  color: #999999;
+  line-height: 27px;
+  padding: 5px 0;
+}

+ 66 - 27
src/teacher/video-class/class-info.tsx

@@ -165,35 +165,74 @@ export default defineComponent({
           </ColField>
         </ColFieldGroup>
 
-        {!this.checked && (
-          <ColFieldGroup>
-            <ColField title="课程组售价" required>
-              <Field
-                v-model={createState.lessonGroup.lessonPrice}
-                name="lessonPrice"
-                placeholder="请输入您的课程组售价"
-                formatter={this.onFormatter}
-                type="number"
-                maxlength={8}
-                rules={[{ required: true, message: '请输入您的课程组售价' }]}
-                v-slots={{
-                  button: () => <span>元</span>
+        <ColFieldGroup>
+          <ColField title="收费方式" required border={false}>
+            <div class={styles.radioGroup}>
+              <div
+                onClick={() => {
+                  createState.lessonGroup.payType = 'PAY'
                 }}
-              />
-            </ColField>
-          </ColFieldGroup>
-        )}
+                class={[
+                  styles.radio,
+                  createState.lessonGroup.payType === 'PAY'
+                    ? styles.active
+                    : null
+                ]}
+              >
+                购买
+              </div>
+              <div
+                onClick={() => {
+                  createState.lessonGroup.payType = 'VIP'
+                }}
+                class={[
+                  styles.radio,
+                  createState.lessonGroup.payType === 'VIP'
+                    ? styles.active
+                    : null
+                ]}
+              >
+                会员
+              </div>
+            </div>
+          </ColField>
+        </ColFieldGroup>
+
+        {createState.lessonGroup.payType === 'PAY' && (
+          <>
+            {!this.checked && (
+              <ColFieldGroup>
+                <ColField title="课程组售价" required>
+                  <Field
+                    v-model={createState.lessonGroup.lessonPrice}
+                    name="lessonPrice"
+                    placeholder="请输入您的课程组售价"
+                    formatter={this.onFormatter}
+                    type="number"
+                    maxlength={8}
+                    rules={[
+                      { required: true, message: '请输入您的课程组售价' }
+                    ]}
+                    v-slots={{
+                      button: () => <span>元</span>
+                    }}
+                  />
+                </ColField>
+              </ColFieldGroup>
+            )}
 
-        <div class={styles['class-info-tip']}>
-          <p>扣除手续费后您的课程预计收入为:</p>
-          <p>
-            课程组总收入<span>{this.calcRatePrice}</span>元/人
-          </p>
-          <p>
-            您的课程收入将在学员购买{createState.video_account_period}
-            天后结算到您的账户中
-          </p>
-        </div>
+            <div class={styles['class-info-tip']}>
+              <p>扣除手续费后您的课程预计收入为:</p>
+              <p>
+                课程组总收入<span>{this.calcRatePrice}</span>元/人
+              </p>
+              <p>
+                您的课程收入将在学员购买{createState.video_account_period}
+                天后结算到您的账户中
+              </p>
+            </div>
+          </>
+        )}
 
         <ColFieldGroup>
           <ColField

+ 3 - 0
src/teacher/video-class/create-submit.tsx

@@ -21,6 +21,7 @@ export default defineComponent({
         headUrl: users.headUrl,
         lessonName: videoDetail.lessonName,
         buyNum: 0,
+        payType: videoDetail.payType,
         lessonDesc: videoDetail.lessonDesc,
         lessonPrice: videoDetail.lessonPrice,
         lessonCoverUrl:
@@ -57,6 +58,8 @@ export default defineComponent({
           lessonList: this.lessonList,
           lessonGroup: {
             ...videoDetail,
+            lessonPrice:
+              videoDetail.payType === 'VIP' ? 0 : videoDetail.lessonPrice,
             lessonCoverUrl:
               videoDetail.lessonCoverTemplateUrl || videoDetail.lessonCoverUrl
           }

+ 1 - 0
src/teacher/video-class/createState.tsx

@@ -30,6 +30,7 @@ export const createState = reactive({
     lessonName: '',
     lessonSubject: null as any,
     lessonDesc: '',
+    payType: 'PAY',
     lessonPrice: null as any,
     lessonCoverUrl: '',
     relationType: 'RECOMMEND',

+ 7 - 3
src/teacher/video-class/video-class-detail.tsx

@@ -34,6 +34,7 @@ export default defineComponent({
       tabIndex: 1,
       title: '',
       lessonPrice: 0,
+      payType: '',
       useRelationType: '',
       alreadyBuy: false,
       currentClassIndex: 1,
@@ -82,6 +83,7 @@ export default defineComponent({
       this.title = result.lessonGroup.lessonName
       this.useRelationType = result.lessonGroup.relationType
       this.lessonPrice = result.lessonGroup.lessonPrice
+      this.payType = result.lessonGroup.payType
       this.alreadyBuy = result.alreadyBuy
       this.detailList = result.detailList || []
 
@@ -100,7 +102,7 @@ export default defineComponent({
       })
 
       const config = await request.get(
-        '/api-student/sysConfig/queryByParamNameList',
+        '/api-teacher/sysConfig/queryByParamNameList',
         {
           params: {
             paramNames: 'video_lesson_free_rate'
@@ -132,7 +134,6 @@ export default defineComponent({
         })
         this.loading = false
         const result = res.data || {}
-        console.log(result)
         // 处理重复请求数据
         if (this.list.length > 0 && result.pageNo === 1) {
           return
@@ -201,8 +202,11 @@ export default defineComponent({
         <ColVideo
           src={this.srcUrl}
           poster={this.posterUrl}
-          freeTitleStatus={this.lessonPrice > 0 ? true : false}
+          freeTitleStatus={
+            this.lessonPrice > 0 || this.payType === 'VIP' ? true : false
+          }
           freeRate={Number(this.freeRate)}
+          payType={this.payType}
           trySee={this.trySee}
           height={this.videoHeight}
         />

+ 1 - 0
src/teacher/video-class/video-detail.tsx

@@ -58,6 +58,7 @@ export default defineComponent({
         buyNum: result.lessonGroup.countStudent,
         lessonId: result.lessonGroup.id,
         lessonNum: result.lessonGroup.lessonCount,
+        payType: result.lessonGroup.payType,
         lessonName: result.lessonGroup.lessonName,
         lessonDesc: result.lessonGroup.lessonDesc,
         lessonPrice: result.lessonGroup.lessonPrice,

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

@@ -1,258 +1,258 @@
-import ColHeader from '@/components/col-header'
-import ColSearch from '@/components/col-search'
-import { Sticky, Image, List, Popup, Icon } from 'vant'
-import { defineComponent } from 'vue'
-import styles from './index.module.less'
-import VideoItem from '@/student/video-class/video-item'
-// import VideoItem from './video-item'
-
-import banner from './images/banner.png'
-import request from '@/helpers/request'
-import ColResult from '@/components/col-result'
-import { state } from '@/state'
-import OrganSearch from '@/student/practice-class/model/organ-search'
-import { SubjectEnum, useEventTracking, useSubjectId } from '@/helpers/hooks'
-
-export default defineComponent({
-  name: 'VideoClass',
-  data() {
-    return {
-      apiSuffix:
-        state.platformType === 'STUDENT' ? '/api-student' : '/api-teacher',
-      search: '',
-      list: [],
-      dataShow: true, // 判断是否有数据
-      loading: false,
-      finished: false,
-      listLoading: true,
-      params: {
-        search: '',
-        lessonSubject: null as any,
-        subjectName: '全部声部',
-        page: 1,
-        rows: 20
-      },
-      searchStatus: false,
-      openStatus: false,
-      subjectList: []
-    }
-  },
-  async mounted() {
-    try {
-      const res = await request.get(
-        `${this.apiSuffix}/subject/subjectSelect?type=VIDEO`
-      )
-      this.subjectList = res.data || []
-    } catch {
-      //
-    }
-
-    if (state.platformType === 'TEACHER') {
-      const users = state.user.data
-      if (users.defaultSubject) {
-        this.params.lessonSubject = users.defaultSubject
-        this.params.subjectName = users.defaultSubjectName
-      }
-    } else {
-      // 判断是否在缓存
-      const subjects: any = useSubjectId(SubjectEnum.VIDEO)
-      if (subjects.id) {
-        this.params.lessonSubject = Number(subjects.id)
-        this.params.subjectName = subjects.name
-      } else {
-        const list = this.subjectList
-        const subjectIds = state.user.data?.subjectId || ''
-        const subjectId = subjectIds ? Number(subjectIds.split(',')[0]) : null
-        list.forEach((subject: any) => {
-          const child = subject.subjects || []
-          child.forEach((sub: any) => {
-            if (sub.id === Number(subjectId)) {
-              this.params.lessonSubject = sub.id
-              this.params.subjectName = sub.name
-            }
-          })
-        })
-      }
-    }
-    this.listLoading = false
-    this.getList()
-
-    useEventTracking('视频课')
-  },
-  methods: {
-    async getList() {
-      try {
-        if (this.listLoading) return
-        this.listLoading = true
-
-        const params: any = {
-          ...this.params
-        }
-        // 只有学生端会有version
-        if (state.version) {
-          params.version = state.version || '' // 处理ios审核版本
-          params.platform =
-            state.platformType === 'STUDENT' ? 'ios-student' : 'ios-teacher'
-        }
-        const url =
-          state.platformType === 'STUDENT'
-            ? '/api-student/videoLesson/selectGroup'
-            : '/api-teacher/videoLessonGroup/page'
-        // 处理搜索,老师端分享用
-        // if (state.platformType === 'TEACHER') {
-        params.myself = false
-        // }
-        const res = await request.post(url, {
-          data: {
-            ...params
-          }
-        })
-        this.loading = false
-        const result = res.data || {}
-        // 处理重复请求数据
-        if (this.list.length > 0 && result.pageNo === 1) {
-          return
-        }
-        this.list = this.list.concat(result.rows || [])
-        this.finished = result.pageNo >= result.totalPage
-        this.params.page = result.pageNo + 1
-        this.dataShow = this.list.length > 0
-      } catch {
-        this.dataShow = false
-        this.finished = true
-      } finally {
-        this.listLoading = false
-      }
-    },
-    // 设置默认声部
-    async setDefaultSubject(subjectId: any) {
-      try {
-        await request.post('/api-teacher/teacher/defaultSubject', {
-          params: {
-            subjectId
-          }
-        })
-      } catch {
-        //
-      }
-    },
-    onSort() {
-      this.params.page = 1
-      this.list = []
-      this.dataShow = true // 判断是否有数据
-      this.loading = false
-      this.finished = false
-      this.searchStatus = false
-      if (state.platformType === 'TEACHER') {
-        this.setDefaultSubject(this.params.lessonSubject)
-      } else {
-        this.params.lessonSubject &&
-          useSubjectId(
-            SubjectEnum.VIDEO,
-            JSON.stringify({
-              id: this.params.lessonSubject,
-              name: this.params.subjectName
-            }),
-            'set'
-          )
-      }
-      this.getList()
-    },
-    onSearch(val: string) {
-      this.params.search = val
-      this.onSort()
-    },
-    onDetail(item: any) {
-      const params: any = {
-        groupId: item.id
-      }
-      // 判断是否是老师端,如果是,则添加分享按钮
-      if (state.platformType === 'TEACHER') {
-        params.share = 1
-      }
-      this.$router.push({
-        path: '/videoDetail',
-        query: params
-      })
-    }
-  },
-  render() {
-    return (
-      <div class={styles.videoClass}>
-        <Sticky offsetTop={0} position="top">
-          <ColHeader
-            class={styles.classHeader}
-            border={false}
-            isFixed={false}
-            background="transparent"
-          />
-          <ColSearch
-            placeholder="请输入老师名称/课程名称"
-            onSearch={this.onSearch}
-            v-slots={{
-              left: () => (
-                <div
-                  class={styles.label}
-                  onClick={() => {
-                    this.searchStatus = !this.searchStatus
-                    this.openStatus = !this.openStatus
-                  }}
-                >
-                  {this.params.subjectName}
-                  <Icon
-                    classPrefix="iconfont"
-                    name="down"
-                    size={12}
-                    color="#333"
-                  />
-                </div>
-              )
-            }}
-          />
-        </Sticky>
-
-        {/* <div class={styles.banner}>
-          <Image src={banner} />
-        </div> */}
-
-        <div>
-          {this.dataShow ? (
-            <List
-              class={styles.videoList}
-              v-model:loading={this.loading}
-              finished={this.finished}
-              finishedText="没有更多了"
-              onLoad={this.getList}
-              immediateCheck={false}
-            >
-              {this.list.map(item => (
-                <VideoItem item={item} onClick={this.onDetail} />
-              ))}
-            </List>
-          ) : (
-            <ColResult btnStatus={false} tips="暂无视频课" />
-          )}
-        </div>
-
-        <Popup
-          show={this.searchStatus}
-          position="bottom"
-          round
-          closeable
-          safe-area-inset-bottom
-          onClose={() => (this.searchStatus = false)}
-          onClosed={() => (this.openStatus = false)}
-        >
-          {this.openStatus && (
-            <OrganSearch
-              subjectList={this.subjectList}
-              onSort={this.onSort}
-              v-model={this.params.lessonSubject}
-              v-model:subjectName={this.params.subjectName}
-            />
-          )}
-        </Popup>
-      </div>
-    )
-  }
-})
+import ColHeader from '@/components/col-header'
+import ColSearch from '@/components/col-search'
+import { Sticky, Image, List, Popup, Icon } from 'vant'
+import { defineComponent } from 'vue'
+import styles from './index.module.less'
+import VideoItem from '@/student/video-class/video-item'
+// import VideoItem from './video-item'
+
+import banner from './images/banner.png'
+import request from '@/helpers/request'
+import ColResult from '@/components/col-result'
+import { state } from '@/state'
+import OrganSearch from '@/student/practice-class/model/organ-search'
+import { SubjectEnum, useEventTracking, useSubjectId } from '@/helpers/hooks'
+
+export default defineComponent({
+  name: 'VideoClass',
+  data() {
+    return {
+      apiSuffix:
+        state.platformType === 'STUDENT' ? '/api-student' : '/api-teacher',
+      search: '',
+      list: [],
+      dataShow: true, // 判断是否有数据
+      loading: false,
+      finished: false,
+      listLoading: true,
+      params: {
+        search: '',
+        lessonSubject: null as any,
+        subjectName: '全部声部',
+        page: 1,
+        rows: 20
+      },
+      searchStatus: false,
+      openStatus: false,
+      subjectList: []
+    }
+  },
+  async mounted() {
+    try {
+      const res = await request.get(
+        `${this.apiSuffix}/subject/subjectSelect?type=VIDEO`
+      )
+      this.subjectList = res.data || []
+    } catch {
+      //
+    }
+
+    if (state.platformType === 'TEACHER') {
+      const users = state.user.data
+      if (users.defaultSubject) {
+        this.params.lessonSubject = users.defaultSubject
+        this.params.subjectName = users.defaultSubjectName
+      }
+    } else {
+      // 判断是否在缓存
+      const subjects: any = useSubjectId(SubjectEnum.VIDEO)
+      if (subjects.id) {
+        this.params.lessonSubject = Number(subjects.id)
+        this.params.subjectName = subjects.name
+      } else {
+        const list = this.subjectList
+        const subjectIds = state.user.data?.subjectId || ''
+        const subjectId = subjectIds ? Number(subjectIds.split(',')[0]) : null
+        list.forEach((subject: any) => {
+          const child = subject.subjects || []
+          child.forEach((sub: any) => {
+            if (sub.id === Number(subjectId)) {
+              this.params.lessonSubject = sub.id
+              this.params.subjectName = sub.name
+            }
+          })
+        })
+      }
+    }
+    this.listLoading = false
+    this.getList()
+
+    useEventTracking('视频课')
+  },
+  methods: {
+    async getList() {
+      try {
+        if (this.listLoading) return
+        this.listLoading = true
+
+        const params: any = {
+          ...this.params
+        }
+        // 只有学生端会有version
+        if (state.version) {
+          params.version = state.version || '' // 处理ios审核版本
+          params.platform =
+            state.platformType === 'STUDENT' ? 'ios-student' : 'ios-teacher'
+        }
+        const url =
+          state.platformType === 'STUDENT'
+            ? '/api-student/videoLesson/selectGroup'
+            : '/api-teacher/videoLessonGroup/page'
+        // 处理搜索,老师端分享用
+        // if (state.platformType === 'TEACHER') {
+        params.myself = false
+        // }
+        const res = await request.post(url, {
+          data: {
+            ...params
+          }
+        })
+        this.loading = false
+        const result = res.data || {}
+        // 处理重复请求数据
+        if (this.list.length > 0 && result.pageNo === 1) {
+          return
+        }
+        this.list = this.list.concat(result.rows || [])
+        this.finished = result.pageNo >= result.totalPage
+        this.params.page = result.pageNo + 1
+        this.dataShow = this.list.length > 0
+      } catch {
+        this.dataShow = false
+        this.finished = true
+      } finally {
+        this.listLoading = false
+      }
+    },
+    // 设置默认声部
+    async setDefaultSubject(subjectId: any) {
+      try {
+        await request.post('/api-teacher/teacher/defaultSubject', {
+          params: {
+            subjectId
+          }
+        })
+      } catch {
+        //
+      }
+    },
+    onSort() {
+      this.params.page = 1
+      this.list = []
+      this.dataShow = true // 判断是否有数据
+      this.loading = false
+      this.finished = false
+      this.searchStatus = false
+      if (state.platformType === 'TEACHER') {
+        this.setDefaultSubject(this.params.lessonSubject)
+      } else {
+        this.params.lessonSubject &&
+          useSubjectId(
+            SubjectEnum.VIDEO,
+            JSON.stringify({
+              id: this.params.lessonSubject,
+              name: this.params.subjectName
+            }),
+            'set'
+          )
+      }
+      this.getList()
+    },
+    onSearch(val: string) {
+      this.params.search = val
+      this.onSort()
+    },
+    onDetail(item: any) {
+      const params: any = {
+        groupId: item.id
+      }
+      // 判断是否是老师端,如果是,则添加分享按钮
+      if (state.platformType === 'TEACHER') {
+        params.share = 1
+      }
+      this.$router.push({
+        path: '/videoDetail',
+        query: params
+      })
+    }
+  },
+  render() {
+    return (
+      <div class={styles.videoClass}>
+        <Sticky offsetTop={0} position="top">
+          <ColHeader
+            class={styles.classHeader}
+            border={false}
+            isFixed={false}
+            background="transparent"
+          />
+          <ColSearch
+            placeholder="请输入老师名称/课程名称"
+            onSearch={this.onSearch}
+            v-slots={{
+              left: () => (
+                <div
+                  class={styles.label}
+                  onClick={() => {
+                    this.searchStatus = !this.searchStatus
+                    this.openStatus = !this.openStatus
+                  }}
+                >
+                  {this.params.subjectName}
+                  <Icon
+                    classPrefix="iconfont"
+                    name="down"
+                    size={12}
+                    color="#333"
+                  />
+                </div>
+              )
+            }}
+          />
+        </Sticky>
+
+        {/* <div class={styles.banner}>
+          <Image src={banner} />
+        </div> */}
+
+        <div>
+          {this.dataShow ? (
+            <List
+              class={styles.videoList}
+              v-model:loading={this.loading}
+              finished={this.finished}
+              finishedText="没有更多了"
+              onLoad={this.getList}
+              immediateCheck={false}
+            >
+              {this.list.map(item => (
+                <VideoItem item={item} onClick={this.onDetail} />
+              ))}
+            </List>
+          ) : (
+            <ColResult btnStatus={false} tips="暂无视频课" />
+          )}
+        </div>
+
+        <Popup
+          show={this.searchStatus}
+          position="bottom"
+          round
+          closeable
+          safe-area-inset-bottom
+          onClose={() => (this.searchStatus = false)}
+          onClosed={() => (this.openStatus = false)}
+        >
+          {this.openStatus && (
+            <OrganSearch
+              subjectList={this.subjectList}
+              onSort={this.onSort}
+              v-model={this.params.lessonSubject}
+              v-model:subjectName={this.params.subjectName}
+            />
+          )}
+        </Popup>
+      </div>
+    )
+  }
+})

+ 1 - 1
vite.config.ts

@@ -12,7 +12,7 @@ function resolve(dir: string) {
 // https://vitejs.dev/config/
 // https://github.com/vitejs/vite/issues/1930 .env
 // const proxyUrl = 'https://online.colexiu.com/'
-const proxyUrl = 'https://test.colexiu.com/'
+const proxyUrl = 'https://dev.colexiu.com/'
 // const proxyUrl = 'http://192.168.3.14:8000/'
 export default defineConfig({
   base: './',