index.vue 17 KB

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