index.vue 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507
  1. <template>
  2. <view class="daily_practice">
  3. <nav-bar title="每日一练"></nav-bar>
  4. <view class="content_up">
  5. <view class="reminds">
  6. <view class="remind_lefts">
  7. <image src="/pages2/static/daily/logo_icon.png" class="logo_icon"></image>
  8. <view class="left_infos">
  9. <text class="one">订阅消息</text>
  10. <text class="two">开启订阅通知,每天打卡不错过</text>
  11. </view>
  12. </view>
  13. <view class="remind_rights">
  14. <!-- 1已订阅 0未订阅 -->
  15. <view class="subscription" @click="getSubscription()">{{ dayExamDetail.subscription == 1 ? '已订阅' : '订阅'}}</view>
  16. </view>
  17. </view>
  18. <view class="punch_days">
  19. <view class="print_day">
  20. <view class="print_left">
  21. <text class="one">打卡天数</text>
  22. <text class="two" v-if=" dayExamDetail.examRecord == 1">恭喜你,今天的打卡已完成</text>
  23. <text class="two" v-else>打卡进度超过了{{ dayExamDetail.recordPercentage || '0%' }}的学员</text>
  24. </view>
  25. <view class="print_right">
  26. <text class="nums">{{ dayExamDetail.recordCount }}</text>天
  27. </view>
  28. </view>
  29. <view class="middle_line">
  30. <view class="half_cir_left"></view>
  31. <view class="half_cir_rig"></view>
  32. </view>
  33. <view class="examNames">
  34. <view class="exam_name">{{ dayExamDetail.examName || '' }}</view>
  35. <image src="/pages2/static/daily/daily_one.png" class="daily_one"></image>
  36. </view>
  37. <view class="learn_btns">
  38. <view class="toLearn" @click="goPractice()">{{ dayExamDetail.examRecord == 1 ? '今日已完成' : '快来做题' }}</view>
  39. </view>
  40. </view>
  41. </view>
  42. <view class="contents">
  43. <view class="c_title">打卡记录</view>
  44. <view class="punch_calendar">
  45. <view class="card_box">
  46. {{ curYear + '年' + curMonth + '月'}}
  47. </view>
  48. <!-- <u-line color="#EEEEEE" /> -->
  49. <view class="weeks">
  50. <view v-for="(item, index) in weekLists" :key="index" class="card_date">{{ item }}</view>
  51. </view>
  52. <view class="day_dailys">
  53. <view v-for="(item, index) in date_num" :key="index" class="date_nums">
  54. <view class="date_items">
  55. <image v-if="item.sign" src="/pages2/static/daily/punch.png" class="pun_icon"></image>
  56. <text v-else>{{ item.date }}</text>
  57. </view>
  58. </view>
  59. </view>
  60. </view>
  61. </view>
  62. <!-- 订阅消息弹窗 -->
  63. <!-- :mask-close-able="false" -->
  64. <u-popup class="modal" v-model="meassgeModal" mode="bottom" border-radius="24" >
  65. <view class="message_box">
  66. <view class="officials">
  67. <image src="/pages2/static/daily/logo_icon.png" class="offi_icon"></image>
  68. <text class="apply">祥粤云学堂申请</text>
  69. </view>
  70. <view class="titles">{{ dayExamDetail.subscription == 1 ? '不再订阅消息' : '发送以下消息' }}</view>
  71. <view class="warns">
  72. <u-icon name="checkmark-circle-fill fill_icon" color="#01C65A" size="50"></u-icon>
  73. <text class="w_tips">每日刷题提醒</text>
  74. </view>
  75. <view class="bottons">
  76. <view class="cancel_btn btns" @click="cancel()">取消</view>
  77. <view class="confirm_btn btns" @click="confirm()">确定</view>
  78. </view>
  79. </view>
  80. </u-popup>
  81. </view>
  82. </template>
  83. <script>
  84. export default {
  85. data() {
  86. return {
  87. weekLists: ['日','一','二','三','四','五','六'],
  88. date_num: [],
  89. curYear: 0, // 当前年份
  90. curMonth: 0, // 当前月份
  91. goodsId: '',
  92. orderGoodsId: '',
  93. dayExamDetail: {}, // 每日一练当天信息试卷
  94. dayRecordList: [], // 每日一练试卷日历打卡记录
  95. meassgeModal: false
  96. }
  97. },
  98. onLoad(option) {
  99. this.goodsId = option.goodsId
  100. this.orderGoodsId = option.orderGoodsId
  101. },
  102. onShow() {
  103. this.initCalendar()
  104. this.getToDayExam()
  105. },
  106. methods: {
  107. // 初始化当月日历
  108. initCalendar() {
  109. let date = new Date()
  110. this.curYear = date.getFullYear() //获取当前年份
  111. this.curMonth = date.getMonth() + 1 //获取当前月份
  112. let dd = new Date(this.curYear, this.curMonth, 0) //获取当月总天数
  113. let current_month = []
  114. // let weekList = ["星期日", "星期一", "星期二", "星期三", "星期四", "星期五", "星期六"]
  115. for (let i = 1; i <= dd.getDate(); i++) {
  116. current_month.push({
  117. date: i,
  118. week: new Date(date.setDate(i)).getDay(),//获取对应日期的星期
  119. });
  120. }
  121. if (current_month[0].week != 0) {
  122. for (let index = 0; index < 2; index++) {
  123. let item = {
  124. date: '',
  125. week: index
  126. }
  127. current_month.splice(index, 0, item)
  128. }
  129. }
  130. this.date_num = current_month
  131. this.getDailyRecord()
  132. },
  133. // 获取每日一练当天的试卷信息
  134. getToDayExam() {
  135. // ${this.goodsId || 990}
  136. this.$http({
  137. url: `/bank/question/getToDayExam/${this.goodsId}`,
  138. method: 'get',
  139. }).then((res) => {
  140. if (res.data.code == 200) {
  141. this.dayExamDetail = res.data.data || {}
  142. }
  143. })
  144. },
  145. // 获取每日一练试卷日历打卡记录
  146. getDailyRecord() {
  147. this.$http({
  148. url: '/bank/question/get/special/record',
  149. method: 'get',
  150. data: {
  151. goodsId: this.goodsId,
  152. }
  153. }).then((res) => {
  154. if (res.data.code == 200) {
  155. let data = res.data.data || []
  156. this.dayRecordList = data.map((item) => {
  157. let day = 0
  158. if (item.recordTime) {
  159. day = new Date(item.recordTime * 1000).getDate()
  160. }
  161. return {
  162. ...item,
  163. day: day
  164. }
  165. })
  166. if (this.dayRecordList.length) {
  167. this.date_num.forEach((item, index) => {
  168. let findV = this.dayRecordList.find(e => e.day == item.date)
  169. console.log('findV', findV);
  170. if (findV) {
  171. this.$set(this.date_num[index], 'sign', true)
  172. } else {
  173. this.$set(this.date_num[index], 'sign', false)
  174. }
  175. })
  176. }
  177. console.log('this.dayRecordList', this.dayRecordList, this.date_num);
  178. }
  179. })
  180. },
  181. goPractice() {
  182. const { examId, moduleExamId = 0, chapterExamId = 0 } = this.dayExamDetail
  183. uni.navigateTo({
  184. url:'/pages2/bank/questionBank?orderGoodsId='+ this.orderGoodsId + '&id=' + examId + '&goodsid=' + this.goodsId
  185. +'&moduleId=' + moduleExamId + '&chapterId=' + chapterExamId + '&entryType=daily'
  186. })
  187. },
  188. confirm() {
  189. this.$http({
  190. url: '/bank/question/today/exam/subscription',
  191. method: 'post',
  192. data: {
  193. goodsId: this.goodsId,
  194. orderGoodsId: this.orderGoodsId,
  195. subscriptionStatus: this.dayExamDetail.subscription == 0 ? 1 : 0,
  196. }
  197. }).then((res) => {
  198. if (res.data.code == 200) {
  199. let msg = this.dayExamDetail.subscription == 0 ? '订阅成功' : '取消订阅成功'
  200. this.$u.toast(msg)
  201. this.meassgeModal = false
  202. let value = this.dayExamDetail.subscription == 0 ? 1 : 0
  203. this.$set(this.dayExamDetail, 'subscription', value)
  204. } else {
  205. this.$u.toast('订阅失败,请重新订阅')
  206. }
  207. }).catch((err) => {
  208. this.$u.toast('订阅失败,请重新订阅')
  209. })
  210. },
  211. cancel() {
  212. this.meassgeModal = false
  213. },
  214. // 订阅消息
  215. getSubscription() {
  216. this.meassgeModal = true
  217. },
  218. },
  219. }
  220. </script>
  221. <style lang="scss">
  222. .daily_practice {
  223. width: 100%;
  224. }
  225. .content_up {
  226. width: 100%;
  227. height: 646rpx;
  228. background: linear-gradient(#3577E8, #FAFAFA);
  229. padding: 0rpx 26rpx 0rpx;
  230. display: flex;
  231. flex-direction: column;
  232. align-items: center;
  233. .reminds {
  234. width: 100%;
  235. height: 112rpx;
  236. border-radius: 14rpx;
  237. background-color: #fff;
  238. padding: 0rpx 24rpx;
  239. display: flex;
  240. align-items: center;
  241. justify-content: space-between;
  242. margin-top: 38rpx;
  243. margin-bottom: 26rpx;
  244. }
  245. .remind_lefts {
  246. display: flex;
  247. align-items: center;
  248. }
  249. .logo_icon {
  250. width: 88rpx;
  251. height: 88rpx;
  252. margin-right: 16rpx;
  253. }
  254. .left_infos {
  255. display: flex;
  256. flex-direction: column;
  257. .one {
  258. font-size: 32rpx;
  259. font-family: PingFang SC-Heavy, PingFang SC;
  260. font-weight: 800;
  261. color: #222222;
  262. margin-bottom: 2rpx;
  263. }
  264. .two {
  265. font-size: 24rpx;
  266. font-family: PingFang SC-Medium, PingFang SC;
  267. font-weight: 500;
  268. color: #999999;
  269. }
  270. }
  271. .subscription {
  272. width: 136rpx;
  273. height: 64rpx;
  274. line-height: 64rpx;
  275. text-align: center;
  276. background: #07C160;
  277. border-radius: 8rpx;
  278. font-size: 28rpx;
  279. font-family: PingFang SC-Heavy, PingFang SC;
  280. font-weight: 800;
  281. color: #FFFFFF;
  282. }
  283. .punch_days {
  284. width: 100%;
  285. height: 470rpx;
  286. background-color: #fff;
  287. border-radius: 16rpx;
  288. .print_day {
  289. padding: 40rpx 40rpx 6rpx 40rpx;
  290. display: flex;
  291. align-items: center;
  292. justify-content: space-between;
  293. }
  294. .print_left {
  295. display: flex;
  296. flex-direction: column;
  297. .one {
  298. margin-bottom: 8rpx;
  299. font-size: 36rpx;
  300. font-weight: 800;
  301. color: #556176;
  302. }
  303. .two {
  304. font-size: 26rpx;
  305. font-weight: 500;
  306. color: #808DA4;
  307. }
  308. }
  309. .print_right {
  310. font-size: 28rpx;
  311. font-weight: 500;
  312. color: #222222;
  313. .nums {
  314. font-size: 76rpx;
  315. font-family: DIN-Medium, DIN;
  316. margin-right: 6rpx;
  317. }
  318. }
  319. .middle_line {
  320. display: flex;
  321. justify-content: space-between;
  322. align-items: center;
  323. .half_cir_left {
  324. width: 16rpx;
  325. height: 32rpx;
  326. border-radius: 0rpx 16rpx 16rpx 0rpx;
  327. background: #D9D9D9;
  328. opacity: 1;
  329. }
  330. .half_cir_rig {
  331. width: 16rpx;
  332. height: 32rpx;
  333. border-radius: 16rpx 0rpx 0rpx 16rpx;
  334. background: #D9D9D9;
  335. opacity: 1;
  336. }
  337. }
  338. .examNames {
  339. width: 100%;
  340. padding: 0rpx 24rpx 0rpx 40rpx;
  341. display: flex;
  342. align-items: center;
  343. justify-content: space-between;
  344. .exam_name {
  345. width: 440rpx;
  346. font-size: 32rpx;
  347. font-weight: 800;
  348. color: #556176;
  349. line-height: 38rpx;
  350. }
  351. .daily_one {
  352. width: 160rpx;
  353. height: 160rpx;
  354. }
  355. }
  356. .learn_btns {
  357. padding-left: 40rpx;
  358. .toLearn {
  359. width: 240rpx;
  360. height: 88rpx;
  361. line-height: 88rpx;
  362. text-align: center;
  363. background: #3577E8;
  364. border-radius: 260rpx;
  365. font-size: 30rpx;
  366. font-weight: bold;
  367. color: #FFFFFF;
  368. }
  369. }
  370. }
  371. }
  372. .contents {
  373. width: 100%;
  374. height: 100%;
  375. background-color: #FAFAFA;
  376. padding: 0rpx 26rpx 100rpx 26rpx;
  377. .c_title {
  378. font-size: 32rpx;
  379. font-weight: 500;
  380. color: #222222;
  381. margin-bottom: 34rpx;
  382. padding-top: 56rpx;
  383. }
  384. }
  385. .punch_calendar {
  386. width: 100%;
  387. background: #ffffff;
  388. border-radius: 24rpx;
  389. padding: 38rpx 34rpx 0rpx;
  390. .card_box {
  391. width: 100%;
  392. font-size: 32rpx;
  393. font-weight: 500;
  394. color: #222222;
  395. }
  396. .t1 {
  397. color: #007AFF;
  398. font-size: 24rpx;
  399. }
  400. .weeks {
  401. width: 100%;
  402. display: flex;
  403. justify-content:center;
  404. margin-top: 32rpx;
  405. margin-bottom: 24rpx;
  406. }
  407. .card_date {
  408. width: 14%;
  409. text-align: center;
  410. color: #7f8caf;
  411. font-size: 26rpx;
  412. font-weight: 500;
  413. color: #888691;
  414. }
  415. .day_dailys {
  416. width: 100%;
  417. display: flex;
  418. margin-top: 40rpx;
  419. flex-wrap: wrap;
  420. }
  421. .date_nums {
  422. width: 14%;
  423. text-align: center;
  424. position: relative;
  425. display: inline-block;
  426. margin-bottom: 32rpx;
  427. .date_items {
  428. width: 100%;
  429. }
  430. .pun_icon {
  431. width: 48rpx;
  432. height: 48rpx;
  433. }
  434. }
  435. }
  436. // 订阅消息弹窗
  437. .message_box {
  438. width: 100%;
  439. height: 756rpx;
  440. background-color: #fff;
  441. padding: 64rpx 56rpx 0rpx;
  442. .officials {
  443. display: flex;
  444. align-items: center;
  445. margin-bottom: 48rpx;
  446. .offi_icon {
  447. width: 56rpx;
  448. height: 56rpx;
  449. margin-right: 56rpx;
  450. }
  451. .apply {
  452. font-size: 32rpx;
  453. font-weight: 500;
  454. color: #222222;
  455. }
  456. }
  457. .titles {
  458. font-size: 36rpx;
  459. font-weight: bold;
  460. color: #222222;
  461. margin-bottom: 48rpx;
  462. }
  463. .warns {
  464. padding: 38rpx 0rpx;
  465. border-top: 2rpx solid #E9E9E9;
  466. border-bottom: 2rpx solid #E9E9E9;
  467. display: flex;
  468. align-items: center;
  469. .w_tips {
  470. margin-left: 24rpx;
  471. font-size: 32rpx;
  472. font-weight: 500;
  473. color: #666666;
  474. }
  475. }
  476. .bottons {
  477. width: 100%;
  478. display: flex;
  479. justify-content: space-around;
  480. margin-top: 160rpx;
  481. .btns {
  482. width: 252rpx;
  483. height: 84rpx;
  484. line-height: 84rpx;
  485. text-align: center;
  486. border-radius: 16rpx;
  487. font-size: 36rpx;
  488. font-weight: 500;
  489. }
  490. .confirm_btn {
  491. background: #01C65A;
  492. color: #FFFFFF;
  493. }
  494. .cancel_btn {
  495. color: #01C65A;
  496. background: #F1F1F1;
  497. }
  498. }
  499. }
  500. </style>