index.vue 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556
  1. <template>
  2. <view class="learnings">
  3. <u-navbar :is-back="false" title="学习中心" :border-bottom="false" title-color="#333333" back-icon-color="#ffffff">
  4. <view class="slot-wrap">
  5. <image src="/static/logo2.png" style="width: 178rpx;height: 31rpx;margin-left: 30rpx;"></image>
  6. </view>
  7. </u-navbar>
  8. <u-line color="#D6D6DB" />
  9. <view class="contents">
  10. <view class="diatance">
  11. <image class="clock" src="/static/learn/clock.png" mode=""></image>
  12. <text>
  13. 一级建造师,距离考试还有
  14. </text>
  15. <u-count-down :timestamp="leftDays" :show-days="true" separator="zh"
  16. :show-hours="false" :show-minutes="false" :show-seconds="false" font-size="28"
  17. bg-color="#007AFF" separator-color="#fff" color="#fff" separator-size="28">
  18. </u-count-down>
  19. </view>
  20. <!-- 有学习的课程 -->
  21. <view v-if="allCourse" class="had_courses">
  22. <!-- 直播 -->
  23. <view v-if="livingLists.length" class="lives">
  24. <view v-for="(live, l_index) in livingLists" :key="l_index" class="live_item">
  25. <view class="live_con">
  26. <view class="live_status">
  27. <image v-if="bgShow(live.liveStartTime, live.watchStatus)" src="/static/learn/living.png" class="liv_icon"></image>
  28. <image v-else src="/static/learn/wlive.png" class="liv_icon"></image>
  29. <text class="status_s">{{ live.liveStartTime | liveStatus(live.watchStatus)}}</text>
  30. <view class="look_bt"
  31. :class="{'living': lookTimeStatus(live.liveStartTime, live.watchStatus) == 1,
  32. 'futuring': lookTimeStatus(live.liveStartTime, live.watchStatus) == 4,
  33. 'curring': [2,3].includes(lookTimeStatus(live.liveStartTime, live.watchStatus))}"
  34. >
  35. <text v-if="lookTimeStatus(live.liveStartTime, live.watchStatus) == 1">点击观看</text>
  36. <text v-if="lookTimeStatus(live.liveStartTime, live.watchStatus) == 2">即将开播</text>
  37. <template v-if="lookTimeStatus(live.liveStartTime, live.watchStatus) == 3">
  38. 剩余:
  39. <u-count-down :timestamp="curTimeTamp(live.liveStartTime)" :show-days="false"
  40. color="#fff" separator-color="#fff" font-size="24" separator-size="24" bg-color="#FFB102">
  41. </u-count-down>
  42. </template>
  43. <template v-if="lookTimeStatus(live.liveStartTime, live.watchStatus) == 4">
  44. 剩余:
  45. <u-count-down :timestamp="curTimeTamp(live.liveStartTime)" :show-days="true" separator="zh"
  46. color="#fff" separator-color="#fff" bg-color="#007AFF"
  47. :show-hours="false" :show-minutes="false" :show-seconds="false" font-size="24" separator-size="24">
  48. </u-count-down>
  49. <u-count-down :timestamp="curTimeTamp(live.liveStartTime)" :show-days="false"
  50. color="#fff" separator-color="#fff" bg-color="#007AFF"
  51. font-size="24" separator-size="24">
  52. </u-count-down>
  53. </template>
  54. </view>
  55. </view>
  56. <view class="liv_time">
  57. <text class="timeR">{{ live.liveStartTime | formate('mm月dd日')}}</text>
  58. <text>{{ live.liveStartTime | formate('hh:mm')}}</text>
  59. </view>
  60. <view class="liv_title">{{ live.name }}</view>
  61. </view>
  62. <image v-if="bgShow(live.liveStartTime, live.watchStatus)" src="/static/learn/living_bg.png" class="my_bg"></image>
  63. <image v-else src="/static/learn/wlive_bg.png" class="my_bg"></image>
  64. </view>
  65. </view>
  66. <!-- 我的课程 -->
  67. <view v-if="courseLists.length" class="my_courses">
  68. <text class="titles">我的课程</text>
  69. <view v-for="(item, index) in courseLists" :key="index" class="course_item">
  70. <view class="lefts">
  71. <image class="lefet_img" :src="$method.splitImgHost(item.coverUrl, true)" mode=""></image>
  72. <view class="live_icon">直播</view>
  73. </view>
  74. <view class="rights">
  75. <view>
  76. <view class="cou_titles">{{ item.goodsName }}</view>
  77. <view v-if="item.serviceStartTime && item.serviceEndTime" class="learn_ranges">
  78. <image class="l_range" src="/static/learn/learn_range.png"></image>
  79. 学习周期:
  80. <text class="l_time">{{ item.serviceStartTime | formate('yyyy.mm.dd') }} - {{ item.serviceEndTime | formate('yyyy.mm.dd') }}</text>
  81. <!-- <text class="l_time">{{ $method.formate(item.studyStartTime,'yyyy.mm.dd') }} - {{ $method.formate(item.studyStartTime,'yyyy.mm.dd') }}</text> -->
  82. </view>
  83. </view>
  84. <view class="learn_progress">
  85. <view class="progress_up">
  86. <image src="/static/icon/wk_icon3.png" class="wk_icon"></image>
  87. 学习进度:{{ item.stuAllNum+item.recordNum }}/{{ item.secAllNum+item.examNum }}
  88. </view>
  89. <view class="progress_down">
  90. <view class="progress_bar" style="width: 50%;">
  91. <u-line-progress :showText="false" height="32" active-color="#ff9900" :show-percent="false"
  92. :percent="((item.stuAllNum+item.recordNum) / (item.secAllNum+item.examNum)) * 100"></u-line-progress>
  93. </view>
  94. <view class="enter_into" @click.stop="studyIn(item.goodsId,item.gradeId,item,index)">进入学习</view>
  95. </view>
  96. </view>
  97. </view>
  98. </view>
  99. </view>
  100. <!-- 我的题库 -->
  101. <view class="my_courses">
  102. <text class="titles">我的题库</text>
  103. <view class="bottoms">
  104. <navigator hover-class="none" url="/pages2/subject/collect">
  105. <view class="item collect">
  106. <view class="text">收藏集<u-icon name="arrow-right"></u-icon></view>
  107. <image class="img" src="/static/questionBank_collect.png"></image>
  108. </view>
  109. </navigator>
  110. <view class="item list">
  111. <navigator hover-class="none" url="/pages2/bank/question_record">
  112. <view class="list-in">
  113. <image class="img" src="/static/questionBank_record.png" ></image>
  114. <view class="text">
  115. 做题记录 <u-icon name="arrow-right"></u-icon>
  116. </view>
  117. </view>
  118. </navigator>
  119. <navigator hover-class="none" url="/pages2/subject/wrong">
  120. <view class="list-in">
  121. <image class="img" src="/static/questionBank_wrong.png"></image>
  122. <view class="text">
  123. 错题集 <u-icon name="arrow-right"></u-icon>
  124. </view>
  125. </view>
  126. </navigator>
  127. </view>
  128. </view>
  129. <template v-if="questionLists.length">
  130. <view v-for="(item, indexq) in questionLists" :key="indexq" class="course_item">
  131. <view class="lefts">
  132. <image class="lefet_img" :src="$method.splitImgHost(item.coverUrl, true)" mode=""></image>
  133. <!-- <view class="live_icon">直播</view> -->
  134. </view>
  135. <view class="rights">
  136. <view>
  137. <view class="cou_titles">{{ item.goodsName }}</view>
  138. <view v-if="item.serviceStartTime && item.serviceEndTime" class="learn_ranges">
  139. <image class="l_range" src="/static/learn/learn_range.png"></image>
  140. 学习周期:
  141. <text class="l_time">{{ item.serviceStartTime | formate('yyyy.mm.dd') }} - {{ item.serviceEndTime | formate('yyyy.mm.dd') }}</text>
  142. </view>
  143. </view>
  144. <view class="learn_progress">
  145. <view class="progress_up">
  146. <image src="/static/icon/wk_icon3.png" class="wk_icon"></image>
  147. 学习进度:{{item.doNum}}/{{item.totalNum}}
  148. </view>
  149. <view class="progress_down">
  150. <view class="progress_bar" style="width: 50%;">
  151. <u-line-progress :show-percent="false" height="32" active-color="#007AFF" :percent="(item.doNum/item.totalNum)*100"></u-line-progress>
  152. </view>
  153. <view class="enter_into" @click="studyques(item,index)">进入练习</view>
  154. </view>
  155. </view>
  156. </view>
  157. </view>
  158. </template>
  159. </view>
  160. </view>
  161. <!-- 没有学习的课程 -->
  162. <view v-if="!allLoading && !allCourse" class="no_datas">
  163. <image class="courses" src="/static/learn/no_course.png" mode=""></image>
  164. <view class="no_learns">您目前没有可学习的课程</view>
  165. <view class="choose" @click="toChoose()">立即去选购</view>
  166. </view>
  167. </view>
  168. </view>
  169. </template>
  170. <script>
  171. var curTime = new Date().getTime() // 当前时间的时间戳
  172. export default {
  173. data() {
  174. return {
  175. leftDays: 0,
  176. paramC: {
  177. pageNum: 1,
  178. pageSize: 50
  179. },
  180. activeItem: {},
  181. itemIndex: '',
  182. confirmTimer:null,
  183. confirmCount:10,
  184. confirmChecked:false,
  185. showUserConfirmInfo:false,
  186. selectItem: {},
  187. selectClassModal: false,
  188. gradeList: [],
  189. gradeValue: -1,
  190. sysTime: 0,
  191. courseLists: [],
  192. questionLists: [], // 题库
  193. paramQ: {
  194. pageNum: 1,
  195. pageSize: 50
  196. },
  197. queitemIndex:'',
  198. livingLists: [],
  199. allLoading: false, // 加载样式
  200. }
  201. },
  202. filters: {
  203. liveStatus(liveTime, watchStatus) {
  204. // let curTime = new Date().getTime() // 当前时间的时间戳
  205. let value = liveTime * 1000
  206. if (curTime < value) { // 判断当前时间和直播开始时间
  207. return ' 未开播'
  208. } else {
  209. return watchStatus == 'live' ? '正在直播中' : '即将开播'
  210. }
  211. }
  212. },
  213. computed: {
  214. allCourse() {
  215. return this.courseLists.length || this.gradeList.length || this.livingLists.length ? true : false
  216. }
  217. },
  218. onLoad() {
  219. console.log('dsfdsf2222222222')
  220. // 1668787200 ,2022.22.19的时间戳
  221. this.leftDays = 1668787200 - parseInt(curTime/1000)
  222. this.getCourseLiveQues()
  223. },
  224. async onShow() {
  225. await this.commonSystemTime()
  226. this.sysTime = +this.$method.timest()
  227. console.log('this.sysTime', this.sysTime)
  228. },
  229. methods: {
  230. bgShow(liveTime, watchStatus) {
  231. // let curTime = new Date().getTime() // 当前时间的时间戳
  232. let value = liveTime * 1000
  233. if (curTime > value) { // 判断当前时间和直播开始时间
  234. return watchStatus == 'live' ? true : false
  235. }
  236. },
  237. lookTimeStatus(liveTime, watchStatus) {
  238. // let curTime = new Date().getTime() // 当前时间的时间戳
  239. let value = liveTime * 1000
  240. var Y = value.getFullYear()
  241. var M = value.getMonth() + 1 < 10 ? '0' + (value.getMonth() + 1) : value.getMonth() + 1
  242. var D = value.getDate() < 10 ? '0' + value.getDate() : value.getDate()
  243. var valZ = Y + '/' + M + '/' + D
  244. let curZeroTime = new Date(valZ).getTime() // 获取开始直播时间当天的零点时间戳
  245. if (curTime > value) { // 判断当前时间和直播开始时间
  246. if (watchStatus == 'live') { //
  247. return 1
  248. } else {
  249. return 2
  250. }
  251. } else {
  252. if (curZeroTime <= curTime && curTime <= value) { //当天
  253. return 3
  254. } else {
  255. return 4
  256. }
  257. }
  258. },
  259. curTimeTamp(liveTime) {
  260. let min = liveTime - parseInt(curTime / 1000)
  261. return min
  262. },
  263. toChoose() {
  264. uni.switchTab({
  265. url:'/pages/course/index'
  266. })
  267. },
  268. // 查询直播课
  269. getCourseLiveQues() {
  270. this.allLoading = true
  271. let arrs = [
  272. this.$api.courseGoodsList(this.paramC), // 查询用户拥有的商品/课程列表/course/goodsList
  273. this.$api.listGoodsUserQuestion(this.paramQ), // 题库列表
  274. this.$api.getgoodsLiveList({
  275. pageNum: 1,
  276. pageSize: 3 // 默认3条
  277. })
  278. ]
  279. Promise.all(arrs).then((res) => {
  280. // if (res.data.code == 200) {
  281. console.log('ewds========', res)
  282. const [{ data: res1}, { data: res2}, {data: res3}] = res
  283. if (res1.code == 200) {
  284. this.courseLists = res1.rows || []
  285. }
  286. if (res2.code == 200) {
  287. this.questionLists = res2.rows || []
  288. }
  289. if (res3.code == 200) {
  290. this.livingLists = res3.rows || []
  291. }
  292. this.allLoading = false
  293. console.log('this.courseLists;', this.courseLists, this.questionLists,this.livingLists)
  294. // }
  295. }).catch(err => {
  296. this.allLoading = false
  297. // this.$u.toast('请重新刷新请求')
  298. })
  299. },
  300. // 查询用户拥有的商品/课程列表/course/goodsList
  301. getcourseList() {
  302. this.$api.courseGoodsList(this.paramC).then(res => {
  303. if (res.data.code == 200) {
  304. this.courseLists = res.data.rows || []
  305. }
  306. })
  307. },
  308. // 题库列表
  309. getlistQuestion() {
  310. this.$api.listGoodsUserQuestion(this.paramQ).then(res => {
  311. if (res.data.code == 200) {
  312. this.questionLists = res.data.rows || []
  313. }
  314. })
  315. },
  316. commonSystemTime() {
  317. return new Promise(resolve => {
  318. this.$api.commonSystemTime().then(res => {
  319. this.sysTime = res.data.data;
  320. })
  321. })
  322. },
  323. async studyIn(v, i, item, index) {
  324. console.log('item', item)
  325. this.activeItem = item
  326. if (item.interfaceAccountId > 0) { //学习账号已开通
  327. if (item.learnStatus == 1) { //跳转第三方h5
  328. uni.navigateTo({
  329. url: `/pages3/polyv/detail?goodsId=${item.goodsId}&orderGoodsId=${item.orderGoodsId}&isOther=1`
  330. })
  331. return;
  332. } else {
  333. uni.showModal({
  334. showCancel: false,
  335. content: '您的学习账号未开通,请稍后再尝试,有疑问,请联系020-87085982!'
  336. });
  337. return;
  338. }
  339. return;
  340. }
  341. if (item.serviceStartTime && (this.sysTime <= item.serviceStartTime || this.sysTime >= item.serviceEndTime)) {
  342. uni.showToast({
  343. icon: 'none',
  344. title: '不在学习服务期,不能进入学习'
  345. })
  346. return;
  347. }
  348. if ((item.classStartTime && this.sysTime <= item.classStartTime) || (item.classEndTime && this
  349. .sysTime >= item.classEndTime)) {
  350. uni.showToast({
  351. icon: 'none',
  352. title: '不在班级有效期,不能进入学习'
  353. })
  354. return
  355. }
  356. if (item.learningStatus == 2) {
  357. uni.showToast({
  358. icon: 'none',
  359. title: '开放学习时间待定,不能进入学习'
  360. })
  361. return
  362. }
  363. if (item.classStatus == 0) {
  364. uni.showToast({
  365. icon: 'none',
  366. title: '尚未开班,不能进入学习'
  367. })
  368. return
  369. }
  370. console.log(this.sysTime, item.learningTimeStart)
  371. console.log(this.sysTime < item.learningTimeStart)
  372. if (item.learningStatus == 3 && (this.sysTime < item.learningTimeStart)) {
  373. uni.showToast({
  374. icon: 'none',
  375. title: '不在开放学习时间,不能进入学习'
  376. })
  377. return;
  378. }
  379. // /course/goodsRebuildStatus查询用户商品重修状态
  380. let rebuildStatus = await this.courseGoodsRebuildStatus(item.goodsId, item.gradeId)
  381. if (rebuildStatus == 0) {
  382. this.$navTo.togo('/pages2/learn/details', {
  383. gradeId: item.gradeId,
  384. goodsId: item.goodsId,
  385. orderGoodsId: item.orderGoodsId,
  386. });
  387. return;
  388. }
  389. // /lock/lockStatus
  390. this.$api.lockLockStatus({
  391. action: 'jxjy',
  392. uuid:this.$method.getUuid()
  393. }).then(res => {
  394. if (res.data.code == 200) { //有其他端在操作,不能学习
  395. uni.showToast({
  396. icon: 'none',
  397. title: res.data.msg,
  398. mask: true,
  399. duration: 3000
  400. })
  401. } else if (res.data.code == 500) { //可以学习
  402. if (item.courseNum == 1) { // 课程数量
  403. // /course/courseList查询商品下的课程列表
  404. this.$api.courseCourseList({
  405. pageNum: 1,
  406. pageSize: 1,
  407. goodsId: item.goodsId,
  408. gradeId: item.gradeId,
  409. orderGoodsId: item.orderGoodsId,
  410. }).then(res => {
  411. if (res.data.code == 200) {
  412. uni.navigateTo({
  413. url: `/pages3/polyv/detail?id=${res.data.rows[0].courseId}&goodsId=${item.goodsId}&orderGoodsId=${item.orderGoodsId}`
  414. })
  415. }
  416. });
  417. return;
  418. }
  419. this.$navTo.togo(`/pages2/wd/course?id=${v}&gid=${i}&orderGoodsId=${item.orderGoodsId}`);
  420. }
  421. })
  422. },
  423. /**
  424. * @param {Object} goodsId 商品id
  425. * 查询商品重修状态
  426. */
  427. courseGoodsRebuildStatus(goodsId, gradeId) {
  428. return new Promise(resolve => {
  429. this.$api.courseGoodsRebuildStatus({
  430. goodsId: goodsId,
  431. gradeId: gradeId
  432. }).then(res => {
  433. resolve(res.data.data)
  434. })
  435. })
  436. },
  437. userConfirmInfoDetail(){
  438. return new Promise(resolve => {
  439. this.$api.userConfirmInfoDetail({
  440. orderGoodsId:this.activeItem.orderGoodsId,
  441. }).then(res => {
  442. if(!res.data.data) {
  443. clearInterval(this.confirmTimer);
  444. this.confirmCount = 10;
  445. this.showUserConfirmInfo = true;
  446. this.confirmTimer = setInterval(() => {
  447. if(this.confirmCount > 0) {
  448. this.confirmCount--
  449. } else {
  450. clearInterval(this.confirmTimer);
  451. }
  452. },1000)
  453. } else {
  454. if(res.data.data.pushInfo) {
  455. resolve(true)
  456. } else {
  457. uni.showModal({
  458. showCancel:false,
  459. title:'提示',
  460. content:'开通信息推送不成功,无法进入学习,请联系020-87085982!'
  461. })
  462. resolve(false)
  463. }
  464. }
  465. })
  466. })
  467. },
  468. selectClass(item, index) {
  469. console.log(item)
  470. this.itemIndex = index;
  471. this.selectItem = item;
  472. this.selectClassModal = true;
  473. this.goodsGradeList(item.goodsId);
  474. },
  475. goodsGradeList(id) {
  476. this.$api.goodsGradeList({
  477. goodsId: id
  478. }).then(res => {
  479. if (res.data.code == 200) {
  480. this.gradeList = res.data.rows
  481. if (this.gradeList.length == 0) {
  482. let item = {
  483. className: '系统分班',
  484. gradeId: 0
  485. }
  486. this.gradeList.push(item)
  487. } else {
  488. let isGradeFull = this.gradeList.every(item => (item.studentNum > 0 && item
  489. .studentNum == item.studentUpper))
  490. //所有班级都满了
  491. if (isGradeFull) {
  492. let item = {
  493. className: '系统分班',
  494. gradeId: 0
  495. }
  496. this.gradeList.unshift(item)
  497. }
  498. }
  499. }
  500. });
  501. },
  502. // 进入刷题
  503. studyques(item,index){
  504. console.log(item)
  505. this.queitemIndex = index;
  506. let sysTime = this.$method.timest()
  507. if (item.serviceStartTime && item.serviceEndTime && (sysTime <= item.serviceStartTime || sysTime >= item.serviceEndTime)) {
  508. uni.showToast({
  509. icon: 'none',
  510. title: '不在学习服务期,不能进入学习'
  511. })
  512. return;
  513. }
  514. uni.navigateTo({
  515. url:'/pages2/bank/question_detail?id='+item.goodsId+'&orderGoodsId='+item.orderGoodsId
  516. })
  517. },
  518. }
  519. }
  520. </script>
  521. <style>
  522. page {
  523. background: #eaeef1;
  524. }
  525. </style>
  526. <style lang="scss" scoped>
  527. @import './index.scss';
  528. </style>