descInfo.vue 3.3 KB

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