homework.vue 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361
  1. <template>
  2. <view class="homework-container">
  3. <!-- 头部区域 -->
  4. <top-box :timeStamp="timeStamp" />
  5. <view class="module-container">
  6. <view style="margin: 0 20rpx;">
  7. <u-tabs :list="list" :current="current" @change="changeModule"
  8. :activeStyle="{color: '#3c9cff',fontWeight: 'bold',transform: 'scale(1.08)',}"
  9. :inactiveStyle="{fontWeight: 'bold',transform: 'scale(1)'}" lineColor="#3c9cff" lineWidth="60">
  10. </u-tabs>
  11. </view>
  12. <view class="module-box" v-for="(item,index) in pageData" :key="index" v-if="current == index">
  13. <!-- 详情头部卡片 -->
  14. <view class="card" :style="{backgroundColor: `${item.color}`}">
  15. <view class="box">
  16. <view class="flex">
  17. <text class="card-title">今日{{item.name}}数:</text>
  18. <text class="card-title" style="margin-left: 20rpx;">{{item.detail.data.length}}</text>
  19. </view>
  20. <view class="box" style="margin: 10rpx 0 0 0;">
  21. <view class="flex">
  22. <text class="card-subtitle">完成数量:</text>
  23. <text class="card-subtitle" style="margin-left: 20rpx;">{{finishData.length}}</text>
  24. </view>
  25. <view class="flex">
  26. <text class="card-subtitle">完成情况:</text>
  27. <text class="card-subtitle" style="margin-left: 20rpx;">{{item.level}}</text>
  28. </view>
  29. </view>
  30. </view>
  31. <view class="image" :style="{backgroundImage:`url(${item.image})`}"></view>
  32. </view>
  33. <!-- 中间标题 -->
  34. <view class="flex">
  35. <view class="cut-off">{{item.name}}信息</view>
  36. </view>
  37. <!-- 列表 -->
  38. <view class="detail-box" v-if="current == index">
  39. <view class="detail-box-item">
  40. <view class="item-info">
  41. <view class="t-icon t-icon-ceping"></view>
  42. <view class="item-text">近七天完成率</view>
  43. </view>
  44. <!-- 图表部分 -->
  45. <view class="charts-box" v-if="current == 0">
  46. <qiun-data-charts type="fin-area" :chartData="homeworkData.testData" :loadingType="4"
  47. :canvas2d='true' tooltipFormat='HomeworkPercent' canvasId='canvans0980111' />
  48. </view>
  49. <view class="charts-box" v-if="current == 1">
  50. <qiun-data-charts type="fin-area" :chartData="homeworkData.homeworkData" :loadingType="4"
  51. :canvas2d='true' tooltipFormat='HomeworkPercent' canvasId='canvans0933511' />
  52. </view>
  53. <view class="charts-box" v-if="current == 2">
  54. <qiun-data-charts type="fin-area" :chartData="homeworkData.activityData" :loadingType="4"
  55. :canvas2d='true' tooltipFormat='HomeworkPercent' canvasId='canvans0531032' />
  56. </view>
  57. </view>
  58. <!-- 完成列表 -->
  59. <view class="detail-box-item">
  60. <view class="item-info">
  61. <view class="t-icon t-icon-shenhe"></view>
  62. <view class="item-text">今日已完成</view>
  63. <!-- 完成列表展示所有已完成的评测作业和活动信息 -->
  64. </view>
  65. <view style="margin-bottom: 20rpx;">
  66. <view class="block-box" v-for="(item,index) in finishData" :key="index">
  67. <view class="index" style="height: 100rpx;background-color: #00b894;"></view>
  68. <view class="class-block" style="height: 100rpx;width: 90%;">
  69. <view class="block-title">{{item.name}}</view>
  70. <view class="block-subtitle">科目:</view>
  71. <view class="block-tag-box">
  72. <view class="block-tag">{{item.subject}}</view>
  73. </view>
  74. <view class="block-subtitle">布置老师:</view>
  75. <view class="block-tag-box">
  76. <view class="block-tag">{{item.teacher}}</view>
  77. </view>
  78. </view>
  79. </view>
  80. </view>
  81. </view>
  82. <!-- 列表 -->
  83. <view class="detail-box-item">
  84. <view class="item-info">
  85. <view class="t-icon t-icon-daiban"></view>
  86. <view class="item-text">{{item.detail.title}}</view>
  87. <!-- 详情列表展示(评测,活动或者作业)信息 -->
  88. <view style="display: flex; align-items: center;margin: 0 10rpx 0 auto;">
  89. <view class="t-icon t-icon-liebiao" style="width: 30rpx; height: 30rpx;"
  90. @click="navData"></view>
  91. <view class="msg" @click="navData" style="color: #3C9CFF;">详情列表</view>
  92. </view>
  93. </view>
  94. <view style="margin-bottom: 20rpx;">
  95. <view class="block-box" v-for="(i,x) in item.detail.data" :key="x">
  96. <view class="index" style="height: 100rpx;"></view>
  97. <view class="class-block" style="height: 100rpx; width: 90%;">
  98. <view class="block-title">{{i.name}}</view>
  99. <view class="block-tag-box">
  100. <view class="block-tag">{{i.subject}}</view>
  101. </view>
  102. <view class="block-tag-box">
  103. <view class="block-tag">{{i.teacher}}</view>
  104. </view>
  105. <view class="block-subtitle">{{i.description}}</view>
  106. </view>
  107. </view>
  108. </view>
  109. </view>
  110. </view>
  111. </view>
  112. </view>
  113. </view>
  114. </template>
  115. <script>
  116. import {
  117. mapState,
  118. mapMutations
  119. } from 'vuex'
  120. export default {
  121. computed: {
  122. ...mapState('m_chart', ['homeworkData']),
  123. },
  124. data() {
  125. return {
  126. //模块名
  127. list: [{
  128. name: '评测详情'
  129. }, {
  130. name: '作业详情'
  131. }, {
  132. name: '活动详情'
  133. }],
  134. //当前模块
  135. current: 0,
  136. //页面数据内容
  137. pageData: '',
  138. //完成内容
  139. finishData: [],
  140. //历史数据
  141. historyData: {
  142. test: [90, 89, 98, 100, 50, 55, 60],
  143. homework: [10, 29, 38, 60, 50, 88, 100],
  144. activity: [70, 19, 28, 40, 60, 100, 83]
  145. },
  146. //时间戳
  147. timeStamp: '',
  148. };
  149. },
  150. watch: {
  151. current() {
  152. this.getFinishData()
  153. }
  154. },
  155. onLoad(options) {
  156. this.init()
  157. if (options.index)
  158. this.current = options.index
  159. },
  160. //刷新页面
  161. onPullDownRefresh() {
  162. this.init()
  163. setTimeout(function() {
  164. uni.stopPullDownRefresh();
  165. }, 1000);
  166. },
  167. methods: {
  168. ...mapMutations('m_chart', ['updateTestArea', 'updateHomeworkArea', 'updateActivityArea']),
  169. ...mapMutations('m_children', ['updateHomeworkDetail']),
  170. //初始化页面
  171. init() {
  172. this.$getTimeStamp()
  173. this.$initHomework()
  174. this.saveToStudyChart()
  175. this.getLevel()
  176. this.getFinishData()
  177. },
  178. //更改模块
  179. changeModule(index) {
  180. this.current = index.index
  181. },
  182. //获得评判信息
  183. getLevel() {
  184. this.pageData[0].level = this.historyData.test[6] >= 40 ? (this.historyData.test[6] >= 70 ? '优秀' : '良好') :
  185. '较差'
  186. this.pageData[1].level = this.historyData.homework[6] >= 40 ? (this.historyData.homework[6] >= 70 ? '优秀' :
  187. '良好') : '较差'
  188. this.pageData[2].level = this.historyData.activity[6] >= 40 ? (this.historyData.activity[6] >= 70 ? '优秀' :
  189. '良好') : '较差'
  190. },
  191. //获得完成数量
  192. getFinishData() {
  193. if (this.current === 0)
  194. this.finishData = this.pageData[0].detail.data.filter(x => x.finish === true)
  195. if (this.current === 1)
  196. this.finishData = this.pageData[1].detail.data.filter(x => x.finish === true)
  197. if (this.current === 2)
  198. this.finishData = this.pageData[2].detail.data.filter(x => x.finish === true)
  199. },
  200. //记录到图表
  201. saveToStudyChart() {
  202. let temp = {
  203. categories: [],
  204. series: [{
  205. "name": "",
  206. "data": []
  207. }]
  208. }
  209. //时间
  210. temp.categories = this.$getRecentDateArray(7)
  211. //数据
  212. //解除对象指向同一块内存(拷贝)
  213. temp.series[0].data = this.historyData.test
  214. let testDataTemp = JSON.parse(JSON.stringify(temp))
  215. this.updateTestArea(testDataTemp)
  216. temp.series[0].data = this.historyData.homework
  217. let homeworkDataTemp = JSON.parse(JSON.stringify(temp))
  218. this.updateHomeworkArea(homeworkDataTemp)
  219. temp.series[0].data = this.historyData.activity
  220. let activityDataTemp = JSON.parse(JSON.stringify(temp))
  221. this.updateActivityArea(activityDataTemp)
  222. },
  223. //导航到详情页面
  224. navData() {
  225. this.updateHomeworkDetail(this.pageData[this.current].detail.data)
  226. uni.navigateTo({
  227. url: '/subpkg/homeworkdata/homeworkdata'
  228. })
  229. }
  230. }
  231. }
  232. </script>
  233. <style lang="scss">
  234. @import '@/pages/common/blockmsg.scss';
  235. .home-topinfo {
  236. background: linear-gradient($color-yellow, $page-background-color) !important;
  237. }
  238. //模块
  239. .module-container {
  240. margin-top: -70rpx;
  241. //头部卡片
  242. .card {
  243. display: flex;
  244. justify-content: space-around;
  245. margin: 20rpx auto 20rpx auto;
  246. height: 220rpx;
  247. width: 95%;
  248. // background: linear-gradient(to right, #ff95007a,#ff8419);
  249. border-radius: $card-border-radius;
  250. .card-title {
  251. font-size: 48rpx;
  252. font-weight: bold;
  253. color: #FFF;
  254. }
  255. .card-subtitle {
  256. font-size: 28rpx;
  257. color: #FFF;
  258. }
  259. .border-bottom {
  260. height: 10rpx;
  261. width: 100%;
  262. border-radius: $card-border-radius;
  263. background-color: #FFF;
  264. margin: 5rpx 0 5rpx 0;
  265. }
  266. .image {
  267. position: relative;
  268. right: -30rpx;
  269. height: 300rpx;
  270. width: 300rpx;
  271. background-size: 100%;
  272. background-repeat: no-repeat;
  273. z-index: 2;
  274. }
  275. }
  276. //头部卡片
  277. .box {
  278. display: flex;
  279. flex-direction: column;
  280. justify-content: space-around;
  281. margin: 25rpx 0;
  282. }
  283. //中间标题
  284. .cut-off {
  285. font-size: 30rpx;
  286. font-weight: bold;
  287. color: #606266;
  288. margin-left: 40rpx;
  289. }
  290. //列表block
  291. .detail-box {
  292. display: flex;
  293. flex-flow: row wrap;
  294. margin: 20rpx 20rpx 0 20rpx;
  295. justify-content: space-between;
  296. .detail-box-item {
  297. margin: 0 0 4% 0;
  298. width: 100%;
  299. height: auto;
  300. background-color: #FFF;
  301. border-radius: $card-border-radius;
  302. .item-info {
  303. display: flex;
  304. align-items: center;
  305. padding: 20rpx;
  306. .t-icon {
  307. width: 40rpx;
  308. height: 40rpx;
  309. }
  310. .item-text {
  311. font-size: 30rpx;
  312. font-weight: bold;
  313. color: $color-title;
  314. margin-left: 15rpx;
  315. }
  316. }
  317. }
  318. }
  319. }
  320. //图表
  321. .charts-box {
  322. width: 100%;
  323. height: 300rpx;
  324. }
  325. .flex {
  326. display: flex;
  327. align-items: center;
  328. margin-left: 20rpx;
  329. }
  330. .msg {
  331. color: $color-title;
  332. margin-left: 10rpx;
  333. font-size: 28rpx;
  334. }
  335. </style>