achievement.vue 6.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266
  1. <template>
  2. <view style="margin-bottom: 60upx;">
  3. <view class="achievementTotal">
  4. <view>
  5. <view><text>0</text></view>
  6. <view><text>年度签单保费</text></view>
  7. </view>
  8. <view>
  9. <view><text>0</text></view>
  10. <view><text>年度成交单数</text></view>
  11. </view>
  12. <view>
  13. <view><text>0</text></view>
  14. <view><text>年度单均保费</text></view>
  15. </view>
  16. </view>
  17. <view class="qiun-charts">
  18. <view class="qiun-title">日度报表统计图</view>
  19. <canvas canvas-id="canvasMix" id="canvasMix" class="charts" disable-scroll=true @touchstart="touchMix" @touchmove="moveMix"
  20. @touchend="touchEndMix"></canvas>
  21. <navigator url="../daysAchievement/daysAchievement">
  22. <view class="row d-flex a-center">
  23. <view>日度业务分析</view>
  24. <view>&gt;</view>
  25. </view>
  26. </navigator>
  27. </view>
  28. <view class="qiun-charts">
  29. <view class="qiun-title">月度报表统计图</view>
  30. <canvas canvas-id="canvasMix1" id="canvasMix1" class="charts" disable-scroll=true @touchstart="touchMix1" @touchmove="moveMix1"
  31. @touchend="touchEndMix1"></canvas>
  32. <navigator url="../monthsAchievement/monthsAchievement">
  33. <view class="row d-flex a-center">
  34. <view>月度业务分析</view>
  35. <view>&gt;</view>
  36. </view>
  37. </navigator>
  38. </view>
  39. </view>
  40. </template>
  41. <script>
  42. import uCharts from '@/components/modules/tools/achievement/u-charts/u-charts.js';
  43. var _self;
  44. var canvaMix = null;
  45. var canvaMix1 = null;
  46. export default {
  47. data() {
  48. return {
  49. cWidth: '',
  50. cHeight: '',
  51. pixelRatio: 1,
  52. }
  53. },
  54. onLoad() {
  55. _self = this;
  56. this.cWidth = uni.upx2px(750);
  57. this.cHeight = uni.upx2px(500);
  58. this.getServerData();
  59. },
  60. methods: {
  61. getServerData() {
  62. uni.request({
  63. url: 'https://www.ucharts.cn/data.json',
  64. data: {},
  65. success: function(res) {
  66. console.log(res.data.data)
  67. let Mix = {
  68. categories: [],
  69. series: []
  70. };
  71. //这里我后台返回的是数组,所以用等于,如果您后台返回的是单条数据,需要push进去
  72. Mix.categories = res.data.data.Mix.categories;
  73. Mix.series = res.data.data.Mix.series;
  74. _self.showMix("canvasMix", Mix);
  75. _self.showMix1("canvasMix1", Mix);
  76. },
  77. fail: () => {
  78. _self.tips = "网络错误,小程序端请检查合法域名";
  79. },
  80. });
  81. },
  82. showMix(canvasId, chartData) {
  83. canvaMix = new uCharts({
  84. $this: _self,
  85. canvasId: canvasId,
  86. type: 'mix',
  87. fontSize: 11,
  88. legend: {
  89. show: true
  90. },
  91. background: '#FFFFFF',
  92. pixelRatio: _self.pixelRatio,
  93. categories: chartData.categories,
  94. series: chartData.series,
  95. animation: true,
  96. enableScroll: true, //开启图表拖拽功能
  97. xAxis: {
  98. disableGrid: false,
  99. type: 'grid',
  100. gridType: 'dash',
  101. itemCount: 4,
  102. scrollShow: true,
  103. scrollAlign: 'left',
  104. },
  105. yAxis: {
  106. gridType: 'dash',
  107. splitNumber: 5,
  108. min: 10,
  109. max: 180,
  110. format: (val) => {
  111. return val.toFixed(0)
  112. }
  113. },
  114. width: _self.cWidth * _self.pixelRatio,
  115. height: _self.cHeight * _self.pixelRatio,
  116. dataLabel: true,
  117. dataPointShape: true,
  118. extra: {
  119. tooltip: {
  120. bgColor: '#000000',
  121. bgOpacity: 0.7,
  122. gridType: 'dash',
  123. dashLength: 8,
  124. gridColor: '#1890ff',
  125. fontColor: '#FFFFFF',
  126. horizentalLine: true,
  127. xAxisLabel: true,
  128. yAxisLabel: true,
  129. labelBgColor: '#DFE8FF',
  130. labelBgOpacity: 0.95,
  131. labelAlign: 'left',
  132. labelFontColor: '#666666'
  133. }
  134. },
  135. });
  136. },
  137. showMix1(canvasId, chartData) {
  138. canvaMix1 = new uCharts({
  139. $this: _self,
  140. canvasId: canvasId,
  141. type: 'mix',
  142. fontSize: 11,
  143. legend: {
  144. show: true
  145. },
  146. background: '#FFFFFF',
  147. pixelRatio: _self.pixelRatio,
  148. categories: chartData.categories,
  149. series: chartData.series,
  150. animation: true,
  151. enableScroll: true, //开启图表拖拽功能
  152. xAxis: {
  153. disableGrid: false,
  154. type: 'grid',
  155. gridType: 'dash',
  156. itemCount: 4,
  157. scrollShow: true,
  158. scrollAlign: 'left',
  159. },
  160. yAxis: {
  161. gridType: 'dash',
  162. splitNumber: 5,
  163. min: 10,
  164. max: 180,
  165. format: (val) => {
  166. return val.toFixed(0)
  167. }
  168. },
  169. width: _self.cWidth * _self.pixelRatio,
  170. height: _self.cHeight * _self.pixelRatio,
  171. dataLabel: true,
  172. dataPointShape: true,
  173. extra: {
  174. tooltip: {
  175. bgColor: '#000000',
  176. bgOpacity: 0.7,
  177. gridType: 'dash',
  178. dashLength: 8,
  179. gridColor: '#1890ff',
  180. fontColor: '#FFFFFF',
  181. horizentalLine: true,
  182. xAxisLabel: true,
  183. yAxisLabel: true,
  184. labelBgColor: '#DFE8FF',
  185. labelBgOpacity: 0.95,
  186. labelAlign: 'left',
  187. labelFontColor: '#666666'
  188. }
  189. },
  190. });
  191. },
  192. touchMix(e) {
  193. canvaMix.scrollStart(e);
  194. },
  195. touchMix1(e) {
  196. canvaMix1.scrollStart(e);
  197. },
  198. moveMix(e) {
  199. canvaMix.scroll(e);
  200. },
  201. moveMix1(e) {
  202. canvaMix1.scroll(e);
  203. },
  204. touchEndMix(e) {
  205. canvaMix.scrollEnd(e);
  206. //下面是toolTip事件,如果滚动后不需要显示,可不填写
  207. canvaMix.showToolTip(e, {
  208. format: function(item, category) {
  209. return category + ' ' + item.name + ':' + item.data
  210. }
  211. });
  212. },
  213. touchEndMix1(e) {
  214. canvaMix1.scrollEnd(e);
  215. //下面是toolTip事件,如果滚动后不需要显示,可不填写
  216. canvaMix1.showToolTip(e, {
  217. format: function(item, category) {
  218. return category + ' ' + item.name + ':' + item.data
  219. }
  220. });
  221. }
  222. }
  223. }
  224. </script>
  225. <style scoped>
  226. .achievementTotal {
  227. display: flex;
  228. flex-wrap: nowrap;
  229. justify-content: space-between;
  230. padding: 25upx 30upx;
  231. font-size: 28upx;
  232. border-bottom: 10upx solid #ccc;
  233. }
  234. .achievementTotal view {
  235. text-align: center;
  236. }
  237. .qiun-title {
  238. height: 70upx;
  239. line-height: 70upx;
  240. font-size: 30upx;
  241. font-weight: bold;
  242. padding: 0upx 20upx;
  243. background: #FAFAFA;
  244. }
  245. .charts {
  246. width: 750upx;
  247. height: 500upx;
  248. background-color: #FFFFFF;
  249. }
  250. .qiun-charts .row {
  251. line-height: 80upx;
  252. height: 80upx;
  253. padding: 0 30upx;
  254. font-size: 30upx;
  255. display: flex;
  256. justify-content: space-between;
  257. border-top: 1px solid #ccc;
  258. border-bottom: 1px solid #ccc;
  259. }
  260. </style>