index.vue 11 KB

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