index.vue 15 KB

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