index.vue 11 KB

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