details.vue 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663
  1. <template>
  2. <view class="container">
  3. <!-- 轮播图 -->
  4. <view class="swiper">
  5. <view class="swiper-box">
  6. <swiper circular="true" autoplay="true" @change="swiperChange">
  7. <swiper-item v-for="swiper in swiperlist" :key="swiper.id"><image :src="swiper"></image></swiper-item>
  8. </swiper>
  9. <view class="indicator"><view class="dots" v-for="(swiper, index) in swiperlist" :class="[swiperCurrent >= index ? 'on' : '']" :key="index"></view></view>
  10. </view>
  11. <view class="swiper-name">
  12. <view class="flex item-box">
  13. <view class="item-name ellipsis">{{ list.title }}</view>
  14. <view class="item-collection" @click="collect">
  15. <image src="../../static/img/img026.png" v-if="list.collect == false"></image>
  16. <image src="../../static/img/img027.png" v-if="list.collect == true"></image>
  17. <view class="collection">收藏</view>
  18. </view>
  19. </view>
  20. <view class="tip-box">
  21. <text v-for="ls in list.label">{{ ls }}</text>
  22. </view>
  23. <view class="price-box flex">
  24. <view class="price" v-if="list.money != '0.00'">
  25. <text>{{ list.money }}</text>
  26. </view>
  27. <view class="free" v-if="list.money == '0.00'"></view>
  28. <view class="number">已有{{ list.browse_count }}人学习</view>
  29. </view>
  30. </view>
  31. </view>
  32. <!-- <view class="navbar">
  33. <view v-for="(item, index) in navList" :key="index" class="nav-item" :class="{ current: tabCurrentIndex === index }" @click="tabClick(index)">{{ item.text }}</view>
  34. </view> -->
  35. <!-- 详情 -->
  36. <view class="course-details" v-if="tabCurrentIndex == 0">
  37. <view class="top">
  38. <video
  39. class="course-video"
  40. src=""
  41. @play="Onplay"
  42. controls=""
  43. x5-playsinline=""
  44. playsinline=""
  45. webkit-playsinline=""
  46. poster=""
  47. x-webkit-airplay="allow"
  48. preload="auto"
  49. ></video>
  50. </view>
  51. <view class="details-intro">
  52. <view class="intro-title"><text>- 直播简介 -</text></view>
  53. <rich-text class="detail-centent" :nodes="list.content"></rich-text>
  54. </view>
  55. </view>
  56. <!-- 课程目录 -->
  57. <view class="course-catalogue" v-if="tabCurrentIndex == 1"><view class="no-data" v-if="courseList == ''">暂无数据</view></view>
  58. <view class="course-catalogue" v-if="tabCurrentIndex == 1">
  59. <view class="course-menu flex_item" v-for="(ls, index) in courseList" :key="index" @click="ToCourseDetail(ls)">
  60. <image :src="ls.image"></image>
  61. <view class="menu-info">
  62. <view class="title">{{ ls.title }}</view>
  63. <view class="tip"><text>直播回放</text></view>
  64. </view>
  65. </view>
  66. </view>
  67. <!-- 支付弹窗 -->
  68. <uni-popup ref="popup" type="bottom">
  69. <view class="payment">
  70. <view class="first flex " @click="payclose()">
  71. <text class="word">选择支付方式</text>
  72. <image src="../../static/img/img25.png"></image>
  73. </view>
  74. <view class="pay-type-list">
  75. <view class="type-item b-b" @click="changePayType('weixin')">
  76. <view class="img"><image class="yue" src="../../static/img/img26.png"></image></view>
  77. <view class="con"><text class="tit">微信支付</text></view>
  78. <label class="radio"><radio value="" color="#FC4141" :checked="payType == 'weixin'"></radio></label>
  79. </view>
  80. <view class="type-item flex_item" @click="changePayType('yue')">
  81. <view class="img"><image class="yue" src="../../static/img/img017.png"></image></view>
  82. <view class="con"><text class="tit">余额支付</text></view>
  83. <label class="radio"><radio value="" color="#FC4141" :checked="payType == 'yue'"></radio></label>
  84. </view>
  85. </view>
  86. <view class="one"></view>
  87. <view class="Third flex">
  88. <view class="two1">
  89. <text class="two1-1 ">合计:</text>
  90. <text class="two1-2">¥</text>
  91. <text class="two1-2 size">{{ list.money }}</text>
  92. </view>
  93. <view class="two2" :class="{ clickbg: payLoding }" @click.stop="!payLoding ? confirm() : ''"><text>立即支付</text></view>
  94. </view>
  95. </view>
  96. </uni-popup>
  97. <view class="foot-box flex" v-show='showPay'>
  98. <view class="home" @click="ToHome">
  99. <image src="../../static/img/img028.png"></image>
  100. <view>首页</view>
  101. </view>
  102. <view class="Topay" @click="ToCourseDetail(ls)">进入直播间</view>
  103. </view>
  104. </view>
  105. </template>
  106. <script>
  107. import { details, collect,create_order } from '@/api/course.js';
  108. // #ifdef H5
  109. import weixinObj from '@/libs/jweixin-module/index.js';
  110. // #endif
  111. export default {
  112. data() {
  113. return {
  114. tabCurrentIndex: 0,
  115. id: '', //直播详情id
  116. swiperlist: '', //轮播图
  117. swiperCurrent: 0, //轮播图
  118. swiperHeight: 300,
  119. list: '', //详情数据
  120. navList: [
  121. {
  122. state: 0,
  123. text: '直播介绍'
  124. }
  125. // {
  126. // state: 1,
  127. // text: '回放目录'
  128. // }
  129. ],
  130. live_id: '' ,//直播间id
  131. showPay:true,
  132. payType: 'weixin', //支付类型
  133. payLoding: false, //判断是否支付中
  134. // #ifdef H5
  135. froms: '', //当前是否为微信浏览器
  136. // #endif
  137. type: '' //判断是否从订单中进入
  138. };
  139. },
  140. onLoad(option) {
  141. let obj = this;
  142. obj.id = option.id;
  143. if (option.type == 'free') {
  144. uni.showModal({
  145. title: '提示',
  146. content: '请付费观看直播',
  147. success: function(res) {
  148. if (res.confirm) {
  149. obj.OpenPay();
  150. } else if (res.cancel) {
  151. uni.switchTab({
  152. url: '/pages/index/index'
  153. });
  154. }
  155. }
  156. });
  157. }
  158. obj.loadData();
  159. // this.course();
  160. },
  161. methods: {
  162. //加载专题详情
  163. loadData() {
  164. let obj = this;
  165. details({
  166. id: obj.id
  167. })
  168. .then(data => {
  169. obj.swiperlist = data.data.special.swiperlist;
  170. obj.live_id = data.data.liveInfo.id;
  171. obj.list = data.data.special.special;
  172. })
  173. .catch(e => {
  174. console.log(e.message);
  175. });
  176. },
  177. //打开支付弹窗
  178. OpenPay() {
  179. this.showPay = false;
  180. this.$refs.popup.open();
  181. },
  182. //关闭支付弹窗
  183. payclose() {
  184. this.showPay = true;
  185. this.$refs.popup.close();
  186. },
  187. //选择支付方式
  188. changePayType(type) {
  189. this.payType = type;
  190. console.log(this.payType);
  191. },
  192. //确认支付
  193. confirm: async function() {
  194. let obj = this;
  195. // 支付中
  196. obj.payLoding = true;
  197. // #ifdef H5
  198. // 获取当前是否为微信浏览器
  199. obj.froms = uni.getStorageSync('weichatBrowser') || '';
  200. // #endif
  201. obj.CreateOrder();
  202. },
  203. //订单创建
  204. CreateOrder() {
  205. let obj = this;
  206. // 生成订单
  207. create_order({
  208. special_id: obj.id,
  209. pay_type_num: 2,
  210. payType: obj.payType ,//支付类型
  211. total_num:1,
  212. })
  213. .then(data => {
  214. // 判断是否为余额支付
  215. if (obj.payType == 'yue') {
  216. if (data.code == 200) {
  217. if (data.msg == '余额支付成功') {
  218. obj.$api.msg('购买成功!');
  219. }
  220. obj.payclose();
  221. obj.loadData();
  222. } else {
  223. obj.payLoding = false;
  224. obj.$api.msg(msg);
  225. }
  226. }
  227. // #ifdef H5
  228. if (obj.payType == 'weixin') {
  229. console.log(data,'data')
  230. let config = data.data.jsConfig;
  231. console.log(config, 'config');
  232. weixinObj.chooseWXPay({
  233. timestamp: config.timestamp,
  234. nonceStr: config.nonceStr,
  235. package: config.package,
  236. signType: config.signType,
  237. paySign: config.paySign,
  238. success: function(res) {
  239. obj.loadData();
  240. obj.payclose();
  241. },
  242. fail: function(res) {
  243. obj.payLoding = false;
  244. console.log(res, '失败');
  245. console.log(res.errMsg);
  246. }
  247. });
  248. }
  249. // #endif
  250. })
  251. .catch(e => {
  252. console.log(e.message);
  253. obj.payLoding = false;
  254. if (e.message == '该订单已支付!') {
  255. // obj.paySuccessTo();
  256. }
  257. });
  258. },
  259. //专题收藏或者取消收藏
  260. collect() {
  261. let obj = this;
  262. collect({
  263. id: obj.id
  264. })
  265. .then(data => {
  266. obj.loadData();
  267. })
  268. .catch(e => {
  269. console.log(e.message);
  270. });
  271. },
  272. //课程目录列表
  273. course() {
  274. let obj = this;
  275. // course({
  276. // special_id: obj.id,
  277. // limit: 10,
  278. // page: 1
  279. // })
  280. // .then(data => {
  281. // this.courseList = data.data.list;
  282. // })
  283. // .catch(e => {
  284. // console.log(e.message);
  285. // });
  286. },
  287. //课程详情
  288. ToCourseDetail(ls) {
  289. let obj = this;
  290. uni.navigateTo({
  291. url: '/pages/live/broadcast?live_id=' + obj.live_id + '&special_id=' + obj.id
  292. });
  293. },
  294. //轮播图
  295. swiperChange(e) {
  296. const index = e.detail.current;
  297. this.swiperCurrent = index;
  298. },
  299. //顶部tab点击
  300. tabClick(index) {
  301. this.tabCurrentIndex = index;
  302. },
  303. //返回首页
  304. ToHome() {
  305. uni.switchTab({
  306. url: '/pages/index/index'
  307. });
  308. },
  309. navTo(url) {
  310. uni.navigateTo({
  311. url
  312. });
  313. }
  314. }
  315. };
  316. </script>
  317. <style lang="scss">
  318. .container {
  319. }
  320. //轮播图
  321. .swiper {
  322. width: 100%;
  323. background-color: #ffffff;
  324. .swiper-box {
  325. width: 100%;
  326. height: 500rpx;
  327. overflow: hidden;
  328. // box-shadow: 0upx 8upx 25upx rgba(0, 0, 0, 0.2);
  329. //兼容ios,微信小程序
  330. position: relative;
  331. z-index: 1;
  332. swiper {
  333. width: 100%;
  334. height: 500rpx;
  335. swiper-item {
  336. image {
  337. width: 100%;
  338. height: 500rpx;
  339. }
  340. }
  341. }
  342. .indicator {
  343. position: absolute;
  344. bottom: 20upx;
  345. left: 20upx;
  346. background-color: rgba(255, 255, 255, 0.4);
  347. width: 150upx;
  348. height: 5upx;
  349. border-radius: 3upx;
  350. overflow: hidden;
  351. display: flex;
  352. .dots {
  353. width: 0upx;
  354. background-color: rgba(255, 255, 255, 1);
  355. transition: all 0.3s ease-out;
  356. &.on {
  357. width: (100%/3);
  358. }
  359. }
  360. }
  361. }
  362. }
  363. .swiper-name {
  364. width: 100%;
  365. padding: 35rpx 30rpx;
  366. .item-box {
  367. position: relative;
  368. .item-name {
  369. position: relative;
  370. top: 0rpx;
  371. font-size: 36rpx;
  372. width: 90%;
  373. }
  374. .item-collection {
  375. text-align: center;
  376. position: absolute;
  377. top: 0rpx;
  378. right: 0;
  379. image {
  380. width: 55rpx;
  381. height: 50rpx;
  382. }
  383. .collection {
  384. font-size: 26rpx;
  385. color: #999999;
  386. }
  387. }
  388. }
  389. .tip-box {
  390. padding: 15rpx 0rpx;
  391. text {
  392. background-color: #e3e9fe;
  393. color: #6786fb;
  394. font-size: 22rpx;
  395. padding: 8rpx 15rpx;
  396. border-radius: 10rpx;
  397. margin-right: 15rpx;
  398. }
  399. }
  400. .price-box {
  401. font-size: 26rpx;
  402. color: #999999;
  403. .price {
  404. color: #e73932;
  405. text {
  406. font-size: 35rpx;
  407. font-weight: bold;
  408. }
  409. }
  410. }
  411. }
  412. //视频
  413. .top {
  414. width: 100%;
  415. height: 500rpx;
  416. .course-video {
  417. width: 100%;
  418. height: 100%;
  419. }
  420. }
  421. .navbar {
  422. display: flex;
  423. height: 40px;
  424. padding: 0 5px;
  425. background: #fff;
  426. box-shadow: 0 1px 5px rgba(0, 0, 0, 0.06);
  427. position: relative;
  428. z-index: 10;
  429. .nav-item {
  430. flex: 1;
  431. display: flex;
  432. justify-content: center;
  433. align-items: center;
  434. height: 100%;
  435. font-size: 30rpx;
  436. color: $font-color-dark;
  437. position: relative;
  438. &.current {
  439. color: $base-color;
  440. }
  441. }
  442. }
  443. // 详情
  444. .course-details {
  445. padding: 20rpx;
  446. .top {
  447. width: 100%;
  448. height: 500rpx;
  449. .course-video {
  450. width: 100%;
  451. height: 100%;
  452. }
  453. }
  454. .details-intro {
  455. padding: 40rpx 20rpx;
  456. background: #ffffff;
  457. border-radius: 10rpx;
  458. margin-top: 20rpx;
  459. margin-bottom: 120rpx;
  460. .intro-title {
  461. width: 100%;
  462. font-size: 28rpx;
  463. font-weight: bold;
  464. color: $font-color;
  465. text-align: center;
  466. margin-bottom: 40rpx;
  467. }
  468. .intro-text {
  469. color: #5dcafa;
  470. font-size: $font-base;
  471. line-height: 40rpx;
  472. }
  473. .intro-img {
  474. width: 100%;
  475. height: 400rpx;
  476. margin-top: 40rpx;
  477. .img {
  478. width: 100%;
  479. height: 100%;
  480. }
  481. }
  482. }
  483. }
  484. // 课程目录
  485. .course-catalogue {
  486. padding: 20rpx;
  487. .no-data {
  488. width: 100%;
  489. text-align: center;
  490. font-size: 26rpx;
  491. }
  492. .course-menu {
  493. background: #ffffff;
  494. border-bottom: 1px solid #f0f0f0;
  495. padding: 20rpx;
  496. display: flex;
  497. align-items: center;
  498. font-size: 24rpx;
  499. image {
  500. width: 250rpx;
  501. height: 135rpx;
  502. border-radius: 15rpx;
  503. }
  504. .menu-info {
  505. padding-left: 25rpx;
  506. color: #333333;
  507. .title {
  508. font-size: 28rpx;
  509. }
  510. .tip {
  511. margin: 15rpx 0rpx;
  512. text {
  513. padding: 5rpx 10rpx;
  514. background-color: rgba(43, 121, 245, 0.18);
  515. color: #6786fb;
  516. }
  517. }
  518. .price {
  519. color: #e73932;
  520. }
  521. .red {
  522. color: #6786fb !important;
  523. }
  524. .free {
  525. background: rgba(253, 248, 234, 1);
  526. border-radius: 19px;
  527. color: rgba(241, 174, 39, 1);
  528. padding: 2rpx 10rpx;
  529. }
  530. }
  531. }
  532. }
  533. .foot-box {
  534. position: fixed;
  535. bottom: 0;
  536. width: 100%;
  537. background-color: #ffffff;
  538. padding: 0rpx 35rpx;
  539. font-size: 22rpx;
  540. color: #333333;
  541. z-index: 999;
  542. .home {
  543. width: 15%;
  544. text-align: center;
  545. image {
  546. width: 35rpx;
  547. height: 38rpx;
  548. }
  549. }
  550. .Topay {
  551. width: 80%;
  552. background-color: #6786fb;
  553. text-align: center;
  554. color: #ffffff;
  555. padding: 25rpx 0rpx;
  556. margin: 15rpx 0rpx;
  557. border-radius: 45rpx;
  558. }
  559. }
  560. //支付弹窗
  561. .pay-type-list {
  562. margin-top: 20upx;
  563. background-color: #fff;
  564. padding-left: 40upx;
  565. .type-item {
  566. height: 120upx;
  567. padding: 20upx 0;
  568. display: flex;
  569. justify-content: space-between;
  570. align-items: center;
  571. padding-right: 60upx;
  572. font-size: 30upx;
  573. position: relative;
  574. }
  575. .icon {
  576. width: 100upx;
  577. font-size: 52upx;
  578. }
  579. .img {
  580. color: #fe8e2e;
  581. width: 50rpx;
  582. height: 50rpx;
  583. image {
  584. width: 100%;
  585. height: 100%;
  586. }
  587. }
  588. .tit {
  589. font-size: $font-lg;
  590. color: $font-color-dark;
  591. margin-bottom: 4upx;
  592. }
  593. .con {
  594. flex: 1;
  595. display: flex;
  596. flex-direction: column;
  597. padding-left: 25rpx;
  598. font-size: $font-sm;
  599. color: $font-color-light;
  600. }
  601. }
  602. .payment {
  603. background-color: #ffffff;
  604. border-radius: 15rpx 15rpx 0rpx 0rpx;
  605. z-index: 999;
  606. .first {
  607. border-bottom: 2rpx solid $border-color-light;
  608. padding: 38rpx 25rpx;
  609. .word {
  610. font-size: $uni-font-size-base;
  611. font-weight: bold;
  612. color: $font-color-dark;
  613. }
  614. image {
  615. width: 25rpx;
  616. height: 25rpx;
  617. }
  618. }
  619. .one {
  620. height: 20rpx;
  621. background-color: #f6f6f6;
  622. }
  623. .Third {
  624. .two1 {
  625. width: 55%;
  626. background-color: #ffffff;
  627. padding-left: 25rpx;
  628. .two1-1 {
  629. font-size: $uni-font-size-base;
  630. font-weight: 400;
  631. color: $font-color-dark;
  632. }
  633. .two1-2 {
  634. font-size: $uni-font-size-sm;
  635. font-weight: bold;
  636. color: $color-red1;
  637. }
  638. .size {
  639. font-size: $uni-font-size-lg + 4rpx;
  640. }
  641. }
  642. .two2 {
  643. width: 45%;
  644. background: $color-red1;
  645. color: #ffffff;
  646. font-size: $uni-font-size-lg;
  647. font-weight: 550;
  648. text-align: center;
  649. padding: 30rpx 0rpx;
  650. }
  651. .clickbg {
  652. background-color: $color-gray !important;
  653. }
  654. }
  655. }
  656. </style>