rise.js 5.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260
  1. import * as echarts from '../../ec-canvas/echarts';
  2. var Api = require('../../utils/api.js');
  3. var wxRequest = require('../../utils/wxRequest.js')
  4. var app = getApp()
  5. function initChart(canvas, width, height, dpr, data) {
  6. const chart = echarts.init(canvas, null, {
  7. width: width,
  8. height: height,
  9. devicePixelRatio: dpr // new
  10. });
  11. canvas.setChart(chart);
  12. var option = {
  13. xAxis : {
  14. type : 'category',
  15. splitNumber: 2,
  16. scale: true,
  17. show:false,
  18. splitLine:{
  19.     show:false
  20.   }
  21. },
  22. yAxis : {
  23. type : 'value',
  24. splitNumber: 2,
  25. scale: true,
  26. show:false,
  27. splitLine:{
  28.     show:false
  29.    }
  30. },
  31. series: [{
  32. type: 'line',
  33. smooth: true,
  34. symbol: 'none',
  35. lineStyle: {
  36. color: '#D81E06',
  37. },
  38. data:data,
  39. areaStyle: {
  40. color: '#D81E06',
  41. },
  42. }]
  43. };
  44. chart.setOption(option);
  45. return chart;
  46. }
  47. Page({
  48. data: {
  49. // 页面配置
  50. winWidth: 0,
  51. winHeight: 0,
  52. // tab切换
  53. currentTab: 0,
  54. ec: {
  55. onInit: initChart
  56. },
  57. realData:[
  58. // {
  59. // title:'BK0422',
  60. // subtitle:"交运物流",
  61. // Increase:"+1.22",
  62. // digital:"33",
  63. // color:'crimson',
  64. // keep:"已关注",
  65. // data:[52,56,355,444]
  66. // },
  67. // {
  68. // title:'BK0738',
  69. // subtitle:"多元金融",
  70. // Increase:"+1.22",
  71. // digital:"33",
  72. // color:'crimson',
  73. // keep:"已关注",
  74. // data:[52,56,355,444]
  75. // },
  76. // {
  77. // title:'BK0450',
  78. // subtitle:"港口水运",
  79. // Increase:"+1.22",
  80. // digital:"33",
  81. // color:'crimson',
  82. // keep:"已关注",
  83. // data:[52,56,355,444,52,56,355,444,52,56,355,444,2]
  84. // },
  85. // {
  86. // title:'BK0734',
  87. // subtitle:"珠宝首饰",
  88. // Increase:"+1.22",
  89. // digital:"33",
  90. // color:'crimson',
  91. // keep:"关注",
  92. // data:[52,56,355,44554]
  93. // },
  94. // {
  95. // title:'BK0471',
  96. // subtitle:"化纤行业",
  97. // Increase:"+1.22",
  98. // digital:"33",
  99. // keep:"关注",
  100. // color:'crimson',
  101. // data:[52,56,355,444]
  102. // },
  103. // {
  104. // title:'BK0485',
  105. // subtitle:"旅游酒店",
  106. // Increase:"+1.22",
  107. // digital:"33",
  108. // color:'crimson',
  109. // keep:"关注",
  110. // data:[52,56,355,444]
  111. // },
  112. // {
  113. // title:'BK0475',
  114. // subtitle:"银行",
  115. // Increase:"+1.22",
  116. // digital:"33",
  117. // keep:"关注",
  118. // color:'crimson',
  119. // data:[52,56,355,44554]
  120. // },
  121. // {
  122. // title:'BK0473',
  123. // subtitle:"券商信托",
  124. // Increase:"+1.22",
  125. // digital:"33",
  126. // color:'crimson',
  127. // keep:"关注",
  128. // data:[52,56,355,444]
  129. // },
  130. // {
  131. // title:'BK0474',
  132. // subtitle:"保险",
  133. // Increase:"+1.22",
  134. // color:'crimson',
  135. // keep:"关注",
  136. // digital:"33",
  137. // data:[52,56,355,444]
  138. // },
  139. // {
  140. // title:'BK0478',
  141. // subtitle:"有色金属",
  142. // Increase:"+1.22",
  143. // keep:"关注",
  144. // digital:"33",
  145. // color:'crimson',
  146. // data:[52,56,355,44554]
  147. // },
  148. // {
  149. // title:'BK0738',
  150. // subtitle:"多元金融",
  151. // Increase:"+1.22",
  152. // digital:"33",
  153. // keep:"关注",
  154. // color:'crimson',
  155. // data:[52,56,355,44554]
  156. // }
  157. ],
  158. onperData:[],
  159. uperData:[],
  160. },
  161. onLoad: function() {
  162. var that = this;
  163. // 获取系统信息
  164. wx.getSystemInfo({
  165. success: function(res) {
  166. let navHeight,
  167. isiOS = res.system.indexOf('iOS') > -1
  168. if(isiOS){
  169. navHeight=44
  170. }else{
  171. navHeight=48
  172. }
  173. that.setData({
  174. winWidth: res.windowWidth,
  175. winHeight: res.windowHeight - res.statusBarHeight - navHeight
  176. });
  177. }
  178. });
  179. that.getinclast()
  180. that.getinclpred()
  181. that.getincnpred()
  182. },
  183. onPullDownRefresh: function () {
  184. wx.showNavigationBarLoading()
  185. var that = this;
  186. this.onLoad(); //重新加载onLoad()
  187. },
  188. //获取上周实际
  189. getinclast:function(){
  190. var that = this;
  191. var getinclast = wxRequest.postRequest(Api.getinclast());
  192. getinclast.then((res)=>{
  193. console.log(res)
  194. if(res.statusCode==200){
  195. that.setData({
  196. realData:res.data.value
  197. })
  198. }
  199. })
  200. },
  201. //获取上周预测
  202. getinclpred:function(){
  203. var that = this;
  204. var getinclast = wxRequest.postRequest(Api.getinclpred());
  205. getinclast.then((res)=>{
  206. console.log(res)
  207. if(res.statusCode==200){
  208. that.setData({
  209. onperData:res.data.value
  210. })
  211. }
  212. })
  213. },
  214. //获取下周预测
  215. getincnpred:function(){
  216. var that = this;
  217. var getinclast = wxRequest.postRequest(Api.getincnpred());
  218. getinclast.then((res)=>{
  219. console.log(res)
  220. if(res.statusCode==200){
  221. that.setData({
  222. uperData:res.data.value
  223. })
  224. }
  225. })
  226. },
  227. // 滑动切换tab
  228. bindChange: function(e) {
  229. var that = this;
  230. that.setData({
  231. currentTab: e.detail.current
  232. });
  233. },
  234. // 点击tab切换
  235. swichNav: function(e) {
  236. var that = this;
  237. if (this.data.currentTab === e.target.dataset.current) {
  238. return false;
  239. } else {
  240. that.setData({
  241. currentTab: e.target.dataset.current
  242. })
  243. }
  244. },
  245. open: function (e) {
  246. console.log(e)
  247. wx.navigateTo({
  248. url: '../item/item?row='+JSON.stringify(e.currentTarget.dataset.row)
  249. });
  250. }
  251. })