123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236 |
- <template>
- <view>
- <view class="flex">
- <view class="list-item add-btn" >
- <uni-icons type="plus-filled" size="30" color="#333" @click="addVideo"></uni-icons>
- </view>
- <swiper class="swiper-container" :autoplay="false" :duration="1000" display-multiple-items="5">
- <swiper-item v-for="(item,index) in cate_list" :key="index" @click="changeItem(item,index)">
- <view class="list-item">
- <text :class="{active:active_index == index}">{{item.name}}</text>
- </view>
- </swiper-item>
- </swiper>
- </view>
-
- <scroll-view class="video-list" :style="{height:scrollHeight+'px',width:sys.windowWidth+'px'}" scroll-x="false" scroll-y="true" @scrolltolower="getVideoList">
- <view class="video-item" v-for="(item,index) in videoList" :key="index" @click="toDetail(item.id)">
- <image :src="static_url+item.gif" mode="aspectFill"></image>
- <view class="cover">
- <view class="flex align-center">
- <image @click.stop="handleUser(item.user_id)" :src="static_photo+item.user_info.face" class="avatar" alt="头像">
- <text class="text-white margin-left-sm name">{{item.user_info.username}}</text>
- </view>
- <view class="flex align-center" @click.stop="handleLike(item)">
- <text :class="{ 'text-red': item.is_fabulous == 1 }"
- class="icon text-xxl"></text>
- <text class="text-white margin-left-xs text-min">{{ item.fabulous }}</text>
- </view>
- </view>
- </view>
- <view class="nomore" v-if="videoList.length == 0">
- <image src="../../static/theme/default/nomore.png" mode="widthFix"></image>
- <text>没有更多了。。</text>
- </view>
- </scroll-view>
- </view>
- </template>
- <script>
- import _mixins from '@/common/_mixins';
- import _data from "@/common/_data";
- import uniIcons from '@/components/uni-icons/uni-icons.vue'
- import uniLoadMore from '@/components/uni-ui/uni-load-more/uni-load-more.vue'
- import uniStatusBar from '@/components/uni-ui/uni-status-bar/uni-status-bar.vue'
- export default{
- data(){
- return{
- cate_list:[],
- active_index:0,
- videoList:[],//视频列表
- current_page:1,
-
- scrollHeight:'',
- sys:{},//系统高度
- static_url:'',
- static_photo:'',
- }
- },
- components:{
- uniIcons,
- uniLoadMore,
- uniStatusBar
- },
- mounted() {
- const sys = uni.getSystemInfoSync();
- this.sys = {
- windowWidth: sys.windowWidth,
- windowHeight: sys.windowHeight,
- status:sys.statusBarHeight
- };
- console.log("this.sys",this.sys);
- this.scrollHeight = this.sys.windowHeight - 50;
- this.static_url = getApp().globalData.static_url;
- console.log(this.static_url,'this.static_url');
- this.static_photo = _data.staticPhoto();
- this.getCate();
- },
- methods:{
- // 获取分类
- getCate(){
- this.$httpSend({
- path: '/im/video.Share/category',
- success: (data) => {
- console.log("data", data);
- this.cate_list = data;
- this.getVideoList();
- }
- })
- },
- addVideo(){
- uni.navigateTo({
- url:'./add?type=video',
- });
- },
- toDetail(id) {
- uni.navigateTo({
- url: './detail?id=' + id,
- })
- },
- handleUser(user_no) {
- uni.navigateTo({
- url: `/pages/video/user?id=${user_no}`,
- });
- },
- async handleLike(item) {
- _mixins.methods.$httpSend({
- path: "/im/video.Share/fabulous",
- data: {
- id: item.id,
- },
- success: (data) => {
- if (data.code == 0) {
- item.is_fabulous = !item.is_fabulous;
- if (item.is_fabulous) {
- item.fabulous++;
- } else {
- item.fabulous--;
- }
- } else {
- uni.showToast({
- icon: "none",
- title: data.msg,
- });
- }
- },
- });
- },
- changeItem(e,index){
- this.active_index = index;
- this.current_page = 1;
- this.videoList = [];
- this.getVideoList();
- },
- getVideoList(){
- _mixins.methods.$httpSend({
- path: "/im/video.Share/video_lists",
- data: {
- type: this.cate_list[this.active_index]?this.cate_list[this.active_index].id:'',
- page:this.current_page
- },
- success: (data) => {
- this.last_page = data.last_page;
- if (this.current_page <= data.last_page) {
- this.current_page++;
- this.videoList = this.videoList.concat(data.data);
- }
- // console.log("this.videoList", this.videoList);
- },
- fail: (err) => {
- console.log("err", err);
- }
- });
- }
- }
- }
- </script>
- <style lang="scss" scoped>
- @import '@/static/css/common.css';
- .nomore{
- width: 200rpx;
- margin: 100rpx auto;
- image{
- width: 100%;
- height: auto;
- }
- }
- .swiper-container{
- height: 100rpx;
- background: #ffffff;
- flex: 1;
- }
- .scroll{
- white-space: nowrap;
- background: #ffffff;
- }
- .list-item{
- display: inline-block;
- width: 160rpx;
- height: 100rpx;
- line-height: 100rpx;
- text-align: center;
- text{
- color: #213547;
- }
- }
- .list-item .active{
- font-weight: bold;
- }
- .add-btn{
- display: inline-block;
- width: 100rpx;
- height: 100rpx;
- line-height: 100rpx;
- text-align: center;
- background: #fff;
- }
- .video-list{
-
- }
- .video-item{
- display: inline-block;
- width: 48%;
- height: 500rpx;
- border-radius: 10rpx;
- overflow: hidden;
- margin: 1%;
- position: relative;
- image{
- width: 100%;
- height: 100%;
- background-color: grey;
- }
- .cover{
- bottom: 0;
- height: 120rpx;
- position: absolute;
- left:0;
- width: 100%;
- display: flex;
- justify-content: space-between;
- align-items: center;
- box-sizing: border-box;
- padding: 10rpx;
- .avatar{
- width: 80rpx;
- height: 80rpx;
- border-radius: 50%;
- }
- .name{
- width:100rpx;//固定宽度
- overflow:hidden;
- text-overflow:ellipsis;
- white-space:nowrap;
- }
- }
- }
- </style>
|