descInfoNav.vue 4.4 KB

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