homework.vue 9.2 KB

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