123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336 |
- // index.js
- // 获取应用实例
- const app = getApp()
- const $api = require('../../utils/api.js').API;
- Page({
- data: {
- loading:0,
- notices:[],
- tabs:['关注','热门股票','热门选手','今日留言','冠军心得'],
- cur:0,
- hot:0,
- date:'2022-04-27',
- followList:[],
- defendList:[],
- winList:[],
- hotFollowList:[],
- hotbuyList:[],
- championList:[],
- explist:[],
- page:1,
- total:-1,
- page1: 1,
- total1: 0,
- page2: 1,
- total2: 0,
- page3: 1,
- total3: 0,
- page4: 1,
- total4: 0,
- page5:1,
- total5:0,
- error:0,
- page6:1,
- total6:0,
- },
- onLoad() {
-
- wx.showNavigationBarLoading()
- var y = new Date().getFullYear(), m = (new Date().getMonth() + 1), d = new Date().getDate();
- m = m > 9 ? m : '0' + m;
- d = d > 9 ? d : '0' + d;
- // this.setData({
- // date: y + '-' + m + '-' + d
- // })
- $api.getDate().then(res=>{
- this.setData({
- date:res.data.data
- })
- $api.getNotoice().then(res=>{
- this.setData({
- notices:res.data.data
- })
- })
- })
- this.getFollow()
-
-
-
- },
- fresh: function () {
- this.setData({
- page:1,
- total:-1,
- loading:1
- })
- this.getFollow()
- },
- //关注分页
- next: function () {
- if (this.data.followList.length < this.data.total) {
- const page = this.data.page + 1
- this.setData({
- page: page
- })
- this.getFollow()
- }
- },
- getFollow(){
- var followList = this.data.followList
- if(this.data.loading){
- followList=[]
- }
- $api.getMyFollow({
- page: this.data.page, page_size: 20
- }).then(res => {
- wx.hideNavigationBarLoading()
- res.data.data.list.forEach(item=>{
- item.today_income=parseInt(item.today_income)+"%"
- item.total_income=parseInt(item.total_income)+"%"
- followList.push(item)
- })
- this.setData({
- followList: followList,
- total:res.data.data.total,
- error:0,
- loading: 0
- })
- })
- .catch(err=>{
- this.setData({
- error:1
- })
- })
- },
- //胜率分页
- next1: function () {
- if (this.data.winList.length < this.data.total1) {
- const page = this.data.page1 + 1
- this.setData({
- page1: page
- })
- this.getWin()
- }
- },
- getWin() {
- var winList = this.data.winList
- $api.getRinrate({
- page: this.data.page1, page_size: 20
- }).then(res => {
- res.data.data.list.forEach(item => {
- winList.push(item)
- })
- this.setData({
- winList: winList,
- total1: res.data.data.total
- })
- })
- },
- //防守分页 防守榜去掉
- // next2: function () {
- // if (this.data.defendList.length < this.data.total2) {
- // const page = this.data.page2 + 1
- // this.setData({
- // page2: page
- // })
- // this.getDefen()
- // }
- // },
- // getDefen() {
- // var defendList = this.data.defendList
- // $api.getDefend({
- // page: this.data.page2, page_size: 20
- // }).then(res => {
- // res.data.data.list.forEach(item => {
- // defendList.push(item)
- // })
- // this.setData({
- // defendList: defendList,
- // total2: res.data.data.total
- // })
- // })
- // },
- getData(){
- //心得
- var championList = this.data.championList;
- $api.getChampionlList({page: this.data.page6, page_size: 20}).then(res => {
- res.data.data.list.forEach(item => {
- championList.push(item)
- })
- this.setData({
- championList: championList,
- total6: res.data.data.total
- })
- })
- },
- next6: function () {
- if (this.data.championList.length < this.data.total6) {
- const page = this.data.page6 + 1
- this.setData({
- page6: page
- })
- this.getData()
- }
- },
- //热门选手分页
- next3: function () {
- if (this.data.hotFollowList.length < this.data.total3) {
- const page = this.data.page3 + 1
- this.setData({
- page3: page
- })
- this.getHotFollowList()
- }
- },
- getHotFollowList() {
- var hotFollowList = this.data.hotFollowList
- let stock_date = this.data.date
- $api.getHotFollow({
- page: this.data.page3, page_size: 20, stock_date: stock_date
- }).then(res => {
-
- res.data.data.list.forEach(item => {
- hotFollowList.push(item)
- })
- this.setData({
- hotFollowList: hotFollowList,
- total3: res.data.data.total
- })
- })
- },
- getHot(){
- //热门
- let stock_date = this.data.date
- $api.getHotbuyList({ stock_date: stock_date }).then(res => {
-
- this.setData({
- hotbuyList: res.data.data.list
- })
- wx.hideNavigationBarLoading()
- })
- // $api.getHotsellList({ stock_date: stock_date }).then(res => {
- // this.setData({
- // hotsellList: res.data.data.list
- // })
- // })
-
- },
- tabChange(e){
- this.setData({
- cur:e.target.dataset.id
- })
- this.renew()
- },
- tabChange1(e){
- this.setData({
- hot:e.target.dataset.id
- })
- },
- //预览
- preview(e){
- console.log(e)
- wx.previewImage({
- urls: e.target.dataset.urls,
- current: e.target.dataset.src
- })
- },
- curChange(e){
- if (e.detail.source == "touch"){
- this.setData({
- cur: e.detail.current
- })
- this.renew()
- }
-
- },
- //热门股票
- bindDateChange(e){
- this.setData({
- date:e.detail.value
- })
- wx.showNavigationBarLoading()
- this.getHot()
- },
- //今日留言
- next5: function () {
- if (this.data.explist.length < this.data.total5) {
- const page = this.data.page5 + 1
- this.setData({
- page5: page
- })
- this.getExp()
- }
- },
- getExp(){
- $api.getExperience({page:this.data.page5,page_size:20}).then(res=>{
- var hotFollowList = this.data.explist
- res.data.data.list.forEach(item => {
- hotFollowList.push(item)
- })
- this.setData({
- explist: hotFollowList,
- total5: res.data.data.total
- })
- })
- },
- renew(){
- this.setData({
- followList:[],
- defendList:[],
- winList:[],
- hotFollowList:[],
- hotbuyList:[],
- championList:[],
- explist:[],
- page:1,
- total:-1,
- page1: 1,
- total1: 0,
- page2: 1,
- total2: 0,
- page3: 1,
- total3: 0,
- page5: 1,
- total5: 0
- })
- switch(this.data.cur){
- case 0:
- this.getFollow()
- break;
- case 1:
- this.getHot()
- break;
- case 2:
- this.getHotFollowList()
- break;
- case 3:
- this.getExp()
- break;
- case 4:
- this.data.page6 = 1
- this.getData()
- break;
- }
- },
- onShow: function (e) {
- //判断是否报名
- $api.getAuthinfo().then(res=>{
- if(res.data.data.role==0){
- wx.navigateTo({
- url: '../login/user?type=3&player_type='+res.data.data.player_type,
- })
- }
- })
-
- // if(this.data.followList.length<=0){
- // this.getFollow()
- // }
- },
- })
|