index.vue 17 KB

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