index.js 6.1 KB

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