123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307 |
- //index.js
- //获取应用实例
- const app = getApp()
- Page({
- data: {
- bringGoodsList:[],
- industryRankList:[],
- fansGrowthList:[],
- rewardInRankList:[],
- rewardOutRankList:[],
- start_time:app.func.getDay(-1,false),
- end_time:app.func.getDay(-1,false),
- reqLoading: {
- bringGoods:false,
- industryRank:false,
- fansGrowth:false,
- rewardInRank:false,
- rewardOutRank:false,
- hotDr:false,
- userMicroFollow:false
- },
- hotDrList:[],
- userMicroFollowList:[],
- swiperIndex:0
- },
- onShow: function (options) {
- if(!wx.getStorageSync('isLogin')){//解决未登录情况下,点击左上角home
- wx.redirectTo({
- url: '/pages/welcome/welcome',
- })
- }else{
- this.userMicroFollow();//首页关注列表
- }
- },
- onLoad: function () {
- //登录判断
- if(wx.getStorageSync('ttl')){
- this.getBringGoods();//带货达人
- this.getIndustryRank();//创作达人
- this.getFansGrowth();//涨粉达人
- this.getRewardInRank();//礼物收入
- this.getRewardOutRank();//土豪打赏
- this.getHotDr();
- this.userMicroFollow();//首页关注列表
- wx.showLoading({
- title: '加载中',
- })
- }
- },
- goHrDetail(e){
- wx.navigateTo({
- url: '/pages/hrDetail/hrDetail?user_id=' + e.currentTarget.dataset.userid ,
- })
- },
- swiper(e){
- this.setData({
- swiperIndex:e.detail.current
- })
- },
- goMyFollow(){//去我的关注页面
- wx.switchTab({
- url: '/pages/follow/follow',
- })
- },
- swiperGoPage(e){//点击轮播图去对应的页面
- console.log(e)
- var item = e.currentTarget.dataset.item;
- if(item.type == 2){
- if(item.is_live_now == 1){//直播中
- wx.navigateTo({
- url: '/pages/liveBoard/index?live_stream_id='+item.show_info.live_stream_id + '&user_id=' + item.user_id,
- })
- }else{//最近直播
- wx.navigateTo({
- url: '/pages/liveDetail/index?id='+item.show_info.live_stream_id + '&user_id=' + item.user_id,
- })
- }
- }else if(item.type == 1){//视频
- wx.navigateTo({
- url: '/pages/videoDetail/index?photoid=' + item.video_info.photo_id + '&userid=' + item.user_id,
- })
- }else{//暂无直播、视频数据
- wx.navigateTo({
- url: '/pages/hrDetail/hrDetail?user_id='+item.user_id,
- })
- }
- },
- goUserDetail(e){//去用户详情
- wx.navigateTo({
- url: '/pages/hrDetail/hrDetail?user_id='+e.currentTarget.dataset.user_id,
- })
- },
- userMicroFollow(){//首页关注列表
- app.func.req('/v2/api/kwai/userMicroFollow', 'get', {
- }, (res) => {
- this.loadingEvent('userMicroFollow')
- console.log(res)
- if(res && res.errno == 0){
- //成功
- this.setData({
- userMicroFollowList:res.rst
- })
- }else{
- wx.showToast({
- title: res.err,
- icon: 'none',
- duration: 2000
- })
- }
- },()=>{
- this.loadingEvent('userMicroFollow')
- })
- },
- getBringGoods(){//带货达人榜
- app.func.req('/api/bang/zhibodaihuo', 'post', {
- 'page': 1,
- 'pagesize':3,
- 'is_elite':1,
- 'starttime':this.data.start_time + ' 00:00:00',
- 'endtime':this.data.end_time + ' 23:59:59',
- 'sort_type':1
- }, (res) => {
- this.loadingEvent('bringGoods')
- if(res && res.errno == 0){
- //成功
- this.setData({
- bringGoodsList: res.rst.list
- })
- }else{
- wx.showToast({
- title: res.err,
- icon: 'none',
- duration: 2000
- })
- }
- },()=>{
- this.loadingEvent('bringGoods')
- })
- },
- getIndustryRank(){//创作达人榜
- app.func.req('/v2/api/kwaiUserTop/industryRank', 'get', {
- 'page': 1,
- 'pagesize':3,
- 'days':1
- }, (res) => {
- this.loadingEvent('industryRank')
- if(res && res.errno == 0){
- //成功
- this.setData({
- industryRankList: res.rst.data
- })
- }else{
- wx.showToast({
- title: res.err,
- icon: 'none',
- duration: 2000
- })
- }
- },()=>{
- this.loadingEvent('industryRank')
- })
- },
- getFansGrowth(){//涨粉达人榜
- app.func.req('/v2/api/kwaiUserTop/fansGrowth', 'get', {
- 'page': 1,
- 'pagesize':3,
- 'days':1
- }, (res) => {
- this.loadingEvent('fansGrowth')
- if(res && res.errno == 0){
- //成功
- this.setData({
- fansGrowthList: res.rst.data
- })
- }else{
- wx.showToast({
- title: res.err,
- icon: 'none',
- duration: 2000
- })
- }
- },()=>{
- this.loadingEvent('fansGrowth')
- })
- },
- getRewardInRank(){//礼物收入榜
- app.func.req('/v2/api/show/rewardInRank', 'get', {
- 'page': 1,
- 'pagesize':3,
- }, (res) => {
- this.loadingEvent('rewardInRank')
- if(res && res.errno == 0){
- //成功
- this.setData({
- rewardInRankList: res.rst.data.slice(0,3)
- })
- }else{
- wx.showToast({
- title: res.err,
- icon: 'none',
- duration: 2000
- })
- }
- },()=>{
- this.loadingEvent('rewardInRank')
- })
- },
- getRewardOutRank(){//土豪打赏榜
- app.func.req('/v2/api/show/rewardOutRank', 'get', {
- 'page': 1,
- 'pagesize':3,
- 'start_time':this.data.start_time,
- 'end_time':this.data.end_time
- }, (res) => {
- this.loadingEvent('rewardOutRank')
- if(res && res.errno == 0){
- //成功
- this.setData({
- rewardOutRankList: res.rst.data.slice(0,3)
- })
- }else{
- wx.showToast({
- title: res.err,
- icon: 'none',
- duration: 2000
- })
- }
- },()=>{
- this.loadingEvent('rewardOutRank')
- })
- },
- getHotDr(){//热门达人
- app.func.req('/api/kwaiUser/redUserList', 'get', {
- 'page': 1,
- 'pagesize':10,
- 'starttime':app.func.getDay(-30,false),
- 'endtime':app.func.getDay(-1,false)
- }, (res) => {
- this.loadingEvent('hotDr')
- if(res && res.errno == 0){
- //成功
- var list = res.rst.data;
- list.forEach((item)=>{
- if(item.categorys){
- item.categorys_arr = item.categorys.splice(',')
- }
- })
- this.setData({
- hotDrList: res.rst.data
- })
- }else{
- wx.showToast({
- title: res.err,
- icon: 'none',
- duration: 2000
- })
- }
- },()=>{
- this.loadingEvent('hotDr')
- })
- },
- loadingEvent(req){
- var data = `reqLoading.${req}`;
- this.setData({
- [data]:true
- })
- var flag = false;
- for(var i in this.data.reqLoading){
- if(!this.data.reqLoading[i]){
- flag = true;
- }
- }
- if(!flag){
- //接口全部加载完毕
- wx.hideLoading()
- }
- },
- goSearch(){
- wx.navigateTo({
- url: '/pages/search/search?type=1',
- })
- },
- onShareAppMessage: function () {
- var that = this;
- return {
- title: '酷炫网络',
- desc: '',
- path: 'pages/index/index',
- imageUrl: 'https://kx-bigdata.oss-cn-beijing.aliyuncs.com/Applet/shareImg.png?v=1.0.1',
- success: function (res) {
- // 转发成功
- wx.showToast({
- title: '分享成功',
- icon: "none"
- });
- },
- fail: function (res) {
- // 转发失败
- wx.showToast({
- title: '分享失败',
- icon: "none"
- })
- }
- }
- }
- })
|