|
@@ -1,22 +1,215 @@
|
|
<template>
|
|
<template>
|
|
<view class="main">
|
|
<view class="main">
|
|
- 答复记录
|
|
|
|
|
|
+ <view class="one">
|
|
|
|
+ <input type="text" v-model="searchInfo.title" @input="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" @tap="toInfo(item)">
|
|
|
|
+ 1111
|
|
|
|
+ </view>
|
|
|
|
+ <view class="is_bottom" v-if="is_bottom">
|
|
|
|
+ <text>{{config.bottom_title||'到底了!'}}</text>
|
|
|
|
+ </view>
|
|
|
|
+ </view>
|
|
|
|
+ </scroll-view>
|
|
|
|
+ </view>
|
|
</view>
|
|
</view>
|
|
</template>
|
|
</template>
|
|
|
|
|
|
<script>
|
|
<script>
|
|
export default {
|
|
export default {
|
|
data() {
|
|
data() {
|
|
- return {}
|
|
|
|
|
|
+ return {
|
|
|
|
+ config: {},
|
|
|
|
+ user: {},
|
|
|
|
+ list: [],
|
|
|
|
+ total: 0,
|
|
|
|
+ skip: 0,
|
|
|
|
+ limit: 6,
|
|
|
|
+ page: 0,
|
|
|
|
+ // 数据是否触底
|
|
|
|
+ is_bottom: false,
|
|
|
|
+ scrollTop: 0,
|
|
|
|
+ }
|
|
|
|
+ },
|
|
|
|
+ onLoad: async function(e) {
|
|
|
|
+ const that = this;
|
|
|
|
+ that.searchToken();
|
|
|
|
+ that.searchConfig();
|
|
|
|
+ },
|
|
|
|
+ onShow: async function() {
|
|
|
|
+ const that = this;
|
|
|
|
+ // that.clearPage();
|
|
|
|
+ // await that.search();
|
|
|
|
+ },
|
|
|
|
+ onPullDownRefresh: async function() {
|
|
|
|
+ const that = this;
|
|
|
|
+ // that.clearPage();
|
|
|
|
+ // await that.search();
|
|
|
|
+ uni.stopPullDownRefresh();
|
|
},
|
|
},
|
|
methods: {
|
|
methods: {
|
|
-
|
|
|
|
|
|
+ searchToken() {
|
|
|
|
+ const that = this;
|
|
|
|
+ try {
|
|
|
|
+ const res = uni.getStorageSync('token');
|
|
|
|
+ if (res) that.$set(that, `user`, res);
|
|
|
|
+ } catch (e) {
|
|
|
|
+ uni.showToast({
|
|
|
|
+ title: err.errmsg,
|
|
|
|
+ icon: 'error',
|
|
|
|
+ duration: 2000
|
|
|
|
+ });
|
|
|
|
+ }
|
|
|
|
+ },
|
|
|
|
+ searchConfig() {
|
|
|
|
+ const that = this;
|
|
|
|
+ try {
|
|
|
|
+ const res = uni.getStorageSync('config');
|
|
|
|
+ if (res) that.$set(that, `config`, res);
|
|
|
|
+ } catch (e) {
|
|
|
|
+ uni.showToast({
|
|
|
|
+ title: err.errmsg,
|
|
|
|
+ icon: 'error',
|
|
|
|
+ duration: 2000
|
|
|
|
+ });
|
|
|
|
+ }
|
|
|
|
+ },
|
|
|
|
+ async search() {
|
|
|
|
+ const that = this;
|
|
|
|
+ let info = {
|
|
|
|
+ skip: that.skip,
|
|
|
|
+ limit: that.limit,
|
|
|
|
+ is_use: '0'
|
|
|
|
+ }
|
|
|
|
+ const res = await that.$api(`/article`, '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,
|
|
|
|
+ });
|
|
|
|
+ }
|
|
|
|
+ },
|
|
|
|
+ // 输入框
|
|
|
|
+ toInput(e) {
|
|
|
|
+ const that = this;
|
|
|
|
+ if (that.searchInfo.title) that.$set(that.searchInfo, `title`, e.detail.value)
|
|
|
|
+ else that.$set(that, `searchInfo`, {})
|
|
|
|
+ that.clearPage();
|
|
|
|
+ that.search();
|
|
|
|
+ },
|
|
|
|
+ // 查看详情
|
|
|
|
+ toInfo(item) {
|
|
|
|
+ uni.navigateTo({
|
|
|
|
+ url: `/pagesScience/science/index?id=${item.id||item._id}`
|
|
|
|
+ })
|
|
|
|
+ },
|
|
|
|
+ // 分页
|
|
|
|
+ toPage(e) {
|
|
|
|
+ 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);
|
|
|
|
+ },
|
|
|
|
+ // 清空列表
|
|
|
|
+ clearPage() {
|
|
|
|
+ const that = this;
|
|
|
|
+ that.$set(that, `list`, [])
|
|
|
|
+ that.$set(that, `skip`, 0)
|
|
|
|
+ that.$set(that, `limit`, 6)
|
|
|
|
+ that.$set(that, `page`, 0)
|
|
|
|
+ }
|
|
}
|
|
}
|
|
}
|
|
}
|
|
</script>
|
|
</script>
|
|
|
|
|
|
<style lang="scss" scoped>
|
|
<style lang="scss" scoped>
|
|
.main {
|
|
.main {
|
|
- padding: 2vw;
|
|
|
|
|
|
+ display: flex;
|
|
|
|
+ flex-direction: column;
|
|
|
|
+ width: 100vw;
|
|
|
|
+ height: 100vh;
|
|
|
|
+
|
|
|
|
+ .one {
|
|
|
|
+ display: flex;
|
|
|
|
+ justify-content: center;
|
|
|
|
+ align-items: center;
|
|
|
|
+ padding: 2vw;
|
|
|
|
+
|
|
|
|
+ input {
|
|
|
|
+ width: 100%;
|
|
|
|
+ padding: 2vw;
|
|
|
|
+ background-color: var(--f1Color);
|
|
|
|
+ font-size: var(--font14Size);
|
|
|
|
+ border-radius: 5px;
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ .two {
|
|
|
|
+ position: relative;
|
|
|
|
+ flex-grow: 1;
|
|
|
|
+ background-color: var(--f9Color);
|
|
|
|
+ margin: 2vw 0 0 0;
|
|
|
|
+
|
|
|
|
+ .list {
|
|
|
|
+ display: flex;
|
|
|
|
+ background-color: var(--mainColor);
|
|
|
|
+ border: 1px solid var(--f5Color);
|
|
|
|
+ padding: 2vw;
|
|
|
|
+ margin: 2vw 2vw 0 2vw;
|
|
|
|
+ border-radius: 5px;
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ .scroll-view {
|
|
|
|
+ position: absolute;
|
|
|
|
+ top: 0;
|
|
|
|
+ left: 0;
|
|
|
|
+ right: 0;
|
|
|
|
+ bottom: 0;
|
|
|
|
+
|
|
|
|
+ .list-scroll-view {
|
|
|
|
+ display: flex;
|
|
|
|
+ flex-direction: column;
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ .is_bottom {
|
|
|
|
+ width: 100%;
|
|
|
|
+ text-align: center;
|
|
|
|
+
|
|
|
|
+ text {
|
|
|
|
+ padding: 2vw 0;
|
|
|
|
+ display: inline-block;
|
|
|
|
+ color: var(--f85Color);
|
|
|
|
+ font-size: var(--font14Size);
|
|
|
|
+ }
|
|
}
|
|
}
|
|
</style>
|
|
</style>
|