123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236 |
- <template>
- <view class="content">
- <view class="one">
- <input type="text" v-model="searchInfo.title" @blur="toInput" placeholder="请输入视频名称">
- </view>
- <view class="two">
- <scroll-view scroll-y="true" class="scroll-view" @scrolltolower="toPage" @scroll="toScroll">
- <view class="list-scroll-view">
- <view class="two_1">
- <view class="list" v-for="(item,index) in list" :key="index" @tap="videoView(item)">
- <image class="image" :src="item.img_url&&item.img_url.length>0?item.img_url[0].url:''"
- mode="">
- </image>
- <view class="name textOver">
- {{item.title}}
- </view>
- <view class="other">
- <view class="other_1">
- <uni-icons type="eye" color="var(--rgbfff)" size="12"></uni-icons>
- {{item.view_num}}
- </view>
- <view class="other_2">
- {{item.time_num}}
- </view>
- </view>
- </view>
- </view>
- </view>
- </scroll-view>
- </view>
- </view>
- </template>
- <script>
- export default {
- data() {
- return {
- // 用户信息
- user: {},
- searchInfo: {},
- list: [],
- total: 0,
- page: 0,
- skip: 0,
- limit: 10,
- // 数据是否触底
- is_bottom: false,
- scrollTop: 0
- }
- },
- onLoad() {
- const that = this;
- that.searchUser()
- },
- onHide() {
- const that = this;
- // that.clearPage()
- },
- onPullDownRefresh: async function() {
- const that = this;
- that.clearPage();
- await that.search();
- uni.stopPullDownRefresh();
- },
- methods: {
- searchUser() {
- const that = this;
- uni.getStorage({
- key: 'token',
- success: (res) => {
- let user = that.$jwt(res.data);
- if (user) that.$set(that, `user`, user);
- that.search();
- },
- fail: (err) => {
- uni.showToast({
- title: '暂无用户信息,无法查询',
- icon: 'none'
- })
- }
- })
- },
- async search() {
- const that = this;
- let user = that.user;
- let info = {
- skip: that.skip,
- limit: that.limit,
- user_id: user._id
- }
- let res = await that.$api('likes', 'GET', {
- ...info,
- ...that.searchInfo,
- })
- if (res.errcode == '0') {
- let list = [...that.list, ...res.data]
- that.$set(that, `list`, list);
- that.$set(that, `total`, res.total);
- }
- },
- toInput(e) {
- const that = this;
- let title = e.detail.value;
- if (title) that.$set(that.searchInfo, `title`, title);
- else delete that.searchInfo.title;
- that.clearPage();
- that.search()
- },
- toPage() {
- const that = this;
- let list = that.list;
- let limit = that.limit;
- if (that.total > list.length) {
- uni.showLoading({
- title: '加载中',
- mask: true
- })
- let page = that.page + 1;
- that.$set(that, `page`, page)
- let skip = page * limit;
- that.$set(that, `skip`, skip)
- that.search();
- uni.hideLoading();
- } else that.$set(that, `is_bottom`, true)
- },
- toScroll(e) {
- const that = this;
- let up = that.scrollTop;
- that.$set(that, `scrollTop`, e.detail.scrollTop);
- let num = Math.sign(up - e.detail.scrollTop);
- if (num == 1) that.$set(that, `is_bottom`, false);
- },
- // 视频查看
- videoView(e) {
- uni.navigateTo({
- url: `/pagesVideo/video/index?id=${e._id}`
- })
- },
- // 清空列表
- clearPage() {
- const that = this;
- that.$set(that, `list`, [])
- that.$set(that, `skip`, 0)
- that.$set(that, `limit`, 10)
- that.$set(that, `page`, 0)
- if (!that.searchInfo.title) delete that.searchInfo.title;
- },
- },
- }
- </script>
- <style lang="scss">
- .content {
- background-color: var(--rgb111);
- .one {
- padding: 2vw;
- input {
- border: 1px solid var(--rgbf1f);
- border-radius: 5px;
- padding: 5px;
- font-size: 14px;
- color: var(--rgbfff);
- }
- }
- .two {
- flex-grow: 1;
- position: relative;
- .two_1 {
- display: flex;
- flex-wrap: wrap;
- .list {
- width: 48%;
- margin: 0 10px 10px 0;
- .image {
- width: 100%;
- height: 100px;
- overflow: hidden;
- border-radius: 5px;
- box-shadow: 0 0 5px var(--rgbf1f);
- margin: 0 0 5px 0;
- }
- .name {
- font-size: 14px;
- color: var(--rgbfff);
- margin: 0 0 5px 0;
- }
- .other {
- display: flex;
- color: var(--rgbfff);
- font-size: 12px;
- justify-content: space-between;
- }
- }
- .list:nth-child(2n) {
- margin: 0 0 10px 0;
- }
- }
- }
- }
- .scroll-view {
- position: absolute;
- top: 0;
- left: 0;
- right: 0;
- bottom: 0;
- .list-scroll-view {
- display: flex;
- flex-direction: column;
- padding: 0 2vw;
- }
- }
- .is_bottom {
- text-align: center;
- text {
- padding: 2vw 0;
- display: inline-block;
- color: #858585;
- font-size: 14px;
- }
- }
- </style>
|