homework.vue 9.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372
  1. <template>
  2. <view class="homework-container">
  3. <!-- 头部区域 -->
  4. <top-box :timeStamp="timeStamp"></top-box>
  5. <view class="module-container">
  6. <view style="margin: 0 20rpx;">
  7. <u-tabs :list="list" :current="current" @change="changeModule"
  8. :activeStyle="{color: '#5b7cff',fontWeight: 'bold',transform: 'scale(1.04)',}"
  9. :inactiveStyle="{fontWeight: 'bold',transform: 'scale(1)'}" lineColor="#5b7cff" lineWidth="60">
  10. </u-tabs>
  11. </view>
  12. <!-- 详情头部卡片 -->
  13. <view class="module-box" v-for="(item,index) in card" :key="index" v-if="current == index">
  14. <view class="card" :style="{backgroundColor: `${item.color}`}">
  15. <view style="display: flex; flex-direction: column;">
  16. <text class="card-title">{{item.title}}{{item.num}}</text>
  17. <text class="card-subtitle">{{item.subtitle}}{{item.finish}}</text>
  18. <text class="card-subtitle">完成情况: {{item.level}}</text>
  19. </view>
  20. <view class="image" :style="{backgroundImage:`url(${item.image})`}"></view>
  21. </view>
  22. <view style="display: flex; align-items: center;">
  23. <view class="cut-off">{{item.detail.nav}}</view>
  24. <!-- <u-button text="获得报表" :plain="true" :hairline="true" shape="circle" size="small"></u-button> -->
  25. </view>
  26. <view class="detail-box" v-if="current == index">
  27. <view class="detail-box-item">
  28. <view class="item-info">
  29. <view class="t-icon t-icon-ceping"></view>
  30. <view class="item-text">近五天完成率</view>
  31. </view>
  32. <view class="charts-box" v-if="current == 0">
  33. <qiun-data-charts type="fin-column" :chartData="homeworkData.testData" :loadingType="4"
  34. :canvas2d='true' tooltipFormat='tooltipPercent' canvasId='canvans0980111' />
  35. </view>
  36. <view class="charts-box" v-if="current == 1">
  37. <qiun-data-charts type="fin-column" :chartData="homeworkData.homeworkData" :loadingType="4"
  38. :canvas2d='true' tooltipFormat='tooltipPercent' canvasId='canvans0933511' />
  39. </view>
  40. <view class="charts-box" v-if="current == 2">
  41. <qiun-data-charts type="fin-column" :chartData="homeworkData.activityData" :loadingType="4"
  42. :canvas2d='true' tooltipFormat='tooltipPercent' canvasId='canvans0531032' />
  43. </view>
  44. </view>
  45. <view class="detail-box-item">
  46. <view class="item-info">
  47. <view class="t-icon t-icon-shenhe"></view>
  48. <view class="item-text">今日已完成</view>
  49. </view>
  50. <u-list>
  51. <u-list-item>
  52. <u-cell :title="`列表长度-${index + 1}`"></u-cell>
  53. <u-cell :title="`列表长度-${index + 1}`"></u-cell>
  54. <u-cell :title="`列表长度-${index + 1}`"></u-cell>
  55. </u-list-item>
  56. </u-list>
  57. </view>
  58. <view class="detail-box-item" style="height: 100%;">
  59. <view class="item-info">
  60. <view class="t-icon t-icon-daiban"></view>
  61. <view class="item-text">{{item.detail.title}}</view>
  62. </view>
  63. <u-swipe-action v-for="(msg,i) in item.detail.data" :key="i">
  64. <u-swipe-action-item :options="options1">
  65. <view class="swipe-action u-border-top u-border-bottom">
  66. <view class="swipe-action__content">
  67. <text class="swipe-action__content__text">{{msg.name}}</text>
  68. </view>
  69. </view>
  70. </u-swipe-action-item>
  71. </u-swipe-action>
  72. </view>
  73. </view>
  74. </view>
  75. </view>
  76. </view>
  77. </template>
  78. <script>
  79. import {
  80. mapState,
  81. mapMutations
  82. } from 'vuex'
  83. export default {
  84. computed: {
  85. ...mapState('m_chart', ['homeworkData', 'todayData']),
  86. },
  87. data() {
  88. return {
  89. //模块名
  90. list: [{
  91. name: '评测详情'
  92. }, {
  93. name: '作业详情'
  94. }, {
  95. name: '活动详情'
  96. }],
  97. //当前模块
  98. current: 0,
  99. //时间戳
  100. timeStamp: '',
  101. //卡片内容
  102. card: [{
  103. title: '今日评测数:' + '\xa0\xa0\xa0',
  104. num: 5,
  105. subtitle: '评测已完成:' + '\xa0\xa0\xa0',
  106. finish: 3,
  107. level: '良好',
  108. color: '#0080ff;',
  109. image: 'https://ouch-cdn2.icons8.com/gpV8ZT40juL5H5uR0cv7ptJaV0vbUu64ANLmkch6cr4/rs:fit:1289:912/czM6Ly9pY29uczgu/b3VjaC1wcm9kLmFz/c2V0cy9zdmcvNTE3/L2M0Zjg4MDUzLTMx/ZDUtNDlhZS05M2Nj/LWU4YWM3YTNjODAx/My5zdmc.png',
  110. detail: {
  111. nav: '评测信息',
  112. title: '评测列表',
  113. data: [{
  114. name: '评测数据1'
  115. }, {
  116. name: '评测数据2'
  117. }, {
  118. name: '评测数据3'
  119. }, {
  120. name: '评测数据4'
  121. }, {
  122. name: '评测数据5'
  123. }
  124. ]
  125. }
  126. }, {
  127. title: '今日作业数:' + '\xa0\xa0\xa0',
  128. num: 3,
  129. subtitle: '作业已完成:' + '\xa0\xa0\xa0',
  130. finish: 3,
  131. level: '完美',
  132. color: '#ff8caf;',
  133. image: 'https://ouch-cdn2.icons8.com/XuAMXajgkDqsOY7cp6uY1LQivtTxahNZjWM1Qk2bfoY/rs:fit:1216:912/czM6Ly9pY29uczgu/b3VjaC1wcm9kLmFz/c2V0cy9zdmcvMzE4/LzdjYTU2NDM4LTc4/MTktNDVhNi1hMjZh/LTMyZWE5NDE4YzI5/My5zdmc.png',
  134. detail: {
  135. nav: '作业信息',
  136. title: '作业列表',
  137. data: [{
  138. name: '作业数据1'
  139. }, {
  140. name: '作业数据2'
  141. }, {
  142. name: '作业数据3'
  143. }
  144. ]
  145. }
  146. }, {
  147. title: '今日活动数:' + '\xa0\xa0\xa0',
  148. num: 6,
  149. subtitle: '活动已完成:' + '\xa0\xa0\xa0',
  150. finish: 5,
  151. level: '优秀',
  152. color: '#f9c752;',
  153. image: 'https://ouch-cdn2.icons8.com/xrmiKHmKAqKegMFWYXXUHk6mqTXXTqoU0wsTFULoboQ/rs:fit:1002:912/czM6Ly9pY29uczgu/b3VjaC1wcm9kLmFz/c2V0cy9zdmcvNzcy/LzczYWVmZjhkLTk4/N2ItNDI2Ny04NmNk/LTA1NTI4YjhiMTIw/Ni5zdmc.png',
  154. detail: {
  155. nav: '活动信息',
  156. title: '活动列表',
  157. data: [{
  158. name: '活动数据1'
  159. }, {
  160. name: '活动数据2'
  161. }, {
  162. name: '活动数据3'
  163. }, {
  164. name: '活动数据4'
  165. }, {
  166. name: '活动数据5'
  167. }, {
  168. name: '活动数据6'
  169. }
  170. ]
  171. }
  172. }],
  173. //历史数据
  174. historyData: {
  175. test: [90, 89, 98, 100, 50],
  176. homework: [10, 29, 38, 60, 50],
  177. activity: [70, 19, 28, 40, 60]
  178. },
  179. options1: [{
  180. text: '待办',
  181. style: {
  182. backgroundColor: '#3c9cff'
  183. }
  184. }, {
  185. text: '删除',
  186. style: {
  187. backgroundColor: '#f56c6c'
  188. }
  189. }],
  190. };
  191. },
  192. onLoad() {
  193. this.$getTimeStamp()
  194. this.saveToStudyChart()
  195. },
  196. //刷新页面
  197. onPullDownRefresh() {
  198. this.$getTimeStamp()
  199. console.log('refresh');
  200. setTimeout(function() {
  201. uni.stopPullDownRefresh();
  202. }, 1000);
  203. },
  204. methods: {
  205. ...mapMutations('m_chart', ['updateTestColumn', 'updateHomeworkColumn', 'updateActivityColumn']),
  206. //更改模块
  207. changeModule(index) {
  208. this.current = index.index
  209. },
  210. //记录到图表
  211. saveToStudyChart() {
  212. let temp = {
  213. categories: [],
  214. series: [{
  215. "name": "",
  216. "data": []
  217. }]
  218. }
  219. //时间
  220. temp.categories = this.$getRecentDateArray(5)
  221. //数据
  222. //解除对象指向同一块内存(拷贝)
  223. temp.series[0].data = this.historyData.test
  224. let testDataTemp = JSON.parse(JSON.stringify(temp))
  225. this.updateTestColumn(testDataTemp)
  226. temp.series[0].data = this.historyData.homework
  227. let homeworkDataTemp = JSON.parse(JSON.stringify(temp))
  228. this.updateHomeworkColumn(homeworkDataTemp)
  229. temp.series[0].data = this.historyData.activity
  230. let activityDataTemp = JSON.parse(JSON.stringify(temp))
  231. this.updateActivityColumn(activityDataTemp)
  232. }
  233. }
  234. }
  235. </script>
  236. <style lang="scss">
  237. .homework-container {
  238. .home-topinfo {
  239. background: linear-gradient($color-green, $page-background-color) !important;
  240. }
  241. }
  242. .module-container {
  243. margin-top: -70rpx;
  244. .card {
  245. display: flex;
  246. justify-content: space-around;
  247. margin: 20rpx auto 20rpx auto;
  248. height: 250rpx;
  249. width: 96%;
  250. // background: linear-gradient(to right, #ff95007a,#ff8419);
  251. border-radius: $card-border-radius;
  252. .card-title {
  253. margin: 30rpx 0 20rpx 20rpx;
  254. font-size: 45rpx;
  255. font-weight: bold;
  256. color: #FFF;
  257. }
  258. .card-subtitle {
  259. margin: 10rpx 20rpx;
  260. font-size: 30rpx;
  261. font-weight: bold;
  262. color: #FFF;
  263. }
  264. .image {
  265. position: relative;
  266. top: -40rpx;
  267. right: -30rpx;
  268. height: 300rpx;
  269. width: 300rpx;
  270. background-size: contain;
  271. background-repeat: no-repeat;
  272. z-index: 2;
  273. }
  274. }
  275. .cut-off {
  276. font-size: 35rpx;
  277. font-weight: bold;
  278. color: #606266;
  279. margin-left: 40rpx;
  280. }
  281. .detail-box {
  282. display: flex;
  283. flex-flow: column wrap;
  284. justify-content: space-between;
  285. margin: 20rpx 0 20rpx 0;
  286. height: 700rpx;
  287. width: 100%;
  288. .detail-box-item {
  289. margin: 0 2%;
  290. height: 48%;
  291. width: 46%;
  292. background-color: #FFF;
  293. border-radius: $card-border-radius;
  294. .item-info {
  295. display: flex;
  296. align-items: center;
  297. padding: 10rpx;
  298. .t-icon {
  299. width: 40rpx;
  300. height: 40rpx;
  301. }
  302. .item-text {
  303. font-size: 30rpx;
  304. font-weight: bold;
  305. color: #3B4144;
  306. margin-left: 10rpx;
  307. }
  308. }
  309. }
  310. }
  311. }
  312. .charts-box {
  313. width: 100%;
  314. height: 250rpx;
  315. margin-bottom: 20rpx;
  316. }
  317. .t-icon {
  318. margin: 20rpx;
  319. width: 110rpx;
  320. height: 110rpx;
  321. }
  322. .u-page {
  323. padding: 0;
  324. }
  325. .u-demo-block__title {
  326. padding: 10px 0 2px 15px;
  327. }
  328. .swipe-action {
  329. &__content {
  330. padding: 25rpx 0;
  331. &__text {
  332. font-size: 15px;
  333. color: $u-main-color;
  334. padding-left: 30rpx;
  335. }
  336. }
  337. }
  338. </style>