attention.js 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158
  1. import * as echarts from '../../ec-canvas/echarts';
  2. // var Api = require('../../api/urls.js');
  3. var wxRequest = require('../../api/request.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. array:[],
  58. currentPage:1,
  59. uerId:wx.getStorageSync('openid')
  60. },
  61. onLoad: function() {
  62. var that = this;
  63. // 获取关注的信息
  64. // var data={
  65. // userId:this.data.uerId,
  66. // currPage:this.data.currentPage
  67. // };
  68. // var that = this;
  69. // wx.showLoading({title: '加载中…'});
  70. this.getFollow(this.data.uerId,this.data.currentPage);
  71. // wxRequest.followList(data).then((res)=>{
  72. // console.log(res);
  73. // wx.hideLoading()
  74. // if(res.statusCode==200){
  75. // that.setData({
  76. // array:res.data.data.incInfos
  77. // })
  78. // }else{
  79. // wx.showToast({
  80. // title: '125',
  81. // icon: 'none'
  82. // })
  83. // }
  84. // })
  85. // 获取系统信息
  86. wx.getSystemInfo({
  87. success: function(res) {
  88. that.setData({
  89. winWidth: res.windowWidth,
  90. winHeight: res.windowHeight
  91. });
  92. }
  93. });
  94. },
  95. scrolltolower:function() {
  96. var that = this;
  97. var tempCurrentPage = that.data.currentPage;
  98. tempCurrentPage = tempCurrentPage + 1;
  99. if(that.data.currentPage==that.data.totalpages){
  100. wx.showLoading({title: '已经到底啦'})
  101. setTimeout(function(){
  102. wx.hideLoading()
  103. },600);
  104. return
  105. }
  106. that.setData({
  107. currentPage: tempCurrentPage,
  108. userId:wx.getStorageSync('openid')
  109. })
  110. that.getFollow(that.data.userId,that.data.currentPage);
  111. },
  112. getFollow:function(userId,currentPage){
  113. console.log(userId,currentPage);
  114. let data = {
  115. userId:userId,
  116. currPage:currentPage
  117. }
  118. var pageIndex = this.data.currentPage;
  119. if(pageIndex==1){
  120. wx.showLoading({title: '加载中…'})
  121. }
  122. wxRequest.followList(data).then((res)=>{
  123. console.log(res);
  124. wx.hideLoading()
  125. if(res.statusCode==200){
  126. if(pageIndex==1){
  127. this.setData({
  128. array:res.data.data.incInfos,
  129. totalpages:res.data.data.pages
  130. })
  131. }else{
  132. var array=this.data.array.concat(res.data.data.incInfos)
  133. this.setData({
  134. array:array
  135. })
  136. }
  137. }else{
  138. wx.showToast({
  139. title: '125',
  140. icon: 'none'
  141. })
  142. }
  143. })
  144. },
  145. open: function (e) {
  146. console.log(e)
  147. wx.navigateTo({
  148. url: '../item/item?row='+JSON.stringify(e.currentTarget.dataset.row)
  149. });
  150. }
  151. })