index2.vue 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209
  1. <template>
  2. <view class="content">
  3. <div class="bigtitle">
  4. <h2>
  5. {{indexTitle}}
  6. </h2>
  7. </div>
  8. <template>
  9. <cyChartVue>
  10. </cyChartVue>
  11. </template>
  12. <u-empty text="暂无数据" icon="../../static/data.png" v-if="!echartsData.length"></u-empty>
  13. </view>
  14. </template>
  15. <script>
  16. import {
  17. nowDate,
  18. timeToDate,
  19. getLastMonth,
  20. getLast3Month
  21. } from '../../utils/date.js'
  22. import cyChartVue from '../../components/ecahrts/cyChart.vue';
  23. export default {
  24. components: {
  25. cyChartVue
  26. },
  27. data() {
  28. return {
  29. indexTitle: '',
  30. queryParams: {
  31. page: 1,
  32. limit: 999
  33. },
  34. windowInfo: null,
  35. viewList: [],
  36. //图表数据
  37. echartsData: [],
  38. value: 3600000,
  39. startTime: null,
  40. clear: true,
  41. choiceTime: 0,
  42. choiceChildTime: 0,
  43. isShow: false,
  44. token: uni.getStorageSync('C_TOKEN'),
  45. chartHeight: 300,
  46. chartFirstTop: 120,
  47. chartMargin: 50
  48. }
  49. },
  50. created() {
  51. this.loadTitle();
  52. uni.getSystemInfo({
  53. success: (res) => {
  54. this.windowInfo = res;
  55. }
  56. });
  57. },
  58. onShow() {
  59. // console.log('onShow')
  60. },
  61. mounted() {
  62. this.initData()
  63. },
  64. onHide() {
  65. //this.clear = false
  66. },
  67. onPullDownRefresh() {
  68. this.loadTitle()
  69. this.initData()
  70. },
  71. onPageScroll() {
  72. },
  73. beforeDestroy() {
  74. },
  75. methods: {
  76. //获得首页标题
  77. loadTitle() {
  78. uni.$http.get('/dict/queryByDictKey?dictKeys=title').then(res => {
  79. const data = res.data
  80. if (data.code === 200) {
  81. this.indexTitle = data.data[0].dictValue;
  82. }
  83. })
  84. },
  85. initData() {
  86. uni.removeStorage('sTime')
  87. this.clear = true
  88. this.value = null
  89. this.choiceTime = 0
  90. this.startTime = timeToDate(new Date().getTime())
  91. this.temperature()
  92. },
  93. //用户图表数据
  94. temperature() {
  95. this.echartsData = []
  96. uni.$http.get('/chart/getAllOkChart', this.queryParams).then(res => {
  97. const data = res.data
  98. if (data.code === 200) {
  99. const {
  100. reportTableList
  101. } = data.data
  102. let array = []
  103. for (let i = 0; i < reportTableList.length; i++) {
  104. let websrc = '',thumbsrc=''
  105. if (reportTableList[i].chartType === 'line') {
  106. websrc =
  107. `/static/webview/line-wv.html?id=${reportTableList[i].id}&token=${this.token}`
  108. thumbsrc = '../../static/image/icon-action-chartline.png'
  109. } else if (reportTableList[i].chartType === 'bar') {
  110. websrc =
  111. `/static/webview/bar-wv.html?id=${reportTableList[i].id}&token=${this.token}`
  112. thumbsrc = '../../static/image/icon-action-chartbar.png'
  113. } else if (reportTableList[i].chartType === 'pie') {
  114. websrc =
  115. `/static/webview/pie-wv.html?id=${reportTableList[i].id}&token=${this.token}`
  116. thumbsrc = '../../static/image/icon-action-chartpie.png'
  117. } else if (reportTableList[i].chartType === 'table') {
  118. websrc =
  119. `/static/webview/table-wv.html?id=${reportTableList[i].id}&token=${this.token}`
  120. thumbsrc = '../../static/image/icon-action-charttable.png'
  121. }
  122. array.push({
  123. id: reportTableList[i].id,
  124. chartType: reportTableList[i].chartType,
  125. chartName: reportTableList[i].chartName,
  126. src:websrc,
  127. thumb:thumbsrc
  128. })
  129. }
  130. //console.log(array)
  131. this.echartsData = array
  132. }
  133. })
  134. uni.stopPullDownRefresh()
  135. },
  136. }
  137. };
  138. </script>
  139. <style scoped>
  140. .container {
  141. height: 100vh
  142. }
  143. .title {
  144. margin: 10rpx 0 10rpx 20rpx;
  145. font-size: 28rpx;
  146. color: #666666;
  147. }
  148. ::v-deep .uni-section-content {
  149. width: 50%;
  150. margin-bottom: 20rpx;
  151. }
  152. ::v-deep .uni-list-item__content-title {
  153. font-size: 36rpx;
  154. }
  155. .moreTime {
  156. display: flex;
  157. justify-content: space-between;
  158. align-items: center;
  159. width: 80vw;
  160. margin: auto
  161. }
  162. .bigtitle {
  163. margin: auto;
  164. text-align: center;
  165. }
  166. .bigtitle h2 {}
  167. .bod {
  168. border-bottom: 3px solid #007AFF;
  169. }
  170. .box {
  171. border: 1px solid #007AFF !important;
  172. }
  173. .childTime {
  174. margin: 16rpx 60rpx 0 60rpx;
  175. }
  176. .childTime>div {
  177. display: flex;
  178. justify-content: space-between;
  179. align-items: center;
  180. }
  181. .childTime>div>div {
  182. width: 140rpx;
  183. padding: 10rpx;
  184. border: 1px solid #e6e6e6;
  185. border-radius: 16rpx;
  186. color: #7e7e7e;
  187. font-size: 26rpx;
  188. text-align: center;
  189. }
  190. </style>