courseCover.vue 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160
  1. <template>
  2. <view class="w100" style="width: 100%;">
  3. <view class="header-nav" :style="{height: `calc(88rpx + ${statusBarHeight}px)`,paddingTop: statusBarHeight + 'px'}">
  4. <u-icon name="arrow-left" size="28" @click="tosales" v-if="appToken"></u-icon>
  5. <view class="header-title" :style="{width:menuButtonLeft + 'px',height:menuButtonH+'px',lineHeight:menuButtonH+'px'}">{{courseInfo.title}}</view>
  6. </view>
  7. <view>
  8. <image class="video-poster" :src="courseInfo.imgUrl" mode="aspectFill">
  9. <view class="title-content" id="title-content">
  10. <!-- 答题时展示小节课程名,其他展示课程名 -->
  11. <!-- 小节课程名 -->
  12. <view class="subtitlebox " >
  13. {{courseInfo.title}}
  14. </view>
  15. <!-- 课程名字 -->
  16. <view class="base-color-6 fs24">
  17. {{courseInfo.courseName}}
  18. </view>
  19. </view>
  20. </view>
  21. <view class="btns">
  22. <view class="author-btn" @click="comecourse">进入课程</view>
  23. </view>
  24. </view>
  25. </template>
  26. <script>
  27. import {
  28. getH5CourseByVideoId,
  29. } from "@/api/courseLook.js"
  30. export default{
  31. data(){
  32. return{
  33. videoId:3450,
  34. courseInfo:'',
  35. projectCode:'',
  36. sendType:'',
  37. courselist:{},
  38. statusBarHeight: uni.getSystemInfoSync().statusBarHeight,
  39. }
  40. },
  41. onLoad(option) {
  42. console.log(option)
  43. const keys = decodeURIComponent(Object.keys(option)[0]);
  44. this.courselist=JSON.parse(keys.split('course=')[1])
  45. this.videoId=this.courselist.videoId
  46. this.projectCode=this.courselist.projectCode
  47. console.log(keys)
  48. console.log(this.courselist)
  49. // if(this.videoId){
  50. // this.getH5CourseByVideo()
  51. // }
  52. },
  53. onShow() {
  54. this.getHeight()
  55. this.utils.getDomain({projectCode:this.projectCode}).then(res=>{
  56. if(res.code == 200) {
  57. if (this.videoId) {
  58. this.sendType=uni.getStorageSync('sendType')
  59. this.getH5CourseByVideo()
  60. // this.utils.getConfigKey()
  61. }
  62. }
  63. })
  64. },
  65. methods:{
  66. getHeight() {
  67. this.$nextTick(() => {
  68. const query = uni.createSelectorQuery().in(this);
  69. query
  70. .select("#title-content")
  71. .boundingClientRect((data) => {
  72. this.height =
  73. `calc(100vh - ${data.height}px - 420rpx - ${this.statusBarHeight}px - 120rpx )`
  74. })
  75. .exec();
  76. })
  77. },
  78. comecourse(){
  79. if(this.sendType==1){
  80. uni.navigateTo({
  81. url:'/pages_course/videovip?course='+JSON.stringify(this.courselist)
  82. })
  83. }else{
  84. }
  85. },
  86. getH5CourseByVideo() {
  87. const data={
  88. videoId:this.videoId
  89. }
  90. getH5CourseByVideoId(data).then(res=>{
  91. if (res.code == 200) {
  92. this.courseInfo = res.data
  93. uni.setNavigationBarTitle({
  94. title: this.courseInfo && this.courseInfo.title ? this.courseInfo.title : ''
  95. });
  96. }else{
  97. }
  98. })
  99. },
  100. }
  101. }
  102. </script>
  103. <style lang="scss" scoped>
  104. .header-nav {
  105. height: 88rpx;
  106. // @include u-flex(row, center, flex-start);
  107. display: flex;
  108. justify-content: center;
  109. align-items: center;
  110. overflow: hidden;
  111. background-color: #fff;
  112. box-sizing: border-box;
  113. .header-title {
  114. text-align: center;
  115. overflow: hidden;
  116. white-space: nowrap;
  117. text-overflow: ellipsis;
  118. padding: 0 10rpx 0rpx;
  119. font-family: PingFang SC,PingFang SC;
  120. font-weight: 500;
  121. font-size: 15px;
  122. color: #000;
  123. box-sizing: border-box;
  124. }
  125. }
  126. .video-poster{
  127. width: 100%;
  128. }
  129. .title-content{
  130. padding: 20rpx;
  131. .subtitlebox{
  132. font-size: 32rpx;
  133. font-weight: bold;
  134. }
  135. }
  136. .btns{
  137. position: fixed;
  138. padding: 40rpx 20rpx;
  139. bottom: 0;
  140. width: calc(100% - 40rpx);
  141. }
  142. .author-btn{
  143. z-index:100;
  144. width: 100%;
  145. height: 80rpx;
  146. background: #ff5c03;
  147. border-radius: 40rpx;
  148. font-size: 36rpx;
  149. font-family: PingFang SC;
  150. font-weight: 500;
  151. text-align: center;
  152. line-height: 80rpx;
  153. color: rgba(255, 255, 255, 1);
  154. }
  155. </style>