index.vue 17 KB

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