todaydata-box.vue 6.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270
  1. <template>
  2. <!-- 今日记录模块 -->
  3. <view class="module-container">
  4. <u-tabs :list="list" :current="current" @change="changeModule"
  5. :activeStyle="{color: '#5b7cff',fontWeight: 'bold',transform: 'scale(1.04)',}"
  6. :inactiveStyle="{fontWeight: 'bold',transform: 'scale(1)'}" lineColor="#5b7cff" lineWidth="60"></u-tabs>
  7. <!-- 记录模块 -->
  8. <view class="module-box" v-if="current == 0">
  9. <view class="module-item" v-for="(item,index) in moduleData" :key="index" :style="item.color"
  10. @click="setTime(index)">
  11. <view class="module-item-box">
  12. <text class="module-item-text">{{item.text}}</text>
  13. <view class="num-box">
  14. <text class="module-item-num">{{item.numData}}</text>
  15. </view>
  16. <view :class="item.icon"></view>
  17. </view>
  18. </view>
  19. </view>
  20. <!-- 记录表 -->
  21. <view class="module-box" v-if="current == 1">
  22. <view class="chart-item" style="width: 100%;">
  23. <view class="chart-info">
  24. <view class="t-icon t-icon-shuju1"></view>
  25. <text class="chart-info-text">近七天学习记录</text>
  26. </view>
  27. <view style=" width:100%; margin-top: -30rpx;">
  28. <qiun-data-charts type="column" :chartData="todayData.studyColumn" :loadingType="4"
  29. tooltipFormat='tooltipHour' :canvas2d="true" canvasId="canvasId9839618" />
  30. </view>
  31. </view>
  32. <view class="chart-item">
  33. <view class="chart-info">
  34. <view class="t-icon t-icon-tiyu"></view>
  35. <text class="chart-info-text">近七天运动</text>
  36. </view>
  37. <view class="chart-view">
  38. <qiun-data-charts type="pie" :chartData="todayData.exercisePie" :loadingType="4"
  39. tooltipFormat='pieMinute' :canvas2d="true" canvasId="canvasId91234111" />
  40. </view>
  41. </view>
  42. <view class="chart-item">
  43. <view class="chart-info">
  44. <view class="t-icon t-icon-yejian"></view>
  45. <text class="chart-info-text">近七天睡眠</text>
  46. </view>
  47. <view class="chart-view">
  48. <qiun-data-charts type="ring" :chartData="todayData.sleepRing" :loadingType="4"
  49. tooltipFormat='tooltipHour' :canvas2d="true" canvasId="canvasId6312231" />
  50. </view>
  51. </view>
  52. </view>
  53. <!-- 时间选择器 -->
  54. <u-picker :show="setTimePicker" :columns="pickerList" ref="uPicker" @confirm="pickerConfirm"
  55. @cancel="pickerCancel" :closeOnClickOverlay="true" :immediateChange="true">
  56. </u-picker>
  57. </view>
  58. </template>
  59. <script>
  60. import {
  61. mapState,
  62. mapMutations
  63. } from 'vuex'
  64. export default {
  65. name: "todaydata-box",
  66. computed: {
  67. ...mapState('m_chart', ['todayData']),
  68. },
  69. data() {
  70. return {
  71. //模块名
  72. list: [{
  73. name: '家庭记录'
  74. }, {
  75. name: '历史记录'
  76. }],
  77. //当前模块
  78. current: 0,
  79. //记录卡片
  80. moduleData: [{
  81. text: '自主学习记录',
  82. color: 'background-color: #5b7cff;',
  83. icon: 't-icon t-icon-bianjibi',
  84. numData: '记录一下',
  85. },
  86. {
  87. text: '娱乐放松记录',
  88. color: 'background-color: #00cca3;',
  89. icon: 't-icon t-icon-leimucuyule',
  90. numData: '记录一下',
  91. },
  92. {
  93. text: '运动锻炼记录',
  94. color: 'background-color: #ff8caf;',
  95. icon: 't-icon t-icon-yundong',
  96. numData: '记录一下',
  97. },
  98. {
  99. text: '每日睡眠记录',
  100. color: 'background-color: #f9c752;',
  101. icon: 't-icon t-icon-a-icon_wananyueliangshuimian',
  102. numData: '记录一下',
  103. }
  104. ],
  105. //当前记录卡片
  106. cardCurrent: 5,
  107. //选择器
  108. setTimePicker: false,
  109. //时间表
  110. pickerList: [
  111. ['0小时', '1小时', '2小时', '3小时', '4小时', '5小时', '6小时', '7小时', '8小时', '9小时', '10小时'],
  112. ['5分钟', '10分钟', '15分钟', '20分钟', '25分钟', '30分钟', '35分钟', '40分钟', '45分钟', '50分钟', '55分钟']
  113. ],
  114. //历史数据
  115. historyData: {
  116. study: [2, 3, 2.5, 3, 2, 1, 3],
  117. rest: [1, 2, 0.5, 3, 0.5, 3.5, 2],
  118. exercise: [],
  119. sleep: []
  120. }
  121. };
  122. },
  123. created() {
  124. this.saveToStudyChart()
  125. },
  126. methods: {
  127. ...mapMutations('m_chart', ['updateStudyColumn', 'updateExercisePie', 'updateSleepRing']),
  128. //更改模块
  129. changeModule(index) {
  130. this.current = index.index
  131. },
  132. //点击卡片唤起picker
  133. setTime(index) {
  134. this.cardCurrent = index
  135. this.setTimePicker = true
  136. },
  137. //确定
  138. pickerConfirm(e) {
  139. if (e.value[0] === '0小时') {
  140. this.moduleData[this.cardCurrent].numData = e.value[1]
  141. } else {
  142. this.moduleData[this.cardCurrent].numData = e.value[0] + e.value[1]
  143. }
  144. uni.$showMsg('记录完成', 1000)
  145. this.setTimePicker = false
  146. },
  147. //取消
  148. pickerCancel() {
  149. uni.$showMsg('取消选择', 1000)
  150. this.setTimePicker = false
  151. },
  152. stringToNum(){
  153. },
  154. //记录到图表
  155. saveToStudyChart() {
  156. let studyColumn = {
  157. categories: [],
  158. series: [{
  159. name: '自主学习',
  160. data: []
  161. }, {
  162. name: '娱乐放松',
  163. data: []
  164. }]
  165. }
  166. //时间
  167. studyColumn.categories = this.$getRecentDateArray()
  168. //数据
  169. studyColumn.series[0].data = this.historyData.study
  170. studyColumn.series[1].data = this.historyData.rest
  171. //存储
  172. this.updateStudyColumn(studyColumn)
  173. }
  174. }
  175. }
  176. </script>
  177. <style lang="scss">
  178. .module-container {
  179. margin: -70rpx 20rpx 0 20rpx;
  180. }
  181. .module-box {
  182. display: flex;
  183. flex-direction: row;
  184. flex-wrap: wrap;
  185. justify-content: space-between;
  186. .module-item {
  187. margin: 2% 0;
  188. display: flex;
  189. flex-direction: column;
  190. background-color: #FFFFFF;
  191. border-radius: $card-border-radius;
  192. width: 48%;
  193. height: auto;
  194. overflow: hidden;
  195. .module-item-box {
  196. padding: 35rpx;
  197. width: 100%;
  198. display: flex;
  199. flex-direction: column;
  200. .t-icon {
  201. width: 250rpx;
  202. height: 250rpx;
  203. margin: -250rpx 0 0 150rpx;
  204. z-index: 1;
  205. }
  206. }
  207. }
  208. }
  209. .module-item-text {
  210. color: #FFF;
  211. font-size: 28rpx;
  212. font-weight: bold;
  213. z-index: 5;
  214. }
  215. .num-box {
  216. margin-top: 20rpx;
  217. z-index: 5;
  218. .module-item-num {
  219. color: #FFF;
  220. font-size: 42rpx;
  221. font-weight: bold;
  222. }
  223. }
  224. .chart-item {
  225. margin: 2% 0;
  226. display: flex;
  227. flex-direction: column;
  228. justify-content: space-between;
  229. background-color: #FFF;
  230. // box-shadow: 0 4rpx 8rpx rgba(0, 0, 0, 0.05);
  231. border-radius: $card-border-radius;
  232. width: 48%;
  233. height: auto;
  234. .chart-info {
  235. display: flex;
  236. align-items: center;
  237. padding: 20rpx;
  238. .chart-info-text {
  239. font-size: 30rpx;
  240. font-weight: bold;
  241. color: #3B4144;
  242. margin-left: 10rpx;
  243. }
  244. }
  245. .chart-view {
  246. height: 300rpx;
  247. }
  248. }
  249. </style>