catli.vue 8.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363
  1. <template>
  2. <view class="container">
  3. <view class="conwarp">
  4. <view class="cl-one"><video id='myVideo' class="vidBox" @timeupdate="timeupdate" @play="play"
  5. initial-time="0" :src="selInfo.files" controls></video></view>
  6. <view class="dfsb">
  7. <view class="gdHead flex1">
  8. <view class="head">{{ selInfo.title }}</view>
  9. <view class="subtit dfsb textgrey fontssm flex1">{{ selInfo.desc }}
  10. <view @click="getSon()" class="promain fontsm dffs">{{showSon?'关闭':"展开更多"}}
  11. <u-icon class="icondoen" size="12" name='arrow-right-double'></u-icon>
  12. </view>
  13. </view>
  14. </view>
  15. <view @click.stop="downItem(selInfo)" class="down dffs">
  16. <u-icon name='download' color="#26565A"></u-icon>
  17. 下载文档
  18. </view>
  19. </view>
  20. <view v-if="showSon" class="sonlist">
  21. <video-list flag="5" :list="sonList"></video-list>
  22. <view v-if="status1 !='nomore'" @click="getmore()" class="promain tips fontsm dffs"> 查看更多 <u-icon class="icon"
  23. name='arrow-down' size='14'></u-icon>
  24. </view>
  25. </view>
  26. </view>
  27. <view class="listBox">
  28. <view @click="selItem(item)" class="bb vidLi dfsb" v-for="(item, ind) in list" :key="ind">
  29. <view v-if="item.id!=selInfo.id" class="show">
  30. </view>
  31. <!-- <image class="imgbox" :src="item.img" mode=""></image> -->
  32. <view class="imgbox">
  33. <image :src="item.img" mode=""></image>
  34. <view class="look">{{ item.fen }} </view>
  35. </view>
  36. <view class="dffd flex1">
  37. <view class="title elli">{{ item.title }}</view>
  38. <view class="textgrey oneelli fontsm">{{ item.desc }}</view>
  39. <view class="auth dfsb">
  40. <text class="fontssm prosecond"> {{ item.is_pay==0?'免费':item.my_is_pay==0?'付费':'已购买' }}</text>
  41. <view @click.stop="downItem(item)" class="down dffs">
  42. <u-icon name='download' color="#26565A"></u-icon>
  43. 下载文档
  44. </view>
  45. </view>
  46. </view>
  47. </view>
  48. </view>
  49. <view class="fixBox">
  50. <view @click="buyTips" v-if="totalInfo.my_is_pay==0" class="clickbtn promain">
  51. 购买全部视频课程:¥{{totalInfo.is_vip==1?totalInfo.vip_price:totalInfo.price}}
  52. </view>
  53. </view>
  54. <y-modal ref='popup' title="提示" text='您确认付费购买此课程吗' @onConfirm='onConfirm'></y-modal>
  55. </view>
  56. </template>
  57. <script>
  58. import {
  59. mixin
  60. } from './mixin.js'
  61. import videoList from '@/pages/index/components/wordlist.vue';
  62. export default {
  63. components: {
  64. videoList
  65. },
  66. mixins: [mixin],
  67. data() {
  68. return {
  69. cat_id: 0, //二级分类cat_id
  70. list: [], //返回列表
  71. selInfo: {}, //选中视频
  72. totalInfo: {}, //总数居
  73. page: 1,
  74. limit: 6,
  75. status: 'loadmore',
  76. page1: 1,
  77. limit1: 6,
  78. status1: 'loadmore',
  79. showSon: false,
  80. sonList: [],
  81. };
  82. },
  83. onPullDownRefresh() {
  84. this.page = 1;
  85. this.list = [];
  86. this.loadData();
  87. setTimeout(res => {
  88. uni.stopPullDownRefresh();
  89. }, 1000);
  90. },
  91. onReachBottom() {
  92. if (this.status == 'nomore') return;
  93. this.status = 'loading';
  94. this.page = ++this.page;
  95. this.loadData();
  96. },
  97. onLoad(option) {
  98. this.cat_id = option.cat_id || '';
  99. this.loadData();
  100. },
  101. onReady: function(res) {
  102. this.videoContext = uni.createVideoContext('myVideo')
  103. },
  104. methods: {
  105. getmore() {
  106. this.status1 = 'loading';
  107. this.page1 = ++this.page1;
  108. this.getsonList();
  109. },
  110. // 获取文档
  111. getSon() {
  112. if (this.showSon) {
  113. this.showSon = !this.showSon
  114. return
  115. }
  116. this.showSon = !this.showSon
  117. this.page1=1;
  118. this.status1='loading'
  119. this.sonList=[];
  120. this.getsonList()
  121. },
  122. getsonList() {
  123. let url = 'new_cate/getVideoFiles';
  124. this.$api
  125. .request(url, {
  126. video_id: this.selInfo.id,
  127. page: this.page1,
  128. limit: this.limit1
  129. })
  130. .then(data => {
  131. if (data.code == '200') {
  132. this.sonList = this.sonList.concat(data.data);
  133. if (data.data.length < this.limit1) {
  134. this.status1 = 'nomore';
  135. }
  136. } else {
  137. this.$api.toast(data.msg);
  138. }
  139. });
  140. },
  141. // 提示购买
  142. buyTips(item) {
  143. this.buyId = this.totalInfo.id;
  144. this.$refs['popup'].open();
  145. },
  146. timeupdate(e) {
  147. console.log(parseInt(e.detail.currentTime));
  148. // is_pay 0 免费 1 付费 my_is_pay 0 未购买 1 已购买
  149. if (this.selInfo.is_pay != 0 && this.selInfo.my_is_pay != 1) {
  150. // is_vip/是否是会员: 0=否 1=是 see_time 可试看时长: 秒
  151. if (parseInt(e.detail.currentTime) >= parseInt(this.selInfo.see_time)) {
  152. this.$api.toast('请购买后观看完整视频');
  153. setTimeout(res => {
  154. // #ifdef MP-WEIXIN
  155. this.videoContext.stop();
  156. // #endif
  157. // #ifndef MP-WEIXIN
  158. this.videoContext.pause();
  159. // #endif
  160. this.videoContext.seek(0);
  161. }, 800);
  162. }
  163. }
  164. },
  165. play(e) {
  166. let url = 'index/setSee';
  167. this.$api
  168. .request(url, {
  169. id: this.selInfo.id
  170. })
  171. .then(res => {
  172. if (res.code != '200') {
  173. this.$api.toast(res.msg);
  174. }
  175. });
  176. },
  177. // 下载
  178. downItem(item) {
  179. // "is_pay": 0, //是否免费: 0=是(直接看) 1=付费(没购买的需要判断试看时长停止播放, 购买过得不需要)
  180. // "my_is_pay": 1 //是否已购买: 0=否 1=是
  181. if (item.is_pay == 1 && item.my_is_pay == 0) {
  182. this.$api.toast('请先购买')
  183. } else {
  184. uni.navigateTo({
  185. url: '/pagesA/catList/downlist?video_id=' + item.id
  186. })
  187. }
  188. },
  189. //选中
  190. selItem(item) {
  191. this.showSon = false;
  192. this.page1 = 1;
  193. this.sonList = [];
  194. this.selInfo = item;
  195. },
  196. async loadData() {
  197. let url = 'new_cate/getVideoList';
  198. this.$api
  199. .request(url, {
  200. id: this.cat_id,
  201. page: this.page,
  202. limit: this.limit
  203. })
  204. .then(res => {
  205. if (res.code == '200') {
  206. this.totalInfo = res.data.info;
  207. if (!this.selInfo.title) {
  208. this.selInfo = res.data.list[0]
  209. }
  210. console.log(!this.selInfo);
  211. this.list = this.list.concat(res.data.list);
  212. if (res.data.list.length < this.pagnum) {
  213. this.status = 'nomore';
  214. }
  215. } else {
  216. this.$api.toast(res.msg);
  217. }
  218. });
  219. },
  220. //去支付购买
  221. toPay() {
  222. uni.navigateTo({
  223. url: '/pages/pay/payVid?item=' + JSON.stringify(this.selInfo)
  224. });
  225. }
  226. }
  227. };
  228. </script>
  229. <style lang="scss" scoped>
  230. .container {
  231. padding-bottom: 100rpx;
  232. .conwarp {
  233. background-color: #fff;
  234. padding: 0rpx 30rpx 10rpx;
  235. border-radius: 16rpx;
  236. margin-bottom: 20rpx;
  237. .gdHead {
  238. line-height: 58rpx;
  239. margin: 16rpx 0;
  240. .head {
  241. font-family: PingFangSC-Medium, PingFang SC;
  242. font-weight: 600;
  243. color: #333333;
  244. line-height: 48rpx;
  245. }
  246. /deep/ .u-icon--right {
  247. transform: rotate(90deg);
  248. }
  249. }
  250. .cl-one {
  251. .vidBox {
  252. margin-top: 30rpx;
  253. width: 690rpx;
  254. height: 335rpx;
  255. }
  256. }
  257. }
  258. .down {
  259. padding: 0 15rpx;
  260. // width: 147rpx;
  261. height: 64rpx;
  262. text-align: center;
  263. line-height: 64rpx;
  264. background: rgba(205, 222, 222, 0.39);
  265. color: #26565A;
  266. font-size: 26rpx;
  267. border-radius: 34rpx;
  268. }
  269. .vidLi {
  270. position: relative;
  271. width: 100%;
  272. padding: 27rpx;
  273. background-color: #fff;
  274. .show {
  275. position: absolute;
  276. width: 100%;
  277. height: 100%;
  278. background-color: #000;
  279. opacity: 0.5;
  280. z-index: 999;
  281. }
  282. &:nth-of-type(2n) {
  283. margin-right: 0;
  284. }
  285. // .imgbox {
  286. // width: 250rpx;
  287. // height: 180rpx;
  288. // }
  289. .imgbox {
  290. width: 250rpx;
  291. height: 180rpx;
  292. margin-right: 18rpx;
  293. border-radius: 10rpx;
  294. position: relative;
  295. image {
  296. width: 250rpx;
  297. height: 180rpx;
  298. border-radius: 10rpx;
  299. }
  300. .look {
  301. position: absolute;
  302. bottom: 15rpx;
  303. right: 19rpx;
  304. background: rgba(#000, 0.3);
  305. border-radius: 18rpx;
  306. font-size: 20rpx;
  307. line-height: 28rpx;
  308. padding: 5rpx 14rpx;
  309. color: #ffffff;
  310. display: inline-block;
  311. }
  312. }
  313. .title {
  314. font-size: 28rpx;
  315. line-height: 40rpx;
  316. margin-bottom: 12rpx;
  317. }
  318. .auth {
  319. margin-top: 15rpx;
  320. width: 100%;
  321. }
  322. }
  323. .bgg {
  324. background: #ececec;
  325. }
  326. .clickbtn {
  327. margin: 0 30rpx;
  328. background: rgba(205, 222, 222, 0.39);
  329. }
  330. .sonlist {
  331. padding: 10rpx 30rpx;
  332. .tips{
  333. padding-top: 20rpx;
  334. width: 100%;
  335. justify-content: center;
  336. }
  337. }
  338. }
  339. </style>