videoInfo.vue 5.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261
  1. <template>
  2. <view class="container">
  3. <view class="conwarp">
  4. <view class="gdHead dffs">
  5. <view class="head flex1">{{ goodInfo.title }}</view>
  6. <text v-for="(item, index) in goodInfo.tags.split('|')" class="desc">{{ item }}</text>
  7. </view>
  8. <view class="subtit textgrey fontssm">{{ goodInfo.desc }}</view>
  9. <!-- -->
  10. <view class="cl-one"><video id='myVideo' class="vidBox" @timeupdate="timeupdate" @play="play"
  11. :initial-time="0" :src="goodInfo.files" controls></video></view>
  12. </view>
  13. <view class="conwarp">
  14. <view class="gdHead">
  15. <view class="head">课程简介</view>
  16. </view>
  17. <view class="cl-one">
  18. <view class="xqcont">
  19. <u-parse :content="goodInfo.content"></u-parse>
  20. </view>
  21. </view>
  22. </view>
  23. <view v-if="goodInfo.is_pay != 0 && goodInfo.my_is_pay == 0" class="fixBox dfsb">
  24. <view @tap="toPay()" class="li flex1 dffs">
  25. <image src="/static/img/pro/navlidown.png" mode=""></image>
  26. 普通购买
  27. </view>
  28. <block v-if="goodInfo.is_vip == 1">
  29. <view class="line"></view>
  30. <view @tap="toPay()" class="li flex1 dffs">
  31. <image src="/static/img/pro/navlivdown.png" mode=""></image>
  32. 会员购买
  33. </view>
  34. </block>
  35. </view>
  36. </view>
  37. </template>
  38. <script>
  39. export default {
  40. data() {
  41. return {
  42. id: 0, //商品id
  43. type: '',
  44. goodInfo: {
  45. tags: ''
  46. }
  47. };
  48. },
  49. onLoad(option) {
  50. this.id = option.id || '';
  51. this.type = option.type || '';
  52. this.loadData();
  53. },
  54. onReady: function(res) {
  55. this.videoContext = uni.createVideoContext('myVideo')
  56. },
  57. methods: {
  58. timeupdate(e) {
  59. console.log(parseInt(e.detail.currentTime));
  60. // is_pay 0 免费 1 付费 my_is_pay 0 未购买 1 已购买
  61. if (this.goodInfo.is_pay != 0 && this.goodInfo.my_is_pay != 1) {
  62. console.log(11);
  63. // is_vip/是否是会员: 0=否 1=是 see_time 可试看时长: 秒
  64. if (parseInt(e.detail.currentTime) >= parseInt(this.goodInfo.see_time)) {
  65. // e.detail.currentTime = 0;
  66. this.$api.toast('请购买后观看完整视频');
  67. setTimeout(res => {
  68. this.videoContext.pause()
  69. this.videoContext.seek(0);
  70. }, 800);
  71. }
  72. }
  73. },
  74. play(e) {
  75. let url = 'index/setSee';
  76. this.$api
  77. .request(url, {
  78. id: this.id
  79. })
  80. .then(res => {
  81. if (res.code != '200') {
  82. this.$api.toast(res.msg);
  83. }
  84. });
  85. },
  86. /**
  87. * 请求数据只是为了代码不那么乱
  88. * 分次请求未作整合
  89. */
  90. async loadData() {
  91. let url = 'index/getVideoInfo';
  92. this.$api
  93. .request(url, {
  94. id: this.id
  95. })
  96. .then(res => {
  97. if (res.code == '200') {
  98. let data = res.data;
  99. this.goodInfo = data;
  100. } else {
  101. this.$api.toast(res.msg);
  102. }
  103. });
  104. },
  105. //去支付购买
  106. toPay() {
  107. uni.navigateTo({
  108. url: '/pages/pay/payVid?item=' + JSON.stringify(this.goodInfo)
  109. });
  110. }
  111. }
  112. };
  113. </script>
  114. <style lang="scss" scoped>
  115. .container {
  116. .conwarp {
  117. background-color: #fff;
  118. padding: 26rpx 30rpx 39rpx;
  119. border-radius: 16rpx;
  120. margin-bottom: 20rpx;
  121. .gdHead {
  122. line-height: 58rpx;
  123. margin-bottom: 16rpx;
  124. .head {
  125. font-size: 34rpx;
  126. font-family: PingFangSC-Medium, PingFang SC;
  127. font-weight: 600;
  128. color: #333333;
  129. line-height: 48rpx;
  130. }
  131. .desc {
  132. background: #f89638;
  133. border-radius: 5rpx;
  134. font-size: 18rpx;
  135. height: 32rpx;
  136. line-height: 32rpx;
  137. padding: 0rpx 8rpx;
  138. display: inline-block;
  139. color: #fff;
  140. margin-left: 10rpx;
  141. &:nth-of-type(2) {
  142. background: #7fc06e;
  143. }
  144. &:nth-of-type(3) {
  145. background: #75b2c4;
  146. }
  147. &:nth-of-type(4) {
  148. background: #8875c0;
  149. }
  150. }
  151. }
  152. .subtit {
  153. margin-top: 10rpx;
  154. }
  155. .cl-one {
  156. .vidBox {
  157. margin-top: 30rpx;
  158. width: 690rpx;
  159. height: 335rpx;
  160. }
  161. .xqcont {
  162. min-height: 800rpx;
  163. width: 100%;
  164. align-items: center;
  165. position: relative;
  166. .xqleft {
  167. position: absolute;
  168. top: 100rpx;
  169. right: 0;
  170. align-items: center;
  171. justify-content: center;
  172. .small {
  173. width: 54rpx;
  174. height: 54rpx;
  175. }
  176. .big {
  177. width: 108rpx;
  178. height: 108rpx;
  179. }
  180. .word {
  181. margin: 8rpx 0 48rpx;
  182. font-size: 20rpx;
  183. color: #999;
  184. }
  185. }
  186. .btnsBox {
  187. align-items: center;
  188. .small {
  189. width: 90rpx;
  190. height: 90rpx;
  191. margin: 60rpx 0 16rpx;
  192. opacity: 0.8;
  193. }
  194. .btns {
  195. margin: 70rpx 60rpx 0;
  196. width: 154rpx;
  197. height: 54rpx;
  198. background: #f6f6f6;
  199. border-radius: 31px;
  200. align-items: center;
  201. padding: 0 15rpx;
  202. justify-content: space-around;
  203. .icon {
  204. width: 35rpx;
  205. height: 31rpx;
  206. }
  207. .word {
  208. font-size: 22rpx;
  209. color: #666;
  210. }
  211. }
  212. }
  213. }
  214. }
  215. }
  216. .fixBox {
  217. padding: 34rpx;
  218. .line {
  219. width: 1rpx;
  220. height: 20rpx;
  221. background: #b7b7bd;
  222. }
  223. .li {
  224. justify-content: center;
  225. color: #7fc06e;
  226. image {
  227. width: 42rpx;
  228. height: 32rpx;
  229. margin-right: 20rpx;
  230. }
  231. }
  232. }
  233. }
  234. </style>