index.vue 17 KB

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