index.js 5.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301
  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. cur:0,
  11. hot:0,
  12. date:'2022-04-27',
  13. followList:[],
  14. defendList:[],
  15. winList:[],
  16. hotFollowList:[],
  17. hotbuyList:[],
  18. championList:[],
  19. explist:[],
  20. page:1,
  21. total:-1,
  22. page1: 1,
  23. total1: 0,
  24. page2: 1,
  25. total2: 0,
  26. page3: 1,
  27. total3: 0,
  28. page4: 1,
  29. total4: 0,
  30. page5:1,
  31. total5:0,
  32. error:0,
  33. page6:1,
  34. total6:0,
  35. },
  36. onLoad() {
  37. wx.showNavigationBarLoading()
  38. $api.getDate().then(res=>{
  39. this.setData({
  40. date:res.data.data
  41. })
  42. $api.getNotoice().then(res=>{
  43. this.setData({
  44. notices:res.data.data
  45. })
  46. })
  47. })
  48. this.getFollow()
  49. },
  50. fresh: function () {
  51. this.setData({
  52. page:1,
  53. total:-1,
  54. loading:1
  55. })
  56. this.getFollow()
  57. },
  58. //关注分页
  59. next: function () {
  60. if (this.data.followList.length < this.data.total) {
  61. const page = this.data.page + 1
  62. this.setData({
  63. page: page
  64. })
  65. this.getFollow()
  66. }
  67. },
  68. getFollow(){
  69. var followList = this.data.followList
  70. if(this.data.loading){
  71. followList=[]
  72. }
  73. $api.getMyFollowV3({
  74. page: this.data.page, page_size: 20
  75. }).then(res => {
  76. wx.hideNavigationBarLoading()
  77. this.setData({
  78. followList: res.data.data.list,
  79. total:res.data.data.total,
  80. error:0,
  81. loading: 0
  82. })
  83. app.globalData.follow = 0
  84. })
  85. .catch(err=>{
  86. this.setData({
  87. error:1
  88. })
  89. })
  90. },
  91. //胜率分页
  92. next1: function () {
  93. if (this.data.winList.length < this.data.total1) {
  94. const page = this.data.page1 + 1
  95. this.setData({
  96. page1: page
  97. })
  98. this.getWin()
  99. }
  100. },
  101. getWin() {
  102. var winList = this.data.winList
  103. $api.getRinrate({
  104. page: this.data.page1, page_size: 20
  105. }).then(res => {
  106. res.data.data.list.forEach(item => {
  107. winList.push(item)
  108. })
  109. this.setData({
  110. winList: winList,
  111. total1: res.data.data.total
  112. })
  113. })
  114. },
  115. getData(){
  116. //心得
  117. var championList = this.data.championList;
  118. $api.getChampionlList({page: this.data.page6, page_size: 20}).then(res => {
  119. res.data.data.list.forEach(item => {
  120. championList.push(item)
  121. })
  122. this.setData({
  123. championList: championList,
  124. total6: res.data.data.total
  125. })
  126. })
  127. },
  128. next6: function () {
  129. if (this.data.championList.length < this.data.total6) {
  130. const page = this.data.page6 + 1
  131. this.setData({
  132. page6: page
  133. })
  134. this.getData()
  135. }
  136. },
  137. //热门选手分页
  138. next3: function () {
  139. if (this.data.hotFollowList.length < this.data.total3) {
  140. const page = this.data.page3 + 1
  141. this.setData({
  142. page3: page
  143. })
  144. this.getHotFollowList()
  145. }
  146. },
  147. getHotFollowList() {
  148. var hotFollowList = this.data.hotFollowList
  149. let stock_date = this.data.date
  150. $api.getHotFollow({
  151. page: this.data.page3, page_size: 20, stock_date: stock_date
  152. }).then(res => {
  153. res.data.data.list.forEach(item => {
  154. hotFollowList.push(item)
  155. })
  156. this.setData({
  157. hotFollowList: hotFollowList,
  158. total3: res.data.data.total
  159. })
  160. })
  161. },
  162. getHot(){
  163. //热门
  164. let stock_date = this.data.date
  165. $api.getHotbuyList({ stock_date: stock_date }).then(res => {
  166. this.setData({
  167. hotbuyList: res.data.data.list
  168. })
  169. wx.hideNavigationBarLoading()
  170. })
  171. },
  172. tabChange(e){
  173. this.setData({
  174. cur:e.target.dataset.id
  175. })
  176. this.renew()
  177. },
  178. tabChange1(e){
  179. this.setData({
  180. hot:e.target.dataset.id
  181. })
  182. },
  183. //预览
  184. preview(e){
  185. console.log(e)
  186. wx.previewImage({
  187. urls: e.target.dataset.urls,
  188. current: e.target.dataset.src
  189. })
  190. },
  191. curChange(e){
  192. if (e.detail.source == "touch"){
  193. this.setData({
  194. cur: e.detail.current
  195. })
  196. this.renew()
  197. }
  198. },
  199. //热门股票
  200. bindDateChange(e){
  201. this.setData({
  202. date:e.detail.value
  203. })
  204. wx.showNavigationBarLoading()
  205. this.getHot()
  206. },
  207. //今日留言
  208. next5: function () {
  209. if (this.data.explist.length < this.data.total5) {
  210. const page = this.data.page5 + 1
  211. this.setData({
  212. page5: page
  213. })
  214. this.getExp()
  215. }
  216. },
  217. getExp(){
  218. $api.getExperience({page:this.data.page5,page_size:20}).then(res=>{
  219. var hotFollowList = this.data.explist
  220. res.data.data.list.forEach(item => {
  221. hotFollowList.push(item)
  222. })
  223. this.setData({
  224. explist: hotFollowList,
  225. total5: res.data.data.total
  226. })
  227. })
  228. },
  229. renew(){
  230. this.setData({
  231. followList:[],
  232. defendList:[],
  233. winList:[],
  234. hotFollowList:[],
  235. hotbuyList:[],
  236. championList:[],
  237. explist:[],
  238. page:1,
  239. total:-1,
  240. page1: 1,
  241. total1: 0,
  242. page2: 1,
  243. total2: 0,
  244. page3: 1,
  245. total3: 0,
  246. page5: 1,
  247. total5: 0
  248. })
  249. switch(this.data.cur){
  250. case 0:
  251. this.getFollow()
  252. break;
  253. case 1:
  254. this.getHot()
  255. break;
  256. case 2:
  257. this.getHotFollowList()
  258. break;
  259. case 3:
  260. this.getExp()
  261. break;
  262. case 4:
  263. this.data.page6 = 1
  264. this.getData()
  265. break;
  266. }
  267. },
  268. onShow: function (e) {
  269. //判断是否报名
  270. $api.getAuthinfo().then(res=>{
  271. if(res.data.data.role==0){
  272. wx.navigateTo({
  273. url: '../login/user?type=3&player_type='+res.data.data.player_type,
  274. })
  275. }
  276. })
  277. if(this.data.cur == 0 && app.globalData.follow == 1){
  278. this.data.loading = 1
  279. this.data.page = 1
  280. this.data.total = -1,
  281. this.getFollow()
  282. }
  283. },
  284. })