index.vue 6.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211
  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. this.date_num = current_month
  84. this.getDailyRecord()
  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. }
  96. })
  97. },
  98. // 获取每日一练试卷日历打卡记录
  99. getDailyRecord() {
  100. this.$http({
  101. url: '/bank/question/get/special/record',
  102. method: 'get',
  103. data: {
  104. goodsId: this.goodsId,
  105. // chapterExamId: this.dayExamDetail.chapterExamId || 0,
  106. // moduleExamId: this.dayExamDetail.moduleExamId || 0,
  107. // examId: this.dayExamDetail.examId,
  108. }
  109. }).then((res) => {
  110. if (res.data.code == 200) {
  111. let data = res.data.data || []
  112. this.dayRecordList = data.map((item) => {
  113. let day = 0
  114. if (item.recordTime) {
  115. day = new Date(item.recordTime * 1000).getDate()
  116. }
  117. return {
  118. ...item,
  119. day: day
  120. }
  121. })
  122. if (this.dayRecordList.length) {
  123. this.date_num.forEach((item, index) => {
  124. let findV = this.dayRecordList.find(e => e.day == item.date)
  125. if (findV) {
  126. this.$set(this.date_num[index], 'sign', true)
  127. } else {
  128. this.$set(this.date_num[index], 'sign', false)
  129. }
  130. })
  131. }
  132. console.log('this.dayRecordList', this.dayRecordList, this.date_num);
  133. }
  134. })
  135. },
  136. goPractice() {
  137. const { examId, moduleExamId = 0, chapterExamId = 0 } = this.dayExamDetail
  138. uni.navigateTo({
  139. url:'/pages2/bank/questionBank?orderGoodsId='+ this.orderGoodsId + '&id=' + examId + '&goodsid=' + this.goodsId
  140. +'&moduleId=' + moduleExamId + '&chapterId=' + chapterExamId + '&entryType=daily'
  141. })
  142. },
  143. },
  144. }
  145. </script>
  146. <style lang="scss">
  147. .daily_practice {
  148. width: 100%;
  149. padding: 32rpx;
  150. }
  151. .contents {
  152. .toPractice {
  153. width: 600rpx;
  154. height: 100rpx;
  155. line-height: 100rpx;
  156. text-align: center;
  157. font-size: 32rpx;
  158. color: #222;
  159. border: 2rpx solid #666;
  160. }
  161. }
  162. .punch_calendar {
  163. width: 100%;
  164. background: #ffffff;
  165. box-shadow: 0rpx 0rpx 16rpx 4rpx rgba(47, 67, 121, 0.1);
  166. border-radius: 22rpx;
  167. margin-top: 16rpx;
  168. padding-bottom: 15rpx;
  169. .card_box {
  170. height: 60rpx;
  171. line-height: 60rpx;
  172. // margin-left: 20rpx;
  173. text-align: center;
  174. }
  175. .t1 {
  176. color: #007AFF;
  177. font-size: 24rpx;
  178. }
  179. .weeks {
  180. width: 100%;
  181. display: flex;
  182. justify-content:center;
  183. margin-top: 20rpx;
  184. }
  185. .card_date {
  186. width: 14%;
  187. text-align: center;
  188. color: #7f8caf;
  189. }
  190. .day_dailys {
  191. width: 100%;
  192. display: flex;
  193. margin-top: 40rpx;
  194. flex-wrap: wrap;
  195. }
  196. .date_num {
  197. width: 14%;
  198. text-align: center;
  199. position: relative;
  200. display: inline-block;
  201. margin-top: 20rpx;
  202. .items {
  203. width: 100%;
  204. }
  205. }
  206. }
  207. </style>