index.vue 17 KB

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