123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226 |
- <template>
- <view class="content">
- <view class="one">
- <input type="text" v-model="searchInfo.name" @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="list" v-for="(item, index) in list" :key="index">
- <view class="name">
- <text>{{ index + 1 }}.</text>
- <text>{{ item.name }}</text>
- </view>
- <view class="other">
- <view class="other_1">
- <text>视频流:</text>
- <text>{{ item.path||'暂无视频流' }}</text>
- </view>
- </view>
- <view class="btn">
- <button type="primary" size="mini" @tap="toPlay(item)">
- 播放视频
- </button>
- </view>
- </view>
- </view>
- </scroll-view>
- </view>
- <view class="is_bottom" v-if="is_bottom">
- <text>到底了,嘻嘻!</text>
- </view>
- </view>
- </template>
- <script>
- export default {
- data() {
- return {
- // 查询
- searchInfo: {},
- list: [],
- total: 0,
- page: 0,
- skip: 0,
- limit: 10,
- // 数据是否触底
- is_bottom: false,
- scrollTop: 0
- };
- },
- onLoad() {
- const that = this;
- that.search();
- },
- onPullDownRefresh: async function() {
- const that = this;
- that.clearPage();
- await that.search();
- uni.stopPullDownRefresh();
- },
- methods: {
- async search() {
- const that = this;
- let info = {
- skip: that.skip,
- limit: that.limit,
- is_use: "0"
- };
- let res = await that.$api("test", "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)
- } else {
- uni.showToast({
- title: res.errmsg,
- icon: 'icon'
- });
- }
- },
- // 分页
- 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);
- },
- // 输入框
- toInput(e) {
- const that = this;
- if (e.detail.value) that.$set(that.searchInfo, `name`, e.detail.value);
- else that.$set(that, `searchInfo`, {});
- that.clearPage();
- that.search();
- },
- toPlay(e) {
- if (e.path) {
- uni.navigateTo({
- url: `/pagesHome/home/video?path=${e.path}&&name=${e.name}`,
- });
- } else {
- uni.showToast({
- title: '暂无视频流,无法播放',
- icon: 'none'
- });
- }
- },
- // 清空列表
- clearPage() {
- const that = this;
- that.$set(that, `list`, [])
- that.$set(that, `skip`, 0)
- that.$set(that, `limit`, 10)
- that.$set(that, `page`, 0)
- }
- },
- };
- </script>
- <style lang="scss">
- .content {
- .one {
- border-bottom: 1px solid #000000;
- input {
- padding: 2vw;
- background-color: #f1f1f1;
- font-size: 14px;
- border-radius: 5px;
- }
- }
- .two {
- position: relative;
- flex-grow: 1;
- padding: 0 10px;
- .list {
- // width: 90%;
- margin: 10px 0 0 0;
- padding: 10px;
- border-radius: 5px;
- box-shadow: 0 0 5px #cccccc;
- .name {
- font-size: 16px;
- font-weight: bold;
- margin: 0 0 5px 0;
- }
- .other {
- margin: 0 0 10px 0;
- .other_1 {
- margin: 0 0 5px 0;
- text {
- font-size: 14px;
- color: #858585;
- }
- text:last-child {
- color: #000000;
- word-break: break-all;
- }
- }
- }
- .btn {
- text-align: center;
- }
- }
- .list:last-child {
- margin: 10px 0;
- }
- }
- }
- .scroll-view {
- position: absolute;
- top: 0;
- left: 0;
- right: 0;
- bottom: 0;
- .list-scroll-view {
- display: flex;
- flex-direction: column;
- padding: 0 10px;
- }
- }
- .is_bottom {
- text-align: center;
- text {
- padding: 2vw 0;
- display: inline-block;
- color: #858585;
- font-size: 14px;
- }
- }
- </style>
|