index.vue 17 KB

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