index.vue 22 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707
  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. <u-popup v-model="selectClassModal" @close="gradeValue = -1" mode="bottom" border-radius="40">
  177. <view class="popup_box">
  178. <view style="margin-bottom: 20rpx;">
  179. <view class="line1"></view>
  180. <view class="grade">选择班级</view>
  181. </view>
  182. <u-line color="#D6D6DB" />
  183. <view>
  184. <scroll-view scroll-y="true" style="height: 500rpx;">
  185. <view>
  186. <u-radio-group v-model="gradeValue" @change="radioGroupChange">
  187. <view v-for="(item, index) in gradeList" :key="index">
  188. <view style="display: flex;align-items: center;padding: 20rpx;">
  189. <view>
  190. <u-radio shape="circle" :name="index"
  191. :disabled="item.studentNum > 0 && item.studentNum == item.studentUpper">
  192. <view :class="item.checked?'white-box blue-box':'white-box'">
  193. <view>
  194. <view class="blackTxt">{{item.className}}</view>
  195. <view class="redTxt" v-if="item.classEndTime">
  196. 有效期至:{{$method.timestampToTime(item.classEndTime,true,true)}}
  197. </view>
  198. <view class="redTxt" v-if="item.classEndTime">
  199. 本班还剩{{$method.GetRTime(item.classEndTime)}}天将结束学习</view>
  200. </view>
  201. </view>
  202. </u-radio>
  203. </view>
  204. </view>
  205. </view>
  206. </u-radio-group>
  207. </view>
  208. </scroll-view>
  209. </view>
  210. <view class="confrim-btn">
  211. <view class="okBtn" @click="okPopup()">确定</view>
  212. </view>
  213. </view>
  214. </u-popup>
  215. <u-modal v-model="showUserConfirmInfo" @confirm="confirmUserConfirm" ref="uModal" :async-close="true"
  216. @cancel="cancelUserConfirm" :confirm-text="'确认' + (confirmCount > 0 ? '('+confirmCount+')' : '')"
  217. :confirm-color="confirmCount > 0 ? '#999' : '#2979ff'" class="confirm-modal" title="实名验证确认"
  218. cancel="取消" :show-cancel-button="true">
  219. <view class="slot-content">
  220. <view class="content">
  221. 为避免个人信息不正确导致您的学习时长无效,请认真核对以下信息是否正确,如信息有误请取消当前操作,立刻联系020-38946666
  222. <view class="msg-list">
  223. <view class="item">
  224. <text class="item__left">姓名:</text>
  225. <text class="item__right">{{userInfo.realname}}</text>
  226. </view>
  227. <view class="item">
  228. <text class="item__left">手机号:</text>
  229. <text class="item__right">{{userInfo.telphone}}</text>
  230. </view>
  231. <view class="item">
  232. <text class="item__left">身份号:</text>
  233. <text class="item__right">{{userInfo.idCard}}</text>
  234. </view>
  235. <view class="item">
  236. <u-checkbox v-model="confirmChecked" :label-disabled="false">确认个人信息无误</u-checkbox>
  237. </view>
  238. </view>
  239. </view>
  240. </view>
  241. </u-modal>
  242. </view>
  243. </template>
  244. <script>
  245. var curTime = new Date().getTime() // 当前时间的时间戳
  246. export default {
  247. data() {
  248. return {
  249. leftDays: 0,
  250. paramC: {
  251. pageNum: 1,
  252. pageSize: 50
  253. },
  254. activeItem: {},
  255. itemIndex: '',
  256. confirmTimer:null,
  257. confirmCount:10,
  258. confirmChecked:false,
  259. showUserConfirmInfo:false,
  260. selectItem: {},
  261. selectClassModal: false,
  262. gradeList: [],
  263. gradeValue: -1,
  264. sysTime: 0,
  265. courseLists: [], // 课程列表
  266. questionLists: [], // 题库列表
  267. paramQ: {
  268. pageNum: 1,
  269. pageSize: 50
  270. },
  271. queitemIndex:'',
  272. livingLists: [], // 直播列表
  273. allLoading: false, // 加载样式
  274. }
  275. },
  276. filters: {
  277. liveStatus(liveTime, watchStatus) {
  278. // let curTime = new Date().getTime() // 当前时间的时间戳
  279. let value = liveTime * 1000
  280. if (curTime < value) { // 判断当前时间和直播开始时间
  281. return ' 未开播'
  282. } else {
  283. return watchStatus == 'live' ? '正在直播中' : '即将开播'
  284. }
  285. }
  286. },
  287. computed: {
  288. allCourse() {
  289. return this.courseLists.length || this.questionLists.length || this.livingLists.length ? true : false
  290. }
  291. },
  292. onLoad() {
  293. // 1668873600 ,2022.11.20的时间戳
  294. this.leftDays = 1668873600 - parseInt(curTime/1000)
  295. this.getCourseLiveQues()
  296. },
  297. async onShow() {
  298. await this.commonSystemTime()
  299. this.sysTime = +this.$method.timest()
  300. },
  301. methods: {
  302. bgShow(liveTime, watchStatus) {
  303. let value = liveTime * 1000
  304. if (curTime > value) { // 判断当前时间和直播开始时间
  305. return watchStatus == 'live' ? true : false
  306. }
  307. },
  308. lookTimeStatus(liveTime, watchStatus) {
  309. if (liveTime) {
  310. let value = new Date(liveTime * 1000)
  311. var Y = value.getFullYear()
  312. var M = value.getMonth() + 1 < 10 ? '0' + (value.getMonth() + 1) : value.getMonth() + 1
  313. var D = value.getDate() < 10 ? '0' + value.getDate() : value.getDate()
  314. var valZ = Y + '/' + M + '/' + D
  315. let curZeroTime = new Date(valZ).getTime() // 获取开始直播时间当天的零点时间戳
  316. if (curTime > value) { // 判断当前时间和直播开始时间
  317. if (watchStatus == 'live') { //
  318. return 1
  319. } else {
  320. return 2
  321. }
  322. } else {
  323. if (curZeroTime <= curTime && curTime <= value) { //当天
  324. return 3
  325. } else {
  326. return 4
  327. }
  328. }
  329. }
  330. },
  331. curTimeTamp(liveTime) {
  332. let min = liveTime - parseInt(curTime / 1000)
  333. return min
  334. },
  335. toChoose() {
  336. uni.switchTab({
  337. url:'/pages/course/index'
  338. })
  339. },
  340. // 查询直播课
  341. getCourseLiveQues() {
  342. this.allLoading = true
  343. let arrs = [
  344. this.$api.courseGoodsList(this.paramC), // 查询用户拥有的商品/课程列表/course/goodsList
  345. this.$api.listGoodsUserQuestion(this.paramQ), // 题库列表
  346. this.$api.getgoodsLiveList({
  347. pageNum: 1,
  348. pageSize: 3 // 默认3条
  349. })
  350. ]
  351. Promise.all(arrs).then((res) => {
  352. // if (res.data.code == 200) {
  353. console.log('ewds========', res)
  354. const [{ data: res1}, { data: res2}, {data: res3}] = res
  355. if (res1.code == 200) {
  356. this.courseLists = res1.rows || []
  357. }
  358. if (res2.code == 200) {
  359. this.questionLists = res2.rows || []
  360. }
  361. if (res3.code == 200) {
  362. this.livingLists = res3.rows || []
  363. }
  364. this.allLoading = false
  365. console.log('this.courseLists;', this.courseLists, this.questionLists,this.livingLists)
  366. // }
  367. }).catch(err => {
  368. this.allLoading = false
  369. // this.$u.toast('请重新刷新请求')
  370. })
  371. },
  372. // 查询用户拥有的商品/课程列表/course/goodsList
  373. // getcourseList() {
  374. // this.$api.courseGoodsList(this.paramC).then(res => {
  375. // if (res.data.code == 200) {
  376. // this.courseLists = res.data.rows || []
  377. // }
  378. // })
  379. // },
  380. // 题库列表
  381. // getlistQuestion() {
  382. // this.$api.listGoodsUserQuestion(this.paramQ).then(res => {
  383. // if (res.data.code == 200) {
  384. // this.questionLists = res.data.rows || []
  385. // }
  386. // })
  387. // },
  388. commonSystemTime() {
  389. return new Promise(resolve => {
  390. this.$api.commonSystemTime().then(res => {
  391. this.sysTime = res.data.data;
  392. })
  393. })
  394. },
  395. async studyIn(v, i, item, index) {
  396. console.log('item', item)
  397. this.activeItem = item
  398. if (item.interfaceAccountId > 0) { //学习账号已开通
  399. if (item.learnStatus == 1) { //跳转第三方h5
  400. uni.navigateTo({
  401. url: `/pages3/polyv/detail?goodsId=${item.goodsId}&orderGoodsId=${item.orderGoodsId}&isOther=1`
  402. })
  403. return;
  404. } else {
  405. uni.showModal({
  406. showCancel: false,
  407. content: '您的学习账号未开通,请稍后再尝试,有疑问,请联系020-87085982!'
  408. });
  409. return;
  410. }
  411. return;
  412. }
  413. if (item.serviceStartTime && (this.sysTime <= item.serviceStartTime || this.sysTime >= item.serviceEndTime)) {
  414. uni.showToast({
  415. icon: 'none',
  416. title: '不在学习服务期,不能进入学习'
  417. })
  418. return;
  419. }
  420. if ((item.classStartTime && this.sysTime <= item.classStartTime) || (item.classEndTime && this
  421. .sysTime >= item.classEndTime)) {
  422. uni.showToast({
  423. icon: 'none',
  424. title: '不在班级有效期,不能进入学习'
  425. })
  426. return
  427. }
  428. if (item.learningStatus == 2) {
  429. uni.showToast({
  430. icon: 'none',
  431. title: '开放学习时间待定,不能进入学习'
  432. })
  433. return
  434. }
  435. if (item.classStatus == 0) {
  436. uni.showToast({
  437. icon: 'none',
  438. title: '尚未开班,不能进入学习'
  439. })
  440. return
  441. }
  442. console.log(this.sysTime, item.learningTimeStart)
  443. console.log(this.sysTime < item.learningTimeStart)
  444. if (item.learningStatus == 3 && (this.sysTime < item.learningTimeStart)) {
  445. uni.showToast({
  446. icon: 'none',
  447. title: '不在开放学习时间,不能进入学习'
  448. })
  449. return;
  450. }
  451. var confirmDetail = true;
  452. if (item.educationName == '继续教育') {
  453. if(item.officialName && item.businessName == '二级' && item.projectName == '建造师') {
  454. confirmDetail = await this.userConfirmInfoDetail()
  455. }
  456. }
  457. if(!confirmDetail) {
  458. return;
  459. }
  460. this.itemIndex = index
  461. if (item.gradeStatus == 1 && item.status == 1 && (item.serviceEndTime > this.sysTime) && (item
  462. .classEndTime && (item.classEndTime < this.sysTime)) && (item.periodStatus == 0 || item
  463. .periodStatus == -1) && item.studyCount > 0) {
  464. this.selectClass(item, index)
  465. return
  466. }
  467. // /course/goodsRebuildStatus查询用户商品重修状态
  468. let rebuildStatus = await this.courseGoodsRebuildStatus(item.goodsId, item.gradeId)
  469. if (rebuildStatus == 0) {
  470. this.$navTo.togo('/pages2/learn/details', {
  471. gradeId: item.gradeId,
  472. goodsId: item.goodsId,
  473. orderGoodsId: item.orderGoodsId,
  474. });
  475. return;
  476. }
  477. // /lock/lockStatus
  478. this.$api.lockLockStatus({
  479. action: 'jxjy',
  480. uuid:this.$method.getUuid()
  481. }).then(res => {
  482. if (res.data.code == 200) { //有其他端在操作,不能学习
  483. uni.showToast({
  484. icon: 'none',
  485. title: res.data.msg,
  486. mask: true,
  487. duration: 3000
  488. })
  489. } else if (res.data.code == 500) { //可以学习
  490. if (item.courseNum == 1) { // 课程数量
  491. // /course/courseList查询商品下的课程列表
  492. this.$api.courseCourseList({
  493. pageNum: 1,
  494. pageSize: 1,
  495. goodsId: item.goodsId,
  496. gradeId: item.gradeId,
  497. orderGoodsId: item.orderGoodsId,
  498. }).then(res => {
  499. if (res.data.code == 200) {
  500. uni.navigateTo({
  501. url: `/pages3/polyv/detail?id=${res.data.rows[0].courseId}&goodsId=${item.goodsId}&orderGoodsId=${item.orderGoodsId}`
  502. })
  503. }
  504. });
  505. return;
  506. }
  507. this.$navTo.togo(`/pages2/wd/course?id=${v}&gid=${i}&orderGoodsId=${item.orderGoodsId}`);
  508. }
  509. })
  510. },
  511. /**
  512. * @param {Object} goodsId 商品id
  513. * 查询商品重修状态
  514. */
  515. courseGoodsRebuildStatus(goodsId, gradeId) {
  516. return new Promise(resolve => {
  517. this.$api.courseGoodsRebuildStatus({
  518. goodsId: goodsId,
  519. gradeId: gradeId
  520. }).then(res => {
  521. resolve(res.data.data)
  522. })
  523. })
  524. },
  525. userConfirmInfoDetail(){
  526. return new Promise(resolve => {
  527. this.$api.userConfirmInfoDetail({
  528. orderGoodsId:this.activeItem.orderGoodsId,
  529. }).then(res => {
  530. if(!res.data.data) {
  531. clearInterval(this.confirmTimer);
  532. this.confirmCount = 10;
  533. this.showUserConfirmInfo = true;
  534. this.confirmTimer = setInterval(() => {
  535. if(this.confirmCount > 0) {
  536. this.confirmCount--
  537. } else {
  538. clearInterval(this.confirmTimer);
  539. }
  540. },1000)
  541. } else {
  542. if(res.data.data.pushInfo) {
  543. resolve(true)
  544. } else {
  545. uni.showModal({
  546. showCancel:false,
  547. title:'提示',
  548. content:'开通信息推送不成功,无法进入学习,请联系020-87085982!'
  549. })
  550. resolve(false)
  551. }
  552. }
  553. })
  554. })
  555. },
  556. selectClass(item, index) {
  557. console.log(item)
  558. this.itemIndex = index;
  559. this.selectItem = item;
  560. this.selectClassModal = true;
  561. this.goodsGradeList(item.goodsId);
  562. },
  563. goodsGradeList(id) {
  564. this.$api.goodsGradeList({
  565. goodsId: id
  566. }).then(res => {
  567. if (res.data.code == 200) {
  568. this.gradeList = res.data.rows
  569. if (this.gradeList.length == 0) {
  570. let item = {
  571. className: '系统分班',
  572. gradeId: 0
  573. }
  574. this.gradeList.push(item)
  575. } else {
  576. let isGradeFull = this.gradeList.every(item => (item.studentNum > 0 && item
  577. .studentNum == item.studentUpper))
  578. //所有班级都满了
  579. if (isGradeFull) {
  580. let item = {
  581. className: '系统分班',
  582. gradeId: 0
  583. }
  584. this.gradeList.unshift(item)
  585. }
  586. }
  587. }
  588. });
  589. },
  590. // 进入刷题
  591. studyques(item,index){
  592. console.log(item)
  593. this.queitemIndex = index;
  594. let sysTime = this.$method.timest()
  595. if (item.serviceStartTime && item.serviceEndTime && (sysTime <= item.serviceStartTime || sysTime >= item.serviceEndTime)) {
  596. uni.showToast({
  597. icon: 'none',
  598. title: '不在学习服务期,不能进入学习'
  599. })
  600. return;
  601. }
  602. uni.navigateTo({
  603. url:'/pages2/bank/question_detail?id='+item.goodsId+'&orderGoodsId='+item.orderGoodsId
  604. })
  605. },
  606. radioGroupChange(e) {
  607. console.log(e)
  608. },
  609. okPopup() {
  610. if (this.gradeValue == -1) {
  611. uni.showToast({
  612. icon: 'none',
  613. title: '请选择班级'
  614. })
  615. return;
  616. }
  617. this.$api.changeGrade({
  618. goodsId: this.selectItem.goodsId,
  619. gradeId: this.gradeValue,
  620. oldGradeId: this.selectItem.gradeId,
  621. orderGoodsId: this.selectItem.orderGoodsId,
  622. userId: this.selectItem.userId
  623. }).then(res => {
  624. if (res.data.code == 200) {
  625. if (this.itemIndex !== '') {
  626. this.refreshByIndex();
  627. }
  628. this.selectClassModal = false;
  629. uni.showToast({
  630. title: '选班成功'
  631. })
  632. } else {
  633. uni.showToast({
  634. icon: 'none',
  635. title: res.data.msg
  636. })
  637. }
  638. })
  639. },
  640. /**
  641. * 返回刷新之前进入的课程数据
  642. */
  643. refreshByIndex() {
  644. let self = this;
  645. this.$api.courseGoodsList({
  646. pageNum: this.itemIndex + 1,
  647. pageSize: 1
  648. }).then(res => {
  649. if (res.data.code == 200) {
  650. this.$set(this.goodsList, this.itemIndex, res.data.rows[0])
  651. }
  652. });
  653. },
  654. }
  655. }
  656. </script>
  657. <style>
  658. page {
  659. background: #eaeef1;
  660. }
  661. </style>
  662. <style lang="scss" scoped>
  663. @import './index.scss';
  664. </style>