drop.js 6.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266
  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.getdeclast()
  180. that.getdeclpred()
  181. that.getdecnpred()
  182. },
  183. onPullDownRefresh: function () {
  184. wx.showNavigationBarLoading()
  185. var that = this;
  186. this.onLoad(); //重新加载onLoad()
  187. },
  188. //获取上周实际
  189. getdeclast:function(){
  190. var that = this;
  191. var getinclast = wxRequest.getRequest(Api.getdeclast());
  192. wx.showLoading({title: '加载中…'})
  193. getinclast.then((res)=>{
  194. wx.hideLoading()
  195. // console.log(res)
  196. if(res.statusCode==200){
  197. that.setData({
  198. realData:res.data.data
  199. })
  200. }
  201. })
  202. },
  203. //获取上周预测
  204. getdeclpred:function(){
  205. var that = this;
  206. var getinclast = wxRequest.getRequest(Api.getdeclpred());
  207. wx.showLoading({title: '加载中…'})
  208. getinclast.then((res)=>{
  209. wx.hideLoading()
  210. // console.log(res)
  211. if(res.statusCode==200){
  212. that.setData({
  213. onperData:res.data.data
  214. })
  215. }
  216. })
  217. },
  218. //获取下周预测
  219. getdecnpred:function(){
  220. var that = this;
  221. var getinclast = wxRequest.getRequest(Api.getdecnpred());
  222. wx.showLoading({title: '加载中…'})
  223. getinclast.then((res)=>{
  224. wx.hideLoading()
  225. // console.log(res)
  226. if(res.statusCode==200){
  227. that.setData({
  228. uperData:res.data.data
  229. })
  230. }
  231. })
  232. },
  233. // 滑动切换tab
  234. bindChange: function(e) {
  235. var that = this;
  236. that.setData({
  237. currentTab: e.detail.current
  238. });
  239. },
  240. // 点击tab切换
  241. swichNav: function(e) {
  242. var that = this;
  243. if (this.data.currentTab === e.target.dataset.current) {
  244. return false;
  245. } else {
  246. that.setData({
  247. currentTab: e.target.dataset.current
  248. })
  249. }
  250. },
  251. open: function (e) {
  252. // console.log(e)
  253. wx.navigateTo({
  254. url: '../item/item?row='+JSON.stringify(e.currentTarget.dataset.row)
  255. });
  256. }
  257. })