detail.vue 49 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902
  1. <template>
  2. <view>
  3. <view style="position: fixed;width: 100%;z-index: 999;background: #FFFFFF;top: 0;" id="top">
  4. <view class="video_box" v-if="!startStatus">
  5. <image :src="$method.splitImgHost(detail.coverUrl)" style="width: 100%;height: 460rpx;"></image>
  6. <image v-if="false" class="video_play" src="/static/play.png" @click="startVideo"></image>
  7. </view>
  8. <view v-else>
  9. <view class="video_box" style="width: 100%;height: 460rpx;" v-if="playVID">
  10. <polyv-player
  11. id="playerVideo"
  12. playerId="playerVideo"
  13. height="460rpx"
  14. :vid="vid"
  15. :showSettingBtn="true"
  16. :enablePlayGesture="true"
  17. @statechange="onStateChange"
  18. :autoplay="autoplay"
  19. :isAllowSeek="isAllowSeek"
  20. :playbackRate="playbackRate"
  21. :startTime="startTime"
  22. ></polyv-player>
  23. </view>
  24. <view class="video_box" style="width: 100%;height: 460rpx;" v-if="playChannelId>0">
  25. <player
  26. class="plv-mp-demo-player"
  27. :videoOption="videoOption"
  28. @onLiveStatusChange="playerLiveStatusChange"
  29. />
  30. </view>
  31. </view>
  32. <view>
  33. <u-row>
  34. <u-col span="10">
  35. <view class="video_t1">{{ detail.courseName }}</view>
  36. </u-col>
  37. <u-col span="2" v-if="false">
  38. <view class="video_t1_t" @click="openJY">
  39. <image src="/static/icon/jy_icon.png" style="width: 40rpx;height: 40rpx;"></image>
  40. 讲义
  41. </view>
  42. </u-col>
  43. </u-row>
  44. </view>
  45. <u-line color="#D6D6DB" />
  46. <view>
  47. <view><u-tabs gutter="0" :item-width="itemWidth()" :list="list" font-size="32" bar-width="24" :current="current" @change="change" active-color="#007AFF"></u-tabs></view>
  48. </view>
  49. <u-line color="#D6D6DB" />
  50. </view>
  51. <view class="box">
  52. <!--目录 -->
  53. <view v-show="current == 0">
  54. <view class="menuBox" v-for="(item, index) in menuList" :key="index">
  55. <!--模块 -->
  56. <view v-if="item.type == 1"><courseModule :courseId="courseId" :learningOrder="businessData.goodsLearningOrder" :goodsId="goodsId" :gradeId="gradeId" :isBuy="true" :menuItem="item" :levelId="item.menuId"></courseModule></view>
  57. <!--章 -->
  58. <view v-if="item.type == 2"><courseChapter :courseId="courseId" :learningOrder="businessData.goodsLearningOrder" :goodsId="goodsId" :gradeId="gradeId" :isBuy="true" :menuItem="item" :levelId="'0-' + item.menuId"></courseChapter></view>
  59. <!--节 -->
  60. <view v-if="item.type == 3"><courseSection @playEnd="sectionPlayEnd(index)" :courseId="courseId" :goodsId="goodsId" :gradeId="gradeId" :isBuy="true" :menuItem="item" :levelId="'0-0-' + item.menuId"></courseSection></view>
  61. </view>
  62. </view>
  63. <!--讲义 -->
  64. <view v-show="current == 1">
  65. <view class="lecture-box">
  66. <view class="title">
  67. {{courseHandoutsData.handoutsName}}
  68. <!-- 这是后台配置的讲义标题过长省略这是后台配置的讲义标题过长省略 -->
  69. </view>
  70. <view class="btn" @click="openDocument">
  71. <u-icon name="download" color="#007AFF" size="40"></u-icon>
  72. </view>
  73. </view>
  74. <!-- <view class="lecture-content">
  75. <rich-text :nodes="'讲义内容讲义内容讲义内容讲义内容讲义内容讲义内容讲义内容讲义内容讲义内容讲义内容讲义内容讲义内容讲义内容讲义内容讲义内容讲义内容讲义内容讲义内容讲义内容讲义内容讲义内容讲义内容讲义内容讲义内容讲义内容讲义内容讲义内容讲义内容讲义内容讲义内容讲义内容讲义内容讲义内容讲义内容讲义内容讲义内容讲义内容讲义内容讲义内容讲义内容讲义内容讲义内容讲义内容讲义内容讲义内容讲义内容讲义内容讲义内容讲义内容讲义内容讲义内容讲义内容讲义内容讲义内容讲义内容讲义内容讲义内容讲义内容讲义内容讲义内容讲义内容讲义内容讲义内容讲义内容讲义内容讲义内容讲义内容讲义内容讲义内容讲义内容讲义内容讲义内容讲义内容讲义内容讲义内容讲义内容讲义内容'"></rich-text>
  76. </view> -->
  77. <!-- <view class="inputBottom">
  78. <view style="width: 10%;"><image src="/static/icon/note3.png" style="width: 39rpx;height: 39rpx;margin:0 29rpx;"></image></view>
  79. <view style="width: 73%;height: 100%;padding: 10rpx 0;">
  80. <u-input class="input" height="60" fixed="true" placeholder="您可以在这里输入笔记内容" type="textarea" :custom-style="inputStyle" v-model="noteValue" />
  81. </view>
  82. <view style="color: #007AFF;font-size: 30rpx;font-weight: bold;width: 15%;text-align: center;" @click="postNote">提交</view>
  83. </view> -->
  84. </view>
  85. <!--笔记 -->
  86. <view v-show="current == 2">
  87. <view v-if="noteList.length == 0" style="text-align: center;">暂无笔记</view>
  88. <view class="inputBottom">
  89. <view style="width: 10%;"><image src="/static/icon/note3.png" style="width: 39rpx;height: 39rpx;margin:0 29rpx;"></image></view>
  90. <view style="width: 73%;height: 100%;padding: 10rpx 0;">
  91. <u-input class="input" height="60" fixed="true" placeholder="您可以在这里输入笔记内容" type="textarea" :custom-style="inputStyle" v-model="noteValue" />
  92. </view>
  93. <view style="color: #007AFF;font-size: 30rpx;font-weight: bold;width: 15%;text-align: center;" @click="postNote">提交</view>
  94. </view>
  95. <view v-for="(item, index) in noteList" :key="index">
  96. <view class="dateBox">{{ $method.timestampToTime(item.dateNote) }}</view>
  97. <view class="noteBox">
  98. <view v-for="(item1, index1) in item.userNotes" :key="index1" style="margin-top: 30rpx;" @click="jumpNote(item1)">
  99. <view style="display: flex;">
  100. <view>
  101. <view>
  102. <image src="/static/icon/note2.png" v-if="noteId != item1.noteId" style="width: 39rpx;height: 39rpx;margin:0 29rpx;"></image>
  103. <image src="/static/icon/note1.png" v-if="noteId == item1.noteId" style="width: 39rpx;height: 39rpx;margin:0 29rpx;"></image>
  104. </view>
  105. <view class="title" style="width: 39rpx;height: 39rpx;margin:0 29rpx;">{{ $method.secondToDate(item1.noteSecond) }}</view>
  106. </view>
  107. <view style="margin-left: 10rpx;">
  108. <view class="t2Content leftPadding">{{ item1.sectionName }}</view>
  109. <view class="tBox2">{{ item1.noteText }}</view>
  110. </view>
  111. </view>
  112. </view>
  113. </view>
  114. </view>
  115. </view>
  116. <!--答疑 -->
  117. <view v-show="current == 3">
  118. <view class="inputBottom">
  119. <view class="flex_auto">
  120. <u-input height="60" fixed="true" :placeholder="placeholder" type="textarea" :custom-style="inputStyle" v-model="ctxValue" />
  121. </view>
  122. <view class="btn" @click="postContent">提交</view>
  123. </view>
  124. <view v-for="(item, index) in answerList" :key="index" style="background-color: #FFFFFF;margin-bottom: 20rpx;">
  125. <view class="chat_box" @click.stop="clearCtx">
  126. <view style="display: flex;">
  127. <view><image :src="$method.splitImgHost(item.avatar)" style="width: 64rpx;height: 64rpx;"></image></view>
  128. <view style="margin-left: 15rpx;">
  129. <view class="chat1">{{ item.realname }}</view>
  130. <view class="chat2">{{ $method.timestampToTime(item.createTime) }}</view>
  131. <view class="chat3">
  132. <text v-if="item.assignUserId > 0">回复</text>
  133. <text v-if="item.assignUserId > 0" style="color: #007AFF;">@{{ item.assignRealname }}</text>
  134. {{ item.answerText }}
  135. </view>
  136. </view>
  137. </view>
  138. <view class="btnReply" @click.stop="replyContent(item)" v-if="item.userId != userInfo.userId">回复</view>
  139. <view v-else class="btnDel" @click.stop="delContent(item)">删除</view>
  140. </view>
  141. <u-line color="#D6D6DB" />
  142. </view>
  143. <view v-if="answerList.length == 0" style="text-align: center;">暂无记录</view>
  144. </view>
  145. <!--目录 -->
  146. <view v-show="current == 4" >
  147. <view class="menuBox" v-for="(item, index) in reMenuList" :key="index">
  148. <!--模块 -->
  149. <view v-if="item.type == 1"><courseModule :courseId="courseId" :goodsId="goodsId" :gradeId="gradeId" :isRebuild="true" :isBuy="true" :menuItem="item" :levelId="item.menuId"></courseModule></view>
  150. <!--章 -->
  151. <view v-if="item.type == 2">
  152. <courseChapter :courseId="courseId" :gradeId="gradeId" :goodsId="goodsId" :isRebuild="true" :isBuy="true" :menuItem="item" :levelId="'0-' + item.menuId"></courseChapter>
  153. </view>
  154. <!--节 -->
  155. <view v-if="item.type == 3">
  156. <courseSection :courseId="courseId" :gradeId="gradeId" :goodsId="goodsId" :isRebuild="true" :isBuy="true" :nextMenuItem="findMenuNextSection(index)" :menuItem="item" :levelId="'0-0-' + item.menuId"></courseSection>
  157. </view>
  158. </view>
  159. </view>
  160. </view>
  161. <!-- 播放前拍照end -->
  162. <u-popup v-model="showSet" :mask-close-able="false" mode="center" border-radius="24">
  163. <view style="align-items:center;padding: 0 40rpx;display: flex;flex-direction: column;justify-content:center;">
  164. <view style="font-weight: bold;color: #333333;font-size: 30rpx;margin-top: 30rpx;">温馨提示</view>
  165. <view style="width: 457rpx;color: #666666;font-size: 30rpx;margin-top: 30rpx;">学习过程中需要拍照验证学员身份,
  166. 拍照功能需要使用您的相机。
  167. 是否授权使用?</view>
  168. <view style="margin: 40rpx 0;">
  169. <button open-type="openSetting" @bindopensetting="openSetting" class="btnSet">去授权</button>
  170. </view>
  171. </view>
  172. </u-popup>
  173. <u-mask :show="photoPopup" >
  174. <!-- 播放前拍照start -->
  175. <view v-if="photoPopup" :mask-close-able="false" style="bottom: 0;position: fixed;width: 100%;z-index: 999;">
  176. <view class="photoBox">
  177. <view class="photoTop">
  178. <view class="sqzz" v-if="false"><u-icon name="close" color="#333333" size="30" @click="closePhoto"></u-icon></view>
  179. <view class="centersq">请正视手机屏幕</view>
  180. <view class="sqzz"></view>
  181. </view>
  182. <view class="photoCenter">
  183. <view style="width: 100%; height: 979rpx;position: fixed;" v-if="photoPopup">
  184. <camera device-position="front" flash="off" @error="error" style="width: 100%; height: 100%;" ></camera>
  185. </view>
  186. <view class="custom"><image src="/static/zhezhao.png" mode=""></image></view>
  187. </view>
  188. <view class="btnResult" @click="takePhoto">拍照</view>
  189. </view>
  190. </view>
  191. </u-mask>
  192. </view>
  193. </template>
  194. <script>
  195. import plv from '../static/polyv-sdk/index';
  196. import courseModule from '@/components/course/courseModule.vue';
  197. import courseChapter from '@/components/course/courseChapter.vue';
  198. import courseSection from '@/components/course/courseSection.vue';
  199. import { mapGetters } from 'vuex';
  200. export default {
  201. components: {
  202. courseModule,
  203. courseChapter,
  204. courseSection
  205. },
  206. data() {
  207. return {
  208. initLiveOk:false,
  209. livePlay:false, //是否正在播放直播,不含暂停
  210. liveDuration:0, //直播观看时长
  211. videoOption:{
  212. mode: 'live',
  213. uid: '',
  214. cid: '',
  215. openId: '',
  216. isAutoChange: false,
  217. forceVideo: false,
  218. },
  219. courseHandoutsData:{},
  220. liveDetail:{},
  221. showSet:false,
  222. startStatus: false,
  223. detail: {},
  224. courseId: 0,
  225. placeholder: '您可以在这里输入笔记内容\n还可以点击左侧图标为笔记加上时间标记',
  226. inputStyle: {
  227. background: 'rgba(244, 244, 244, 0.98)',
  228. borderRadius: '24rpx',
  229. padding: '8rpx',
  230. marginBottom: '10rpx'
  231. },
  232. list: [],
  233. menuList: [],
  234. current: 0,
  235. vid: '',
  236. goodsId: 0,
  237. goodsData: {},
  238. photoPopup: false,
  239. goodsPlayConfig: null,
  240. autoplay: false,
  241. isAllowSeek: 'no',
  242. playbackRate: [1.0],
  243. timer: null,
  244. goodsPhotographConfig: null,
  245. intervalTimeList: [], // 间隔拍照时长
  246. intervalTimeIndex: 0, //当前处于哪个时间段拍照
  247. playTime: 0, //页面播放时长,不含暂停
  248. currentTime: 0,
  249. avatarUrl: '',
  250. ossAvatarUrl: '',
  251. studyDuration: 0, // 当前视频时长
  252. gradeId: 0,
  253. chapterId: 0,
  254. moduleId: 0,
  255. reMenuList: [],
  256. answerList: [],
  257. assignUserId: 0,
  258. placeholder: '您可以在这里输入答疑内容',
  259. ctxValue: '',
  260. noteList: [],
  261. noteValue: '',
  262. noteId: 0,
  263. recordObj: 0,
  264. gradeDetail:{},
  265. needSeek: false, //第一次播放是否需要跳转
  266. needProfileModal:false, //是否需要资料审核弹框
  267. liveObj:{},
  268. photoNum:0,
  269. photoList:[], //拍照的时间点
  270. photoConfig:false, //是否配置好拍照次数
  271. photoIndex:0, //当前位于拍照的区间下标 从0开始
  272. photoHistoryList:[], //已拍照历史的下标点
  273. businessData:{},
  274. };
  275. },
  276. computed: { ...mapGetters(['userInfo', 'playSectionId','playChannelId','playVID']) },
  277. onLoad(option) {
  278. this.courseId = Number(option.id);
  279. this.goodsId = Number(option.goodsId);
  280. this.courseDetail();
  281. this.getGoodsDetail();
  282. this.getAnswerList();
  283. let noteSecond = Number(option.noteSecond);
  284. if(noteSecond>0){
  285. //我的消息跳过来,播放节
  286. let item = {
  287. sectionId:Number(option.sectionId),
  288. recordingUrl:option.recordingUrl,
  289. noteSecond:noteSecond
  290. }
  291. this.$store.commit('setPlaySectionId', {playSectionId :item.sectionId});
  292. this.playNoteVideo(item);
  293. }
  294. },
  295. onShow() {
  296. var self = this;
  297. //相机授权
  298. this.getCameraSetting()
  299. this.$api.getbaseprofiletplists({ goodsId: self.goodsId }).then(res => {
  300. console.log(res,'res')
  301. if (res.data.code === 200 && res.data.rows.length) {
  302. if (res.data.rows[0].keyValue) {
  303. self.$api.getbaseprofiletpgetInfo({ goodsId: self.goodsId }).then(result => {
  304. console.log(result,'result')
  305. if (result.data.code === 200) {
  306. if (!result.data.data || (result.data.data.status === 3 && result.data.data.changeStatus === 1)) {
  307. if (!result.data.data) {
  308. self.needProfileModal = true
  309. uni.showModal({
  310. content: '请前往填写资料',
  311. cancelText: '返回',
  312. success: function(resultst) {
  313. if (resultst.confirm) {
  314. self.$navTo.togo('/pages2/verify/input', {
  315. id: self.goodsId
  316. });
  317. }
  318. if (resultst.cancel) {
  319. uni.navigateBack();
  320. }
  321. }
  322. });
  323. } else {
  324. self.needProfileModal = true
  325. uni.showModal({
  326. content: '资料审核不通过,请前往重新填写',
  327. cancelText: '返回',
  328. success: function(resultst) {
  329. if (resultst.confirm) {
  330. self.$navTo.togo('/pages2/verify/input', {
  331. id: self.goodsId
  332. });
  333. }
  334. if (resultst.cancel) {
  335. uni.navigateBack();
  336. }
  337. }
  338. });
  339. }
  340. } else if (result.data.data.status === 1 && JSON.parse(res.data.rows[0].keyValue2)[0]) {
  341. self.$api.getbaseprofileStampgetInfo({ goodsId: self.goodsId }).then(k => {
  342. if (k.data.code === 200) {
  343. if (!k.data.data || (k.data.data.status === 3 && k.data.data.changeStatus === 1)) {
  344. if (!k.data.data) {
  345. self.needProfileModal = true
  346. uni.showModal({
  347. cancelText: '返回',
  348. content: '请前往填写盖章资料',
  349. success: function(resultst) {
  350. if (resultst.confirm) {
  351. self.$navTo.togo('/pages2/verify/input2', {
  352. id: self.goodsId
  353. });
  354. }
  355. if (resultst.cancel) {
  356. uni.navigateBack();
  357. }
  358. }
  359. });
  360. } else {
  361. self.needProfileModal = true
  362. uni.showModal({
  363. cancelText: '返回',
  364. content: '资料盖章审核不通过,请前往重新填写',
  365. success: function(resultst) {
  366. if (resultst.confirm) {
  367. self.$navTo.togo('/pages2/verify/input2', {
  368. id: self.goodsId
  369. });
  370. }
  371. if (resultst.cancel) {
  372. uni.navigateBack();
  373. }
  374. }
  375. });
  376. }
  377. }
  378. }
  379. });
  380. }
  381. }
  382. });
  383. }
  384. }
  385. });
  386. console.log(this.gradeId,7512)
  387. if(this.gradeId>0){
  388. //提交完资料返回判断是否已开班
  389. this.getGradeInfo()
  390. }
  391. },
  392. onUnload() {
  393. if (this.playSectionId > 0) {
  394. //退出提交记录
  395. this.postStudyRecord();
  396. }
  397. //清除正在播放的节ID
  398. this.$store.commit('setPlaySectionId', { playSectionId: 0 });
  399. this.$store.commit('setPlayChannelId', { playChannelId: 0 });
  400. this.$store.commit('setPlayVID', { playVID: null });
  401. this.closePlv()
  402. console.log('onUnload')
  403. //移除所有的事件监听器
  404. uni.$off();
  405. if (this.timer) {
  406. clearInterval(this.timer);
  407. }
  408. },
  409. mounted() {
  410. uni.$on('changeSection', oldSectionId => {
  411. console.log(this.playVID)
  412. //清除直播
  413. this.$store.commit('setPlayChannelId', { playChannelId: 0 });
  414. this.postStudyRecord(0, oldSectionId);
  415. });
  416. uni.$on('getSection', item => {
  417. //清除直播
  418. this.$store.commit('setPlayChannelId', { playChannelId: 0 });
  419. //获取拍照历史
  420. this.getPhotoLastRecord()
  421. this.playVideo(item);
  422. });
  423. uni.$on('levelId', item => {
  424. let arr = item.split('-');
  425. //点击节获取的各层级ID
  426. this.moduleId = arr[0];
  427. this.chapterId = arr[1];
  428. });
  429. uni.$on('getChannel', item => {
  430. //清除录播
  431. this.$store.commit('setPlayVID', {playVID :null});
  432. this.playChannel(item);
  433. });
  434. },
  435. methods: {
  436. /**
  437. * 模块大节播放完毕,刷新列表
  438. */
  439. sectionPlayEnd(index) {
  440. console.log('sectionPlayEnd')
  441. this.$api.reMenuList({ courseId: this.courseId, gradeId: this.gradeId }).then(res => {
  442. if (res.data.code == 200) {
  443. res.data.rows[index].name = res.data.rows[index].menuName;
  444. this.$set(this.menuList,index,res.data.rows[index])
  445. }
  446. });
  447. },
  448. /**
  449. * 获取业务层次详情
  450. */
  451. courseBusiness(){
  452. this.$api.courseBusiness(this.goodsData.businessId).then(res => {
  453. this.businessData = res.data.data;
  454. })
  455. },
  456. /**
  457. * 计算tabs宽度
  458. */
  459. itemWidth() {
  460. return 100/this.list.length + '%'
  461. },
  462. /**
  463. * 获取讲义权限
  464. */
  465. courseHandouts() {
  466. this.$api.courseHandouts(this.goodsData.handoutsId).then(res => {
  467. this.courseHandoutsData = res.data.data
  468. })
  469. },
  470. findMenuNextSection(index){
  471. for(let i=index+1;i<this.reMenuList.length;i++){
  472. let item = this.reMenuList[i]
  473. if(item.type==3){
  474. return item;
  475. }
  476. }
  477. return {}
  478. },
  479. getPhotoLastRecord() {
  480. let self = this;
  481. let data = {
  482. sectionId: parseInt(self.playSectionId),
  483. goodsId: parseInt(self.goodsId),
  484. courseId: parseInt(self.courseId),
  485. gradeId: parseInt(self.gradeId),
  486. chapterId: parseInt(self.chapterId),
  487. moduleId: parseInt(self.moduleId)}
  488. this.$api.getPhotoLastRecord(data).then(res => {
  489. if(res.data.code==200){
  490. //清空历史数据
  491. self.photoHistoryList = []
  492. this.photoIndex = 0
  493. for(let i=0;i<res.data.data.length;i++){
  494. self.photoHistoryList.push(res.data.data[i].photoIndex)
  495. }
  496. }
  497. });
  498. },
  499. postCoursePhotoRecord() {
  500. let currentTime = 0;
  501. var polyvPlayerContext = this.selectComponent('#playerVideo');
  502. if (polyvPlayerContext) {
  503. currentTime = polyvPlayerContext.getCurrentTime();
  504. }
  505. let self = this;
  506. let photoIndex = self.photoIndex-1
  507. let data = {
  508. photo: self.ossAvatarUrl,
  509. sectionId: parseInt(self.playSectionId),
  510. goodsId: parseInt(self.goodsId),
  511. courseId: parseInt(self.courseId),
  512. photoTime: parseInt(currentTime > 0 ? currentTime : 0),
  513. gradeId: parseInt(self.gradeId),
  514. photoIndex: parseInt(photoIndex),//从0算起
  515. photoNum:parseInt(self.photoNum),
  516. chapterId: parseInt(self.chapterId),
  517. moduleId: parseInt(self.moduleId),
  518. };
  519. console.log('提交接口', data);
  520. this.$api.coursePhotoRecord(data).then(res => {
  521. console.log(res);
  522. });
  523. },
  524. randomNum(minNum,maxNum){
  525. switch(arguments.length){
  526. case 1:
  527. return parseInt(Math.random()*minNum+1,10);
  528. break;
  529. case 2:
  530. return parseInt(Math.random()*(maxNum-minNum+1)+minNum,10);
  531. break;
  532. default:
  533. return 0;
  534. break;
  535. }
  536. },
  537. //配置随机拍照时间
  538. configPhoto(){
  539. var polyvPlayerContext = this.selectComponent('#playerVideo');
  540. let totalVideoTime = polyvPlayerContext.getDuration()
  541. let duration = polyvPlayerContext.getCurrentTime()
  542. if(!this.photoConfig){
  543. this.photoConfig = true
  544. let spaceTime = Math.floor(totalVideoTime/this.photoNum) //拍照时间区间
  545. if(spaceTime<5){//区间小于5秒
  546. this.photoNum = Math.floor(totalVideoTime/5)
  547. spaceTime = 5
  548. }
  549. if(this.photoNum<1){
  550. this.photoNum = 1 //只要设置,至少拍一次
  551. spaceTime = totalVideoTime
  552. }
  553. let initSpace = 0
  554. this.photoList = []
  555. for(let i=0;i<this.photoNum;i++){
  556. let s = this.randomNum(initSpace,initSpace+spaceTime)
  557. if(s>totalVideoTime){
  558. s = totalVideoTime-1
  559. }
  560. if(s<2){
  561. s =1
  562. }
  563. this.photoList.push(s)
  564. initSpace+=spaceTime
  565. }
  566. // console.log(this.photoList,"随机拍时间数组",this.photoNum)
  567. //兼容已有观看历史
  568. for(let i=0;i<this.photoList.length-1;i++){
  569. if(this.photoList[i]<duration&&this.photoList[i+1]>duration){
  570. this.photoIndex = i+1
  571. // console.log("我的修改了photoIndex")
  572. break
  573. }
  574. if(duration>this.photoList[this.photoList.length-1]){
  575. this.photoIndex = this.photoList.length-1 //取最后一个下标
  576. // console.log("我的修改了photoIndex")
  577. break
  578. }
  579. }
  580. }
  581. },
  582. getLiveUid(channelId) {
  583. let self = this;
  584. return new Promise(resolve => {
  585. let data = {
  586. channelId: channelId
  587. };
  588. self.$api.polyvSign(data).then(res => {
  589. resolve(res.data.data);
  590. });
  591. });
  592. },
  593. timeEventLiving() {
  594. if (plv != null) {
  595. if(this.livePlay){
  596. this.liveDuration = this.liveDuration +1 //每隔1秒
  597. if(this.liveDuration==2){ //直播第2秒拍照
  598. if(this.goodsPhotographConfig){
  599. if(this.goodsPhotographConfig.livephotograph==1){
  600. //开启直播拍照
  601. this.openPhoto();
  602. }
  603. }
  604. }
  605. }
  606. }
  607. },
  608. playerLiveStatusChange(e) {
  609. const status = e.detail.status;
  610. console.log('直播状态',status);
  611. if (status === 'live') {
  612. console.log('开始直播');
  613. //开始播放
  614. if (this.timer) {
  615. clearInterval(this.timer);
  616. }
  617. this.livePlay = true
  618. this.timer = setInterval(this.timeEventLiving, 1000); //定时器
  619. }
  620. if (status === 'end') {
  621. if(this.livePlay){
  622. //只有播放过的结束才提交,避免未开播触发结束
  623. this.postStudyRecord(1);
  624. }
  625. console.log('结束直播');
  626. this.livePlay = false
  627. // 未开始
  628. }
  629. },
  630. closePlv(){
  631. if(plv){
  632. plv.destroy();
  633. }
  634. },
  635. playChannel(item){
  636. if (this.timer) {
  637. clearInterval(this.timer);
  638. }
  639. this.startStatus = true
  640. this.initLive()
  641. },
  642. setLiveOption(status) {
  643. const { userId, channelId, recordFileSimpleModel, playbackEnabled } = this.detail;
  644. const playRecordFile = playbackEnabled && recordFileSimpleModel && status === 'end';
  645. this.videoOption = {
  646. mode: 'live',
  647. uid: this.liveObj.uid, //this.playChannelId egsxlptzdq
  648. cid: this.playChannelId,
  649. openId: this.userInfo.userAccount,
  650. isAutoChange: false,
  651. forceVideo: false,
  652. }
  653. },
  654. async initLive(){
  655. console.log(this.playChannelId,7111)
  656. this.liveObj = await this.getLiveUid(this.playChannelId);
  657. this.initLiveOk = true
  658. let optionsData = {}
  659. optionsData.mode = 'live';
  660. optionsData.forceVideo = false;
  661. optionsData.channelId = this.playChannelId; // 频道ID '2553128'
  662. optionsData.openId = this.userInfo.userAccount; // 用户openId this.userInfo.userAccount 'oQ5eX5BCtSjkE1ct8CzvxGWgh0hQ'
  663. optionsData.userId = this.liveObj.uid // 2.0.0及以上版本的demo需要使用 userId 设置学员唯一id 'egsxlptzdq'
  664. let self = this
  665. this.closePlv()
  666. plv.init(optionsData)
  667. .then(({ detail, chat }) => {
  668. self.liveDetail = detail
  669. // 设置mode为live的videoOption
  670. this.setLiveOption();
  671. if (detail.isPPT) {
  672. chat.on(chat.events.SLICESTART, () => {
  673. // 开始直播
  674. });
  675. } else {
  676. plv.api.getOrdinaryLiveStatus(detail.stream);
  677. }
  678. });
  679. },
  680. openSetting(res){
  681. console.log(res,98)
  682. },
  683. getCameraSetting () {
  684. const self = this
  685. wx.getSetting({
  686. success: res => {
  687. if (res.authSetting['scope.camera']) {
  688. // 用户已经授权
  689. self.showSet = false
  690. } else {
  691. // 用户还没有授权,向用户发起授权请求
  692. wx.authorize({
  693. scope: 'scope.camera',
  694. success() { // 用户同意授权
  695. self.showSet = false
  696. },
  697. fail() { // 用户不同意授权
  698. self.showSet = true
  699. /* wx.showToast({
  700. title: '摄像头授权失败',
  701. icon: 'none',
  702. duration: 3000
  703. }) */
  704. }
  705. })
  706. }
  707. },
  708. fail: res => {
  709. }
  710. })
  711. },
  712. openJY(){
  713. this.$u.toast('此功能正在开发中');
  714. },
  715. //播放笔记视频
  716. async playNoteVideo(item) {
  717. if (this.timer) {
  718. clearInterval(this.timer);
  719. }
  720. if (this.vid) {
  721. //切换视频
  722. var polyvPlayerContext = this.selectComponent('#playerVideo');
  723. polyvPlayerContext.changeVid(item.recordingUrl);
  724. } else {
  725. this.vid = item.recordingUrl;
  726. }
  727. this.recordObj = {studyDuration:item.noteSecond}
  728. if (this.recordObj.studyDuration) {
  729. this.needSeek = true; //需要跳转到播放记录
  730. }
  731. this.startStatus = true;
  732. //获取节笔记
  733. this.getNoteList();
  734. },
  735. //正常播放视频
  736. async playVideo(item) {
  737. if (this.timer) {
  738. clearInterval(this.timer);
  739. }
  740. if (this.vid) {
  741. //切换视频
  742. var polyvPlayerContext = this.selectComponent('#playerVideo');
  743. polyvPlayerContext.changeVid(item.recordingUrl);
  744. } else {
  745. this.vid = item.recordingUrl;
  746. }
  747. this.recordObj = await this.getRecordLast();
  748. if (this.recordObj.studyDuration) {
  749. this.needSeek = true; //需要跳转到播放记录
  750. }
  751. this.startStatus = true;
  752. //获取节笔记
  753. this.getNoteList();
  754. },
  755. getRecordLast() {
  756. let self = this;
  757. return new Promise(resolve => {
  758. let data = {
  759. gradeId: Number(self.gradeId),
  760. goodsId: Number(self.goodsId),
  761. sectionId: Number(self.playSectionId),
  762. courseId: Number(self.courseId),
  763. chapterId: parseInt(self.chapterId),
  764. moduleId: parseInt(self.moduleId)
  765. };
  766. self.$api.recordLast(data).then(res => {
  767. resolve(res.data.data);
  768. });
  769. });
  770. },
  771. jumpNote(item) {
  772. this.noteId = item.noteId;
  773. //没视频播放
  774. if(this.playSectionId==0){
  775. this.$u.toast('即将跳到笔记位置');
  776. this.$store.commit('setPlaySectionId', {playSectionId :item.sectionId});
  777. this.playNoteVideo(item);
  778. }else{
  779. //正在看当前笔记视频
  780. this.$u.toast('即将跳到笔记位置');
  781. //跳到笔记时刻
  782. var polyvPlayerContext = this.selectComponent('#playerVideo');
  783. polyvPlayerContext.seek(item.noteSecond);
  784. polyvPlayerContext.play();
  785. }
  786. },
  787. postNote() {
  788. let self = this;
  789. if (!(this.playSectionId > 0)) {
  790. this.$u.toast('目前无播放视频');
  791. return;
  792. }
  793. if (!this.noteValue) {
  794. this.$u.toast('请输入内容');
  795. return;
  796. }
  797. if(!this.gradeId){
  798. this.$u.toast('暂无班级数据');
  799. return;
  800. }
  801. var polyvPlayerContext = this.selectComponent('#playerVideo');
  802. let noteDate = this.$method.getZeroTime();
  803. let noteSecond = polyvPlayerContext.getCurrentTime();
  804. console.log(noteSecond,698)
  805. if (!noteSecond) {
  806. if(noteSecond==0){
  807. //播放结束
  808. noteSecond = polyvPlayerContext.getDuration();
  809. console.log(noteSecond,63398)
  810. }
  811. if(!noteSecond){
  812. this.$u.toast('视频暂未开始');
  813. return;
  814. }
  815. }
  816. let data = {
  817. gradeId: this.gradeId,
  818. goodsId: this.goodsId,
  819. sectionId: this.playSectionId,
  820. courseId: this.courseId,
  821. noteText: this.noteValue,
  822. noteDate: noteDate,
  823. noteSecond: noteSecond
  824. };
  825. this.$api.postNote(data).then(res => {
  826. if (res.data.code == 200) {
  827. this.$u.toast('发布成功');
  828. self.getNoteList();
  829. this.noteValue = '';
  830. }
  831. });
  832. },
  833. getGradeInfo() {
  834. let self = this;
  835. this.$store.state.allowLoading = false;
  836. this.$api.goodsGradeInfo(this.gradeId).then(res => {
  837. if (res.data.code == 200) {
  838. self.gradeDetail = res.data.data;
  839. if(self.needProfileModal){
  840. return
  841. }
  842. if(self.gradeDetail.learningStatus==2){
  843. uni.showModal({
  844. showCancel:false,
  845. cancelText: '返回',
  846. content: '当前课程正在申请中,请耐心等待',
  847. success: function(resultst) {
  848. uni.navigateBack();
  849. }
  850. });
  851. }
  852. if(self.gradeDetail.learningStatus==3&&(Number(self.gradeDetail.learningTimeStart)>Number((new Date())/1000))){
  853. uni.showModal({
  854. showCancel:false,
  855. cancelText: '返回',
  856. content: '当前课程正在申请中,请耐心等待',
  857. success: function(resultst) {
  858. uni.navigateBack();
  859. }
  860. });
  861. }
  862. }
  863. });
  864. this.$store.state.allowLoading = true;
  865. },
  866. getNoteList() {
  867. let self = this;
  868. self.noteList = [];
  869. let data = { courseId: this.courseId, gradeId: this.gradeId, goodsId: this.goodsId }
  870. if(this.playSectionId>0){
  871. data.sectionId = this.playSectionId
  872. }
  873. this.$api.noteList(data).then(res => {
  874. if (res.data.code == 200) {
  875. self.noteList = res.data.rows;
  876. }
  877. });
  878. },
  879. delAnswer(answerId) {
  880. let self = this;
  881. let data = { answerId: answerId, status: -1 };
  882. this.$api.delAnswer(data).then(res => {
  883. if (res.data.code == 200) {
  884. self.getAnswerList();
  885. }
  886. });
  887. },
  888. clearCtx() {
  889. console.log(4234);
  890. this.placeholder = '您可以在这里输入答疑内容';
  891. this.ctxValue = '';
  892. this.assignUserId = 0;
  893. },
  894. replyContent(item) {
  895. this.assignUserId = item.userId;
  896. this.placeholder = '@' + item.realname;
  897. },
  898. delContent(item) {
  899. this.delAnswer(item.answerId);
  900. },
  901. postAnswer() {
  902. let self = this;
  903. let data = { courseId: this.courseId, answerText: this.ctxValue, goodsId: this.goodsId };
  904. if (this.assignUserId > 0) {
  905. data.assignUserId = this.assignUserId;
  906. }
  907. this.$api.postAnswer(data).then(res => {
  908. if (res.data.code == 200) {
  909. this.$u.toast('发布成功');
  910. self.getAnswerList();
  911. this.placeholder = '您可以在这里输入答疑内容';
  912. this.ctxValue = '';
  913. this.assignUserId = 0;
  914. }
  915. });
  916. },
  917. postContent() {
  918. if (!this.ctxValue||this.ctxValue=='') {
  919. this.$u.toast('请输入内容');
  920. return
  921. }
  922. this.postAnswer();
  923. },
  924. postStudyRecord(status = 0, sectionId = this.playSectionId) {
  925. let currentTime = 0;
  926. let PlayDuration = 0
  927. var polyvPlayerContext = this.selectComponent('#playerVideo');
  928. if (polyvPlayerContext) {
  929. currentTime = polyvPlayerContext.getCurrentTime(); //总的视频播放时刻
  930. PlayDuration = polyvPlayerContext.getVideoPlayDuration();//本次看的时长
  931. }
  932. if(this.playChannelId>0){
  933. currentTime = 2;//直播无法获取,无论开始结束都传2秒
  934. }
  935. let self = this;
  936. let data = {
  937. photo: self.ossAvatarUrl,
  938. sectionId: parseInt(sectionId),
  939. goodsId: parseInt(self.goodsId),
  940. courseId: parseInt(self.courseId),
  941. studyDuration: parseInt(PlayDuration > 0 ? PlayDuration : self.studyDuration),
  942. gradeId: parseInt(self.gradeId),
  943. chapterId: parseInt(self.chapterId),
  944. moduleId: parseInt(self.moduleId),
  945. videoCurrentTime: parseInt(currentTime > 0 ? currentTime : self.studyDuration)
  946. };
  947. if (status > 0) {
  948. data.status = status;
  949. }
  950. console.log('提交接口', data);
  951. this.$api.studyRecord(data).then(res => {
  952. if (status > 0) {
  953. uni.$emit('playEnd'); //通知播放结束
  954. }
  955. self.ossAvatarUrl = ''
  956. console.log(res,'res');
  957. });
  958. },
  959. uploadFile(options, int) {
  960. var self = this;
  961. return new Promise((resolve, reject) => {
  962. var data = {
  963. imageStatus: int
  964. };
  965. self.$api.aliyunpolicy(data).then(res => {
  966. if (res.data.code != 200) {
  967. self.$method.showToast('签名错误' + JSON.stringify(res.data));
  968. return;
  969. }
  970. var ossToken = res.data.data.resultContent;
  971. if (ossToken.host == null || ossToken.host == undefined) {
  972. self.$method.showToast('上传路径报错' + JSON.stringify(res.data));
  973. return;
  974. }
  975. uni.uploadFile({
  976. url: ossToken.host,
  977. name: 'file',
  978. filePath: options,
  979. fileType: 'image',
  980. header: {
  981. AuthorizationToken: 'WX ' + uni.getStorageSync('token')
  982. },
  983. formData: {
  984. key: ossToken.dir,
  985. OSSAccessKeyId: ossToken.accessid,
  986. policy: ossToken.policy,
  987. Signature: ossToken.signature,
  988. callback: ossToken.callback,
  989. success_action_status: 200
  990. },
  991. success: result => {
  992. if (result.statusCode === 200) {
  993. self.ossAvatarUrl = ossToken.dir;
  994. resolve();
  995. } else {
  996. uni.showToast({
  997. title: '上传失败',
  998. icon: 'none'
  999. });
  1000. return;
  1001. }
  1002. },
  1003. fail: error => {
  1004. uni.showToast({
  1005. title: '上传接口报错' + error,
  1006. icon: 'none'
  1007. });
  1008. return;
  1009. }
  1010. });
  1011. });
  1012. });
  1013. },
  1014. imageInfos() {
  1015. var self = this;
  1016. return new Promise((resolve, reject) => {
  1017. uni.getImageInfo({
  1018. src: self.avatarUrl,
  1019. success: async res => {
  1020. let canvasWidth = res.width; //图片原始长宽
  1021. let canvasHeight = res.height;
  1022. if (canvasWidth > 1000 || canvasHeight > 1000) {
  1023. uni.compressImage({
  1024. src: self.avatarUrl,
  1025. quality: 75,
  1026. width: '50%',
  1027. height: '50%',
  1028. success: async rest => {
  1029. const waitUpload = await self.uploadFile(rest.tempFilePath, 0);
  1030. resolve();
  1031. }
  1032. });
  1033. } else {
  1034. console.log('无需压缩');
  1035. const waitUpload = await self.uploadFile(self.avatarUrl, 0);
  1036. resolve();
  1037. }
  1038. }
  1039. });
  1040. });
  1041. },
  1042. timeEvent() {
  1043. let self = this;
  1044. var polyvPlayerContext = this.selectComponent('#playerVideo');
  1045. if (polyvPlayerContext != null) {
  1046. this.playTime = polyvPlayerContext.getCurrentTime() //播放时刻
  1047. //判断是否需要拍照
  1048. if (this.photoNum > 0) {
  1049. this.configPhoto()
  1050. if(this.photoIndex<this.photoList.length){
  1051. let photoTime = Number(this.photoList[this.photoIndex]); //获取拍照秒数
  1052. let nextIndex = this.photoIndex+1
  1053. let nextTime = 0
  1054. if(nextIndex<this.photoList.length){
  1055. nextTime = Number(this.photoList[nextIndex]); //获取下次拍照秒数
  1056. }
  1057. if (photoTime < this.playTime) {
  1058. if(this.photoHistoryList.indexOf(this.photoIndex)<0){ //不存在拍照历史则拍照
  1059. //启动拍照
  1060. //暂停
  1061. polyvPlayerContext.exitFullScreen();
  1062. polyvPlayerContext.pause();
  1063. this.photoIndex++;
  1064. this.openPhoto();
  1065. }
  1066. }
  1067. }
  1068. }
  1069. }
  1070. },
  1071. onStateChange(newstate, oldstate) {
  1072. if (newstate.detail.newstate == 'playing') {
  1073. if (this.needSeek) {
  1074. var polyvPlayerContext = this.selectComponent('#playerVideo');
  1075. polyvPlayerContext.seek(this.recordObj.studyDuration);
  1076. polyvPlayerContext.play();
  1077. this.needSeek = false;
  1078. }
  1079. //开始播放
  1080. if (this.timer) {
  1081. clearInterval(this.timer);
  1082. }
  1083. this.timer = setInterval(this.timeEvent, 1000); //定时器
  1084. }
  1085. if (newstate.detail.newstate == 'pause') {
  1086. //暂停提交记录
  1087. /* this.ossAvatarUrl = ""
  1088. this.postStudyRecord() */
  1089. }
  1090. if (newstate.detail.newstate == 'ended') {
  1091. this.postStudyRecord(1);
  1092. uni.$emit('playNext') //播放重修下一节
  1093. }
  1094. },
  1095. //拍照
  1096. openPhoto() {
  1097. this.photoPopup = true;
  1098. uni.authorize({
  1099. scope: 'scope.camera',
  1100. success() {
  1101. }
  1102. })
  1103. },
  1104. async submit() {
  1105. const waitYS = await this.imageInfos();
  1106. this.postCoursePhotoRecord()
  1107. this.postStudyRecord(); //提交记录
  1108. //恢复播放
  1109. var polyvPlayerContext = this.selectComponent('#playerVideo');
  1110. if (polyvPlayerContext != null) {
  1111. polyvPlayerContext.play();
  1112. }
  1113. },
  1114. //确认拍照
  1115. takePhoto() {
  1116. var self = this;
  1117. const ctx = uni.createCameraContext();
  1118. ctx.takePhoto({
  1119. quality: 'high',
  1120. success: res => {
  1121. console.log(res.tempImagePath);
  1122. self.avatarUrl = res.tempImagePath;
  1123. self.submit();
  1124. self.photoPopup = false;
  1125. },
  1126. fail: err => {
  1127. console.log(err);
  1128. }
  1129. });
  1130. },
  1131. //拍照报错
  1132. error(e) {
  1133. console.log(e.detail);
  1134. },
  1135. //关闭相机
  1136. closePhoto() {
  1137. this.photoPopup = false;
  1138. },
  1139. getGoodsDetail() {
  1140. let self = this;
  1141. this.$api.goodsDetail(this.goodsId).then(res => {
  1142. self.goodsData = res.data.data;
  1143. self.gradeId = self.goodsData.gradeId;
  1144. console.log(self.gradeId, "班级ID");
  1145. this.courseBusiness()
  1146. this.courseHandouts();
  1147. self.getMenuList();
  1148. self.getReMenuList(); //获取重修目录
  1149. setTimeout(function(){
  1150. if(!self.needProfileModal){
  1151. self.getGradeInfo()
  1152. }
  1153. },500)
  1154. //获取节笔记
  1155. this.getNoteList();
  1156. if (self.goodsData.goodsPlayConfig) {
  1157. self.goodsPlayConfig = JSON.parse(self.goodsData.goodsPlayConfig);
  1158. if (self.goodsPlayConfig.autoPlay > 0) {
  1159. self.autoplay = true;
  1160. }
  1161. if (self.goodsPlayConfig.drag > 0) {
  1162. self.isAllowSeek = 'yes';
  1163. }
  1164. if (self.goodsPlayConfig.speed > 0) {
  1165. self.playbackRate = [0.5, 0.8, 1.0, 1.25, 1.5, 2.0];
  1166. }
  1167. }
  1168. if (self.goodsData.goodsPhotographConfig) {
  1169. self.goodsPhotographConfig = JSON.parse(self.goodsData.goodsPhotographConfig);
  1170. if (self.goodsPhotographConfig.photoNum>0) {
  1171. self.photoNum = self.goodsPhotographConfig.photoNum
  1172. console.log(self.photoNum,777777)
  1173. }
  1174. }
  1175. });
  1176. },
  1177. startVideo() {
  1178. this.startStatus = true;
  1179. },
  1180. getAnswerList() {
  1181. let self = this;
  1182. this.$api.answerList({ courseId: this.courseId,goodsId: this.goodsId }).then(res => {
  1183. if (res.data.code == 200) {
  1184. self.answerList = res.data.rows;
  1185. }
  1186. });
  1187. },
  1188. getReMenuList() {
  1189. let self = this;
  1190. this.$api.reMenuList({ courseId: this.courseId, rebuild: 1, gradeId: this.gradeId }).then(res => {
  1191. if (res.data.code == 200) {
  1192. for (let i = 0; i < res.data.rows.length; i++) {
  1193. let item = res.data.rows[i];
  1194. item.down = true;
  1195. item.id = item.menuId;
  1196. item.name = item.menuName;
  1197. }
  1198. self.reMenuList = res.data.rows;
  1199. if(self.reMenuList.length>0){
  1200. self.list = [
  1201. {
  1202. name: '目录'
  1203. },
  1204. {
  1205. name: '讲义'
  1206. },
  1207. {
  1208. name: '笔记'
  1209. },
  1210. {
  1211. name: '答疑'
  1212. },
  1213. {name:'重修目录'}
  1214. ];
  1215. this.current = 0;
  1216. } else {
  1217. self.list = [
  1218. {
  1219. name: '目录'
  1220. },
  1221. {
  1222. name: '讲义'
  1223. },
  1224. {
  1225. name: '笔记'
  1226. },
  1227. {
  1228. name: '答疑'
  1229. }
  1230. ];
  1231. this.current = 0;
  1232. }
  1233. }
  1234. });
  1235. },
  1236. getMenuList() {
  1237. let self = this;
  1238. this.$api.reMenuList({ courseId: this.courseId, gradeId: this.gradeId }).then(res => {
  1239. if (res.data.code == 200) {
  1240. for (let i = 0; i < res.data.rows.length; i++) {
  1241. let item = res.data.rows[i];
  1242. item.down = true;
  1243. item.id = item.menuId;
  1244. item.name = item.menuName;
  1245. }
  1246. self.menuList = res.data.rows;
  1247. }
  1248. });
  1249. },
  1250. courseDetail() {
  1251. let self = this;
  1252. this.$api.courseDetail(this.courseId).then(res => {
  1253. if (res.data.code == 200) {
  1254. self.detail = res.data.data;
  1255. uni.setNavigationBarTitle({
  1256. title:self.detail.courseName
  1257. })
  1258. }
  1259. });
  1260. },
  1261. open(item) {
  1262. item.showChildren = !item.showChildren;
  1263. },
  1264. change(index) {
  1265. this.current = index;
  1266. },
  1267. openDocument() {
  1268. let self = this;
  1269. let url = this.$method.splitImgHost(this.courseHandoutsData.handoutsUrl)
  1270. console.log(url)
  1271. uni.downloadFile({
  1272. url: url,
  1273. success: function (res) {
  1274. console.log(999)
  1275. var filePath = res.tempFilePath;
  1276. uni.openDocument({
  1277. filePath: filePath,
  1278. showMenu: self.courseHandoutsData.canDownload == 1 ? true : false,
  1279. success: function (res) {
  1280. console.log(res,'打开文档成功');
  1281. },
  1282. fail:function(err) {
  1283. console.log(err)
  1284. uni.showToast({
  1285. icon:'none',
  1286. title:'文档地址错误'
  1287. })
  1288. }
  1289. });
  1290. },
  1291. fail:(err) => {
  1292. uni.showModal({
  1293. title:'提示',
  1294. content:'文档错误,'+err.errMsg,
  1295. showCancel:false
  1296. })
  1297. }
  1298. });
  1299. }
  1300. }
  1301. };
  1302. </script>
  1303. <style lang="scss" scope>
  1304. .btnSet{
  1305. width: 440rpx;
  1306. height: 80rpx;
  1307. background: #007AFF;
  1308. border-radius: 40rpx;
  1309. color: #FFFFFF;
  1310. font-size: 28rpx;
  1311. line-height: 80rpx;
  1312. }
  1313. .btnReply {
  1314. width: 80rpx;
  1315. height: 40rpx;
  1316. background: #e3f0ff;
  1317. border-radius: 16rpx;
  1318. text-align: center;
  1319. color: #007aff;
  1320. }
  1321. .btnDel {
  1322. width: 80rpx;
  1323. height: 40rpx;
  1324. background: #ffedf0;
  1325. border-radius: 16rpx;
  1326. text-align: center;
  1327. color: #ff2d55;
  1328. }
  1329. .btnReply {
  1330. width: 80rpx;
  1331. height: 40rpx;
  1332. background: #e3f0ff;
  1333. border-radius: 16rpx;
  1334. font-size: 24rpx;
  1335. }
  1336. .lecture-box {
  1337. display: flex;
  1338. align-items: center;
  1339. height: 80rpx;
  1340. background: #FFFFFF;
  1341. border-radius: 16rpx 16rpx 16rpx 16rpx;
  1342. .title {
  1343. padding:10rpx;
  1344. flex:1;
  1345. overflow: hidden;
  1346. text-overflow: ellipsis;
  1347. white-space: nowrap;
  1348. color:#333;
  1349. font-weight: bold;
  1350. font-size: 32rpx;
  1351. }
  1352. .btn {
  1353. display: flex;
  1354. align-items: center;
  1355. justify-content: center;
  1356. width:80rpx;
  1357. height:80rpx;
  1358. background: #FFFFFF;
  1359. box-shadow: -4rpx 0rpx 4rpx 0rpx rgba(0,0,0,0.1);
  1360. border-radius: 16rpx 16rpx 16rpx 16rpx;
  1361. }
  1362. }
  1363. .lecture-content {
  1364. background:#fff;
  1365. margin-top:10rpx;
  1366. padding:10rpx;
  1367. border-radius:16rpx;
  1368. }
  1369. .photoBox {
  1370. background-color: #FFFFFF;
  1371. border-radius: 32px 32px 0px 0px;
  1372. .photoTop {
  1373. height: 74upx;
  1374. display: flex;
  1375. align-items: center;
  1376. justify-content: space-between;
  1377. padding: 0upx 38upx;
  1378. .sqzz {
  1379. width: 28upx;
  1380. height: 28upx;
  1381. display: flex;
  1382. align-items: center;
  1383. justify-content: center;
  1384. }
  1385. .centersq {
  1386. color: #333;
  1387. font-size: 30upx;
  1388. font-weight: 500;
  1389. }
  1390. }
  1391. .photoCenter {
  1392. width: 750upx;
  1393. height: 979upx;
  1394. position: relative;
  1395. .custom {
  1396. width: 750upx;
  1397. height: 979upx;
  1398. position: absolute;
  1399. z-index: 1000;
  1400. top: 0;
  1401. left: 0;
  1402. image {
  1403. width: 100%;
  1404. height: 100%;
  1405. }
  1406. }
  1407. }
  1408. .btnResult {
  1409. height: 100rpx;
  1410. width: 100%;
  1411. background-color: #07c160;
  1412. text-align: center;
  1413. line-height: 100upx;
  1414. color: #fff;
  1415. font-size: 32upx;
  1416. font-weight: bold;
  1417. }
  1418. }
  1419. .chat_box {
  1420. display: flex;
  1421. padding: 20rpx;
  1422. justify-content: space-between;
  1423. }
  1424. .chat3 {
  1425. font-size: 30rpx;
  1426. font-family: PingFang SC;
  1427. font-weight: 500;
  1428. color: #666666;
  1429. margin-top: 10rpx;
  1430. }
  1431. .chat2 {
  1432. font-size: 20rpx;
  1433. font-family: PingFang SC;
  1434. font-weight: 500;
  1435. color: #999999;
  1436. margin-top: 10rpx;
  1437. }
  1438. .chat1 {
  1439. font-size: 24rpx;
  1440. font-family: PingFang SC;
  1441. font-weight: 500;
  1442. color: #333333;
  1443. }
  1444. .leftPadding {
  1445. margin-left: 8rpx;
  1446. }
  1447. .t2Content {
  1448. font-size: 28rpx;
  1449. font-family: PingFang SC;
  1450. font-weight: bold;
  1451. color: #999999;
  1452. line-height: 48rpx;
  1453. }
  1454. .tBox2 {
  1455. display: flex;
  1456. padding-top: 10rpx;
  1457. color: #333333;
  1458. font-size: 30rpx;
  1459. }
  1460. .tBox {
  1461. display: flex;
  1462. align-items: center;
  1463. padding-top: 10rpx;
  1464. }
  1465. .title {
  1466. font-size: 24rpx;
  1467. color: #999999;
  1468. }
  1469. page {
  1470. padding-top: 10px;
  1471. padding-top: constant(safe-area-inset-top);
  1472. padding-top: env(safe-area-inset-top);
  1473. }
  1474. .inputBottom {
  1475. position: fixed;
  1476. left: 0;
  1477. bottom: 0;
  1478. background: #ffffff;
  1479. height: 98rpx;
  1480. display: flex;
  1481. align-items: center;
  1482. width: 100%;
  1483. .flex_auto {
  1484. flex:1;
  1485. margin-left: 10% ;
  1486. .input {
  1487. height:60rpx;
  1488. }
  1489. }
  1490. .btn {
  1491. color: #007AFF;font-size: 30rpx;font-weight: bold;width: 15%;text-align: center;
  1492. }
  1493. }
  1494. .noteBox {
  1495. width: 100%;
  1496. background: #ffffff;
  1497. padding: 10rpx;
  1498. border-radius: 16rpx;
  1499. }
  1500. .dateBox {
  1501. width: 216rpx;
  1502. height: 48rpx;
  1503. background: #ffffff;
  1504. border-radius: 24rpx;
  1505. font-size: 24rpx;
  1506. color: #666666;
  1507. text-align: center;
  1508. line-height: 48rpx;
  1509. margin: 20rpx 0;
  1510. }
  1511. .t_content1 {
  1512. color: #007aff;
  1513. margin-left: 10rpx;
  1514. }
  1515. .tag1 {
  1516. border: 2rpx solid #007aff;
  1517. border-radius: 8rpx;
  1518. font-size: 20rpx;
  1519. color: #007aff;
  1520. padding: 5rpx;
  1521. }
  1522. .b_title {
  1523. color: #333333;
  1524. font-size: 30rpx;
  1525. font-weight: bold;
  1526. }
  1527. page {
  1528. background: #eaeef1;
  1529. }
  1530. .menuBox {
  1531. width: 100%;
  1532. background: #ffffff;
  1533. border-radius: 16rpx;
  1534. padding: 20rpx;
  1535. margin-bottom: 20rpx;
  1536. }
  1537. .btnspric {
  1538. border-top: 1rpx solid #eee;
  1539. display: flex;
  1540. align-items: center;
  1541. justify-content: space-between;
  1542. height: 108rpx;
  1543. padding-left: 43rpx;
  1544. padding-right: 32rpx;
  1545. }
  1546. .btnspric > .lefprL {
  1547. font-size: 36rpx;
  1548. color: #0c141f;
  1549. font-weight: bold;
  1550. }
  1551. .btnspric > .lefprR {
  1552. padding: 0rpx 24rpx;
  1553. height: 60rpx;
  1554. line-height: 60rpx;
  1555. text-align: center;
  1556. color: #fff;
  1557. background: #32467b;
  1558. border-radius: 24rpx;
  1559. box-shadow: 0rpx 0rpx 16rpx 4rpx rgba(145, 156, 178, 0.1);
  1560. }
  1561. .yhj,
  1562. .hdyhj {
  1563. padding: 24rpx 29rpx 24rpx 34rpx;
  1564. }
  1565. .yhj {
  1566. border-bottom: 16rpx solid #f9f9f9;
  1567. }
  1568. .yhjtit {
  1569. font-size: 30rpx;
  1570. color: #0c141f;
  1571. font-weight: 500;
  1572. margin-bottom: 14rpx;
  1573. }
  1574. .yhjList {
  1575. display: flex;
  1576. align-items: center;
  1577. justify-content: space-between;
  1578. margin-bottom: 14rpx;
  1579. }
  1580. .yhjList > .yhjLefts {
  1581. display: flex;
  1582. align-items: center;
  1583. }
  1584. .yhjLefts > .yhl {
  1585. color: #32467b;
  1586. font-size: 30rpx;
  1587. margin-right: 31rpx;
  1588. }
  1589. .yhjLefts > .yhbq {
  1590. font-size: 24rpx;
  1591. color: #ff9500;
  1592. border-radius: 18rpx;
  1593. background-color: rgba(255, 149, 0, 0.2);
  1594. border: 2rpx solid #ff9500;
  1595. height: 38rpx;
  1596. line-height: 38rpx;
  1597. padding: 0rpx 16rpx;
  1598. }
  1599. .ts {
  1600. font-size: 24rpx;
  1601. color: #999;
  1602. margin: 14rpx 0rpx;
  1603. padding-right: 29rpx;
  1604. padding-left: 34rpx;
  1605. }
  1606. .yh {
  1607. padding-top: 20rpx;
  1608. }
  1609. .yh > .yhtitle {
  1610. display: flex;
  1611. align-items: center;
  1612. justify-content: space-between;
  1613. padding-right: 29rpx;
  1614. padding-left: 34rpx;
  1615. }
  1616. .priceBxs {
  1617. display: flex;
  1618. align-items: center;
  1619. }
  1620. .priceBxs > .pricleft {
  1621. border-radius: 24rpx;
  1622. border: 1rpx solid #e91313;
  1623. background-color: rgba(233, 19, 19, 0.1);
  1624. padding: 0rpx 18rpx;
  1625. height: 49rpx;
  1626. line-height: 49rpx;
  1627. text-align: center;
  1628. font-size: 30rpx;
  1629. font-weight: 500;
  1630. color: #e91313;
  1631. margin-right: 13rpx;
  1632. }
  1633. .topBox {
  1634. padding: 32rpx 32rpx 24rpx;
  1635. border-bottom: 1rpx solid #eeeeee;
  1636. }
  1637. .topBox > .boldFonstType {
  1638. font-weight: 500;
  1639. font-size: 30rpx;
  1640. margin: 16rpx 0rpx 23rpx;
  1641. }
  1642. .topBox > .firstTopL {
  1643. display: flex;
  1644. align-items: center;
  1645. }
  1646. .topBox > .firstTopL > .imageBs {
  1647. width: 331rpx;
  1648. height: 160rpx;
  1649. border-radius: 6rpx;
  1650. overflow: hidden;
  1651. margin-right: 8rpx;
  1652. box-shadow: 0rpx 6rpx 6rpx 0rpx rgba(47, 67, 121, 0.08);
  1653. }
  1654. .topBox > .firstTopL > .imageBs > image {
  1655. width: 100%;
  1656. height: 100%;
  1657. }
  1658. .topBox > .firstTopL > .textBs {
  1659. font-size: 30rpx;
  1660. font-weight: bold;
  1661. color: #0c141f;
  1662. }
  1663. .content {
  1664. padding: 24rpx;
  1665. text-align: left;
  1666. }
  1667. .catalogBox {
  1668. display: flex;
  1669. align-items: center;
  1670. flex-wrap: nowrap;
  1671. overflow-x: auto;
  1672. padding-left: 38rpx;
  1673. max-height: 305rpx;
  1674. overflow-y: auto;
  1675. transition: all 0.4s;
  1676. }
  1677. .catalogBox > .catalogA {
  1678. min-width: 200rpx;
  1679. height: 48rpx;
  1680. line-height: 48rpx;
  1681. // text-align: center;
  1682. border: 2rpx solid transparent;
  1683. white-space: nowrap;
  1684. text-overflow: ellipsis;
  1685. overflow: hidden;
  1686. word-break: break-all;
  1687. border-radius: 10rpx;
  1688. background: rgba(22, 119, 255, 0.05);
  1689. padding-left: 19rpx;
  1690. box-sizing: border-box;
  1691. padding-right: 15rpx;
  1692. margin-right: 16rpx;
  1693. margin-bottom: 20rpx;
  1694. margin-top: 15rpx;
  1695. font-size: 24rpx;
  1696. color: #666;
  1697. }
  1698. .catalogBox > .activesq {
  1699. border-color: #1677ff;
  1700. }
  1701. .changeCatalogBox {
  1702. display: block;
  1703. }
  1704. .catalogBox::-webkit-scrollbar {
  1705. display: none; /* Chrome Safari */
  1706. }
  1707. .box {
  1708. position: relative;
  1709. top: 650rpx;
  1710. padding-bottom: 88rpx;
  1711. margin: 20rpx;
  1712. }
  1713. .price_t2 {
  1714. font-size: 18rpx;
  1715. font-family: PingFang SC;
  1716. font-weight: 500;
  1717. text-decoration: line-through;
  1718. color: #999999;
  1719. }
  1720. .price_t1 {
  1721. font-size: 33rpx;
  1722. font-family: PingFang SC;
  1723. font-weight: bold;
  1724. color: #e91313;
  1725. }
  1726. .sc_t {
  1727. font-size: 22rpx;
  1728. color: #000000;
  1729. }
  1730. .sc {
  1731. width: 29rpx;
  1732. height: 29rpx;
  1733. }
  1734. .buy {
  1735. width: 138rpx;
  1736. height: 48rpx;
  1737. line-height: 48rpx;
  1738. background: #32467b;
  1739. border-radius: 10rpx;
  1740. color: #ffffff;
  1741. font-size: 28rpx;
  1742. text-align: center;
  1743. vertical-align: middle;
  1744. position: absolute;
  1745. right: 30rpx;
  1746. }
  1747. .video_body {
  1748. padding-bottom: 96rpx;
  1749. }
  1750. .footer_tab {
  1751. position: fixed;
  1752. bottom: 0;
  1753. height: 96rpx;
  1754. width: 100%;
  1755. background-color: #ffffff;
  1756. }
  1757. .tj_box {
  1758. width: 50%;
  1759. display: inline-block;
  1760. text-align: center;
  1761. margin: 10rpx 0;
  1762. }
  1763. .teacher_t {
  1764. font-size: 24rpx;
  1765. font-family: PingFang SC;
  1766. font-weight: 400;
  1767. color: #666666;
  1768. line-height: 36rpx;
  1769. margin-left: 15rpx;
  1770. }
  1771. .teacher_img {
  1772. width: 87rpx;
  1773. height: 129rpx;
  1774. }
  1775. .t2 {
  1776. font-size: 24rpx;
  1777. font-family: PingFang SC;
  1778. color: #666666;
  1779. line-height: 36rpx;
  1780. margin: 15rpx;
  1781. }
  1782. .r_t2 {
  1783. width: 201rpx;
  1784. height: 49rpx;
  1785. background: rgba(22, 119, 255, 0.05);
  1786. border: 1rpx solid #32467b;
  1787. border-radius: 16rpx;
  1788. color: #666666;
  1789. font-size: 23rpx;
  1790. text-align: center;
  1791. display: flex;
  1792. align-items: center;
  1793. padding: 5rpx;
  1794. }
  1795. .scroll_box {
  1796. width: 100%;
  1797. height: 60rpx;
  1798. background: #ffffff;
  1799. box-shadow: 0rpx 0rpx 16rpx 4rpx rgba(145, 156, 178, 0.1);
  1800. white-space: nowrap;
  1801. overflow: hidden;
  1802. margin: 15rpx 0;
  1803. }
  1804. .r_sliper {
  1805. padding: 0 20rpx;
  1806. }
  1807. .top_line {
  1808. width: 6rpx;
  1809. height: 22rpx;
  1810. background: #32467b;
  1811. margin-right: 10rpx;
  1812. }
  1813. .video_t2 {
  1814. font-size: 24rpx;
  1815. font-family: PingFang SC;
  1816. font-weight: 500;
  1817. color: #666666;
  1818. }
  1819. .video_t1 {
  1820. height: 80rpx;
  1821. color: #333333;
  1822. line-height: 80rpx;
  1823. font-size: 30rpx;
  1824. font-family: PingFang SC;
  1825. font-weight: bold;
  1826. color: #333333;
  1827. overflow: hidden;
  1828. text-overflow: ellipsis;
  1829. white-space: nowrap;
  1830. }
  1831. .video_t1_t {
  1832. display: flex;
  1833. flex-direction: column;
  1834. height: 80rpx;
  1835. color: #333333;
  1836. text-align: center;
  1837. align-items: center;
  1838. border-left: solid 1px #d6d6db;
  1839. }
  1840. .video_play {
  1841. position: absolute;
  1842. width: 95rpx;
  1843. height: 95rpx;
  1844. top: 0;
  1845. left: 0;
  1846. right: 0;
  1847. bottom: 0;
  1848. margin: auto;
  1849. }
  1850. .video_box {
  1851. position: relative;
  1852. }
  1853. .rotoct {
  1854. transform: rotate(90deg);
  1855. }
  1856. </style>