123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397 |
- <template>
- <view class="content">
- <view class="navbar">
- <view v-for="(item, index) in navList" :key="index" class="nav-item"
- :class="{ current: tabCurrentIndex === index }" @click="tabClick(index)">{{ item.text }}</view>
- </view>
- <swiper :current="tabCurrentIndex" :style="{ height: height }" class="swiper-box" duration="300"
- @change="changeTab">
- <swiper-item class="tab-content" v-for="(tabItem, tabIndex) in navList" :key="tabIndex">
- <scroll-view scroll-y="true" class="list-scroll-content" :class="{ yan: tabCurrentIndex == 0 }"
- @scrolltolower="loadData">
- <!-- 空白页 -->
- <empty v-if="tabItem.loaded === true && tabItem.orderList.length === 0"></empty>
- <!-- 订单列表 -->
- <view v-else>
- <view class="order-item flex" v-for="(item, index) in tabItem.orderList" :key="index"
- @click="navTo('/pages/info/myarticle?id=' + item.id + '&type=' + tabCurrentIndex)">
- <view class="order-image">
- <image :src="item.image_input[0]" mode=""></image>
- </view>
- <view class="order-info">
- <view class="order-title clamp2">{{ item.title }}</view>
- <view class="order-info-main flex">
- <view class="order-time">{{ item.add_time }}</view>
- <view class="order-btnBox flex" v-if="tabCurrentIndex == 0">
- <view class="order-btn-item"
- @click.stop="navTo('/pages/info/myarticle?id=' + item.id)">
- <view class="order-btn-icon">
- <image src="../../static/icon/bj.png" mode=""></image>
- </view>
- <view class="order-btn-font">编辑</view>
- </view>
- <view class="order-btn-item" @click.stop="del(item.id)">
- <view class="order-btn-icon1">
- <image src="../../static/icon/sc.png" mode=""></image>
- </view>
- <view class="order-btn-font1">删除</view>
- </view>
- </view>
- </view>
- </view>
- <view class="cgsb" v-if="item.check_status !=0">
- {{item.check_status == 1?'审核成功':'审核失败'}}
- </view>
- </view>
- </view>
- <uni-load-more :status="tabItem.loadingType"
- v-if="!(tabItem.orderList.length == 0 && tabItem.loaded)"></uni-load-more>
- </scroll-view>
- <view class="btn" @click="navTo('/pages/info/myarticle')" v-if="tabCurrentIndex == 0">发帖</view>
- </swiper-item>
- </swiper>
- </view>
- </template>
- <script>
- import empty from '@/components/empty';
- import {
- delete_article,
- my_article
- } from '@/api/activity.js';
- import {
- getTime
- } from '@/utils/rocessor.js'
- export default {
- components: {
- empty
- },
- data() {
- return {
- height: '',
- tabCurrentIndex: 0,
- navList: [{
- type: 0,
- state: -1,
- text: '草稿箱',
- loadingType: 'more',
- orderList: [],
- page: 1, //当前页数
- limit: 10 //每次信息条数
- },
- {
- type: 1,
- state: 1,
- text: '已审核',
- loadingType: 'more',
- orderList: [],
- page: 1, //当前页数
- limit: 10 //每次信息条数
- },
- {
- type: 1,
- state: 0,
- text: '审核中',
- loadingType: 'more',
- orderList: [],
- page: 1, //当前页数
- limit: 10 //每次信息条数
- }
- ]
- };
- },
- onLoad(opt) {
- this.tabCurrentIndex = opt.id * 1;
- },
- onShow() {
- this.loadData();
- },
- onReachBottom() {},
- onReady(res) {
- var _this = this;
- uni.getSystemInfo({
- success: resu => {
- const query = uni.createSelectorQuery();
- query.select('.swiper-box').boundingClientRect();
- query.exec(function(res) {
- _this.height = resu.windowHeight - res[0].top + 'px';
- console.log('打印页面的剩余高度', _this.height);
- });
- },
- fail: res => {}
- });
- },
- methods: {
- //swiper 切换
- changeTab(e) {
- this.tabCurrentIndex = e.target.current;
- this.loadData('tabChange');
- },
- //顶部tab点击
- tabClick(index) {
- this.tabCurrentIndex = index;
- },
- navTo(url) {
- uni.navigateTo({
- url
- });
- },
- // 删除草稿
- del(id) {
- const obj = this;
- uni.showModal({
- title: '提示',
- content: '是否删除这个草稿',
- success: function(res) {
- if (res.confirm) {
- delete_article({}, id).then(({
- data
- }) => {
- obj.$api.msg('删除成功');
- obj.loadData('shua');
- });
- } else if (res.cancel) {
- console.log('用户点击取消');
- }
- }
- });
- },
- async loadData(source) {
- let obj = this;
- //这里是将订单挂载到tab列表下
- let index = this.tabCurrentIndex;
- let navItem = this.navList[index];
- let state = navItem.state;
- let type = navItem.type;
- if (source === 'shua') {
- navItem.loadingType = 'more';
- navItem.page = 1;
- navItem.limit = 10;
- navItem.orderList = [];
- }
- if (source === 'tabChange' && navItem.loaded === true) {
- //tab切换只有第一次需要加载数据
- return;
- }
- if (navItem.loadingType === 'loading') {
- //防止重复加载
- return;
- }
- // 修改当前对象状态为加载中
- navItem.loadingType = 'loading';
- my_article({
- page: navItem.page,
- limit: navItem.limit,
- state: state
- }, type)
- .then(({
- data
- }) => {
- let arr = []
- if (state == -1) {
- arr = data.list
- }
- if (state == 0) {
- arr = data.list.filter(e => {
- return e.check_status == 0
- })
- }
- if (state == 1) {
- arr = data.list.filter(e => {
- return e.check_status != 0
- })
- }
- console.log(arr);
- console.log(data, '123456');
- arr.forEach(e => {
- e.add_time = getTime(e.add_time)
- })
- navItem.orderList = navItem.orderList.concat(arr);
- navItem.page++;
- if (navItem.limit == data.list.length) {
- navItem.loadingType = 'more';
- } else {
- navItem.loadingType = 'noMore';
- }
- obj.$set(navItem, 'loaded', true);
- })
- .catch(e => {
- console.log(e);
- });
- }
- }
- };
- </script>
- <style lang="scss">
- page,
- .content {
- min-height: 100%;
- height: auto;
- }
- .navbar {
- display: flex;
- height: 88rpx;
- padding: 0 5px;
- background: #fff;
- box-shadow: 0 1px 5px rgba(0, 0, 0, 0.06);
- position: relative;
- z-index: 10;
- .nav-item {
- flex: 1;
- display: flex;
- justify-content: center;
- align-items: center;
- height: 100%;
- font-size: 15px;
- color: #999999;
- position: relative;
- &.current {
- color: #000;
- &:after {
- content: '';
- position: absolute;
- left: 50%;
- bottom: 0;
- transform: translateX(-50%);
- width: 44px;
- height: 0;
- border-bottom: 2px solid #c54b4a;
- }
- }
- }
- }
- //列表
- .swiper-box {
- margin-top: 20rpx;
- .order-item {
- padding: 22rpx 24rpx 24rpx;
- border-bottom: 1px solid #eeeeee;
- justify-content: flex-start;
- position: relative;
- .cgsb {
- position: absolute;
- bottom: 30rpx;
- right: 30rpx;
- color: red;
- font-size: 30rpx;
- font-family: PingFang SC;
- font-weight: 500;
- }
- image {
- width: 100%;
- height: 100%;
- }
- .order-image {
- flex-shrink: 0;
- width: 200rpx;
- height: 160rpx;
- }
- .order-info {
- margin-left: 16rpx;
- width: 100%;
- display: flex;
- flex-direction: column;
- justify-content: space-between;
- .order-title {
- font-size: 30rpx;
- font-family: PingFang SC;
- font-weight: 500;
- color: #333333;
- }
- .order-info-main {
- margin-top: 20rpx;
- .order-time {
- font-size: 24rpx;
- font-family: PingFang SC;
- font-weight: 500;
- color: #999999;
- }
- .order-btnBox {
- justify-content: flex-start;
- .order-btn-item {
- display: flex;
- align-items: center;
- margin: 0 10rpx;
- .order-btn-icon {
- width: 30rpx;
- height: 30rpx;
- }
- .order-btn-font {
- margin-left: 10rpx;
- font-size: 26rpx;
- font-family: PingFang SC;
- font-weight: 500;
- color: #000000;
- }
- .order-btn-icon1 {
- width: 30rpx;
- height: 30rpx;
- }
- .order-btn-font1 {
- margin-left: 10rpx;
- font-size: 26rpx;
- font-family: PingFang SC;
- font-weight: 500;
- color: #ff4c4c;
- }
- }
- }
- }
- }
- }
- }
- .list-scroll-content {
- background: #ffffff;
- height: 100%;
- .yan {
- padding-bottom: 100rpx;
- }
- }
- .tab-content {
- position: relative;
- }
- .btn {
- position: absolute;
- bottom: 20rpx;
- left: 0;
- right: 0;
- display: flex;
- justify-content: center;
- align-items: center;
- width: 560rpx;
- height: 76rpx;
- background: #000000;
- border-radius: 38rpx;
- font-size: 34rpx;
- font-family: PingFang SC;
- font-weight: 500;
- color: #ffffff;
- margin: 0 auto;
- }
- </style>
|