index.vue 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411
  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. </view>
  63. </template>
  64. <script>
  65. export default {
  66. data() {
  67. return {
  68. weekLists: ['日','一','二','三','四','五','六'],
  69. date_num: [],
  70. curYear: 0, // 当前年份
  71. curMonth: 0, // 当前月份
  72. goodsId: '',
  73. orderGoodsId: '',
  74. dayExamDetail: {}, // 每日一练当天信息试卷
  75. dayRecordList: [], // 每日一练试卷日历打卡记录
  76. }
  77. },
  78. onLoad(option) {
  79. this.goodsId = option.goodsId
  80. this.orderGoodsId = option.orderGoodsId
  81. },
  82. onShow() {
  83. this.initCalendar()
  84. this.getToDayExam()
  85. },
  86. methods: {
  87. // 初始化当月日历
  88. initCalendar() {
  89. let date = new Date()
  90. this.curYear = date.getFullYear() //获取当前年份
  91. this.curMonth = date.getMonth() + 1 //获取当前月份
  92. let dd = new Date(this.curYear, this.curMonth, 0) //获取当月总天数
  93. let current_month = []
  94. // let weekList = ["星期日", "星期一", "星期二", "星期三", "星期四", "星期五", "星期六"]
  95. for (let i = 1; i <= dd.getDate(); i++) {
  96. current_month.push({
  97. date: i,
  98. week: new Date(date.setDate(i)).getDay(),//获取对应日期的星期
  99. });
  100. }
  101. if (current_month[0].week != 0) {
  102. for (let index = 0; index < 2; index++) {
  103. let item = {
  104. date: '',
  105. week: index
  106. }
  107. current_month.splice(index, 0, item)
  108. }
  109. }
  110. this.date_num = current_month
  111. this.getDailyRecord()
  112. },
  113. // 获取每日一练当天的试卷信息
  114. getToDayExam() {
  115. // ${this.goodsId || 990}
  116. this.$http({
  117. url: `/bank/question/getToDayExam/${this.goodsId}`,
  118. method: 'get',
  119. }).then((res) => {
  120. if (res.data.code == 200) {
  121. this.dayExamDetail = res.data.data || {}
  122. }
  123. })
  124. },
  125. // 获取每日一练试卷日历打卡记录
  126. getDailyRecord() {
  127. this.$http({
  128. url: '/bank/question/get/special/record',
  129. method: 'get',
  130. data: {
  131. goodsId: this.goodsId,
  132. }
  133. }).then((res) => {
  134. if (res.data.code == 200) {
  135. let data = res.data.data || []
  136. this.dayRecordList = data.map((item) => {
  137. let day = 0
  138. if (item.recordTime) {
  139. day = new Date(item.recordTime * 1000).getDate()
  140. }
  141. return {
  142. ...item,
  143. day: day
  144. }
  145. })
  146. if (this.dayRecordList.length) {
  147. this.date_num.forEach((item, index) => {
  148. let findV = this.dayRecordList.find(e => e.day == item.date)
  149. console.log('findV', findV);
  150. if (findV) {
  151. this.$set(this.date_num[index], 'sign', true)
  152. } else {
  153. this.$set(this.date_num[index], 'sign', false)
  154. }
  155. })
  156. }
  157. console.log('this.dayRecordList', this.dayRecordList, this.date_num);
  158. }
  159. })
  160. },
  161. goPractice() {
  162. const { examId, moduleExamId = 0, chapterExamId = 0 } = this.dayExamDetail
  163. uni.navigateTo({
  164. url:'/pages2/bank/questionBank?orderGoodsId='+ this.orderGoodsId + '&id=' + examId + '&goodsid=' + this.goodsId
  165. +'&moduleId=' + moduleExamId + '&chapterId=' + chapterExamId + '&entryType=daily'
  166. })
  167. },
  168. // 订阅消息
  169. getSubscription() {
  170. this.$http({
  171. url: '/bank/question/today/exam/subscription',
  172. method: 'post',
  173. data: {
  174. goodsId: this.goodsId,
  175. orderGoodsId: this.orderGoodsId,
  176. subscriptionStatus: this.dayExamDetail.subscription == 0 ? 1 : 0,
  177. }
  178. }).then((res) => {
  179. if (res.data.code == 200) {
  180. this.$u.toast('订阅成功')
  181. } else {
  182. this.$u.toast('订阅失败,请重新订阅')
  183. }
  184. }).catch((err) => {
  185. this.$u.toast('订阅失败,请重新订阅')
  186. })
  187. },
  188. },
  189. }
  190. </script>
  191. <style lang="scss">
  192. .daily_practice {
  193. width: 100%;
  194. }
  195. .content_up {
  196. width: 100%;
  197. height: 646rpx;
  198. background: linear-gradient(#3577E8, #FAFAFA);
  199. padding: 0rpx 26rpx 0rpx;
  200. display: flex;
  201. flex-direction: column;
  202. align-items: center;
  203. .reminds {
  204. width: 100%;
  205. height: 112rpx;
  206. border-radius: 14rpx;
  207. background-color: #fff;
  208. padding: 0rpx 24rpx;
  209. display: flex;
  210. align-items: center;
  211. justify-content: space-between;
  212. margin-top: 38rpx;
  213. margin-bottom: 26rpx;
  214. }
  215. .remind_lefts {
  216. display: flex;
  217. align-items: center;
  218. }
  219. .logo_icon {
  220. width: 88rpx;
  221. height: 88rpx;
  222. margin-right: 16rpx;
  223. }
  224. .left_infos {
  225. display: flex;
  226. flex-direction: column;
  227. .one {
  228. font-size: 32rpx;
  229. font-family: PingFang SC-Heavy, PingFang SC;
  230. font-weight: 800;
  231. color: #222222;
  232. margin-bottom: 2rpx;
  233. }
  234. .two {
  235. font-size: 24rpx;
  236. font-family: PingFang SC-Medium, PingFang SC;
  237. font-weight: 500;
  238. color: #999999;
  239. }
  240. }
  241. .subscription {
  242. width: 136rpx;
  243. height: 64rpx;
  244. line-height: 64rpx;
  245. text-align: center;
  246. background: #07C160;
  247. border-radius: 8rpx;
  248. font-size: 28rpx;
  249. font-family: PingFang SC-Heavy, PingFang SC;
  250. font-weight: 800;
  251. color: #FFFFFF;
  252. }
  253. .punch_days {
  254. width: 100%;
  255. height: 470rpx;
  256. background-color: #fff;
  257. border-radius: 16rpx;
  258. .print_day {
  259. padding: 40rpx 40rpx 6rpx 40rpx;
  260. display: flex;
  261. align-items: center;
  262. justify-content: space-between;
  263. }
  264. .print_left {
  265. display: flex;
  266. flex-direction: column;
  267. .one {
  268. margin-bottom: 8rpx;
  269. font-size: 36rpx;
  270. font-weight: 800;
  271. color: #556176;
  272. }
  273. .two {
  274. font-size: 26rpx;
  275. font-weight: 500;
  276. color: #808DA4;
  277. }
  278. }
  279. .print_right {
  280. font-size: 28rpx;
  281. font-weight: 500;
  282. color: #222222;
  283. .nums {
  284. font-size: 76rpx;
  285. font-family: DIN-Medium, DIN;
  286. margin-right: 6rpx;
  287. }
  288. }
  289. .middle_line {
  290. display: flex;
  291. justify-content: space-between;
  292. align-items: center;
  293. .half_cir_left {
  294. width: 16rpx;
  295. height: 32rpx;
  296. border-radius: 0rpx 16rpx 16rpx 0rpx;
  297. background: #D9D9D9;
  298. opacity: 1;
  299. }
  300. .half_cir_rig {
  301. width: 16rpx;
  302. height: 32rpx;
  303. border-radius: 16rpx 0rpx 0rpx 16rpx;
  304. background: #D9D9D9;
  305. opacity: 1;
  306. }
  307. }
  308. .examNames {
  309. width: 100%;
  310. padding: 0rpx 24rpx 0rpx 40rpx;
  311. display: flex;
  312. align-items: center;
  313. justify-content: space-between;
  314. .exam_name {
  315. width: 440rpx;
  316. font-size: 32rpx;
  317. font-weight: 800;
  318. color: #556176;
  319. line-height: 38rpx;
  320. }
  321. .daily_one {
  322. width: 160rpx;
  323. height: 160rpx;
  324. }
  325. }
  326. .learn_btns {
  327. padding-left: 40rpx;
  328. .toLearn {
  329. width: 240rpx;
  330. height: 88rpx;
  331. line-height: 88rpx;
  332. text-align: center;
  333. background: #3577E8;
  334. border-radius: 260rpx;
  335. font-size: 30rpx;
  336. font-weight: bold;
  337. color: #FFFFFF;
  338. }
  339. }
  340. }
  341. }
  342. .contents {
  343. width: 100%;
  344. height: 100%;
  345. background-color: #FAFAFA;
  346. padding: 0rpx 26rpx 100rpx 26rpx;
  347. .c_title {
  348. font-size: 32rpx;
  349. font-weight: 500;
  350. color: #222222;
  351. margin-bottom: 34rpx;
  352. padding-top: 56rpx;
  353. }
  354. }
  355. .punch_calendar {
  356. width: 100%;
  357. background: #ffffff;
  358. border-radius: 24rpx;
  359. padding: 38rpx 34rpx 0rpx;
  360. .card_box {
  361. width: 100%;
  362. font-size: 32rpx;
  363. font-weight: 500;
  364. color: #222222;
  365. }
  366. .t1 {
  367. color: #007AFF;
  368. font-size: 24rpx;
  369. }
  370. .weeks {
  371. width: 100%;
  372. display: flex;
  373. justify-content:center;
  374. margin-top: 32rpx;
  375. margin-bottom: 24rpx;
  376. }
  377. .card_date {
  378. width: 14%;
  379. text-align: center;
  380. color: #7f8caf;
  381. font-size: 26rpx;
  382. font-weight: 500;
  383. color: #888691;
  384. }
  385. .day_dailys {
  386. width: 100%;
  387. display: flex;
  388. margin-top: 40rpx;
  389. flex-wrap: wrap;
  390. }
  391. .date_nums {
  392. width: 14%;
  393. text-align: center;
  394. position: relative;
  395. display: inline-block;
  396. margin-bottom: 32rpx;
  397. .date_items {
  398. width: 100%;
  399. }
  400. .pun_icon {
  401. width: 48rpx;
  402. height: 48rpx;
  403. }
  404. }
  405. }
  406. </style>