「小程序JAVA實戰(zhàn)」小程序的個人信息作品蘑秽,收藏饺著,關(guān)注(66)

原創(chuàng)文章,歡迎轉(zhuǎn)載肠牲。轉(zhuǎn)載請注明:轉(zhuǎn)載自IT人故事會幼衰,謝謝!
原文鏈接地址:「小程序JAVA實戰(zhàn)」小程序的個人信息作品缀雳,收藏渡嚣,關(guān)注(66)

個人信息頁面有一個tab(作品,收藏肥印,關(guān)注)源碼:https://github.com/limingios/wxProgram.git 中No.15和springboot

作品识椰,收藏,關(guān)注的列表

VideoController.java

package com.idig8.controller;

import java.io.File;
import java.util.Date;
import java.util.UUID;

import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.multipart.MultipartFile;

import com.idig8.pojo.Bgm;
import com.idig8.pojo.Videos;
import com.idig8.service.BgmService;
import com.idig8.service.VideoService;
import com.idig8.utils.FetchVideoCover;
import com.idig8.utils.JSONResult;
import com.idig8.utils.MergeVideoMp3;
import com.idig8.utils.PagedResult;
import com.idig8.utils.enums.VideoStatusEnum;
import com.idig8.utils.file.FileUtil;

import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;


@RestController
@Api(value="視頻相關(guān)業(yè)務(wù)的接口", tags= {"視頻相關(guān)業(yè)務(wù)的controller"})
@RequestMapping("/video")
public class VideoController extends BasicController {
    
    @Autowired
    private BgmService bgmService;
    
    @Autowired
    private VideoService videosService;
    
    @Value("${server.file.path}")
    private String fileSpace;
    
    @Value("${server.ffmpeg.path}")
    private String ffmpegexe;
    
    
    @ApiOperation(value="上傳視頻", notes="上傳視頻的接口")
    @ApiImplicitParams({
        @ApiImplicitParam(name="userId", value="用戶id", required=true, 
                dataType="String", paramType="form"),
        @ApiImplicitParam(name="bgmId", value="背景音樂id", required=false, 
                dataType="String", paramType="form"),
        @ApiImplicitParam(name="videoSeconds", value="背景音樂播放長度", required=true, 
                dataType="String", paramType="form"),
        @ApiImplicitParam(name="videoWidth", value="視頻寬度", required=true, 
                dataType="String", paramType="form"),
        @ApiImplicitParam(name="videoHeight", value="視頻高度", required=true, 
                dataType="String", paramType="form"),
        @ApiImplicitParam(name="desc", value="視頻描述", required=false, 
                dataType="String", paramType="form")
    })
    @PostMapping(value="/upload", headers="content-type=multipart/form-data")
    public JSONResult upload(String userId, 
                String bgmId, double videoSeconds, 
                int videoWidth, int videoHeight,
                String desc,
                @ApiParam(value="短視頻", required=true)
                MultipartFile file) throws Exception {
        
        if (StringUtils.isBlank(userId)) {
            return JSONResult.errorMsg("用戶id不能為空...");
        }
        // 文件保存的命名空間
        String fileName = file.getOriginalFilename();
        // 保存到數(shù)據(jù)庫中的相對路徑
        String path = "";
        String videOutPath = "";
        String ImagePath = "";
        try {
             path = FileUtil.uploadFile(file.getBytes(), fileSpace, fileName);
            } catch (Exception e) {
                e.getStackTrace();
                   return JSONResult.errorMsg(e.getMessage());
            }                
         
    
        if(StringUtils.isNotBlank(bgmId)){
            Bgm bgm = bgmService.queryBgmById(bgmId);
            String mp3BgmPath = fileSpace + bgm.getPath();
            MergeVideoMp3 mergeVideoMp3 = new MergeVideoMp3(ffmpegexe);
            String videOutPathName = UUID.randomUUID().toString()+".mp4";
            File targetFile = new File(fileSpace + userId);
            if (!targetFile.exists()) {
                targetFile.mkdirs();
            }
            videOutPath = "/"+userId+"/"+videOutPathName;
            String videoInput = fileSpace +path;
            mergeVideoMp3.convertor(videoInput, mp3BgmPath, videoSeconds, fileSpace +videOutPath);
            
        }else{
            videOutPath = path;
            
        }
        
        ImagePath =  "/"+userId+"/"+UUID.randomUUID().toString()+".jpg";;
        FetchVideoCover fetchVideoCover = new FetchVideoCover(ffmpegexe);
        fetchVideoCover.getCover(fileSpace +videOutPath, fileSpace +ImagePath);
        
        
        Videos videos = new Videos();
        videos.setAudioId(bgmId);
        videos.setCreateTime(new Date());
        videos.setVideoDesc(desc);
        videos.setId(UUID.randomUUID().toString());
        videos.setUserId(userId);
        videos.setVideoHeight(videoHeight);
        videos.setVideoWidth(videoWidth);
        videos.setVideoPath(videOutPath);
        videos.setCoverPath(ImagePath);
        videos.setStatus(VideoStatusEnum.SUCCESS.value);
        videosService.saveVideo(videos);
                 
        return JSONResult.ok(path);
        
    }
    
    @PostMapping(value="/showAll")
    @ApiOperation(value="視頻列表", notes="分頁的視頻列表")
    public JSONResult showAll(@RequestBody Videos video,Integer isSaveRecord,
            Integer page) throws Exception {
        if(page == null){
            page = 1;
        }
        PagedResult result = videosService.getAllVideos(video,isSaveRecord,page, PAGE_SIZE);     
        return JSONResult.ok(result);
        
    }
    
    @PostMapping(value="/userLike")
    @ApiOperation(value="熱搜詞列表", notes="熱搜詞列表")
    public JSONResult userLike(String userId,String videoId,String videoCreaterId) throws Exception {
        
        videosService.userLikeVideo(userId, videoId, videoCreaterId);
        return JSONResult.ok();
        
    }
    
    @PostMapping(value="/userUnLike")
    public JSONResult userUnLike(String userId,String videoId,String videoCreaterId) throws Exception {
        videosService.userUnLikeVideo(userId, videoId, videoCreaterId);
        return JSONResult.ok();
        
    }
    
    @PostMapping(value="/hot")
    public JSONResult upload() throws Exception {
 
        return JSONResult.ok(videosService.gethostList());
        
    }
    
    @PostMapping(value="/showMyLike")
    public JSONResult showMyLike(String userId,Integer page,Integer pageSize) throws Exception {
        if(StringUtils.isBlank(userId)){
            return JSONResult.ok();
        }
        
        if(page == null){
            page = 1;
        }
        
        if(pageSize == null){
            pageSize = PAGE_SIZE;
        }
        
        PagedResult videoList = videosService.queryMyLikeVideos(userId,page,pageSize);
        
        
        return JSONResult.ok(videoList);
        
    }
    
    @PostMapping(value="/showMyFollow")
    public JSONResult showMyFollow(String userId,Integer page,Integer pageSize) throws Exception {
        if(StringUtils.isBlank(userId)){
            return JSONResult.ok();
        }
        
        if(page == null){
            page = 1;
        }
        
        if(pageSize == null){
            pageSize = PAGE_SIZE;
        }
        
        PagedResult videoList = videosService.queryMyFollowVideos(userId,page,pageSize);
        
        
        return JSONResult.ok(videoList);
        
    }
    
    
}

VideoService.java

package com.idig8.service;

import java.util.List;

import com.idig8.pojo.Videos;
import com.idig8.utils.PagedResult;

public interface VideoService {

    
    /**
     * 保存視頻信息
     * @param Id
     * @return
     */
    public String saveVideo(Videos video);
    
    /**
     * 分析查詢視頻列表
     * @param video
     * @param isSaveRecord
     * @param page
     * @param pageSize
     * @return
     */
    public PagedResult getAllVideos(Videos video,Integer isSaveRecord,Integer page,Integer pageSize);
    
    /**
     * 獲取熱搜詞列表
     * @return
     */
    public List<String> gethostList();
    
    public void userLikeVideo(String userId,String videoId,String videoCreaterId);
    
    public void userUnLikeVideo(String userId,String videoId,String videoCreaterId);
    
    public PagedResult queryMyLikeVideos(String userId,Integer page,Integer pageSize);
    
    public PagedResult queryMyFollowVideos(String userId,Integer page,Integer pageSize);
    
}
    

VideoServiceImpl.java

package com.idig8.service.Impl;

import java.util.List;

import org.n3r.idworker.Sid;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.idig8.mapper.SearchRecordsMapper;
import com.idig8.mapper.UsersLikeVideosMapper;
import com.idig8.mapper.UsersMapper;
import com.idig8.mapper.VideosMapper;
import com.idig8.mapper.VideosUsersMapper;
import com.idig8.pojo.SearchRecords;
import com.idig8.pojo.UsersLikeVideos;
import com.idig8.pojo.Videos;
import com.idig8.pojo.vo.VideosVO;
import com.idig8.service.VideoService;
import com.idig8.utils.PagedResult;

import tk.mybatis.mapper.entity.Example;
import tk.mybatis.mapper.entity.Example.Criteria;

@Service
public class VideoServiceImpl implements VideoService {

    @Autowired
    private VideosMapper videosMapper;

    @Autowired
    private UsersMapper usersMapper;

    @Autowired
    private VideosUsersMapper videosUsersMapper;

    @Autowired
    private SearchRecordsMapper searchRecordsMapper;

    @Autowired
    private UsersLikeVideosMapper usersLikeVideosMapper;

    @Autowired
    private Sid sid;

    @Transactional(propagation = Propagation.REQUIRED)
    public String saveVideo(Videos video) {
        String id = sid.nextShort();
        video.setId(id);

        videosMapper.insertSelective(video);
        return id;

    }

    @Override
    @Transactional(propagation = Propagation.REQUIRED)
    public PagedResult getAllVideos(Videos video, Integer isSaveRecord, Integer page, Integer pageSize) {

        String desc = video.getVideoDesc();
        String userId = video.getUserId();
        if (isSaveRecord != null && isSaveRecord == 1) {
            SearchRecords record = new SearchRecords();
            String recordId = sid.nextShort();
            record.setId(recordId);
            record.setContent(desc);
            searchRecordsMapper.insert(record);
        }

        PageHelper.startPage(page, pageSize);
        List<VideosVO> list = videosUsersMapper.queryAllVideos(desc,userId);
        PageInfo<VideosVO> pageList = new PageInfo<>(list);

        PagedResult result = new PagedResult();
        result.setPage(page);
        result.setTotal(pageList.getPages());
        result.setRows(list);
        result.setRecords(pageList.getTotal());

        return result;
    }

    @Transactional(propagation = Propagation.SUPPORTS)
    @Override
    public List<String> gethostList() {

        return searchRecordsMapper.gethotList();
    }

    @Override
    public void userLikeVideo(String userId, String videoId, String videoCreaterId) {

        // 1.保存用戶和視頻的關(guān)聯(lián)關(guān)系
        String likeId = sid.nextShort();
        UsersLikeVideos usersLikeVideos = new UsersLikeVideos();
        usersLikeVideos.setId(likeId);
        usersLikeVideos.setUserId(userId);
        usersLikeVideos.setVideoId(videoId);
        usersLikeVideosMapper.insert(usersLikeVideos);

        // 2.視頻喜歡的累加
        videosUsersMapper.addVideoLikeCount(videoId);

        // 3. 用戶喜歡的累加
        usersMapper.addReceiveLikeCount(userId);

    }

    @Override
    public void userUnLikeVideo(String userId, String videoId, String videoCreaterId) {
        Example example = new Example(UsersLikeVideos.class);
        Criteria criteria = example.createCriteria();
        criteria.andEqualTo("userId", userId);
        criteria.andEqualTo("videoId", videoId);
        usersLikeVideosMapper.deleteByExample(example);
        // 2.視頻喜歡的累減
        videosUsersMapper.reduceVideoLikeCount(videoId);

        // 3. 用戶喜歡的累減
        usersMapper.reduceReceiveLikeCount(userId);
    }

    @Override
    public PagedResult queryMyLikeVideos(String userId, Integer page, Integer pageSize) {
        PageHelper.startPage(page,pageSize);
        List<VideosVO> list = videosUsersMapper.queryMyLikeVideos(userId);
        
        PageInfo<VideosVO> pageList = new PageInfo<>(list);
        PagedResult pagedResult = new PagedResult();
        pagedResult.setTotal(pageList.getPages());
        pagedResult.setRows(list);
        pagedResult.setPage(page);
        pagedResult.setRecords(pageList.getTotal());
        
        return pagedResult;
    }

    @Override
    public PagedResult queryMyFollowVideos(String userId, Integer page, Integer pageSize) {
        PageHelper.startPage(page,pageSize);
        List<VideosVO> list = videosUsersMapper.queryMyFollowVideos(userId);
        
        PageInfo<VideosVO> pageList = new PageInfo<>(list);
        PagedResult pagedResult = new PagedResult();
        pagedResult.setTotal(pageList.getPages());
        pagedResult.setRows(list);
        pagedResult.setPage(page);
        pagedResult.setRecords(pageList.getTotal());
        
        return pagedResult;
    }
    
    
}

VideosUsersMapper.java

package com.idig8.mapper;

import java.util.List;

import org.apache.ibatis.annotations.Param;

import com.idig8.pojo.vo.VideosVO;
import com.idig8.utils.MyMapper;

public interface VideosUsersMapper extends MyMapper<VideosVO> {
    
    public List<VideosVO> queryAllVideos(@Param("videoDesc") String videoDesc,@Param("userId")String userId);
    
    public void addVideoLikeCount(String videoId);
    
    public void reduceVideoLikeCount(String videoId);
    
    public List<VideosVO> queryMyLikeVideos(String userId);
    
    public List<VideosVO> queryMyFollowVideos(String userId);
    
}

VideosUserMapper.xml

<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd" >
<mapper namespace="com.idig8.mapper.VideosUsersMapper" >
  <resultMap id="BaseResultMap" type="com.idig8.pojo.vo.VideosVO" >
    <!--
      WARNING - @mbg.generated
    -->
    <id column="id" property="id" jdbcType="VARCHAR" />
    <result column="user_id" property="userId" jdbcType="VARCHAR" />
    <result column="audio_id" property="audioId" jdbcType="VARCHAR" />
    <result column="video_desc" property="videoDesc" jdbcType="VARCHAR" />
    <result column="video_path" property="videoPath" jdbcType="VARCHAR" />
    <result column="video_seconds" property="videoSeconds" jdbcType="REAL" />
    <result column="video_width" property="videoWidth" jdbcType="INTEGER" />
    <result column="video_height" property="videoHeight" jdbcType="INTEGER" />
    <result column="cover_path" property="coverPath" jdbcType="VARCHAR" />
    <result column="like_counts" property="likeCounts" jdbcType="BIGINT" />
    <result column="status" property="status" jdbcType="INTEGER" />
    <result column="create_time" property="createTime" jdbcType="TIMESTAMP" />
    <result column="username" property="username" jdbcType="VARCHAR" />
    <result column="face_image" property="faceImage" jdbcType="VARCHAR" />
    <result column="nickname" property="nickname" jdbcType="VARCHAR" />
  </resultMap>
  
  <select id="queryAllVideos" resultMap="BaseResultMap" parameterType="String">
    select v.*,u.face_image,u.username,u.nickname from videos v
    left join users u on v.user_id = u.id
    where 
        1 = 1
        <if test="videoDesc !=null  and videoDesc != '' ">
            and v.video_desc like '%${videoDesc}%'
        </if>
        
        <if test="userId !=null  and userId != '' ">
            and v.user_id = #{userId}
        </if>
        and v.status = 1
    order by v.create_time
    
  </select>
  
  
  <update id="addVideoLikeCount" parameterType="String">
    update videos set like_counts=like_counts+1 where id=#{videoId}
  </update>
  
   <update id="reduceVideoLikeCount" parameterType="String">
    update videos set like_counts=like_counts-1 where id=#{videoId}
  </update>
  
  
  <select id="queryMyLikeVideos" resultMap="BaseResultMap" parameterType="String">
    select v.*,u.face_image as face_image,u.nickname as nickname from videos v
    left join users u on v.user_id = u.id
    where
       v.id in (select ulv.video_id from users_like_videos ulv where ulv.user_id = #{userId})
       and v.status = 1
       order by v.create_time desc
  </select>
  
  
   <select id="queryMyFollowVideos" resultMap="BaseResultMap" parameterType="String">
    select v.*,u.face_image as face_image,u.nickname as nickname from videos v
    left join users u on v.user_id = u.id
    where
       v.id in (select uf.user_id from users_fans uf where uf.fan_id = #{userId})
       and v.status = 1
       order by v.create_time desc
  </select>
</mapper>

小程序開發(fā)

mine.js

// pages/mine/mine.js
const app = getApp()
var videoUtils = require('../../utils/videoUtils.js')
Page({

  /**
   * 頁面的初始數(shù)據(jù)
   */
  data: {
    faceImage: "../../resource/images/noneface.png",
    nickname: "昵稱",
    fansCounts: 0,
    followCounts: 0,
    receiveLikeCounts: 0,
    isMe:true,
    isFollow:false,
    publisherId: '',

    videoSelClass: "video-info",
    isSelectedWork: "video-info-selected",
    isSelectedLike: "",
    isSelectedFollow: "",

    myVideoList: [],
    myVideoPage: 1,
    myVideoTotal: 1,

    likeVideoList: [],
    likeVideoPage: 1,
    likeVideoTotal: 1,

    followVideoList: [],
    followVideoPage: 1,
    followVideoTotal: 1,

    myWorkFalg: false,
    myLikesFalg: true,
    myFollowFalg: true
  },
  /**
   * 用戶注銷
   */
  logout: function(e) {
    var user = app.getGlobalUserInfo();
    wx.showLoading({
      title: '正在注銷中竖独。裤唠。。'
    });




    wx.request({
      url: app.serverUrl + "/logout?userId=" + user.id,
      method: "POST",
      header: {
        'content-type': 'application/json' // 默認(rèn)值
      },
      success: function(res) {
        console.log(res.data);
        var status = res.data.status;
        wx.hideLoading();
        if (status == 200) {
          wx.showToast({
            title: "用戶注銷成功~莹痢!",
            icon: 'none',
            duration: 3000
          })
          // app.userInfo = null;
          wx.removeStorageSync("userInfo");
          wx.redirectTo({
            url: '../userRegister/userRegister',
          })

        } else if (status == 500) {
          wx.showToast({
            title: res.data.msg,
            icon: 'none',
            duration: 3000
          })
        }
      }
    })
  },

  followMe: function (e) {
    var me = this;

    var user = app.getGlobalUserInfo();
    var userId = user.id;
    var publisherId = me.data.publisherId;

    var followType = e.currentTarget.dataset.followtype;



    // 1:關(guān)注 0:取消關(guān)注
    var url = '';
    if (followType == '1') {
      url = '/user/beyourfans?userId=' + publisherId + '&fanId=' + userId;
    } else {
      url = '/user/dontbeyourfans?userId=' + publisherId + '&fanId=' + userId;
    }

    wx.showLoading();
    wx.request({
      url: app.serverUrl + url,
      method: 'POST',
      header: {
        'content-type': 'application/json', // 默認(rèn)值
        'headerUserId': user.id,
        'headerUserToken': user.userToken
      },
      success: function () {
        wx.hideLoading();
        if (followType == '1') {
          me.setData({
            isFollow: true,
            fansCounts: ++me.data.fansCounts
          })
        } else {
          me.setData({
            isFollow: false,
            fansCounts: --me.data.fansCounts
          })
        }
      }
    })
  },
  /**
   * 頭像上傳
   */
  uploadFace: function(e) {
    // var user = app.userInfo;
    var user = app.getGlobalUserInfo();
    var me = this;
    wx.chooseImage({
      count: 1, // 默認(rèn)9
      sizeType: ['compressed'], // 可以指定是原圖還是壓縮圖种蘸,默認(rèn)二者都有
      sourceType: ['album', 'camera'], // 可以指定來源是相冊還是相機(jī),默認(rèn)二者都有
      success: function(res) {
        // 返回選定照片的本地文件路徑列表竞膳,tempFilePath可以作為img標(biāo)簽的src屬性顯示圖片
        var tempFilePaths = res.tempFilePaths
        if (tempFilePaths.length > 0) {
          console.log(tempFilePaths[0]);
          wx.uploadFile({
            url: app.serverUrl + "/user/uploadFace?userId=" + user.id, //僅為示例航瞭,非真實的接口地址
            filePath: tempFilePaths[0],
            name: 'file',
            success: function(res) {
              var data = JSON.parse(res.data);
              console.log(data);
              wx.hideLoading();
              if (data.status == 200) {
                wx.showToast({
                  title: "用戶上傳成功~!",
                  icon: 'none',
                  duration: 3000
                })
                me.setData({
                  faceUrl: app.serverUrl + data.data
                })


              } else if (data.status == 500) {
                wx.showToast({
                  title: data.msg,
                  icon: 'none',
                  duration: 3000
                })
              }
            }
          })
        }

      }
    })
  },
  /**
   * 生命周期函數(shù)--監(jiān)聽頁面加載
   */
  onLoad: function(params) {
    var me = this;

    var userInfo = app.getGlobalUserInfo();
    var publisherId = params.publisherId;
    var userId = userInfo.id;
    if (publisherId != null && publisherId != '' && publisherId!=undefined){
      userId = publisherId;
      me.setData({
        isMe:false,
        publisherId: publisherId,
      })
    }

  
    wx.showLoading({
      title: '正在獲取用戶信息坦辟。刊侯。。'
    });
    wx.request({
      url: app.serverUrl + "/user/queryByUserId?userId=" + userId + "&fanId" + userInfo.id,
      method: "POST",
      header: {
        'content-type': 'application/json', // 默認(rèn)值
        'headerUserId': userInfo.id,
        'headerUserToken': userInfo.userToken
      },
      success: function(res) {
        console.log(res.data);
        var status = res.data.status;

        if (status == 200) {
          var userInfo = res.data.data;
          wx.hideLoading();
          var faceImage = me.data.faceUrl;
          if (userInfo.faceImage != null && userInfo.faceImage != '' && userInfo.faceImage != undefined) {
            faceImage = app.serverUrl + userInfo.faceImage;
          }

          me.setData({
            faceImage: faceImage,
            fansCounts: userInfo.fansCounts,
            followCounts: userInfo.followCounts,
            receiveLikeCounts: userInfo.receiveLikeCounts,
            nickname: userInfo.nickname,
            isFollow: userInfo.follow

          })
          me.getMyVideoList(1)
        } else if (status == 502){
          wx.showToast({
            title: res.data.msg,
            duration:3000,
            icon:'none',
            complete:function(){
              wx.removeStorageSync("userInfo");

              wx.navigateTo({
                url: '../userLogin/userLogin',
              })
            }
          })
          
        }
      }
    })
  },

  uploadVideo: function(e) {
    videoUtils.uploadVideo();
  },

  doSelectWork: function () {
    this.setData({
      isSelectedWork: "video-info-selected",
      isSelectedLike: "",
      isSelectedFollow: "",

      myWorkFalg: false,
      myLikesFalg: true,
      myFollowFalg: true,

      myVideoList: [],
      myVideoPage: 1,
      myVideoTotal: 1,

      likeVideoList: [],
      likeVideoPage: 1,
      likeVideoTotal: 1,

      followVideoList: [],
      followVideoPage: 1,
      followVideoTotal: 1
    });

    this.getMyVideoList(1);
  },

  doSelectLike: function () {
    this.setData({
      isSelectedWork: "",
      isSelectedLike: "video-info-selected",
      isSelectedFollow: "",

      myWorkFalg: true,
      myLikesFalg: false,
      myFollowFalg: true,

      myVideoList: [],
      myVideoPage: 1,
      myVideoTotal: 1,

      likeVideoList: [],
      likeVideoPage: 1,
      likeVideoTotal: 1,

      followVideoList: [],
      followVideoPage: 1,
      followVideoTotal: 1
    });

    this.getMyLikesList(1);
  },

  doSelectFollow: function () {
    this.setData({
      isSelectedWork: "",
      isSelectedLike: "",
      isSelectedFollow: "video-info-selected",

      myWorkFalg: true,
      myLikesFalg: true,
      myFollowFalg: false,

      myVideoList: [],
      myVideoPage: 1,
      myVideoTotal: 1,

      likeVideoList: [],
      likeVideoPage: 1,
      likeVideoTotal: 1,

      followVideoList: [],
      followVideoPage: 1,
      followVideoTotal: 1
    });

    this.getMyFollowList(1)
  },

  getMyVideoList: function (page) {
    var me = this;

    // 查詢視頻信息
    wx.showLoading();
    // 調(diào)用后端
    var serverUrl = app.serverUrl;
    wx.request({
      url: serverUrl + '/video/showAll/?page=' + page + '&pageSize=6',
      method: "POST",
      data: {
        userId: me.data.userId
      },
      header: {
        'content-type': 'application/json' // 默認(rèn)值
      },
      success: function (res) {
        console.log(res.data);
        var myVideoList = res.data.data.rows;
        wx.hideLoading();

        var newVideoList = me.data.myVideoList;
        me.setData({
          myVideoPage: page,
          myVideoList: newVideoList.concat(myVideoList),
          myVideoTotal: res.data.data.total,
          serverUrl: app.serverUrl
        });
      }
    })
  },

  getMyLikesList: function (page) {
    var me = this;
    var userId = me.data.userId;

    // 查詢視頻信息
    wx.showLoading();
    // 調(diào)用后端
    var serverUrl = app.serverUrl;
    wx.request({
      url: serverUrl + '/video/showMyLike/?userId=' + userId + '&page=' + page + '&pageSize=6',
      method: "POST",
      header: {
        'content-type': 'application/json' // 默認(rèn)值
      },
      success: function (res) {
        console.log(res.data);
        var likeVideoList = res.data.data.rows;
        wx.hideLoading();

        var newVideoList = me.data.likeVideoList;
        me.setData({
          likeVideoPage: page,
          likeVideoList: newVideoList.concat(likeVideoList),
          likeVideoTotal: res.data.data.total,
          serverUrl: app.serverUrl
        });
      }
    })
  },

  getMyFollowList: function (page) {
    var me = this;
    var userId = me.data.userId;

    // 查詢視頻信息
    wx.showLoading();
    // 調(diào)用后端
    var serverUrl = app.serverUrl;
    wx.request({
      url: serverUrl + '/video/showMyFollow/?userId=' + userId + '&page=' + page + '&pageSize=6',
      method: "POST",
      header: {
        'content-type': 'application/json' // 默認(rèn)值
      },
      success: function (res) {
        console.log(res.data);
        var followVideoList = res.data.data.rows;
        wx.hideLoading();

        var newVideoList = me.data.followVideoList;
        me.setData({
          followVideoPage: page,
          followVideoList: newVideoList.concat(followVideoList),
          followVideoTotal: res.data.data.total,
          serverUrl: app.serverUrl
        });
      }
    })
  },

  // 點(diǎn)擊跳轉(zhuǎn)到視頻詳情頁面
  showVideo: function (e) {

    console.log(e);

    var myWorkFalg = this.data.myWorkFalg;
    var myLikesFalg = this.data.myLikesFalg;
    var myFollowFalg = this.data.myFollowFalg;

    if (!myWorkFalg) {
      var videoList = this.data.myVideoList;
    } else if (!myLikesFalg) {
      var videoList = this.data.likeVideoList;
    } else if (!myFollowFalg) {
      var videoList = this.data.followVideoList;
    }

    var arrindex = e.target.dataset.arrindex;
    var videoInfo = JSON.stringify(videoList[arrindex]);

    wx.redirectTo({
      url: '../videoinfo/videoinfo?videoInfo=' + videoInfo
    })

  },

  // 到底部后觸發(fā)加載
  onReachBottom: function () {
    var myWorkFalg = this.data.myWorkFalg;
    var myLikesFalg = this.data.myLikesFalg;
    var myFollowFalg = this.data.myFollowFalg;

    if (!myWorkFalg) {
      var currentPage = this.data.myVideoPage;
      var totalPage = this.data.myVideoTotal;
      // 獲取總頁數(shù)進(jìn)行判斷锉走,如果當(dāng)前頁數(shù)和總頁數(shù)相等滨彻,則不分頁
      if (currentPage === totalPage) {
        wx.showToast({
          title: '已經(jīng)沒有視頻啦...',
          icon: "none"
        });
        return;
      }
      var page = currentPage + 1;
      this.getMyVideoList(page);
    } else if (!myLikesFalg) {
      var currentPage = this.data.likeVideoPage;
      var totalPage = this.data.myLikesTotal;
      // 獲取總頁數(shù)進(jìn)行判斷,如果當(dāng)前頁數(shù)和總頁數(shù)相等挪蹭,則不分頁
      if (currentPage === totalPage) {
        wx.showToast({
          title: '已經(jīng)沒有視頻啦...',
          icon: "none"
        });
        return;
      }
      var page = currentPage + 1;
      this.getMyLikesList(page);
    } else if (!myFollowFalg) {
      var currentPage = this.data.followVideoPage;
      var totalPage = this.data.followVideoTotal;
      // 獲取總頁數(shù)進(jìn)行判斷亭饵,如果當(dāng)前頁數(shù)和總頁數(shù)相等,則不分頁
      if (currentPage === totalPage) {
        wx.showToast({
          title: '已經(jīng)沒有視頻啦...',
          icon: "none"
        });
        return;
      }
      var page = currentPage + 1;
      this.getMyFollowList(page);
    }

  }

})

mine.wxml

<view>

  <view class='container'>
    <image src="{{faceImage}}" class="face" bindtap='uploadFace'></image>
    <label class='nickname'>{{nickname}}</label>

    <block wx:if='{{isMe}}'>
      <button size='mini' class='primary' bindtap='uploadVideo'> 上傳作品</button>
      <button size='mini' type='' class='logout' bindtap='logout'>注銷</button>
    </block>
    <block wx:if='{{!isMe}}'>
      <block wx:if='{{isFollow}}'>
        <button size='mini' type='' class='follow' data-followType='0' bindtap='followMe'>已關(guān)注</button>
      </block>
      <block wx:if='{{!isFollow}}'>
        <button size='mini' type='primary' class='follow' data-followType='1' bindtap='followMe'>關(guān)注我</button>
      </block>
    </block>

    <view class='container-row'>
      <label class='info-items'>{{fansCounts}} 粉絲</label>
      <label class='info-items'>{{followCounts}} 關(guān)注</label>
      <label class='info-items'>{{receiveLikeCounts}} 獲贊</label>
    </view>
  </view>

</view>

<view class="line"></view>

<view class='container-video'>
  <!-- 發(fā)布過的作品 -->
  <view class='{{videoSelClass}} {{isSelectedWork}}' bindtap='doSelectWork'>作品</view>
  <!-- 收藏的點(diǎn)贊的視頻 -->
  <view class='{{videoSelClass}} {{isSelectedLike}}' bindtap='doSelectLike'>收藏</view>
  <!-- 用戶關(guān)注過人發(fā)表的視頻 -->
  <view class='{{videoSelClass}} {{isSelectedFollow}}' bindtap='doSelectFollow'>關(guān)注</view>
</view>

<view class='container-video-list'>

  <view hidden='{{myWorkFalg}}'>
    <block wx:for="{{myVideoList}}">
      <image src='{{serverUrl}}{{item.coverPath}}' class='videoImage' mode="aspectFill" bindtap='showVideo' data-arrindex='{{index}}'></image>
    </block>
  </view>

  <view hidden='{{myLikesFalg}}'>
    <block wx:for="{{likeVideoList}}">
      <image src='{{serverUrl}}{{item.coverPath}}' class='videoImage' mode="aspectFill" bindtap='showVideo' data-arrindex='{{index}}'></image>
    </block>
  </view>

  <view hidden='{{myFollowFalg}}'>
    <block wx:for="{{followVideoList}}">
      <image src='{{serverUrl}}{{item.coverPath}}' class='videoImage' mode="aspectFill" bindtap='showVideo' data-arrindex='{{index}}'></image>
    </block>
  </view>

</view>

PS:基本操作梁厉,獲取作品列表辜羊,關(guān)注列表,收藏列表

?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請聯(lián)系作者
  • 序言:七十年代末词顾,一起剝皮案震驚了整個濱河市八秃,隨后出現(xiàn)的幾起案子,更是在濱河造成了極大的恐慌肉盹,老刑警劉巖昔驱,帶你破解...
    沈念sama閱讀 218,755評論 6 507
  • 序言:濱河連續(xù)發(fā)生了三起死亡事件,死亡現(xiàn)場離奇詭異垮媒,居然都是意外死亡舍悯,警方通過查閱死者的電腦和手機(jī)航棱,發(fā)現(xiàn)死者居然都...
    沈念sama閱讀 93,305評論 3 395
  • 文/潘曉璐 我一進(jìn)店門,熙熙樓的掌柜王于貴愁眉苦臉地迎上來萌衬,“玉大人饮醇,你說我怎么就攤上這事★踉ィ” “怎么了朴艰?”我有些...
    開封第一講書人閱讀 165,138評論 0 355
  • 文/不壞的土叔 我叫張陵,是天一觀的道長混移。 經(jīng)常有香客問我祠墅,道長,這世上最難降的妖魔是什么歌径? 我笑而不...
    開封第一講書人閱讀 58,791評論 1 295
  • 正文 為了忘掉前任毁嗦,我火速辦了婚禮,結(jié)果婚禮上回铛,老公的妹妹穿的比我還像新娘狗准。我一直安慰自己,他們只是感情好茵肃,可當(dāng)我...
    茶點(diǎn)故事閱讀 67,794評論 6 392
  • 文/花漫 我一把揭開白布腔长。 她就那樣靜靜地躺著,像睡著了一般验残。 火紅的嫁衣襯著肌膚如雪捞附。 梳的紋絲不亂的頭發(fā)上,一...
    開封第一講書人閱讀 51,631評論 1 305
  • 那天您没,我揣著相機(jī)與錄音鸟召,去河邊找鬼。 笑死氨鹏,一個胖子當(dāng)著我的面吹牛药版,可吹牛的內(nèi)容都是我干的。 我是一名探鬼主播喻犁,決...
    沈念sama閱讀 40,362評論 3 418
  • 文/蒼蘭香墨 我猛地睜開眼,長吁一口氣:“原來是場噩夢啊……” “哼何缓!你這毒婦竟也來了肢础?” 一聲冷哼從身側(cè)響起,我...
    開封第一講書人閱讀 39,264評論 0 276
  • 序言:老撾萬榮一對情侶失蹤碌廓,失蹤者是張志新(化名)和其女友劉穎传轰,沒想到半個月后,有當(dāng)?shù)厝嗽跇淞掷锇l(fā)現(xiàn)了一具尸體谷婆,經(jīng)...
    沈念sama閱讀 45,724評論 1 315
  • 正文 獨(dú)居荒郊野嶺守林人離奇死亡慨蛙,尸身上長有42處帶血的膿包…… 初始之章·張勛 以下內(nèi)容為張勛視角 年9月15日...
    茶點(diǎn)故事閱讀 37,900評論 3 336
  • 正文 我和宋清朗相戀三年辽聊,在試婚紗的時候發(fā)現(xiàn)自己被綠了。 大學(xué)時的朋友給我發(fā)了我未婚夫和他白月光在一起吃飯的照片期贫。...
    茶點(diǎn)故事閱讀 40,040評論 1 350
  • 序言:一個原本活蹦亂跳的男人離奇死亡跟匆,死狀恐怖,靈堂內(nèi)的尸體忽然破棺而出通砍,到底是詐尸還是另有隱情玛臂,我是刑警寧澤,帶...
    沈念sama閱讀 35,742評論 5 346
  • 正文 年R本政府宣布封孙,位于F島的核電站迹冤,受9級特大地震影響,放射性物質(zhì)發(fā)生泄漏虎忌。R本人自食惡果不足惜泡徙,卻給世界環(huán)境...
    茶點(diǎn)故事閱讀 41,364評論 3 330
  • 文/蒙蒙 一、第九天 我趴在偏房一處隱蔽的房頂上張望膜蠢。 院中可真熱鬧堪藐,春花似錦、人聲如沸狡蝶。這莊子的主人今日做“春日...
    開封第一講書人閱讀 31,944評論 0 22
  • 文/蒼蘭香墨 我抬頭看了看天上的太陽贪惹。三九已至苏章,卻和暖如春,著一層夾襖步出監(jiān)牢的瞬間奏瞬,已是汗流浹背枫绅。 一陣腳步聲響...
    開封第一講書人閱讀 33,060評論 1 270
  • 我被黑心中介騙來泰國打工, 沒想到剛下飛機(jī)就差點(diǎn)兒被人妖公主榨干…… 1. 我叫王不留硼端,地道東北人并淋。 一個月前我還...
    沈念sama閱讀 48,247評論 3 371
  • 正文 我出身青樓,卻偏偏與公主長得像珍昨,于是被迫代替她去往敵國和親县耽。 傳聞我的和親對象是個殘疾皇子,可洞房花燭夜當(dāng)晚...
    茶點(diǎn)故事閱讀 44,979評論 2 355

推薦閱讀更多精彩內(nèi)容

  • 到書 17歲少女戀上45歲離異大叔镣典,畫風(fēng)出奇的干凈兔毙。女主晶瑩剔透的雙眸,能不讓大叔動心嗎兄春!年輕就是好芭彀! 無限住人...
    老李3閱讀 542評論 7 3
  • 徘徊著的 在路上的 你要走嗎 易碎的 驕傲著 那也曾是我的模樣 沸騰著的 不安著的 你要去哪 謎一樣的 沉默著的 ...
    千里草閱讀 306評論 0 1
  • 櫻花青苔歸路赶舆,君書香何處哑姚。 消息競淺淺祭饭,今夜相思幾許,驟雨滿街叙量。 冬雨倡蝙,冬雨,一半因你而來宛乃,一半因風(fēng)吹去悠咱。
    我是張小生閱讀 87評論 1 3
  • 今年,00后的一代也有滿18歲的人了征炼。 2018年是一個不同的一年析既,這一年,90后也被拍在了沙灘上了谆奥。 在這個物質(zhì)...
    北望溫南否閱讀 334評論 1 1
  • 也不知是哪一朝代的老和尚眼坏,竟然給后人留下了一首通俗得再不能通俗、哲學(xué)得再不能哲學(xué)酸些、佛法得再不能佛法的《掃地歌》宰译,曰...
    儲建明閱讀 490評論 0 0