index.js 4.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232
  1. // index.js
  2. // 获取应用实例
  3. const app = getApp()
  4. const $api = require('../../utils/api.js').API;
  5. Page({
  6. data: {
  7. loading:0,
  8. notices:[],
  9. tabs:['今日留言','我的关注'],
  10. tabs1:['收益榜','盈利榜','亏损榜'],
  11. cur:0,
  12. cur1:0,
  13. date:'2022-04-27',
  14. explist:[], //留言
  15. total1:0,
  16. page1:1,
  17. followList:[], //关注
  18. total2:-1,
  19. page2:1,
  20. banners:[],
  21. winLost:{},
  22. baikeList:[],
  23. articleList1:[],
  24. articleList2:[],
  25. articleList3:[],
  26. articleList4:[],
  27. groups:{}
  28. },
  29. onLoad() {
  30. wx.showNavigationBarLoading()
  31. $api.getDate().then(res=>{
  32. this.setData({
  33. date:res.data.data
  34. })
  35. $api.getNotoice().then(res=>{
  36. this.setData({
  37. notices:res.data.data
  38. })
  39. })
  40. })
  41. this.getFollow()
  42. this.getIndexData()
  43. this.getExp()
  44. },
  45. fresh: function () {
  46. },
  47. // 获取首页数据
  48. getIndexData:function(){
  49. $api.getChampionlList({isbanner:1}).then(res=>{
  50. console.log(res)
  51. this.setData({
  52. banners:res.data.data.list
  53. })
  54. })
  55. $api.getWinList({new:1}).then(res=>{
  56. this.setData({
  57. winLost:res.data.data[0]
  58. })
  59. $api.getWinLose({match_id:res.data.data[0].match_id}).then(res1=>{
  60. this.setData({
  61. groups:res1.data.data
  62. })
  63. })
  64. })
  65. $api.getBaikeRandom().then(res=>{
  66. this.setData({
  67. baikeList:res.data.data
  68. })
  69. })
  70. $api.getChampionlList({category:'游资专场',page:1}).then(res=>{
  71. this.setData({
  72. articleList1:res.data.data.list
  73. })
  74. })
  75. $api.getChampionlList({category:'冠军交割',page:1}).then(res=>{
  76. this.setData({
  77. articleList2:res.data.data.list
  78. })
  79. })
  80. $api.getChampionlList({category:'牛人专场',page:1}).then(res=>{
  81. this.setData({
  82. articleList3:res.data.data.list
  83. })
  84. })
  85. $api.getChampionlList({category:'妖股列传',page:1}).then(res=>{
  86. this.setData({
  87. articleList4:res.data.data.list
  88. })
  89. })
  90. },
  91. //获取今日留言
  92. getExp:function(){
  93. var list = this.data.explist
  94. $api.getExperience({page:this.data.page1,page_size:20}).then(res=>{
  95. res.data.data.list.forEach(item => {
  96. list.push(item)
  97. })
  98. this.setData({
  99. explist: list,
  100. total1: res.data.data.total
  101. })
  102. })
  103. },
  104. //留言分页
  105. next1: function () {
  106. if (this.data.explist.length < this.data.total1) {
  107. const page = this.data.page1 + 1
  108. this.setData({
  109. page1: page
  110. })
  111. this.getExp()
  112. }
  113. },
  114. //我的关注
  115. getFollow(){
  116. var followList = this.data.followList
  117. if(this.data.loading){
  118. followList=[]
  119. }
  120. $api.getMyFollowV3({
  121. page: this.data.page2, page_size: 20
  122. }).then(res => {
  123. wx.hideNavigationBarLoading()
  124. res.data.data.list.forEach(item => {
  125. followList.push(item)
  126. })
  127. this.setData({
  128. followList: followList,
  129. total2:res.data.data.total,
  130. error:0,
  131. loading: 0
  132. })
  133. app.globalData.follow = 0
  134. })
  135. .catch(err=>{
  136. this.setData({
  137. error:1
  138. })
  139. })
  140. },
  141. //关注分页
  142. next2: function () {
  143. if (this.data.followList.length < this.data.total2) {
  144. const page = this.data.page2 + 1
  145. this.setData({
  146. page2: page
  147. })
  148. this.getFollow()
  149. }
  150. },
  151. tabChange(e){
  152. this.setData({
  153. cur:e.target.dataset.id
  154. })
  155. this.renew()
  156. },
  157. tabChange1(e){
  158. this.setData({
  159. cur1:e.target.dataset.id
  160. })
  161. },
  162. //预览
  163. preview(e){
  164. wx.previewImage({
  165. urls: e.target.dataset.urls,
  166. current: e.target.dataset.src
  167. })
  168. },
  169. curChange(e){
  170. if (e.detail.source == "touch"){
  171. this.setData({
  172. cur: e.detail.current
  173. })
  174. this.renew()
  175. }
  176. },
  177. curChange1(e){
  178. if (e.detail.source == "touch"){
  179. this.setData({
  180. cur1: e.detail.current
  181. })
  182. }
  183. },
  184. renew(){
  185. this.setData({
  186. followList:[],
  187. explist:[],
  188. page1: 1,
  189. total1: 0,
  190. page2: 1,
  191. total2: -1
  192. })
  193. switch(this.data.cur){
  194. case 0:
  195. this.data.page1 = 1
  196. this.getExp()
  197. break;
  198. case 1:
  199. this.data.page2 = 1
  200. this.getFollow()
  201. break;
  202. }
  203. },
  204. onShow: function (e) {
  205. $api.getsignup().then(res => {
  206. this.setData({
  207. info: res.data.data
  208. })
  209. })
  210. //判断是否报名
  211. $api.getAuthinfo().then(res=>{
  212. if(res.data.data.role==0){
  213. wx.navigateTo({
  214. url: '../login/user?type=3&player_type='+res.data.data.player_type,
  215. })
  216. }
  217. })
  218. if(this.data.cur == 0 && app.globalData.follow == 1){
  219. this.data.loading = 1
  220. this.data.page2 = 1
  221. this.data.total2 = -1,
  222. this.getFollow()
  223. }
  224. },
  225. })