index.vue 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502
  1. <template>
  2. <view>
  3. <nav-bar title="模考讲解直播" class="nav"></nav-bar>
  4. <view class="tabs">
  5. <view class="tab" :class="{ active: index == 2 }" data-index="2">
  6. <view class="dateRange">
  7. <picker mode="date" :value="param.startTime" :end="endDate" @change="bindDateFromChange">
  8. <view class="uni-input">{{param.startTime || '开始时间'}}</view>
  9. </picker>
  10. -
  11. <picker mode="date" :value="param.endTime" :end="endDate" @change="bindDateToChange">
  12. <view class="uni-input">{{param.endTime || '结束时间'}}</view>
  13. </picker>
  14. </view>
  15. <u-icon class="icon" name="calendar"></u-icon>
  16. </view>
  17. <view class="tab" :class="{ active: index == 1 }" data-index="1">
  18. <view class="dateRange">
  19. <picker class="picker" mode="selector" :range="listApplyName" range-key="applyName" :value="param.applyName" @change="bindTitleChange">
  20. <view style="width:300rpx;height:40rpx;">{{param.applyName}}</view>
  21. </picker>
  22. </view>
  23. <u-icon class="icon" :class="index ==1? 'animals':''" name="arrow-down"></u-icon>
  24. </view>
  25. </view>
  26. <view class="record">
  27. <view class="item" v-for="(item,index) in liveList" :key="index" @click="goLive(item)">
  28. <view class="item__header">
  29. <view class="note" :class="{blue:item.liveStatus == 1,green:item.liveStatus == 2,gray:item.liveStatus == 3}">
  30. <image v-if="item.liveStatus == 0" src="../static/living.png" mode="widthFix"></image>
  31. <image v-if="item.liveStatus == 1" src="../static/noliving.png" mode="widthFix"></image>
  32. <image v-if="item.liveStatus == 2" src="../static/playback.png" mode="widthFix"></image>
  33. {{item.liveStatus == 0? '直播中' : ''}}
  34. {{item.liveStatus == 1? '未开播' :''}}
  35. {{item.liveStatus == 2? '回放中' :''}}
  36. {{item.liveStatus == 3? '已结束' :''}}
  37. </view>
  38. <image class="img" src="/pages5/static/questionBank.png" ></image>
  39. </view>
  40. <view class="item__body">
  41. <view class="title">
  42. {{item.sectionName}}
  43. </view>
  44. <view class="desc">直播时间</view>
  45. <view class="desc">{{$method.timestampToTime(item.liveStartTime,false)}} - {{$method.timestampToTime(item.liveEndTime,false)}} </view>
  46. </view>
  47. </view>
  48. </view>
  49. <view class="modal" :style="{top:modalTop+'px'}" v-if="index == 1">
  50. <view class="content">
  51. <scroll-view scroll-y="true" style="height:100%">
  52. <view class="top" :class="activeIndex === 0 ? 'activesty' : ''" @click="testClick(3)">全部</view>
  53. <view class="list">
  54. <view class="item" :class="activeIndex == listItem.goodsId ? 'activesty' : ''" v-for="(listItem,listIndex) in list" :key="listIndex" @click="testClick(listItem)">
  55. {{ listItem.goodsName }}
  56. </view>
  57. </view>
  58. </scroll-view>
  59. </view>
  60. <view class="modal_wrap" @click="index = 0"></view>
  61. </view>
  62. <view class="notice_modal" :style="{top:modalTop+'px'}" v-if="index == 2">
  63. <view class="content">
  64. <scroll-view scroll-y="true" style="height:100%">
  65. <view class="top" :class="typeIndex === 0 ? 'activesty' : ''" @click="paperClick(3)">全部试卷类型</view>
  66. <view class="list">
  67. <view class="item" :class="typeIndex == listItem.paperId ? 'activesty' : ''" v-for="(listItem,listIndex) in list1" :key="listIndex" @click="paperClick(listItem)">{{ listItem.paperName }}</view>
  68. </view>
  69. </scroll-view>
  70. </view>
  71. <view class="modal_wrap" @click="index = 0"></view>
  72. </view>
  73. </view>
  74. </template>
  75. <script>
  76. import { mapGetters } from 'vuex';
  77. export default {
  78. data() {
  79. return {
  80. openAppoint:false,
  81. appointModal:false,
  82. noticeModal:false,
  83. index: 0,
  84. liveList:[],
  85. list: [],
  86. list1: [],
  87. recordList: [],
  88. listApplyName:[],
  89. goodsData: {},
  90. param: {
  91. pageNum: 1,
  92. pageSize: 10,
  93. startTime:'',
  94. endTime:'',
  95. applyName:'',
  96. },
  97. isRepeat:false,
  98. total: 0,
  99. activeIndex: 0,
  100. typeIndex:0,
  101. itemIndex:'',
  102. modalTop:0,
  103. endDate:'',
  104. };
  105. },
  106. computed: { ...mapGetters(['userInfo','config']) },
  107. onLoad(option) {
  108. this.endDate = this.$method.timestampToTime(new Date().getTime() / 1000).replace(/-/g,'/');
  109. this.mockApplyListMockLive();
  110. uni.getSystemInfo({
  111. success:(e) => {
  112. let info = uni.createSelectorQuery().select(".nav");
  113. info.boundingClientRect((navData) => { //data - 各种参数
  114. let info = uni.createSelectorQuery().select(".tabs");
  115. info.boundingClientRect((tabData) => { //data - 各种参数
  116. this.modalTop = navData.height + tabData.height
  117. console.log(navData) // 获取元素宽度
  118. console.log(tabData) // 获取元素宽度
  119. }).exec()
  120. }).exec()
  121. }
  122. })
  123. },
  124. onPullDownRefresh() {
  125. let that = this;
  126. this.liveList = [];
  127. this.param = {
  128. pageNum: 1,
  129. pageSize: 10
  130. };
  131. this.mockApplyListMockLive();
  132. setTimeout(function() {
  133. uni.stopPullDownRefresh();
  134. }, 500);
  135. },
  136. onReachBottom() {
  137. if (this.liveList.length < this.total) {
  138. this.param.pageNum++;
  139. this.mockApplyListMockLive();
  140. }
  141. },
  142. onShow() {
  143. },
  144. methods: {
  145. goLive(item) {
  146. if(item.liveStatus == 0) { //直播中
  147. let uuid = new Date().valueOf() + ""
  148. // buyCourse 是否购买课程:1是 0否
  149. let encode = encodeURIComponent(this.config.hostLive+'/pages/live/index?token='+uni.getStorageSync('token')+'&userInfo='+JSON.stringify(this.userInfo)+
  150. '&channelId='+item.liveUrl+'&buyCourse=1'+'&ident='+uuid)
  151. uni.navigateTo({
  152. url:`/pages5/webview/index?url=`+encode
  153. })
  154. } else if(item.liveStatus == 1) { //未开播
  155. uni.showToast({
  156. icon:'none',
  157. title:'暂未开播,请在开播后查看'
  158. })
  159. } else if(item.liveStatus == 2) { //回放中
  160. uni.navigateTo({
  161. url:'/pages3/live/playback?vid='+item.recordingUrl
  162. })
  163. } else if(item.liveStatus == 3) { //已结束
  164. uni.showToast({
  165. icon:'none',
  166. title:'直播已结束,不能查看回放'
  167. })
  168. }
  169. },
  170. mockApplyListMockLive() {
  171. let param = JSON.parse(JSON.stringify(this.param))
  172. if(param.endTime) {
  173. param.endTime = this.$method.TimeTotimestamp(param.endTime)
  174. }
  175. if(param.startTime) {
  176. param.startTime = this.$method.TimeTotimestamp(param.startTime)
  177. }
  178. this.$api.mockApplyListMockLive(param).then(res => {
  179. this.liveList.push(...res.data.rows)
  180. this.total = res.data.total;
  181. })
  182. },
  183. refreshByIndex() {
  184. this.$api.examRecordGroupList({
  185. pageNum: this.itemIndex+1,
  186. pageSize: 1
  187. }).then(res => {
  188. this.$set(this.recordList,this.itemIndex,res.data.rows[0])
  189. this.itemIndex = ''
  190. });
  191. },
  192. appoint(item) {
  193. this.appointModal = true;
  194. },
  195. tab(index) {
  196. if(this.index == index) {
  197. this.index = 0;
  198. return;
  199. }
  200. this.index = index;
  201. },
  202. mockApplyListApplyName() {
  203. let param = JSON.parse(JSON.stringify(this.param));
  204. if(param.endTime) {
  205. param.endTime = this.$method.TimeTotimestamp(param.endTime)
  206. }
  207. if(param.startTime) {
  208. param.startTime = this.$method.TimeTotimestamp(param.startTime)
  209. }
  210. this.$api.mockApplyListApplyName(param).then((res) => {
  211. this.listApplyName = res.data.rows;
  212. this.param.applyName = "";
  213. this.mockApplyListMockLive();
  214. });
  215. },
  216. bindDateFromChange(e) {
  217. this.param.startTime = e.detail.value
  218. this.param.pageNum = 1;
  219. this.param.applyName = '';
  220. this.liveList = []
  221. this.mockApplyListApplyName();
  222. },
  223. bindDateToChange(e) {
  224. this.param.endTime = e.detail.value
  225. this.param.pageNum = 1;
  226. this.param.applyName = '';
  227. this.liveList = []
  228. this.mockApplyListApplyName();
  229. },
  230. bindTitleChange(e) {
  231. if (this.listApplyName.length) {
  232. let index = e.detail.value;
  233. this.param.applyName = this.listApplyName[index].applyName
  234. } else {
  235. this.param.applyName =''
  236. }
  237. this.param.pageNum = 1;
  238. this.liveList = []
  239. this.mockApplyListMockLive();
  240. }
  241. }
  242. };
  243. </script>
  244. <style>
  245. page {
  246. background: #eaeef1;
  247. }
  248. </style>
  249. <style lang="scss" scope>
  250. .animals{
  251. transition: all 0.3s;
  252. transform: rotate(180deg);
  253. }
  254. .tabs {
  255. position: fixed;
  256. padding:18rpx 0;
  257. left: 0;
  258. width: 100%;
  259. display: flex;
  260. z-index: 10;
  261. background: #ffffff;
  262. .tab {
  263. padding:0 18rpx;
  264. flex: 1;
  265. display: flex;
  266. align-items: center;
  267. justify-content: space-between;
  268. background: #ffffff;
  269. font-size: 24rpx;
  270. color: #999999;
  271. &:nth-of-type(1) {
  272. border-right:1px solid #EEEEEE;
  273. }
  274. .picker {
  275. width:100%;
  276. display: flex;
  277. align-items: center;
  278. }
  279. .dateRange {
  280. width:100%;
  281. display: flex;
  282. justify-content: space-between;
  283. }
  284. &.active {
  285. color: #333333;
  286. .icon{
  287. transform: rotate(180deg);
  288. }
  289. }
  290. }
  291. }
  292. .record {
  293. margin-top:80rpx;
  294. padding: 16rpx 16rpx;
  295. display: flex;
  296. flex-wrap: wrap;
  297. .item {
  298. margin-bottom: 16rpx;
  299. width:351rpx;
  300. background: #ffffff;
  301. border-radius: 16rpx;
  302. position: relative;
  303. &:nth-of-type(2n) {
  304. margin-left:16rpx;
  305. }
  306. &__header {
  307. width: 100%;
  308. height: 170rpx;
  309. position:relative;
  310. .note {
  311. position:absolute;
  312. left:0;
  313. top:0;
  314. width: 136rpx;
  315. height: 40rpx;
  316. background: linear-gradient(90deg, #B37FEB, #722ED1);
  317. box-shadow: 3rpx 3rpx 6rpx 0rpx rgba(239, 219, 255, 0.6);
  318. border-radius: 16rpx 0rpx 8rpx 0rpx;
  319. text-align: center;
  320. color:#fff;
  321. &.blue {
  322. background: linear-gradient(90deg, #40A9FF, #096DD9);
  323. }
  324. &.green {
  325. background: linear-gradient(90deg, #24F2C1, #00B9A0);
  326. }
  327. &.gray {
  328. background: linear-gradient(90deg, #BFBFBF, #8C8C8C);
  329. }
  330. image {
  331. width:24rpx;
  332. vertical-align: middle;
  333. }
  334. }
  335. .img {
  336. width:100%;
  337. height:100%;
  338. }
  339. }
  340. &__body {
  341. padding:16rpx;
  342. .title {
  343. font-size: 30rpx;
  344. color: #333333;
  345. line-height: 48rpx;
  346. font-weight: bold;
  347. }
  348. .desc {
  349. margin-top:10rpx;
  350. font-size: 24rpx;
  351. color: #666666;
  352. line-height: 36rpx;
  353. }
  354. .btn {
  355. margin-top:30rpx;
  356. background: #FFFFFF;
  357. border-radius: 16rpx;
  358. height: 64rpx;
  359. line-height: 62rpx;
  360. text-align: center;
  361. font-size: 28rpx;
  362. border: 1px solid #D9D9D9;
  363. color:#D9D9D9;
  364. &.active {
  365. border: 1px solid #007AFF;
  366. color:#007AFF;
  367. }
  368. }
  369. }
  370. }
  371. }
  372. .notice {
  373. position:fixed;
  374. right:0;
  375. top:50%;
  376. width: 48rpx;
  377. height: 200rpx;
  378. background: #52C41A;
  379. box-shadow: 0px 3rpx 16rpx 0rpx rgba(44, 121, 7, 0.5);
  380. border-radius: 24rpx;
  381. display: flex;
  382. flex-direction: column;
  383. align-items: center;
  384. justify-content: center;
  385. padding:10rpx 0;
  386. .text {
  387. flex:1;
  388. color:#fff;
  389. text-align: center;
  390. }
  391. }
  392. .modal {
  393. bottom:0;
  394. z-index: 199999999;
  395. position: fixed;
  396. left: 0;
  397. width: 100%;
  398. .content {
  399. height:80%;
  400. overflow: hidden;
  401. position: relative;
  402. z-index: 10;
  403. background: #fff;
  404. padding: 8rpx 12rpx 20rpx;
  405. display: flex;
  406. flex-wrap: wrap;
  407. .top {
  408. margin: 0 auto;
  409. width: 726rpx;
  410. height: 80rpx;
  411. background: #f5f5f5;
  412. color: #666666;
  413. border-radius: 16rpx;
  414. text-align: center;
  415. line-height: 80rpx;
  416. font-size: 32rpx;
  417. }
  418. .list {
  419. width:100%;
  420. margin-top: 16rpx;
  421. display: flex;
  422. flex-wrap: wrap;
  423. justify-content: space-between;
  424. .item {
  425. padding: 25rpx 20rpx;
  426. width: 49%;
  427. background: #f5f5f5;
  428. border-radius: 16rpx;
  429. font-size: 32rpx;
  430. color: #666666;
  431. margin: 8rpx 0;
  432. }
  433. }
  434. }
  435. .modal_wrap {
  436. position: absolute;
  437. left: 0;
  438. width: 100%;
  439. top: 0;
  440. height: 100%;
  441. background: rgba(0, 0, 0, 0.3);
  442. }
  443. }
  444. .activesty {
  445. background: #007aff !important;
  446. color: #fff !important;
  447. }
  448. </style>