index.vue 5.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192
  1. <template>
  2. <view class="daily_practice">
  3. <nav-bar title="每日一练"></nav-bar>
  4. <view class="contents">
  5. <view class="remind">
  6. <view>订阅</view>
  7. </view>
  8. <view class="insist">
  9. <view>坚持打卡{{ dayExamDetail.recordCount }} 天</view>
  10. </view>
  11. <view class="names">
  12. <view class="name_title">{{ dayExamDetail.examName || ''}}</view>
  13. <view class="percentage">
  14. <text v-if=" dayExamDetail.examRecord == 1">恭喜你,今天的打卡已完成~</text>
  15. <text v-else>打卡进度超过了{{ dayExamDetail.recordPercentage || '0%' }}的学员,快来打卡呀~</text>
  16. </view>
  17. </view>
  18. <view class="toPractice" @click="goPractice()">
  19. {{ dayExamDetail.examRecord == 1 ? '今日已完成' : '快来做题' }}
  20. </view>
  21. <view class="punch_calendar">
  22. <view class="card_box">
  23. {{ curMonth + '月'}}
  24. </view>
  25. <u-line color="#EEEEEE" />
  26. <view class="weeks">
  27. <view v-for="(item, index) in weekLists" :key="index" class="card_date">{{ item }}</view>
  28. </view>
  29. <view class="day_dailys">
  30. <view v-for="(item, index) in date_num" :key="index" class="date_num">
  31. <view class="items">
  32. {{ item.date }}
  33. </view>
  34. </view>
  35. </view>
  36. </view>
  37. </view>
  38. </view>
  39. </template>
  40. <script>
  41. export default {
  42. data() {
  43. return {
  44. weekLists: ['日','一','二','三','四','五','六'],
  45. date_num: [],
  46. curMonth: 0, // 当前月份
  47. goodsId: '',
  48. orderGoodsId: '',
  49. dayExamDetail: {}, // 每日一练当天信息试卷
  50. dayRecordList: [], // 每日一练试卷打卡记录
  51. }
  52. },
  53. onLoad(option) {
  54. this.goodsId = option.goodsId
  55. this.orderGoodsId = option.orderGoodsId
  56. this.initCalendar()
  57. this.getToDayExam()
  58. },
  59. methods: {
  60. // 初始化当月日历
  61. initCalendar() {
  62. let date = new Date()
  63. let year = date.getFullYear() //获取当前年份
  64. this.curMonth = date.getMonth() + 1 //获取当前月份
  65. let dd = new Date(year, this.curMonth, 0) //获取当月总天数
  66. let current_month = []
  67. let weekList = ["星期日", "星期一", "星期二", "星期三", "星期四", "星期五", "星期六"]
  68. for (let i = 1; i <= dd.getDate(); i++) {
  69. current_month.push({
  70. date: i,
  71. week: new Date(date.setDate(i)).getDay(),//获取对应日期的星期
  72. });
  73. }
  74. if (current_month[0].week != 0) {
  75. for (let index = 0; index < 2; index++) {
  76. let item = {
  77. date: '',
  78. week: index
  79. }
  80. current_month.splice(index, 0, item)
  81. }
  82. }
  83. // console.log('====:', current_month);
  84. this.date_num = current_month
  85. },
  86. // 获取每日一练当天的试卷信息
  87. getToDayExam() {
  88. // ${this.goodsId || 990}
  89. this.$http({
  90. url: `/bank/question/getToDayExam/${this.goodsId}`,
  91. method: 'get',
  92. }).then((res) => {
  93. if (res.data.code == 200) {
  94. this.dayExamDetail = res.data.data || {}
  95. if (Object.keys(this.dayExamDetail).length) {
  96. this.getDailyRecord()
  97. }
  98. }
  99. })
  100. },
  101. // 获取每日一练试卷日历打卡记录
  102. getDailyRecord() {
  103. this.$http({
  104. url: '/bank/question/get/special/record',
  105. method: 'get',
  106. data: {
  107. goodsId: this.goodsId,
  108. chapterExamId: this.dayExamDetail.chapterExamId || 0,
  109. moduleExamId: this.dayExamDetail.moduleExamId || 0,
  110. examId: this.dayExamDetail.examId,
  111. }
  112. }).then((res) => {
  113. if (res.data.code == 200) {
  114. console.log('--res-', res)
  115. }
  116. })
  117. },
  118. goPractice() {
  119. const { examId, moduleExamId = 0, chapterExamId = 0 } = this.dayExamDetail
  120. uni.navigateTo({
  121. url:'/pages2/bank/questionBank?orderGoodsId='+ this.orderGoodsId + '&id=' + examId + '&goodsid=' + this.goodsId
  122. +'&moduleId=' + moduleExamId + '&chapterId=' + chapterExamId + '&entryType=daily'
  123. })
  124. },
  125. },
  126. }
  127. </script>
  128. <style lang="scss">
  129. .daily_practice {
  130. width: 100%;
  131. padding: 32rpx;
  132. }
  133. .contents {
  134. .toPractice {
  135. width: 600rpx;
  136. height: 100rpx;
  137. line-height: 100rpx;
  138. text-align: center;
  139. font-size: 32rpx;
  140. color: #222;
  141. border: 2rpx solid #666;
  142. }
  143. }
  144. .punch_calendar {
  145. width: 100%;
  146. background: #ffffff;
  147. box-shadow: 0rpx 0rpx 16rpx 4rpx rgba(47, 67, 121, 0.1);
  148. border-radius: 22rpx;
  149. margin-top: 16rpx;
  150. padding-bottom: 15rpx;
  151. .card_box {
  152. height: 60rpx;
  153. line-height: 60rpx;
  154. // margin-left: 20rpx;
  155. text-align: center;
  156. }
  157. .t1 {
  158. color: #007AFF;
  159. font-size: 24rpx;
  160. }
  161. .weeks {
  162. width: 100%;
  163. display: flex;
  164. justify-content:center;
  165. margin-top: 20rpx;
  166. }
  167. .card_date {
  168. width: 14%;
  169. text-align: center;
  170. color: #7f8caf;
  171. }
  172. .day_dailys {
  173. width: 100%;
  174. display: flex;
  175. margin-top: 40rpx;
  176. flex-wrap: wrap;
  177. }
  178. .date_num {
  179. width: 14%;
  180. text-align: center;
  181. position: relative;
  182. display: inline-block;
  183. margin-top: 20rpx;
  184. .items {
  185. width: 100%;
  186. }
  187. }
  188. }
  189. </style>