todaydata-box.vue 6.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260
  1. <template>
  2. <!-- 今日记录模块 -->
  3. <view class="module-container">
  4. <u-tabs :list="list" :current="current" @change="change"
  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" style="background-color: #5b7cff;" @click="studyTimePicker = true">
  10. <view class="module-item-box">
  11. <text class="module-item-text">自主学习记录</text>
  12. <view class="num-box">
  13. <text class="module-item-num">{{studyTime[6]}}</text>
  14. <text class="unit">小时</text>
  15. </view>
  16. <view class="t-icon t-icon-bianjibi"></view>
  17. </view>
  18. </view>
  19. <view class="module-item" style="background-color: #00cca3;" @click="restTimePicker = true">
  20. <view class="module-item-box">
  21. <text class="module-item-text">娱乐放松记录</text>
  22. <view class="num-box">
  23. <text class="module-item-num">{{restTime}}</text>
  24. <text class="unit">小时</text>
  25. </view>
  26. <view class="t-icon t-icon-leimucuyule"></view>
  27. </view>
  28. </view>
  29. <view class="module-item" style="background-color: #ff9db2;">
  30. <view class="module-item-box">
  31. <text class="module-item-text">运动锻炼记录</text>
  32. <view class="num-box">
  33. <text class="module-item-num">5</text>
  34. <text class="unit">分钟</text>
  35. </view>
  36. <view class="t-icon t-icon-yundong"></view>
  37. </view>
  38. </view>
  39. <view class="module-item" style="background-color: #f9c752;" @click="sleepTimePicker = true">
  40. <view class="module-item-box">
  41. <text class="module-item-text">睡眠记录</text>
  42. <view class="num-box">
  43. <text class="module-item-num">{{sleepTime}}</text>
  44. <text class="unit">小时</text>
  45. </view>
  46. <view class="t-icon t-icon-a-icon_wananyueliangshuimian"></view>
  47. </view>
  48. </view>
  49. </view>
  50. <!-- 时间选择器 -->
  51. <u-picker :show="studyTimePicker" :columns="pickerHour" title="单位(小时)" ref="uPickerStudy" @confirm="hourStudy"
  52. @cancel="studyCancel" :closeOnClickOverlay="true" @change="changeTime"></u-picker>
  53. <u-picker :show="restTimePicker" :columns="pickerHour" title="单位(小时)" ref="uPickerRest" @confirm="hourRest"
  54. @cancel="restCancel" :closeOnClickOverlay="true"></u-picker>
  55. <u-picker :show="sleepTimePicker" :columns="pickerHour" title="单位(小时)" ref="uPickerSleep" @confirm="hourSleep"
  56. @cancel="sleepCancel" :closeOnClickOverlay="true"></u-picker>
  57. <!-- 记录表 -->
  58. <view class="module-box" v-if="current == 1">
  59. <view class="card-item" style="width: 710rpx;">
  60. <view class="card-info">
  61. <view class="t-icon t-icon-jiaoshidaka"></view>
  62. <text class="info-text">近七天学习记录</text>
  63. </view>
  64. <view style=" width:100%; 500rpx; margin-top: -30rpx;">
  65. <qiun-data-charts type="column" :chartData="todayData.studyColumn" :loadingType="4" :canvas2d='true'
  66. canvasId='canvans912' :opts="{dataLabel:false, extra:{column: {barBorderCircle:true}}}" />
  67. </view>
  68. </view>
  69. <view class="card-item">
  70. <view class="card-info">
  71. <view class="t-icon t-icon-jiankangshangbao"></view>
  72. <text class="info-text">近七天运动</text>
  73. </view>
  74. <view class="charts-box">
  75. <qiun-data-charts type="pie" :chartData="todayData.exercisePie" :loadingType="4" :canvas2d='true'
  76. canvasId='canvans8121' />
  77. </view>
  78. </view>
  79. <view class="card-item">
  80. <view class="card-info">
  81. <view class="t-icon t-icon-jiankangshangbao"></view>
  82. <text class="info-text">近七天睡眠</text>
  83. </view>
  84. <view class="charts-box">
  85. <qiun-data-charts type="ring" :chartData="todayData.sleepRing" :loadingType="4" :canvas2d='true'
  86. canvasId='canvans9122' :tooltipFormat='yAxisDemo1' />
  87. </view>
  88. </view>
  89. </view>
  90. </view>
  91. </template>
  92. <script>
  93. import {
  94. mapState
  95. } from 'vuex'
  96. export default {
  97. name: "todaydata-box",
  98. computed: {
  99. ...mapState('m_chart', ['todayData']),
  100. },
  101. data() {
  102. return {
  103. //选择器
  104. studyTimePicker: false,
  105. restTimePicker: false,
  106. sleepTimePicker: false,
  107. //模块名
  108. list: [{
  109. name: '今日记录'
  110. }, {
  111. name: '历史记录'
  112. }],
  113. //当前模块
  114. current: 0,
  115. pickerHour: [
  116. ['0.5', '1', '1.5', '2', '2.5', '3', '3.5', '4', '4.5', '5',
  117. '5.5', '6', '6.5', '7', '7.5', '8', '8.5', '9', '9.5', '10'],
  118. ],
  119. //选择数据暂存
  120. changeValue: 0,
  121. //今日数据记录
  122. studyTime: [2, 4, 3, 3.5, 5, 4, 0],
  123. restTime: 0,
  124. exerciseTime: 0,
  125. sleepTime: 0,
  126. };
  127. },
  128. methods: {
  129. //更改模块
  130. change(index) {
  131. console.log(index)
  132. this.current = index.index
  133. },
  134. changeTime(e) {
  135. console.log('change事件', e)
  136. if (e.value[0]) {
  137. //将用户的选择的值抛出去
  138. this.changeValue = e.value[0]
  139. }else{
  140. //默认值
  141. this.changeValue = 1
  142. }
  143. },
  144. //自主学习
  145. hourStudy() {
  146. let arr = this.studyTime
  147. let num = parseFloat(this.changeValue)
  148. arr.push(num)
  149. if (arr.length > 7) {
  150. arr.shift()
  151. }
  152. console.log(arr)
  153. this.studyTime = arr
  154. this.studyTimePicker = false
  155. },
  156. studyCancel() {
  157. uni.$showMsg('取消选择')
  158. this.studyTimePicker = false
  159. },
  160. //娱乐放松
  161. hourRest(e) {
  162. this.restTime = e.value[0]
  163. this.restTimePicker = false
  164. },
  165. restCancel() {
  166. uni.$showMsg('取消选择')
  167. this.restTimePicker = false
  168. },
  169. //睡眠记录
  170. hourSleep(e) {
  171. this.sleepTime = e.value[0]
  172. this.sleepTimePicker = false
  173. },
  174. sleepCancel() {
  175. uni.$showMsg('取消选择')
  176. this.sleepTimePicker = false
  177. },
  178. }
  179. }
  180. </script>
  181. <style lang="scss">
  182. @import '@/pages/common/mainpage.scss';
  183. .module-box {
  184. display: flex;
  185. flex-direction: row;
  186. flex-wrap: wrap;
  187. justify-content: space-between;
  188. .module-item {
  189. margin: 2% 0;
  190. display: flex;
  191. flex-direction: column;
  192. background-color: #FFFFFF;
  193. border-radius: $card-border-radius;
  194. width: 48%;
  195. height: auto;
  196. overflow: hidden;
  197. .module-item-box {
  198. padding: 30rpx;
  199. width: 100%;
  200. display: flex;
  201. flex-direction: column;
  202. .t-icon {
  203. width: 250rpx;
  204. height: 250rpx;
  205. margin: -250rpx 0 0 150rpx;
  206. }
  207. }
  208. }
  209. }
  210. .module-item-text {
  211. color: #FFF;
  212. font-size: 35rpx;
  213. font-weight: bold;
  214. z-index: 1;
  215. }
  216. .num-box {
  217. margin: 30rpx 0 0 20rpx;
  218. display: flex;
  219. align-items: flex-end;
  220. .module-item-num {
  221. color: #FFF;
  222. font-size: 70rpx;
  223. font-weight: bold;
  224. z-index: 1;
  225. }
  226. .unit {
  227. margin-bottom: 15rpx;
  228. margin-left: 20rpx;
  229. color: #FFF;
  230. font-size: 35rpx;
  231. font-weight: bold;
  232. z-index: 1;
  233. }
  234. }
  235. </style>