descInfoNav.vue 4.9 KB

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