descInfoNav.vue 4.4 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="baseUrl+'/app/image/course_arrow_up_icon.png'" v-show="isExpand"></image>
  25. <image :src="baseUrl+'/app/image/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="baseUrl+'/app/image/course_arrow_up_icon.png'" v-show="isExpand"></image>
  34. <image :src="baseUrl+'/app/image/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. baseUrl:uni.getStorageSync('requestImagesPath'),
  59. // 是否展开
  60. isExpand: true,
  61. textHeight: 0, //文本高度
  62. }
  63. },
  64. methods: {
  65. // 展开简介
  66. handleExpand() {
  67. this.isExpand = !this.isExpand
  68. },
  69. getDescHeight() {
  70. this.$nextTick(() => {
  71. const query = uni.createSelectorQuery().in(this);
  72. query
  73. .select("#descbox-desc")
  74. .boundingClientRect((data) => {
  75. if(data){
  76. this.textHeight = data.height
  77. }
  78. })
  79. .exec();
  80. })
  81. },
  82. }
  83. }
  84. </script>
  85. <style scoped lang="scss">
  86. @mixin u-flex($flexD, $alignI, $justifyC) {
  87. display: flex;
  88. flex-direction: $flexD;
  89. align-items: $alignI;
  90. justify-content: $justifyC;
  91. }
  92. .miantitlebox {
  93. padding: 30rpx 32rpx;
  94. font-family: PingFang SC, PingFang SC;
  95. font-weight: 500;
  96. font-size: 36rpx;
  97. color: #222222;
  98. }
  99. .subtitlebox {
  100. padding: 30rpx 0;
  101. font-family: PingFang SC, PingFang SC;
  102. font-weight: 500;
  103. font-size: 36rpx;
  104. color: #222222;
  105. }
  106. .title-content {
  107. padding: 0 32rpx;
  108. background-color: #fff;
  109. font-size: 28rpx;
  110. line-height: 1.6;
  111. .title {
  112. font-size: 36rpx;
  113. font-weight: 500;
  114. color: #414858;
  115. }
  116. .time-or-subtitle {
  117. margin-top: 12rpx;
  118. color: #666666;
  119. }
  120. }
  121. .descbox {
  122. padding: 14rpx 32rpx;
  123. margin-bottom: 20rpx;
  124. background-color: #fff;
  125. font-family: PingFang SC, PingFang SC;
  126. font-weight: 400;
  127. font-size: 28rpx;
  128. color: #222222;
  129. line-height: 42rpx;
  130. word-break: break-word;
  131. &-title {
  132. margin-bottom: 24rpx;
  133. font-weight: 500;
  134. font-size: 32rpx;
  135. }
  136. &-info {
  137. margin-bottom: 24rpx;
  138. @include u-flex(row, center, space-between);
  139. font-size: 26rpx;
  140. color: #757575;
  141. &-l {
  142. flex: 1;
  143. @include u-flex(row, center, flex-start);
  144. }
  145. &-time {
  146. margin-left: 18rpx;
  147. padding-left: 18rpx;
  148. position: relative;
  149. &::after {
  150. content: "";
  151. width: 4rpx;
  152. height: 4rpx;
  153. background: #999999;
  154. border-radius: 50%;
  155. position: absolute;
  156. left: 0;
  157. top: 50%;
  158. transform: translateY(-50%);
  159. }
  160. }
  161. &-r {
  162. background: transparent;
  163. }
  164. }
  165. &-desc {
  166. overflow: hidden;
  167. position: relative;
  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>