index.vue 17 KB

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