descInfo.vue 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163
  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="imgPath+'/app/image/course_arrow_up_icon.png'" v-show="isExpand"></image>
  13. <image :src="imgPath+'/app/image/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="imgPath+'/app/image/course_arrow_up_icon.png'" v-show="isExpand"></image>
  22. <image :src="imgPath+'/app/image/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. computed:{
  44. imgPath() {
  45. return this.$store.state.imgpath
  46. },
  47. },
  48. data() {
  49. return {
  50. // 是否展开
  51. isExpand: true,
  52. textHeight: 0, //文本高度
  53. }
  54. },
  55. methods: {
  56. // 展开简介
  57. handleExpand() {
  58. this.isExpand = !this.isExpand
  59. },
  60. getDescHeight() {
  61. this.$nextTick(() => {
  62. const query = uni.createSelectorQuery().in(this);
  63. query
  64. .select("#descbox-desc")
  65. .boundingClientRect((data) => {
  66. if(data) {
  67. this.textHeight = data.height
  68. }
  69. })
  70. .exec();
  71. })
  72. },
  73. }
  74. }
  75. </script>
  76. <style scoped lang="scss">
  77. @mixin u-flex($flexD, $alignI, $justifyC) {
  78. display: flex;
  79. flex-direction: $flexD;
  80. align-items: $alignI;
  81. justify-content: $justifyC;
  82. }
  83. .descbox {
  84. padding: 0 32rpx;
  85. margin-bottom: 20rpx;
  86. background-color: #fff;
  87. font-family: PingFang SC, PingFang SC;
  88. font-weight: 400;
  89. font-size: 28rpx;
  90. color: #222222;
  91. line-height: 42rpx;
  92. word-break: break-word;
  93. &-title {
  94. padding: 24rpx 0;
  95. font-weight: 500;
  96. font-size: 32rpx;
  97. }
  98. &-info {
  99. padding-top: 24rpx;
  100. @include u-flex(row, center, space-between);
  101. font-size: 26rpx;
  102. color: #757575;
  103. &-l {
  104. flex: 1;
  105. @include u-flex(row, center, flex-start);
  106. }
  107. &-time {
  108. margin-left: 18rpx;
  109. padding-left: 18rpx;
  110. position: relative;
  111. &::after {
  112. content: "";
  113. width: 4rpx;
  114. height: 4rpx;
  115. background: #999999;
  116. border-radius: 50%;
  117. position: absolute;
  118. left: 0;
  119. top: 50%;
  120. transform: translateY(-50%);
  121. }
  122. }
  123. &-r {
  124. background: transparent;
  125. }
  126. }
  127. &-desc {
  128. overflow: hidden;
  129. position: relative;
  130. margin-top: 20rpx;
  131. }
  132. }
  133. .expand {
  134. flex-shrink: 0;
  135. @include u-flex(row, center, flex-end);
  136. color: #FF5C03;
  137. font-weight: 400;
  138. font-size: 24rpx;
  139. image {
  140. width: 32rpx;
  141. height: 32rpx;
  142. }
  143. }
  144. .expand-ab {
  145. position: absolute;
  146. top: 0;
  147. right: 0;
  148. box-shadow: -50rpx 0 20rpx 8rpx #FFFFFF;
  149. background-color: #fff;
  150. }
  151. </style>