detail.vue 7.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254
  1. <template>
  2. <view>
  3. <view class="head">
  4. <block v-if="detail.filetype == '视频'">
  5. <video id="myVideo" class="video" :src="files[0].showUrl" />
  6. <view class="video-bottom">
  7. 倍数
  8. <view @click="changeSpeed(item)" v-for="item in speeds" :key="item" class="speed"
  9. :class="speed == item ? 'active' : ''" hover-class="navigator-hover">
  10. {{ item }}x
  11. </view>
  12. </view>
  13. </block>
  14. <block v-else-if="detail.filetype == '图文'">
  15. <scroll-view class="scroll" scroll-y>
  16. <u-parse :content="detail.content" />
  17. </scroll-view>
  18. </block>
  19. <block v-else-if="detail.filetype == '音频'">
  20. <my-audio :src="files[0].url" :title="files[0].document" />
  21. </block>
  22. <view class="collect" @click="loadings.collect ? '' : handleCollect(1, detail.iscollect)">
  23. <u-loading-icon v-if="loadings.collect" />
  24. <block v-else>
  25. <view v-if="detail.iscollect" style="color: #FFC300;" class="iconfont icon-yishoucang" />
  26. <view v-else style="color: #646566;" class="iconfont icon-weishoucang" />
  27. <view class="text">
  28. 收藏
  29. </view>
  30. </block>
  31. </view>
  32. </view>
  33. <My_listbox v-if="showListbox" :pullDown="false" boxBackground="#fff">
  34. <view class="introduce">
  35. <view class="detail-title">详情</view>
  36. <view class="group">
  37. <view class="title">课件名称</view>
  38. <view class="value">{{ detail.title || ' --' }}</view>
  39. </view>
  40. <view class="group">
  41. <view class="title">讲师</view>
  42. <view class="value">{{ detail.teacher || ' --' }}</view>
  43. </view>
  44. <view class="group">
  45. <view class="title">简介</view>
  46. <view class="value">{{ detail.description || ' --' }}</view>
  47. </view>
  48. </view>
  49. </My_listbox>
  50. </view>
  51. </template>
  52. <script>
  53. import myAudio from "../../components/my-audio.vue"
  54. export default {
  55. components: { myAudio },
  56. data() {
  57. return {
  58. sat_coursewaredetailid: 0,
  59. detail: {},
  60. files: [],
  61. showListbox: false,
  62. speed: '1.0',
  63. speeds: ['0.5', '1.0', '1.5', '2.0'],
  64. loadings: {
  65. collect: false
  66. }
  67. }
  68. },
  69. onLoad(options) {
  70. console.log(options)
  71. this.sat_coursewaredetailid = options.id;
  72. this.getDetail()
  73. },
  74. methods: {
  75. getDetail() {
  76. this.$Http.basic({
  77. "id": 20240315131502,
  78. "content": {
  79. "sat_coursewaredetailid": this.sat_coursewaredetailid
  80. }
  81. }).then(res => {
  82. console.log("获取课件详情", res)
  83. if (this.cutoff(res.msg)) return;
  84. this.files = res.data.attinfos.filter(v => {
  85. if (v.usetype == "file") switch (res.data.filetype) {
  86. case '视频':
  87. v.showUrl = this.getSpecifiedImage(v, 'hls')
  88. break;
  89. }
  90. return v.usetype == "file"
  91. });
  92. this.detail = res.data;
  93. uni.setNavigationBarTitle({
  94. title: res.data.title,
  95. })
  96. setTimeout(() => { this.showListbox = true }, 100)
  97. })
  98. },
  99. //修改视频播放倍数
  100. changeSpeed(speed) {
  101. if (!this.videoContext) this.videoContext = uni.createVideoContext('myVideo');
  102. this.videoContext.playbackRate(speed - 0)
  103. this.speed = speed;
  104. },
  105. handleCollect(type, value) {
  106. if (type == 1) {
  107. this.loadings.collect = true;
  108. } else {
  109. this.loadings.like = true;
  110. }
  111. this.$Http.basic({
  112. "id": 20240416133702,
  113. "content": {
  114. "ownertable": "sat_coursewaredetail",
  115. "ownerid": this.detail.sat_coursewaredetailid,
  116. type
  117. },
  118. }).then(res => {
  119. console.log(value ? '取消' : '添加', type == 1 ? "收藏" : "喜欢", res)
  120. if (type == 1) {
  121. this.loadings.collect = false;
  122. } else {
  123. this.loadings.like = false;
  124. }
  125. if (this.cutoff(res.msg)) return;
  126. if (type == 1) {
  127. this.detail.iscollect = value ? 0 : 1
  128. this.detail.collectcount = value ? this.detail.collectcount - 1 : this.detail.collectcount - 0 + 1
  129. } else {
  130. this.detail.islike = value ? 0 : 1
  131. this.detail.likecount = value ? this.detail.likecount - 1 : this.detail.likecount - 0 + 1
  132. }
  133. })
  134. }
  135. }
  136. }
  137. </script>
  138. <style lang="scss">
  139. .head {
  140. position: relative;
  141. width: 100vw;
  142. background: #fff;
  143. margin-bottom: 10px;
  144. .video {
  145. width: 375px;
  146. height: 230px;
  147. }
  148. .video-bottom {
  149. display: flex;
  150. align-items: center;
  151. justify-content: space-around;
  152. width: 375px;
  153. height: 62px;
  154. background: #FFFFFF;
  155. box-sizing: border-box;
  156. .speed {
  157. width: 71px;
  158. height: 32px;
  159. text-align: center;
  160. line-height: 32px;
  161. background: #F2F2F2;
  162. border-radius: 5px;
  163. font-family: PingFang SC, PingFang SC;
  164. font-size: 14px;
  165. color: #333333;
  166. }
  167. .active {
  168. color: #FFFFFF;
  169. background: #C30D23;
  170. }
  171. }
  172. .scroll {
  173. width: 100vw;
  174. height: 400px;
  175. background: #fff;
  176. }
  177. .audio-box {
  178. display: flex;
  179. align-items: center;
  180. justify-content: center;
  181. height: 100px;
  182. }
  183. .collect {
  184. position: absolute;
  185. display: flex;
  186. align-items: center;
  187. justify-content: center;
  188. top: 10px;
  189. right: 10px;
  190. width: 80px;
  191. height: 24px;
  192. background: #FFFFFF;
  193. border-radius: 12px;
  194. border: 1px solid #CCCCCC;
  195. .iconfont {
  196. font-size: 14px;
  197. }
  198. .text {
  199. font-family: PingFang SC, PingFang SC;
  200. font-size: 12px;
  201. color: #333333;
  202. margin-left: 5px;
  203. }
  204. }
  205. }
  206. .introduce {
  207. padding: 10px;
  208. .detail-title {
  209. height: 35px;
  210. background: #FFFFFF;
  211. padding-top: 2px;
  212. font-family: PingFang SC, PingFang SC;
  213. font-weight: bold;
  214. font-size: 16px;
  215. color: #333333;
  216. }
  217. .group {
  218. margin-bottom: 20px;
  219. font-family: Source Han Sans SC, Source Han Sans SC;
  220. font-size: 14px;
  221. line-height: 20px;
  222. .title {
  223. color: #666666;
  224. }
  225. .value {
  226. color: #000000;
  227. margin-top: 10px;
  228. }
  229. }
  230. }
  231. </style>