index.vue 13 KB

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