descInfoNav.vue 5.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254
  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 class="giftbtn-big" v-if="isLogin">
  39. 兑换礼品
  40. <wx-open-launch-weapp appid="wx20d588bebb30130f" path="pages_user/integralGoodsList" @launch="weappLaunch" @error="weappError">
  41. <component :is="'script'" type="text/wxtag-template">
  42. <div class="giftbtn-big-weapp"></div>
  43. </component>
  44. </wx-open-launch-weapp>
  45. </view>
  46. </view>
  47. </view>
  48. </template>
  49. <script>
  50. export default {
  51. props: {
  52. isLogin: {
  53. type: Boolean,
  54. default: false,
  55. },
  56. isAddKf: {
  57. type: [String,Number],
  58. default: 0,
  59. },
  60. courseInfo: {
  61. type: Object,
  62. default: {},
  63. },
  64. showAnswerTip: {
  65. type: Boolean,
  66. default: false,
  67. },
  68. source: {
  69. type: String,
  70. default: '',
  71. },
  72. },
  73. data() {
  74. return {
  75. // 是否展开
  76. isExpand: true,
  77. textHeight: 0, //文本高度
  78. }
  79. },
  80. methods: {
  81. // 展开简介
  82. handleExpand() {
  83. this.isExpand = !this.isExpand
  84. },
  85. getDescHeight() {
  86. this.$nextTick(() => {
  87. const query = uni.createSelectorQuery().in(this);
  88. query
  89. .select("#descbox-desc")
  90. .boundingClientRect((data) => {
  91. if(data){
  92. this.textHeight = data.height
  93. }
  94. })
  95. .exec();
  96. })
  97. },
  98. handleGift() {
  99. this.$emit('handleGift')
  100. }
  101. }
  102. }
  103. </script>
  104. <style>
  105. .giftbtn-big-weapp {
  106. position: absolute;
  107. top: 0;
  108. left: 0;
  109. width: 100%;
  110. height: 100%;
  111. }
  112. </style>
  113. <style scoped lang="scss">
  114. @mixin u-flex($flexD, $alignI, $justifyC) {
  115. display: flex;
  116. flex-direction: $flexD;
  117. align-items: $alignI;
  118. justify-content: $justifyC;
  119. }
  120. .giftbtn-big {
  121. width: 100%;
  122. height: 98rpx;
  123. border-radius: 19rpx;
  124. line-height: 98rpx;
  125. text-align: center;
  126. font-family: PingFang SC, PingFang SC;
  127. font-weight: 600;
  128. font-size: 32rpx;
  129. color: #FF5C03;
  130. @include u-flex(row, center, center);
  131. border: 1px solid #FF5C03;
  132. position: relative;
  133. }
  134. .miantitlebox {
  135. padding: 30rpx 32rpx;
  136. font-family: PingFang SC, PingFang SC;
  137. font-weight: 500;
  138. font-size: 36rpx;
  139. color: #222222;
  140. }
  141. .subtitlebox {
  142. padding: 30rpx 0;
  143. font-family: PingFang SC, PingFang SC;
  144. font-weight: 500;
  145. font-size: 36rpx;
  146. color: #222222;
  147. }
  148. .title-content {
  149. padding: 0 32rpx;
  150. background-color: #fff;
  151. font-size: 28rpx;
  152. line-height: 1.6;
  153. @include u-flex(row, center, space-between);
  154. .title {
  155. font-size: 36rpx;
  156. font-weight: 500;
  157. color: #414858;
  158. }
  159. .time-or-subtitle {
  160. margin-top: 12rpx;
  161. color: #666666;
  162. }
  163. .giftbtn {
  164. flex-shrink: 0;
  165. padding: 6rpx 16rpx;
  166. background: #FF5C03;
  167. border-radius: 42rpx 42rpx 42rpx 42rpx;
  168. @include u-flex(row, center, center);
  169. font-family: PingFang SC;
  170. font-weight: 500;
  171. font-size: 28rpx;
  172. color: #FFFFFF;
  173. }
  174. }
  175. .descbox {
  176. padding: 14rpx 32rpx;
  177. margin-bottom: 20rpx;
  178. background-color: #fff;
  179. font-family: PingFang SC, PingFang SC;
  180. font-weight: 400;
  181. font-size: 28rpx;
  182. color: #222222;
  183. line-height: 42rpx;
  184. word-break: break-word;
  185. &-title {
  186. margin-bottom: 24rpx;
  187. font-weight: 500;
  188. font-size: 32rpx;
  189. }
  190. &-info {
  191. margin-bottom: 24rpx;
  192. @include u-flex(row, center, space-between);
  193. font-size: 26rpx;
  194. color: #757575;
  195. &-l {
  196. flex: 1;
  197. @include u-flex(row, center, flex-start);
  198. }
  199. &-time {
  200. margin-left: 18rpx;
  201. padding-left: 18rpx;
  202. position: relative;
  203. &::after {
  204. content: "";
  205. width: 4rpx;
  206. height: 4rpx;
  207. background: #999999;
  208. border-radius: 50%;
  209. position: absolute;
  210. left: 0;
  211. top: 50%;
  212. transform: translateY(-50%);
  213. }
  214. }
  215. &-r {
  216. background: transparent;
  217. }
  218. }
  219. &-desc {
  220. overflow: hidden;
  221. position: relative;
  222. }
  223. }
  224. .expand {
  225. flex-shrink: 0;
  226. @include u-flex(row, center, flex-end);
  227. color: #FF5C03;
  228. font-weight: 400;
  229. font-size: 24rpx;
  230. image {
  231. width: 32rpx;
  232. height: 32rpx;
  233. }
  234. }
  235. .expand-ab {
  236. position: absolute;
  237. top: 0;
  238. right: 0;
  239. box-shadow: -50rpx 0 20rpx 8rpx #FFFFFF;
  240. background-color: #fff;
  241. }
  242. </style>