record.vue 6.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228
  1. <template>
  2. <view class="report_content">
  3. <view class="header">
  4. <view class="header_content">
  5. <view class="title">本次{{ type == "exam" ? "测评" : "学习" }}概览</view>
  6. <view class="content">
  7. <view class="content_row">
  8. <view class="main">{{ type == "exam" ? formatTime(reportInfo.exam_time) : formatTime(reportInfo.video_lasttime - reportInfo.video_inittime) }}</view>
  9. <view class="tip">学习时长</view>
  10. </view>
  11. <view class="content_row">
  12. <view class="main">{{ reportInfo.isanswer_total + "/" + reportInfo.answer_total }}</view>
  13. <view class="tip">答对题目</view>
  14. </view>
  15. <view class="content_row">
  16. <view class="main">{{ reportInfo.get_score }}</view>
  17. <view class="tip">获得积分</view>
  18. </view>
  19. </view>
  20. </view>
  21. </view>
  22. <view class="content">
  23. <view class="title">答题情况</view>
  24. <view class="content_list">
  25. <view class="conent_main" v-for="(item, index) in queston_list" :key="index">
  26. <view class="item_num">
  27. <view class="item_answer"><icon :type="item.is_answer == 0 ? 'cancel' : 'success'" size="20" /> &nbsp;第{{ index + 1 }}题</view>
  28. <view :style="item.get_score > 0 ? 'color:green' : 'color:red'">+{{ item.get_score }}&nbsp;积分</view>
  29. </view>
  30. <view class="item_title">{{ item.question_title }}</view>
  31. </view>
  32. </view>
  33. </view>
  34. <view class="bottom_btn">
  35. <view class="submit_btn defult" @click="_backList">返回课程列表</view>
  36. <view class="submit_btn" @click="_continue">{{ type == "exam" ? "重新练习" : "继续课后评测" }}</view>
  37. </view>
  38. </view>
  39. </template>
  40. <script>
  41. export default {
  42. data() {
  43. return {
  44. reportInfo: {
  45. exam_time: 0,
  46. isanswer_total: 0,
  47. answer_total: 0,
  48. get_score: 0,
  49. },
  50. queston_list: [],
  51. record_id: null,
  52. type: null, // 确保 type 在 data 中定义
  53. };
  54. },
  55. onLoad(params) {
  56. console.log("params:", params); // 获取到query参数
  57. this.record_id = params.record_id;
  58. this.type = params.type;
  59. //分享按钮
  60. uni.showShareMenu({
  61. withShareTicket: true,
  62. menus: ["shareAppMessage", "shareTimeline"],
  63. });
  64. },
  65. onShow() {
  66. this._getRecord(this.type);
  67. this._getAnswerList(this.type);
  68. },
  69. onShareAppMessage(obj) {
  70. return {
  71. title: `999智控终端平台\n学习报告`,
  72. path: `/pages/video/record?type=${this.type}&record_id=${this.record_id}`,
  73. };
  74. },
  75. methods: {
  76. _backList() {
  77. uni.redirectTo({
  78. url: `/pages/video/index`,
  79. });
  80. },
  81. _continue() {
  82. uni.redirectTo({
  83. url: `/pages/video/exam?id=${this.reportInfo.course_id}`,
  84. });
  85. },
  86. _getRecord(type) {
  87. this.$http
  88. .request(`api/video_${type}_record/get_report`, {
  89. record_id: this.record_id,
  90. })
  91. .then((re) => {
  92. if (re.code == "success") {
  93. console.log(re.data);
  94. this.reportInfo = re.data;
  95. }
  96. });
  97. },
  98. _getAnswerList(type) {
  99. this.$http
  100. .request(`api/video_${type}_answer/get_list`, {
  101. record_id: this.record_id,
  102. })
  103. .then((re) => {
  104. if (re.code == "success") {
  105. console.log(re.data);
  106. this.queston_list = re.data;
  107. }
  108. });
  109. },
  110. formatTime(seconds) {
  111. const minutes = Math.floor(seconds / 60);
  112. const remainingSeconds = seconds % 60;
  113. return `${String(minutes).padStart(2, "0")}:${String(remainingSeconds).padStart(2, "0")}`;
  114. },
  115. },
  116. };
  117. </script>
  118. <style lang="less" scoped>
  119. .report_content {
  120. .header {
  121. width: 100vw;
  122. padding: 36rpx;
  123. box-sizing: border-box;
  124. .header_content {
  125. height: 360rpx;
  126. width: 100%;
  127. background: linear-gradient(to bottom right, #6765f1, #a556f7);
  128. border-radius: 20rpx;
  129. color: #fff;
  130. padding: 36rpx;
  131. box-sizing: border-box;
  132. .content {
  133. height: calc(100% - 55rpx);
  134. display: flex;
  135. align-items: center;
  136. justify-content: space-between;
  137. .content_row {
  138. display: flex;
  139. flex-direction: column;
  140. align-items: center;
  141. .main {
  142. font-size: 52rpx;
  143. font-weight: bold;
  144. margin-bottom: 20rpx;
  145. }
  146. .tip {
  147. color: #bba6ff;
  148. font-size: 28rpx;
  149. }
  150. }
  151. }
  152. }
  153. }
  154. > .content {
  155. width: 100vw;
  156. padding: 36rpx;
  157. box-sizing: border-box;
  158. > .title {
  159. font-size: 32rpx;
  160. font-weight: bold;
  161. margin-bottom: 36rpx;
  162. }
  163. > .content_list {
  164. width: 100%;
  165. height: calc(100vh - 750rpx);
  166. overflow: auto;
  167. box-sizing: border-box;
  168. display: flex;
  169. flex-direction: column;
  170. gap: 20rpx;
  171. .conent_main {
  172. border: 1px solid #ddd;
  173. box-shadow: 0 2px 4px 0 rgba(204, 204, 204, 0.5); /* 添加背景阴影 */
  174. width: 100%;
  175. padding: 20rpx;
  176. box-sizing: border-box;
  177. border-radius: 6rpx;
  178. display: flex;
  179. flex-direction: column;
  180. gap: 20rpx;
  181. .item_num {
  182. display: flex;
  183. justify-content: space-between;
  184. align-items: center;
  185. }
  186. .item_answer {
  187. display: flex;
  188. align-items: center;
  189. }
  190. }
  191. }
  192. }
  193. .bottom_btn {
  194. position: fixed;
  195. bottom: 0;
  196. left: 0;
  197. width: 100%;
  198. height: 150rpx;
  199. border-top: 4rpx solid #ddd;
  200. display: flex;
  201. align-items: center;
  202. justify-content: space-between;
  203. padding: 0 40rpx;
  204. box-sizing: border-box;
  205. .answer_info {
  206. display: flex;
  207. align-items: baseline;
  208. }
  209. .submit_btn {
  210. background-color: #5045e6;
  211. color: #fff;
  212. font-size: 28rpx;
  213. width: 45%;
  214. height: 80rpx;
  215. line-height: 80rpx;
  216. border-radius: 8rpx;
  217. box-shadow: 2rpx 2rpx 8rpx rgba(0, 0, 0, 0.1);
  218. text-align: center;
  219. &.defult {
  220. background-color: #fff;
  221. color: #333;
  222. }
  223. }
  224. }
  225. }
  226. </style>