123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177 |
- const app = getApp()
- Page({
- data: {
- safeAreaTop:0,//距离上面的安全距离
- userMicroFollowList:[],
- hotVideoList:[],//热门视频
- statusNavBarHeight:app.data.statusNavBarHeight,
- videoTopicsList:[],//标签话题
- },
- onLoad() {
- this.init()
- this.getFollow()
- this.getVideoHotList()
- this.videoTopics()
- },
- onShow(){
- this.getFollow()
- this.getVideoHotList()
- },
- onPullDownRefresh: function () {//下拉加载
- this.getFollow()
- this.getVideoHotList()
- this.videoTopics()
- },
- goPageClaim(){
- swan.navigateTo({
- url: '/pages/claim/index/index',
- })
- },
- goSearch() {
- swan.navigateTo({
- url: '/pages/search/search',
- })
- },
- gpLivePage(){
- swan.navigateTo({
- url: '/pages/live/index/index',
- })
- },
- goUserDetail(e){
- swan.navigateTo({
- url: '/pages/userDrtail/index?user_id='+e.currentTarget.dataset.user_id,
- })
- },
- goVideoDetail(e){
- swan.navigateTo({
- url: '/pages/videoDetail/videoDetail?video_id='+e.currentTarget.dataset.item.video_id+'&user_id='+e.currentTarget.dataset.item.user_id,
- })
- },
- switchPlatform(){//平台切换
- var _this = this;
- swan.showActionSheet({
- itemList: ['快手版', '抖音版'],
- success (res) {
- if(res.tapIndex == 1||res.tapIndex == 0){
- swan.navigateToMiniProgram({
- appId: 'wx187b26eedae4ad85',
- path: '/pages/index/index?platform='+(res.tapIndex+1),
- success(res) {
- swan.showToast({
- title: '跳转成功',
- })
- },
- fail(err) {
- }
- })
- }
- },
- fail (res) {
- }
- })
- },
- init(){//初始化
- this.setData({
- safeAreaTop:app.data.safeAreaTop,
- })
- },
- getFollow(){//我的收藏
- app.func.req('/api/sphUserConsole/followList', 'get', {
- page:1,
- page_size:10,
- start_time:app.func.getDay(-1,false),
- end_time: app.func.getDay(-1,false),
- sort:'fans_count'
- }, (res) => {
- swan.stopPullDownRefresh();
- if(res && res.errno == 0){
- //成功
- this.setData({
- userMicroFollowList:res.rst.data.slice(0,6)
- })
- }else{
- swan.showToast({
- title: res.err,
- icon: 'none',
- duration: 2000
- })
- }
- },()=>{
- swan.stopPullDownRefresh();
- })
- },
- getVideoHotList(){//热门视频
- app.func.req('/api/sphVideo/hotList', 'get', {
- page:1,
- pagesize:10,
- }, (res) => {
- if(res && res.errno == 0){
- //成功
- this.setData({
- hotVideoList:res.rst.data
- })
- }else{
- swan.showToast({
- title: res.err,
- icon: 'none',
- duration: 2000
- })
- }
- },()=>{
- })
- },
- videoTopics(){//标签话题
- app.func.req('/api/sphVideo/videoTopics', 'get', {
- type:3,
- sort:'like_count_avg'
- }, (res) => {
- if(res && res.errno == 0){
- //成功
- var arr = res.rst.slice(0,6)
- arr.forEach((item)=>{
- item.like_count_avg = app.func.NumberHandle(item.like_count_avg)
- item.red_count = app.func.NumberHandle(item.red_count)
- })
- this.setData({
- videoTopicsList:res.rst.slice(0,6)
- })
- }else{
- swan.showToast({
- title: res.err,
- icon: 'none',
- duration: 2000
- })
- }
- },()=>{
- })
- },
- goPageSwitch(e){
- var data = e.currentTarget.dataset;
- if(data.page == '/pages/cyRank/index'){
- app.data.cyRank_type = data.type
- }
- swan.switchTab({
- url: data.page,
- })
- },
- toTopic(e) {
- swan.navigateTo({
- url: '/pages/topicDetail/topicDetail?name='+e.currentTarget.dataset.item.topic_name,
- })
- },
- goLogin(){
- swan.redirectTo({
- url: '/pages/welcome/welcome',
- })
- },
- goSphRank(){
- swan.switchTab({
- url: '/pages/sphRank/index',
- })
- },
- onShareAppMessage: function (res) {
- return app.shareEvent(res,'/pages/index/index')
- }
- })
|