tab_swap.vue 9.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277
  1. <template>
  2. <view class="page_view">
  3. <!-- 统计 -->
  4. <view class="bg1">
  5. <view class="circle_line1"></view>
  6. <view class="circle_line2"></view>
  7. <view class="circle_line3"></view>
  8. <top-info :timeStamp="timeStamp"></top-info>
  9. <scroll-view class="scroll_view" scroll-x="true" :scroll-with-animation="true" scroll-left="0">
  10. <view class="view_box">
  11. <view class="scroll_view_item" v-for="(item,index) in cardList" :key="index" @click="navSwapStats">
  12. <view class="card_info">
  13. <view :class="item.icon"></view>
  14. <view class="title">{{item.title}}</view>
  15. </view>
  16. <view class="chart_box">
  17. <qiun-data-charts :type="item.type" :chartData="item.data" :opts="{legend:{show: false}}" />
  18. </view>
  19. </view>
  20. </view>
  21. </scroll-view>
  22. </view>
  23. <!-- 统计卡片 -->
  24. <view class="card_view">
  25. <view class="total_card" style="background-color:#FF6D31">
  26. <view class="flex_cloumn" style="justify-content: space-around;margin: 20rpx 0 20rpx 20rpx;">
  27. <view class="flex_baseline">
  28. <text class="_title">今日活动</text>
  29. <text class="_title" style="margin-left: 20rpx;">{{swapData.length}}</text>
  30. <text class="_unit">例</text>
  31. </view>
  32. <view class="flex_baseline">
  33. <text class="_subtitle">已完成</text>
  34. <text class="_subtitle" style="margin-left: 20rpx;">{{finishData.length}}</text>
  35. <text class="_unit">例</text>
  36. </view>
  37. <view class="flex_baseline">
  38. <text class="_subtitle">完成情况</text>
  39. <text class="_subtitle" style="margin-left: 20rpx;">{{performance}}</text>
  40. </view>
  41. </view>
  42. <view class="image" :style="{backgroundImage:`url(${image})`}"></view>
  43. </view>
  44. <!-- 列表卡片 -->
  45. <view class="card_item" style="width: 100%;">
  46. <view class="card_title">
  47. <view class="front_tag"></view>
  48. <view class="title">今日活动</view>
  49. <view class="flex_row" style="margin: 0 0 0 auto;" @click="navSwapList" v-if="swapData.length != 0">
  50. <view class="t-icon t-icon-fenlei"></view>
  51. <view class="title" style="color: #4169E1;margin-left: 10rpx;">活动列表</view>
  52. </view>
  53. </view>
  54. <view class="class_list">
  55. <view class="class_item" :style="{borderImage: none}" v-for="(item,index) in swapData" :key="index" @click="navSwapData(index)" v-if="swapData.length != 0">
  56. <view class="flex_row" style="margin: 0 20rpx;">
  57. <view class="t-icon t-icon-swapfont" style="width: 60rpx; height: 60rpx;"></view>
  58. <view class="flex_cloumn">
  59. <view class="flex_row">
  60. <view class="class_item_title">{{item.survey.name || item.vote.name}}</view>
  61. <view class="tag_fill" style="background-color: #FF6D31;">
  62. <view class="tag_text">
  63. {{item.survey.scope === 'private' ? '个人':'学校' || item.vote.scope === 'private' ? '个人':'学校'}}
  64. </view>
  65. </view>
  66. <view class="tag_fill"
  67. :style="{backgroundColor: item.survey.progress === 'finish' || item.vote.progress === 'finish'? '#23b46c':'#ff5959'}">
  68. <view class="tag_text">
  69. {{item.survey.progress === 'finish' || item.vote.progress === 'finish' ? '已完成' : '进行中'}}
  70. </view>
  71. </view>
  72. </view>
  73. <view class="flex_row"
  74. style="width:510rpx;overflow: hidden;white-space: nowrap;text-overflow: ellipsis">
  75. <view class="class_item_subtitle" style="font-size: 26rpx;font-weight: 400;">
  76. {{item.vote.description || item.survey.description}}
  77. </view>
  78. </view>
  79. </view>
  80. </view>
  81. </view>
  82. <view class="image_box" v-if="swapData.length === 0">
  83. <view class="detail_image_none" :style="{backgroundImage:`url(${image1})`}"></view>
  84. <view class="subtitle">今日暂无投票问卷活动</view>
  85. </view>
  86. </view>
  87. </view>
  88. <view class="flex_cloumn" style="margin: 15rpx 0 10rpx 20rpx;">
  89. <view class="title" style="font-size: 32rpx;">家校互动</view>
  90. <view class="bottom_tag"></view>
  91. </view>
  92. <view class="flex_row" style="width: 70%;"></view>
  93. </view>
  94. <scroll-view class="scroll_view_bottom" scroll-x="true" :scroll-with-animation="true" scroll-left="0">
  95. <view class="_item">
  96. <view class="_item_inner"></view>
  97. </view>
  98. <view class="_item"></view>
  99. <view class="_item"></view>
  100. <view class="_item"></view>
  101. <view class="_item"></view>
  102. </scroll-view>
  103. </view>
  104. </template>
  105. <script>
  106. import {
  107. mapState,
  108. mapMutations
  109. } from 'vuex'
  110. export default {
  111. computed: {
  112. ...mapState('m_children', ['swapData']),
  113. ...mapState('m_parent', ['childDailyData'])
  114. },
  115. data() {
  116. return {
  117. //图表卡片列表
  118. cardList: [{
  119. icon: 't-icon t-icon-zoushi1',
  120. title: '近期学习对比',
  121. type: 'mini-column',
  122. data: '',
  123. }, {
  124. icon: 't-icon t-icon-lishijilu',
  125. title: '近期运动记录',
  126. type: 'pie',
  127. data: '',
  128. }, {
  129. icon: 't-icon t-icon-naozhong',
  130. title: '近期睡眠记录',
  131. type: 'ring',
  132. data: '',
  133. }],
  134. image: 'https://ouch-cdn2.icons8.com/LW70TMgW1cGfYeGNSTEp7__kiKVgIhwdZwUmykdLYMY/rs:fit:912:912/czM6Ly9pY29uczgu/b3VjaC1wcm9kLmFz/c2V0cy9wbmcvOTI0/LzU3MWU4ZDZkLTg0/NzEtNGM5YS04MDJk/LTEzNTM5YmZmZTM2/YS5wbmc.png',
  135. //完成情况
  136. performance: '',
  137. //完成数据
  138. finishData: '',
  139. finishRate: '',
  140. timeStamp: '',
  141. image1: 'https://image.meiye.art/pic_1631411820764Vm5iw82gnV2lVKWRokFmU'
  142. };
  143. },
  144. onLoad() {
  145. this.init()
  146. },
  147. //刷新页面
  148. onPullDownRefresh() {
  149. this.init()
  150. setTimeout(function() {
  151. uni.stopPullDownRefresh();
  152. }, 1000);
  153. },
  154. methods: {
  155. ...mapMutations('m_chart', ['updateSwapChartData']),
  156. //初始化
  157. init() {
  158. this.timeStamp = (new Date()).format("hh:mm")
  159. this.getPerformance()
  160. this.$initSwap()
  161. this.getSwapChartData()
  162. },
  163. //获得统计图表信息
  164. getSwapChartData() {
  165. let recentDate = this.$getRecentDateArray(this.childDailyData.study.length);
  166. let swapChartData = [];
  167. let studyColumn = {
  168. categories: recentDate,
  169. series: [{
  170. name: '自主学习',
  171. data: this.childDailyData.study
  172. },
  173. {
  174. name: '娱乐放松',
  175. data: this.childDailyData.rest
  176. }
  177. ]
  178. };
  179. //运动记录表
  180. let exercisePie = {
  181. series: [{
  182. data: [{}, {}, {}, {}, {}, {}, {}]
  183. }]
  184. };
  185. //睡眠记录表
  186. let sleepRing = {
  187. series: [{
  188. data: [{}, {}, {}, {}, {}, {}, {}]
  189. }]
  190. };
  191. studyColumn.categories.forEach((value, index) => {
  192. exercisePie.series[0].data[index].name = value;
  193. exercisePie.series[0].data[index].value = parseFloat((this.childDailyData.exercise[index]));
  194. sleepRing.series[0].data[index].name = value;
  195. sleepRing.series[0].data[index].value = this.childDailyData.sleep[index];
  196. });
  197. swapChartData.push(studyColumn);
  198. swapChartData.push(exercisePie);
  199. swapChartData.push(sleepRing);
  200. this.updateSwapChartData(swapChartData)
  201. this.cardList[0].data = studyColumn
  202. this.cardList[1].data = exercisePie
  203. this.cardList[2].data = sleepRing
  204. },
  205. //获得评判信息
  206. getPerformance() {
  207. if (this.swapData.length != 0) {
  208. this.finishData = this.swapData.filter(x => x.vote && x.vote.progress === 'finish')
  209. this.finishData.push(...this.swapData.filter(x => x.survey && x.survey.progress === 'finish'))
  210. this.finishRate = (this.finishData.length * 100 / this.swapData.length).toFixed(0)
  211. this.performance = this.finishData.length / this.swapData.length >= 0.4 ?
  212. (this.finishData.length / this.swapData.length >= 0.7 ? '优秀' : '良好') : '较差'
  213. } else {
  214. this.finishData = []
  215. this.finishRate = 0
  216. this.performance = '无活动'
  217. }
  218. },
  219. navSwapStats() {
  220. uni.navigateTo({
  221. url: '/subpkg/swap/swapstats'
  222. })
  223. },
  224. navSwapList() {
  225. let value = this.finishRate
  226. uni.navigateTo({
  227. url: `/subpkg/datalist/swaplist?value=${value}`
  228. })
  229. },
  230. navSwapData(index) {
  231. uni.navigateTo({
  232. url: `/subpkg/datalist/swapdata?index=${index}`
  233. })
  234. }
  235. }
  236. }
  237. </script>
  238. <style lang="scss">
  239. @import '@/pages/style/tab_pages.scss';
  240. .bg1 {
  241. background-color: $color-orange;
  242. }
  243. .flex_row {
  244. margin: 5rpx 20rpx;
  245. }
  246. .tag_fill {
  247. background-color: $color-orange;
  248. margin-left: 20rpx;
  249. }
  250. .circle_line1 {
  251. background-image: linear-gradient(to right, #FF6D31, #FF6D31), linear-gradient(90deg, #FFF -50%, rgba(255, 255, 255, 0.0));
  252. }
  253. .circle_line2 {
  254. background-image: linear-gradient(to right, #FF6D31, #FF6D31), linear-gradient(180deg, #FFF -50%, rgba(255, 255, 255, 0.0));
  255. }
  256. .circle_line3 {
  257. background-image: linear-gradient(to right, #FF6D31, #FF6D31), linear-gradient(0deg, #FFF -50%, rgba(255, 255, 255, 0.0));
  258. }
  259. ._item{
  260. background-color: #ccc;
  261. background-image: radial-gradient(#fff 50%, transparent 50%);
  262. background-position: -5px -5px;
  263. background-repeat: repeat;
  264. background-size: 10px 10px;
  265. padding: 5px;
  266. ._item_inner{
  267. background-color: #ccc;
  268. }
  269. }
  270. </style>