rise.js 9.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404
  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. hidebreak: true,//下拉刷新
  53. currentPage:1,//当前页
  54. currentPage1:1,//上周实际当前页
  55. currentPage2:1,//上周预测当前页
  56. totalpages:0,//总页数
  57. totalpages1:0,//上周实际总页数
  58. totalpages2:0,//上周预测总页数
  59. loading: false,
  60. // tab切换
  61. currentTab: 0,
  62. // ec: {
  63. // onInit: initChart
  64. // },
  65. realData:[
  66. // {
  67. // title:'BK0422',
  68. // subtitle:"交运物流",
  69. // Increase:"+1.22",
  70. // digital:"33",
  71. // color:'crimson',
  72. // keep:"已关注",
  73. // data:[52,56,355,444]
  74. // },
  75. // {
  76. // title:'BK0738',
  77. // subtitle:"多元金融",
  78. // Increase:"+1.22",
  79. // digital:"33",
  80. // color:'crimson',
  81. // keep:"已关注",
  82. // data:[52,56,355,444]
  83. // },
  84. // {
  85. // title:'BK0450',
  86. // subtitle:"港口水运",
  87. // Increase:"+1.22",
  88. // digital:"33",
  89. // color:'crimson',
  90. // keep:"已关注",
  91. // data:[52,56,355,444,52,56,355,444,52,56,355,444,2]
  92. // },
  93. // {
  94. // title:'BK0734',
  95. // subtitle:"珠宝首饰",
  96. // Increase:"+1.22",
  97. // digital:"33",
  98. // color:'crimson',
  99. // keep:"关注",
  100. // data:[52,56,355,44554]
  101. // },
  102. // {
  103. // title:'BK0471',
  104. // subtitle:"化纤行业",
  105. // Increase:"+1.22",
  106. // digital:"33",
  107. // keep:"关注",
  108. // color:'crimson',
  109. // data:[52,56,355,444]
  110. // },
  111. // {
  112. // title:'BK0485',
  113. // subtitle:"旅游酒店",
  114. // Increase:"+1.22",
  115. // digital:"33",
  116. // color:'crimson',
  117. // keep:"关注",
  118. // data:[52,56,355,444]
  119. // },
  120. // {
  121. // title:'BK0475',
  122. // subtitle:"银行",
  123. // Increase:"+1.22",
  124. // digital:"33",
  125. // keep:"关注",
  126. // color:'crimson',
  127. // data:[52,56,355,44554]
  128. // },
  129. // {
  130. // title:'BK0473',
  131. // subtitle:"券商信托",
  132. // Increase:"+1.22",
  133. // digital:"33",
  134. // color:'crimson',
  135. // keep:"关注",
  136. // data:[52,56,355,444]
  137. // },
  138. // {
  139. // title:'BK0474',
  140. // subtitle:"保险",
  141. // Increase:"+1.22",
  142. // color:'crimson',
  143. // keep:"关注",
  144. // digital:"33",
  145. // data:[52,56,355,444]
  146. // },
  147. // {
  148. // title:'BK0478',
  149. // subtitle:"有色金属",
  150. // Increase:"+1.22",
  151. // keep:"关注",
  152. // digital:"33",
  153. // color:'crimson',
  154. // data:[52,56,355,44554]
  155. // },
  156. // {
  157. // title:'BK0738',
  158. // subtitle:"多元金融",
  159. // Increase:"+1.22",
  160. // digital:"33",
  161. // keep:"关注",
  162. // color:'crimson',
  163. // data:[52,56,355,44554]
  164. // }
  165. ],
  166. onperData:[],
  167. uperData:[],
  168. },
  169. onLoad: function() {
  170. var that = this;
  171. // 获取系统信息
  172. wx.getSystemInfo({
  173. success: function(res) {
  174. let navHeight,
  175. isiOS = res.system.indexOf('iOS') > -1
  176. if(isiOS){
  177. navHeight=44
  178. }else{
  179. navHeight=48
  180. }
  181. that.setData({
  182. winWidth: res.windowWidth,
  183. winHeight: res.windowHeight - res.statusBarHeight - navHeight
  184. });
  185. }
  186. });
  187. that.getinclast()
  188. that.getinclpred()
  189. that.getincnpred()
  190. },
  191. //下周预测下拉刷新
  192. onRefresh: function(e) {
  193. this.setData({
  194. currentPage: 1,
  195. loading:true
  196. })
  197. this.getincnpred()
  198. },
  199. //下周预测上拉刷新
  200. scrolltolower:function() {
  201. var that = this;
  202. var tempCurrentPage = that.data.currentPage;
  203. tempCurrentPage = tempCurrentPage + 1;
  204. if(that.data.currentPage==that.data.totalpages){
  205. wx.showLoading({title: '已经到底啦'})
  206. setTimeout(function(){
  207. wx.hideLoading()
  208. },600);
  209. return
  210. }
  211. that.setData({
  212. currentPage: tempCurrentPage,
  213. })
  214. that.getincnpred()
  215. },
  216. //上周实际下拉刷新
  217. onRefresh1: function(e) {
  218. this.setData({
  219. currentPage1: 1,
  220. loading:true
  221. })
  222. this.getinclast()
  223. },
  224. //上周实际上拉刷新
  225. scrolltolower1:function() {
  226. var that = this;
  227. var tempCurrentPage = that.data.currentPage1;
  228. tempCurrentPage = tempCurrentPage + 1;
  229. if(that.data.currentPage1==that.data.totalpages1){
  230. wx.showLoading({title: '已经到底啦'})
  231. setTimeout(function(){
  232. wx.hideLoading()
  233. },600);
  234. return
  235. }
  236. that.setData({
  237. currentPage1: tempCurrentPage,
  238. })
  239. that.getinclast()
  240. },
  241. //上周预测下拉刷新
  242. onRefresh2: function(e) {
  243. this.setData({
  244. currentPage2: 1,
  245. loading:true
  246. })
  247. this.getinclpred()
  248. },
  249. //上周预测上拉刷新
  250. scrolltolower2:function() {
  251. var that = this;
  252. var tempCurrentPage = that.data.currentPage2;
  253. tempCurrentPage = tempCurrentPage + 1;
  254. if(that.data.currentPage2==that.data.totalpages2){
  255. wx.showLoading({title: '已经到底啦'})
  256. setTimeout(function(){
  257. wx.hideLoading()
  258. },600);
  259. return
  260. }
  261. that.setData({
  262. currentPage2: tempCurrentPage,
  263. })
  264. that.getinclpred()
  265. },
  266. onPullDownRefresh: function () {
  267. wx.showNavigationBarLoading()
  268. var that = this;
  269. this.onLoad(); //重新加载onLoad()
  270. },
  271. //获取上周实际
  272. getinclast:function(){
  273. var that = this;
  274. var data={'currPage':that.data.currentPage1}
  275. var getinclast = wxRequest.getRequest(Api.getinclast(),data);
  276. var pageIndex = that.data.currentPage1;
  277. if(pageIndex==1){
  278. wx.showLoading({title: '加载中…'})
  279. }
  280. getinclast.then((res)=>{
  281. console.log(res)
  282. wx.hideLoading()
  283. wx.stopPullDownRefresh()
  284. if(res.statusCode==200){
  285. if(pageIndex==1){
  286. that.setData({
  287. realData:res.data.data.incInfos,
  288. totalpages1:res.data.data.pages,
  289. loading:false
  290. })
  291. }else{
  292. var realArray=that.data.realData.concat(res.data.data.incInfos)
  293. that.setData({
  294. realData:realArray
  295. })
  296. }
  297. }
  298. })
  299. },
  300. //获取上周预测
  301. getinclpred:function(){
  302. var that = this;
  303. var data={'currPage':that.data.currentPage2}
  304. var getinclast = wxRequest.getRequest(Api.getinclpred(),data);
  305. var pageIndex = that.data.currentPage2;
  306. if(pageIndex==1){
  307. wx.showLoading({title: '加载中…'})
  308. }
  309. getinclast.then((res)=>{
  310. wx.hideLoading()
  311. wx.stopPullDownRefresh()
  312. // console.log(res)
  313. if(res.statusCode==200){
  314. if(pageIndex==1){
  315. that.setData({
  316. onperData:res.data.data.incInfos,
  317. totalpages2:res.data.data.pages,
  318. loading:false
  319. })
  320. }else{
  321. var onperArray=that.data.onperData.concat(res.data.data.incInfos)
  322. that.setData({
  323. onperData:onperArray
  324. })
  325. }
  326. }
  327. })
  328. },
  329. //获取下周预测
  330. getincnpred:function(){
  331. var that = this;
  332. var data={'currPage':that.data.currentPage}
  333. var getinclast = wxRequest.getRequest(Api.getincnpred(),data);
  334. var pageIndex = that.data.currentPage;
  335. if(pageIndex==1){
  336. wx.showLoading({title: '加载中…'})
  337. }
  338. getinclast.then((res)=>{
  339. wx.hideLoading()
  340. wx.stopPullDownRefresh()
  341. // console.log(res)
  342. if(res.statusCode==200){
  343. if(pageIndex==1){
  344. that.setData({
  345. uperData:res.data.data.incInfos,
  346. totalpages:res.data.data.pages,
  347. loading:false
  348. })
  349. }else{
  350. var uperArray=that.data.uperData.concat(res.data.data.incInfos)
  351. that.setData({
  352. uperData:uperArray
  353. })
  354. }
  355. }
  356. })
  357. },
  358. // 滑动切换tab
  359. bindChange: function(e) {
  360. var that = this;
  361. that.setData({
  362. currentTab: e.detail.current
  363. });
  364. },
  365. // 点击tab切换
  366. swichNav: function(e) {
  367. var that = this;
  368. if (this.data.currentTab === e.target.dataset.current) {
  369. return false;
  370. } else {
  371. that.setData({
  372. currentTab: e.target.dataset.current
  373. })
  374. }
  375. },
  376. open: function (e) {
  377. // console.log(e)
  378. wx.navigateTo({
  379. url: '../item/item?row='+JSON.stringify(e.currentTarget.dataset.row)
  380. });
  381. }
  382. })