You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

238 lines
5.6 KiB

3 years ago
// index.js
3 years ago
import {time} from '../../utils/util'
3 years ago
// 获取应用实例
3 years ago
import {
http,
formatTime
} from '../../utils/util'
import {
cdn
} from '../../utils/config'
3 years ago
const app = getApp()
Page({
data: {
3 years ago
cdn: getApp().globalData.cdn,
numlist: [],
toplist: [
3 years ago
{
url: '/images/ic_bofang@3x.png',
title: '总播放量',
num: '0'
},
3 years ago
{
url: '/images/ic_dianzan@3x.png',
title: '总点赞数',
num: '0'
}, {
url: '/images/collection@3x.png',
title: '总收藏数',
num: '0'
}, {
url: '/images/comment@3x.png',
title: '总评论数',
num: '0'
},
{
url: '/images/ic_zhuanfa@3x.png',
title: '总转发数',
num: '0'
},
{
url: '/images/ic_tuijian@3x.png',
title: '总推荐数',
num: '0'
},
],
3 years ago
rankurl: [
'/images/img_diyi@3x.png',
'/images/img_dier@3x.png',
'/images/img_disan@3x.png'
],
3 years ago
records: [],
disranking: [{
url: '/images/img_diyi@3x.png',
name: '-',
3 years ago
add: ''
}, {
url: '/images/img_dier@3x.png',
3 years ago
name: '-',
3 years ago
add: ''
}, {
url: '/images/img_disan@3x.png',
3 years ago
name: '-',
3 years ago
add: ''
}],
3 years ago
staranking: [{
url: '/images/img_diyi@3x.png',
3 years ago
name: '-',
dis: '-'
3 years ago
}, {
url: '/images/img_dier@3x.png',
3 years ago
name: '-',
dis: '-'
3 years ago
}, {
url: '/images/img_disan@3x.png',
3 years ago
name: '-',
dis: '-'
3 years ago
}],
3 years ago
page: 1,
size: 3,
month: ''
3 years ago
},
to(e) {
console.log(e.target.dataset.url)
wx.navigateTo({
url: e.target.dataset.url
})
},
onLoad: function (options) {
3 years ago
// wx.setNavigationBarTitle({
// title: '',
// success: function (res) {}
// })
3 years ago
wx.setNavigationBarColor({
frontColor: '#ffffff',
backgroundColor: '#006BFF',
animation: {
duration: 400,
timingFunc: 'easeIn'
}
})
3 years ago
this.getrecordslist()
this.RankingList()
this.numlist()
this.setData({
month:this.getPreMonth(formatTime(new Date()).split(' ')[0]).split('-')[0]+'-'+this.getPreMonth(formatTime(new Date()).split(' ')[0]).split('-')[1]
})
3 years ago
},
3 years ago
//总数
3 years ago
numlist() {
http("/rank/myEffect", "post", {}).then(res => {
3 years ago
this.setData({
3 years ago
'toplist[0].num': res.data.playNumSum,
'toplist[1].num': res.data.commendNumSum,
'toplist[2].num': res.data.collectionNumSum,
'toplist[3].num': res.data.commentNumSum,
'toplist[4].num': res.data.reSendNumSum,
'toplist[5].num': res.data.recommendNumSum
3 years ago
})
})
},
//品牌动态
3 years ago
getrecordslist() {
3 years ago
http("/topicActivity/list", "post", {
3 years ago
showAtIndex: 1
}).then(res => {
3 years ago
let arr = []
for (let index = 0; index < res.data.records.length; index++) {
const element = res.data.records[index];
element.time = time(element.duration)
arr.push(element)
}
// console.log(arr)
3 years ago
this.setData({
3 years ago
records: arr
3 years ago
})
})
},
3 years ago
//排行榜
3 years ago
RankingList() {
let mon = this.getPreMonth(formatTime(new Date()).split(' ')[0])+' '+ formatTime(new Date()).split(' ')[1]
3 years ago
http("/rank/list", "post", {
3 years ago
pageNum: this.data.page,
pageSize: this.data.size,
type: 1,
dateTime:mon
}).then(res => {
let count = 0
3 years ago
res.data.forEach(el=>{
3 years ago
let str = 'disranking['+count+'].name'
let str2 = 'disranking['+count+'].add'
this.setData({
[str]:el.title,
3 years ago
[str2]:el.effectValue
3 years ago
})
count++
3 years ago
})
3 years ago
this.setData({
disranking: this.data.disranking.slice(0, 3)
})
3 years ago
})
3 years ago
http("/rank/list", "post", {
pageNum: this.data.page,
pageSize: this.data.size,
type: 2,
dateTime:mon
}).then(res => {
let count = 0
3 years ago
res.data.forEach(el=>{
3 years ago
let str = 'staranking['+count+'].name'
let str2 = 'staranking['+count+'].dis'
this.setData({
[str]:el.title,
[str2]:el.subtitle
})
count++
})
3 years ago
this.setData({
staranking: this.data.staranking.slice(0, 3)
})
3 years ago
})
},
getPreMonth(date) {
var arr = date.split('-');
var year = arr[0]; //获取当前日期的年份
var month = arr[1]; //获取当前日期的月份
var day = arr[2]; //获取当前日期的日
var days = new Date(year, month, 0);
days = days.getDate(); //获取当前日期中月的天数
var year2 = year;
var month2 = parseInt(month) - 1;
if (month2 == 0) {
year2 = parseInt(year2) - 1;
month2 = 12;
}
var day2 = day;
var days2 = new Date(year2, month2, 0);
days2 = days2.getDate();
if (day2 > days2) {
day2 = days2;
}
if (month2 < 10) {
month2 = '0' + month2;
}
var t2 = year2 + '-' + month2 + '-' + day2;
return t2;
3 years ago
},
//查看全部
3 years ago
detail(e) {
3 years ago
console.log(e)
wx.setStorageSync('info', e.currentTarget.dataset.cycle_id)
wx.navigateTo({
3 years ago
url: "/pages/index/subpage/brand/brandDetails/brandDetails?id="
3 years ago
})
3 years ago
3 years ago
},
/**
* 页面相关事件处理函数--监听用户下拉动作
*/
onPullDownRefresh() {
this.onRefresh()
},
3 years ago
onRefresh: function () {
//导航条加载动画
wx.showNavigationBarLoading()
//loading 提示框
wx.showLoading({
title: 'Loading...',
})
console.log("下拉刷新啦");
3 years ago
this.getrecordslist()
setTimeout(function () {
wx.hideLoading();
wx.hideNavigationBarLoading();
//停止下拉刷新
wx.stopPullDownRefresh();
}, 2000)
},
3 years ago
})