index.vue 11 KB

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