todaydata-box.vue 5.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213
  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. <u-picker :show="setTimePicker" :columns="pickerList" ref="uPicker" @confirm="pickerConfirm"
  22. @cancel="pickerCancel" :closeOnClickOverlay="true" @change="changeHandler" :immediateChange="true"></u-picker>
  23. <!-- 记录表 -->
  24. <view class="module-box" v-if="current == 1">
  25. <view class="card-item" style="width: 710rpx;">
  26. <view class="card-info">
  27. <view class="t-icon t-icon-jiaoshidaka"></view>
  28. <text class="info-text">近七天学习记录</text>
  29. </view>
  30. <view style=" width:100%; 500rpx; margin-top: -30rpx;">
  31. <qiun-data-charts type="column" :chartData="todayData.studyColumn" :loadingType="4"
  32. :opts="{dataLabel:false}" tooltipFormat='tooltipHour' :canvas2d="true"
  33. canvasId="canvasId9839618" />
  34. </view>
  35. </view>
  36. <view class="card-item">
  37. <view class="card-info">
  38. <view class="t-icon t-icon-jiankangshangbao"></view>
  39. <text class="info-text">近七天运动</text>
  40. </view>
  41. <view class="charts-box">
  42. <qiun-data-charts type="pie" :chartData="todayData.exercisePie" :loadingType="4"
  43. tooltipFormat='pieMinute' :canvas2d="true" canvasId="canvasId91234111" />
  44. </view>
  45. </view>
  46. <view class="card-item">
  47. <view class="card-info">
  48. <view class="t-icon t-icon-jiankangshangbao"></view>
  49. <text class="info-text">近七天睡眠</text>
  50. </view>
  51. <view class="charts-box">
  52. <qiun-data-charts type="ring" :chartData="todayData.sleepRing" :loadingType="4"
  53. tooltipFormat='tooltipHour' :canvas2d="true" canvasId="canvasId6312231" />
  54. </view>
  55. </view>
  56. </view>
  57. </view>
  58. </template>
  59. <script>
  60. import {
  61. mapState
  62. } from 'vuex'
  63. export default {
  64. name: "todaydata-box",
  65. computed: {
  66. ...mapState('m_chart', ['todayData']),
  67. },
  68. data() {
  69. return {
  70. //模块名
  71. list: [{
  72. name: '今日记录'
  73. }, {
  74. name: '历史记录'
  75. }],
  76. //当前模块
  77. current: 0,
  78. //记录卡片
  79. moduleData: [{
  80. text: '自主学习记录',
  81. color: 'background-color: #5b7cff;',
  82. icon: 't-icon t-icon-bianjibi',
  83. numData: '记录一下',
  84. },
  85. {
  86. text: '娱乐放松记录',
  87. color: 'background-color: #00cca3;',
  88. icon: 't-icon t-icon-leimucuyule',
  89. numData: '记录一下',
  90. },
  91. {
  92. text: '运动锻炼记录',
  93. color: 'background-color: #ff9db2;',
  94. icon: 't-icon t-icon-yundong',
  95. numData: '记录一下',
  96. },
  97. {
  98. text: '每日睡眠记录',
  99. color: 'background-color: #f9c752;',
  100. icon: 't-icon t-icon-a-icon_wananyueliangshuimian',
  101. numData: '记录一下',
  102. }
  103. ],
  104. //当前记录卡片
  105. cardCurrent: 5,
  106. //选择器
  107. setTimePicker: false,
  108. //时间表
  109. pickerList: [
  110. ['0小时', '1小时', '2小时', '3小时', '4小时', '5小时', '6小时', '7小时', '8小时', '9小时', '10小时'],
  111. ['5分钟', '10分钟', '15分钟', '20分钟', '25分钟', '30分钟', '35分钟', '40分钟', '45分钟', '50分钟', '55分钟']
  112. ],
  113. };
  114. },
  115. onLoad() {},
  116. methods: {
  117. //更改模块
  118. changeModule(index) {
  119. this.current = index.index
  120. },
  121. //点击卡片唤起picker
  122. setTime(index) {
  123. this.cardCurrent = index
  124. this.setTimePicker = true
  125. },
  126. //更改完成事件
  127. changeHandler(e) {
  128. if (e.value[0] === '0小时') {
  129. this.moduleData[this.cardCurrent].numData = e.value[1]
  130. } else {
  131. this.moduleData[this.cardCurrent].numData = e.value[0] + e.value[1]
  132. }
  133. },
  134. pickerConfirm(e) {
  135. // this.setTimePicker = false
  136. // 闭包的运用
  137. let that = this
  138. setTimeout(function () {
  139. uni.$showMsg('记录完成',1000)
  140. that.setTimePicker = false
  141. }, 100)
  142. },
  143. pickerCancel() {
  144. uni.$showMsg('取消选择',1000)
  145. this.setTimePicker = false
  146. },
  147. }
  148. }
  149. </script>
  150. <style lang="scss">
  151. @import '@/pages/common/mainpage.scss';
  152. .module-box {
  153. display: flex;
  154. flex-direction: row;
  155. flex-wrap: wrap;
  156. justify-content: space-between;
  157. .module-item {
  158. margin: 2% 0;
  159. display: flex;
  160. flex-direction: column;
  161. background-color: #FFFFFF;
  162. border-radius: $card-border-radius;
  163. width: 48%;
  164. height: auto;
  165. overflow: hidden;
  166. .module-item-box {
  167. padding: 35rpx;
  168. width: 100%;
  169. display: flex;
  170. flex-direction: column;
  171. .t-icon {
  172. width: 250rpx;
  173. height: 250rpx;
  174. margin: -250rpx 0 0 150rpx;
  175. z-index: 1;
  176. }
  177. }
  178. }
  179. }
  180. .module-item-text {
  181. color: #FFF;
  182. font-size: 28rpx;
  183. font-weight: bold;
  184. z-index: 5;
  185. }
  186. .num-box {
  187. margin-top: 20rpx;
  188. z-index: 5;
  189. .module-item-num {
  190. color: #FFF;
  191. font-size: 42rpx;
  192. font-weight: bold;
  193. }
  194. }
  195. </style>