methods.js 7.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234
  1. import Apis from '@/common/apis/index'
  2. import uCharts from '@/common/utils/u-charts/u-charts.js'
  3. let canvaLineA = null;
  4. let lastMoveTime = null; //最后执行移动的时间戳
  5. export default {
  6. async inData() {
  7. try {
  8. uni.showLoading({
  9. title: '数据获取中'
  10. });
  11. // date_flag 近几个月
  12. // exam_type 1为视力,2为眼压,3为综合验光,4为角膜内皮检查,5为光学生物测量
  13. let query = {
  14. group_id: uni.getStorageSync('gid'),
  15. id: this.patientId,
  16. date_flag: 12,
  17. exam_type: 5
  18. }
  19. const res = await Apis.patientExamResultAnalysis(query)
  20. res.data.eye_list.forEach(v => {
  21. let reg = /(\d{4})-(\d{2})-(\d{2})/
  22. v.month = v.date.toString().replace(reg, '$2/$3')
  23. })
  24. this.data = res.data
  25. this.getServerData();
  26. uni.hideLoading();
  27. } catch (error) {
  28. console.log(error)
  29. }
  30. },
  31. getServerData() {
  32. let _self = this;
  33. let data = {
  34. "categories": this.data.eye_list.map(v => v.month),
  35. "series": [{
  36. "name": "右眼",
  37. "lineType": "solid",
  38. "legendShape": 'circle',
  39. "color": '#FF8673',
  40. "data": this.data.eye_list.map(v => v.al_od)
  41. },
  42. {
  43. "name": "左眼",
  44. "lineType": "solid",
  45. "legendShape": 'circle',
  46. "color": '#24B1E9',
  47. "data": this.data.eye_list.map(v => v.al_os)
  48. }
  49. ]
  50. }
  51. console.log(data)
  52. let LineA = {
  53. categories: [],
  54. series: []
  55. };
  56. //这里我后台返回的是数组,所以用等于,如果您后台返回的是单条数据,需要push进去
  57. LineA.categories = data.categories;
  58. LineA.series = data.series;
  59. _self.textarea = JSON.stringify(data);
  60. _self.showLineA("canvasLineA", LineA);
  61. },
  62. showLineA(canvasId, chartData) {
  63. let _self = this;
  64. canvaLineA = new uCharts({
  65. $this: _self,
  66. canvasId: canvasId,
  67. type: 'line',
  68. background: '#ffffff',
  69. animation: true,
  70. timing: 'easeOut',
  71. duration: 1000,
  72. // color: [
  73. // '#FF8673',
  74. // '#24B1E9',
  75. // ],
  76. rotate: false,
  77. errorReload: true,
  78. fontSize: 10,
  79. fontColor: '#999999',
  80. enableScroll: false,
  81. touchMoveLimit: 60,
  82. enableMarkLine: false,
  83. dataLabel: false,
  84. dataPointShape: true,
  85. dataPointShapeType: 'solid',
  86. tapLegend: true,
  87. pixelRatio: _self.pixelRatio,
  88. categories: chartData.categories,
  89. series: chartData.series,
  90. animation: true,
  91. xAxis: {
  92. disabled: false,
  93. axisLine: true,
  94. axisLineColor: '#DBDBDB',
  95. calibration: false,
  96. fontColor: '#999999',
  97. fontSize: 10,
  98. rotateLabel: false,
  99. boundaryGap: 'center',
  100. disableGrid: true,
  101. gridColor: '#DBDBDB',
  102. gridType: 'solid',
  103. dashLength: 4,
  104. gridEval: 1
  105. },
  106. yAxis: {
  107. disabled: false,
  108. disableGrid: false,
  109. padding: 800,
  110. axisLineColor: '#DBDBDB',
  111. gridType: 'solid',
  112. gridColor: '#DBDBDB',
  113. showTitle: false,
  114. data: [{
  115. axisLine: false,
  116. format: (val) => {
  117. return val.toFixed(1)
  118. }
  119. }],
  120. },
  121. legend: {
  122. show: true,
  123. position: 'top',
  124. float: 'right',
  125. padding: 0,
  126. margin: 25,
  127. backgroundColor: 'rgba(0,0,0,0)',
  128. borderColor: 'rgba(0,0,0,0)',
  129. borderWidth: 0,
  130. fontSize: 12,
  131. fontColor: '#000000',
  132. lineHeight: 12,
  133. hiddenColor: '#CECECE',
  134. itemGap: 16,
  135. },
  136. extra: {
  137. line: {
  138. type: 'straight',
  139. width: 2
  140. },
  141. tooltip: {
  142. showBox: true,
  143. showArrow: true,
  144. showCategory: false,
  145. borderWidth: 0,
  146. borderRadius: 0,
  147. borderColor: '#000000',
  148. borderOpacity: 0.7,
  149. bgColor: '#000000',
  150. bgOpacity: 0.7,
  151. gridType: 'solid',
  152. dashLength: 4,
  153. gridColor: '#CCCCCC',
  154. fontColor: '#FFFFFF',
  155. splitLine: true,
  156. horizentalLine: false,
  157. xAxisLabel: false,
  158. yAxisLabel: false,
  159. labelBgColor: '#FFFFFF',
  160. labelBgOpacity: 0.7,
  161. labelFontColor: '#666666'
  162. },
  163. markLine: {
  164. type: 'solid',
  165. dashLength: 4,
  166. data: []
  167. }
  168. },
  169. width: _self.cWidth,
  170. height: _self.cHeight,
  171. });
  172. },
  173. touchLineA(e) {
  174. lastMoveTime = Date.now();
  175. },
  176. moveLineA(e) {
  177. let currMoveTime = Date.now();
  178. let duration = currMoveTime - lastMoveTime;
  179. if (duration < Math.floor(1000 / 60)) return; //每秒60帧
  180. lastMoveTime = currMoveTime;
  181. let currIndex = canvaLineA.getCurrentDataIndex(e);
  182. if (currIndex > -1 && currIndex < canvaLineA.opts.categories.length) {
  183. let riqi = canvaLineA.opts.categories[currIndex];
  184. let leibie = canvaLineA.opts.series[0].name;
  185. let shuju = canvaLineA.opts.series[0].data[currIndex];
  186. this.Interactive = leibie + ':' + riqi + '-' + shuju + '元';
  187. }
  188. canvaLineA.showToolTip(e, {
  189. format: function(item, category) {
  190. return category + ' ' + item.name + ':' + item.data
  191. }
  192. });
  193. },
  194. touchEndLineA(e) {
  195. let currIndex = canvaLineA.getCurrentDataIndex(e);
  196. if (currIndex > -1 && currIndex < canvaLineA.opts.categories.length) {
  197. let riqi = canvaLineA.opts.categories[currIndex];
  198. let leibie = canvaLineA.opts.series[0].name;
  199. let shuju = canvaLineA.opts.series[0].data[currIndex];
  200. this.Interactive = leibie + ':' + riqi + '-' + shuju + '元';
  201. }
  202. canvaLineA.touchLegend(e);
  203. canvaLineA.showToolTip(e, {
  204. format: function(item, category) {
  205. return category + ' ' + item.name + ':' + item.data
  206. }
  207. });
  208. },
  209. onOpenPopup(name) {
  210. this.popupData.title = name
  211. switch (name) {
  212. case '屈光度':
  213. this.popupData.content = '眼轴是角膜正中到视神经与视网膜黄斑中心凹之间的一条假设线的长度,也就是眼球前后径的长度。'
  214. break
  215. case '眼轴':
  216. this.popupData.content =
  217. `眼球的发育如同人的身高从矮到高的发育一样,眼轴经历从短到长、眼轴屈光状态从远视眼到正视眼的过程,这就是眼球发育的正视化过程。<br/> <img mode="widthFix" style="width:100%;display: block;" src="${this.baseUrl}/device/chart_eye_1.png" > <br/>眼球的发育如同人的身高从矮到高的发育一样,眼轴经历从短到长、眼轴屈光状态从远视眼到正视眼的过程,这就是眼球发育的正视化过程。`
  218. break
  219. case '轴率比':
  220. this.popupData.content =
  221. `轴率比是眼轴长度与角膜曲率半径平均值的比值。<br/>
  222. 近视分为三种, 屈光指数性近视、 曲率性近视、 轴性近视。 第一种是指轴长不变( 或在正常范围内), 而由晶状体等屈光因素改变所引起的近视。 第二种是角膜曲率过高( 超过46D) 引起的近视。 这两种都不常见。 最常见的是第三种, 由眼轴异常变长引发的近视。<br/>
  223. 眼球在发育过程中为了维持正视化( 不近视) 的状态, 角膜曲率半径平均值会随着眼轴长度的延长而变大。 当角膜曲率半径变大在不能充分代偿眼轴长度过度延长时, 就会慢慢发展为近视。 轴率比( AL /
  224. CR, 即上述第二个指标数值除以第三个指标数值) 均值在不同种族、 年龄、 性别间无显著差距, 不同人种平均值范围在2 .90~3.10 之间。<br/>
  225. 近年来, 研究人员发现, 轴率比可以作为检验小朋友是否近视、 近视程度的一个判定标准。 轴率比大于3小于3 .199, 则意味着产生了低度近视( 50 度 - 300 度, 准确度90 .3 % );轴率比大于3 .199, 则意味着产生了中度近视( 300 度 - 600 度, 准确度89 .10 % )。`
  226. break
  227. }
  228. this.$refs.popupShow.open()
  229. },
  230. }