descInfoNav.vue 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202
  1. <template>
  2. <view style="background-color: #fff;padding-bottom: 116rpx;">
  3. <view class="title-content" id="title-content">
  4. <!-- 答题时展示小节课程名,其他展示课程名 -->
  5. <!-- 小节课程名 -->
  6. <view class="subtitlebox" v-if="isLogin&&isAddKf==1">
  7. {{courseInfo.title}}
  8. </view>
  9. <!-- 课程名字 -->
  10. <view class="miantitlebox" v-else>
  11. {{courseInfo.courseName}}
  12. </view>
  13. </view>
  14. <view class="descbox" >
  15. <template v-if="!isLogin||isAddKf!=1">
  16. <view class="descbox-title">{{courseInfo.title}}</view>
  17. <view class="descbox-info">
  18. <!-- <view class="descbox-info-l">
  19. <view>{{courseInfo.views}}次播放</view>
  20. <view class="descbox-info-time">总时长:{{courseInfo.totalDuration}}</view>
  21. </view> -->
  22. <view class="descbox-info-r expand" v-if="textHeight > 21">
  23. <text @click="handleExpand">{{isExpand ? '收起简介' : '展开简介'}}</text>
  24. <image src="/static/images/course_arrow_up_icon.png" v-show="isExpand"></image>
  25. <image src="/static/images/course_arrow_down_icon.png" v-show="!isExpand"></image>
  26. </view>
  27. </view>
  28. </template>
  29. <view class="descbox-desc" id="descbox-desc" :style="{height: isExpand ? 'auto': '42rpx'}">
  30. <text>{{courseInfo.description}}</text>
  31. <view :class="isExpand ? 'expand': 'expand expand-ab'" v-if="isLogin&&isAddKf==1&&textHeight > 21">
  32. <text @click="handleExpand">{{isExpand ? '收起简介' : '展开简介'}}</text>
  33. <image src="/static/images/course_arrow_up_icon.png" v-show="isExpand"></image>
  34. <image src="/static/images/course_arrow_down_icon.png" v-show="!isExpand"></image>
  35. </view>
  36. </view>
  37. </view>
  38. </view>
  39. </template>
  40. <script>
  41. export default {
  42. props: {
  43. isLogin: {
  44. type: Boolean,
  45. default: false,
  46. },
  47. isAddKf: {
  48. type: [String,Number],
  49. default: 0,
  50. },
  51. courseInfo: {
  52. type: Object,
  53. default: {},
  54. },
  55. },
  56. data() {
  57. return {
  58. // 是否展开
  59. isExpand: true,
  60. textHeight: 0, //文本高度
  61. }
  62. },
  63. methods: {
  64. // 展开简介
  65. handleExpand() {
  66. this.isExpand = !this.isExpand
  67. },
  68. getDescHeight() {
  69. this.$nextTick(() => {
  70. const query = uni.createSelectorQuery().in(this);
  71. query
  72. .select("#descbox-desc")
  73. .boundingClientRect((data) => {
  74. if(data){
  75. this.textHeight = data.height
  76. }
  77. })
  78. .exec();
  79. })
  80. },
  81. }
  82. }
  83. </script>
  84. <style scoped lang="scss">
  85. @mixin u-flex($flexD, $alignI, $justifyC) {
  86. display: flex;
  87. flex-direction: $flexD;
  88. align-items: $alignI;
  89. justify-content: $justifyC;
  90. }
  91. .miantitlebox {
  92. padding: 30rpx 32rpx;
  93. font-family: PingFang SC, PingFang SC;
  94. font-weight: 500;
  95. font-size: 36rpx;
  96. color: #222222;
  97. }
  98. .subtitlebox {
  99. padding: 30rpx 0;
  100. font-family: PingFang SC, PingFang SC;
  101. font-weight: 500;
  102. font-size: 36rpx;
  103. color: #222222;
  104. }
  105. .title-content {
  106. padding: 0 32rpx;
  107. background-color: #fff;
  108. font-size: 28rpx;
  109. line-height: 1.6;
  110. .title {
  111. font-size: 36rpx;
  112. font-weight: 500;
  113. color: #414858;
  114. }
  115. .time-or-subtitle {
  116. margin-top: 12rpx;
  117. color: #666666;
  118. }
  119. }
  120. .descbox {
  121. padding: 14rpx 32rpx;
  122. margin-bottom: 20rpx;
  123. background-color: #fff;
  124. font-family: PingFang SC, PingFang SC;
  125. font-weight: 400;
  126. font-size: 28rpx;
  127. color: #222222;
  128. line-height: 42rpx;
  129. word-break: break-word;
  130. &-title {
  131. margin-bottom: 24rpx;
  132. font-weight: 500;
  133. font-size: 32rpx;
  134. }
  135. &-info {
  136. margin-bottom: 24rpx;
  137. @include u-flex(row, center, space-between);
  138. font-size: 26rpx;
  139. color: #757575;
  140. &-l {
  141. flex: 1;
  142. @include u-flex(row, center, flex-start);
  143. }
  144. &-time {
  145. margin-left: 18rpx;
  146. padding-left: 18rpx;
  147. position: relative;
  148. &::after {
  149. content: "";
  150. width: 4rpx;
  151. height: 4rpx;
  152. background: #999999;
  153. border-radius: 50%;
  154. position: absolute;
  155. left: 0;
  156. top: 50%;
  157. transform: translateY(-50%);
  158. }
  159. }
  160. &-r {
  161. background: transparent;
  162. }
  163. }
  164. &-desc {
  165. overflow: hidden;
  166. position: relative;
  167. margin-top: 20rpx;
  168. }
  169. }
  170. .expand {
  171. flex-shrink: 0;
  172. @include u-flex(row, center, flex-end);
  173. color: #FF5C03;
  174. font-weight: 400;
  175. font-size: 24rpx;
  176. image {
  177. width: 32rpx;
  178. height: 32rpx;
  179. }
  180. }
  181. .expand-ab {
  182. position: absolute;
  183. top: 0;
  184. right: 0;
  185. box-shadow: -50rpx 0 20rpx 8rpx #FFFFFF;
  186. background-color: #fff;
  187. }
  188. </style>