detail.vue 10 KB

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