detail.vue 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461
  1. <template>
  2. <view>
  3. <view class="videoBox" >
  4. <view >
  5. <view class="video_box" v-if="!startStatus">
  6. <image :src="$method.splitImgHost(detail.coverUrl)" style="width: 100%;height: 460rpx;"></image>
  7. <image v-if="false" class="video_play" src="/static/play.png" @click="startVideo"></image>
  8. </view>
  9. <view v-else class="video_box" style="width: 100%;height: 460rpx;">
  10. <polyv-player
  11. id="playerVideo"
  12. playerId="playerVideo"
  13. height="460rpx"
  14. :vid="vid"
  15. :showSettingBtn="true"
  16. :enablePlayGesture="true"
  17. :playbackRate="playbackRate"
  18. :isAllowSeek="isAllowSeek"
  19. :autoplay="autoplay"
  20. :startTime="startTime"
  21. @statechange="onStateChange"
  22. ></polyv-player>
  23. </view>
  24. <view style="padding:20rpx;height: 120rpx;">
  25. <view style="display: flex;">
  26. <view class="yearTag" v-if="detail.year">{{detail.year}}</view>
  27. <view class="titleTag">{{detail.goodsName}}</view>
  28. </view>
  29. <view style="display: flex;justify-content: space-between;margin-top: 13rpx;">
  30. <view class="noteTag"><image src="/static/icon/wk_icon1.png" class="wk_icon"></image>
  31. 共 <text class="blackFont">{{detail.subjectNum}}</text> 科 {{detail.classHours}}</text> 学时</view>
  32. </view>
  33. </view>
  34. </view>
  35. <u-line color="#D6D6DB" />
  36. <view style="height: 80rpx;">
  37. <view style="width: 160px;margin: 0 auto;"><u-tabs :list="list" item-width="150" font-size="24" bar-width="110" :current="current" @change="change" active-color="#007AFF"></u-tabs></view>
  38. </view>
  39. </view>
  40. <view style="padding: 20rpx;position: relative;top: 680rpx;" v-show="current==0">
  41. <<<<<<< HEAD
  42. <view class="content">
  43. <view v-html="detail.mobileDetailHtml" style="width: 100%;overflow: hidden;"></view>
  44. =======
  45. <view class="content" style="padding: 10rpx;">
  46. <view v-html="detail.mobileDetailHtml" style="width: 100%;"></view>
  47. >>>>>>> 50b8991b1bbfc147f6098874fb80946439feb3c1
  48. </view>
  49. </view>
  50. <view style="padding: 20rpx;padding-bottom: 100rpx;position: relative;top: 680rpx;" v-show="current==1">
  51. <view >
  52. <view v-for="(item,index) in courseList" >
  53. <view class="courseItemBox" >
  54. <view class="courseItem" @click="openCourse(item)">
  55. <view class="courseName">{{item.courseName}}</view>
  56. <view>
  57. <image src="/static/icon/up.png" class="icon_up" v-if="item.down"></image>
  58. <image src="/static/icon/down.png" class="icon_up" v-if="!item.down"></image>
  59. </view>
  60. </view>
  61. <view v-show="!item.down">
  62. <view v-for="(itemM,indexM) in menuList" >
  63. <courseModule v-if="itemM.type==1" :menuItem="itemM"></courseModule>
  64. <courseChapter v-if="itemM.type==2" :isBuy="false" :menuItem="itemM"></courseChapter>
  65. <courseSection v-if="itemM.type==3" :isBuy="false" :menuItem="itemM"></courseSection>
  66. <u-line></u-line>
  67. </view>
  68. </view>
  69. </view>
  70. </view>
  71. </view>
  72. </view>
  73. <view class="bottomBox">
  74. <view class="priceTag">¥ {{detail.standPrice}}</view>
  75. <view style="display: flex;color: #FFFFFF;align-items: center;">
  76. <view class="btn1" @click="addCart">加购物车</view>
  77. <view class="btn2" @click="buy">立即购买 </view>
  78. </view>
  79. </view>
  80. </view>
  81. </template>
  82. <script>
  83. import courseModule from '@/components/course/courseModule.vue';
  84. import courseChapter from '@/components/course/courseChapter.vue';
  85. import courseSection from '@/components/course/courseSection.vue';
  86. import { mapGetters } from 'vuex';
  87. export default {
  88. components: {
  89. courseModule,
  90. courseChapter,
  91. courseSection
  92. },
  93. data() {
  94. return {
  95. id:0,
  96. list: [
  97. {
  98. name: '详情'
  99. },
  100. {
  101. name: '大纲'
  102. }
  103. ],
  104. current:0,
  105. detail:{},
  106. courseList:[],
  107. menuList:[],
  108. startStatus:false,
  109. playbackRate: [1.0],
  110. isAllowSeek:'no',
  111. vid:'',
  112. autoplay:true,
  113. listenConfigList:[],
  114. listenSecond:0,
  115. timer:null,
  116. startTime:0
  117. };
  118. },
  119. computed: { ...mapGetters(['userInfo','goodsAuditionConfigIdList','playSectionId']) },
  120. onLoad(option) {
  121. this.id = option.id;
  122. this.getDetail()
  123. this.goodsCourseList()
  124. },
  125. onUnload(option) {
  126. this.$store.commit('setPlaySectionId', {playSectionId :0});
  127. //移除所有的事件监听器
  128. uni.$off();
  129. },
  130. mounted() {
  131. let self = this
  132. uni.$on('getSection', item => {
  133. //播放试听
  134. self.listenSecond = 0
  135. for (var itemChild of self.listenConfigList) {
  136. if(itemChild.sectionId==self.playSectionId){
  137. if(itemChild.auditionMinute>0){
  138. self.listenSecond = itemChild.auditionMinute *60 //试听秒数
  139. }
  140. }
  141. }
  142. if(self.listenSecond>0){
  143. if(self.timer){
  144. clearInterval(self.timer);
  145. }
  146. if(self.vid){
  147. //切换视频
  148. var polyvPlayerContext = self.selectComponent('#playerVideo');
  149. polyvPlayerContext.changeVid(item.recordingUrl)
  150. }else{
  151. self.vid = item.recordingUrl
  152. }
  153. self.startStatus = true
  154. self.startTime = 0
  155. }else{
  156. self.$u.toast('试听配置错误');
  157. }
  158. })
  159. },
  160. methods: {
  161. onStateChange(newstate, oldstate) {
  162. if (newstate.detail.newstate == 'playing') {
  163. //开始播放
  164. if(this.timer){
  165. clearInterval(this.timer);
  166. }
  167. this.timer = setInterval(this.timeEvent, 1500);//定时器
  168. }
  169. },
  170. closePlay(){
  171. this.vid = ""
  172. this.startStatus = false
  173. },
  174. timeEvent() {
  175. let self = this
  176. var polyvPlayerContext = this.selectComponent('#playerVideo');
  177. if (polyvPlayerContext != null) {
  178. let PlayCurrentTime = polyvPlayerContext.getCurrentTime();
  179. if(PlayCurrentTime>=this.listenSecond){
  180. polyvPlayerContext.stop();
  181. polyvPlayerContext.exitFullScreen();
  182. clearInterval(this.timer);
  183. this.timer = null
  184. uni.showModal({
  185. title: '提示',
  186. content: '试听结束',
  187. showCancel:false,
  188. success: function(resst) {
  189. self.closePlay()
  190. }
  191. });
  192. }
  193. }
  194. },
  195. openCourse(item){
  196. item.down = !item.down
  197. if(!item.down&&this.menuList.length==0){
  198. this.getMenuList(item.courseId)
  199. }
  200. },
  201. addShopCart() {
  202. let self = this
  203. this.$api.addCart({goodsId:this.id}).then(res => {
  204. if(res.data.code==200){
  205. uni.setStorageSync('updateCart',1) //提醒刷新购物车
  206. uni.showToast({
  207. title: '添加成功'
  208. });
  209. }else{
  210. this.$u.toast(res.data.msg);
  211. }
  212. });
  213. },
  214. goodsCourseList() {
  215. let self = this
  216. this.$api.goodsCourseList(this.id).then(res => {
  217. if(res.data.code==200){
  218. for(let i=0;i<res.data.rows.length;i++){
  219. let item = res.data.rows[i]
  220. item.down = true
  221. }
  222. self.courseList = res.data.rows
  223. }
  224. });
  225. },
  226. getMenuList(courseId) {
  227. let self = this
  228. this.$api.menuList({courseId:courseId}).then(res => {
  229. if(res.data.code==200){
  230. for(let i=0;i<res.data.rows.length;i++){
  231. let item = res.data.rows[i]
  232. item.down = true
  233. item.id = item.menuId
  234. item.name = item.menuName
  235. if(item.type==3){
  236. //判断是否试听
  237. item.tryListen = false
  238. if(self.goodsAuditionConfigIdList.indexOf(item.id)!==-1){
  239. item.tryListen = true
  240. }
  241. }
  242. }
  243. self.menuList = res.data.rows
  244. }
  245. });
  246. },
  247. getDetail() {
  248. let self = this
  249. let sectionIdList = []
  250. this.$api.commonGoodsDetail(this.id).then(res => {
  251. if(res.data.code==200){
  252. if(res.data.data.mobileDetailHtml){
  253. res.data.data.mobileDetailHtml = res.data.data.mobileDetailHtml.replace(/<img/gi,'<img style="max-width:100%;"')
  254. }
  255. self.detail = res.data.data
  256. if(self.detail.goodsAuditionConfig){
  257. self.listenConfigList = JSON.parse(self.detail.goodsAuditionConfig)
  258. for (var itemChild of self.listenConfigList) {
  259. sectionIdList.push(itemChild.sectionId)//存储试听节ID
  260. }
  261. self.$store.commit('setGoodsAuditionConfigIdList', {goodsAuditionConfigIdList:sectionIdList});
  262. }
  263. }
  264. });
  265. },
  266. buy(){
  267. if(this.$method.isGoLogin()){
  268. return
  269. }
  270. this.$navTo.togo('/pages2/order/confirm_list?id='+this.id);
  271. },
  272. addCart(){
  273. if(this.$method.isGoLogin()){
  274. return
  275. }
  276. this.addShopCart()
  277. },
  278. open(item){
  279. item.showChildren = !item.showChildren
  280. },
  281. change(index){
  282. this.current = index;
  283. }
  284. }
  285. };
  286. </script>
  287. <style >
  288. page{
  289. background-color: #EAEEF1;
  290. }
  291. </style>
  292. <style scope>
  293. .video_t2 {
  294. font-size: 24rpx;
  295. font-family: PingFang SC;
  296. font-weight: 500;
  297. color: #666666;
  298. }
  299. .video_t1 {
  300. height: 80rpx;
  301. color: #333333;
  302. line-height: 80rpx;
  303. font-size: 30rpx;
  304. font-family: PingFang SC;
  305. font-weight: bold;
  306. color: #333333;
  307. overflow: hidden;
  308. text-overflow:ellipsis;
  309. white-space: nowrap;
  310. }
  311. .video_t1_t {
  312. display: flex;
  313. flex-direction: column;
  314. height: 80rpx;
  315. color: #333333;
  316. text-align: center;
  317. align-items: center;
  318. border-left: solid 1px #d6d6db;
  319. }
  320. .video_play {
  321. position: absolute;
  322. width: 95rpx;
  323. height: 95rpx;
  324. top: 0;
  325. left: 0;
  326. right: 0;
  327. bottom: 0;
  328. margin: auto;
  329. }
  330. .video_box {
  331. position: relative;
  332. }
  333. .courseName{
  334. white-space:nowrap;
  335. overflow:hidden;
  336. text-overflow:ellipsis;
  337. }
  338. .videoBox{
  339. position: fixed;
  340. background-color: #FFFFFF;
  341. width: 100%;
  342. height: 680rpx;
  343. z-index: 999;
  344. }
  345. .icon_up{
  346. width: 32rpx;
  347. height: 32rpx;
  348. }
  349. .contentBox{
  350. }
  351. .courseItemBox{
  352. background: #FFFFFF;
  353. border-radius: 16rpx;
  354. padding: 0 10rpx;
  355. margin-bottom: 20rpx;
  356. }
  357. .courseItem{
  358. height: 80rpx;
  359. color: #333333;
  360. font-size: 32rpx;
  361. line-height: 80rpx;
  362. font-weight: bold;
  363. display: flex;
  364. justify-content: space-between;
  365. }
  366. .content{
  367. background-color: #FFFFFF;
  368. width: 100%;
  369. }
  370. .btn2{
  371. width: 200rpx;
  372. height: 64rpx;
  373. background: linear-gradient(0deg, #FFB102, #FD644F);
  374. box-shadow: 0rpx 10rpx 16rpx 4rpx rgba(1, 99, 235, 0.04);
  375. border-radius: 32rpx;
  376. line-height: 64rpx;
  377. text-align: center;
  378. }
  379. .btn1{
  380. width: 200rpx;
  381. height: 64rpx;
  382. background: linear-gradient(0deg, #015EEA, #00C0FA);
  383. border-radius: 32rpx;
  384. line-height: 64rpx;
  385. text-align: center;
  386. margin-right: 20rpx;
  387. }
  388. .bottomBox{
  389. position: fixed;
  390. bottom: 0;
  391. width: 100%;
  392. left: 0;
  393. height:98rpx ;
  394. background-color: #FFFFFF;
  395. display: flex;
  396. justify-content: space-between;
  397. align-items: center;
  398. padding: 0 30rpx;
  399. }
  400. .blackFont{
  401. color: #333333;
  402. margin: 0 4rpx;
  403. }
  404. .wk_icon{
  405. width: 24rpx;
  406. height: 24rpx;
  407. margin-right: 12rpx;
  408. }
  409. .noteTag{
  410. ont-size: 24rpx;
  411. font-family: PingFang SC;
  412. font-weight: 500;
  413. color: #999999;
  414. align-items: center;
  415. }
  416. .priceTag{
  417. font-size: 30rpx;
  418. font-family: PingFang SC;
  419. font-weight: bold;
  420. color: #FF2D55;
  421. }
  422. .titleTag{
  423. font-size: 32rpx;
  424. font-weight: bold;
  425. color: #333333;
  426. margin-left: 8rpx;
  427. }
  428. .yearTag{
  429. width: 80rpx;
  430. height: 32rpx;
  431. background: #EBF5FF;
  432. border: 2rpx solid #007AFF;
  433. border-radius: 16rpx;
  434. font-size: 24rpx;
  435. color: #007AFF;
  436. text-align: center;
  437. line-height: 32rpx;
  438. }
  439. .itemBox{
  440. background: #FFFFFF;
  441. box-shadow: 0rpx 10rpx 9rpx 1rpx rgba(165, 196, 239, 0.1);
  442. border-radius: 24rpx;
  443. width: 100%;
  444. padding: 20rpx;
  445. margin-bottom: 20rpx;
  446. }
  447. </style>