123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370 |
- <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 class="main" v-for="(item, index) in tabItem.orderList" :key="index" @click="navTo('/pages/share/myarticle?id=' + item.id + '&type=' + tabCurrentIndex)">
- <view class="main-userInfo">
- <view class="avatar">
- <image :src="item.author" mode=""></image>
- </view>
- <view class="main-user-info">
- <view class="main-userName">{{item.title}}</view>
- <view class="main-user-time">{{item.add_time}}</view>
- </view>
- <view class="fenxiang flex">
- <image class="img-lj" src="../../static/icon/lj.png"></image>
- <view class="wen-lj">{{item.visit}}</view>
- </view>
- </view>
- <view class="text">
- <view>{{item.content}}</view>
- </view>
- <view class="fh-im">
- <image v-for="item in item.share_images" class="fh-img" :src="item" mode=""></image>
- </view>
- <view class="bot flex">
- <image class="del" src="../../static/icon/del.png" mode=""></image>
- <view @click.stop="del(item.id)" class="sc">删除</view>
- </view>
- </view>
- <!-- 订单列表 -->
- <uni-load-more :status="tabItem.loadingType"
- v-if="!(tabItem.orderList.length == 0 && tabItem.loaded)"></uni-load-more>
- </scroll-view>
- </swiper-item>
- </swiper>
- <button class="rele" @click="navTo('/pages/share/myarticle')" >发布素材</button>
- </view>
- </template>
- <script>
- import empty from '@/components/empty';
- import {
- my_article,
- delete_article,
- } from '@/api/user.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() {
- this.loadData();
- },
- onShow() {},
- 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: {
- //顶部tab点击
- tabClick(index) {
- this.tabCurrentIndex = index;
- },
- //swiper 切换
- changeTab(e) {
- this.tabCurrentIndex = e.target.current;
- this.loadData('tabChange');
- },
- dele(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('用户点击取消');
- }
- }
- });
- },
- navTo(url) {
- uni.navigateTo({
- url
- });
- },
- 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 = []
- data.list = data.list.map((e)=>{
- e.share_images = e.share_images.split(',');
- return e
- });
- 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
- })
- }
- arr.forEach(e => {
- e.add_time = getTime(e.add_time)
- })
- console.log(arr);
- 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,'233');
- });
- }
- }
- };
- </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;
- }
- }
- }
- }
- .main {
- margin: 20rpx;
- padding: 35rpx 20rpx 24rpx;
- background: #ffffff;
- width: 702rpx;
- border-radius: 30rpx;
- image {
- width: 100%;
- height: 100%;
- }
- .main-userInfo {
- display: flex;
- align-items: center;
- .avatar {
- width: 80rpx;
- height: 80rpx;
- background: #ffffff;
- border-radius: 50%;
- }
- .main-user-info {
- margin-left: 14rpx;
- line-height: 1;
- .main-userName {
- font-size: 28rpx;
- font-weight: bold;
- color: #000000;
- }
- .main-user-time {
- margin-top: 14rpx;
- font-size: 21rpx;
- font-family: PingFang SC;
- font-weight: 500;
- color: #666666;
- }
- }
- .fenxiang {
- padding-left: 310rpx;
- .img-lj {
- width: 28rpx;
- height: 28rpx;
- }
- .wen-lj {
- font-size: 28rpx;
- color: #FF6F0F;
- padding-left: 10rpx;
- }
- }
- }
- .text {
- word-wrap: break-word;
- word-break: normal;
- margin: 20rpx 0rpx;
- font-size: 28rpx;
- font-weight: 500;
- color: #666666;
- }
- .fh-im {
- .fh-img {
- // margin: auto 10rpx;
- margin: 10rpx 21rpx 0rpx 0rpx;
- width: 200rpx;
- height: 200rpx;
- // padding: 10rpx;
- }
- }
- .bot {
- .del {
- margin-left: 540rpx;
- width: 24rpx;
- height: 28rpx;
- }
- .sc {
- padding-right: 40rpx;
- font-size: 24rpx;
- font-weight: 500;
- color: #FF4C4C;
- }
- }
- }
- .rele {
- position: fixed;
- width: 750rpx;
- bottom: 0rpx;
- background-color: #FF6F0F;
- color: #ffffff;
- }
- .swiper-box {
- margin-top: 20rpx;
- .tab-content {
- position: relative;
- }
- }
- </style>
|