index.vue 18 KB

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