index.vue 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578
  1. <template>
  2. <view class="daily_practice">
  3. <nav-bar title="每日一练"></nav-bar>
  4. <template v-if="Object.keys(dayExamDetail).length">
  5. <view class="content_up">
  6. <view class="reminds">
  7. <view class="remind_lefts">
  8. <image src="/pages2/static/daily/logo_icon.png" class="logo_icon"></image>
  9. <view class="left_infos">
  10. <text class="one">订阅消息</text>
  11. <text class="two">开启订阅通知,每天打卡不错过</text>
  12. </view>
  13. </view>
  14. <view class="remind_rights">
  15. <!-- 1已订阅 0未订阅 -->
  16. <view class="subscription" @click="getSubscription()">{{ dayExamDetail.subscription == 1 ? '已订阅' : '订阅'}}</view>
  17. </view>
  18. </view>
  19. <view class="punch_days">
  20. <view class="print_day">
  21. <view class="print_left">
  22. <text class="one">打卡天数</text>
  23. <text class="two" v-if=" dayExamDetail.examRecord == 1">恭喜你,今天的打卡已完成</text>
  24. <text class="two" v-else>打卡进度超过了{{ dayExamDetail.recordPercentage || '0%' }}的学员</text>
  25. </view>
  26. <view class="print_right">
  27. <text class="nums">{{ dayExamDetail.recordCount || 0 }}</text>天
  28. </view>
  29. </view>
  30. <view class="middle_line">
  31. <view class="half_cir_left"></view>
  32. <view class="half_cir_rig"></view>
  33. </view>
  34. <view class="examNames">
  35. <view class="exam_name">{{ dayExamDetail.examName || '' }}</view>
  36. <image src="/pages2/static/daily/daily_one.png" class="daily_one"></image>
  37. </view>
  38. <view class="learn_btns">
  39. <view class="toLearn" @click="goPractice()">{{ dayExamDetail.examRecord == 1 ? '今日已完成' : '今日打卡' }}</view>
  40. <view class="ranks" @click="toRank()">
  41. <text>打卡PK榜</text>
  42. <u-icon name="arrow-right" color="#677998" size="28"></u-icon>
  43. </view>
  44. </view>
  45. </view>
  46. </view>
  47. <view class="contents">
  48. <view class="c_title">打卡记录</view>
  49. <view class="punch_calendar">
  50. <view class="card_box">
  51. {{ curYear + '年' + curMonth + '月'}}
  52. </view>
  53. <!-- <u-line color="#EEEEEE" /> -->
  54. <view class="weeks">
  55. <view v-for="(item, index) in weekLists" :key="index" class="card_date">{{ item }}</view>
  56. </view>
  57. <view class="day_dailys">
  58. <view v-for="(item, index) in date_num" :key="index" class="date_nums">
  59. <view class="date_items">
  60. <image v-if="item.sign" src="/pages2/static/daily/punch.png" class="pun_icon"></image>
  61. <text v-else>{{ item.date }}</text>
  62. </view>
  63. </view>
  64. </view>
  65. </view>
  66. </view>
  67. </template>
  68. <template v-else>
  69. <view class="no_datas">
  70. <image src="/static/learn/empty_status.png" class="empty_status"></image>
  71. <text class="word_tip">暂无每日一练</text>
  72. </view>
  73. </template>
  74. <!-- 订阅消息弹窗 -->
  75. <!-- :mask-close-able="false" -->
  76. <u-popup class="modal" v-model="meassgeModal" mode="bottom" border-radius="24" >
  77. <view class="message_box">
  78. <view class="officials">
  79. <image src="/pages2/static/daily/logo_icon.png" class="offi_icon"></image>
  80. <text class="apply">祥粤云学堂申请</text>
  81. </view>
  82. <view class="titles">{{ dayExamDetail.subscription == 1 ? '不再订阅消息' : '发送以下消息' }}</view>
  83. <view class="warns">
  84. <u-icon name="checkmark-circle-fill fill_icon" color="#01C65A" size="50"></u-icon>
  85. <text class="w_tips">每日刷题提醒</text>
  86. </view>
  87. <view class="bottons">
  88. <view class="cancel_btn btns" @click="cancel()">取消</view>
  89. <view class="confirm_btn btns" @click="confirm()">确定</view>
  90. </view>
  91. </view>
  92. </u-popup>
  93. </view>
  94. </template>
  95. <script>
  96. export default {
  97. data() {
  98. return {
  99. weekLists: ['日','一','二','三','四','五','六'],
  100. date_num: [],
  101. curYear: 0, // 当前年份
  102. curMonth: 0, // 当前月份
  103. goodsId: '',
  104. orderGoodsId: '',
  105. dayExamDetail: {}, // 每日一练当天信息试卷
  106. dayRecordList: [], // 每日一练试卷日历打卡记录
  107. meassgeModal: false,
  108. options: {},
  109. timer: null,
  110. }
  111. },
  112. onLoad(option) {
  113. console.log('参数option:', option);
  114. this.options = option
  115. this.goodsId = option.goodsId
  116. this.orderGoodsId = option.orderGoodsId
  117. },
  118. onShow() {
  119. console.log('this.options:', this.options);
  120. if (this.$method.isGoLogin()) { // 从公众号消息进来的没登录需要跳到登录页,登录后返回
  121. return
  122. }
  123. console.log('onshow进来了');
  124. this.initCalendar()
  125. this.getToDayExam()
  126. if (!this.timer) {
  127. this.getLock()
  128. this.timer = setInterval(this.getLock, 10000)
  129. }
  130. },
  131. onUnload() {
  132. clearInterval(this.timer)
  133. this.$api.lockDelLock({
  134. action: 'bank',
  135. uuid: this.$method.getUuid()
  136. }).then(res => {
  137. })
  138. },
  139. methods: {
  140. getLock() {
  141. this.$api.lockLockAction({
  142. action: 'bank',
  143. uuid: this.$method.getUuid()
  144. }).then(res => {
  145. })
  146. },
  147. // 初始化当月日历
  148. initCalendar() {
  149. let date = new Date()
  150. this.curYear = date.getFullYear() //获取当前年份
  151. this.curMonth = date.getMonth() + 1 //获取当前月份
  152. let dd = new Date(this.curYear, this.curMonth, 0) //获取当月总天数
  153. let current_month = []
  154. // let weekList = ["星期日", "星期一", "星期二", "星期三", "星期四", "星期五", "星期六"]
  155. for (let i = 1; i <= dd.getDate(); i++) {
  156. current_month.push({
  157. date: i,
  158. week: new Date(date.setDate(i)).getDay(),//获取对应日期的星期
  159. });
  160. }
  161. if (current_month[0].week != 0) {
  162. for (let index = 0; index < 2; index++) {
  163. let item = {
  164. date: '',
  165. week: index
  166. }
  167. current_month.splice(index, 0, item)
  168. }
  169. }
  170. this.date_num = current_month
  171. this.getDailyRecord()
  172. },
  173. // 获取每日一练当天的试卷信息
  174. getToDayExam() {
  175. // ${this.goodsId || 990}
  176. this.$http({
  177. url: `/bank/question/getToDayExam/${this.goodsId}`,
  178. method: 'get',
  179. }).then((res) => {
  180. if (res.data.code == 200) {
  181. this.dayExamDetail = res.data && res.data.data || {}
  182. console.log('dayExamDetail:', this.dayExamDetail);
  183. }
  184. })
  185. },
  186. // 获取每日一练试卷日历打卡记录
  187. getDailyRecord() {
  188. this.$http({
  189. url: '/bank/question/get/special/record',
  190. method: 'get',
  191. data: {
  192. goodsId: this.goodsId,
  193. }
  194. }).then((res) => {
  195. if (res.data.code == 200) {
  196. let data = res.data.data || []
  197. this.dayRecordList = data.map((item) => {
  198. let day = 0
  199. if (item.recordTime) {
  200. day = new Date(item.recordTime * 1000).getDate()
  201. }
  202. return {
  203. ...item,
  204. day: day
  205. }
  206. })
  207. if (this.dayRecordList.length) {
  208. this.date_num.forEach((item, index) => {
  209. let findV = this.dayRecordList.find(e => e.day == item.date)
  210. if (findV) {
  211. this.$set(this.date_num[index], 'sign', true)
  212. } else {
  213. this.$set(this.date_num[index], 'sign', false)
  214. }
  215. })
  216. }
  217. }
  218. })
  219. },
  220. goPractice() {
  221. const { examId, moduleExamId = 0, chapterExamId = 0 } = this.dayExamDetail
  222. uni.navigateTo({
  223. url:'/pages2/bank/questionBank?orderGoodsId='+ this.orderGoodsId + '&id=' + examId + '&goodsid=' + this.goodsId
  224. +'&moduleId=' + moduleExamId + '&chapterId=' + chapterExamId + '&entryType=daily'
  225. })
  226. },
  227. toRank() {
  228. uni.navigateTo({
  229. url: '/pages2/dailyPractice/rankList?goodsId=' + this.goodsId
  230. })
  231. },
  232. confirm() {
  233. this.$http({
  234. url: '/bank/question/today/exam/subscription',
  235. method: 'post',
  236. data: {
  237. goodsId: this.goodsId,
  238. orderGoodsId: this.orderGoodsId,
  239. subscriptionStatus: this.dayExamDetail.subscription == 0 ? 1 : 0,
  240. }
  241. }).then((res) => {
  242. if (res.data.code == 200) {
  243. let msg = this.dayExamDetail.subscription == 0 ? '订阅成功' : '取消订阅成功'
  244. this.$u.toast(msg)
  245. this.meassgeModal = false
  246. let value = this.dayExamDetail.subscription == 0 ? 1 : 0
  247. this.$set(this.dayExamDetail, 'subscription', value)
  248. } else {
  249. this.$u.toast('订阅失败,请重新订阅')
  250. }
  251. }).catch((err) => {
  252. this.$u.toast('订阅失败,请重新订阅')
  253. })
  254. },
  255. cancel() {
  256. this.meassgeModal = false
  257. },
  258. // 订阅消息
  259. getSubscription() {
  260. this.meassgeModal = true
  261. },
  262. },
  263. }
  264. </script>
  265. <style lang="scss">
  266. .daily_practice {
  267. width: 100%;
  268. }
  269. .content_up {
  270. width: 100%;
  271. height: 646rpx;
  272. background: linear-gradient(#3577E8, #FAFAFA);
  273. padding: 0rpx 26rpx 0rpx;
  274. display: flex;
  275. flex-direction: column;
  276. align-items: center;
  277. .reminds {
  278. width: 100%;
  279. height: 112rpx;
  280. border-radius: 14rpx;
  281. background-color: #fff;
  282. padding: 0rpx 24rpx;
  283. display: flex;
  284. align-items: center;
  285. justify-content: space-between;
  286. margin-top: 38rpx;
  287. margin-bottom: 26rpx;
  288. }
  289. .remind_lefts {
  290. display: flex;
  291. align-items: center;
  292. }
  293. .logo_icon {
  294. width: 88rpx;
  295. height: 88rpx;
  296. margin-right: 16rpx;
  297. }
  298. .left_infos {
  299. display: flex;
  300. flex-direction: column;
  301. .one {
  302. font-size: 32rpx;
  303. font-family: PingFang SC-Heavy, PingFang SC;
  304. font-weight: 800;
  305. color: #222222;
  306. margin-bottom: 2rpx;
  307. }
  308. .two {
  309. font-size: 24rpx;
  310. font-family: PingFang SC-Medium, PingFang SC;
  311. font-weight: 500;
  312. color: #999999;
  313. }
  314. }
  315. .subscription {
  316. width: 136rpx;
  317. height: 64rpx;
  318. line-height: 64rpx;
  319. text-align: center;
  320. background: #07C160;
  321. border-radius: 8rpx;
  322. font-size: 28rpx;
  323. font-family: PingFang SC-Heavy, PingFang SC;
  324. font-weight: 800;
  325. color: #FFFFFF;
  326. }
  327. .punch_days {
  328. width: 100%;
  329. height: 470rpx;
  330. background-color: #fff;
  331. border-radius: 16rpx;
  332. .print_day {
  333. padding: 40rpx 40rpx 6rpx 40rpx;
  334. display: flex;
  335. align-items: center;
  336. justify-content: space-between;
  337. }
  338. .print_left {
  339. display: flex;
  340. flex-direction: column;
  341. .one {
  342. margin-bottom: 8rpx;
  343. font-size: 36rpx;
  344. font-weight: 800;
  345. color: #556176;
  346. }
  347. .two {
  348. font-size: 26rpx;
  349. font-weight: 500;
  350. color: #808DA4;
  351. }
  352. }
  353. .print_right {
  354. font-size: 28rpx;
  355. font-weight: 500;
  356. color: #222222;
  357. .nums {
  358. font-size: 76rpx;
  359. font-family: DIN-Medium, DIN;
  360. margin-right: 6rpx;
  361. }
  362. }
  363. .middle_line {
  364. display: flex;
  365. justify-content: space-between;
  366. align-items: center;
  367. .half_cir_left {
  368. width: 16rpx;
  369. height: 32rpx;
  370. border-radius: 0rpx 16rpx 16rpx 0rpx;
  371. background: #D9D9D9;
  372. opacity: 1;
  373. }
  374. .half_cir_rig {
  375. width: 16rpx;
  376. height: 32rpx;
  377. border-radius: 16rpx 0rpx 0rpx 16rpx;
  378. background: #D9D9D9;
  379. opacity: 1;
  380. }
  381. }
  382. .examNames {
  383. width: 100%;
  384. padding: 0rpx 24rpx 0rpx 40rpx;
  385. display: flex;
  386. align-items: center;
  387. justify-content: space-between;
  388. .exam_name {
  389. width: 440rpx;
  390. font-size: 32rpx;
  391. font-weight: 800;
  392. color: #556176;
  393. line-height: 38rpx;
  394. }
  395. .daily_one {
  396. width: 160rpx;
  397. height: 160rpx;
  398. }
  399. }
  400. .learn_btns {
  401. display: flex;
  402. align-items: center;
  403. padding-left: 40rpx;
  404. .toLearn {
  405. width: 240rpx;
  406. height: 88rpx;
  407. line-height: 88rpx;
  408. text-align: center;
  409. background: #3577E8;
  410. border-radius: 260rpx;
  411. font-size: 30rpx;
  412. font-weight: bold;
  413. color: #FFFFFF;
  414. margin-right: 32rpx;
  415. }
  416. .ranks {
  417. font-size: 28rpx;
  418. font-weight: 500;
  419. color: #677998;
  420. }
  421. }
  422. }
  423. }
  424. .contents {
  425. width: 100%;
  426. height: 100%;
  427. background-color: #FAFAFA;
  428. padding: 0rpx 26rpx 100rpx 26rpx;
  429. .c_title {
  430. font-size: 32rpx;
  431. font-weight: 500;
  432. color: #222222;
  433. margin-bottom: 34rpx;
  434. padding-top: 56rpx;
  435. }
  436. }
  437. .punch_calendar {
  438. width: 100%;
  439. background: #ffffff;
  440. border-radius: 24rpx;
  441. padding: 38rpx 34rpx 0rpx;
  442. .card_box {
  443. width: 100%;
  444. font-size: 32rpx;
  445. font-weight: 500;
  446. color: #222222;
  447. }
  448. .t1 {
  449. color: #007AFF;
  450. font-size: 24rpx;
  451. }
  452. .weeks {
  453. width: 100%;
  454. display: flex;
  455. justify-content:center;
  456. margin-top: 32rpx;
  457. margin-bottom: 24rpx;
  458. }
  459. .card_date {
  460. width: 14%;
  461. text-align: center;
  462. color: #7f8caf;
  463. font-size: 26rpx;
  464. font-weight: 500;
  465. color: #888691;
  466. }
  467. .day_dailys {
  468. width: 100%;
  469. display: flex;
  470. margin-top: 40rpx;
  471. flex-wrap: wrap;
  472. }
  473. .date_nums {
  474. width: 14%;
  475. text-align: center;
  476. position: relative;
  477. display: inline-block;
  478. margin-bottom: 32rpx;
  479. .date_items {
  480. width: 100%;
  481. }
  482. .pun_icon {
  483. width: 48rpx;
  484. height: 48rpx;
  485. }
  486. }
  487. }
  488. // 订阅消息弹窗
  489. .message_box {
  490. width: 100%;
  491. height: 756rpx;
  492. background-color: #fff;
  493. padding: 64rpx 56rpx 0rpx;
  494. .officials {
  495. display: flex;
  496. align-items: center;
  497. margin-bottom: 48rpx;
  498. .offi_icon {
  499. width: 56rpx;
  500. height: 56rpx;
  501. margin-right: 56rpx;
  502. }
  503. .apply {
  504. font-size: 32rpx;
  505. font-weight: 500;
  506. color: #222222;
  507. }
  508. }
  509. .titles {
  510. font-size: 36rpx;
  511. font-weight: bold;
  512. color: #222222;
  513. margin-bottom: 48rpx;
  514. }
  515. .warns {
  516. padding: 38rpx 0rpx;
  517. border-top: 2rpx solid #E9E9E9;
  518. border-bottom: 2rpx solid #E9E9E9;
  519. display: flex;
  520. align-items: center;
  521. .w_tips {
  522. margin-left: 24rpx;
  523. font-size: 32rpx;
  524. font-weight: 500;
  525. color: #666666;
  526. }
  527. }
  528. .bottons {
  529. width: 100%;
  530. display: flex;
  531. justify-content: space-around;
  532. margin-top: 160rpx;
  533. .btns {
  534. width: 252rpx;
  535. height: 84rpx;
  536. line-height: 84rpx;
  537. text-align: center;
  538. border-radius: 16rpx;
  539. font-size: 36rpx;
  540. font-weight: 500;
  541. }
  542. .confirm_btn {
  543. background: #01C65A;
  544. color: #FFFFFF;
  545. }
  546. .cancel_btn {
  547. color: #01C65A;
  548. background: #F1F1F1;
  549. }
  550. }
  551. }
  552. .no_datas {
  553. width: 100%;
  554. height: 100vh;
  555. background-color: #FFFFFF;
  556. display: flex;
  557. align-items: center;
  558. // justify-content: center;
  559. flex-direction: column;
  560. .empty_status {
  561. width: 160rpx;
  562. height: 160rpx;
  563. margin-bottom: 14rpx;
  564. margin-top: 300rpx;
  565. }
  566. .word_tip {
  567. font-size: 30rpx;
  568. color: #888691;
  569. }
  570. }
  571. </style>