rise.js 9.7 KB

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